< prev index next >

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template

Print this page




 498      */
 499 #if[intOrLong]
 500     public static $abstractvectortype$ random(Species<$Boxtype$> s) {
 501         ThreadLocalRandom r = ThreadLocalRandom.current();
 502         return (($Type$Species)s).op(i -> r.next$Type$());
 503     }
 504 #else[intOrLong]
 505 #if[FP]
 506     public static $abstractvectortype$ random(Species<$Boxtype$> s) {
 507         ThreadLocalRandom r = ThreadLocalRandom.current();
 508         return (($Type$Species)s).op(i -> r.next$Type$());
 509     }
 510 #else[FP]
 511     public static $abstractvectortype$ random(Species<$Boxtype$> s) {
 512         ThreadLocalRandom r = ThreadLocalRandom.current();
 513         return (($Type$Species)s).op(i -> ($type$) r.nextInt());
 514     }
 515 #end[FP]
 516 #end[intOrLong]
 517 
 518     /**
 519      * Returns a mask where each lane is set or unset according to given
 520      * {@code boolean} values
 521      * <p>
 522      * For each mask lane, where {@code N} is the mask lane index,
 523      * if the given {@code boolean} value at index {@code N} is {@code true}
 524      * then the mask lane at index {@code N} is set, otherwise it is unset.
 525      *
 526      * @param species mask species
 527      * @param bits the given {@code boolean} values
 528      * @return a mask where each lane is set or unset according to the given {@code boolean} value
 529      * @throws IndexOutOfBoundsException if {@code bits.length < species.length()}
 530      */
 531     @ForceInline
 532     public static Mask<$Boxtype$> maskFromValues(Species<$Boxtype$> species, boolean... bits) {
 533         if (species.boxType() == $Type$MaxVector.class)
 534             return new $Type$MaxVector.$Type$MaxMask(bits);
 535         switch (species.bitSize()) {
 536             case 64: return new $Type$64Vector.$Type$64Mask(bits);
 537             case 128: return new $Type$128Vector.$Type$128Mask(bits);
 538             case 256: return new $Type$256Vector.$Type$256Mask(bits);
 539             case 512: return new $Type$512Vector.$Type$512Mask(bits);
 540             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 541         }
 542     }
 543 
 544     // @@@ This is a bad implementation -- makes lambdas capturing -- fix this
 545     static Mask<$Boxtype$> trueMask(Species<$Boxtype$> species) {
 546         if (species.boxType() == $Type$MaxVector.class)
 547             return $Type$MaxVector.$Type$MaxMask.TRUE_MASK;
 548         switch (species.bitSize()) {
 549             case 64: return $Type$64Vector.$Type$64Mask.TRUE_MASK;
 550             case 128: return $Type$128Vector.$Type$128Mask.TRUE_MASK;
 551             case 256: return $Type$256Vector.$Type$256Mask.TRUE_MASK;
 552             case 512: return $Type$512Vector.$Type$512Mask.TRUE_MASK;
 553             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 554         }
 555     }
 556 
 557     static Mask<$Boxtype$> falseMask(Species<$Boxtype$> species) {
 558         if (species.boxType() == $Type$MaxVector.class)
 559             return $Type$MaxVector.$Type$MaxMask.FALSE_MASK;
 560         switch (species.bitSize()) {
 561             case 64: return $Type$64Vector.$Type$64Mask.FALSE_MASK;
 562             case 128: return $Type$128Vector.$Type$128Mask.FALSE_MASK;
 563             case 256: return $Type$256Vector.$Type$256Mask.FALSE_MASK;
 564             case 512: return $Type$512Vector.$Type$512Mask.FALSE_MASK;
 565             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 566         }
 567     }
 568 
 569     /**
 570      * Loads a mask from a {@code boolean} array starting at an offset.
 571      * <p>
 572      * For each mask lane, where {@code N} is the mask lane index,
 573      * if the array element at index {@code ix + N} is {@code true} then the
 574      * mask lane at index {@code N} is set, otherwise it is unset.
 575      *
 576      * @param species mask species
 577      * @param bits the {@code boolean} array
 578      * @param ix the offset into the array
 579      * @return the mask loaded from a {@code boolean} array
 580      * @throws IndexOutOfBoundsException if {@code ix < 0}, or
 581      * {@code ix > bits.length - species.length()}
 582      */
 583     @ForceInline
 584     @SuppressWarnings("unchecked")
 585     public static Mask<$Boxtype$> maskFromArray(Species<$Boxtype$> species, boolean[] bits, int ix) {
 586         Objects.requireNonNull(bits);
 587         ix = VectorIntrinsics.checkIndex(ix, bits.length, species.length());
 588         return VectorIntrinsics.load((Class<Mask<$Boxtype$>>) species.maskType(), $bitstype$.class, species.length(),
 589                                      bits, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_BOOLEAN_BASE_OFFSET,
 590                                      bits, ix, species,
 591                                      (c, idx, s) -> (Mask<$Boxtype$>) (($Type$Species)s).opm(n -> c[idx + n]));
 592     }
 593 
 594     /**
 595      * Returns a mask where all lanes are set.
 596      *
 597      * @param species mask species
 598      * @return a mask where all lanes are set
 599      */
 600     @ForceInline
 601     @SuppressWarnings("unchecked")
 602     public static Mask<$Boxtype$> maskAllTrue(Species<$Boxtype$> species) {
 603         return VectorIntrinsics.broadcastCoerced((Class<Mask<$Boxtype$>>) species.maskType(), $bitstype$.class, species.length(),
 604                                                  ($bitstype$)-1,  species,
 605                                                  ((z, s) -> trueMask(s)));
 606     }
 607 
 608     /**
 609      * Returns a mask where all lanes are unset.
 610      *
 611      * @param species mask species
 612      * @return a mask where all lanes are unset
 613      */
 614     @ForceInline
 615     @SuppressWarnings("unchecked")
 616     public static Mask<$Boxtype$> maskAllFalse(Species<$Boxtype$> species) {
 617         return VectorIntrinsics.broadcastCoerced((Class<Mask<$Boxtype$>>) species.maskType(), $bitstype$.class, species.length(),
 618                                                  0, species, 
 619                                                  ((z, s) -> falseMask(s)));
 620     }
 621 
 622     /**
 623      * Returns a shuffle of mapped indexes where each lane element is
 624      * the result of applying a mapping function to the corresponding lane
 625      * index.
 626      * <p>
 627      * Care should be taken to ensure Shuffle values produced from this
 628      * method are consumed as constants to ensure optimal generation of
 629      * code.  For example, values held in static final fields or values
 630      * held in loop constant local variables.
 631      * <p>
 632      * This method behaves as if a shuffle is created from an array of
 633      * mapped indexes as follows:
 634      * <pre>{@code
 635      *   int[] a = new int[species.length()];
 636      *   for (int i = 0; i < a.length; i++) {
 637      *       a[i] = f.applyAsInt(i);
 638      *   }
 639      *   return this.shuffleFromValues(a);
 640      * }</pre>
 641      *
 642      * @param species shuffle species
 643      * @param f the lane index mapping function
 644      * @return a shuffle of mapped indexes
 645      */
 646     @ForceInline
 647     public static Shuffle<$Boxtype$> shuffle(Species<$Boxtype$> species, IntUnaryOperator f) {
 648         if (species.boxType() == $Type$MaxVector.class)
 649             return new $Type$MaxVector.$Type$MaxShuffle(f);
 650         switch (species.bitSize()) {
 651             case 64: return new $Type$64Vector.$Type$64Shuffle(f);
 652             case 128: return new $Type$128Vector.$Type$128Shuffle(f);
 653             case 256: return new $Type$256Vector.$Type$256Shuffle(f);
 654             case 512: return new $Type$512Vector.$Type$512Shuffle(f);
 655             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 656         }
 657     }
 658 
 659     /**
 660      * Returns a shuffle where each lane element is the value of its
 661      * corresponding lane index.
 662      * <p>
 663      * This method behaves as if a shuffle is created from an identity
 664      * index mapping function as follows:
 665      * <pre>{@code
 666      *   return this.shuffle(i -> i);
 667      * }</pre>
 668      *
 669      * @param species shuffle species
 670      * @return a shuffle of lane indexes
 671      */
 672     @ForceInline
 673     public static Shuffle<$Boxtype$> shuffleIota(Species<$Boxtype$> species) {
 674         if (species.boxType() == $Type$MaxVector.class)
 675             return new $Type$MaxVector.$Type$MaxShuffle(AbstractShuffle.IDENTITY);
 676         switch (species.bitSize()) {
 677             case 64: return new $Type$64Vector.$Type$64Shuffle(AbstractShuffle.IDENTITY);
 678             case 128: return new $Type$128Vector.$Type$128Shuffle(AbstractShuffle.IDENTITY);
 679             case 256: return new $Type$256Vector.$Type$256Shuffle(AbstractShuffle.IDENTITY);
 680             case 512: return new $Type$512Vector.$Type$512Shuffle(AbstractShuffle.IDENTITY);
 681             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 682         }
 683     }
 684 
 685     /**
 686      * Returns a shuffle where each lane element is set to a given
 687      * {@code int} value logically AND'ed by the species length minus one.
 688      * <p>
 689      * For each shuffle lane, where {@code N} is the shuffle lane index, the
 690      * the {@code int} value at index {@code N} logically AND'ed by
 691      * {@code species.length() - 1} is placed into the resulting shuffle at
 692      * lane index {@code N}.
 693      *
 694      * @param species shuffle species
 695      * @param ixs the given {@code int} values
 696      * @return a shuffle where each lane element is set to a given
 697      * {@code int} value
 698      * @throws IndexOutOfBoundsException if the number of int values is
 699      * {@code < species.length()}
 700      */
 701     @ForceInline
 702     public static Shuffle<$Boxtype$> shuffleFromValues(Species<$Boxtype$> species, int... ixs) {
 703         if (species.boxType() == $Type$MaxVector.class)
 704             return new $Type$MaxVector.$Type$MaxShuffle(ixs);
 705         switch (species.bitSize()) {
 706             case 64: return new $Type$64Vector.$Type$64Shuffle(ixs);
 707             case 128: return new $Type$128Vector.$Type$128Shuffle(ixs);
 708             case 256: return new $Type$256Vector.$Type$256Shuffle(ixs);
 709             case 512: return new $Type$512Vector.$Type$512Shuffle(ixs);
 710             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 711         }
 712     }
 713 
 714     /**
 715      * Loads a shuffle from an {@code int} array starting at an offset.
 716      * <p>
 717      * For each shuffle lane, where {@code N} is the shuffle lane index, the
 718      * array element at index {@code i + N} logically AND'ed by
 719      * {@code species.length() - 1} is placed into the resulting shuffle at lane
 720      * index {@code N}.
 721      *
 722      * @param species shuffle species
 723      * @param ixs the {@code int} array
 724      * @param i the offset into the array
 725      * @return a shuffle loaded from the {@code int} array
 726      * @throws IndexOutOfBoundsException if {@code i < 0}, or
 727      * {@code i > a.length - species.length()}
 728      */
 729     @ForceInline
 730     public static Shuffle<$Boxtype$> shuffleFromArray(Species<$Boxtype$> species, int[] ixs, int i) {
 731         if (species.boxType() == $Type$MaxVector.class)
 732             return new $Type$MaxVector.$Type$MaxShuffle(ixs, i);
 733         switch (species.bitSize()) {
 734             case 64: return new $Type$64Vector.$Type$64Shuffle(ixs, i);
 735             case 128: return new $Type$128Vector.$Type$128Shuffle(ixs, i);
 736             case 256: return new $Type$256Vector.$Type$256Shuffle(ixs, i);
 737             case 512: return new $Type$512Vector.$Type$512Shuffle(ixs, i);
 738             default: throw new IllegalArgumentException(Integer.toString(species.bitSize()));
 739         }
 740     }
 741 
 742     // Ops
 743 
 744     @Override
 745     public abstract $abstractvectortype$ add(Vector<$Boxtype$> v);
 746 
 747     /**
 748      * Adds this vector to the broadcast of an input scalar.
 749      * <p>
 750      * This is a vector binary operation where the primitive addition operation
 751      * ({@code +}) is applied to lane elements.
 752      *
 753      * @param s the input scalar
 754      * @return the result of adding this vector to the broadcast of an input
 755      * scalar
 756      */
 757     public abstract $abstractvectortype$ add($type$ s);
 758 
 759     @Override
 760     public abstract $abstractvectortype$ add(Vector<$Boxtype$> v, Mask<$Boxtype$> m);
 761 


