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 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     @Override
 374     @ForceInline
 375     public final Byte512Mask test(Test op, VectorMask<Byte> m) {
 376         return super.testTemplate(Byte512Mask.class, op, (Byte512Mask) m);  // specialize
 377     }
 378 
 379     // Specialized comparisons
 380 
 381     @Override
 382     @ForceInline
 383     public final Byte512Mask compare(Comparison op, Vector<Byte> v) {
 384         return super.compareTemplate(Byte512Mask.class, op, v);  // specialize
 385     }
 386 
 387     @Override
 388     @ForceInline
 389     public final Byte512Mask compare(Comparison op, byte s) {
 390         return super.compareTemplate(Byte512Mask.class, op, s);  // specialize
 391     }
 392 
 393     @Override
 394     @ForceInline
 395     public final Byte512Mask compare(Comparison op, long s) {
 396         return super.compareTemplate(Byte512Mask.class, op, s);  // specialize
 397     }
 398 
 399     @Override
 400     @ForceInline
 401     public final Byte512Mask compare(Comparison op, Vector<Byte> v, VectorMask<Byte> m) {
 402         return super.compareTemplate(Byte512Mask.class, op, v, (Byte512Mask) m);
 403     }
 404 
 405 
 406     @Override
 407     @ForceInline
 408     public Byte512Vector blend(Vector<Byte> v, VectorMask<Byte> m) {
 409         return (Byte512Vector)
 410             super.blendTemplate(Byte512Mask.class,
 411                                 (Byte512Vector) v,
 412                                 (Byte512Mask) m);  // specialize
 413     }
 414 
 415     @Override
 416     @ForceInline
 417     public Byte512Vector slice(int origin, Vector<Byte> v) {
 418         return (Byte512Vector) super.sliceTemplate(origin, v);  // specialize
 419     }
 420 
 421     @Override
 422     @ForceInline
 423     public Byte512Vector slice(int origin) {
 424         return (Byte512Vector) super.sliceTemplate(origin);  // specialize
 425     }
 426 
 427     @Override
 428     @ForceInline
 429     public Byte512Vector unslice(int origin, Vector<Byte> w, int part) {
 430         return (Byte512Vector) super.unsliceTemplate(origin, w, part);  // specialize
 431     }
 432 
 433     @Override
 434     @ForceInline
 435     public Byte512Vector unslice(int origin, Vector<Byte> w, int part, VectorMask<Byte> m) {
 436         return (Byte512Vector)
 437             super.unsliceTemplate(Byte512Mask.class,
 438                                   origin, w, part,
 439                                   (Byte512Mask) m);  // specialize
 440     }
 441 
 442     @Override
 443     @ForceInline
 444     public Byte512Vector unslice(int origin) {
 445         return (Byte512Vector) super.unsliceTemplate(origin);  // specialize
 446     }
 447 
 448     @Override
 449     @ForceInline
 450     public Byte512Vector rearrange(VectorShuffle<Byte> s) {
 451         return (Byte512Vector)
 452             super.rearrangeTemplate(Byte512Shuffle.class,
 453                                     (Byte512Shuffle) s);  // specialize
 454     }
 455 
 456     @Override
 457     @ForceInline
 458     public Byte512Vector rearrange(VectorShuffle<Byte> shuffle,
 459                                   VectorMask<Byte> m) {
 460         return (Byte512Vector)
 461             super.rearrangeTemplate(Byte512Shuffle.class,
 462                                     Byte512Mask.class,
 463                                     (Byte512Shuffle) shuffle,
 464                                     (Byte512Mask) m);  // specialize
 465     }
 466 
 467     @Override
 468     @ForceInline
 469     public Byte512Vector rearrange(VectorShuffle<Byte> s,
 470                                   Vector<Byte> v) {
 471         return (Byte512Vector)
 472             super.rearrangeTemplate(Byte512Shuffle.class,
 473                                     (Byte512Shuffle) s,
 474                                     (Byte512Vector) v);  // specialize
 475     }
 476 
 477     @Override
 478     @ForceInline
 479     public Byte512Vector selectFrom(Vector<Byte> v) {
 480         return (Byte512Vector)
 481             super.selectFromTemplate((Byte512Vector) v);  // specialize
 482     }
 483 
 484     @Override
 485     @ForceInline
 486     public Byte512Vector selectFrom(Vector<Byte> v,
 487                                    VectorMask<Byte> m) {
 488         return (Byte512Vector)
 489             super.selectFromTemplate((Byte512Vector) v,
 490                                      (Byte512Mask) m);  // specialize
 491     }
 492 
 493 
 494     @ForceInline
 495     @Override
 496     public byte lane(int i) {
 497         switch(i) {
 498             case 0: return laneHelper(0);
 499             case 1: return laneHelper(1);
 500             case 2: return laneHelper(2);
 501             case 3: return laneHelper(3);
 502             case 4: return laneHelper(4);
 503             case 5: return laneHelper(5);
 504             case 6: return laneHelper(6);
 505             case 7: return laneHelper(7);
 506             case 8: return laneHelper(8);
 507             case 9: return laneHelper(9);
 508             case 10: return laneHelper(10);
 509             case 11: return laneHelper(11);
 510             case 12: return laneHelper(12);
 511             case 13: return laneHelper(13);
 512             case 14: return laneHelper(14);
 513             case 15: return laneHelper(15);
 514             case 16: return laneHelper(16);
 515             case 17: return laneHelper(17);
 516             case 18: return laneHelper(18);
 517             case 19: return laneHelper(19);
 518             case 20: return laneHelper(20);
 519             case 21: return laneHelper(21);
 520             case 22: return laneHelper(22);
 521             case 23: return laneHelper(23);
 522             case 24: return laneHelper(24);
 523             case 25: return laneHelper(25);
 524             case 26: return laneHelper(26);
 525             case 27: return laneHelper(27);
 526             case 28: return laneHelper(28);
 527             case 29: return laneHelper(29);
 528             case 30: return laneHelper(30);
 529             case 31: return laneHelper(31);
 530             case 32: return laneHelper(32);
 531             case 33: return laneHelper(33);
 532             case 34: return laneHelper(34);
 533             case 35: return laneHelper(35);
 534             case 36: return laneHelper(36);
 535             case 37: return laneHelper(37);
 536             case 38: return laneHelper(38);
 537             case 39: return laneHelper(39);
 538             case 40: return laneHelper(40);
 539             case 41: return laneHelper(41);
 540             case 42: return laneHelper(42);
 541             case 43: return laneHelper(43);
 542             case 44: return laneHelper(44);
 543             case 45: return laneHelper(45);
 544             case 46: return laneHelper(46);
 545             case 47: return laneHelper(47);
 546             case 48: return laneHelper(48);
 547             case 49: return laneHelper(49);
 548             case 50: return laneHelper(50);
 549             case 51: return laneHelper(51);
 550             case 52: return laneHelper(52);
 551             case 53: return laneHelper(53);
 552             case 54: return laneHelper(54);
 553             case 55: return laneHelper(55);
 554             case 56: return laneHelper(56);
 555             case 57: return laneHelper(57);
 556             case 58: return laneHelper(58);
 557             case 59: return laneHelper(59);
 558             case 60: return laneHelper(60);
 559             case 61: return laneHelper(61);
 560             case 62: return laneHelper(62);
 561             case 63: return laneHelper(63);
 562             default: throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH);
 563         }
 564     }
 565 
 566     public byte laneHelper(int i) {
 567         return (byte) VectorSupport.extract(
 568                                 VCLASS, ETYPE, VLENGTH,
 569                                 this, i,
 570                                 (vec, ix) -> {
 571                                     byte[] vecarr = vec.vec();
 572                                     return (long)vecarr[ix];
 573                                 });
 574     }
 575 
 576     @ForceInline
 577     @Override
 578     public Byte512Vector withLane(int i, byte e) {
 579         switch (i) {
 580             case 0: return withLaneHelper(0, e);
 581             case 1: return withLaneHelper(1, e);
 582             case 2: return withLaneHelper(2, e);
 583             case 3: return withLaneHelper(3, e);
 584             case 4: return withLaneHelper(4, e);
 585             case 5: return withLaneHelper(5, e);
 586             case 6: return withLaneHelper(6, e);
 587             case 7: return withLaneHelper(7, e);
 588             case 8: return withLaneHelper(8, e);
 589             case 9: return withLaneHelper(9, e);
 590             case 10: return withLaneHelper(10, e);
 591             case 11: return withLaneHelper(11, e);
 592             case 12: return withLaneHelper(12, e);
 593             case 13: return withLaneHelper(13, e);
 594             case 14: return withLaneHelper(14, e);
 595             case 15: return withLaneHelper(15, e);
 596             case 16: return withLaneHelper(16, e);
 597             case 17: return withLaneHelper(17, e);
 598             case 18: return withLaneHelper(18, e);
 599             case 19: return withLaneHelper(19, e);
 600             case 20: return withLaneHelper(20, e);
 601             case 21: return withLaneHelper(21, e);
 602             case 22: return withLaneHelper(22, e);
 603             case 23: return withLaneHelper(23, e);
 604             case 24: return withLaneHelper(24, e);
 605             case 25: return withLaneHelper(25, e);
 606             case 26: return withLaneHelper(26, e);
 607             case 27: return withLaneHelper(27, e);
 608             case 28: return withLaneHelper(28, e);
 609             case 29: return withLaneHelper(29, e);
 610             case 30: return withLaneHelper(30, e);
 611             case 31: return withLaneHelper(31, e);
 612             case 32: return withLaneHelper(32, e);
 613             case 33: return withLaneHelper(33, e);
 614             case 34: return withLaneHelper(34, e);
 615             case 35: return withLaneHelper(35, e);
 616             case 36: return withLaneHelper(36, e);
 617             case 37: return withLaneHelper(37, e);
 618             case 38: return withLaneHelper(38, e);
 619             case 39: return withLaneHelper(39, e);
 620             case 40: return withLaneHelper(40, e);
 621             case 41: return withLaneHelper(41, e);
 622             case 42: return withLaneHelper(42, e);
 623             case 43: return withLaneHelper(43, e);
 624             case 44: return withLaneHelper(44, e);
 625             case 45: return withLaneHelper(45, e);
 626             case 46: return withLaneHelper(46, e);
 627             case 47: return withLaneHelper(47, e);
 628             case 48: return withLaneHelper(48, e);
 629             case 49: return withLaneHelper(49, e);
 630             case 50: return withLaneHelper(50, e);
 631             case 51: return withLaneHelper(51, e);
 632             case 52: return withLaneHelper(52, e);
 633             case 53: return withLaneHelper(53, e);
 634             case 54: return withLaneHelper(54, e);
 635             case 55: return withLaneHelper(55, e);
 636             case 56: return withLaneHelper(56, e);
 637             case 57: return withLaneHelper(57, e);
 638             case 58: return withLaneHelper(58, e);
 639             case 59: return withLaneHelper(59, e);
 640             case 60: return withLaneHelper(60, e);
 641             case 61: return withLaneHelper(61, e);
 642             case 62: return withLaneHelper(62, e);
 643             case 63: return withLaneHelper(63, e);
 644             default: throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH);
 645         }
 646     }
 647 
 648     public Byte512Vector withLaneHelper(int i, byte e) {
 649         return VectorSupport.insert(
 650                                 VCLASS, ETYPE, VLENGTH,
 651                                 this, i, (long)e,
 652                                 (v, ix, bits) -> {
 653                                     byte[] res = v.vec().clone();
 654                                     res[ix] = (byte)bits;
 655                                     return v.vectorFactory(res);
 656                                 });
 657     }
 658 
 659     // Mask
 660 
 661     static final class Byte512Mask extends AbstractMask<Byte> {
 662         static final int VLENGTH = VSPECIES.laneCount();    // used by the JVM
 663         static final Class<Byte> ETYPE = byte.class; // used by the JVM
 664 
 665         Byte512Mask(boolean[] bits) {
 666             this(bits, 0);
 667         }
 668 
 669         Byte512Mask(boolean[] bits, int offset) {
 670             super(prepare(bits, offset));
 671         }
 672 
 673         Byte512Mask(boolean val) {
 674             super(prepare(val));
 675         }
 676 
 677         private static boolean[] prepare(boolean[] bits, int offset) {
 678             boolean[] newBits = new boolean[VSPECIES.laneCount()];
 679             for (int i = 0; i < newBits.length; i++) {
 680                 newBits[i] = bits[offset + i];
 681             }
 682             return newBits;
 683         }
 684 
 685         private static boolean[] prepare(boolean val) {
 686             boolean[] bits = new boolean[VSPECIES.laneCount()];
 687             Arrays.fill(bits, val);
 688             return bits;
 689         }
 690 
 691         @ForceInline
 692         final @Override
 693         public ByteSpecies vspecies() {
 694             // ISSUE:  This should probably be a @Stable
 695             // field inside AbstractMask, rather than
 696             // a megamorphic method.
 697             return VSPECIES;
 698         }
 699 
 700         @ForceInline
 701         boolean[] getBits() {
 702             return (boolean[])getPayload();
 703         }
 704 
 705         @Override
 706         Byte512Mask uOp(MUnOp f) {
 707             boolean[] res = new boolean[vspecies().laneCount()];
 708             boolean[] bits = getBits();
 709             for (int i = 0; i < res.length; i++) {
 710                 res[i] = f.apply(i, bits[i]);
 711             }
 712             return new Byte512Mask(res);
 713         }
 714 
 715         @Override
 716         Byte512Mask bOp(VectorMask<Byte> m, MBinOp f) {
 717             boolean[] res = new boolean[vspecies().laneCount()];
 718             boolean[] bits = getBits();
 719             boolean[] mbits = ((Byte512Mask)m).getBits();
 720             for (int i = 0; i < res.length; i++) {
 721                 res[i] = f.apply(i, bits[i], mbits[i]);
 722             }
 723             return new Byte512Mask(res);
 724         }
 725 
 726         @ForceInline
 727         @Override
 728         public final
 729         Byte512Vector toVector() {
 730             return (Byte512Vector) super.toVectorTemplate();  // specialize
 731         }
 732 
 733         /**
 734          * Helper function for lane-wise mask conversions.
 735          * This function kicks in after intrinsic failure.
 736          */
 737         @ForceInline
 738         private final <E>
 739         VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
 740             if (length() != dsp.laneCount())
 741                 throw new IllegalArgumentException("VectorMask length and species length differ");
 742             boolean[] maskArray = toArray();
 743             return  dsp.maskFactory(maskArray).check(dsp);
 744         }
 745 
 746         @Override
 747         @ForceInline
 748         public <E> VectorMask<E> cast(VectorSpecies<E> dsp) {
 749             AbstractSpecies<E> species = (AbstractSpecies<E>) dsp;
 750             if (length() != species.laneCount())
 751                 throw new IllegalArgumentException("VectorMask length and species length differ");
 752 
 753             return VectorSupport.convert(VectorSupport.VECTOR_OP_CAST,
 754                 this.getClass(), ETYPE, VLENGTH,
 755                 species.maskType(), species.elementType(), VLENGTH,
 756                 this, species,
 757                 (m, s) -> s.maskFactory(m.toArray()).check(s));
 758         }
 759 
 760         @Override
 761         @ForceInline
 762         public Byte512Mask eq(VectorMask<Byte> mask) {
 763             Objects.requireNonNull(mask);
 764             Byte512Mask m = (Byte512Mask)mask;
 765             return xor(m.not());
 766         }
 767 
 768         // Unary operations
 769 
 770         @Override
 771         @ForceInline
 772         public Byte512Mask not() {
 773             return xor(maskAll(true));
 774         }
 775 
 776         // Binary operations
 777 
 778         @Override
 779         @ForceInline
 780         public Byte512Mask and(VectorMask<Byte> mask) {
 781             Objects.requireNonNull(mask);
 782             Byte512Mask m = (Byte512Mask)mask;
 783             return VectorSupport.binaryOp(VECTOR_OP_AND, Byte512Mask.class, null, byte.class, VLENGTH,
 784                                           this, m, null,
 785                                           (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b));
 786         }
 787 
 788         @Override
 789         @ForceInline
 790         public Byte512Mask or(VectorMask<Byte> mask) {
 791             Objects.requireNonNull(mask);
 792             Byte512Mask m = (Byte512Mask)mask;
 793             return VectorSupport.binaryOp(VECTOR_OP_OR, Byte512Mask.class, null, byte.class, VLENGTH,
 794                                           this, m, null,
 795                                           (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b));
 796         }
 797 
 798         @ForceInline
 799         /* package-private */
 800         Byte512Mask xor(VectorMask<Byte> mask) {
 801             Objects.requireNonNull(mask);
 802             Byte512Mask m = (Byte512Mask)mask;
 803             return VectorSupport.binaryOp(VECTOR_OP_XOR, Byte512Mask.class, null, byte.class, VLENGTH,
 804                                           this, m, null,
 805                                           (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b));
 806         }
 807 
 808         // Mask Query operations
 809 
 810         @Override
 811         @ForceInline
 812         public int trueCount() {
 813             return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Byte512Mask.class, byte.class, VLENGTH, this,
 814                                                       (m) -> trueCountHelper(m.getBits()));
 815         }
 816 
 817         @Override
 818         @ForceInline
 819         public int firstTrue() {
 820             return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Byte512Mask.class, byte.class, VLENGTH, this,
 821                                                       (m) -> firstTrueHelper(m.getBits()));
 822         }
 823 
 824         @Override
 825         @ForceInline
 826         public int lastTrue() {
 827             return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Byte512Mask.class, byte.class, VLENGTH, this,
 828                                                       (m) -> lastTrueHelper(m.getBits()));
 829         }
 830 
 831         @Override
 832         @ForceInline
 833         public long toLong() {
 834             if (length() > Long.SIZE) {
 835                 throw new UnsupportedOperationException("too many lanes for one long");
 836             }
 837             return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Byte512Mask.class, byte.class, VLENGTH, this,
 838                                                       (m) -> toLongHelper(m.getBits()));
 839         }
 840 
 841         // Reductions
 842 
 843         @Override
 844         @ForceInline
 845         public boolean anyTrue() {
 846             return VectorSupport.test(BT_ne, Byte512Mask.class, byte.class, VLENGTH,
 847                                          this, vspecies().maskAll(true),
 848                                          (m, __) -> anyTrueHelper(((Byte512Mask)m).getBits()));
 849         }
 850 
 851         @Override
 852         @ForceInline
 853         public boolean allTrue() {
 854             return VectorSupport.test(BT_overflow, Byte512Mask.class, byte.class, VLENGTH,
 855                                          this, vspecies().maskAll(true),
 856                                          (m, __) -> allTrueHelper(((Byte512Mask)m).getBits()));
 857         }
 858 
 859         @ForceInline
 860         /*package-private*/
 861         static Byte512Mask maskAll(boolean bit) {
 862             return VectorSupport.fromBitsCoerced(Byte512Mask.class, byte.class, VLENGTH,
 863                                                  (bit ? -1 : 0), MODE_BROADCAST, null,
 864                                                  (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
 865         }
 866         private static final Byte512Mask  TRUE_MASK = new Byte512Mask(true);
 867         private static final Byte512Mask FALSE_MASK = new Byte512Mask(false);
 868 
 869     }
 870 
 871     // Shuffle
 872 
 873     static final class Byte512Shuffle extends AbstractShuffle<Byte> {
 874         static final int VLENGTH = VSPECIES.laneCount();    // used by the JVM
 875         static final Class<Byte> ETYPE = byte.class; // used by the JVM
 876 
 877         Byte512Shuffle(byte[] reorder) {
 878             super(VLENGTH, reorder);
 879         }
 880 
 881         public Byte512Shuffle(int[] reorder) {
 882             super(VLENGTH, reorder);
 883         }
 884 
 885         public Byte512Shuffle(int[] reorder, int i) {
 886             super(VLENGTH, reorder, i);
 887         }
 888 
 889         public Byte512Shuffle(IntUnaryOperator fn) {
 890             super(VLENGTH, fn);
 891         }
 892 
 893         @Override
 894         public ByteSpecies vspecies() {
 895             return VSPECIES;
 896         }
 897 
 898         static {
 899             // There must be enough bits in the shuffle lanes to encode
 900             // VLENGTH valid indexes and VLENGTH exceptional ones.
 901             assert(VLENGTH < Byte.MAX_VALUE);
 902             assert(Byte.MIN_VALUE <= -VLENGTH);
 903         }
 904         static final Byte512Shuffle IOTA = new Byte512Shuffle(IDENTITY);
 905 
 906         @Override
 907         @ForceInline
 908         public Byte512Vector toVector() {
 909             return VectorSupport.shuffleToVector(VCLASS, ETYPE, Byte512Shuffle.class, this, VLENGTH,
 910                                                     (s) -> ((Byte512Vector)(((AbstractShuffle<Byte>)(s)).toVectorTemplate())));
 911         }
 912 
 913         @Override
 914         @ForceInline
 915         public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
 916             AbstractSpecies<F> species = (AbstractSpecies<F>) s;
 917             if (length() != species.laneCount())
 918                 throw new IllegalArgumentException("VectorShuffle length and species length differ");
 919             int[] shuffleArray = toArray();
 920             return s.shuffleFromArray(shuffleArray, 0).check(s);
 921         }
 922 
 923         @ForceInline
 924         @Override
 925         public Byte512Shuffle rearrange(VectorShuffle<Byte> shuffle) {
 926             Byte512Shuffle s = (Byte512Shuffle) shuffle;
 927             byte[] reorder1 = reorder();
 928             byte[] reorder2 = s.reorder();
 929             byte[] r = new byte[reorder1.length];
 930             for (int i = 0; i < reorder1.length; i++) {
 931                 int ssi = reorder2[i];
 932                 r[i] = reorder1[ssi];  // throws on exceptional index
 933             }
 934             return new Byte512Shuffle(r);
 935         }
 936     }
 937 
 938     // ================================================
 939 
 940     // Specialized low-level memory operations.
 941 
 942     @ForceInline
 943     @Override
 944     final
 945     ByteVector fromArray0(byte[] a, int offset) {
 946         return super.fromArray0Template(a, offset);  // specialize
 947     }
 948 
 949     @ForceInline
 950     @Override
 951     final
 952     ByteVector fromArray0(byte[] a, int offset, VectorMask<Byte> m) {
 953         return super.fromArray0Template(Byte512Mask.class, a, offset, (Byte512Mask) m);  // specialize
 954     }
 955 
 956 
 957 
 958     @ForceInline
 959     @Override
 960     final
 961     ByteVector fromBooleanArray0(boolean[] a, int offset) {
 962         return super.fromBooleanArray0Template(a, offset);  // specialize
 963     }
 964 
 965     @ForceInline
 966     @Override
 967     final
 968     ByteVector fromBooleanArray0(boolean[] a, int offset, VectorMask<Byte> m) {
 969         return super.fromBooleanArray0Template(Byte512Mask.class, a, offset, (Byte512Mask) m);  // specialize
 970     }
 971 
 972     @ForceInline
 973     @Override
 974     final
 975     ByteVector fromByteArray0(byte[] a, int offset) {
 976         return super.fromByteArray0Template(a, offset);  // specialize
 977     }
 978 
 979     @ForceInline
 980     @Override
 981     final
 982     ByteVector fromByteArray0(byte[] a, int offset, VectorMask<Byte> m) {
 983         return super.fromByteArray0Template(Byte512Mask.class, a, offset, (Byte512Mask) m);  // specialize
 984     }
 985 
 986     @ForceInline
 987     @Override
 988     final
 989     ByteVector fromByteBuffer0(ByteBuffer bb, int offset) {
 990         return super.fromByteBuffer0Template(bb, offset);  // specialize
 991     }
 992 
 993     @ForceInline
 994     @Override
 995     final
 996     ByteVector fromByteBuffer0(ByteBuffer bb, int offset, VectorMask<Byte> m) {
 997         return super.fromByteBuffer0Template(Byte512Mask.class, bb, offset, (Byte512Mask) m);  // specialize
 998     }
 999 
