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 Byte512Vector extends ByteVector {
  43     static final ByteSpecies VSPECIES =
  44         (ByteSpecies) ByteVector.SPECIES_512;
  45 
  46     static final VectorShape VSHAPE =
  47         VSPECIES.vectorShape();
  48 
  49     static final Class<Byte512Vector> VCLASS = Byte512Vector.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<Byte> ETYPE = byte.class; // used by the JVM
  56 
  57     Byte512Vector(byte[] v) {
  58         super(v);
  59     }
  60 
  61     // For compatibility as Byte512Vector::new,
  62     // stored into species.vectorFactory.
  63     Byte512Vector(Object v) {
  64         this((byte[]) v);
  65     }
  66 
  67     static final Byte512Vector ZERO = new Byte512Vector(new byte[VLENGTH]);
  68     static final Byte512Vector IOTA = new Byte512Vector(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 ByteSpecies 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<Byte> elementType() { return byte.class; }
  92 
  93     @ForceInline
  94     @Override
  95     public final int elementSize() { return Byte.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     byte[] vec() {
 117         return (byte[])getPayload();
 118     }
 119 
 120     // Virtualized constructors
 121 
 122     @Override
 123     @ForceInline
 124     public final Byte512Vector broadcast(byte e) {
 125         return (Byte512Vector) super.broadcastTemplate(e);  // specialize
 126     }
 127 
 128     @Override
 129     @ForceInline
 130     public final Byte512Vector broadcast(long e) {
 131         return (Byte512Vector) super.broadcastTemplate(e);  // specialize
 132     }
 133 
 134     @Override
 135     @ForceInline
 136     Byte512Mask maskFromArray(boolean[] bits) {
 137         return new Byte512Mask(bits);
 138     }
 139 
 140     @Override
 141     @ForceInline
 142     Byte512Shuffle iotaShuffle() { return Byte512Shuffle.IOTA; }
 143 
 144     @ForceInline
 145     Byte512Shuffle iotaShuffle(int start, int step, boolean wrap) {
 146       if (wrap) {
 147         return (Byte512Shuffle)VectorSupport.shuffleIota(ETYPE, Byte512Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
 148                 (l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
 149       } else {
 150         return (Byte512Shuffle)VectorSupport.shuffleIota(ETYPE, Byte512Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
 151                 (l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
 152       }
 153     }
 154 
 155     @Override
 156     @ForceInline
 157     Byte512Shuffle shuffleFromBytes(byte[] reorder) { return new Byte512Shuffle(reorder); }
 158 
 159     @Override
 160     @ForceInline
 161     Byte512Shuffle shuffleFromArray(int[] indexes, int i) { return new Byte512Shuffle(indexes, i); }
 162 
 163     @Override
 164     @ForceInline
 165     Byte512Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Byte512Shuffle(fn); }
 166 
 167     // Make a vector of the same species but the given elements:
 168     @ForceInline
 169     final @Override
 170     Byte512Vector vectorFactory(byte[] vec) {
 171         return new Byte512Vector(vec);
 172     }
 173 
 174     @ForceInline
 175     final @Override
 176     Byte512Vector asByteVectorRaw() {
 177         return (Byte512Vector) super.asByteVectorRawTemplate();  // specialize
 178     }
 179 
 180     @ForceInline
 181     final @Override
 182     AbstractVector<?> asVectorRaw(LaneType laneType) {
 183         return super.asVectorRawTemplate(laneType);  // specialize
 184     }
 185 
 186     // Unary operator
 187 
 188     @ForceInline
 189     final @Override
 190     Byte512Vector uOp(FUnOp f) {
 191         return (Byte512Vector) super.uOpTemplate(f);  // specialize
 192     }
 193 
 194     @ForceInline
 195     final @Override
 196     Byte512Vector uOp(VectorMask<Byte> m, FUnOp f) {
 197         return (Byte512Vector)
 198             super.uOpTemplate((Byte512Mask)m, f);  // specialize
 199     }
 200 
 201     // Binary operator
 202 
 203     @ForceInline
 204     final @Override
 205     Byte512Vector bOp(Vector<Byte> v, FBinOp f) {
 206         return (Byte512Vector) super.bOpTemplate((Byte512Vector)v, f);  // specialize
 207     }
 208 
 209     @ForceInline
 210     final @Override
 211     Byte512Vector bOp(Vector<Byte> v,
 212                      VectorMask<Byte> m, FBinOp f) {
 213         return (Byte512Vector)
 214             super.bOpTemplate((Byte512Vector)v, (Byte512Mask)m,
 215                               f);  // specialize
 216     }
 217 
 218     // Ternary operator
 219 
 220     @ForceInline
 221     final @Override
 222     Byte512Vector tOp(Vector<Byte> v1, Vector<Byte> v2, FTriOp f) {
 223         return (Byte512Vector)
 224             super.tOpTemplate((Byte512Vector)v1, (Byte512Vector)v2,
 225                               f);  // specialize
 226     }
 227 
 228     @ForceInline
 229     final @Override
 230     Byte512Vector tOp(Vector<Byte> v1, Vector<Byte> v2,
 231                      VectorMask<Byte> m, FTriOp f) {
 232         return (Byte512Vector)
 233             super.tOpTemplate((Byte512Vector)v1, (Byte512Vector)v2,
 234                               (Byte512Mask)m, f);  // specialize
 235     }
 236 
 237     @ForceInline
 238     final @Override
 239     byte rOp(byte v, VectorMask<Byte> m, FBinOp f) {
 240         return super.rOpTemplate(v, m, f);  // specialize
 241     }
 242 
 243     @Override
 244     @ForceInline
 245     public final <F>
 246     Vector<F> convertShape(VectorOperators.Conversion<Byte,F> conv,
 247                            VectorSpecies<F> rsp, int part) {
 248         return super.convertShapeTemplate(conv, rsp, part);  // specialize
 249     }
 250 
 251     @Override
 252     @ForceInline
 253     public final <F>
 254     Vector<F> reinterpretShape(VectorSpecies<F> toSpecies, int part) {
 255         return super.reinterpretShapeTemplate(toSpecies, part);  // specialize
 256     }
 257 
 258     // Specialized algebraic operations:
 259 
 260     // The following definition forces a specialized version of this
 261     // crucial method into the v-table of this class.  A call to add()
 262     // will inline to a call to lanewise(ADD,), at which point the JIT
 263     // intrinsic will have the opcode of ADD, plus all the metadata
 264     // for this particular class, enabling it to generate precise
 265     // code.
 266     //
 267     // There is probably no benefit to the JIT to specialize the
 268     // masked or broadcast versions of the lanewise method.
 269 
 270     @Override
 271     @ForceInline
 272     public Byte512Vector lanewise(Unary op) {
 273         return (Byte512Vector) super.lanewiseTemplate(op);  // specialize
 274     }
 275 
 276     @Override
 277     @ForceInline
 278     public Byte512Vector lanewise(Unary op, VectorMask<Byte> m) {
 279         return (Byte512Vector) super.lanewiseTemplate(op, Byte512Mask.class, (Byte512Mask) m);  // specialize
 280     }
 281 
 282     @Override
 283     @ForceInline
 284     public Byte512Vector lanewise(Binary op, Vector<Byte> v) {
 285         return (Byte512Vector) super.lanewiseTemplate(op, v);  // specialize
 286     }
 287 
 288     @Override
 289     @ForceInline
 290     public Byte512Vector lanewise(Binary op, Vector<Byte> v, VectorMask<Byte> m) {
 291         return (Byte512Vector) super.lanewiseTemplate(op, Byte512Mask.class, v, (Byte512Mask) m);  // specialize
 292     }
 293 
 294     /*package-private*/
 295     @Override
 296     @ForceInline Byte512Vector
 297     lanewiseShift(VectorOperators.Binary op, int e) {
 298         return (Byte512Vector) super.lanewiseShiftTemplate(op, e);  // specialize
 299     }
 300 
 301     /*package-private*/
 302     @Override
 303     @ForceInline Byte512Vector
 304     lanewiseShift(VectorOperators.Binary op, int e, VectorMask<Byte> m) {
 305         return (Byte512Vector) super.lanewiseShiftTemplate(op, Byte512Mask.class, e, (Byte512Mask) m);  // specialize
 306     }
 307 
 308     /*package-private*/
 309     @Override
 310     @ForceInline
 311     public final
 312     Byte512Vector
 313     lanewise(Ternary op, Vector<Byte> v1, Vector<Byte> v2) {
 314         return (Byte512Vector) super.lanewiseTemplate(op, v1, v2);  // specialize
 315     }
 316 
 317     @Override
 318     @ForceInline
 319     public final
 320     Byte512Vector
 321     lanewise(Ternary op, Vector<Byte> v1, Vector<Byte> v2, VectorMask<Byte> m) {
 322         return (Byte512Vector) super.lanewiseTemplate(op, Byte512Mask.class, v1, v2, (Byte512Mask) m);  // specialize
 323     }
 324 
 325     @Override
 326     @ForceInline
 327     public final
 328     Byte512Vector addIndex(int scale) {
 329         return (Byte512Vector) super.addIndexTemplate(scale);  // specialize
 330     }
 331 
 332     // Type specific horizontal reductions
 333 
 334     @Override
 335     @ForceInline
 336     public final byte reduceLanes(VectorOperators.Associative op) {
 337         return super.reduceLanesTemplate(op);  // specialized
 338     }
 339 
 340     @Override
 341     @ForceInline
 342     public final byte reduceLanes(VectorOperators.Associative op,
 343                                     VectorMask<Byte> m) {
 344         return super.reduceLanesTemplate(op, Byte512Mask.class, (Byte512Mask) m);  // specialized
 345     }
 346 
 347     @Override
 348     @ForceInline
 349     public final long reduceLanesToLong(VectorOperators.Associative op) {
 350         return (long) super.reduceLanesTemplate(op);  // specialized
 351     }
 352 
 353     @Override
 354     @ForceInline
 355     public final long reduceLanesToLong(VectorOperators.Associative op,
 356                                         VectorMask<Byte> m) {
 357         return (long) super.reduceLanesTemplate(op, Byte512Mask.class, (Byte512Mask) m);  // specialized
 358     }
 359 
 360     @ForceInline
 361     public VectorShuffle<Byte> toShuffle() {
 362         return super.toShuffleTemplate(Byte512Shuffle.class); // specialize
 363     }
 364 
 365     // Specialized unary testing
 366 
 367     @Override
 368     @ForceInline
 369     public final Byte512Mask test(Test op) {
 370         return super.testTemplate(Byte512Mask.class, op);  // specialize
 371     }
 372 
 373     // Specialized comparisons
 374 
 375     @Override
 376     @ForceInline
 377     public final Byte512Mask compare(Comparison op, Vector<Byte> v) {
 378         return super.compareTemplate(Byte512Mask.class, op, v);  // specialize
 379     }
 380 
 381     @Override
 382     @ForceInline
 383     public final Byte512Mask compare(Comparison op, byte s) {
 384         return super.compareTemplate(Byte512Mask.class, op, s);  // specialize
 385     }
 386 
 387     @Override
 388     @ForceInline
 389     public final Byte512Mask compare(Comparison op, long s) {
 390         return super.compareTemplate(Byte512Mask.class, op, s);  // specialize
 391     }
 392 
 393     @Override
 394     @ForceInline
 395     public final Byte512Mask compare(Comparison op, Vector<Byte> v, VectorMask<Byte> m) {
 396         return super.compareTemplate(Byte512Mask.class, op, v, (Byte512Mask) m);
 397     }
 398 
 399 
 400     @Override
 401     @ForceInline
 402     public Byte512Vector blend(Vector<Byte> v, VectorMask<Byte> m) {
 403         return (Byte512Vector)
 404             super.blendTemplate(Byte512Mask.class,
 405                                 (Byte512Vector) v,
 406                                 (Byte512Mask) m);  // specialize
 407     }
 408 
 409     @Override
 410     @ForceInline
 411     public Byte512Vector slice(int origin, Vector<Byte> v) {
 412         return (Byte512Vector) super.sliceTemplate(origin, v);  // specialize
 413     }
 414 
 415     @Override
 416     @ForceInline
 417     public Byte512Vector slice(int origin) {
 418         return (Byte512Vector) super.sliceTemplate(origin);  // specialize
 419     }
 420 
 421     @Override
 422     @ForceInline
 423     public Byte512Vector unslice(int origin, Vector<Byte> w, int part) {
 424         return (Byte512Vector) super.unsliceTemplate(origin, w, part);  // specialize
 425     }
 426 
 427     @Override
 428     @ForceInline
 429     public Byte512Vector unslice(int origin, Vector<Byte> w, int part, VectorMask<Byte> m) {
 430         return (Byte512Vector)
 431             super.unsliceTemplate(Byte512Mask.class,
 432                                   origin, w, part,
 433                                   (Byte512Mask) m);  // specialize
 434     }
 435 
 436     @Override
 437     @ForceInline
 438     public Byte512Vector unslice(int origin) {
 439         return (Byte512Vector) super.unsliceTemplate(origin);  // specialize
 440     }
 441 
 442     @Override
 443     @ForceInline
 444     public Byte512Vector rearrange(VectorShuffle<Byte> s) {
 445         return (Byte512Vector)
 446             super.rearrangeTemplate(Byte512Shuffle.class,
 447                                     (Byte512Shuffle) s);  // specialize
 448     }
 449 
 450     @Override
 451     @ForceInline
 452     public Byte512Vector rearrange(VectorShuffle<Byte> shuffle,
 453                                   VectorMask<Byte> m) {
 454         return (Byte512Vector)
 455             super.rearrangeTemplate(Byte512Shuffle.class,
 456                                     Byte512Mask.class,
 457                                     (Byte512Shuffle) shuffle,
 458                                     (Byte512Mask) m);  // specialize
 459     }
 460 
 461     @Override
 462     @ForceInline
 463     public Byte512Vector rearrange(VectorShuffle<Byte> s,
 464                                   Vector<Byte> v) {
 465         return (Byte512Vector)
 466             super.rearrangeTemplate(Byte512Shuffle.class,
 467                                     (Byte512Shuffle) s,
 468                                     (Byte512Vector) v);  // specialize
 469     }
 470 
















 471     @Override
 472     @ForceInline
 473     public Byte512Vector selectFrom(Vector<Byte> v) {
 474         return (Byte512Vector)
 475             super.selectFromTemplate((Byte512Vector) v);  // specialize
 476     }
 477 
 478     @Override
 479     @ForceInline
 480     public Byte512Vector selectFrom(Vector<Byte> v,
 481                                    VectorMask<Byte> m) {
 482         return (Byte512Vector)
 483             super.selectFromTemplate((Byte512Vector) v,
 484                                      (Byte512Mask) m);  // specialize
 485     }
 486 
 487 
 488     @ForceInline
 489     @Override
 490     public byte lane(int i) {
 491         switch(i) {
 492             case 0: return laneHelper(0);
 493             case 1: return laneHelper(1);
 494             case 2: return laneHelper(2);
 495             case 3: return laneHelper(3);
 496             case 4: return laneHelper(4);
 497             case 5: return laneHelper(5);
 498             case 6: return laneHelper(6);
 499             case 7: return laneHelper(7);
 500             case 8: return laneHelper(8);
 501             case 9: return laneHelper(9);
 502             case 10: return laneHelper(10);
 503             case 11: return laneHelper(11);
 504             case 12: return laneHelper(12);
 505             case 13: return laneHelper(13);
 506             case 14: return laneHelper(14);
 507             case 15: return laneHelper(15);
 508             case 16: return laneHelper(16);
 509             case 17: return laneHelper(17);
 510             case 18: return laneHelper(18);
 511             case 19: return laneHelper(19);
 512             case 20: return laneHelper(20);
 513             case 21: return laneHelper(21);
 514             case 22: return laneHelper(22);
 515             case 23: return laneHelper(23);
 516             case 24: return laneHelper(24);
 517             case 25: return laneHelper(25);
 518             case 26: return laneHelper(26);
 519             case 27: return laneHelper(27);
 520             case 28: return laneHelper(28);
 521             case 29: return laneHelper(29);
 522             case 30: return laneHelper(30);
 523             case 31: return laneHelper(31);
 524             case 32: return laneHelper(32);
 525             case 33: return laneHelper(33);
 526             case 34: return laneHelper(34);
 527             case 35: return laneHelper(35);
 528             case 36: return laneHelper(36);
 529             case 37: return laneHelper(37);
 530             case 38: return laneHelper(38);
 531             case 39: return laneHelper(39);
 532             case 40: return laneHelper(40);
 533             case 41: return laneHelper(41);
 534             case 42: return laneHelper(42);
 535             case 43: return laneHelper(43);
 536             case 44: return laneHelper(44);
 537             case 45: return laneHelper(45);
 538             case 46: return laneHelper(46);
 539             case 47: return laneHelper(47);
 540             case 48: return laneHelper(48);
 541             case 49: return laneHelper(49);
 542             case 50: return laneHelper(50);
 543             case 51: return laneHelper(51);
 544             case 52: return laneHelper(52);
 545             case 53: return laneHelper(53);
 546             case 54: return laneHelper(54);
 547             case 55: return laneHelper(55);
 548             case 56: return laneHelper(56);
 549             case 57: return laneHelper(57);
 550             case 58: return laneHelper(58);
 551             case 59: return laneHelper(59);
 552             case 60: return laneHelper(60);
 553             case 61: return laneHelper(61);
 554             case 62: return laneHelper(62);
 555             case 63: return laneHelper(63);
 556             default: throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH);
 557         }
 558     }
 559 
 560     public byte laneHelper(int i) {
 561         return (byte) VectorSupport.extract(
 562                                 VCLASS, ETYPE, VLENGTH,
 563                                 this, i,
 564                                 (vec, ix) -> {
 565                                     byte[] vecarr = vec.vec();
 566                                     return (long)vecarr[ix];
 567                                 });
 568     }
 569 
 570     @ForceInline
 571     @Override
 572     public Byte512Vector withLane(int i, byte e) {
 573         switch (i) {
 574             case 0: return withLaneHelper(0, e);
 575             case 1: return withLaneHelper(1, e);
 576             case 2: return withLaneHelper(2, e);
 577             case 3: return withLaneHelper(3, e);
 578             case 4: return withLaneHelper(4, e);
 579             case 5: return withLaneHelper(5, e);
 580             case 6: return withLaneHelper(6, e);
 581             case 7: return withLaneHelper(7, e);
 582             case 8: return withLaneHelper(8, e);
 583             case 9: return withLaneHelper(9, e);
 584             case 10: return withLaneHelper(10, e);
 585             case 11: return withLaneHelper(11, e);
 586             case 12: return withLaneHelper(12, e);
 587             case 13: return withLaneHelper(13, e);
 588             case 14: return withLaneHelper(14, e);
 589             case 15: return withLaneHelper(15, e);
 590             case 16: return withLaneHelper(16, e);
 591             case 17: return withLaneHelper(17, e);
 592             case 18: return withLaneHelper(18, e);
 593             case 19: return withLaneHelper(19, e);
 594             case 20: return withLaneHelper(20, e);
 595             case 21: return withLaneHelper(21, e);
 596             case 22: return withLaneHelper(22, e);
 597             case 23: return withLaneHelper(23, e);
 598             case 24: return withLaneHelper(24, e);
 599             case 25: return withLaneHelper(25, e);
 600             case 26: return withLaneHelper(26, e);
 601             case 27: return withLaneHelper(27, e);
 602             case 28: return withLaneHelper(28, e);
 603             case 29: return withLaneHelper(29, e);
 604             case 30: return withLaneHelper(30, e);
 605             case 31: return withLaneHelper(31, e);
 606             case 32: return withLaneHelper(32, e);
 607             case 33: return withLaneHelper(33, e);
 608             case 34: return withLaneHelper(34, e);
 609             case 35: return withLaneHelper(35, e);
 610             case 36: return withLaneHelper(36, e);
 611             case 37: return withLaneHelper(37, e);
 612             case 38: return withLaneHelper(38, e);
 613             case 39: return withLaneHelper(39, e);
 614             case 40: return withLaneHelper(40, e);
 615             case 41: return withLaneHelper(41, e);
 616             case 42: return withLaneHelper(42, e);
 617             case 43: return withLaneHelper(43, e);
 618             case 44: return withLaneHelper(44, e);
 619             case 45: return withLaneHelper(45, e);
 620             case 46: return withLaneHelper(46, e);
 621             case 47: return withLaneHelper(47, e);
 622             case 48: return withLaneHelper(48, e);
 623             case 49: return withLaneHelper(49, e);
 624             case 50: return withLaneHelper(50, e);
 625             case 51: return withLaneHelper(51, e);
 626             case 52: return withLaneHelper(52, e);
 627             case 53: return withLaneHelper(53, e);
 628             case 54: return withLaneHelper(54, e);
 629             case 55: return withLaneHelper(55, e);
 630             case 56: return withLaneHelper(56, e);
 631             case 57: return withLaneHelper(57, e);
 632             case 58: return withLaneHelper(58, e);
 633             case 59: return withLaneHelper(59, e);
 634             case 60: return withLaneHelper(60, e);
 635             case 61: return withLaneHelper(61, e);
 636             case 62: return withLaneHelper(62, e);
 637             case 63: return withLaneHelper(63, e);
 638             default: throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH);
 639         }
 640     }
 641 
 642     public Byte512Vector withLaneHelper(int i, byte e) {
 643         return VectorSupport.insert(
 644                                 VCLASS, ETYPE, VLENGTH,
 645                                 this, i, (long)e,
 646                                 (v, ix, bits) -> {
 647                                     byte[] res = v.vec().clone();
 648                                     res[ix] = (byte)bits;
 649                                     return v.vectorFactory(res);
 650                                 });
 651     }
 652 
 653     // Mask
 654 
 655     static final class Byte512Mask extends AbstractMask<Byte> {
 656         static final int VLENGTH = VSPECIES.laneCount();    // used by the JVM
 657         static final Class<Byte> ETYPE = byte.class; // used by the JVM
 658 
 659         Byte512Mask(boolean[] bits) {
 660             this(bits, 0);
 661         }
 662 
 663         Byte512Mask(boolean[] bits, int offset) {
 664             super(prepare(bits, offset));
 665         }
 666 
 667         Byte512Mask(boolean val) {
 668             super(prepare(val));
 669         }
 670 
 671         private static boolean[] prepare(boolean[] bits, int offset) {
 672             boolean[] newBits = new boolean[VSPECIES.laneCount()];
 673             for (int i = 0; i < newBits.length; i++) {
 674                 newBits[i] = bits[offset + i];
 675             }
 676             return newBits;
 677         }
 678 
 679         private static boolean[] prepare(boolean val) {
 680             boolean[] bits = new boolean[VSPECIES.laneCount()];
 681             Arrays.fill(bits, val);
 682             return bits;
 683         }
 684 
 685         @ForceInline
 686         final @Override
 687         public ByteSpecies vspecies() {
 688             // ISSUE:  This should probably be a @Stable
 689             // field inside AbstractMask, rather than
 690             // a megamorphic method.
 691             return VSPECIES;
 692         }
 693 
 694         @ForceInline
 695         boolean[] getBits() {
 696             return (boolean[])getPayload();
 697         }
 698 
 699         @Override
 700         Byte512Mask uOp(MUnOp f) {
 701             boolean[] res = new boolean[vspecies().laneCount()];
 702             boolean[] bits = getBits();
 703             for (int i = 0; i < res.length; i++) {
 704                 res[i] = f.apply(i, bits[i]);
 705             }
 706             return new Byte512Mask(res);
 707         }
 708 
 709         @Override
 710         Byte512Mask bOp(VectorMask<Byte> m, MBinOp f) {
 711             boolean[] res = new boolean[vspecies().laneCount()];
 712             boolean[] bits = getBits();
 713             boolean[] mbits = ((Byte512Mask)m).getBits();
 714             for (int i = 0; i < res.length; i++) {
 715                 res[i] = f.apply(i, bits[i], mbits[i]);
 716             }
 717             return new Byte512Mask(res);
 718         }
 719 
 720         @ForceInline
 721         @Override
 722         public final
 723         Byte512Vector toVector() {
 724             return (Byte512Vector) super.toVectorTemplate();  // specialize
 725         }
 726 
 727         /**
 728          * Helper function for lane-wise mask conversions.
 729          * This function kicks in after intrinsic failure.
 730          */
 731         @ForceInline
 732         private final <E>
 733         VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
 734             if (length() != dsp.laneCount())
 735                 throw new IllegalArgumentException("VectorMask length and species length differ");
 736             boolean[] maskArray = toArray();
 737             return  dsp.maskFactory(maskArray).check(dsp);
 738         }
 739 
 740         @Override
 741         @ForceInline
 742         public <E> VectorMask<E> cast(VectorSpecies<E> dsp) {
 743             AbstractSpecies<E> species = (AbstractSpecies<E>) dsp;
 744             if (length() != species.laneCount())
 745                 throw new IllegalArgumentException("VectorMask length and species length differ");
 746 
 747             return VectorSupport.convert(VectorSupport.VECTOR_OP_CAST,
 748                 this.getClass(), ETYPE, VLENGTH,
 749                 species.maskType(), species.elementType(), VLENGTH,
 750                 this, species,
 751                 (m, s) -> s.maskFactory(m.toArray()).check(s));
 752         }
 753 
 754         @Override
 755         @ForceInline
 756         public Byte512Mask eq(VectorMask<Byte> mask) {
 757             Objects.requireNonNull(mask);
 758             Byte512Mask m = (Byte512Mask)mask;
 759             return xor(m.not());
 760         }
 761 
 762         // Unary operations
 763 
 764         @Override
 765         @ForceInline
 766         public Byte512Mask not() {
 767             return xor(maskAll(true));
 768         }
 769 









 770         // Binary operations
 771 
 772         @Override
 773         @ForceInline
 774         public Byte512Mask and(VectorMask<Byte> mask) {
 775             Objects.requireNonNull(mask);
 776             Byte512Mask m = (Byte512Mask)mask;
 777             return VectorSupport.binaryOp(VECTOR_OP_AND, Byte512Mask.class, null, byte.class, VLENGTH,
 778                                           this, m, null,
 779                                           (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b));
 780         }
 781 
 782         @Override
 783         @ForceInline
 784         public Byte512Mask or(VectorMask<Byte> mask) {
 785             Objects.requireNonNull(mask);
 786             Byte512Mask m = (Byte512Mask)mask;
 787             return VectorSupport.binaryOp(VECTOR_OP_OR, Byte512Mask.class, null, byte.class, VLENGTH,
 788                                           this, m, null,
 789                                           (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b));
 790         }
 791 
 792         @ForceInline
 793         /* package-private */
 794         Byte512Mask xor(VectorMask<Byte> mask) {
 795             Objects.requireNonNull(mask);
 796             Byte512Mask m = (Byte512Mask)mask;
 797             return VectorSupport.binaryOp(VECTOR_OP_XOR, Byte512Mask.class, null, byte.class, VLENGTH,
 798                                           this, m, null,
 799                                           (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b));
 800         }
 801 
 802         // Mask Query operations
 803 
 804         @Override
 805         @ForceInline
 806         public int trueCount() {
 807             return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Byte512Mask.class, byte.class, VLENGTH, this,
 808                                                       (m) -> trueCountHelper(m.getBits()));
 809         }
 810 
 811         @Override
 812         @ForceInline
 813         public int firstTrue() {
 814             return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Byte512Mask.class, byte.class, VLENGTH, this,
 815                                                       (m) -> firstTrueHelper(m.getBits()));
 816         }
 817 
 818         @Override
 819         @ForceInline
 820         public int lastTrue() {
 821             return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Byte512Mask.class, byte.class, VLENGTH, this,
 822                                                       (m) -> lastTrueHelper(m.getBits()));
 823         }
 824 
 825         @Override
 826         @ForceInline
 827         public long toLong() {
 828             if (length() > Long.SIZE) {
 829                 throw new UnsupportedOperationException("too many lanes for one long");
 830             }
 831             return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Byte512Mask.class, byte.class, VLENGTH, this,
 832                                                       (m) -> toLongHelper(m.getBits()));
 833         }
 834 
 835         // Reductions
 836 
 837         @Override
 838         @ForceInline
 839         public boolean anyTrue() {
 840             return VectorSupport.test(BT_ne, Byte512Mask.class, byte.class, VLENGTH,
 841                                          this, vspecies().maskAll(true),
 842                                          (m, __) -> anyTrueHelper(((Byte512Mask)m).getBits()));
 843         }
 844 
 845         @Override
 846         @ForceInline
 847         public boolean allTrue() {
 848             return VectorSupport.test(BT_overflow, Byte512Mask.class, byte.class, VLENGTH,
 849                                          this, vspecies().maskAll(true),
 850                                          (m, __) -> allTrueHelper(((Byte512Mask)m).getBits()));
 851         }
 852 
 853         @ForceInline
 854         /*package-private*/
 855         static Byte512Mask maskAll(boolean bit) {
 856             return VectorSupport.broadcastCoerced(Byte512Mask.class, byte.class, VLENGTH,
 857                                                   (bit ? -1 : 0), null,
 858                                                   (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
 859         }
 860         private static final Byte512Mask  TRUE_MASK = new Byte512Mask(true);
 861         private static final Byte512Mask FALSE_MASK = new Byte512Mask(false);
 862 
 863     }
 864 
 865     // Shuffle
 866 
 867     static final class Byte512Shuffle extends AbstractShuffle<Byte> {
 868         static final int VLENGTH = VSPECIES.laneCount();    // used by the JVM
 869         static final Class<Byte> ETYPE = byte.class; // used by the JVM
 870 
 871         Byte512Shuffle(byte[] reorder) {
 872             super(VLENGTH, reorder);
 873         }
 874 
 875         public Byte512Shuffle(int[] reorder) {
 876             super(VLENGTH, reorder);
 877         }
 878 
 879         public Byte512Shuffle(int[] reorder, int i) {
 880             super(VLENGTH, reorder, i);
 881         }
 882 
 883         public Byte512Shuffle(IntUnaryOperator fn) {
 884             super(VLENGTH, fn);
 885         }
 886 
 887         @Override
 888         public ByteSpecies vspecies() {
 889             return VSPECIES;
 890         }
 891 
 892         static {
 893             // There must be enough bits in the shuffle lanes to encode
 894             // VLENGTH valid indexes and VLENGTH exceptional ones.
 895             assert(VLENGTH < Byte.MAX_VALUE);
 896             assert(Byte.MIN_VALUE <= -VLENGTH);
 897         }
 898         static final Byte512Shuffle IOTA = new Byte512Shuffle(IDENTITY);
 899 
 900         @Override
 901         @ForceInline
 902         public Byte512Vector toVector() {
 903             return VectorSupport.shuffleToVector(VCLASS, ETYPE, Byte512Shuffle.class, this, VLENGTH,
 904                                                     (s) -> ((Byte512Vector)(((AbstractShuffle<Byte>)(s)).toVectorTemplate())));
 905         }
 906 
 907         @Override
 908         @ForceInline
 909         public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
 910             AbstractSpecies<F> species = (AbstractSpecies<F>) s;
 911             if (length() != species.laneCount())
 912                 throw new IllegalArgumentException("VectorShuffle length and species length differ");
 913             int[] shuffleArray = toArray();
 914             return s.shuffleFromArray(shuffleArray, 0).check(s);
 915         }
 916 
 917         @ForceInline
 918         @Override
 919         public Byte512Shuffle rearrange(VectorShuffle<Byte> shuffle) {
 920             Byte512Shuffle s = (Byte512Shuffle) shuffle;
 921             byte[] reorder1 = reorder();
 922             byte[] reorder2 = s.reorder();
 923             byte[] r = new byte[reorder1.length];
 924             for (int i = 0; i < reorder1.length; i++) {
 925                 int ssi = reorder2[i];
 926                 r[i] = reorder1[ssi];  // throws on exceptional index
 927             }
 928             return new Byte512Shuffle(r);
 929         }
 930     }
 931 
 932     // ================================================
 933 
 934     // Specialized low-level memory operations.
 935 
 936     @ForceInline
 937     @Override
 938     final
 939     ByteVector fromArray0(byte[] a, int offset) {
 940         return super.fromArray0Template(a, offset);  // specialize
 941     }
 942 
 943     @ForceInline
 944     @Override
 945     final
 946     ByteVector fromArray0(byte[] a, int offset, VectorMask<Byte> m) {
 947         return super.fromArray0Template(Byte512Mask.class, a, offset, (Byte512Mask) m);  // specialize
 948     }
 949 
 950 
 951 
 952     @ForceInline
 953     @Override
 954     final
 955     ByteVector fromBooleanArray0(boolean[] a, int offset) {
 956         return super.fromBooleanArray0Template(a, offset);  // specialize
 957     }
 958 
 959     @ForceInline
 960     @Override
 961     final
 962     ByteVector fromBooleanArray0(boolean[] a, int offset, VectorMask<Byte> m) {
 963         return super.fromBooleanArray0Template(Byte512Mask.class, a, offset, (Byte512Mask) m);  // specialize
 964     }
 965 
 966     @ForceInline
 967     @Override
 968     final
 969     ByteVector fromByteArray0(byte[] a, int offset) {
 970         return super.fromByteArray0Template(a, offset);  // specialize
 971     }
 972 
 973     @ForceInline
 974     @Override
 975     final
 976     ByteVector fromByteArray0(byte[] a, int offset, VectorMask<Byte> m) {
 977         return super.fromByteArray0Template(Byte512Mask.class, a, offset, (Byte512Mask) m);  // specialize
 978     }
 979 
 980     @ForceInline
 981     @Override
 982     final
 983     ByteVector fromByteBuffer0(ByteBuffer bb, int offset) {
 984         return super.fromByteBuffer0Template(bb, offset);  // specialize
 985     }
 986 
 987     @ForceInline
 988     @Override
 989     final
 990     ByteVector fromByteBuffer0(ByteBuffer bb, int offset, VectorMask<Byte> m) {
 991         return super.fromByteBuffer0Template(Byte512Mask.class, bb, offset, (Byte512Mask) m);  // specialize
 992     }
 993 
 994     @ForceInline
 995     @Override
 996     final
 997     void intoArray0(byte[] a, int offset) {
 998         super.intoArray0Template(a, offset);  // specialize
 999     }