2912      * @param j the offset into the index map
2913      * @throws IndexOutOfBoundsException if {@code j < 0}, or
2914      * {@code j > indexMap.length - this.length()},
2915      * or for any vector lane index {@code N} where the mask at lane
2916      * {@code N} is set the result of {@code i + indexMap[j + N]} is
2917      * {@code < 0} or {@code >= a.length}
2918      */
2919 #if[byteOrShort]
2920     public void intoArray($type$[] a, int i, Mask<$Boxtype$> m, int[] indexMap, int j) {
2921         forEach(m, (n, e) -> a[i + indexMap[j + n]] = e);
2922     }
2923 #else[byteOrShort]
2924     public abstract void intoArray($type$[] a, int i, Mask<$Boxtype$> m, int[] indexMap, int j);
2925 #end[byteOrShort]
2926     // Species
2927 
2928     @Override
2929     public abstract Species<$Boxtype$> species();
2930 
2931     /**
2932      * Class representing {@link $abstractvectortype$}'s of the same {@link Vector.Shape Shape}.
2933      */
2934     static final class $Type$Species extends Vector.AbstractSpecies<$Boxtype$> {
2935         final Function<$type$[], $Type$Vector> vectorFactory;
2936         final Function<boolean[], Vector.Mask<$Boxtype$>> maskFactory;
2937 
2938         private $Type$Species(Vector.Shape shape,
2939                           Class<?> boxType,
2940                           Class<?> maskType,
2941                           Function<$type$[], $Type$Vector> vectorFactory,
2942                           Function<boolean[], Vector.Mask<$Boxtype$>> maskFactory) {
2943             super(shape, $type$.class, $Boxtype$.SIZE, boxType, maskType);



2944             this.vectorFactory = vectorFactory;
2945             this.maskFactory = maskFactory;
2946         }
2947 
2948         interface FOp {
2949             $type$ apply(int i);
2950         }
2951 
2952         interface FOpm {
2953             boolean apply(int i);
2954         }
2955 
2956         $Type$Vector op(FOp f) {
2957             $type$[] res = new $type$[length()];
2958             for (int i = 0; i < length(); i++) {
2959                 res[i] = f.apply(i);
2960             }
2961             return vectorFactory.apply(res);
2962         }
2963 
2964         $Type$Vector op(Vector.Mask<$Boxtype$> o, FOp f) {
2965             $type$[] res = new $type$[length()];
2966             boolean[] mbits = ((AbstractMask<$Boxtype$>)o).getBits();
2967             for (int i = 0; i < length(); i++) {
2968                 if (mbits[i]) {
2969                     res[i] = f.apply(i);
2970                 }
2971             }
2972             return vectorFactory.apply(res);
2973         }
2974 
2975         Vector.Mask<$Boxtype$> opm(IntVector.IntSpecies.FOpm f) {
2976             boolean[] res = new boolean[length()];
2977             for (int i = 0; i < length(); i++) {
2978                 res[i] = (boolean)f.apply(i);
2979             }
2980             return maskFactory.apply(res);
2981         }
2982     }
2983 
2984     /**
2985      * Finds the preferred species for an element type of {@code $type$}.
2986      * <p>
2987      * A preferred species is a species chosen by the platform that has a
2988      * shape of maximal bit size.  A preferred species for different element
2989      * types will have the same shape, and therefore vectors, masks, and
2990      * shuffles created from such species will be shape compatible.
2991      *
2992      * @return the preferred species for an element type of {@code $type$}
2993      */
2994     private static $Type$Species preferredSpecies() {
2995         return ($Type$Species) Species.ofPreferred($type$.class);
2996     }
2997 
2998     /**
2999      * Finds a species for an element type of {@code $type$} and shape.
3000      *
3001      * @param s the shape
3002      * @return a species for an element type of {@code $type$} and shape
3003      * @throws IllegalArgumentException if no such species exists for the shape
3004      */
3005     static $Type$Species species(Vector.Shape s) {
3006         Objects.requireNonNull(s);
3007         switch (s) {
3008             case S_64_BIT: return ($Type$Species) SPECIES_64;
3009             case S_128_BIT: return ($Type$Species) SPECIES_128;
3010             case S_256_BIT: return ($Type$Species) SPECIES_256;
3011             case S_512_BIT: return ($Type$Species) SPECIES_512;
3012             case S_Max_BIT: return ($Type$Species) SPECIES_MAX;
3013             default: throw new IllegalArgumentException("Bad shape: " + s);
3014         }
3015     }
3016 
3017     /** Species representing {@link $Type$Vector}s of {@link Vector.Shape#S_64_BIT Shape.S_64_BIT}. */
3018     public static final Species<$Boxtype$> SPECIES_64 = new $Type$Species(Shape.S_64_BIT, $Type$64Vector.class, $Type$64Vector.$Type$64Mask.class,
3019                                                                      $Type$64Vector::new, $Type$64Vector.$Type$64Mask::new);

