--- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java 2019-04-16 10:39:18.232800700 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java 2019-04-16 10:39:17.773687000 -0700 @@ -56,7 +56,7 @@ abstract IntVector uOp(FUnOp f); - abstract IntVector uOp(Mask m, FUnOp f); + abstract IntVector uOp(VectorMask m, FUnOp f); // Binary operator @@ -66,7 +66,7 @@ abstract IntVector bOp(Vector v, FBinOp f); - abstract IntVector bOp(Vector v, Mask m, FBinOp f); + abstract IntVector bOp(Vector v, VectorMask m, FBinOp f); // Trinary operator @@ -76,7 +76,7 @@ abstract IntVector tOp(Vector v1, Vector v2, FTriOp f); - abstract IntVector tOp(Vector v1, Vector v2, Mask m, FTriOp f); + abstract IntVector tOp(Vector v1, Vector v2, VectorMask m, FTriOp f); // Reduction operator @@ -88,7 +88,7 @@ boolean apply(int i, int a, int b); } - abstract Mask bTest(Vector v, FBinTest f); + abstract VectorMask bTest(Vector v, FBinTest f); // Foreach @@ -98,7 +98,7 @@ abstract void forEach(FUnCon f); - abstract void forEach(Mask m, FUnCon f); + abstract void forEach(VectorMask m, FUnCon f); // Static factories @@ -111,7 +111,7 @@ */ @ForceInline @SuppressWarnings("unchecked") - public static IntVector zero(Species species) { + public static IntVector zero(VectorSpecies species) { return VectorIntrinsics.broadcastCoerced((Class) species.boxType(), int.class, species.length(), 0, species, ((bits, s) -> ((IntSpecies)s).op(i -> (int)bits))); @@ -125,7 +125,7 @@ *

