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