1 /*
  2  * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.  Oracle designates this
  8  * particular file as subject to the "Classpath" exception as provided
  9  * by Oracle in the LICENSE file that accompanied this code.
 10  *
 11  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  * version 2 for more details (a copy is included in the LICENSE file that
 15  * accompanied this code).
 16  *
 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any
 23  * questions.
 24  */
 25 package jdk.incubator.vector;
 26 
 27 import java.nio.ByteBuffer;
 28 import java.util.Arrays;
 29 import java.util.Objects;
 30 import java.util.function.IntUnaryOperator;
 31 
 32 import jdk.internal.vm.annotation.ForceInline;
 33 import jdk.internal.vm.vector.VectorSupport;
 34 
 35 import static jdk.internal.vm.vector.VectorSupport.*;
 36 
 37 import static jdk.incubator.vector.VectorOperators.*;
 38 
 39 // -- This file was mechanically generated: Do not edit! -- //
 40 
 41 @SuppressWarnings("cast")  // warning: redundant cast
 42 final class FloatMaxVector extends FloatVector {
 43     static final FloatSpecies VSPECIES =
 44         (FloatSpecies) FloatVector.SPECIES_MAX;
 45 
 46     static final VectorShape VSHAPE =
 47         VSPECIES.vectorShape();
 48 
 49     static final Class<FloatMaxVector> VCLASS = FloatMaxVector.class;
 50 
 51     static final int VSIZE = VSPECIES.vectorBitSize();
 52 
 53     static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
 54 
 55     static final Class<Float> ETYPE = float.class; // used by the JVM
 56 
 57     FloatMaxVector(float[] v) {
 58         super(v);
 59     }
 60 
 61     // For compatibility as FloatMaxVector::new,
 62     // stored into species.vectorFactory.
 63     FloatMaxVector(Object v) {
 64         this((float[]) v);
 65     }
 66 
 67     static final FloatMaxVector ZERO = new FloatMaxVector(new float[VLENGTH]);
 68     static final FloatMaxVector IOTA = new FloatMaxVector(VSPECIES.iotaArray());
 69 
 70     static {
 71         // Warm up a few species caches.
 72         // If we do this too much we will
 73         // get NPEs from bootstrap circularity.
 74         VSPECIES.dummyVector();
 75         VSPECIES.withLanes(LaneType.BYTE);
 76     }
 77 
 78     // Specialized extractors
 79 
 80     @ForceInline
 81     final @Override
 82     public FloatSpecies vspecies() {
 83         // ISSUE:  This should probably be a @Stable
 84         // field inside AbstractVector, rather than
 85         // a megamorphic method.
 86         return VSPECIES;
 87     }
 88 
 89     @ForceInline
 90     @Override
 91     public final Class<Float> elementType() { return float.class; }
 92 
 93     @ForceInline
 94     @Override
 95     public final int elementSize() { return Float.SIZE; }
 96 
 97     @ForceInline
 98     @Override
 99     public final VectorShape shape() { return VSHAPE; }
100 
101     @ForceInline
102     @Override
103     public final int length() { return VLENGTH; }
104 
105     @ForceInline
106     @Override
107     public final int bitSize() { return VSIZE; }
108 
109     @ForceInline
110     @Override
111     public final int byteSize() { return VSIZE / Byte.SIZE; }
112 
113     /*package-private*/
114     @ForceInline
115     final @Override
116     float[] vec() {
117         return (float[])getPayload();
118     }
119 
120     // Virtualized constructors
121 
122     @Override
123     @ForceInline
124     public final FloatMaxVector broadcast(float e) {
125         return (FloatMaxVector) super.broadcastTemplate(e);  // specialize
126     }
127 
128     @Override
129     @ForceInline
130     public final FloatMaxVector broadcast(long e) {
131         return (FloatMaxVector) super.broadcastTemplate(e);  // specialize
132     }
133 
134     @Override
135     @ForceInline
136     FloatMaxMask maskFromArray(boolean[] bits) {
137         return new FloatMaxMask(bits);
138     }
139 
140     @Override
141     @ForceInline
142     FloatMaxShuffle iotaShuffle() { return FloatMaxShuffle.IOTA; }
143 
144     @ForceInline
145     FloatMaxShuffle iotaShuffle(int start, int step, boolean wrap) {
146       if (wrap) {
147         return (FloatMaxShuffle)VectorSupport.shuffleIota(ETYPE, FloatMaxShuffle.class, VSPECIES, VLENGTH, start, step, 1,
148                 (l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
149       } else {
150         return (FloatMaxShuffle)VectorSupport.shuffleIota(ETYPE, FloatMaxShuffle.class, VSPECIES, VLENGTH, start, step, 0,
151                 (l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
152       }
153     }
154 
155     @Override
156     @ForceInline
157     FloatMaxShuffle shuffleFromBytes(byte[] reorder) { return new FloatMaxShuffle(reorder); }
158 
159     @Override
160     @ForceInline
161     FloatMaxShuffle shuffleFromArray(int[] indexes, int i) { return new FloatMaxShuffle(indexes, i); }
162 
163     @Override
164     @ForceInline
165     FloatMaxShuffle shuffleFromOp(IntUnaryOperator fn) { return new FloatMaxShuffle(fn); }
166 
167     // Make a vector of the same species but the given elements:
168     @ForceInline
169     final @Override
170     FloatMaxVector vectorFactory(float[] vec) {
171         return new FloatMaxVector(vec);
172     }
173 
174     @ForceInline
175     final @Override
176     ByteMaxVector asByteVectorRaw() {
177         return (ByteMaxVector) super.asByteVectorRawTemplate();  // specialize
178     }
179 
180     @ForceInline
181     final @Override
182     AbstractVector<?> asVectorRaw(LaneType laneType) {
183         return super.asVectorRawTemplate(laneType);  // specialize
184     }
185 
186     // Unary operator
187 
188     @ForceInline
189     final @Override
190     FloatMaxVector uOp(FUnOp f) {
191         return (FloatMaxVector) super.uOpTemplate(f);  // specialize
192     }
193 
194     @ForceInline
195     final @Override
196     FloatMaxVector uOp(VectorMask<Float> m, FUnOp f) {
197         return (FloatMaxVector)
198             super.uOpTemplate((FloatMaxMask)m, f);  // specialize
199     }
200 
201     // Binary operator
202 
203     @ForceInline
204     final @Override
205     FloatMaxVector bOp(Vector<Float> v, FBinOp f) {
206         return (FloatMaxVector) super.bOpTemplate((FloatMaxVector)v, f);  // specialize
207     }
208 
209     @ForceInline
210     final @Override
211     FloatMaxVector bOp(Vector<Float> v,
212                      VectorMask<Float> m, FBinOp f) {
213         return (FloatMaxVector)
214             super.bOpTemplate((FloatMaxVector)v, (FloatMaxMask)m,
215                               f);  // specialize
216     }
217 
218     // Ternary operator
219 
220     @ForceInline
221     final @Override
222     FloatMaxVector tOp(Vector<Float> v1, Vector<Float> v2, FTriOp f) {
223         return (FloatMaxVector)
224             super.tOpTemplate((FloatMaxVector)v1, (FloatMaxVector)v2,
225                               f);  // specialize
226     }
227 
228     @ForceInline
229     final @Override
230     FloatMaxVector tOp(Vector<Float> v1, Vector<Float> v2,
231                      VectorMask<Float> m, FTriOp f) {
232         return (FloatMaxVector)
233             super.tOpTemplate((FloatMaxVector)v1, (FloatMaxVector)v2,
234                               (FloatMaxMask)m, f);  // specialize
235     }
236 
237     @ForceInline
238     final @Override
239     float rOp(float v, FBinOp f) {
240         return super.rOpTemplate(v, f);  // specialize
241     }
242 
243     @Override
244     @ForceInline
245     public final <F>
246     Vector<F> convertShape(VectorOperators.Conversion<Float,F> conv,
247                            VectorSpecies<F> rsp, int part) {
248         return super.convertShapeTemplate(conv, rsp, part);  // specialize
249     }
250 
251     @Override
252     @ForceInline
253     public final <F>
254     Vector<F> reinterpretShape(VectorSpecies<F> toSpecies, int part) {
255         return super.reinterpretShapeTemplate(toSpecies, part);  // specialize
256     }
257 
258     // Specialized algebraic operations:
259 
260     // The following definition forces a specialized version of this
261     // crucial method into the v-table of this class.  A call to add()
262     // will inline to a call to lanewise(ADD,), at which point the JIT
263     // intrinsic will have the opcode of ADD, plus all the metadata
264     // for this particular class, enabling it to generate precise
265     // code.
266     //
267     // There is probably no benefit to the JIT to specialize the
268     // masked or broadcast versions of the lanewise method.
269 
270     @Override
271     @ForceInline
272     public FloatMaxVector lanewise(Unary op) {
273         return (FloatMaxVector) super.lanewiseTemplate(op);  // specialize
274     }
275 
276     @Override
277     @ForceInline
278     public FloatMaxVector lanewise(Binary op, Vector<Float> v) {
279         return (FloatMaxVector) super.lanewiseTemplate(op, v);  // specialize
280     }
281 
282 
283     /*package-private*/
284     @Override
285     @ForceInline
286     public final
287     FloatMaxVector
288     lanewise(VectorOperators.Ternary op, Vector<Float> v1, Vector<Float> v2) {
289         return (FloatMaxVector) super.lanewiseTemplate(op, v1, v2);  // specialize
290     }
291 
292     @Override
293     @ForceInline
294     public final
295     FloatMaxVector addIndex(int scale) {
296         return (FloatMaxVector) super.addIndexTemplate(scale);  // specialize
297     }
298 
299     // Type specific horizontal reductions
300 
301     @Override
302     @ForceInline
303     public final float reduceLanes(VectorOperators.Associative op) {
304         return super.reduceLanesTemplate(op);  // specialized
305     }
306 
307     @Override
308     @ForceInline
309     public final float reduceLanes(VectorOperators.Associative op,
310                                     VectorMask<Float> m) {
311         return super.reduceLanesTemplate(op, m);  // specialized
312     }
313 
314     @Override
315     @ForceInline
316     public final long reduceLanesToLong(VectorOperators.Associative op) {
317         return (long) super.reduceLanesTemplate(op);  // specialized
318     }
319 
320     @Override
321     @ForceInline
322     public final long reduceLanesToLong(VectorOperators.Associative op,
323                                         VectorMask<Float> m) {
324         return (long) super.reduceLanesTemplate(op, m);  // specialized
325     }
326 
327     @ForceInline
328     public VectorShuffle<Float> toShuffle() {
329         return super.toShuffleTemplate(FloatMaxShuffle.class); // specialize
330     }
331 
332     // Specialized unary testing
333 
334     @Override
335     @ForceInline
336     public final FloatMaxMask test(Test op) {
337         return super.testTemplate(FloatMaxMask.class, op);  // specialize
338     }
339 
340     // Specialized comparisons
341 
342     @Override
343     @ForceInline
344     public final FloatMaxMask compare(Comparison op, Vector<Float> v) {
345         return super.compareTemplate(FloatMaxMask.class, op, v);  // specialize
346     }
347 
348     @Override
349     @ForceInline
350     public final FloatMaxMask compare(Comparison op, float s) {
351         return super.compareTemplate(FloatMaxMask.class, op, s);  // specialize
352     }
353 
354     @Override
355     @ForceInline
356     public final FloatMaxMask compare(Comparison op, long s) {
357         return super.compareTemplate(FloatMaxMask.class, op, s);  // specialize
358     }
359 
360     @Override
361     @ForceInline
362     public FloatMaxVector blend(Vector<Float> v, VectorMask<Float> m) {
363         return (FloatMaxVector)
364             super.blendTemplate(FloatMaxMask.class,
365                                 (FloatMaxVector) v,
366                                 (FloatMaxMask) m);  // specialize
367     }
368 
369     @Override
370     @ForceInline
371     public FloatMaxVector slice(int origin, Vector<Float> v) {
372         return (FloatMaxVector) super.sliceTemplate(origin, v);  // specialize
373     }
374 
375     @Override
376     @ForceInline
377     public FloatMaxVector slice(int origin) {
378         return (FloatMaxVector) super.sliceTemplate(origin);  // specialize
379     }
380 
381     @Override
382     @ForceInline
383     public FloatMaxVector unslice(int origin, Vector<Float> w, int part) {
384         return (FloatMaxVector) super.unsliceTemplate(origin, w, part);  // specialize
385     }
386 
387     @Override
388     @ForceInline
389     public FloatMaxVector unslice(int origin, Vector<Float> w, int part, VectorMask<Float> m) {
390         return (FloatMaxVector)
391             super.unsliceTemplate(FloatMaxMask.class,
392                                   origin, w, part,
393                                   (FloatMaxMask) m);  // specialize
394     }
395 
396     @Override
397     @ForceInline
398     public FloatMaxVector unslice(int origin) {
399         return (FloatMaxVector) super.unsliceTemplate(origin);  // specialize
400     }
401 
402     @Override
403     @ForceInline
404     public FloatMaxVector rearrange(VectorShuffle<Float> s) {
405         return (FloatMaxVector)
406             super.rearrangeTemplate(FloatMaxShuffle.class,
407                                     (FloatMaxShuffle) s);  // specialize
408     }
409 
410     @Override
411     @ForceInline
412     public FloatMaxVector rearrange(VectorShuffle<Float> shuffle,
413                                   VectorMask<Float> m) {
414         return (FloatMaxVector)
415             super.rearrangeTemplate(FloatMaxShuffle.class,
416                                     (FloatMaxShuffle) shuffle,
417                                     (FloatMaxMask) m);  // specialize
418     }
419 
420     @Override
421     @ForceInline
422     public FloatMaxVector rearrange(VectorShuffle<Float> s,
423                                   Vector<Float> v) {
424         return (FloatMaxVector)
425             super.rearrangeTemplate(FloatMaxShuffle.class,
426                                     (FloatMaxShuffle) s,
427                                     (FloatMaxVector) v);  // specialize
428     }
429 
430     @Override
431     @ForceInline
432     public FloatMaxVector selectFrom(Vector<Float> v) {
433         return (FloatMaxVector)
434             super.selectFromTemplate((FloatMaxVector) v);  // specialize
435     }
436 
437     @Override
438     @ForceInline
439     public FloatMaxVector selectFrom(Vector<Float> v,
440                                    VectorMask<Float> m) {
441         return (FloatMaxVector)
442             super.selectFromTemplate((FloatMaxVector) v,
443                                      (FloatMaxMask) m);  // specialize
444     }
445 
446 
447     @ForceInline
448     @Override
449     public float lane(int i) {
450         if (i < 0 || i >= VLENGTH) {
451             throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH);
452         }
453         int bits = laneHelper(i);
454         return Float.intBitsToFloat(bits);
455     }
456 
457     public int laneHelper(int i) {
458         return (int) VectorSupport.extract(
459                      VCLASS, ETYPE, VLENGTH,
460                      this, i,
461                      (vec, ix) -> {
462                      float[] vecarr = vec.vec();
463                      return (long)Float.floatToIntBits(vecarr[ix]);
464                      });
465     }
466 
467     @ForceInline
468     @Override
469     public FloatMaxVector withLane(int i, float e) {
470         if (i < 0 || i >= VLENGTH) {
471             throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH);
472         }
473         return withLaneHelper(i, e);
474     }
475 
476     public FloatMaxVector withLaneHelper(int i, float e) {
477         return VectorSupport.insert(
478                                 VCLASS, ETYPE, VLENGTH,
479                                 this, i, (long)Float.floatToIntBits(e),
480                                 (v, ix, bits) -> {
481                                     float[] res = v.vec().clone();
482                                     res[ix] = Float.intBitsToFloat((int)bits);
483                                     return v.vectorFactory(res);
484                                 });
485     }
486 
487     // Mask
488 
489     static final class FloatMaxMask extends AbstractMask<Float> {
490         static final int VLENGTH = VSPECIES.laneCount();    // used by the JVM
491         static final Class<Float> ETYPE = float.class; // used by the JVM
492 
493         FloatMaxMask(boolean[] bits) {
494             this(bits, 0);
495         }
496 
497         FloatMaxMask(boolean[] bits, int offset) {
498             super(prepare(bits, offset));
499         }
500 
501         FloatMaxMask(boolean val) {
502             super(prepare(val));
503         }
504 
505         private static boolean[] prepare(boolean[] bits, int offset) {
506             boolean[] newBits = new boolean[VSPECIES.laneCount()];
507             for (int i = 0; i < newBits.length; i++) {
508                 newBits[i] = bits[offset + i];
509             }
510             return newBits;
511         }
512 
513         private static boolean[] prepare(boolean val) {
514             boolean[] bits = new boolean[VSPECIES.laneCount()];
515             Arrays.fill(bits, val);
516             return bits;
517         }
518 
519         @ForceInline
520         final @Override
521         public FloatSpecies vspecies() {
522             // ISSUE:  This should probably be a @Stable
523             // field inside AbstractMask, rather than
524             // a megamorphic method.
525             return VSPECIES;
526         }
527 
528         @ForceInline
529         boolean[] getBits() {
530             return (boolean[])getPayload();
531         }
532 
533         @Override
534         FloatMaxMask uOp(MUnOp f) {
535             boolean[] res = new boolean[vspecies().laneCount()];
536             boolean[] bits = getBits();
537             for (int i = 0; i < res.length; i++) {
538                 res[i] = f.apply(i, bits[i]);
539             }
540             return new FloatMaxMask(res);
541         }
542 
543         @Override
544         FloatMaxMask bOp(VectorMask<Float> m, MBinOp f) {
545             boolean[] res = new boolean[vspecies().laneCount()];
546             boolean[] bits = getBits();
547             boolean[] mbits = ((FloatMaxMask)m).getBits();
548             for (int i = 0; i < res.length; i++) {
549                 res[i] = f.apply(i, bits[i], mbits[i]);
550             }
551             return new FloatMaxMask(res);
552         }
553 
554         @ForceInline
555         @Override
556         public final
557         FloatMaxVector toVector() {
558             return (FloatMaxVector) super.toVectorTemplate();  // specialize
559         }
560 
561         /**
562          * Helper function for lane-wise mask conversions.
563          * This function kicks in after intrinsic failure.
564          */
565         @ForceInline
566         private final <E>
567         VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
568             if (length() != dsp.laneCount())
569                 throw new IllegalArgumentException("VectorMask length and species length differ");
570             boolean[] maskArray = toArray();
571             return  dsp.maskFactory(maskArray).check(dsp);
572         }
573 
574         @Override
575         @ForceInline
576         public <E> VectorMask<E> cast(VectorSpecies<E> dsp) {
577             AbstractSpecies<E> species = (AbstractSpecies<E>) dsp;
578             if (length() != species.laneCount())
579                 throw new IllegalArgumentException("VectorMask length and species length differ");
580             if (VSIZE == species.vectorBitSize()) {
581                 Class<?> dtype = species.elementType();
582                 Class<?> dmtype = species.maskType();
583                 return VectorSupport.convert(VectorSupport.VECTOR_OP_REINTERPRET,
584                     this.getClass(), ETYPE, VLENGTH,
585                     dmtype, dtype, VLENGTH,
586                     this, species,
587                     FloatMaxMask::defaultMaskCast);
588             }
589             return this.defaultMaskCast(species);
590         }
591 
592         @Override
593         @ForceInline
594         public FloatMaxMask eq(VectorMask<Float> mask) {
595             Objects.requireNonNull(mask);
596             FloatMaxMask m = (FloatMaxMask)mask;
597             return xor(m.not());
598         }
599 
600         // Unary operations
601 
602         @Override
603         @ForceInline
604         public FloatMaxMask not() {
605             return xor(maskAll(true));
606         }
607 
608         // Binary operations
609 
610         @Override
611         @ForceInline
612         public FloatMaxMask and(VectorMask<Float> mask) {
613             Objects.requireNonNull(mask);
614             FloatMaxMask m = (FloatMaxMask)mask;
615             return VectorSupport.binaryOp(VECTOR_OP_AND, FloatMaxMask.class, int.class, VLENGTH,
616                                              this, m,
617                                              (m1, m2) -> m1.bOp(m2, (i, a, b) -> a & b));
618         }
619 
620         @Override
621         @ForceInline
622         public FloatMaxMask or(VectorMask<Float> mask) {
623             Objects.requireNonNull(mask);
624             FloatMaxMask m = (FloatMaxMask)mask;
625             return VectorSupport.binaryOp(VECTOR_OP_OR, FloatMaxMask.class, int.class, VLENGTH,
626                                              this, m,
627                                              (m1, m2) -> m1.bOp(m2, (i, a, b) -> a | b));
628         }
629 
630         @ForceInline
631         /* package-private */
632         FloatMaxMask xor(VectorMask<Float> mask) {
633             Objects.requireNonNull(mask);
634             FloatMaxMask m = (FloatMaxMask)mask;
635             return VectorSupport.binaryOp(VECTOR_OP_XOR, FloatMaxMask.class, int.class, VLENGTH,
636                                           this, m,
637                                           (m1, m2) -> m1.bOp(m2, (i, a, b) -> a ^ b));
638         }
639 
640         // Mask Query operations
641 
642         @Override
643         @ForceInline
644         public int trueCount() {
645             return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, FloatMaxMask.class, int.class, VLENGTH, this,
646                                                       (m) -> trueCountHelper(((FloatMaxMask)m).getBits()));
647         }
648 
649         @Override
650         @ForceInline
651         public int firstTrue() {
652             return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, FloatMaxMask.class, int.class, VLENGTH, this,
653                                                       (m) -> firstTrueHelper(((FloatMaxMask)m).getBits()));
654         }
655 
656         @Override
657         @ForceInline
658         public int lastTrue() {
659             return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, FloatMaxMask.class, int.class, VLENGTH, this,
660                                                       (m) -> lastTrueHelper(((FloatMaxMask)m).getBits()));
661         }
662 
663         // Reductions
664 
665         @Override
666         @ForceInline
667         public boolean anyTrue() {
668             return VectorSupport.test(BT_ne, FloatMaxMask.class, int.class, VLENGTH,
669                                          this, vspecies().maskAll(true),
670                                          (m, __) -> anyTrueHelper(((FloatMaxMask)m).getBits()));
671         }
672 
673         @Override
674         @ForceInline
675         public boolean allTrue() {
676             return VectorSupport.test(BT_overflow, FloatMaxMask.class, int.class, VLENGTH,
677                                          this, vspecies().maskAll(true),
678                                          (m, __) -> allTrueHelper(((FloatMaxMask)m).getBits()));
679         }
680 
681         @ForceInline
682         /*package-private*/
683         static FloatMaxMask maskAll(boolean bit) {
684             return VectorSupport.broadcastCoerced(FloatMaxMask.class, int.class, VLENGTH,
685                                                   (bit ? -1 : 0), null,
686                                                   (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
687         }
688         private static final FloatMaxMask  TRUE_MASK = new FloatMaxMask(true);
689         private static final FloatMaxMask FALSE_MASK = new FloatMaxMask(false);
690 
691     }
692 
693     // Shuffle
694 
695     static final class FloatMaxShuffle extends AbstractShuffle<Float> {
696         static final int VLENGTH = VSPECIES.laneCount();    // used by the JVM
697         static final Class<Float> ETYPE = float.class; // used by the JVM
698 
699         FloatMaxShuffle(byte[] reorder) {
700             super(VLENGTH, reorder);
701         }
702 
703         public FloatMaxShuffle(int[] reorder) {
704             super(VLENGTH, reorder);
705         }
706 
707         public FloatMaxShuffle(int[] reorder, int i) {
708             super(VLENGTH, reorder, i);
709         }
710 
711         public FloatMaxShuffle(IntUnaryOperator fn) {
712             super(VLENGTH, fn);
713         }
714 
715         @Override
716         public FloatSpecies vspecies() {
717             return VSPECIES;
718         }
719 
720         static {
721             // There must be enough bits in the shuffle lanes to encode
722             // VLENGTH valid indexes and VLENGTH exceptional ones.
723             assert(VLENGTH < Byte.MAX_VALUE);
724             assert(Byte.MIN_VALUE <= -VLENGTH);
725         }
726         static final FloatMaxShuffle IOTA = new FloatMaxShuffle(IDENTITY);
727 
728         @Override
729         @ForceInline
730         public FloatMaxVector toVector() {
731             return VectorSupport.shuffleToVector(VCLASS, ETYPE, FloatMaxShuffle.class, this, VLENGTH,
732                                                     (s) -> ((FloatMaxVector)(((AbstractShuffle<Float>)(s)).toVectorTemplate())));
733         }
734 
735         @Override
736         @ForceInline
737         public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
738             AbstractSpecies<F> species = (AbstractSpecies<F>) s;
739             if (length() != species.laneCount())
740                 throw new IllegalArgumentException("VectorShuffle length and species length differ");
741             int[] shuffleArray = toArray();
742             return s.shuffleFromArray(shuffleArray, 0).check(s);
743         }
744 
745         @ForceInline
746         @Override
747         public FloatMaxShuffle rearrange(VectorShuffle<Float> shuffle) {
748             FloatMaxShuffle s = (FloatMaxShuffle) shuffle;
749             byte[] reorder1 = reorder();
750             byte[] reorder2 = s.reorder();
751             byte[] r = new byte[reorder1.length];
752             for (int i = 0; i < reorder1.length; i++) {
753                 int ssi = reorder2[i];
754                 r[i] = reorder1[ssi];  // throws on exceptional index
755             }
756             return new FloatMaxShuffle(r);
757         }
758     }
759 
760     // ================================================
761 
762     // Specialized low-level memory operations.
763 
764     @ForceInline
765     @Override
766     final
767     FloatVector fromArray0(float[] a, int offset) {
768         return super.fromArray0Template(a, offset);  // specialize
769     }
770 
771 
772 
773     @ForceInline
774     @Override
775     final
776     FloatVector fromByteArray0(byte[] a, int offset) {
777         return super.fromByteArray0Template(a, offset);  // specialize
778     }
779 
780     @ForceInline
781     @Override
782     final
783     FloatVector fromByteBuffer0(ByteBuffer bb, int offset) {
784         return super.fromByteBuffer0Template(bb, offset);  // specialize
785     }
786 
787     @ForceInline
788     @Override
789     final
790     void intoArray0(float[] a, int offset) {
791         super.intoArray0Template(a, offset);  // specialize
792     }
793 
794     @ForceInline
795     @Override
796     final
797     void intoByteArray0(byte[] a, int offset) {
798         super.intoByteArray0Template(a, offset);  // specialize
799     }
800 
801     // End of specialized low-level memory operations.
802 
803     // ================================================
804 
805 }