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