--- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java 2019-04-16 10:38:03.241819400 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java 2019-04-16 10:38:02.811565900 -0700 @@ -55,7 +55,7 @@ abstract ByteVector uOp(FUnOp f); - abstract ByteVector uOp(Mask m, FUnOp f); + abstract ByteVector uOp(VectorMask m, FUnOp f); // Binary operator @@ -65,7 +65,7 @@ abstract ByteVector bOp(Vector v, FBinOp f); - abstract ByteVector bOp(Vector v, Mask m, FBinOp f); + abstract ByteVector bOp(Vector v, VectorMask m, FBinOp f); // Trinary operator @@ -75,7 +75,7 @@ abstract ByteVector tOp(Vector v1, Vector v2, FTriOp f); - abstract ByteVector tOp(Vector v1, Vector v2, Mask m, FTriOp f); + abstract ByteVector tOp(Vector v1, Vector v2, VectorMask m, FTriOp f); // Reduction operator @@ -87,7 +87,7 @@ boolean apply(int i, byte a, byte b); } - abstract Mask bTest(Vector v, FBinTest f); + abstract VectorMask bTest(Vector v, FBinTest f); // Foreach @@ -97,7 +97,7 @@ abstract void forEach(FUnCon f); - abstract void forEach(Mask m, FUnCon f); + abstract void forEach(VectorMask m, FUnCon f); // Static factories @@ -110,7 +110,7 @@ */ @ForceInline @SuppressWarnings("unchecked") - public static ByteVector zero(Species species) { + public static ByteVector zero(VectorSpecies species) { return VectorIntrinsics.broadcastCoerced((Class) species.boxType(), byte.class, species.length(), 0, species, ((bits, s) -> ((ByteSpecies)s).op(i -> (byte)bits))); @@ -124,7 +124,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());
      * }
@@ -138,7 +138,7 @@ */ @ForceInline @SuppressWarnings("unchecked") - public static ByteVector fromByteArray(Species species, byte[] a, int ix) { + public static ByteVector 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(), byte.class, species.length(), @@ -160,7 +160,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);
      * }
