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 ByteMaxVector extends ByteVector {
 43     static final ByteSpecies VSPECIES =
 44         (ByteSpecies) ByteVector.SPECIES_MAX;
 45 
 46     static final VectorShape VSHAPE =
 47         VSPECIES.vectorShape();
 48 
 49     static final Class<ByteMaxVector> VCLASS = ByteMaxVector.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<Byte> ETYPE = byte.class; // used by the JVM
 56 
 57     ByteMaxVector(byte[] v) {
 58         super(v);
 59     }
 60 
 61     // For compatibility as ByteMaxVector::new,
 62     // stored into species.vectorFactory.
 63     ByteMaxVector(Object v) {
 64         this((byte[]) v);
 65     }
 66 
 67     static final ByteMaxVector ZERO = new ByteMaxVector(new byte[VLENGTH]);
 68     static final ByteMaxVector IOTA = new ByteMaxVector(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 ByteSpecies 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<Byte> elementType() { return byte.class; }
 92 
 93     @ForceInline
 94     @Override
 95     public final int elementSize() { return Byte.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     byte[] vec() {
117         return (byte[])getPayload();
118     }
119 
120     // Virtualized constructors
121 
122     @Override
123     @ForceInline
124     public final ByteMaxVector broadcast(byte e) {
125         return (ByteMaxVector) super.broadcastTemplate(e);  // specialize
126     }
127 
128     @Override
129     @ForceInline
130     public final ByteMaxVector broadcast(long e) {
131         return (ByteMaxVector) super.broadcastTemplate(e);  // specialize
132     }
133 
134     @Override
135     @ForceInline
136     ByteMaxMask maskFromArray(boolean[] bits) {
137         return new ByteMaxMask(bits);
138     }
139 
140     @Override
141     @ForceInline
142     ByteMaxShuffle iotaShuffle() { return ByteMaxShuffle.IOTA; }
143 
144     @ForceInline
145     ByteMaxShuffle iotaShuffle(int start, int step, boolean wrap) {
146       if (wrap) {
147         return (ByteMaxShuffle)VectorSupport.shuffleIota(ETYPE, ByteMaxShuffle.class, VSPECIES, VLENGTH, start, step, 1,
148                 (l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
149       } else {
150         return (ByteMaxShuffle)VectorSupport.shuffleIota(ETYPE, ByteMaxShuffle.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     ByteMaxShuffle shuffleFromBytes(byte[] reorder) { return new ByteMaxShuffle(reorder); }
158 
159     @Override
160     @ForceInline
161     ByteMaxShuffle shuffleFromArray(int[] indexes, int i) { return new ByteMaxShuffle(indexes, i); }
162 
163     @Override
164     @ForceInline
165     ByteMaxShuffle shuffleFromOp(IntUnaryOperator fn) { return new ByteMaxShuffle(fn); }
166 
167     // Make a vector of the same species but the given elements:
168     @ForceInline
169     final @Override
170     ByteMaxVector vectorFactory(byte[] vec) {
171         return new ByteMaxVector(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     ByteMaxVector uOp(FUnOp f) {
191         return (ByteMaxVector) super.uOpTemplate(f);  // specialize
192     }
193 
194     @ForceInline
195     final @Override
196     ByteMaxVector uOp(VectorMask<Byte> m, FUnOp f) {
197         return (ByteMaxVector)
198             super.uOpTemplate((ByteMaxMask)m, f);  // specialize
199     }
200 
201     // Binary operator
202 
203     @ForceInline
204     final @Override
205     ByteMaxVector bOp(Vector<Byte> v, FBinOp f) {
206         return (ByteMaxVector) super.bOpTemplate((ByteMaxVector)v, f);  // specialize
207     }
208 
209     @ForceInline
210     final @Override
211     ByteMaxVector bOp(Vector<Byte> v,
212                      VectorMask<Byte> m, FBinOp f) {
213         return (ByteMaxVector)
214             super.bOpTemplate((ByteMaxVector)v, (ByteMaxMask)m,
215                               f);  // specialize
216     }
217 
218     // Ternary operator
219 
220     @ForceInline
221     final @Override
222     ByteMaxVector tOp(Vector<Byte> v1, Vector<Byte> v2, FTriOp f) {
223         return (ByteMaxVector)
224             super.tOpTemplate((ByteMaxVector)v1, (ByteMaxVector)v2,
225                               f);  // specialize
226     }
227 
228     @ForceInline
229     final @Override
230     ByteMaxVector tOp(Vector<Byte> v1, Vector<Byte> v2,
231                      VectorMask<Byte> m, FTriOp f) {
232         return (ByteMaxVector)
233             super.tOpTemplate((ByteMaxVector)v1, (ByteMaxVector)v2,
234                               (ByteMaxMask)m, f);  // specialize
235     }
236 
237     @ForceInline
238     final @Override
239     byte rOp(byte 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<Byte,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 ByteMaxVector lanewise(Unary op) {
273         return (ByteMaxVector) super.lanewiseTemplate(op);  // specialize
274     }
275 
276     @Override
277     @ForceInline
278     public ByteMaxVector lanewise(Binary op, Vector<Byte> v) {
279         return (ByteMaxVector) super.lanewiseTemplate(op, v);  // specialize
280     }
281 
282     /*package-private*/
283     @Override
284     @ForceInline ByteMaxVector
285     lanewiseShift(VectorOperators.Binary op, int e) {
286         return (ByteMaxVector) super.lanewiseShiftTemplate(op, e);  // specialize
287     }
288 
289     /*package-private*/
290     @Override
291     @ForceInline
292     public final
293     ByteMaxVector
294     lanewise(VectorOperators.Ternary op, Vector<Byte> v1, Vector<Byte> v2) {
295         return (ByteMaxVector) super.lanewiseTemplate(op, v1, v2);  // specialize
296     }
297 
298     @Override
299     @ForceInline
300     public final
301     ByteMaxVector addIndex(int scale) {
302         return (ByteMaxVector) super.addIndexTemplate(scale);  // specialize
303     }
304 
305     // Type specific horizontal reductions
306 
307     @Override
308     @ForceInline
309     public final byte reduceLanes(VectorOperators.Associative op) {
310         return super.reduceLanesTemplate(op);  // specialized
311     }
312 
313     @Override
314     @ForceInline
315     public final byte reduceLanes(VectorOperators.Associative op,
316                                     VectorMask<Byte> m) {
317         return super.reduceLanesTemplate(op, m);  // specialized
318     }
319 
320     @Override
321     @ForceInline
322     public final long reduceLanesToLong(VectorOperators.Associative op) {
323         return (long) super.reduceLanesTemplate(op);  // specialized
324     }
325 
326     @Override
327     @ForceInline
328     public final long reduceLanesToLong(VectorOperators.Associative op,
329                                         VectorMask<Byte> m) {
330         return (long) super.reduceLanesTemplate(op, m);  // specialized
331     }
332 
333     @ForceInline
334     public VectorShuffle<Byte> toShuffle() {
335         return super.toShuffleTemplate(ByteMaxShuffle.class); // specialize
336     }
337 
338     // Specialized unary testing
339 
340     @Override
341     @ForceInline
342     public final ByteMaxMask test(Test op) {
343         return super.testTemplate(ByteMaxMask.class, op);  // specialize
344     }
345 
346     // Specialized comparisons
347 
348     @Override
349     @ForceInline
350     public final ByteMaxMask compare(Comparison op, Vector<Byte> v) {
351         return super.compareTemplate(ByteMaxMask.class, op, v);  // specialize
352     }
353 
354     @Override
355     @ForceInline
356     public final ByteMaxMask compare(Comparison op, byte s) {
357         return super.compareTemplate(ByteMaxMask.class, op, s);  // specialize
358     }
359 
360     @Override
361     @ForceInline
362     public final ByteMaxMask compare(Comparison op, long s) {
363         return super.compareTemplate(ByteMaxMask.class, op, s);  // specialize
364     }
365 
366     @Override
367     @ForceInline
368     public ByteMaxVector blend(Vector<Byte> v, VectorMask<Byte> m) {
369         return (ByteMaxVector)
370             super.blendTemplate(ByteMaxMask.class,
371                                 (ByteMaxVector) v,
372                                 (ByteMaxMask) m);  // specialize
373     }
374 
375     @Override
376     @ForceInline
377     public ByteMaxVector slice(int origin, Vector<Byte> v) {
378         return (ByteMaxVector) super.sliceTemplate(origin, v);  // specialize
379     }
380 
381     @Override
382     @ForceInline
383     public ByteMaxVector slice(int origin) {
384         return (ByteMaxVector) super.sliceTemplate(origin);  // specialize
385     }
386 
387     @Override
388     @ForceInline
389     public ByteMaxVector unslice(int origin, Vector<Byte> w, int part) {
390         return (ByteMaxVector) super.unsliceTemplate(origin, w, part);  // specialize
391     }
392 
393     @Override
394     @ForceInline
395     public ByteMaxVector unslice(int origin, Vector<Byte> w, int part, VectorMask<Byte> m) {
396         return (ByteMaxVector)
397             super.unsliceTemplate(ByteMaxMask.class,
398                                   origin, w, part,
399                                   (ByteMaxMask) m);  // specialize
400     }
401 
402     @Override
403     @ForceInline
404     public ByteMaxVector unslice(int origin) {
405         return (ByteMaxVector) super.unsliceTemplate(origin);  // specialize
406     }
407 
408     @Override
409     @ForceInline
410     public ByteMaxVector rearrange(VectorShuffle<Byte> s) {
411         return (ByteMaxVector)
412             super.rearrangeTemplate(ByteMaxShuffle.class,
413                                     (ByteMaxShuffle) s);  // specialize
414     }
415 
416     @Override
417     @ForceInline
418     public ByteMaxVector rearrange(VectorShuffle<Byte> shuffle,
419                                   VectorMask<Byte> m) {
420         return (ByteMaxVector)
421             super.rearrangeTemplate(ByteMaxShuffle.class,
422                                     (ByteMaxShuffle) shuffle,
423                                     (ByteMaxMask) m);  // specialize
424     }
425 
426     @Override
427     @ForceInline
428     public ByteMaxVector rearrange(VectorShuffle<Byte> s,
429                                   Vector<Byte> v) {
430         return (ByteMaxVector)
431             super.rearrangeTemplate(ByteMaxShuffle.class,
432                                     (ByteMaxShuffle) s,
433                                     (ByteMaxVector) v);  // specialize
434     }
435 
436     @Override
437     @ForceInline
438     public ByteMaxVector selectFrom(Vector<Byte> v) {
439         return (ByteMaxVector)
440             super.selectFromTemplate((ByteMaxVector) v);  // specialize
441     }
442 
443     @Override
444     @ForceInline
445     public ByteMaxVector selectFrom(Vector<Byte> v,
446                                    VectorMask<Byte> m) {
447         return (ByteMaxVector)
448             super.selectFromTemplate((ByteMaxVector) v,
449                                      (ByteMaxMask) m);  // specialize
450     }
451 
452 
453     @ForceInline
454     @Override
455     public byte lane(int i) {
456         if (i < 0 || i >= VLENGTH) {
457             throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH);
458         }
459         return laneHelper(i);
460     }
461 
462     public byte laneHelper(int i) {
463         return (byte) VectorSupport.extract(
464                                 VCLASS, ETYPE, VLENGTH,
465                                 this, i,
466                                 (vec, ix) -> {
467                                     byte[] vecarr = vec.vec();
468                                     return (long)vecarr[ix];
469                                 });
470     }
471 
472     @ForceInline
473     @Override
474     public ByteMaxVector withLane(int i, byte e) {
475         if (i < 0 || i >= VLENGTH) {
476             throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH);
477         }
478         return withLaneHelper(i, e);
479     }
480 
481     public ByteMaxVector withLaneHelper(int i, byte e) {
482         return VectorSupport.insert(
483                                 VCLASS, ETYPE, VLENGTH,
484                                 this, i, (long)e,
485                                 (v, ix, bits) -> {
486                                     byte[] res = v.vec().clone();
487                                     res[ix] = (byte)bits;
488                                     return v.vectorFactory(res);
489                                 });
490     }
491 
492     // Mask
493 
494     static final class ByteMaxMask extends AbstractMask<Byte> {
495         static final int VLENGTH = VSPECIES.laneCount();    // used by the JVM
496         static final Class<Byte> ETYPE = byte.class; // used by the JVM
497 
498         ByteMaxMask(boolean[] bits) {
499             this(bits, 0);
500         }
501 
502         ByteMaxMask(boolean[] bits, int offset) {
503             super(prepare(bits, offset));
504         }
505 
506         ByteMaxMask(boolean val) {
507             super(prepare(val));
508         }
509 
510         private static boolean[] prepare(boolean[] bits, int offset) {
511             boolean[] newBits = new boolean[VSPECIES.laneCount()];
512             for (int i = 0; i < newBits.length; i++) {
513                 newBits[i] = bits[offset + i];
514             }
515             return newBits;
516         }
517 
518         private static boolean[] prepare(boolean val) {
519             boolean[] bits = new boolean[VSPECIES.laneCount()];
520             Arrays.fill(bits, val);
521             return bits;
522         }
523 
524         @ForceInline
525         final @Override
526         public ByteSpecies vspecies() {
527             // ISSUE:  This should probably be a @Stable
528             // field inside AbstractMask, rather than
529             // a megamorphic method.
530             return VSPECIES;
531         }
532 
533         @ForceInline
534         boolean[] getBits() {
535             return (boolean[])getPayload();
536         }
537 
538         @Override
539         ByteMaxMask uOp(MUnOp f) {
540             boolean[] res = new boolean[vspecies().laneCount()];
541             boolean[] bits = getBits();
542             for (int i = 0; i < res.length; i++) {
543                 res[i] = f.apply(i, bits[i]);
544             }
545             return new ByteMaxMask(res);
546         }
547 
548         @Override
549         ByteMaxMask bOp(VectorMask<Byte> m, MBinOp f) {
550             boolean[] res = new boolean[vspecies().laneCount()];
551             boolean[] bits = getBits();
552             boolean[] mbits = ((ByteMaxMask)m).getBits();
553             for (int i = 0; i < res.length; i++) {
554                 res[i] = f.apply(i, bits[i], mbits[i]);
555             }
556             return new ByteMaxMask(res);
557         }
558 
559         @ForceInline
560         @Override
561         public final
562         ByteMaxVector toVector() {
563             return (ByteMaxVector) super.toVectorTemplate();  // specialize
564         }
565 
566         /**
567          * Helper function for lane-wise mask conversions.
568          * This function kicks in after intrinsic failure.
569          */
570         @ForceInline
571         private final <E>
572         VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
573             if (length() != dsp.laneCount())
574                 throw new IllegalArgumentException("VectorMask length and species length differ");
575             boolean[] maskArray = toArray();
576             return  dsp.maskFactory(maskArray).check(dsp);
577         }
578 
579         @Override
580         @ForceInline
581         public <E> VectorMask<E> cast(VectorSpecies<E> dsp) {
582             AbstractSpecies<E> species = (AbstractSpecies<E>) dsp;
583             if (length() != species.laneCount())
584                 throw new IllegalArgumentException("VectorMask length and species length differ");
585             if (VSIZE == species.vectorBitSize()) {
586                 Class<?> dtype = species.elementType();
587                 Class<?> dmtype = species.maskType();
588                 return VectorSupport.convert(VectorSupport.VECTOR_OP_REINTERPRET,
589                     this.getClass(), ETYPE, VLENGTH,
590                     dmtype, dtype, VLENGTH,
591                     this, species,
592                     ByteMaxMask::defaultMaskCast);
593             }
594             return this.defaultMaskCast(species);
595         }
596 
597         @Override
598         @ForceInline
599         public ByteMaxMask eq(VectorMask<Byte> mask) {
600             Objects.requireNonNull(mask);
601             ByteMaxMask m = (ByteMaxMask)mask;
602             return xor(m.not());
603         }
604 
605         // Unary operations
606 
607         @Override
608         @ForceInline
609         public ByteMaxMask not() {
610             return xor(maskAll(true));
611         }
612 
613         // Binary operations
614 
615         @Override
616         @ForceInline
617         public ByteMaxMask and(VectorMask<Byte> mask) {
618             Objects.requireNonNull(mask);
619             ByteMaxMask m = (ByteMaxMask)mask;
620             return VectorSupport.binaryOp(VECTOR_OP_AND, ByteMaxMask.class, byte.class, VLENGTH,
621                                              this, m,
622                                              (m1, m2) -> m1.bOp(m2, (i, a, b) -> a & b));
623         }
624 
625         @Override
626         @ForceInline
627         public ByteMaxMask or(VectorMask<Byte> mask) {
628             Objects.requireNonNull(mask);
629             ByteMaxMask m = (ByteMaxMask)mask;
630             return VectorSupport.binaryOp(VECTOR_OP_OR, ByteMaxMask.class, byte.class, VLENGTH,
631                                              this, m,
632                                              (m1, m2) -> m1.bOp(m2, (i, a, b) -> a | b));
633         }
634 
635         @ForceInline
636         /* package-private */
637         ByteMaxMask xor(VectorMask<Byte> mask) {
638             Objects.requireNonNull(mask);
639             ByteMaxMask m = (ByteMaxMask)mask;
640             return VectorSupport.binaryOp(VECTOR_OP_XOR, ByteMaxMask.class, byte.class, VLENGTH,
641                                           this, m,
642                                           (m1, m2) -> m1.bOp(m2, (i, a, b) -> a ^ b));
643         }
644 
645         // Mask Query operations
646 
647         @Override
648         @ForceInline
649         public int trueCount() {
650             return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, ByteMaxMask.class, byte.class, VLENGTH, this,
651                                                       (m) -> trueCountHelper(((ByteMaxMask)m).getBits()));
652         }
653 
654         @Override
655         @ForceInline
656         public int firstTrue() {
657             return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, ByteMaxMask.class, byte.class, VLENGTH, this,
658                                                       (m) -> firstTrueHelper(((ByteMaxMask)m).getBits()));
659         }
660 
661         @Override
662         @ForceInline
663         public int lastTrue() {
664             return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, ByteMaxMask.class, byte.class, VLENGTH, this,
665                                                       (m) -> lastTrueHelper(((ByteMaxMask)m).getBits()));
666         }
667 
668         // Reductions
669 
670         @Override
671         @ForceInline
672         public boolean anyTrue() {
673             return VectorSupport.test(BT_ne, ByteMaxMask.class, byte.class, VLENGTH,
674                                          this, vspecies().maskAll(true),
675                                          (m, __) -> anyTrueHelper(((ByteMaxMask)m).getBits()));
676         }
677 
678         @Override
679         @ForceInline
680         public boolean allTrue() {
681             return VectorSupport.test(BT_overflow, ByteMaxMask.class, byte.class, VLENGTH,
682                                          this, vspecies().maskAll(true),
683                                          (m, __) -> allTrueHelper(((ByteMaxMask)m).getBits()));
684         }
685 
686         @ForceInline
687         /*package-private*/
688         static ByteMaxMask maskAll(boolean bit) {
689             return VectorSupport.broadcastCoerced(ByteMaxMask.class, byte.class, VLENGTH,
690                                                   (bit ? -1 : 0), null,
691                                                   (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
692         }
693         private static final ByteMaxMask  TRUE_MASK = new ByteMaxMask(true);
694         private static final ByteMaxMask FALSE_MASK = new ByteMaxMask(false);
695 
696     }
697 
698     // Shuffle
699 
700     static final class ByteMaxShuffle extends AbstractShuffle<Byte> {
701         static final int VLENGTH = VSPECIES.laneCount();    // used by the JVM
702         static final Class<Byte> ETYPE = byte.class; // used by the JVM
703 
704         ByteMaxShuffle(byte[] reorder) {
705             super(VLENGTH, reorder);
706         }
707 
708         public ByteMaxShuffle(int[] reorder) {
709             super(VLENGTH, reorder);
710         }
711 
712         public ByteMaxShuffle(int[] reorder, int i) {
713             super(VLENGTH, reorder, i);
714         }
715 
716         public ByteMaxShuffle(IntUnaryOperator fn) {
717             super(VLENGTH, fn);
718         }
719 
720         @Override
721         public ByteSpecies vspecies() {
722             return VSPECIES;
723         }
724 
725         static {
726             // There must be enough bits in the shuffle lanes to encode
727             // VLENGTH valid indexes and VLENGTH exceptional ones.
728             assert(VLENGTH < Byte.MAX_VALUE);
729             assert(Byte.MIN_VALUE <= -VLENGTH);
730         }
731         static final ByteMaxShuffle IOTA = new ByteMaxShuffle(IDENTITY);
732 
733         @Override
734         @ForceInline
735         public ByteMaxVector toVector() {
736             return VectorSupport.shuffleToVector(VCLASS, ETYPE, ByteMaxShuffle.class, this, VLENGTH,
737                                                     (s) -> ((ByteMaxVector)(((AbstractShuffle<Byte>)(s)).toVectorTemplate())));
738         }
739 
740         @Override
741         @ForceInline
742         public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
743             AbstractSpecies<F> species = (AbstractSpecies<F>) s;
744             if (length() != species.laneCount())
745                 throw new IllegalArgumentException("VectorShuffle length and species length differ");
746             int[] shuffleArray = toArray();
747             return s.shuffleFromArray(shuffleArray, 0).check(s);
748         }
749 
750         @ForceInline
751         @Override
752         public ByteMaxShuffle rearrange(VectorShuffle<Byte> shuffle) {
753             ByteMaxShuffle s = (ByteMaxShuffle) shuffle;
754             byte[] reorder1 = reorder();
755             byte[] reorder2 = s.reorder();
756             byte[] r = new byte[reorder1.length];
757             for (int i = 0; i < reorder1.length; i++) {
758                 int ssi = reorder2[i];
759                 r[i] = reorder1[ssi];  // throws on exceptional index
760             }
761             return new ByteMaxShuffle(r);
762         }
763     }
764 
765     // ================================================
766 
767     // Specialized low-level memory operations.
768 
769     @ForceInline
770     @Override
771     final
772     ByteVector fromArray0(byte[] a, int offset) {
773         return super.fromArray0Template(a, offset);  // specialize
774     }
775 
776 
777     @ForceInline
778     @Override
779     final
780     ByteVector fromBooleanArray0(boolean[] a, int offset) {
781         return super.fromBooleanArray0Template(a, offset);  // specialize
782     }
783 
784     @ForceInline
785     @Override
786     final
787     ByteVector fromByteArray0(byte[] a, int offset) {
788         return super.fromByteArray0Template(a, offset);  // specialize
789     }
790 
791     @ForceInline
792     @Override
793     final
794     ByteVector fromByteBuffer0(ByteBuffer bb, int offset) {
795         return super.fromByteBuffer0Template(bb, offset);  // specialize
796     }
797 
798     @ForceInline
799     @Override
800     final
801     void intoArray0(byte[] a, int offset) {
802         super.intoArray0Template(a, offset);  // specialize
803     }
804 
805     @ForceInline
806     @Override
807     final
808     void intoByteArray0(byte[] a, int offset) {
809         super.intoByteArray0Template(a, offset);  // specialize
810     }
811 
812     // End of specialized low-level memory operations.
813 
814     // ================================================
815 
816 }