1000 
1001     @ForceInline
1002     @Override
1003     final
1004     void intoArray0(byte[] a, int offset, VectorMask<Byte> m) {
1005         super.intoArray0Template(Byte512Mask.class, a, offset, (Byte512Mask) m);
1006     }
1007 
1008 
1009     @ForceInline
1010     @Override
1011     final
1012     void intoBooleanArray0(boolean[] a, int offset, VectorMask<Byte> m) {
1013         super.intoBooleanArray0Template(Byte512Mask.class, a, offset, (Byte512Mask) m);
1014     }
1015 
1016     @ForceInline
1017     @Override
1018     final
1019     void intoByteArray0(byte[] a, int offset) {
1020         super.intoByteArray0Template(a, offset);  // specialize
1021     }
1022 
1023     @ForceInline
1024     @Override
1025     final
1026     void intoByteArray0(byte[] a, int offset, VectorMask<Byte> m) {
1027         super.intoByteArray0Template(Byte512Mask.class, a, offset, (Byte512Mask) m);  // specialize
1028     }
1029 
1030     @ForceInline
1031     @Override
1032     final
1033     void intoByteBuffer0(ByteBuffer bb, int offset, VectorMask<Byte> m) {
1034         super.intoByteBuffer0Template(Byte512Mask.class, bb, offset, (Byte512Mask) m);
1035     }
1036 
1037 
1038     // End of specialized low-level memory operations.
1039 
1040     // ================================================
1041 
1042 }
--- EOF ---