3020 
3021     /** Species representing {@link $Type$Vector}s of {@link Vector.Shape#S_128_BIT Shape.S_128_BIT}. */
3022     public static final Species<$Boxtype$> SPECIES_128 = new $Type$Species(Shape.S_128_BIT, $Type$128Vector.class, $Type$128Vector.$Type$128Mask.class,
3023                                                                       $Type$128Vector::new, $Type$128Vector.$Type$128Mask::new);

3024 
3025     /** Species representing {@link $Type$Vector}s of {@link Vector.Shape#S_256_BIT Shape.S_256_BIT}. */
3026     public static final Species<$Boxtype$> SPECIES_256 = new $Type$Species(Shape.S_256_BIT, $Type$256Vector.class, $Type$256Vector.$Type$256Mask.class,
3027                                                                       $Type$256Vector::new, $Type$256Vector.$Type$256Mask::new);

3028 
3029     /** Species representing {@link $Type$Vector}s of {@link Vector.Shape#S_512_BIT Shape.S_512_BIT}. */
3030     public static final Species<$Boxtype$> SPECIES_512 = new $Type$Species(Shape.S_512_BIT, $Type$512Vector.class, $Type$512Vector.$Type$512Mask.class,
3031                                                                       $Type$512Vector::new, $Type$512Vector.$Type$512Mask::new);

