1 /* 2 * Copyright (c) 2017, 2022, 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 57 Long128Vector(long[] v) { 58 super(v); 59 } 60 61 // For compatibility as Long128Vector::new, 62 // stored into species.vectorFactory. 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. 74 VSPECIES.dummyVector(); 75 VSPECIES.withLanes(LaneType.BYTE); 76 } 77 78 // Specialized extractors 79 80 @ForceInline 81 final @Override 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 91 public final Class<Long> elementType() { return long.class; } 92 93 @ForceInline 94 @Override 95 public final int elementSize() { return Long.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 long[] vec() { 117 return (long[])getPayload(); 118 } 119 120 // Virtualized constructors 121 122 @Override 123 @ForceInline 124 public final Long128Vector broadcast(long e) { 125 return (Long128Vector) super.broadcastTemplate(e); // specialize 126 } 127 128 129 @Override 130 @ForceInline 131 Long128Mask maskFromArray(boolean[] bits) { 132 return new Long128Mask(bits); 133 } 134 135 @Override 136 @ForceInline 137 Long128Shuffle iotaShuffle() { return Long128Shuffle.IOTA; } 138 139 @ForceInline 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 152 Long128Shuffle shuffleFromBytes(byte[] reorder) { return new Long128Shuffle(reorder); } 153 154 @Override 155 @ForceInline 156 Long128Shuffle shuffleFromArray(int[] indexes, int i) { return new Long128Shuffle(indexes, i); } 157 158 @Override 159 @ForceInline 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 165 Long128Vector vectorFactory(long[] vec) { 166 return new Long128Vector(vec); 167 } 168 169 @ForceInline 170 final @Override 171 Byte128Vector asByteVectorRaw() { 172 return (Byte128Vector) super.asByteVectorRawTemplate(); // specialize 173 } 174 175 @ForceInline 176 final @Override 177 AbstractVector<?> asVectorRaw(LaneType laneType) { 178 return super.asVectorRawTemplate(laneType); // specialize 179 } 180 181 // Unary operator 182 183 @ForceInline 184 final @Override 185 Long128Vector uOp(FUnOp f) { 186 return (Long128Vector) super.uOpTemplate(f); // specialize 187 } 188 189 @ForceInline 190 final @Override 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 200 Long128Vector bOp(Vector<Long> v, FBinOp f) { 201 return (Long128Vector) super.bOpTemplate((Long128Vector)v, f); // specialize 202 } 203 204 @ForceInline 205 final @Override 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 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 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 234 long rOp(long v, VectorMask<Long> m, FBinOp f) { 235 return super.rOpTemplate(v, m, f); // specialize 236 } 237 238 @Override 239 @ForceInline 240 public final <F> 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> 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 267 public Long128Vector lanewise(Unary op) { 268 return (Long128Vector) super.lanewiseTemplate(op); // specialize 269 } 270 271 @Override 272 @ForceInline 273 public Long128Vector lanewise(Unary op, VectorMask<Long> m) { 274 return (Long128Vector) super.lanewiseTemplate(op, Long128Mask.class, (Long128Mask) m); // specialize 275 } 276 277 @Override 278 @ForceInline 279 public Long128Vector lanewise(Binary op, Vector<Long> v) { 280 return (Long128Vector) super.lanewiseTemplate(op, v); // specialize 281 } 282 283 @Override 284 @ForceInline 285 public Long128Vector lanewise(Binary op, Vector<Long> v, VectorMask<Long> m) { 286 return (Long128Vector) super.lanewiseTemplate(op, Long128Mask.class, v, (Long128Mask) m); // specialize 287 } 288 289 /*package-private*/ 290 @Override 291 @ForceInline Long128Vector 292 lanewiseShift(VectorOperators.Binary op, int e) { 293 return (Long128Vector) super.lanewiseShiftTemplate(op, e); // specialize 294 } 295 296 /*package-private*/ 297 @Override 298 @ForceInline Long128Vector 299 lanewiseShift(VectorOperators.Binary op, int e, VectorMask<Long> m) { 300 return (Long128Vector) super.lanewiseShiftTemplate(op, Long128Mask.class, e, (Long128Mask) m); // specialize 301 } 302 303 /*package-private*/ 304 @Override 305 @ForceInline 306 public final 307 Long128Vector 308 lanewise(Ternary op, Vector<Long> v1, Vector<Long> v2) { 309 return (Long128Vector) super.lanewiseTemplate(op, v1, v2); // specialize 310 } 311 312 @Override 313 @ForceInline 314 public final 315 Long128Vector 316 lanewise(Ternary op, Vector<Long> v1, Vector<Long> v2, VectorMask<Long> m) { 317 return (Long128Vector) super.lanewiseTemplate(op, Long128Mask.class, v1, v2, (Long128Mask) m); // specialize 318 } 319 320 @Override 321 @ForceInline 322 public final 323 Long128Vector addIndex(int scale) { 324 return (Long128Vector) super.addIndexTemplate(scale); // specialize 325 } 326 327 // Type specific horizontal reductions 328 329 @Override 330 @ForceInline 331 public final long reduceLanes(VectorOperators.Associative op) { 332 return super.reduceLanesTemplate(op); // specialized 333 } 334 335 @Override 336 @ForceInline 337 public final long reduceLanes(VectorOperators.Associative op, 338 VectorMask<Long> m) { 339 return super.reduceLanesTemplate(op, Long128Mask.class, (Long128Mask) m); // specialized 340 } 341 342 @Override 343 @ForceInline 344 public final long reduceLanesToLong(VectorOperators.Associative op) { 345 return (long) super.reduceLanesTemplate(op); // specialized 346 } 347 348 @Override 349 @ForceInline 350 public final long reduceLanesToLong(VectorOperators.Associative op, 351 VectorMask<Long> m) { 352 return (long) super.reduceLanesTemplate(op, Long128Mask.class, (Long128Mask) m); // specialized 353 } 354 355 @ForceInline 356 public VectorShuffle<Long> toShuffle() { 357 return super.toShuffleTemplate(Long128Shuffle.class); // specialize 358 } 359 360 // Specialized unary testing 361 362 @Override 363 @ForceInline 364 public final Long128Mask test(Test op) { 365 return super.testTemplate(Long128Mask.class, op); // specialize 366 } 367 368 @Override 369 @ForceInline 370 public final Long128Mask test(Test op, VectorMask<Long> m) { 371 return super.testTemplate(Long128Mask.class, op, (Long128Mask) m); // specialize 372 } 373 374 // Specialized comparisons 375 376 @Override 377 @ForceInline 378 public final Long128Mask compare(Comparison op, Vector<Long> v) { 379 return super.compareTemplate(Long128Mask.class, op, v); // specialize 380 } 381 382 @Override 383 @ForceInline 384 public final Long128Mask compare(Comparison op, long s) { 385 return super.compareTemplate(Long128Mask.class, op, s); // specialize 386 } 387 388 389 @Override 390 @ForceInline 391 public final Long128Mask compare(Comparison op, Vector<Long> v, VectorMask<Long> m) { 392 return super.compareTemplate(Long128Mask.class, op, v, (Long128Mask) m); 393 } 394 395 396 @Override 397 @ForceInline 398 public Long128Vector blend(Vector<Long> v, VectorMask<Long> m) { 399 return (Long128Vector) 400 super.blendTemplate(Long128Mask.class, 401 (Long128Vector) v, 402 (Long128Mask) m); // specialize 403 } 404 405 @Override 406 @ForceInline 407 public Long128Vector slice(int origin, Vector<Long> v) { 408 return (Long128Vector) super.sliceTemplate(origin, v); // specialize 409 } 410 411 @Override 412 @ForceInline 413 public Long128Vector slice(int origin) { 414 return (Long128Vector) super.sliceTemplate(origin); // specialize 415 } 416 417 @Override 418 @ForceInline 419 public Long128Vector unslice(int origin, Vector<Long> w, int part) { 420 return (Long128Vector) super.unsliceTemplate(origin, w, part); // specialize 421 } 422 423 @Override 424 @ForceInline 425 public Long128Vector unslice(int origin, Vector<Long> w, int part, VectorMask<Long> m) { 426 return (Long128Vector) 427 super.unsliceTemplate(Long128Mask.class, 428 origin, w, part, 429 (Long128Mask) m); // specialize 430 } 431 432 @Override 433 @ForceInline 434 public Long128Vector unslice(int origin) { 435 return (Long128Vector) super.unsliceTemplate(origin); // specialize 436 } 437 438 @Override 439 @ForceInline 440 public Long128Vector rearrange(VectorShuffle<Long> s) { 441 return (Long128Vector) 442 super.rearrangeTemplate(Long128Shuffle.class, 443 (Long128Shuffle) s); // specialize 444 } 445 446 @Override 447 @ForceInline 448 public Long128Vector rearrange(VectorShuffle<Long> shuffle, 449 VectorMask<Long> m) { 450 return (Long128Vector) 451 super.rearrangeTemplate(Long128Shuffle.class, 452 Long128Mask.class, 453 (Long128Shuffle) shuffle, 454 (Long128Mask) m); // specialize 455 } 456 457 @Override 458 @ForceInline 459 public Long128Vector rearrange(VectorShuffle<Long> s, 460 Vector<Long> v) { 461 return (Long128Vector) 462 super.rearrangeTemplate(Long128Shuffle.class, 463 (Long128Shuffle) s, 464 (Long128Vector) v); // specialize 465 } 466 467 @Override 468 @ForceInline 469 public Long128Vector selectFrom(Vector<Long> v) { 470 return (Long128Vector) 471 super.selectFromTemplate((Long128Vector) v); // specialize 472 } 473 474 @Override 475 @ForceInline 476 public Long128Vector selectFrom(Vector<Long> v, 477 VectorMask<Long> m) { 478 return (Long128Vector) 479 super.selectFromTemplate((Long128Vector) v, 480 (Long128Mask) m); // specialize 481 } 482 483 484 @ForceInline 485 @Override 486 public long lane(int i) { 487 switch(i) { 488 case 0: return laneHelper(0); 489 case 1: return laneHelper(1); 490 default: throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH); 491 } 492 } 493 494 public long laneHelper(int i) { 495 return (long) VectorSupport.extract( 496 VCLASS, ETYPE, VLENGTH, 497 this, i, 498 (vec, ix) -> { 499 long[] vecarr = vec.vec(); 500 return (long)vecarr[ix]; 501 }); 502 } 503 504 @ForceInline 505 @Override 506 public Long128Vector withLane(int i, long e) { 507 switch (i) { 508 case 0: return withLaneHelper(0, e); 509 case 1: return withLaneHelper(1, e); 510 default: throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH); 511 } 512 } 513 514 public Long128Vector withLaneHelper(int i, long e) { 515 return VectorSupport.insert( 516 VCLASS, ETYPE, VLENGTH, 517 this, i, (long)e, 518 (v, ix, bits) -> { 519 long[] res = v.vec().clone(); 520 res[ix] = (long)bits; 521 return v.vectorFactory(res); 522 }); 523 } 524 525 // Mask 526 527 static final class Long128Mask extends AbstractMask<Long> { 528 static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM 529 static final Class<Long> ETYPE = long.class; // used by the JVM 530 531 Long128Mask(boolean[] bits) { 532 this(bits, 0); 533 } 534 535 Long128Mask(boolean[] bits, int offset) { 536 super(prepare(bits, offset)); 537 } 538 539 Long128Mask(boolean val) { 540 super(prepare(val)); 541 } 542 543 private static boolean[] prepare(boolean[] bits, int offset) { 544 boolean[] newBits = new boolean[VSPECIES.laneCount()]; 545 for (int i = 0; i < newBits.length; i++) { 546 newBits[i] = bits[offset + i]; 547 } 548 return newBits; 549 } 550 551 private static boolean[] prepare(boolean val) { 552 boolean[] bits = new boolean[VSPECIES.laneCount()]; 553 Arrays.fill(bits, val); 554 return bits; 555 } 556 557 @ForceInline 558 final @Override 559 public LongSpecies vspecies() { 560 // ISSUE: This should probably be a @Stable 561 // field inside AbstractMask, rather than 562 // a megamorphic method. 563 return VSPECIES; 564 } 565 566 @ForceInline 567 boolean[] getBits() { 568 return (boolean[])getPayload(); 569 } 570 571 @Override 572 Long128Mask uOp(MUnOp f) { 573 boolean[] res = new boolean[vspecies().laneCount()]; 574 boolean[] bits = getBits(); 575 for (int i = 0; i < res.length; i++) { 576 res[i] = f.apply(i, bits[i]); 577 } 578 return new Long128Mask(res); 579 } 580 581 @Override 582 Long128Mask bOp(VectorMask<Long> m, MBinOp f) { 583 boolean[] res = new boolean[vspecies().laneCount()]; 584 boolean[] bits = getBits(); 585 boolean[] mbits = ((Long128Mask)m).getBits(); 586 for (int i = 0; i < res.length; i++) { 587 res[i] = f.apply(i, bits[i], mbits[i]); 588 } 589 return new Long128Mask(res); 590 } 591 592 @ForceInline 593 @Override 594 public final 595 Long128Vector toVector() { 596 return (Long128Vector) super.toVectorTemplate(); // specialize 597 } 598 599 /** 600 * Helper function for lane-wise mask conversions. 601 * This function kicks in after intrinsic failure. 602 */ 603 @ForceInline 604 private final <E> 605 VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) { 606 if (length() != dsp.laneCount()) 607 throw new IllegalArgumentException("VectorMask length and species length differ"); 608 boolean[] maskArray = toArray(); 609 return dsp.maskFactory(maskArray).check(dsp); 610 } 611 612 @Override 613 @ForceInline 614 public <E> VectorMask<E> cast(VectorSpecies<E> dsp) { 615 AbstractSpecies<E> species = (AbstractSpecies<E>) dsp; 616 if (length() != species.laneCount()) 617 throw new IllegalArgumentException("VectorMask length and species length differ"); 618 619 return VectorSupport.convert(VectorSupport.VECTOR_OP_CAST, 620 this.getClass(), ETYPE, VLENGTH, 621 species.maskType(), species.elementType(), VLENGTH, 622 this, species, 623 (m, s) -> s.maskFactory(m.toArray()).check(s)); 624 } 625 626 @Override 627 @ForceInline 628 public Long128Mask eq(VectorMask<Long> mask) { 629 Objects.requireNonNull(mask); 630 Long128Mask m = (Long128Mask)mask; 631 return xor(m.not()); 632 } 633 634 // Unary operations 635 636 @Override 637 @ForceInline 638 public Long128Mask not() { 639 return xor(maskAll(true)); 640 } 641 642 // Binary operations 643 644 @Override 645 @ForceInline 646 public Long128Mask and(VectorMask<Long> mask) { 647 Objects.requireNonNull(mask); 648 Long128Mask m = (Long128Mask)mask; 649 return VectorSupport.binaryOp(VECTOR_OP_AND, Long128Mask.class, null, long.class, VLENGTH, 650 this, m, null, 651 (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); 652 } 653 654 @Override 655 @ForceInline 656 public Long128Mask or(VectorMask<Long> mask) { 657 Objects.requireNonNull(mask); 658 Long128Mask m = (Long128Mask)mask; 659 return VectorSupport.binaryOp(VECTOR_OP_OR, Long128Mask.class, null, long.class, VLENGTH, 660 this, m, null, 661 (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); 662 } 663 664 @ForceInline 665 /* package-private */ 666 Long128Mask xor(VectorMask<Long> mask) { 667 Objects.requireNonNull(mask); 668 Long128Mask m = (Long128Mask)mask; 669 return VectorSupport.binaryOp(VECTOR_OP_XOR, Long128Mask.class, null, long.class, VLENGTH, 670 this, m, null, 671 (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); 672 } 673 674 // Mask Query operations 675 676 @Override 677 @ForceInline 678 public int trueCount() { 679 return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Long128Mask.class, long.class, VLENGTH, this, 680 (m) -> trueCountHelper(m.getBits())); 681 } 682 683 @Override 684 @ForceInline 685 public int firstTrue() { 686 return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Long128Mask.class, long.class, VLENGTH, this, 687 (m) -> firstTrueHelper(m.getBits())); 688 } 689 690 @Override 691 @ForceInline 692 public int lastTrue() { 693 return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Long128Mask.class, long.class, VLENGTH, this, 694 (m) -> lastTrueHelper(m.getBits())); 695 } 696 697 @Override 698 @ForceInline 699 public long toLong() { 700 if (length() > Long.SIZE) { 701 throw new UnsupportedOperationException("too many lanes for one long"); 702 } 703 return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Long128Mask.class, long.class, VLENGTH, this, 704 (m) -> toLongHelper(m.getBits())); 705 } 706 707 // Reductions 708 709 @Override 710 @ForceInline 711 public boolean anyTrue() { 712 return VectorSupport.test(BT_ne, Long128Mask.class, long.class, VLENGTH, 713 this, vspecies().maskAll(true), 714 (m, __) -> anyTrueHelper(((Long128Mask)m).getBits())); 715 } 716 717 @Override 718 @ForceInline 719 public boolean allTrue() { 720 return VectorSupport.test(BT_overflow, Long128Mask.class, long.class, VLENGTH, 721 this, vspecies().maskAll(true), 722 (m, __) -> allTrueHelper(((Long128Mask)m).getBits())); 723 } 724 725 @ForceInline 726 /*package-private*/ 727 static Long128Mask maskAll(boolean bit) { 728 return VectorSupport.fromBitsCoerced(Long128Mask.class, long.class, VLENGTH, 729 (bit ? -1 : 0), MODE_BROADCAST, null, 730 (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); 731 } 732 private static final Long128Mask TRUE_MASK = new Long128Mask(true); 733 private static final Long128Mask FALSE_MASK = new Long128Mask(false); 734 735 } 736 737 // Shuffle 738 739 static final class Long128Shuffle extends AbstractShuffle<Long> { 740 static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM 741 static final Class<Long> ETYPE = long.class; // used by the JVM 742 743 Long128Shuffle(byte[] reorder) { 744 super(VLENGTH, reorder); 745 } 746 747 public Long128Shuffle(int[] reorder) { 748 super(VLENGTH, reorder); 749 } 750 751 public Long128Shuffle(int[] reorder, int i) { 752 super(VLENGTH, reorder, i); 753 } 754 755 public Long128Shuffle(IntUnaryOperator fn) { 756 super(VLENGTH, fn); 757 } 758 759 @Override 760 public LongSpecies vspecies() { 761 return VSPECIES; 762 } 763 764 static { 765 // There must be enough bits in the shuffle lanes to encode 766 // VLENGTH valid indexes and VLENGTH exceptional ones. 767 assert(VLENGTH < Byte.MAX_VALUE); 768 assert(Byte.MIN_VALUE <= -VLENGTH); 769 } 770 static final Long128Shuffle IOTA = new Long128Shuffle(IDENTITY); 771 772 @Override 773 @ForceInline 774 public Long128Vector toVector() { 775 return VectorSupport.shuffleToVector(VCLASS, ETYPE, Long128Shuffle.class, this, VLENGTH, 776 (s) -> ((Long128Vector)(((AbstractShuffle<Long>)(s)).toVectorTemplate()))); 777 } 778 779 @Override 780 @ForceInline 781 public <F> VectorShuffle<F> cast(VectorSpecies<F> s) { 782 AbstractSpecies<F> species = (AbstractSpecies<F>) s; 783 if (length() != species.laneCount()) 784 throw new IllegalArgumentException("VectorShuffle length and species length differ"); 785 int[] shuffleArray = toArray(); 786 return s.shuffleFromArray(shuffleArray, 0).check(s); 787 } 788 789 @ForceInline 790 @Override 791 public Long128Shuffle rearrange(VectorShuffle<Long> shuffle) { 792 Long128Shuffle s = (Long128Shuffle) shuffle; 793 byte[] reorder1 = reorder(); 794 byte[] reorder2 = s.reorder(); 795 byte[] r = new byte[reorder1.length]; 796 for (int i = 0; i < reorder1.length; i++) { 797 int ssi = reorder2[i]; 798 r[i] = reorder1[ssi]; // throws on exceptional index 799 } 800 return new Long128Shuffle(r); 801 } 802 } 803 804 // ================================================ 805 806 // Specialized low-level memory operations. 807 808 @ForceInline 809 @Override 810 final 811 LongVector fromArray0(long[] a, int offset) { 812 return super.fromArray0Template(a, offset); // specialize 813 } 814 815 @ForceInline 816 @Override 817 final 818 LongVector fromArray0(long[] a, int offset, VectorMask<Long> m) { 819 return super.fromArray0Template(Long128Mask.class, a, offset, (Long128Mask) m); // specialize 820 } 821 822 @ForceInline 823 @Override 824 final 825 LongVector fromArray0(long[] a, int offset, int[] indexMap, int mapOffset, VectorMask<Long> m) { 826 return super.fromArray0Template(Long128Mask.class, a, offset, indexMap, mapOffset, (Long128Mask) m); 827 } 828 829 830 831 @ForceInline 832 @Override 833 final 834 LongVector fromByteArray0(byte[] a, int offset) { 835 return super.fromByteArray0Template(a, offset); // specialize 836 } 837 838 @ForceInline 839 @Override 840 final 841 LongVector fromByteArray0(byte[] a, int offset, VectorMask<Long> m) { 842 return super.fromByteArray0Template(Long128Mask.class, a, offset, (Long128Mask) m); // specialize 843 } 844 845 @ForceInline 846 @Override 847 final 848 LongVector fromByteBuffer0(ByteBuffer bb, int offset) { 849 return super.fromByteBuffer0Template(bb, offset); // specialize 850 } 851 852 @ForceInline 853 @Override 854 final 855 LongVector fromByteBuffer0(ByteBuffer bb, int offset, VectorMask<Long> m) { 856 return super.fromByteBuffer0Template(Long128Mask.class, bb, offset, (Long128Mask) m); // specialize 857 } 858 859 @ForceInline 860 @Override 861 final 862 void intoArray0(long[] a, int offset) { 863 super.intoArray0Template(a, offset); // specialize 864 } 865 866 @ForceInline 867 @Override 868 final 869 void intoArray0(long[] a, int offset, VectorMask<Long> m) { 870 super.intoArray0Template(Long128Mask.class, a, offset, (Long128Mask) m); 871 } 872 873 @ForceInline 874 @Override 875 final 876 void intoArray0(long[] a, int offset, int[] indexMap, int mapOffset, VectorMask<Long> m) { 877 super.intoArray0Template(Long128Mask.class, a, offset, indexMap, mapOffset, (Long128Mask) m); 878 } 879 880 881 @ForceInline 882 @Override 883 final 884 void intoByteArray0(byte[] a, int offset) { 885 super.intoByteArray0Template(a, offset); // specialize 886 } 887 888 @ForceInline 889 @Override 890 final 891 void intoByteArray0(byte[] a, int offset, VectorMask<Long> m) { 892 super.intoByteArray0Template(Long128Mask.class, a, offset, (Long128Mask) m); // specialize 893 } 894 895 @ForceInline 896 @Override 897 final 898 void intoByteBuffer0(ByteBuffer bb, int offset, VectorMask<Long> m) { 899 super.intoByteBuffer0Template(Long128Mask.class, bb, offset, (Long128Mask) m); 900 } 901 902 903 // End of specialized low-level memory operations. 904 905 // ================================================ 906 907 }