1 /* 2 * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package jdk.incubator.vector; 26 27 import java.nio.ByteBuffer; 28 import java.util.Arrays; 29 import java.util.Objects; 30 import java.util.function.IntUnaryOperator; 31 32 import jdk.internal.vm.annotation.ForceInline; 33 import jdk.internal.vm.vector.VectorSupport; 34 35 import static jdk.internal.vm.vector.VectorSupport.*; 36 37 import static jdk.incubator.vector.VectorOperators.*; 38 39 // -- This file was mechanically generated: Do not edit! -- // 40 41 @SuppressWarnings("cast") // warning: redundant cast 42 final class Long64Vector extends LongVector { 43 static final LongSpecies VSPECIES = 44 (LongSpecies) LongVector.SPECIES_64; 45 46 static final VectorShape VSHAPE = 47 VSPECIES.vectorShape(); 48 49 static final Class<Long64Vector> VCLASS = Long64Vector.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 Long64Vector(long[] v)57 Long64Vector(long[] v) { 58 super(v); 59 } 60 61 // For compatibility as Long64Vector::new, 62 // stored into species.vectorFactory. Long64Vector(Object v)63 Long64Vector(Object v) { 64 this((long[]) v); 65 } 66 67 static final Long64Vector ZERO = new Long64Vector(new long[VLENGTH]); 68 static final Long64Vector IOTA = new Long64Vector(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 Long64Vector broadcast(long e) { 125 return (Long64Vector) super.broadcastTemplate(e); // specialize 126 } 127 128 129 @Override 130 @ForceInline maskFromArray(boolean[] bits)131 Long64Mask maskFromArray(boolean[] bits) { 132 return new Long64Mask(bits); 133 } 134 135 @Override 136 @ForceInline iotaShuffle()137 Long64Shuffle iotaShuffle() { return Long64Shuffle.IOTA; } 138 139 @ForceInline iotaShuffle(int start, int step, boolean wrap)140 Long64Shuffle iotaShuffle(int start, int step, boolean wrap) { 141 if (wrap) { 142 return (Long64Shuffle)VectorSupport.shuffleIota(ETYPE, Long64Shuffle.class, VSPECIES, VLENGTH, start, step, 1, 143 (l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l)))); 144 } else { 145 return (Long64Shuffle)VectorSupport.shuffleIota(ETYPE, Long64Shuffle.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 Long64Shuffle shuffleFromBytes(byte[] reorder) { return new Long64Shuffle(reorder); } 153 154 @Override 155 @ForceInline shuffleFromArray(int[] indexes, int i)156 Long64Shuffle shuffleFromArray(int[] indexes, int i) { return new Long64Shuffle(indexes, i); } 157 158 @Override 159 @ForceInline shuffleFromOp(IntUnaryOperator fn)160 Long64Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Long64Shuffle(fn); } 161 162 // Make a vector of the same species but the given elements: 163 @ForceInline 164 final @Override vectorFactory(long[] vec)165 Long64Vector vectorFactory(long[] vec) { 166 return new Long64Vector(vec); 167 } 168 169 @ForceInline 170 final @Override asByteVectorRaw()171 Byte64Vector asByteVectorRaw() { 172 return (Byte64Vector) 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 Long64Vector uOp(FUnOp f) { 186 return (Long64Vector) super.uOpTemplate(f); // specialize 187 } 188 189 @ForceInline 190 final @Override uOp(VectorMask<Long> m, FUnOp f)191 Long64Vector uOp(VectorMask<Long> m, FUnOp f) { 192 return (Long64Vector) 193 super.uOpTemplate((Long64Mask)m, f); // specialize 194 } 195 196 // Binary operator 197 198 @ForceInline 199 final @Override bOp(Vector<Long> v, FBinOp f)200 Long64Vector bOp(Vector<Long> v, FBinOp f) { 201 return (Long64Vector) super.bOpTemplate((Long64Vector)v, f); // specialize 202 } 203 204 @ForceInline 205 final @Override bOp(Vector<Long> v, VectorMask<Long> m, FBinOp f)206 Long64Vector bOp(Vector<Long> v, 207 VectorMask<Long> m, FBinOp f) { 208 return (Long64Vector) 209 super.bOpTemplate((Long64Vector)v, (Long64Mask)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 Long64Vector tOp(Vector<Long> v1, Vector<Long> v2, FTriOp f) { 218 return (Long64Vector) 219 super.tOpTemplate((Long64Vector)v1, (Long64Vector)v2, 220 f); // specialize 221 } 222 223 @ForceInline 224 final @Override tOp(Vector<Long> v1, Vector<Long> v2, VectorMask<Long> m, FTriOp f)225 Long64Vector tOp(Vector<Long> v1, Vector<Long> v2, 226 VectorMask<Long> m, FTriOp f) { 227 return (Long64Vector) 228 super.tOpTemplate((Long64Vector)v1, (Long64Vector)v2, 229 (Long64Mask)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 Long64Vector lanewise(Unary op) { 268 return (Long64Vector) super.lanewiseTemplate(op); // specialize 269 } 270 271 @Override 272 @ForceInline lanewise(Binary op, Vector<Long> v)273 public Long64Vector lanewise(Binary op, Vector<Long> v) { 274 return (Long64Vector) super.lanewiseTemplate(op, v); // specialize 275 } 276 277 /*package-private*/ 278 @Override 279 @ForceInline Long64Vector lanewiseShift(VectorOperators.Binary op, int e)280 lanewiseShift(VectorOperators.Binary op, int e) { 281 return (Long64Vector) super.lanewiseShiftTemplate(op, e); // specialize 282 } 283 284 /*package-private*/ 285 @Override 286 @ForceInline 287 public final 288 Long64Vector lanewise(VectorOperators.Ternary op, Vector<Long> v1, Vector<Long> v2)289 lanewise(VectorOperators.Ternary op, Vector<Long> v1, Vector<Long> v2) { 290 return (Long64Vector) super.lanewiseTemplate(op, v1, v2); // specialize 291 } 292 293 @Override 294 @ForceInline 295 public final addIndex(int scale)296 Long64Vector addIndex(int scale) { 297 return (Long64Vector) 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 @ForceInline toShuffle()329 public VectorShuffle<Long> toShuffle() { 330 return super.toShuffleTemplate(Long64Shuffle.class); // specialize 331 } 332 333 // Specialized unary testing 334 335 @Override 336 @ForceInline test(Test op)337 public final Long64Mask test(Test op) { 338 return super.testTemplate(Long64Mask.class, op); // specialize 339 } 340 341 // Specialized comparisons 342 343 @Override 344 @ForceInline compare(Comparison op, Vector<Long> v)345 public final Long64Mask compare(Comparison op, Vector<Long> v) { 346 return super.compareTemplate(Long64Mask.class, op, v); // specialize 347 } 348 349 @Override 350 @ForceInline compare(Comparison op, long s)351 public final Long64Mask compare(Comparison op, long s) { 352 return super.compareTemplate(Long64Mask.class, op, s); // specialize 353 } 354 355 356 @Override 357 @ForceInline blend(Vector<Long> v, VectorMask<Long> m)358 public Long64Vector blend(Vector<Long> v, VectorMask<Long> m) { 359 return (Long64Vector) 360 super.blendTemplate(Long64Mask.class, 361 (Long64Vector) v, 362 (Long64Mask) m); // specialize 363 } 364 365 @Override 366 @ForceInline slice(int origin, Vector<Long> v)367 public Long64Vector slice(int origin, Vector<Long> v) { 368 return (Long64Vector) super.sliceTemplate(origin, v); // specialize 369 } 370 371 @Override 372 @ForceInline slice(int origin)373 public Long64Vector slice(int origin) { 374 return (Long64Vector) super.sliceTemplate(origin); // specialize 375 } 376 377 @Override 378 @ForceInline unslice(int origin, Vector<Long> w, int part)379 public Long64Vector unslice(int origin, Vector<Long> w, int part) { 380 return (Long64Vector) super.unsliceTemplate(origin, w, part); // specialize 381 } 382 383 @Override 384 @ForceInline unslice(int origin, Vector<Long> w, int part, VectorMask<Long> m)385 public Long64Vector unslice(int origin, Vector<Long> w, int part, VectorMask<Long> m) { 386 return (Long64Vector) 387 super.unsliceTemplate(Long64Mask.class, 388 origin, w, part, 389 (Long64Mask) m); // specialize 390 } 391 392 @Override 393 @ForceInline unslice(int origin)394 public Long64Vector unslice(int origin) { 395 return (Long64Vector) super.unsliceTemplate(origin); // specialize 396 } 397 398 @Override 399 @ForceInline rearrange(VectorShuffle<Long> s)400 public Long64Vector rearrange(VectorShuffle<Long> s) { 401 return (Long64Vector) 402 super.rearrangeTemplate(Long64Shuffle.class, 403 (Long64Shuffle) s); // specialize 404 } 405 406 @Override 407 @ForceInline rearrange(VectorShuffle<Long> shuffle, VectorMask<Long> m)408 public Long64Vector rearrange(VectorShuffle<Long> shuffle, 409 VectorMask<Long> m) { 410 return (Long64Vector) 411 super.rearrangeTemplate(Long64Shuffle.class, 412 (Long64Shuffle) shuffle, 413 (Long64Mask) m); // specialize 414 } 415 416 @Override 417 @ForceInline rearrange(VectorShuffle<Long> s, Vector<Long> v)418 public Long64Vector rearrange(VectorShuffle<Long> s, 419 Vector<Long> v) { 420 return (Long64Vector) 421 super.rearrangeTemplate(Long64Shuffle.class, 422 (Long64Shuffle) s, 423 (Long64Vector) v); // specialize 424 } 425 426 @Override 427 @ForceInline selectFrom(Vector<Long> v)428 public Long64Vector selectFrom(Vector<Long> v) { 429 return (Long64Vector) 430 super.selectFromTemplate((Long64Vector) v); // specialize 431 } 432 433 @Override 434 @ForceInline selectFrom(Vector<Long> v, VectorMask<Long> m)435 public Long64Vector selectFrom(Vector<Long> v, 436 VectorMask<Long> m) { 437 return (Long64Vector) 438 super.selectFromTemplate((Long64Vector) v, 439 (Long64Mask) m); // specialize 440 } 441 442 443 @ForceInline 444 @Override lane(int i)445 public long lane(int i) { 446 switch(i) { 447 case 0: return laneHelper(0); 448 default: throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH); 449 } 450 } 451 laneHelper(int i)452 public long laneHelper(int i) { 453 return (long) VectorSupport.extract( 454 VCLASS, ETYPE, VLENGTH, 455 this, i, 456 (vec, ix) -> { 457 long[] vecarr = vec.vec(); 458 return (long)vecarr[ix]; 459 }); 460 } 461 462 @ForceInline 463 @Override withLane(int i, long e)464 public Long64Vector withLane(int i, long e) { 465 switch (i) { 466 case 0: return withLaneHelper(0, e); 467 default: throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH); 468 } 469 } 470 withLaneHelper(int i, long e)471 public Long64Vector withLaneHelper(int i, long e) { 472 return VectorSupport.insert( 473 VCLASS, ETYPE, VLENGTH, 474 this, i, (long)e, 475 (v, ix, bits) -> { 476 long[] res = v.vec().clone(); 477 res[ix] = (long)bits; 478 return v.vectorFactory(res); 479 }); 480 } 481 482 // Mask 483 484 static final class Long64Mask extends AbstractMask<Long> { 485 static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM 486 static final Class<Long> ETYPE = long.class; // used by the JVM 487 488 Long64Mask(boolean[] bits) { 489 this(bits, 0); 490 } 491 492 Long64Mask(boolean[] bits, int offset) { 493 super(prepare(bits, offset)); 494 } 495 496 Long64Mask(boolean val) { 497 super(prepare(val)); 498 } 499 500 private static boolean[] prepare(boolean[] bits, int offset) { 501 boolean[] newBits = new boolean[VSPECIES.laneCount()]; 502 for (int i = 0; i < newBits.length; i++) { 503 newBits[i] = bits[offset + i]; 504 } 505 return newBits; 506 } 507 508 private static boolean[] prepare(boolean val) { 509 boolean[] bits = new boolean[VSPECIES.laneCount()]; 510 Arrays.fill(bits, val); 511 return bits; 512 } 513 514 @ForceInline 515 final @Override 516 public LongSpecies vspecies() { 517 // ISSUE: This should probably be a @Stable 518 // field inside AbstractMask, rather than 519 // a megamorphic method. 520 return VSPECIES; 521 } 522 523 @ForceInline 524 boolean[] getBits() { 525 return (boolean[])getPayload(); 526 } 527 528 @Override 529 Long64Mask uOp(MUnOp f) { 530 boolean[] res = new boolean[vspecies().laneCount()]; 531 boolean[] bits = getBits(); 532 for (int i = 0; i < res.length; i++) { 533 res[i] = f.apply(i, bits[i]); 534 } 535 return new Long64Mask(res); 536 } 537 538 @Override 539 Long64Mask bOp(VectorMask<Long> m, MBinOp f) { 540 boolean[] res = new boolean[vspecies().laneCount()]; 541 boolean[] bits = getBits(); 542 boolean[] mbits = ((Long64Mask)m).getBits(); 543 for (int i = 0; i < res.length; i++) { 544 res[i] = f.apply(i, bits[i], mbits[i]); 545 } 546 return new Long64Mask(res); 547 } 548 549 @ForceInline 550 @Override 551 public final 552 Long64Vector toVector() { 553 return (Long64Vector) super.toVectorTemplate(); // specialize 554 } 555 556 /** 557 * Helper function for lane-wise mask conversions. 558 * This function kicks in after intrinsic failure. 559 */ 560 @ForceInline 561 private final <E> 562 VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) { 563 if (length() != dsp.laneCount()) 564 throw new IllegalArgumentException("VectorMask length and species length differ"); 565 boolean[] maskArray = toArray(); 566 return dsp.maskFactory(maskArray).check(dsp); 567 } 568 569 @Override 570 @ForceInline 571 public <E> VectorMask<E> cast(VectorSpecies<E> dsp) { 572 AbstractSpecies<E> species = (AbstractSpecies<E>) dsp; 573 if (length() != species.laneCount()) 574 throw new IllegalArgumentException("VectorMask length and species length differ"); 575 if (VSIZE == species.vectorBitSize()) { 576 Class<?> dtype = species.elementType(); 577 Class<?> dmtype = species.maskType(); 578 return VectorSupport.convert(VectorSupport.VECTOR_OP_REINTERPRET, 579 this.getClass(), ETYPE, VLENGTH, 580 dmtype, dtype, VLENGTH, 581 this, species, 582 Long64Mask::defaultMaskCast); 583 } 584 return this.defaultMaskCast(species); 585 } 586 587 @Override 588 @ForceInline 589 public Long64Mask eq(VectorMask<Long> mask) { 590 Objects.requireNonNull(mask); 591 Long64Mask m = (Long64Mask)mask; 592 return xor(m.not()); 593 } 594 595 // Unary operations 596 597 @Override 598 @ForceInline 599 public Long64Mask not() { 600 return xor(maskAll(true)); 601 } 602 603 // Binary operations 604 605 @Override 606 @ForceInline 607 public Long64Mask and(VectorMask<Long> mask) { 608 Objects.requireNonNull(mask); 609 Long64Mask m = (Long64Mask)mask; 610 return VectorSupport.binaryOp(VECTOR_OP_AND, Long64Mask.class, long.class, VLENGTH, 611 this, m, 612 (m1, m2) -> m1.bOp(m2, (i, a, b) -> a & b)); 613 } 614 615 @Override 616 @ForceInline 617 public Long64Mask or(VectorMask<Long> mask) { 618 Objects.requireNonNull(mask); 619 Long64Mask m = (Long64Mask)mask; 620 return VectorSupport.binaryOp(VECTOR_OP_OR, Long64Mask.class, long.class, VLENGTH, 621 this, m, 622 (m1, m2) -> m1.bOp(m2, (i, a, b) -> a | b)); 623 } 624 625 @ForceInline 626 /* package-private */ 627 Long64Mask xor(VectorMask<Long> mask) { 628 Objects.requireNonNull(mask); 629 Long64Mask m = (Long64Mask)mask; 630 return VectorSupport.binaryOp(VECTOR_OP_XOR, Long64Mask.class, long.class, VLENGTH, 631 this, m, 632 (m1, m2) -> m1.bOp(m2, (i, a, b) -> a ^ b)); 633 } 634 635 // Mask Query operations 636 637 @Override 638 @ForceInline 639 public int trueCount() { 640 return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Long64Mask.class, long.class, VLENGTH, this, 641 (m) -> trueCountHelper(((Long64Mask)m).getBits())); 642 } 643 644 @Override 645 @ForceInline 646 public int firstTrue() { 647 return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Long64Mask.class, long.class, VLENGTH, this, 648 (m) -> firstTrueHelper(((Long64Mask)m).getBits())); 649 } 650 651 @Override 652 @ForceInline 653 public int lastTrue() { 654 return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Long64Mask.class, long.class, VLENGTH, this, 655 (m) -> lastTrueHelper(((Long64Mask)m).getBits())); 656 } 657 658 // Reductions 659 660 @Override 661 @ForceInline 662 public boolean anyTrue() { 663 return VectorSupport.test(BT_ne, Long64Mask.class, long.class, VLENGTH, 664 this, vspecies().maskAll(true), 665 (m, __) -> anyTrueHelper(((Long64Mask)m).getBits())); 666 } 667 668 @Override 669 @ForceInline 670 public boolean allTrue() { 671 return VectorSupport.test(BT_overflow, Long64Mask.class, long.class, VLENGTH, 672 this, vspecies().maskAll(true), 673 (m, __) -> allTrueHelper(((Long64Mask)m).getBits())); 674 } 675 676 @ForceInline 677 /*package-private*/ 678 static Long64Mask maskAll(boolean bit) { 679 return VectorSupport.broadcastCoerced(Long64Mask.class, long.class, VLENGTH, 680 (bit ? -1 : 0), null, 681 (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); 682 } 683 private static final Long64Mask TRUE_MASK = new Long64Mask(true); 684 private static final Long64Mask FALSE_MASK = new Long64Mask(false); 685 686 } 687 688 // Shuffle 689 690 static final class Long64Shuffle extends AbstractShuffle<Long> { 691 static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM 692 static final Class<Long> ETYPE = long.class; // used by the JVM 693 694 Long64Shuffle(byte[] reorder) { 695 super(VLENGTH, reorder); 696 } 697 698 public Long64Shuffle(int[] reorder) { 699 super(VLENGTH, reorder); 700 } 701 702 public Long64Shuffle(int[] reorder, int i) { 703 super(VLENGTH, reorder, i); 704 } 705 706 public Long64Shuffle(IntUnaryOperator fn) { 707 super(VLENGTH, fn); 708 } 709 710 @Override 711 public LongSpecies vspecies() { 712 return VSPECIES; 713 } 714 715 static { 716 // There must be enough bits in the shuffle lanes to encode 717 // VLENGTH valid indexes and VLENGTH exceptional ones. 718 assert(VLENGTH < Byte.MAX_VALUE); 719 assert(Byte.MIN_VALUE <= -VLENGTH); 720 } 721 static final Long64Shuffle IOTA = new Long64Shuffle(IDENTITY); 722 723 @Override 724 @ForceInline 725 public Long64Vector toVector() { 726 return VectorSupport.shuffleToVector(VCLASS, ETYPE, Long64Shuffle.class, this, VLENGTH, 727 (s) -> ((Long64Vector)(((AbstractShuffle<Long>)(s)).toVectorTemplate()))); 728 } 729 730 @Override 731 @ForceInline 732 public <F> VectorShuffle<F> cast(VectorSpecies<F> s) { 733 AbstractSpecies<F> species = (AbstractSpecies<F>) s; 734 if (length() != species.laneCount()) 735 throw new IllegalArgumentException("VectorShuffle length and species length differ"); 736 int[] shuffleArray = toArray(); 737 return s.shuffleFromArray(shuffleArray, 0).check(s); 738 } 739 740 @ForceInline 741 @Override 742 public Long64Shuffle rearrange(VectorShuffle<Long> shuffle) { 743 Long64Shuffle s = (Long64Shuffle) shuffle; 744 byte[] reorder1 = reorder(); 745 byte[] reorder2 = s.reorder(); 746 byte[] r = new byte[reorder1.length]; 747 for (int i = 0; i < reorder1.length; i++) { 748 int ssi = reorder2[i]; 749 r[i] = reorder1[ssi]; // throws on exceptional index 750 } 751 return new Long64Shuffle(r); 752 } 753 } 754 755 // ================================================ 756 757 // Specialized low-level memory operations. 758 759 @ForceInline 760 @Override 761 final 762 LongVector fromArray0(long[] a, int offset) { 763 return super.fromArray0Template(a, offset); // specialize 764 } 765 766 767 768 @ForceInline 769 @Override 770 final 771 LongVector fromByteArray0(byte[] a, int offset) { 772 return super.fromByteArray0Template(a, offset); // specialize 773 } 774 775 @ForceInline 776 @Override 777 final 778 LongVector fromByteBuffer0(ByteBuffer bb, int offset) { 779 return super.fromByteBuffer0Template(bb, offset); // specialize 780 } 781 782 @ForceInline 783 @Override 784 final 785 void intoArray0(long[] a, int offset) { 786 super.intoArray0Template(a, offset); // specialize 787 } 788 789 @ForceInline 790 @Override 791 final 792 void intoByteArray0(byte[] a, int offset) { 793 super.intoByteArray0Template(a, offset); // specialize 794 } 795 796 // End of specialized low-level memory operations. 797 798 // ================================================ 799 800 } 801