3032 
3033     /** Species representing {@link $Type$Vector}s of {@link Vector.Shape#S_Max_BIT Shape.S_Max_BIT}. */
3034     public static final Species<$Boxtype$> SPECIES_MAX = new $Type$Species(Shape.S_Max_BIT, $Type$MaxVector.class, $Type$MaxVector.$Type$MaxMask.class,
3035                                                                       $Type$MaxVector::new, $Type$MaxVector.$Type$MaxMask::new);

3036 
3037     /**
3038      * Preferred species for {@link $Type$Vector}s.
3039      * A preferred species is a species of maximal bit size for the platform.
3040      */
3041     public static final Species<$Boxtype$> SPECIES_PREFERRED = (Species<$Boxtype$>) preferredSpecies();
3042 }


 498      */
 499 #if[intOrLong]
 500     public static $abstractvectortype$ random(Species<$Boxtype$> s) {
 501         ThreadLocalRandom r = ThreadLocalRandom.current();
 502         return (($Type$Species)s).op(i -> r.next$Type$());
 503     }
 504 #else[intOrLong]
 505 #if[FP]
 506     public static $abstractvectortype$ random(Species<$Boxtype$> s) {
 507         ThreadLocalRandom r = ThreadLocalRandom.current();
 508         return (($Type$Species)s).op(i -> r.next$Type$());
 509     }
 510 #else[FP]
 511     public static $abstractvectortype$ random(Species<$Boxtype$> s) {
 512         ThreadLocalRandom r = ThreadLocalRandom.current();
 513         return (($Type$Species)s).op(i -> ($type$) r.nextInt());
 514     }
 515 #end[FP]
 516 #end[intOrLong]
 517 
































































































































































































































 518     // Ops
 519 
 520     @Override
 521     public abstract $abstractvectortype$ add(Vector<$Boxtype$> v);
 522 
 523     /**
 524      * Adds this vector to the broadcast of an input scalar.
 525      * <p>
 526      * This is a vector binary operation where the primitive addition operation
 527      * ({@code +}) is applied to lane elements.
 528      *
 529      * @param s the input scalar
 530      * @return the result of adding this vector to the broadcast of an input
 531      * scalar
 532      */
 533     public abstract $abstractvectortype$ add($type$ s);
 534 
 535     @Override
 536     public abstract $abstractvectortype$ add(Vector<$Boxtype$> v, Mask<$Boxtype$> m);
 537 