@@ -179,7 +179,7 @@ * {@code i >= a.length - (N * this.elementSize() / Byte.SIZE)} */ @ForceInline - public static ByteVector fromByteArray(Species species, byte[] a, int ix, Mask m) { + public static ByteVector fromByteArray(VectorSpecies species, byte[] a, int ix, VectorMask m) { return zero(species).blend(fromByteArray(species, a, ix), m); } @@ -199,7 +199,7 @@ */ @ForceInline @SuppressWarnings("unchecked") - public static ByteVector fromArray(Species species, byte[] a, int i){ + public static ByteVector fromArray(VectorSpecies species, byte[] a, int i){ Objects.requireNonNull(a); i = VectorIntrinsics.checkIndex(i, a.length, species.length()); return VectorIntrinsics.load((Class) species.boxType(), byte.class, species.length(), @@ -228,7 +228,7 @@ * is set {@code i > a.length - N} */ @ForceInline - public static ByteVector fromArray(Species species, byte[] a, int i, Mask m) { + public static ByteVector fromArray(VectorSpecies species, byte[] a, int i, VectorMask m) { return zero(species).blend(fromArray(species, a, i), m); } @@ -253,7 +253,7 @@ * or for any vector lane index {@code N} the result of * {@code i + indexMap[j + N]} is {@code < 0} or {@code >= a.length} */ - public static ByteVector fromArray(Species species, byte[] a, int i, int[] indexMap, int j) { + public static ByteVector fromArray(VectorSpecies species, byte[] a, int i, int[] indexMap, int j) { return ((ByteSpecies)species).op(n -> a[i + indexMap[j + n]]); } /** @@ -280,7 +280,7 @@ * {@code N} is set the result of {@code i + indexMap[j + N]} is * {@code < 0} or {@code >= a.length} */ - public static ByteVector fromArray(Species species, byte[] a, int i, Mask m, int[] indexMap, int j) { + public static ByteVector fromArray(VectorSpecies species, byte[] a, int i, VectorMask m, int[] indexMap, int j) { return ((ByteSpecies)species).op(m, n -> a[i + indexMap[j + n]]); } @@ -293,7 +293,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())
      * }
@@ -310,7 +310,7 @@ */ @ForceInline @SuppressWarnings("unchecked") - public static ByteVector fromByteBuffer(Species species, ByteBuffer bb, int ix) { + public static ByteVector fromByteBuffer(VectorSpecies species, ByteBuffer bb, int ix) { if (bb.order() != ByteOrder.nativeOrder()) { throw new IllegalArgumentException(); } @@ -362,7 +362,7 @@ * {@code i >= b.limit() - (N * this.elementSize() / Byte.SIZE)} */ @ForceInline - public static ByteVector fromByteBuffer(Species species, ByteBuffer bb, int ix, Mask m) { + public static ByteVector fromByteBuffer(VectorSpecies species, ByteBuffer bb, int ix, VectorMask m) { return zero(species).blend(fromByteBuffer(species, bb, ix), m); } @@ -377,7 +377,7 @@ */ @ForceInline @SuppressWarnings("unchecked") - public static ByteVector broadcast(Species s, byte e) { + public static ByteVector broadcast(VectorSpecies s, byte e) { return VectorIntrinsics.broadcastCoerced( (Class) s.boxType(), byte.class, s.length(), e, s, @@ -400,7 +400,7 @@ */ @ForceInline @SuppressWarnings("unchecked") - public static ByteVector scalars(Species s, byte... es) { + public static ByteVector scalars(VectorSpecies s, byte... es) { Objects.requireNonNull(es); int ix = VectorIntrinsics.checkIndex(0, es.length, s.length()); return VectorIntrinsics.load((Class) s.boxType(), byte.class, s.length(), @@ -420,7 +420,7 @@ * value {@code e} */ @ForceInline - public static final ByteVector single(Species s, byte e) { + public static final ByteVector single(VectorSpecies s, byte e) { return zero(s).with(0, e); } @@ -435,235 +435,11 @@ * @return a vector where each lane elements is set to a randomly * generated primitive value */ - public static ByteVector random(Species s) { + public static ByteVector random(VectorSpecies s) { ThreadLocalRandom r = ThreadLocalRandom.current(); return ((ByteSpecies)s).op(i -> (byte) 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() == ByteMaxVector.class) - return new ByteMaxVector.ByteMaxMask(bits); - switch (species.bitSize()) { - case 64: return new Byte64Vector.Byte64Mask(bits); - case 128: return new Byte128Vector.Byte128Mask(bits); - case 256: return new Byte256Vector.Byte256Mask(bits); - case 512: return new Byte512Vector.Byte512Mask(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() == ByteMaxVector.class) - return ByteMaxVector.ByteMaxMask.TRUE_MASK; - switch (species.bitSize()) { - case 64: return Byte64Vector.Byte64Mask.TRUE_MASK; - case 128: return Byte128Vector.Byte128Mask.TRUE_MASK; - case 256: return Byte256Vector.Byte256Mask.TRUE_MASK; - case 512: return Byte512Vector.Byte512Mask.TRUE_MASK; - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - - static Mask falseMask(Species species) { - if (species.boxType() == ByteMaxVector.class) - return ByteMaxVector.ByteMaxMask.FALSE_MASK; - switch (species.bitSize()) { - case 64: return Byte64Vector.Byte64Mask.FALSE_MASK; - case 128: return Byte128Vector.Byte128Mask.FALSE_MASK; - case 256: return Byte256Vector.Byte256Mask.FALSE_MASK; - case 512: return Byte512Vector.Byte512Mask.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(), byte.class, species.length(), - bits, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_BOOLEAN_BASE_OFFSET, - bits, ix, species, - (c, idx, s) -> (Mask) ((ByteSpecies)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(), byte.class, species.length(), - (byte)-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(), byte.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() == ByteMaxVector.class) - return new ByteMaxVector.ByteMaxShuffle(f); - switch (species.bitSize()) { - case 64: return new Byte64Vector.Byte64Shuffle(f); - case 128: return new Byte128Vector.Byte128Shuffle(f); - case 256: return new Byte256Vector.Byte256Shuffle(f); - case 512: return new Byte512Vector.Byte512Shuffle(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() == ByteMaxVector.class) - return new ByteMaxVector.ByteMaxShuffle(AbstractShuffle.IDENTITY); - switch (species.bitSize()) { - case 64: return new Byte64Vector.Byte64Shuffle(AbstractShuffle.IDENTITY); - case 128: return new Byte128Vector.Byte128Shuffle(AbstractShuffle.IDENTITY); - case 256: return new Byte256Vector.Byte256Shuffle(AbstractShuffle.IDENTITY); - case 512: return new Byte512Vector.Byte512Shuffle(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() == ByteMaxVector.class) - return new ByteMaxVector.ByteMaxShuffle(ixs); - switch (species.bitSize()) { - case 64: return new Byte64Vector.Byte64Shuffle(ixs); - case 128: return new Byte128Vector.Byte128Shuffle(ixs); - case 256: return new Byte256Vector.Byte256Shuffle(ixs); - case 512: return new Byte512Vector.Byte512Shuffle(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() == ByteMaxVector.class) - return new ByteMaxVector.ByteMaxShuffle(ixs, i); - switch (species.bitSize()) { - case 64: return new Byte64Vector.Byte64Shuffle(ixs, i); - case 128: return new Byte128Vector.Byte128Shuffle(ixs, i); - case 256: return new Byte256Vector.Byte256Shuffle(ixs, i); - case 512: return new Byte512Vector.Byte512Shuffle(ixs, i); - default: throw new IllegalArgumentException(Integer.toString(species.bitSize())); - } - } - // Ops @Override @@ -682,7 +458,7 @@ public abstract ByteVector add(byte s); @Override - public abstract ByteVector add(Vector v, Mask m); + public abstract ByteVector add(Vector v, VectorMask m); /** * Adds this vector to broadcast of an input scalar, @@ -696,7 +472,7 @@ * @return the result of adding this vector to the broadcast of an input * scalar */ - public abstract ByteVector add(byte s, Mask m); + public abstract ByteVector add(byte s, VectorMask m); @Override public abstract ByteVector sub(Vector v); @@ -714,7 +490,7 @@ public abstract ByteVector sub(byte s); @Override - public abstract ByteVector sub(Vector v, Mask m); + public abstract ByteVector sub(Vector v, VectorMask m); /** * Subtracts the broadcast of an input scalar from this vector, selecting @@ -728,7 +504,7 @@ * @return the result of subtracting the broadcast of an input * scalar from this vector */ - public abstract ByteVector sub(byte s, Mask m); + public abstract ByteVector sub(byte s, VectorMask m); @Override public abstract ByteVector mul(Vector v); @@ -746,7 +522,7 @@ public abstract ByteVector mul(byte s); @Override - public abstract ByteVector mul(Vector v, Mask m); + public abstract ByteVector mul(Vector v, VectorMask m); /** * Multiplies this vector with the broadcast of an input scalar, selecting @@ -760,25 +536,25 @@ * @return the result of multiplying this vector with the broadcast of an * input scalar */ - public abstract ByteVector mul(byte s, Mask m); + public abstract ByteVector mul(byte s, VectorMask m); @Override public abstract ByteVector neg(); @Override - public abstract ByteVector neg(Mask m); + public abstract ByteVector neg(VectorMask m); @Override public abstract ByteVector abs(); @Override - public abstract ByteVector abs(Mask m); + public abstract ByteVector abs(VectorMask m); @Override public abstract ByteVector min(Vector v); @Override - public abstract ByteVector min(Vector v, Mask m); + public abstract ByteVector min(Vector v, VectorMask m); /** * Returns the minimum of this vector and the broadcast of an input scalar. @@ -795,7 +571,7 @@ public abstract ByteVector max(Vector v); @Override - public abstract ByteVector max(Vector v, Mask m); + public abstract ByteVector max(Vector v, VectorMask m); /** * Returns the maximum of this vector and the broadcast of an input scalar. @@ -809,7 +585,7 @@ public abstract ByteVector max(byte 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. @@ -821,10 +597,10 @@ * @return the result mask of testing if this vector is equal to the * broadcast of an input scalar */ - public abstract Mask equal(byte s); + public abstract VectorMask equal(byte 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. @@ -836,10 +612,10 @@ * @return the result mask of testing if this vector is not equal to the * broadcast of an input scalar */ - public abstract Mask notEqual(byte s); + public abstract VectorMask notEqual(byte 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. @@ -851,10 +627,10 @@ * @return the mask result of testing if this vector is less than the * broadcast of an input scalar */ - public abstract Mask lessThan(byte s); + public abstract VectorMask lessThan(byte 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. @@ -866,10 +642,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(byte s); + public abstract VectorMask lessThanEq(byte 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. @@ -881,10 +657,10 @@ * @return the mask result of testing if this vector is greater than the * broadcast of an input scalar */ - public abstract Mask greaterThan(byte s); + public abstract VectorMask greaterThan(byte 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 @@ -897,10 +673,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(byte s); + public abstract VectorMask greaterThanEq(byte s); @Override - public abstract ByteVector blend(Vector v, Mask m); + public abstract ByteVector blend(Vector v, VectorMask m); /** * Blends the lane elements of this vector with those of the broadcast of an @@ -917,17 +693,17 @@ * @return the result of blending the lane elements of this vector with * those of the broadcast of an input scalar */ - public abstract ByteVector blend(byte s, Mask m); + public abstract ByteVector blend(byte s, VectorMask m); @Override public abstract ByteVector rearrange(Vector v, - Shuffle s, Mask m); + VectorShuffle s, VectorMask m); @Override - public abstract ByteVector rearrange(Shuffle m); + public abstract ByteVector rearrange(VectorShuffle m); @Override - public abstract ByteVector reshape(Species s); + public abstract ByteVector reshape(VectorSpecies s); @Override public abstract ByteVector rotateEL(int i); @@ -977,7 +753,7 @@ * @param m the mask controlling lane selection * @return the bitwise AND of this vector with the input vector */ - public abstract ByteVector and(Vector v, Mask m); + public abstract ByteVector and(Vector v, VectorMask m); /** * Bitwise ANDs this vector with the broadcast of an input scalar, selecting @@ -991,7 +767,7 @@ * @return the bitwise AND of this vector with the broadcast of an input * scalar */ - public abstract ByteVector and(byte s, Mask m); + public abstract ByteVector and(byte s, VectorMask m); /** * Bitwise ORs this vector with an input vector. @@ -1027,7 +803,7 @@ * @param m the mask controlling lane selection * @return the bitwise OR of this vector with the input vector */ - public abstract ByteVector or(Vector v, Mask m); + public abstract ByteVector or(Vector v, VectorMask m); /** * Bitwise ORs this vector with the broadcast of an input scalar, selecting @@ -1041,7 +817,7 @@ * @return the bitwise OR of this vector with the broadcast of an input * scalar */ - public abstract ByteVector or(byte s, Mask m); + public abstract ByteVector or(byte s, VectorMask m); /** * Bitwise XORs this vector with an input vector. @@ -1077,7 +853,7 @@ * @param m the mask controlling lane selection * @return the bitwise XOR of this vector with the input vector */ - public abstract ByteVector xor(Vector v, Mask m); + public abstract ByteVector xor(Vector v, VectorMask m); /** * Bitwise XORs this vector with the broadcast of an input scalar, selecting @@ -1091,7 +867,7 @@ * @return the bitwise XOR of this vector with the broadcast of an input * scalar */ - public abstract ByteVector xor(byte s, Mask m); + public abstract ByteVector xor(byte s, VectorMask m); /** * Bitwise NOTs this vector. @@ -1112,7 +888,7 @@ * @param m the mask controlling lane selection * @return the bitwise NOT of this vector */ - public abstract ByteVector not(Mask m); + public abstract ByteVector not(VectorMask m); /** * Logically left shifts this vector by the broadcast of an input scalar. @@ -1146,7 +922,7 @@ * @return the result of logically left shifting left this vector by the * broadcast of an input scalar */ - public abstract ByteVector shiftL(int s, Mask m); + public abstract ByteVector shiftL(int s, VectorMask m); // logical, or unsigned, shift right @@ -1185,7 +961,7 @@ * @return the result of logically right shifting this vector by the * broadcast of an input scalar */ - public abstract ByteVector shiftR(int s, Mask m); + public abstract ByteVector shiftR(int s, VectorMask m); /** @@ -1222,20 +998,20 @@ * @return the result of arithmetically right shifting this vector by the * broadcast of an input scalar */ - public abstract ByteVector aShiftR(int s, Mask m); + public abstract ByteVector aShiftR(int s, VectorMask m); @Override 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 @@ -1261,7 +1037,7 @@ * @param m the mask controlling lane selection * @return the addition of the selected lane elements of this vector */ - public abstract byte addAll(Mask m); + public abstract byte addAll(VectorMask m); /** * Multiplies all lane elements of this vector. @@ -1285,7 +1061,7 @@ * @param m the mask controlling lane selection * @return the multiplication of all the lane elements of this vector */ - public abstract byte mulAll(Mask m); + public abstract byte mulAll(VectorMask m); /** * Returns the minimum lane element of this vector. @@ -1311,7 +1087,7 @@ * @param m the mask controlling lane selection * @return the minimum lane element of this vector */ - public abstract byte minAll(Mask m); + public abstract byte minAll(VectorMask m); /** * Returns the maximum lane element of this vector. @@ -1337,7 +1113,7 @@ * @param m the mask controlling lane selection * @return the maximum lane element of this vector */ - public abstract byte maxAll(Mask m); + public abstract byte maxAll(VectorMask m); /** * Logically ORs all lane elements of this vector. @@ -1361,7 +1137,7 @@ * @param m the mask controlling lane selection * @return the logical OR all the lane elements of this vector */ - public abstract byte orAll(Mask m); + public abstract byte orAll(VectorMask m); /** * Logically ANDs all lane elements of this vector. @@ -1385,7 +1161,7 @@ * @param m the mask controlling lane selection * @return the logical AND all the lane elements of this vector */ - public abstract byte andAll(Mask m); + public abstract byte andAll(VectorMask m); /** * Logically XORs all lane elements of this vector. @@ -1409,7 +1185,7 @@ * @param m the mask controlling lane selection * @return the logical XOR all the lane elements of this vector */ - public abstract byte xorAll(Mask m); + public abstract byte xorAll(VectorMask m); // Type specific accessors @@ -1491,7 +1267,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(byte[] a, int i, Mask m); + public abstract void intoArray(byte[] a, int i, VectorMask m); /** * Stores this vector into an array using indexes obtained from an index @@ -1538,39 +1314,36 @@ * {@code N} is set the result of {@code i + indexMap[j + N]} is * {@code < 0} or {@code >= a.length} */ - public void intoArray(byte[] a, int i, Mask m, int[] indexMap, int j) { + public void intoArray(byte[] a, int i, VectorMask m, int[] indexMap, int j) { forEach(m, (n, e) -> a[i + indexMap[j + n]] = e); } // Species @Override - public abstract Species species(); + public abstract VectorSpecies species(); /** - * Class representing {@link ByteVector}'s of the same {@link Vector.Shape Shape}. + * Class representing {@link ByteVector}'s of the same {@link VectorShape VectorShape}. */ - static final class ByteSpecies extends Vector.AbstractSpecies { + static final class ByteSpecies extends AbstractSpecies { final Function vectorFactory; - final Function> maskFactory; - private ByteSpecies(Vector.Shape shape, + private ByteSpecies(VectorShape shape, Class boxType, Class maskType, Function vectorFactory, - Function> maskFactory) { - super(shape, byte.class, Byte.SIZE, boxType, maskType); + Function> maskFactory, + Function> shuffleFromArrayFactory, + fShuffleFromArray shuffleFromOpFactory) { + super(shape, byte.class, Byte.SIZE, boxType, maskType, maskFactory, + shuffleFromArrayFactory, shuffleFromOpFactory); this.vectorFactory = vectorFactory; - this.maskFactory = maskFactory; } interface FOp { byte apply(int i); } - interface FOpm { - boolean apply(int i); - } - ByteVector op(FOp f) { byte[] res = new byte[length()]; for (int i = 0; i < length(); i++) { @@ -1579,7 +1352,7 @@ return vectorFactory.apply(res); } - ByteVector op(Vector.Mask o, FOp f) { + ByteVector op(VectorMask o, FOp f) { byte[] res = new byte[length()]; boolean[] mbits = ((AbstractMask)o).getBits(); for (int i = 0; i < length(); i++) { @@ -1589,14 +1362,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); - } } /** @@ -1610,7 +1375,7 @@ * @return the preferred species for an element type of {@code byte} */ private static ByteSpecies preferredSpecies() { - return (ByteSpecies) Species.ofPreferred(byte.class); + return (ByteSpecies) VectorSpecies.ofPreferred(byte.class); } /** @@ -1620,7 +1385,7 @@ * @return a species for an element type of {@code byte} and shape * @throws IllegalArgumentException if no such species exists for the shape */ - static ByteSpecies species(Vector.Shape s) { + static ByteSpecies species(VectorShape s) { Objects.requireNonNull(s); switch (s) { case S_64_BIT: return (ByteSpecies) SPECIES_64; @@ -1632,29 +1397,34 @@ } } - /** Species representing {@link ByteVector}s of {@link Vector.Shape#S_64_BIT Shape.S_64_BIT}. */ - public static final Species SPECIES_64 = new ByteSpecies(Shape.S_64_BIT, Byte64Vector.class, Byte64Vector.Byte64Mask.class, - Byte64Vector::new, Byte64Vector.Byte64Mask::new); - - /** Species representing {@link ByteVector}s of {@link Vector.Shape#S_128_BIT Shape.S_128_BIT}. */ - public static final Species SPECIES_128 = new ByteSpecies(Shape.S_128_BIT, Byte128Vector.class, Byte128Vector.Byte128Mask.class, - Byte128Vector::new, Byte128Vector.Byte128Mask::new); - - /** Species representing {@link ByteVector}s of {@link Vector.Shape#S_256_BIT Shape.S_256_BIT}. */ - public static final Species SPECIES_256 = new ByteSpecies(Shape.S_256_BIT, Byte256Vector.class, Byte256Vector.Byte256Mask.class, - Byte256Vector::new, Byte256Vector.Byte256Mask::new); - - /** Species representing {@link ByteVector}s of {@link Vector.Shape#S_512_BIT Shape.S_512_BIT}. */ - public static final Species SPECIES_512 = new ByteSpecies(Shape.S_512_BIT, Byte512Vector.class, Byte512Vector.Byte512Mask.class, - Byte512Vector::new, Byte512Vector.Byte512Mask::new); - - /** Species representing {@link ByteVector}s of {@link Vector.Shape#S_Max_BIT Shape.S_Max_BIT}. */ - public static final Species SPECIES_MAX = new ByteSpecies(Shape.S_Max_BIT, ByteMaxVector.class, ByteMaxVector.ByteMaxMask.class, - ByteMaxVector::new, ByteMaxVector.ByteMaxMask::new); + /** Species representing {@link ByteVector}s of {@link VectorShape#S_64_BIT VectorShape.S_64_BIT}. */ + public static final VectorSpecies SPECIES_64 = new ByteSpecies(VectorShape.S_64_BIT, Byte64Vector.class, Byte64Vector.Byte64Mask.class, + Byte64Vector::new, Byte64Vector.Byte64Mask::new, + Byte64Vector.Byte64Shuffle::new, Byte64Vector.Byte64Shuffle::new); + + /** Species representing {@link ByteVector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */ + public static final VectorSpecies SPECIES_128 = new ByteSpecies(VectorShape.S_128_BIT, Byte128Vector.class, Byte128Vector.Byte128Mask.class, + Byte128Vector::new, Byte128Vector.Byte128Mask::new, + Byte128Vector.Byte128Shuffle::new, Byte128Vector.Byte128Shuffle::new); + + /** Species representing {@link ByteVector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */ + public static final VectorSpecies SPECIES_256 = new ByteSpecies(VectorShape.S_256_BIT, Byte256Vector.class, Byte256Vector.Byte256Mask.class, + Byte256Vector::new, Byte256Vector.Byte256Mask::new, + Byte256Vector.Byte256Shuffle::new, Byte256Vector.Byte256Shuffle::new); + + /** Species representing {@link ByteVector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */ + public static final VectorSpecies SPECIES_512 = new ByteSpecies(VectorShape.S_512_BIT, Byte512Vector.class, Byte512Vector.Byte512Mask.class, + Byte512Vector::new, Byte512Vector.Byte512Mask::new, + Byte512Vector.Byte512Shuffle::new, Byte512Vector.Byte512Shuffle::new); + + /** Species representing {@link ByteVector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */ + public static final VectorSpecies SPECIES_MAX = new ByteSpecies(VectorShape.S_Max_BIT, ByteMaxVector.class, ByteMaxVector.ByteMaxMask.class, + ByteMaxVector::new, ByteMaxVector.ByteMaxMask::new, + ByteMaxVector.ByteMaxShuffle::new, ByteMaxVector.ByteMaxShuffle::new); /** * Preferred species for {@link ByteVector}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(); }