< prev index next >

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java

Print this page
rev 54658 : refactored mask and shuffle creation methods, moved classes to top-level

@@ -54,31 +54,31 @@
         short apply(int i, short a);
     }
 
     abstract ShortVector uOp(FUnOp f);
 
-    abstract ShortVector uOp(Mask<Short> m, FUnOp f);
+    abstract ShortVector uOp(VectorMask<Short> m, FUnOp f);
 
     // Binary operator
 
     interface FBinOp {
         short apply(int i, short a, short b);
     }
 
     abstract ShortVector bOp(Vector<Short> v, FBinOp f);
 
-    abstract ShortVector bOp(Vector<Short> v, Mask<Short> m, FBinOp f);
+    abstract ShortVector bOp(Vector<Short> v, VectorMask<Short> m, FBinOp f);
 
     // Trinary operator
 
     interface FTriOp {
         short apply(int i, short a, short b, short c);
     }
 
     abstract ShortVector tOp(Vector<Short> v1, Vector<Short> v2, FTriOp f);
 
-    abstract ShortVector tOp(Vector<Short> v1, Vector<Short> v2, Mask<Short> m, FTriOp f);
+    abstract ShortVector tOp(Vector<Short> v1, Vector<Short> v2, VectorMask<Short> m, FTriOp f);
 
     // Reduction operator
 
     abstract short rOp(short v, FBinOp f);
 

@@ -86,21 +86,21 @@
 
     interface FBinTest {
         boolean apply(int i, short a, short b);
     }
 
-    abstract Mask<Short> bTest(Vector<Short> v, FBinTest f);
+    abstract VectorMask<Short> bTest(Vector<Short> v, FBinTest f);
 
     // Foreach
 
     interface FUnCon {
         void apply(int i, short a);
     }
 
     abstract void forEach(FUnCon f);
 
-    abstract void forEach(Mask<Short> m, FUnCon f);
+    abstract void forEach(VectorMask<Short> m, FUnCon f);
 
     // Static factories
 
     /**
      * Returns a vector where all lane elements are set to the default

@@ -109,11 +109,11 @@
      * @param species species of desired vector
      * @return a zero vector of given species
      */
     @ForceInline
     @SuppressWarnings("unchecked")