2688      * @param j the offset into the index map
2689      * @throws IndexOutOfBoundsException if {@code j < 0}, or
2690      * {@code j > indexMap.length - this.length()},
2691      * or for any vector lane index {@code N} where the mask at lane
2692      * {@code N} is set the result of {@code i + indexMap[j + N]} is
2693      * {@code < 0} or {@code >= a.length}
2694      */
2695 #if[byteOrShort]
2696     public void intoArray($type$[] a, int i, Mask<$Boxtype$> m, int[] indexMap, int j) {
2697         forEach(m, (n, e) -> a[i + indexMap[j + n]] = e);
2698     }
2699 #else[byteOrShort]
2700     public abstract void intoArray($type$[] a, int i, Mask<$Boxtype$> m, int[] indexMap, int j);
2701 #end[byteOrShort]
2702     // Species
2703 
2704     @Override
2705     public abstract Species<$Boxtype$> species();
2706 
2707     /**
2708      * Class representing {@link $abstractvectortype$}'s of the same {@link Shape Shape}.
2709      */
2710     static final class $Type$Species extends AbstractSpecies<$Boxtype$> {
2711         final Function<$type$[], $Type$Vector> vectorFactory;

2712 
2713         private $Type$Species(Shape shape,
2714                           Class<?> boxType,
2715                           Class<?> maskType,
2716                           Function<$type$[], $Type$Vector> vectorFactory,
2717                           Function<boolean[], Mask<$Boxtype$>> maskFactory,
2718                           Function<IntUnaryOperator, Shuffle<$Boxtype$>> shuffleFromArrayFactory,
2719                           fShuffleFromArray<$Boxtype$> shuffleFromOpFactory) {
2720             super(shape, $type$.class, $Boxtype$.SIZE, boxType, maskType, maskFactory,
2721                   shuffleFromArrayFactory, shuffleFromOpFactory);
2722             this.vectorFactory = vectorFactory;

2723         }
2724 
2725         interface FOp {
2726             $type$ apply(int i);
2727         }
2728 
2729         interface FOpm {
2730             boolean apply(int i);
2731         }
2732 
2733         $Type$Vector op(FOp f) {
2734             $type$[] res = new $type$[length()];
2735             for (int i = 0; i < length(); i++) {
2736                 res[i] = f.apply(i);
2737             }
2738             return vectorFactory.apply(res);
2739         }
2740 
2741         $Type$Vector op(Mask<$Boxtype$> o, FOp f) {
2742             $type$[] res = new $type$[length()];
2743             boolean[] mbits = ((AbstractMask<$Boxtype$>)o).getBits();
2744             for (int i = 0; i < length(); i++) {
2745                 if (mbits[i]) {
2746                     res[i] = f.apply(i);
2747                 }
2748             }
2749             return vectorFactory.apply(res);
2750         }








2751     }
2752 
2753     /**
2754      * Finds the preferred species for an element type of {@code $type$}.
2755      * <p>
2756      * A preferred species is a species chosen by the platform that has a
2757      * shape of maximal bit size.  A preferred species for different element
2758      * types will have the same shape, and therefore vectors, masks, and
2759      * shuffles created from such species will be shape compatible.
2760      *
2761      * @return the preferred species for an element type of {@code $type$}
2762      */
2763     private static $Type$Species preferredSpecies() {
2764         return ($Type$Species) Species.ofPreferred($type$.class);
2765     }
2766 
2767     /**
2768      * Finds a species for an element type of {@code $type$} and shape.
2769      *
2770      * @param s the shape
2771      * @return a species for an element type of {@code $type$} and shape
2772      * @throws IllegalArgumentException if no such species exists for the shape
2773      */
2774     static $Type$Species species(Shape s) {
2775         Objects.requireNonNull(s);
2776         switch (s) {
2777             case S_64_BIT: return ($Type$Species) SPECIES_64;
2778             case S_128_BIT: return ($Type$Species) SPECIES_128;
2779             case S_256_BIT: return ($Type$Species) SPECIES_256;
2780             case S_512_BIT: return ($Type$Species) SPECIES_512;
2781             case S_Max_BIT: return ($Type$Species) SPECIES_MAX;
2782             default: throw new IllegalArgumentException("Bad shape: " + s);
2783         }
2784     }
2785 
2786     /** Species representing {@link $Type$Vector}s of {@link Shape#S_64_BIT Shape.S_64_BIT}. */
2787     public static final Species<$Boxtype$> SPECIES_64 = new $Type$Species(Shape.S_64_BIT, $Type$64Vector.class, $Type$64Vector.$Type$64Mask.class,
2788                                                                      $Type$64Vector::new, $Type$64Vector.$Type$64Mask::new,
2789                                                                      $Type$64Vector.$Type$64Shuffle::new, $Type$64Vector.$Type$64Shuffle::new);
2790 
2791     /** Species representing {@link $Type$Vector}s of {@link Shape#S_128_BIT Shape.S_128_BIT}. */
2792     public static final Species<$Boxtype$> SPECIES_128 = new $Type$Species(Shape.S_128_BIT, $Type$128Vector.class, $Type$128Vector.$Type$128Mask.class,
2793                                                                       $Type$128Vector::new, $Type$128Vector.$Type$128Mask::new,
2794                                                                       $Type$128Vector.$Type$128Shuffle::new, $Type$128Vector.$Type$128Shuffle::new);
2795 
2796     /** Species representing {@link $Type$Vector}s of {@link Shape#S_256_BIT Shape.S_256_BIT}. */
2797     public static final Species<$Boxtype$> SPECIES_256 = new $Type$Species(Shape.S_256_BIT, $Type$256Vector.class, $Type$256Vector.$Type$256Mask.class,
2798                                                                       $Type$256Vector::new, $Type$256Vector.$Type$256Mask::new,
2799                                                                       $Type$256Vector.$Type$256Shuffle::new, $Type$256Vector.$Type$256Shuffle::new);
2800 
2801     /** Species representing {@link $Type$Vector}s of {@link Shape#S_512_BIT Shape.S_512_BIT}. */
2802     public static final Species<$Boxtype$> SPECIES_512 = new $Type$Species(Shape.S_512_BIT, $Type$512Vector.class, $Type$512Vector.$Type$512Mask.class,
2803                                                                       $Type$512Vector::new, $Type$512Vector.$Type$512Mask::new,
2804                                                                       $Type$512Vector.$Type$512Shuffle::new, $Type$512Vector.$Type$512Shuffle::new);
2805 
2806     /** Species representing {@link $Type$Vector}s of {@link Shape#S_Max_BIT Shape.S_Max_BIT}. */
2807     public static final Species<$Boxtype$> SPECIES_MAX = new $Type$Species(Shape.S_Max_BIT, $Type$MaxVector.class, $Type$MaxVector.$Type$MaxMask.class,
2808                                                                       $Type$MaxVector::new, $Type$MaxVector.$Type$MaxMask::new,
2809                                                                       $Type$MaxVector.$Type$MaxShuffle::new, $Type$MaxVector.$Type$MaxShuffle::new);
2810 
2811     /**
2812      * Preferred species for {@link $Type$Vector}s.
2813      * A preferred species is a species of maximal bit size for the platform.
2814      */
2815     public static final Species<$Boxtype$> SPECIES_PREFERRED = (Species<$Boxtype$>) preferredSpecies();
2816 }
< prev index next >