1000     @ForceInline
1001     @Override
1002     final
1003     void intoArray0(byte[] a, int offset) {
1004         super.intoArray0Template(a, offset);  // specialize
1005     }
1006 
1007     @ForceInline
1008     @Override
1009     final
1010     void intoArray0(byte[] a, int offset, VectorMask<Byte> m) {
1011         super.intoArray0Template(Byte512Mask.class, a, offset, (Byte512Mask) m);
1012     }
1013 
1014 
1015     @ForceInline
1016     @Override
1017     final
1018     void intoBooleanArray0(boolean[] a, int offset, VectorMask<Byte> m) {
1019         super.intoBooleanArray0Template(Byte512Mask.class, a, offset, (Byte512Mask) m);
1020     }
1021 
1022     @ForceInline
1023     @Override
1024     final
1025     void intoByteArray0(byte[] a, int offset) {
1026         super.intoByteArray0Template(a, offset);  // specialize
1027     }
1028 
1029     @ForceInline
1030     @Override
1031     final
1032     void intoByteArray0(byte[] a, int offset, VectorMask<Byte> m) {
1033         super.intoByteArray0Template(Byte512Mask.class, a, offset, (Byte512Mask) m);  // specialize
1034     }
1035 
1036     @ForceInline
1037     @Override
1038     final
1039     void intoByteBuffer0(ByteBuffer bb, int offset, VectorMask<Byte> m) {
1040         super.intoByteBuffer0Template(Byte512Mask.class, bb, offset, (Byte512Mask) m);
1041     }
1042 
1043 
1044     // End of specialized low-level memory operations.
1045 
1046     // ================================================
1047 
1048 }