* This method behaves as if it returns the result of calling the * byte buffer, offset, and mask accepting - * {@link #fromByteBuffer(Species, ByteBuffer, int, Mask) method} as follows: + * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask) method} as follows: *

{@code
      * return this.fromByteBuffer(ByteBuffer.wrap(a), i, this.maskAllTrue());
      * }
@@ -139,7 +139,7 @@ */ @ForceInline @SuppressWarnings("unchecked") - public static IntVector fromByteArray(Species species, byte[] a, int ix) { + public static IntVector fromByteArray(VectorSpecies species, byte[] a, int ix) { Objects.requireNonNull(a); ix = VectorIntrinsics.checkIndex(ix, a.length, species.bitSize() / Byte.SIZE); return VectorIntrinsics.load((Class) species.boxType(), int.class, species.length(), @@ -161,7 +161,7 @@ *

* This method behaves as if it returns the result of calling the * byte buffer, offset, and mask accepting - * {@link #fromByteBuffer(Species, ByteBuffer, int, Mask) method} as follows: + * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask) method} as follows: *

{@code
      * return this.fromByteBuffer(ByteBuffer.wrap(a), i, m);
      * }
@@ -180,7 +180,7 @@ * {@code i >= a.length - (N * this.elementSize() / Byte.SIZE)} */ @ForceInline - public static IntVector fromByteArray(Species species, byte[] a, int ix, Mask m) { + public static IntVector fromByteArray(VectorSpecies species, byte[] a, int ix, VectorMask m) { return zero(species).blend(fromByteArray(species, a, ix), m); } @@ -200,7 +200,7 @@ */ @ForceInline @SuppressWarnings("unchecked") - public static IntVector fromArray(Species species, int[] a, int i){ + public static IntVector fromArray(VectorSpecies species, int[] a, int i){ Objects.requireNonNull(a); i = VectorIntrinsics.checkIndex(i, a.length, species.length()); return VectorIntrinsics.load((Class) species.boxType(), int.class, species.length(), @@ -229,7 +229,7 @@ * is set {@code i > a.length - N} */ @ForceInline - public static IntVector fromArray(Species species, int[] a, int i, Mask m) { + public static IntVector fromArray(VectorSpecies species, int[] a, int i, VectorMask m) { return zero(species).blend(fromArray(species, a, i), m); } @@ -256,7 +256,7 @@ */ @ForceInline @SuppressWarnings("unchecked") - public static IntVector fromArray(Species species, int[] a, int i, int[] indexMap, int j) { + public static IntVector fromArray(VectorSpecies species, int[] a, int i, int[] indexMap, int j) { Objects.requireNonNull(a); Objects.requireNonNull(indexMap); @@ -269,7 +269,7 @@ return VectorIntrinsics.loadWithMap((Class) species.boxType(), int.class, species.length(), IntVector.species(species.indexShape()).boxType(), a, Unsafe.ARRAY_INT_BASE_OFFSET, vix, a, i, indexMap, j, species, - (int[] c, int idx, int[] iMap, int idy, Species s) -> + (int[] c, int idx, int[] iMap, int idy, VectorSpecies s) -> ((IntSpecies)s).op(n -> c[idx + iMap[idy+n]])); } @@ -299,7 +299,7 @@ */ @ForceInline @SuppressWarnings("unchecked") - public static IntVector fromArray(Species species, int[] a, int i, Mask m, int[] indexMap, int j) { + public static IntVector fromArray(VectorSpecies species, int[] a, int i, VectorMask m, int[] indexMap, int j) { // @@@ This can result in out of bounds errors for unset mask lanes return zero(species).blend(fromArray(species, a, i, indexMap, j), m); } @@ -314,7 +314,7 @@ *

* This method behaves as if it returns the result of calling the * byte buffer, offset, and mask accepting - * {@link #fromByteBuffer(Species, ByteBuffer, int, Mask)} method} as follows: + * {@link #fromByteBuffer(VectorSpecies, ByteBuffer, int, VectorMask)} method} as follows: *

{@code
      *   return this.fromByteBuffer(b, i, this.maskAllTrue())
      * }
@@ -331,7 +331,7 @@ */ @ForceInline @SuppressWarnings("unchecked") - public static IntVector fromByteBuffer(Species species, ByteBuffer bb, int ix) { + public static IntVector fromByteBuffer(VectorSpecies species, ByteBuffer bb, int ix) { if (bb.order() != ByteOrder.nativeOrder()) { throw new IllegalArgumentException(); } @@ -383,7 +383,7 @@ * {@code i >= b.limit() - (N * this.elementSize() / Byte.SIZE)} */ @ForceInline - public static IntVector fromByteBuffer(Species species, ByteBuffer bb, int ix, Mask m) { + public static IntVector fromByteBuffer(VectorSpecies species, ByteBuffer bb, int ix, VectorMask m) { return zero(species).blend(fromByteBuffer(species, bb, ix), m); } @@ -398,7 +398,7 @@ */ @ForceInline @SuppressWarnings("unchecked") - public static IntVector broadcast(Species s, int e) { + public static IntVector broadcast(VectorSpecies s, int e) { return VectorIntrinsics.broadcastCoerced( (Class) s.boxType(), int.class, s.length(), e, s, @@ -421,7 +421,7 @@ */ @ForceInline @SuppressWarnings("unchecked") - public static IntVector scalars(Species s, int... es) { + public static IntVector scalars(VectorSpecies s, int... es) { Objects.requireNonNull(es); int ix = VectorIntrinsics.checkIndex(0, es.length, s.length()); return VectorIntrinsics.load((Class) s.boxType(), int.class, s.length(), @@ -441,7 +441,7 @@ * value {@code e} */ @ForceInline - public static final IntVector single(Species s, int e) { + public static final IntVector single(VectorSpecies s, int e) { return zero(s).with(0, e); } @@ -456,235 +456,11 @@ * @return a vector where each lane elements is set to a randomly * generated primitive value */ - public static IntVector random(Species s) { + public static IntVector random(VectorSpecies s) { ThreadLocalRandom r = ThreadLocalRandom.current(); return ((IntSpecies)s).op(i -> r.nextInt()); } - /** - * Returns a mask where each lane is set or unset according to given - * {@code boolean} values - *

- * For each mask lane, where {@code N} is the mask lane index, - * if the given {@code boolean} value at index {@code N} is {@code true} - * then the mask lane at index {@code N} is set, otherwise it is unset. - * - * @param species mask species - * @param bits the given {@code boolean} values - * @return a mask where each lane is set or unset according to the given {@code boolean} value - * @throws IndexOutOfBoundsException if {@code bits.length < species.length()} - */ - @ForceInline - public static Mask maskFromValues(Species species, boolean... bits) { - if (species.boxType() == IntMaxVector.class) - return new IntMaxVector.IntMaxMask(bits); - switch (species.bitSize()) { - case 64: return new Int64Vector.Int64Mask(bits); - case 128: return new Int128Vector.Int128Mask(bits); - case 256: return new Int256Vector.Int256Mask(bits); - case 512: return new Int512Vector.Int512Mask(bits); - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - - // @@@ This is a bad implementation -- makes lambdas capturing -- fix this - static Mask trueMask(Species species) { - if (species.boxType() == IntMaxVector.class) - return IntMaxVector.IntMaxMask.TRUE_MASK; - switch (species.bitSize()) { - case 64: return Int64Vector.Int64Mask.TRUE_MASK; - case 128: return Int128Vector.Int128Mask.TRUE_MASK; - case 256: return Int256Vector.Int256Mask.TRUE_MASK; - case 512: return Int512Vector.Int512Mask.TRUE_MASK; - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - - static Mask falseMask(Species species) { - if (species.boxType() == IntMaxVector.class) - return IntMaxVector.IntMaxMask.FALSE_MASK; - switch (species.bitSize()) { - case 64: return Int64Vector.Int64Mask.FALSE_MASK; - case 128: return Int128Vector.Int128Mask.FALSE_MASK; - case 256: return Int256Vector.Int256Mask.FALSE_MASK; - case 512: return Int512Vector.Int512Mask.FALSE_MASK; - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - - /** - * Loads a mask from a {@code boolean} array starting at an offset. - *

- * For each mask lane, where {@code N} is the mask lane index, - * if the array element at index {@code ix + N} is {@code true} then the - * mask lane at index {@code N} is set, otherwise it is unset. - * - * @param species mask species - * @param bits the {@code boolean} array - * @param ix the offset into the array - * @return the mask loaded from a {@code boolean} array - * @throws IndexOutOfBoundsException if {@code ix < 0}, or - * {@code ix > bits.length - species.length()} - */ - @ForceInline - @SuppressWarnings("unchecked") - public static Mask maskFromArray(Species species, boolean[] bits, int ix) { - Objects.requireNonNull(bits); - ix = VectorIntrinsics.checkIndex(ix, bits.length, species.length()); - return VectorIntrinsics.load((Class>) species.maskType(), int.class, species.length(), - bits, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_BOOLEAN_BASE_OFFSET, - bits, ix, species, - (c, idx, s) -> (Mask) ((IntSpecies)s).opm(n -> c[idx + n])); - } - - /** - * Returns a mask where all lanes are set. - * - * @param species mask species - * @return a mask where all lanes are set - */ - @ForceInline - @SuppressWarnings("unchecked") - public static Mask maskAllTrue(Species species) { - return VectorIntrinsics.broadcastCoerced((Class>) species.maskType(), int.class, species.length(), - (int)-1, species, - ((z, s) -> trueMask(s))); - } - - /** - * Returns a mask where all lanes are unset. - * - * @param species mask species - * @return a mask where all lanes are unset - */ - @ForceInline - @SuppressWarnings("unchecked") - public static Mask maskAllFalse(Species species) { - return VectorIntrinsics.broadcastCoerced((Class>) species.maskType(), int.class, species.length(), - 0, species, - ((z, s) -> falseMask(s))); - } - - /** - * Returns a shuffle of mapped indexes where each lane element is - * the result of applying a mapping function to the corresponding lane - * index. - *

- * Care should be taken to ensure Shuffle values produced from this - * method are consumed as constants to ensure optimal generation of - * code. For example, values held in static final fields or values - * held in loop constant local variables. - *

- * This method behaves as if a shuffle is created from an array of - * mapped indexes as follows: - *

{@code
-     *   int[] a = new int[species.length()];
-     *   for (int i = 0; i < a.length; i++) {
-     *       a[i] = f.applyAsInt(i);
-     *   }
-     *   return this.shuffleFromValues(a);
-     * }
- * - * @param species shuffle species - * @param f the lane index mapping function - * @return a shuffle of mapped indexes - */ - @ForceInline - public static Shuffle shuffle(Species species, IntUnaryOperator f) { - if (species.boxType() == IntMaxVector.class) - return new IntMaxVector.IntMaxShuffle(f); - switch (species.bitSize()) { - case 64: return new Int64Vector.Int64Shuffle(f); - case 128: return new Int128Vector.Int128Shuffle(f); - case 256: return new Int256Vector.Int256Shuffle(f); - case 512: return new Int512Vector.Int512Shuffle(f); - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - - /** - * Returns a shuffle where each lane element is the value of its - * corresponding lane index. - *

- * This method behaves as if a shuffle is created from an identity - * index mapping function as follows: - *

{@code
-     *   return this.shuffle(i -> i);
-     * }
- * - * @param species shuffle species - * @return a shuffle of lane indexes - */ - @ForceInline - public static Shuffle shuffleIota(Species species) { - if (species.boxType() == IntMaxVector.class) - return new IntMaxVector.IntMaxShuffle(AbstractShuffle.IDENTITY); - switch (species.bitSize()) { - case 64: return new Int64Vector.Int64Shuffle(AbstractShuffle.IDENTITY); - case 128: return new Int128Vector.Int128Shuffle(AbstractShuffle.IDENTITY); - case 256: return new Int256Vector.Int256Shuffle(AbstractShuffle.IDENTITY); - case 512: return new Int512Vector.Int512Shuffle(AbstractShuffle.IDENTITY); - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - - /** - * Returns a shuffle where each lane element is set to a given - * {@code int} value logically AND'ed by the species length minus one. - *

- * For each shuffle lane, where {@code N} is the shuffle lane index, the - * the {@code int} value at index {@code N} logically AND'ed by - * {@code species.length() - 1} is placed into the resulting shuffle at - * lane index {@code N}. - * - * @param species shuffle species - * @param ixs the given {@code int} values - * @return a shuffle where each lane element is set to a given - * {@code int} value - * @throws IndexOutOfBoundsException if the number of int values is - * {@code < species.length()} - */ - @ForceInline - public static Shuffle shuffleFromValues(Species species, int... ixs) { - if (species.boxType() == IntMaxVector.class) - return new IntMaxVector.IntMaxShuffle(ixs); - switch (species.bitSize()) { - case 64: return new Int64Vector.Int64Shuffle(ixs); - case 128: return new Int128Vector.Int128Shuffle(ixs); - case 256: return new Int256Vector.Int256Shuffle(ixs); - case 512: return new Int512Vector.Int512Shuffle(ixs); - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - - /** - * Loads a shuffle from an {@code int} array starting at an offset. - *

- * For each shuffle lane, where {@code N} is the shuffle lane index, the - * array element at index {@code i + N} logically AND'ed by - * {@code species.length() - 1} is placed into the resulting shuffle at lane - * index {@code N}. - * - * @param species shuffle species - * @param ixs the {@code int} array - * @param i the offset into the array - * @return a shuffle loaded from the {@code int} array - * @throws IndexOutOfBoundsException if {@code i < 0}, or - * {@code i > a.length - species.length()} - */ - @ForceInline - public static Shuffle shuffleFromArray(Species species, int[] ixs, int i) { - if (species.boxType() == IntMaxVector.class) - return new IntMaxVector.IntMaxShuffle(ixs, i); - switch (species.bitSize()) { - case 64: return new Int64Vector.Int64Shuffle(ixs, i); - case 128: return new Int128Vector.Int128Shuffle(ixs, i); - case 256: return new Int256Vector.Int256Shuffle(ixs, i); - case 512: return new Int512Vector.Int512Shuffle(ixs, i); - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - // Ops @Override @@ -703,7 +479,7 @@ public abstract IntVector add(int s); @Override - public abstract IntVector add(Vector v, Mask m); + public abstract IntVector add(Vector v, VectorMask m); /** * Adds this vector to broadcast of an input scalar, @@ -717,7 +493,7 @@ * @return the result of adding this vector to the broadcast of an input * scalar */ - public abstract IntVector add(int s, Mask m); + public abstract IntVector add(int s, VectorMask m); @Override public abstract IntVector sub(Vector v); @@ -735,7 +511,7 @@ public abstract IntVector sub(int s); @Override - public abstract IntVector sub(Vector v, Mask m); + public abstract IntVector sub(Vector v, VectorMask m); /** * Subtracts the broadcast of an input scalar from this vector, selecting @@ -749,7 +525,7 @@ * @return the result of subtracting the broadcast of an input * scalar from this vector */ - public abstract IntVector sub(int s, Mask m); + public abstract IntVector sub(int s, VectorMask m); @Override public abstract IntVector mul(Vector v); @@ -767,7 +543,7 @@ public abstract IntVector mul(int s); @Override - public abstract IntVector mul(Vector v, Mask m); + public abstract IntVector mul(Vector v, VectorMask m); /** * Multiplies this vector with the broadcast of an input scalar, selecting @@ -781,25 +557,25 @@ * @return the result of multiplying this vector with the broadcast of an * input scalar */ - public abstract IntVector mul(int s, Mask m); + public abstract IntVector mul(int s, VectorMask m); @Override public abstract IntVector neg(); @Override - public abstract IntVector neg(Mask m); + public abstract IntVector neg(VectorMask m); @Override public abstract IntVector abs(); @Override - public abstract IntVector abs(Mask m); + public abstract IntVector abs(VectorMask m); @Override public abstract IntVector min(Vector v); @Override - public abstract IntVector min(Vector v, Mask m); + public abstract IntVector min(Vector v, VectorMask m); /** * Returns the minimum of this vector and the broadcast of an input scalar. @@ -816,7 +592,7 @@ public abstract IntVector max(Vector v); @Override - public abstract IntVector max(Vector v, Mask m); + public abstract IntVector max(Vector v, VectorMask m); /** * Returns the maximum of this vector and the broadcast of an input scalar. @@ -830,7 +606,7 @@ public abstract IntVector max(int s); @Override - public abstract Mask equal(Vector v); + public abstract VectorMask equal(Vector v); /** * Tests if this vector is equal to the broadcast of an input scalar. @@ -842,10 +618,10 @@ * @return the result mask of testing if this vector is equal to the * broadcast of an input scalar */ - public abstract Mask equal(int s); + public abstract VectorMask equal(int s); @Override - public abstract Mask notEqual(Vector v); + public abstract VectorMask notEqual(Vector v); /** * Tests if this vector is not equal to the broadcast of an input scalar. @@ -857,10 +633,10 @@ * @return the result mask of testing if this vector is not equal to the * broadcast of an input scalar */ - public abstract Mask notEqual(int s); + public abstract VectorMask notEqual(int s); @Override - public abstract Mask lessThan(Vector v); + public abstract VectorMask lessThan(Vector v); /** * Tests if this vector is less than the broadcast of an input scalar. @@ -872,10 +648,10 @@ * @return the mask result of testing if this vector is less than the * broadcast of an input scalar */ - public abstract Mask lessThan(int s); + public abstract VectorMask lessThan(int s); @Override - public abstract Mask lessThanEq(Vector v); + public abstract VectorMask lessThanEq(Vector v); /** * Tests if this vector is less or equal to the broadcast of an input scalar. @@ -887,10 +663,10 @@ * @return the mask result of testing if this vector is less than or equal * to the broadcast of an input scalar */ - public abstract Mask lessThanEq(int s); + public abstract VectorMask lessThanEq(int s); @Override - public abstract Mask greaterThan(Vector v); + public abstract VectorMask greaterThan(Vector v); /** * Tests if this vector is greater than the broadcast of an input scalar. @@ -902,10 +678,10 @@ * @return the mask result of testing if this vector is greater than the * broadcast of an input scalar */ - public abstract Mask greaterThan(int s); + public abstract VectorMask greaterThan(int s); @Override - public abstract Mask greaterThanEq(Vector v); + public abstract VectorMask greaterThanEq(Vector v); /** * Tests if this vector is greater than or equal to the broadcast of an @@ -918,10 +694,10 @@ * @return the mask result of testing if this vector is greater than or * equal to the broadcast of an input scalar */ - public abstract Mask greaterThanEq(int s); + public abstract VectorMask greaterThanEq(int s); @Override - public abstract IntVector blend(Vector v, Mask m); + public abstract IntVector blend(Vector v, VectorMask m); /** * Blends the lane elements of this vector with those of the broadcast of an @@ -938,17 +714,17 @@ * @return the result of blending the lane elements of this vector with * those of the broadcast of an input scalar */ - public abstract IntVector blend(int s, Mask m); + public abstract IntVector blend(int s, VectorMask m); @Override public abstract IntVector rearrange(Vector v, - Shuffle s, Mask m); + VectorShuffle s, VectorMask m); @Override - public abstract IntVector rearrange(Shuffle m); + public abstract IntVector rearrange(VectorShuffle m); @Override - public abstract IntVector reshape(Species s); + public abstract IntVector reshape(VectorSpecies s); @Override public abstract IntVector rotateEL(int i); @@ -998,7 +774,7 @@ * @param m the mask controlling lane selection * @return the bitwise AND of this vector with the input vector */ - public abstract IntVector and(Vector v, Mask m); + public abstract IntVector and(Vector v, VectorMask m); /** * Bitwise ANDs this vector with the broadcast of an input scalar, selecting @@ -1012,7 +788,7 @@ * @return the bitwise AND of this vector with the broadcast of an input * scalar */ - public abstract IntVector and(int s, Mask m); + public abstract IntVector and(int s, VectorMask m); /** * Bitwise ORs this vector with an input vector. @@ -1048,7 +824,7 @@ * @param m the mask controlling lane selection * @return the bitwise OR of this vector with the input vector */ - public abstract IntVector or(Vector v, Mask m); + public abstract IntVector or(Vector v, VectorMask m); /** * Bitwise ORs this vector with the broadcast of an input scalar, selecting @@ -1062,7 +838,7 @@ * @return the bitwise OR of this vector with the broadcast of an input * scalar */ - public abstract IntVector or(int s, Mask m); + public abstract IntVector or(int s, VectorMask m); /** * Bitwise XORs this vector with an input vector. @@ -1098,7 +874,7 @@ * @param m the mask controlling lane selection * @return the bitwise XOR of this vector with the input vector */ - public abstract IntVector xor(Vector v, Mask m); + public abstract IntVector xor(Vector v, VectorMask m); /** * Bitwise XORs this vector with the broadcast of an input scalar, selecting @@ -1112,7 +888,7 @@ * @return the bitwise XOR of this vector with the broadcast of an input * scalar */ - public abstract IntVector xor(int s, Mask m); + public abstract IntVector xor(int s, VectorMask m); /** * Bitwise NOTs this vector. @@ -1133,7 +909,7 @@ * @param m the mask controlling lane selection * @return the bitwise NOT of this vector */ - public abstract IntVector not(Mask m); + public abstract IntVector not(VectorMask m); /** * Logically left shifts this vector by the broadcast of an input scalar. @@ -1159,7 +935,7 @@ * @return the result of logically left shifting this vector by the * broadcast of an input scalar */ - public abstract IntVector shiftL(int s, Mask m); + public abstract IntVector shiftL(int s, VectorMask m); /** * Logically left shifts this vector by an input vector. @@ -1185,7 +961,7 @@ * @return the result of logically left shifting this vector by the input * vector */ - public IntVector shiftL(Vector v, Mask m) { + public IntVector shiftL(Vector v, VectorMask m) { return bOp(v, m, (i, a, b) -> (int) (a << b)); } @@ -1217,7 +993,7 @@ * @return the result of logically right shifting this vector by the * broadcast of an input scalar */ - public abstract IntVector shiftR(int s, Mask m); + public abstract IntVector shiftR(int s, VectorMask m); /** * Logically right shifts (or unsigned right shifts) this vector by an @@ -1244,7 +1020,7 @@ * @return the result of logically right shifting this vector by the * input vector */ - public IntVector shiftR(Vector v, Mask m) { + public IntVector shiftR(Vector v, VectorMask m) { return bOp(v, m, (i, a, b) -> (int) (a >>> b)); } @@ -1274,7 +1050,7 @@ * @return the result of arithmetically right shifting this vector by the * broadcast of an input scalar */ - public abstract IntVector aShiftR(int s, Mask m); + public abstract IntVector aShiftR(int s, VectorMask m); /** * Arithmetically right shifts (or signed right shifts) this vector by an @@ -1301,7 +1077,7 @@ * @return the result of arithmetically right shifting this vector by the * input vector */ - public IntVector aShiftR(Vector v, Mask m) { + public IntVector aShiftR(Vector v, VectorMask m) { return bOp(v, m, (i, a, b) -> (int) (a >> b)); } @@ -1339,7 +1115,7 @@ * input scalar */ @ForceInline - public final IntVector rotateL(int s, Mask m) { + public final IntVector rotateL(int s, VectorMask m) { return shiftL(s, m).or(shiftR(-s, m), m); } @@ -1377,7 +1153,7 @@ * input scalar */ @ForceInline - public final IntVector rotateR(int s, Mask m) { + public final IntVector rotateR(int s, VectorMask m) { return shiftR(s, m).or(shiftL(-s, m), m); } @@ -1385,13 +1161,13 @@ public abstract void intoByteArray(byte[] a, int ix); @Override - public abstract void intoByteArray(byte[] a, int ix, Mask m); + public abstract void intoByteArray(byte[] a, int ix, VectorMask m); @Override public abstract void intoByteBuffer(ByteBuffer bb, int ix); @Override - public abstract void intoByteBuffer(ByteBuffer bb, int ix, Mask m); + public abstract void intoByteBuffer(ByteBuffer bb, int ix, VectorMask m); // Type specific horizontal reductions @@ -1417,7 +1193,7 @@ * @param m the mask controlling lane selection * @return the addition of the selected lane elements of this vector */ - public abstract int addAll(Mask m); + public abstract int addAll(VectorMask m); /** * Multiplies all lane elements of this vector. @@ -1441,7 +1217,7 @@ * @param m the mask controlling lane selection * @return the multiplication of all the lane elements of this vector */ - public abstract int mulAll(Mask m); + public abstract int mulAll(VectorMask m); /** * Returns the minimum lane element of this vector. @@ -1467,7 +1243,7 @@ * @param m the mask controlling lane selection * @return the minimum lane element of this vector */ - public abstract int minAll(Mask m); + public abstract int minAll(VectorMask m); /** * Returns the maximum lane element of this vector. @@ -1493,7 +1269,7 @@ * @param m the mask controlling lane selection * @return the maximum lane element of this vector */ - public abstract int maxAll(Mask m); + public abstract int maxAll(VectorMask m); /** * Logically ORs all lane elements of this vector. @@ -1517,7 +1293,7 @@ * @param m the mask controlling lane selection * @return the logical OR all the lane elements of this vector */ - public abstract int orAll(Mask m); + public abstract int orAll(VectorMask m); /** * Logically ANDs all lane elements of this vector. @@ -1541,7 +1317,7 @@ * @param m the mask controlling lane selection * @return the logical AND all the lane elements of this vector */ - public abstract int andAll(Mask m); + public abstract int andAll(VectorMask m); /** * Logically XORs all lane elements of this vector. @@ -1565,7 +1341,7 @@ * @param m the mask controlling lane selection * @return the logical XOR all the lane elements of this vector */ - public abstract int xorAll(Mask m); + public abstract int xorAll(VectorMask m); // Type specific accessors @@ -1647,7 +1423,7 @@ * for any vector lane index {@code N} where the mask at lane {@code N} * is set {@code i >= a.length - N} */ - public abstract void intoArray(int[] a, int i, Mask m); + public abstract void intoArray(int[] a, int i, VectorMask m); /** * Stores this vector into an array using indexes obtained from an index @@ -1692,37 +1468,34 @@ * {@code N} is set the result of {@code i + indexMap[j + N]} is * {@code < 0} or {@code >= a.length} */ - public abstract void intoArray(int[] a, int i, Mask m, int[] indexMap, int j); + public abstract void intoArray(int[] a, int i, VectorMask m, int[] indexMap, int j); // Species @Override - public abstract Species species(); + public abstract VectorSpecies species(); /** - * Class representing {@link IntVector}'s of the same {@link Vector.Shape Shape}. + * Class representing {@link IntVector}'s of the same {@link VectorShape VectorShape}. */ - static final class IntSpecies extends Vector.AbstractSpecies { + static final class IntSpecies extends AbstractSpecies { final Function vectorFactory; - final Function> maskFactory; - private IntSpecies(Vector.Shape shape, + private IntSpecies(VectorShape shape, Class boxType, Class maskType, Function vectorFactory, - Function> maskFactory) { - super(shape, int.class, Integer.SIZE, boxType, maskType); + Function> maskFactory, + Function> shuffleFromArrayFactory, + fShuffleFromArray shuffleFromOpFactory) { + super(shape, int.class, Integer.SIZE, boxType, maskType, maskFactory, + shuffleFromArrayFactory, shuffleFromOpFactory); this.vectorFactory = vectorFactory; - this.maskFactory = maskFactory; } interface FOp { int apply(int i); } - interface FOpm { - boolean apply(int i); - } - IntVector op(FOp f) { int[] res = new int[length()]; for (int i = 0; i < length(); i++) { @@ -1731,7 +1504,7 @@ return vectorFactory.apply(res); } - IntVector op(Vector.Mask o, FOp f) { + IntVector op(VectorMask o, FOp f) { int[] res = new int[length()]; boolean[] mbits = ((AbstractMask)o).getBits(); for (int i = 0; i < length(); i++) { @@ -1741,14 +1514,6 @@ } return vectorFactory.apply(res); } - - Vector.Mask opm(IntVector.IntSpecies.FOpm f) { - boolean[] res = new boolean[length()]; - for (int i = 0; i < length(); i++) { - res[i] = (boolean)f.apply(i); - } - return maskFactory.apply(res); - } } /** @@ -1762,7 +1527,7 @@ * @return the preferred species for an element type of {@code int} */ private static IntSpecies preferredSpecies() { - return (IntSpecies) Species.ofPreferred(int.class); + return (IntSpecies) VectorSpecies.ofPreferred(int.class); } /** @@ -1772,7 +1537,7 @@ * @return a species for an element type of {@code int} and shape * @throws IllegalArgumentException if no such species exists for the shape */ - static IntSpecies species(Vector.Shape s) { + static IntSpecies species(VectorShape s) { Objects.requireNonNull(s); switch (s) { case S_64_BIT: return (IntSpecies) SPECIES_64; @@ -1784,29 +1549,34 @@ } } - /** Species representing {@link IntVector}s of {@link Vector.Shape#S_64_BIT Shape.S_64_BIT}. */ - public static final Species SPECIES_64 = new IntSpecies(Shape.S_64_BIT, Int64Vector.class, Int64Vector.Int64Mask.class, - Int64Vector::new, Int64Vector.Int64Mask::new); - - /** Species representing {@link IntVector}s of {@link Vector.Shape#S_128_BIT Shape.S_128_BIT}. */ - public static final Species SPECIES_128 = new IntSpecies(Shape.S_128_BIT, Int128Vector.class, Int128Vector.Int128Mask.class, - Int128Vector::new, Int128Vector.Int128Mask::new); - - /** Species representing {@link IntVector}s of {@link Vector.Shape#S_256_BIT Shape.S_256_BIT}. */ - public static final Species SPECIES_256 = new IntSpecies(Shape.S_256_BIT, Int256Vector.class, Int256Vector.Int256Mask.class, - Int256Vector::new, Int256Vector.Int256Mask::new); - - /** Species representing {@link IntVector}s of {@link Vector.Shape#S_512_BIT Shape.S_512_BIT}. */ - public static final Species SPECIES_512 = new IntSpecies(Shape.S_512_BIT, Int512Vector.class, Int512Vector.Int512Mask.class, - Int512Vector::new, Int512Vector.Int512Mask::new); - - /** Species representing {@link IntVector}s of {@link Vector.Shape#S_Max_BIT Shape.S_Max_BIT}. */ - public static final Species SPECIES_MAX = new IntSpecies(Shape.S_Max_BIT, IntMaxVector.class, IntMaxVector.IntMaxMask.class, - IntMaxVector::new, IntMaxVector.IntMaxMask::new); + /** Species representing {@link IntVector}s of {@link VectorShape#S_64_BIT VectorShape.S_64_BIT}. */ + public static final VectorSpecies SPECIES_64 = new IntSpecies(VectorShape.S_64_BIT, Int64Vector.class, Int64Vector.Int64Mask.class, + Int64Vector::new, Int64Vector.Int64Mask::new, + Int64Vector.Int64Shuffle::new, Int64Vector.Int64Shuffle::new); + + /** Species representing {@link IntVector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */ + public static final VectorSpecies SPECIES_128 = new IntSpecies(VectorShape.S_128_BIT, Int128Vector.class, Int128Vector.Int128Mask.class, + Int128Vector::new, Int128Vector.Int128Mask::new, + Int128Vector.Int128Shuffle::new, Int128Vector.Int128Shuffle::new); + + /** Species representing {@link IntVector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */ + public static final VectorSpecies SPECIES_256 = new IntSpecies(VectorShape.S_256_BIT, Int256Vector.class, Int256Vector.Int256Mask.class, + Int256Vector::new, Int256Vector.Int256Mask::new, + Int256Vector.Int256Shuffle::new, Int256Vector.Int256Shuffle::new); + + /** Species representing {@link IntVector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */ + public static final VectorSpecies SPECIES_512 = new IntSpecies(VectorShape.S_512_BIT, Int512Vector.class, Int512Vector.Int512Mask.class, + Int512Vector::new, Int512Vector.Int512Mask::new, + Int512Vector.Int512Shuffle::new, Int512Vector.Int512Shuffle::new); + + /** Species representing {@link IntVector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */ + public static final VectorSpecies SPECIES_MAX = new IntSpecies(VectorShape.S_Max_BIT, IntMaxVector.class, IntMaxVector.IntMaxMask.class, + IntMaxVector::new, IntMaxVector.IntMaxMask::new, + IntMaxVector.IntMaxShuffle::new, IntMaxVector.IntMaxShuffle::new); /** * Preferred species for {@link IntVector}s. * A preferred species is a species of maximal bit size for the platform. */ - public static final Species SPECIES_PREFERRED = (Species) preferredSpecies(); + public static final VectorSpecies SPECIES_PREFERRED = (VectorSpecies) preferredSpecies(); }