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