-    public static ShortVector zero(Species<Short> species) {
+    public static ShortVector zero(VectorSpecies<Short> species) {
         return VectorIntrinsics.broadcastCoerced((Class<ShortVector>) species.boxType(), short.class, species.length(),
                                                  0, species,
                                                  ((bits, s) -> ((ShortSpecies)s).op(i -> (short)bits)));
     }
 

@@ -123,11 +123,11 @@
      * Bytes are composed into primitive lane elements according to the
      * native byte order of the underlying platform
      * <p>
      * This method behaves as if it returns the result of calling the
      * byte buffer, offset, and mask accepting
-     * {@link #fromByteBuffer(Species<Short>, ByteBuffer, int, Mask) method} as follows:
+     * {@link #fromByteBuffer(VectorSpecies<Short>, ByteBuffer, int, VectorMask) method} as follows:
      * <pre>{@code
      * return this.fromByteBuffer(ByteBuffer.wrap(a), i, this.maskAllTrue());
      * }</pre>
      *
      * @param species species of desired vector

@@ -137,11 +137,11 @@
      * @throws IndexOutOfBoundsException if {@code i < 0} or
      * {@code i > a.length - (this.length() * this.elementSize() / Byte.SIZE)}
      */
     @ForceInline
     @SuppressWarnings("unchecked")
-    public static ShortVector fromByteArray(Species<Short> species, byte[] a, int ix) {
+    public static ShortVector fromByteArray(VectorSpecies<Short> species, byte[] a, int ix) {
         Objects.requireNonNull(a);
         ix = VectorIntrinsics.checkIndex(ix, a.length, species.bitSize() / Byte.SIZE);
         return VectorIntrinsics.load((Class<ShortVector>) species.boxType(), short.class, species.length(),
                                      a, ((long) ix) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
                                      a, ix, species,

@@ -159,11 +159,11 @@
      * Bytes are composed into primitive lane elements according to the
      * native byte order of the underlying platform.
      * <p>
      * This method behaves as if it returns the result of calling the
      * byte buffer, offset, and mask accepting
-     * {@link #fromByteBuffer(Species<Short>, ByteBuffer, int, Mask) method} as follows:
+     * {@link #fromByteBuffer(VectorSpecies<Short>, ByteBuffer, int, VectorMask) method} as follows:
      * <pre>{@code
      * return this.fromByteBuffer(ByteBuffer.wrap(a), i, m);
      * }</pre>
      *
      * @param species species of desired vector

@@ -178,11 +178,11 @@
      * for any vector lane index {@code N} where the mask at lane {@code N}
      * is set
      * {@code i >= a.length - (N * this.elementSize() / Byte.SIZE)}
      */
     @ForceInline
-    public static ShortVector fromByteArray(Species<Short> species, byte[] a, int ix, Mask<Short> m) {
+    public static ShortVector fromByteArray(VectorSpecies<Short> species, byte[] a, int ix, VectorMask<Short> m) {
         return zero(species).blend(fromByteArray(species, a, ix), m);
     }
 
     /**
      * Loads a vector from an array starting at offset.

@@ -198,11 +198,11 @@
      * @throws IndexOutOfBoundsException if {@code i < 0}, or
      * {@code i > a.length - this.length()}
      */
     @ForceInline
     @SuppressWarnings("unchecked")
-    public static ShortVector fromArray(Species<Short> species, short[] a, int i){
+    public static ShortVector fromArray(VectorSpecies<Short> species, short[] a, int i){
         Objects.requireNonNull(a);
         i = VectorIntrinsics.checkIndex(i, a.length, species.length());
         return VectorIntrinsics.load((Class<ShortVector>) species.boxType(), short.class, species.length(),
                                      a, (((long) i) << ARRAY_SHIFT) + Unsafe.ARRAY_SHORT_BASE_OFFSET,
                                      a, i, species,

@@ -227,11 +227,11 @@
      * @throws IndexOutOfBoundsException if {@code i < 0}, or
      * for any vector lane index {@code N} where the mask at lane {@code N}
      * is set {@code i > a.length - N}
      */
     @ForceInline
-    public static ShortVector fromArray(Species<Short> species, short[] a, int i, Mask<Short> m) {
+    public static ShortVector fromArray(VectorSpecies<Short> species, short[] a, int i, VectorMask<Short> m) {
         return zero(species).blend(fromArray(species, a, i), m);
     }
 
     /**
      * Loads a vector from an array using indexes obtained from an index

@@ -252,11 +252,11 @@
      * @throws IndexOutOfBoundsException if {@code j < 0}, or
      * {@code j > indexMap.length - this.length()},
      * 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 ShortVector fromArray(Species<Short> species, short[] a, int i, int[] indexMap, int j) {
+    public static ShortVector fromArray(VectorSpecies<Short> species, short[] a, int i, int[] indexMap, int j) {
         return ((ShortSpecies)species).op(n -> a[i + indexMap[j + n]]);
     }
     /**
      * Loads a vector from an array using indexes obtained from an index
      * map and using a mask.

@@ -279,11 +279,11 @@
      * {@code j > indexMap.length - this.length()},
      * or for any vector lane index {@code N} where the mask at lane
      * {@code N} is set the result of {@code i + indexMap[j + N]} is
      * {@code < 0} or {@code >= a.length}
      */
-    public static ShortVector fromArray(Species<Short> species, short[] a, int i, Mask<Short> m, int[] indexMap, int j) {
+    public static ShortVector fromArray(VectorSpecies<Short> species, short[] a, int i, VectorMask<Short> m, int[] indexMap, int j) {
         return ((ShortSpecies)species).op(m, n -> a[i + indexMap[j + n]]);
     }
 
     /**
      * Loads a vector from a {@link ByteBuffer byte buffer} starting at an

@@ -292,11 +292,11 @@
      * Bytes are composed into primitive lane elements according to the
      * native byte order of the underlying platform.
      * <p>
      * This method behaves as if it returns the result of calling the
      * byte buffer, offset, and mask accepting
-     * {@link #fromByteBuffer(Species<Short>, ByteBuffer, int, Mask)} method} as follows:
+     * {@link #fromByteBuffer(VectorSpecies<Short>, ByteBuffer, int, VectorMask)} method} as follows:
      * <pre>{@code
      *   return this.fromByteBuffer(b, i, this.maskAllTrue())
      * }</pre>
      *
      * @param species species of desired vector

@@ -309,11 +309,11 @@
      * {@code this.length() * this.elementSize() / Byte.SIZE} bytes
      * remaining in the byte buffer from the given offset
      */
     @ForceInline
     @SuppressWarnings("unchecked")
-    public static ShortVector fromByteBuffer(Species<Short> species, ByteBuffer bb, int ix) {
+    public static ShortVector fromByteBuffer(VectorSpecies<Short> species, ByteBuffer bb, int ix) {
         if (bb.order() != ByteOrder.nativeOrder()) {
             throw new IllegalArgumentException();
         }
         ix = VectorIntrinsics.checkIndex(ix, bb.limit(), species.bitSize() / Byte.SIZE);
         return VectorIntrinsics.load((Class<ShortVector>) species.boxType(), short.class, species.length(),

@@ -361,11 +361,11 @@
      * for any vector lane index {@code N} where the mask at lane {@code N}
      * is set
      * {@code i >= b.limit() - (N * this.elementSize() / Byte.SIZE)}
      */
     @ForceInline
-    public static ShortVector fromByteBuffer(Species<Short> species, ByteBuffer bb, int ix, Mask<Short> m) {
+    public static ShortVector fromByteBuffer(VectorSpecies<Short> species, ByteBuffer bb, int ix, VectorMask<Short> m) {
         return zero(species).blend(fromByteBuffer(species, bb, ix), m);
     }
 
     /**
      * Returns a vector where all lane elements are set to the primitive

@@ -376,11 +376,11 @@
      * @return a vector of vector where all lane elements are set to
      * the primitive value {@code e}
      */
     @ForceInline
     @SuppressWarnings("unchecked")
-    public static ShortVector broadcast(Species<Short> s, short e) {
+    public static ShortVector broadcast(VectorSpecies<Short> s, short e) {
         return VectorIntrinsics.broadcastCoerced(
             (Class<ShortVector>) s.boxType(), short.class, s.length(),
             e, s,
             ((bits, sp) -> ((ShortSpecies)sp).op(i -> (short)bits)));
     }

@@ -399,11 +399,11 @@
      * value
      * @throws IndexOutOfBoundsException if {@code es.length < this.length()}
      */
     @ForceInline
     @SuppressWarnings("unchecked")
-    public static ShortVector scalars(Species<Short> s, short... es) {
+    public static ShortVector scalars(VectorSpecies<Short> s, short... es) {
         Objects.requireNonNull(es);
         int ix = VectorIntrinsics.checkIndex(0, es.length, s.length());
         return VectorIntrinsics.load((Class<ShortVector>) s.boxType(), short.class, s.length(),
                                      es, Unsafe.ARRAY_SHORT_BASE_OFFSET,
                                      es, ix, s,

@@ -419,11 +419,11 @@
      * @param e the value
      * @return a vector where the first lane element is set to the primitive
      * value {@code e}
      */
     @ForceInline
-    public static final ShortVector single(Species<Short> s, short e) {
+    public static final ShortVector single(VectorSpecies<Short> s, short e) {
         return zero(s).with(0, e);
     }
 
     /**
      * Returns a vector where each lane element is set to a randomly

@@ -434,239 +434,15 @@
      *
      * @param s species of the desired vector
      * @return a vector where each lane elements is set to a randomly
      * generated primitive value
      */
-    public static ShortVector random(Species<Short> s) {
+    public static ShortVector random(VectorSpecies<Short> s) {
         ThreadLocalRandom r = ThreadLocalRandom.current();
         return ((ShortSpecies)s).op(i -> (short) r.nextInt());
     }
 
-    /**
-     * Returns a mask where each lane is set or unset according to given
-     * {@code boolean} values
-     * <p>
-     * 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<Short> maskFromValues(Species<Short> species, boolean... bits) {
-        if (species.boxType() == ShortMaxVector.class)
-            return new ShortMaxVector.ShortMaxMask(bits);
-        switch (species.bitSize()) {
-            case 64: return new Short64Vector.Short64Mask(bits);
-            case 128: return new Short128Vector.Short128Mask(bits);
-            case 256: return new Short256Vector.Short256Mask(bits);
-            case 512: return new Short512Vector.Short512Mask(bits);
-            default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
-        }
-    }
-
-    // @@@ This is a bad implementation -- makes lambdas capturing -- fix this
-    static Mask<Short> trueMask(Species<Short> species) {
-        if (species.boxType() == ShortMaxVector.class)
-            return ShortMaxVector.ShortMaxMask.TRUE_MASK;
-        switch (species.bitSize()) {
-            case 64: return Short64Vector.Short64Mask.TRUE_MASK;
-            case 128: return Short128Vector.Short128Mask.TRUE_MASK;
-            case 256: return Short256Vector.Short256Mask.TRUE_MASK;
-            case 512: return Short512Vector.Short512Mask.TRUE_MASK;
-            default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
-        }
-    }
-
-    static Mask<Short> falseMask(Species<Short> species) {
-        if (species.boxType() == ShortMaxVector.class)
-            return ShortMaxVector.ShortMaxMask.FALSE_MASK;
-        switch (species.bitSize()) {
-            case 64: return Short64Vector.Short64Mask.FALSE_MASK;
-            case 128: return Short128Vector.Short128Mask.FALSE_MASK;
-            case 256: return Short256Vector.Short256Mask.FALSE_MASK;
-            case 512: return Short512Vector.Short512Mask.FALSE_MASK;
-            default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
-        }
-    }
-
-    /**
-     * Loads a mask from a {@code boolean} array starting at an offset.
-     * <p>
-     * 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<Short> maskFromArray(Species<Short> species, boolean[] bits, int ix) {
-        Objects.requireNonNull(bits);
-        ix = VectorIntrinsics.checkIndex(ix, bits.length, species.length());
-        return VectorIntrinsics.load((Class<Mask<Short>>) species.maskType(), short.class, species.length(),
-                                     bits, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_BOOLEAN_BASE_OFFSET,
-                                     bits, ix, species,
-                                     (c, idx, s) -> (Mask<Short>) ((ShortSpecies)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<Short> maskAllTrue(Species<Short> species) {
-        return VectorIntrinsics.broadcastCoerced((Class<Mask<Short>>) species.maskType(), short.class, species.length(),
-                                                 (short)-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<Short> maskAllFalse(Species<Short> species) {
-        return VectorIntrinsics.broadcastCoerced((Class<Mask<Short>>) species.maskType(), short.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.
-     * <p>
-     * 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.
-     * <p>
-     * This method behaves as if a shuffle is created from an array of
-     * mapped indexes as follows:
-     * <pre>{@code
-     *   int[] a = new int[species.length()];
-     *   for (int i = 0; i < a.length; i++) {
-     *       a[i] = f.applyAsInt(i);
-     *   }
-     *   return this.shuffleFromValues(a);
-     * }</pre>
-     *
-     * @param species shuffle species
-     * @param f the lane index mapping function
-     * @return a shuffle of mapped indexes
-     */
-    @ForceInline
-    public static Shuffle<Short> shuffle(Species<Short> species, IntUnaryOperator f) {
-        if (species.boxType() == ShortMaxVector.class)
-            return new ShortMaxVector.ShortMaxShuffle(f);
-        switch (species.bitSize()) {
-            case 64: return new Short64Vector.Short64Shuffle(f);
-            case 128: return new Short128Vector.Short128Shuffle(f);
-            case 256: return new Short256Vector.Short256Shuffle(f);
-            case 512: return new Short512Vector.Short512Shuffle(f);
-            default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
-        }
-    }
-
-    /**
-     * Returns a shuffle where each lane element is the value of its
-     * corresponding lane index.
-     * <p>
-     * This method behaves as if a shuffle is created from an identity
-     * index mapping function as follows:
-     * <pre>{@code
-     *   return this.shuffle(i -> i);
-     * }</pre>
-     *
-     * @param species shuffle species
-     * @return a shuffle of lane indexes
-     */
-    @ForceInline
-    public static Shuffle<Short> shuffleIota(Species<Short> species) {
-        if (species.boxType() == ShortMaxVector.class)
-            return new ShortMaxVector.ShortMaxShuffle(AbstractShuffle.IDENTITY);
-        switch (species.bitSize()) {
-            case 64: return new Short64Vector.Short64Shuffle(AbstractShuffle.IDENTITY);
-            case 128: return new Short128Vector.Short128Shuffle(AbstractShuffle.IDENTITY);
-            case 256: return new Short256Vector.Short256Shuffle(AbstractShuffle.IDENTITY);
-            case 512: return new Short512Vector.Short512Shuffle(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.
-     * <p>
-     * 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<Short> shuffleFromValues(Species<Short> species, int... ixs) {
-        if (species.boxType() == ShortMaxVector.class)
-            return new ShortMaxVector.ShortMaxShuffle(ixs);
-        switch (species.bitSize()) {
-            case 64: return new Short64Vector.Short64Shuffle(ixs);
-            case 128: return new Short128Vector.Short128Shuffle(ixs);
-            case 256: return new Short256Vector.Short256Shuffle(ixs);
-            case 512: return new Short512Vector.Short512Shuffle(ixs);
-            default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
-        }
-    }
-
-    /**
-     * Loads a shuffle from an {@code int} array starting at an offset.
-     * <p>
-     * 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<Short> shuffleFromArray(Species<Short> species, int[] ixs, int i) {
-        if (species.boxType() == ShortMaxVector.class)
-            return new ShortMaxVector.ShortMaxShuffle(ixs, i);
-        switch (species.bitSize()) {
-            case 64: return new Short64Vector.Short64Shuffle(ixs, i);
-            case 128: return new Short128Vector.Short128Shuffle(ixs, i);
-            case 256: return new Short256Vector.Short256Shuffle(ixs, i);
-            case 512: return new Short512Vector.Short512Shuffle(ixs, i);
-            default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
-        }
-    }
-
     // Ops
 
     @Override
     public abstract ShortVector add(Vector<Short> v);
 

@@ -681,11 +457,11 @@
      * scalar
      */
     public abstract ShortVector add(short s);
 
     @Override
-    public abstract ShortVector add(Vector<Short> v, Mask<Short> m);
+    public abstract ShortVector add(Vector<Short> v, VectorMask<Short> m);
 
     /**
      * Adds this vector to broadcast of an input scalar,
      * selecting lane elements controlled by a mask.
      * <p>

@@ -695,11 +471,11 @@
      * @param s the input scalar
      * @param m the mask controlling lane selection
      * @return the result of adding this vector to the broadcast of an input
      * scalar
      */
-    public abstract ShortVector add(short s, Mask<Short> m);
+    public abstract ShortVector add(short s, VectorMask<Short> m);
 
     @Override
     public abstract ShortVector sub(Vector<Short> v);
 
     /**

@@ -713,11 +489,11 @@
      * scalar from this vector
      */
     public abstract ShortVector sub(short s);
 
     @Override
-    public abstract ShortVector sub(Vector<Short> v, Mask<Short> m);
+    public abstract ShortVector sub(Vector<Short> v, VectorMask<Short> m);
 
     /**
      * Subtracts the broadcast of an input scalar from this vector, selecting
      * lane elements controlled by a mask.
      * <p>

@@ -727,11 +503,11 @@
      * @param s the input scalar
      * @param m the mask controlling lane selection
      * @return the result of subtracting the broadcast of an input
      * scalar from this vector
      */
-    public abstract ShortVector sub(short s, Mask<Short> m);
+    public abstract ShortVector sub(short s, VectorMask<Short> m);
 
     @Override
     public abstract ShortVector mul(Vector<Short> v);
 
     /**

@@ -745,11 +521,11 @@
      * input scalar
      */
     public abstract ShortVector mul(short s);
 
     @Override
-    public abstract ShortVector mul(Vector<Short> v, Mask<Short> m);
+    public abstract ShortVector mul(Vector<Short> v, VectorMask<Short> m);
 
     /**
      * Multiplies this vector with the broadcast of an input scalar, selecting
      * lane elements controlled by a mask.
      * <p>

@@ -759,29 +535,29 @@
      * @param s the input scalar
      * @param m the mask controlling lane selection
      * @return the result of multiplying this vector with the broadcast of an
      * input scalar
      */
-    public abstract ShortVector mul(short s, Mask<Short> m);
+    public abstract ShortVector mul(short s, VectorMask<Short> m);
 
     @Override
     public abstract ShortVector neg();
 
     @Override
-    public abstract ShortVector neg(Mask<Short> m);
+    public abstract ShortVector neg(VectorMask<Short> m);
 
     @Override
     public abstract ShortVector abs();
 
     @Override
-    public abstract ShortVector abs(Mask<Short> m);
+    public abstract ShortVector abs(VectorMask<Short> m);
 
     @Override
     public abstract ShortVector min(Vector<Short> v);
 
     @Override
-    public abstract ShortVector min(Vector<Short> v, Mask<Short> m);
+    public abstract ShortVector min(Vector<Short> v, VectorMask<Short> m);
 
     /**
      * Returns the minimum of this vector and the broadcast of an input scalar.
      * <p>
      * This is a vector binary operation where the operation

@@ -794,11 +570,11 @@
 
     @Override
     public abstract ShortVector max(Vector<Short> v);
 
     @Override
-    public abstract ShortVector max(Vector<Short> v, Mask<Short> m);
+    public abstract ShortVector max(Vector<Short> v, VectorMask<Short> m);
 
     /**
      * Returns the maximum of this vector and the broadcast of an input scalar.
      * <p>
      * This is a vector binary operation where the operation

@@ -808,11 +584,11 @@
      * @return the maximum of this vector and the broadcast of an input scalar
      */
     public abstract ShortVector max(short s);
 
     @Override
-    public abstract Mask<Short> equal(Vector<Short> v);
+    public abstract VectorMask<Short> equal(Vector<Short> v);
 
     /**
      * Tests if this vector is equal to the broadcast of an input scalar.
      * <p>
      * This is a vector binary test operation where the primitive equals

@@ -820,14 +596,14 @@
      *
      * @param s the input scalar
      * @return the result mask of testing if this vector is equal to the
      * broadcast of an input scalar
      */
-    public abstract Mask<Short> equal(short s);
+    public abstract VectorMask<Short> equal(short s);
 
     @Override
-    public abstract Mask<Short> notEqual(Vector<Short> v);
+    public abstract VectorMask<Short> notEqual(Vector<Short> v);
 
     /**
      * Tests if this vector is not equal to the broadcast of an input scalar.
      * <p>
      * This is a vector binary test operation where the primitive not equals

@@ -835,14 +611,14 @@
      *
      * @param s the input scalar
      * @return the result mask of testing if this vector is not equal to the
      * broadcast of an input scalar
      */
-    public abstract Mask<Short> notEqual(short s);
+    public abstract VectorMask<Short> notEqual(short s);
 
     @Override
-    public abstract Mask<Short> lessThan(Vector<Short> v);
+    public abstract VectorMask<Short> lessThan(Vector<Short> v);
 
     /**
      * Tests if this vector is less than the broadcast of an input scalar.
      * <p>
      * This is a vector binary test operation where the primitive less than

@@ -850,14 +626,14 @@
      *
      * @param s the input scalar
      * @return the mask result of testing if this vector is less than the
      * broadcast of an input scalar
      */
-    public abstract Mask<Short> lessThan(short s);
+    public abstract VectorMask<Short> lessThan(short s);
 
     @Override
-    public abstract Mask<Short> lessThanEq(Vector<Short> v);
+    public abstract VectorMask<Short> lessThanEq(Vector<Short> v);
 
     /**
      * Tests if this vector is less or equal to the broadcast of an input scalar.
      * <p>
      * This is a vector binary test operation where the primitive less than

@@ -865,14 +641,14 @@
      *
      * @param s the input scalar
      * @return the mask result of testing if this vector is less than or equal
      * to the broadcast of an input scalar
      */
-    public abstract Mask<Short> lessThanEq(short s);
+    public abstract VectorMask<Short> lessThanEq(short s);
 
     @Override
-    public abstract Mask<Short> greaterThan(Vector<Short> v);
+    public abstract VectorMask<Short> greaterThan(Vector<Short> v);
 
     /**
      * Tests if this vector is greater than the broadcast of an input scalar.
      * <p>
      * This is a vector binary test operation where the primitive greater than

@@ -880,14 +656,14 @@
      *
      * @param s the input scalar
      * @return the mask result of testing if this vector is greater than the
      * broadcast of an input scalar
      */
-    public abstract Mask<Short> greaterThan(short s);
+    public abstract VectorMask<Short> greaterThan(short s);
 
     @Override
-    public abstract Mask<Short> greaterThanEq(Vector<Short> v);
+    public abstract VectorMask<Short> greaterThanEq(Vector<Short> v);
 
     /**
      * Tests if this vector is greater than or equal to the broadcast of an
      * input scalar.
      * <p>

@@ -896,14 +672,14 @@
      *
      * @param s the input scalar
      * @return the mask result of testing if this vector is greater than or
      * equal to the broadcast of an input scalar
      */
-    public abstract Mask<Short> greaterThanEq(short s);
+    public abstract VectorMask<Short> greaterThanEq(short s);
 
     @Override
-    public abstract ShortVector blend(Vector<Short> v, Mask<Short> m);
+    public abstract ShortVector blend(Vector<Short> v, VectorMask<Short> m);
 
     /**
      * Blends the lane elements of this vector with those of the broadcast of an
      * input scalar, selecting lanes controlled by a mask.
      * <p>

@@ -916,21 +692,21 @@
      * @param s the input scalar
      * @param m the mask controlling lane selection
      * @return the result of blending the lane elements of this vector with
      * those of the broadcast of an input scalar
      */
-    public abstract ShortVector blend(short s, Mask<Short> m);
+    public abstract ShortVector blend(short s, VectorMask<Short> m);
 
     @Override
     public abstract ShortVector rearrange(Vector<Short> v,
-                                                      Shuffle<Short> s, Mask<Short> m);
+                                                      VectorShuffle<Short> s, VectorMask<Short> m);
 
     @Override
-    public abstract ShortVector rearrange(Shuffle<Short> m);
+    public abstract ShortVector rearrange(VectorShuffle<Short> m);
 
     @Override
-    public abstract ShortVector reshape(Species<Short> s);
+    public abstract ShortVector reshape(VectorSpecies<Short> s);
 
     @Override
     public abstract ShortVector rotateEL(int i);
 
     @Override

@@ -976,11 +752,11 @@
      *
      * @param v the input vector
      * @param m the mask controlling lane selection
      * @return the bitwise AND of this vector with the input vector
      */
-    public abstract ShortVector and(Vector<Short> v, Mask<Short> m);
+    public abstract ShortVector and(Vector<Short> v, VectorMask<Short> m);
 
     /**
      * Bitwise ANDs this vector with the broadcast of an input scalar, selecting
      * lane elements controlled by a mask.
      * <p>

@@ -990,11 +766,11 @@
      * @param s the input scalar
      * @param m the mask controlling lane selection
      * @return the bitwise AND of this vector with the broadcast of an input
      * scalar
      */
-    public abstract ShortVector and(short s, Mask<Short> m);
+    public abstract ShortVector and(short s, VectorMask<Short> m);
 
     /**
      * Bitwise ORs this vector with an input vector.
      * <p>
      * This is a vector binary operation where the primitive bitwise OR

@@ -1026,11 +802,11 @@
      *
      * @param v the input vector
      * @param m the mask controlling lane selection
      * @return the bitwise OR of this vector with the input vector
      */
-    public abstract ShortVector or(Vector<Short> v, Mask<Short> m);
+    public abstract ShortVector or(Vector<Short> v, VectorMask<Short> m);
 
     /**
      * Bitwise ORs this vector with the broadcast of an input scalar, selecting
      * lane elements controlled by a mask.
      * <p>

@@ -1040,11 +816,11 @@
      * @param s the input scalar
      * @param m the mask controlling lane selection
      * @return the bitwise OR of this vector with the broadcast of an input
      * scalar
      */
-    public abstract ShortVector or(short s, Mask<Short> m);
+    public abstract ShortVector or(short s, VectorMask<Short> m);
 
     /**
      * Bitwise XORs this vector with an input vector.
      * <p>
      * This is a vector binary operation where the primitive bitwise XOR

@@ -1076,11 +852,11 @@
      *
      * @param v the input vector
      * @param m the mask controlling lane selection
      * @return the bitwise XOR of this vector with the input vector
      */
-    public abstract ShortVector xor(Vector<Short> v, Mask<Short> m);
+    public abstract ShortVector xor(Vector<Short> v, VectorMask<Short> m);
 
     /**
      * Bitwise XORs this vector with the broadcast of an input scalar, selecting
      * lane elements controlled by a mask.
      * <p>

@@ -1090,11 +866,11 @@
      * @param s the input scalar
      * @param m the mask controlling lane selection
      * @return the bitwise XOR of this vector with the broadcast of an input
      * scalar
      */
-    public abstract ShortVector xor(short s, Mask<Short> m);
+    public abstract ShortVector xor(short s, VectorMask<Short> m);
 
     /**
      * Bitwise NOTs this vector.
      * <p>
      * This is a vector unary operation where the primitive bitwise NOT

@@ -1111,11 +887,11 @@
      * operation ({@code ~}) is applied to lane elements.
      *
      * @param m the mask controlling lane selection
      * @return the bitwise NOT of this vector
      */
-    public abstract ShortVector not(Mask<Short> m);
+    public abstract ShortVector not(VectorMask<Short> m);
 
     /**
      * Logically left shifts this vector by the broadcast of an input scalar.
      * <p>
      * This is a vector binary operation where the primitive logical left shift

@@ -1145,11 +921,11 @@
      * @param s the input scalar; the number of the bits to left shift
      * @param m the mask controlling lane selection
      * @return the result of logically left shifting left this vector by the
      * broadcast of an input scalar
      */
-    public abstract ShortVector shiftL(int s, Mask<Short> m);
+    public abstract ShortVector shiftL(int s, VectorMask<Short> m);
 
 
     // logical, or unsigned, shift right
 
      /**

@@ -1184,11 +960,11 @@
      * @param s the input scalar; the number of the bits to right shift
      * @param m the mask controlling lane selection
      * @return the result of logically right shifting this vector by the
      * broadcast of an input scalar
      */
-    public abstract ShortVector shiftR(int s, Mask<Short> m);
+    public abstract ShortVector shiftR(int s, VectorMask<Short> m);
 
 
     /**
      * Arithmetically right shifts (or signed right shifts) this vector by the
      * broadcast of an input scalar.

@@ -1221,24 +997,24 @@
      * @param s the input scalar; the number of the bits to right shift
      * @param m the mask controlling lane selection
      * @return the result of arithmetically right shifting this vector by the
      * broadcast of an input scalar
      */
-    public abstract ShortVector aShiftR(int s, Mask<Short> m);
+    public abstract ShortVector aShiftR(int s, VectorMask<Short> m);
 
 
     @Override
     public abstract void intoByteArray(byte[] a, int ix);
 
     @Override
-    public abstract void intoByteArray(byte[] a, int ix, Mask<Short> m);
+    public abstract void intoByteArray(byte[] a, int ix, VectorMask<Short> m);
 
     @Override
     public abstract void intoByteBuffer(ByteBuffer bb, int ix);
 
     @Override
-    public abstract void intoByteBuffer(ByteBuffer bb, int ix, Mask<Short> m);
+    public abstract void intoByteBuffer(ByteBuffer bb, int ix, VectorMask<Short> m);
 
 
     // Type specific horizontal reductions
     /**
      * Adds all lane elements of this vector.

@@ -1260,11 +1036,11 @@
      * and the identity value is {@code 0}.
      *
      * @param m the mask controlling lane selection
      * @return the addition of the selected lane elements of this vector
      */
-    public abstract short addAll(Mask<Short> m);
+    public abstract short addAll(VectorMask<Short> m);
 
     /**
      * Multiplies all lane elements of this vector.
      * <p>
      * This is an associative vector reduction operation where the

@@ -1284,11 +1060,11 @@
      * and the identity value is {@code 1}.
      *
      * @param m the mask controlling lane selection
      * @return the multiplication of all the lane elements of this vector
      */
-    public abstract short mulAll(Mask<Short> m);
+    public abstract short mulAll(VectorMask<Short> m);
 
     /**
      * Returns the minimum lane element of this vector.
      * <p>
      * This is an associative vector reduction operation where the operation

@@ -1310,11 +1086,11 @@
      * {@link Short#MAX_VALUE}.
      *
      * @param m the mask controlling lane selection
      * @return the minimum lane element of this vector
      */
-    public abstract short minAll(Mask<Short> m);
+    public abstract short minAll(VectorMask<Short> m);
 
     /**
      * Returns the maximum lane element of this vector.
      * <p>
      * This is an associative vector reduction operation where the operation

@@ -1336,11 +1112,11 @@
      * {@link Short#MIN_VALUE}.
      *
      * @param m the mask controlling lane selection
      * @return the maximum lane element of this vector
      */
-    public abstract short maxAll(Mask<Short> m);
+    public abstract short maxAll(VectorMask<Short> m);
 
     /**
      * Logically ORs all lane elements of this vector.
      * <p>
      * This is an associative vector reduction operation where the logical OR

@@ -1360,11 +1136,11 @@
      * and the identity value is {@code 0}.
      *
      * @param m the mask controlling lane selection
      * @return the logical OR all the lane elements of this vector
      */
-    public abstract short orAll(Mask<Short> m);
+    public abstract short orAll(VectorMask<Short> m);
 
     /**
      * Logically ANDs all lane elements of this vector.
      * <p>
      * This is an associative vector reduction operation where the logical AND

@@ -1384,11 +1160,11 @@
      * and the identity value is {@code -1}.
      *
      * @param m the mask controlling lane selection
      * @return the logical AND all the lane elements of this vector
      */
-    public abstract short andAll(Mask<Short> m);
+    public abstract short andAll(VectorMask<Short> m);
 
     /**
      * Logically XORs all lane elements of this vector.
      * <p>
      * This is an associative vector reduction operation where the logical XOR

@@ -1408,11 +1184,11 @@
      * and the identity value is {@code 0}.
      *
      * @param m the mask controlling lane selection
      * @return the logical XOR all the lane elements of this vector
      */
-    public abstract short xorAll(Mask<Short> m);
+    public abstract short xorAll(VectorMask<Short> m);
 
     // Type specific accessors
 
     /**
      * Gets the lane element at lane index {@code i}

@@ -1490,11 +1266,11 @@
      * @param m the mask
      * @throws IndexOutOfBoundsException if {@code i < 0}, or
      * 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(short[] a, int i, Mask<Short> m);
+    public abstract void intoArray(short[] a, int i, VectorMask<Short> m);
 
     /**
      * Stores this vector into an array using indexes obtained from an index
      * map.
      * <p>

@@ -1537,69 +1313,58 @@
      * {@code j > indexMap.length - this.length()},
      * or for any vector lane index {@code N} where the mask at lane
      * {@code N} is set the result of {@code i + indexMap[j + N]} is
      * {@code < 0} or {@code >= a.length}
      */
-    public void intoArray(short[] a, int i, Mask<Short> m, int[] indexMap, int j) {
+    public void intoArray(short[] a, int i, VectorMask<Short> m, int[] indexMap, int j) {
         forEach(m, (n, e) -> a[i + indexMap[j + n]] = e);
     }
     // Species
 
     @Override
-    public abstract Species<Short> species();
+    public abstract VectorSpecies<Short> species();
 
     /**
-     * Class representing {@link ShortVector}'s of the same {@link Vector.Shape Shape}.
+     * Class representing {@link ShortVector}'s of the same {@link VectorShape VectorShape}.
      */
-    static final class ShortSpecies extends Vector.AbstractSpecies<Short> {
+    static final class ShortSpecies extends AbstractSpecies<Short> {
         final Function<short[], ShortVector> vectorFactory;
-        final Function<boolean[], Vector.Mask<Short>> maskFactory;
 
-        private ShortSpecies(Vector.Shape shape,
+        private ShortSpecies(VectorShape shape,
                           Class<?> boxType,
                           Class<?> maskType,
                           Function<short[], ShortVector> vectorFactory,
-                          Function<boolean[], Vector.Mask<Short>> maskFactory) {
-            super(shape, short.class, Short.SIZE, boxType, maskType);
+                          Function<boolean[], VectorMask<Short>> maskFactory,
+                          Function<IntUnaryOperator, VectorShuffle<Short>> shuffleFromArrayFactory,
+                          fShuffleFromArray<Short> shuffleFromOpFactory) {
+            super(shape, short.class, Short.SIZE, boxType, maskType, maskFactory,
+                  shuffleFromArrayFactory, shuffleFromOpFactory);
             this.vectorFactory = vectorFactory;
-            this.maskFactory = maskFactory;
         }
 
         interface FOp {
             short apply(int i);
         }
 
-        interface FOpm {
-            boolean apply(int i);
-        }
-
         ShortVector op(FOp f) {
             short[] res = new short[length()];
             for (int i = 0; i < length(); i++) {
                 res[i] = f.apply(i);
             }
             return vectorFactory.apply(res);
         }
 
-        ShortVector op(Vector.Mask<Short> o, FOp f) {
+        ShortVector op(VectorMask<Short> o, FOp f) {
             short[] res = new short[length()];
             boolean[] mbits = ((AbstractMask<Short>)o).getBits();
             for (int i = 0; i < length(); i++) {
                 if (mbits[i]) {
                     res[i] = f.apply(i);
                 }
             }
             return vectorFactory.apply(res);
         }
-
-        Vector.Mask<Short> 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);
-        }
     }
 
     /**
      * Finds the preferred species for an element type of {@code short}.
      * <p>

@@ -1609,21 +1374,21 @@
      * shuffles created from such species will be shape compatible.
      *
      * @return the preferred species for an element type of {@code short}
      */
     private static ShortSpecies preferredSpecies() {
-        return (ShortSpecies) Species.ofPreferred(short.class);
+        return (ShortSpecies) VectorSpecies.ofPreferred(short.class);
     }
 
     /**
      * Finds a species for an element type of {@code short} and shape.
      *
      * @param s the shape
      * @return a species for an element type of {@code short} and shape
      * @throws IllegalArgumentException if no such species exists for the shape
      */
-    static ShortSpecies species(Vector.Shape s) {
+    static ShortSpecies species(VectorShape s) {
         Objects.requireNonNull(s);
         switch (s) {
             case S_64_BIT: return (ShortSpecies) SPECIES_64;
             case S_128_BIT: return (ShortSpecies) SPECIES_128;
             case S_256_BIT: return (ShortSpecies) SPECIES_256;

@@ -1631,31 +1396,36 @@
             case S_Max_BIT: return (ShortSpecies) SPECIES_MAX;
             default: throw new IllegalArgumentException("Bad shape: " + s);
         }
     }
 
-    /** Species representing {@link ShortVector}s of {@link Vector.Shape#S_64_BIT Shape.S_64_BIT}. */
-    public static final Species<Short> SPECIES_64 = new ShortSpecies(Shape.S_64_BIT, Short64Vector.class, Short64Vector.Short64Mask.class,
-                                                                     Short64Vector::new, Short64Vector.Short64Mask::new);
-
-    /** Species representing {@link ShortVector}s of {@link Vector.Shape#S_128_BIT Shape.S_128_BIT}. */
-    public static final Species<Short> SPECIES_128 = new ShortSpecies(Shape.S_128_BIT, Short128Vector.class, Short128Vector.Short128Mask.class,
-                                                                      Short128Vector::new, Short128Vector.Short128Mask::new);
-
-    /** Species representing {@link ShortVector}s of {@link Vector.Shape#S_256_BIT Shape.S_256_BIT}. */
-    public static final Species<Short> SPECIES_256 = new ShortSpecies(Shape.S_256_BIT, Short256Vector.class, Short256Vector.Short256Mask.class,
-                                                                      Short256Vector::new, Short256Vector.Short256Mask::new);
-
-    /** Species representing {@link ShortVector}s of {@link Vector.Shape#S_512_BIT Shape.S_512_BIT}. */
-    public static final Species<Short> SPECIES_512 = new ShortSpecies(Shape.S_512_BIT, Short512Vector.class, Short512Vector.Short512Mask.class,
-                                                                      Short512Vector::new, Short512Vector.Short512Mask::new);
-
-    /** Species representing {@link ShortVector}s of {@link Vector.Shape#S_Max_BIT Shape.S_Max_BIT}. */
-    public static final Species<Short> SPECIES_MAX = new ShortSpecies(Shape.S_Max_BIT, ShortMaxVector.class, ShortMaxVector.ShortMaxMask.class,
-                                                                      ShortMaxVector::new, ShortMaxVector.ShortMaxMask::new);
+    /** Species representing {@link ShortVector}s of {@link VectorShape#S_64_BIT VectorShape.S_64_BIT}. */
+    public static final VectorSpecies<Short> SPECIES_64 = new ShortSpecies(VectorShape.S_64_BIT, Short64Vector.class, Short64Vector.Short64Mask.class,
+                                                                     Short64Vector::new, Short64Vector.Short64Mask::new,
+                                                                     Short64Vector.Short64Shuffle::new, Short64Vector.Short64Shuffle::new);
+
+    /** Species representing {@link ShortVector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */
+    public static final VectorSpecies<Short> SPECIES_128 = new ShortSpecies(VectorShape.S_128_BIT, Short128Vector.class, Short128Vector.Short128Mask.class,
+                                                                      Short128Vector::new, Short128Vector.Short128Mask::new,
+                                                                      Short128Vector.Short128Shuffle::new, Short128Vector.Short128Shuffle::new);
+
+    /** Species representing {@link ShortVector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */
+    public static final VectorSpecies<Short> SPECIES_256 = new ShortSpecies(VectorShape.S_256_BIT, Short256Vector.class, Short256Vector.Short256Mask.class,
+                                                                      Short256Vector::new, Short256Vector.Short256Mask::new,
+                                                                      Short256Vector.Short256Shuffle::new, Short256Vector.Short256Shuffle::new);
+
+    /** Species representing {@link ShortVector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */
+    public static final VectorSpecies<Short> SPECIES_512 = new ShortSpecies(VectorShape.S_512_BIT, Short512Vector.class, Short512Vector.Short512Mask.class,
+                                                                      Short512Vector::new, Short512Vector.Short512Mask::new,
+                                                                      Short512Vector.Short512Shuffle::new, Short512Vector.Short512Shuffle::new);
+
+    /** Species representing {@link ShortVector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */
+    public static final VectorSpecies<Short> SPECIES_MAX = new ShortSpecies(VectorShape.S_Max_BIT, ShortMaxVector.class, ShortMaxVector.ShortMaxMask.class,
+                                                                      ShortMaxVector::new, ShortMaxVector.ShortMaxMask::new,
+                                                                      ShortMaxVector.ShortMaxShuffle::new, ShortMaxVector.ShortMaxShuffle::new);
 
     /**
      * Preferred species for {@link ShortVector}s.
      * A preferred species is a species of maximal bit size for the platform.
      */
-    public static final Species<Short> SPECIES_PREFERRED = (Species<Short>) preferredSpecies();
+    public static final VectorSpecies<Short> SPECIES_PREFERRED = (VectorSpecies<Short>) preferredSpecies();
 }
< prev index next >