1 /* 2 * Copyright (c) 2017, 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 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 jdk.internal.vm.annotation.ForceInline; 31 import static jdk.incubator.vector.VectorIntrinsics.*; 32 33 @SuppressWarnings("cast") 34 final class Byte64Vector extends ByteVector<Shapes.S64Bit> { 35 static final Byte64Species SPECIES = new Byte64Species(); 36 37 static final Byte64Vector ZERO = new Byte64Vector(); 38 39 static final int LENGTH = SPECIES.length(); 40 41 private final byte[] vec; // Don't access directly, use getElements() instead. 42 43 private byte[] getElements() { 44 return VectorIntrinsics.maybeRebox(this).vec; 45 } 46 47 Byte64Vector() { 48 vec = new byte[SPECIES.length()]; 49 } 50 51 Byte64Vector(byte[] v) { 52 vec = v; 53 } 54 55 @Override 56 public int length() { return LENGTH; } 57 58 // Unary operator 59 60 @Override 61 Byte64Vector uOp(FUnOp f) { 62 byte[] vec = getElements(); 63 byte[] res = new byte[length()]; 64 for (int i = 0; i < length(); i++) { 65 res[i] = f.apply(i, vec[i]); 66 } 67 return new Byte64Vector(res); 68 } 69 70 @Override 71 Byte64Vector uOp(Mask<Byte, Shapes.S64Bit> o, FUnOp f) { 72 byte[] vec = getElements(); 73 byte[] res = new byte[length()]; 74 boolean[] mbits = ((Byte64Mask)o).getBits(); 75 for (int i = 0; i < length(); i++) { 76 res[i] = mbits[i] ? f.apply(i, vec[i]) : vec[i]; 77 } 78 return new Byte64Vector(res); 79 } 80 81 // Binary operator 82 83 @Override 84 Byte64Vector bOp(Vector<Byte, Shapes.S64Bit> o, FBinOp f) { 85 byte[] res = new byte[length()]; 86 byte[] vec1 = this.getElements(); 87 byte[] vec2 = ((Byte64Vector)o).getElements(); 88 for (int i = 0; i < length(); i++) { 89 res[i] = f.apply(i, vec1[i], vec2[i]); 90 } 91 return new Byte64Vector(res); 92 } 93 94 @Override 95 Byte64Vector bOp(Vector<Byte, Shapes.S64Bit> o1, Mask<Byte, Shapes.S64Bit> o2, FBinOp f) { 96 byte[] res = new byte[length()]; 97 byte[] vec1 = this.getElements(); 98 byte[] vec2 = ((Byte64Vector)o1).getElements(); 99 boolean[] mbits = ((Byte64Mask)o2).getBits(); 100 for (int i = 0; i < length(); i++) { 101 res[i] = mbits[i] ? f.apply(i, vec1[i], vec2[i]) : vec1[i]; 102 } 103 return new Byte64Vector(res); 104 } 105 106 // Trinary operator 107 108 @Override 109 Byte64Vector tOp(Vector<Byte, Shapes.S64Bit> o1, Vector<Byte, Shapes.S64Bit> o2, FTriOp f) { 110 byte[] res = new byte[length()]; 111 byte[] vec1 = this.getElements(); 112 byte[] vec2 = ((Byte64Vector)o1).getElements(); 113 byte[] vec3 = ((Byte64Vector)o2).getElements(); 114 for (int i = 0; i < length(); i++) { 115 res[i] = f.apply(i, vec1[i], vec2[i], vec3[i]); 116 } 117 return new Byte64Vector(res); 118 } 119 120 @Override 121 Byte64Vector tOp(Vector<Byte, Shapes.S64Bit> o1, Vector<Byte, Shapes.S64Bit> o2, Mask<Byte, Shapes.S64Bit> o3, FTriOp f) { 122 byte[] res = new byte[length()]; 123 byte[] vec1 = getElements(); 124 byte[] vec2 = ((Byte64Vector)o1).getElements(); 125 byte[] vec3 = ((Byte64Vector)o2).getElements(); 126 boolean[] mbits = ((Byte64Mask)o3).getBits(); 127 for (int i = 0; i < length(); i++) { 128 res[i] = mbits[i] ? f.apply(i, vec1[i], vec2[i], vec3[i]) : vec1[i]; 129 } 130 return new Byte64Vector(res); 131 } 132 133 @Override 134 byte rOp(byte v, FBinOp f) { 135 byte[] vec = getElements(); 136 for (int i = 0; i < length(); i++) { 137 v = f.apply(i, v, vec[i]); 138 } 139 return v; 140 } 141 142 // Binary operations with scalars 143 144 @Override 145 @ForceInline 146 public ByteVector<Shapes.S64Bit> add(byte o) { 147 return add(SPECIES.broadcast(o)); 148 } 149 150 @Override 151 @ForceInline 152 public ByteVector<Shapes.S64Bit> add(byte o, Mask<Byte,Shapes.S64Bit> m) { 153 return add(SPECIES.broadcast(o), m); 154 } 155 156 @Override 157 @ForceInline 158 public ByteVector<Shapes.S64Bit> addSaturate(byte o) { 159 return addSaturate(SPECIES.broadcast(o)); 160 } 161 162 @Override 163 @ForceInline 164 public ByteVector<Shapes.S64Bit> addSaturate(byte o, Mask<Byte,Shapes.S64Bit> m) { 165 return addSaturate(SPECIES.broadcast(o), m); 166 } 167 168 @Override 169 @ForceInline 170 public ByteVector<Shapes.S64Bit> sub(byte o) { 171 return sub(SPECIES.broadcast(o)); 172 } 173 174 @Override 175 @ForceInline 176 public ByteVector<Shapes.S64Bit> sub(byte o, Mask<Byte,Shapes.S64Bit> m) { 177 return sub(SPECIES.broadcast(o), m); 178 } 179 180 @Override 181 @ForceInline 182 public ByteVector<Shapes.S64Bit> subSaturate(byte o) { 183 return subSaturate(SPECIES.broadcast(o)); 184 } 185 186 @Override 187 @ForceInline 188 public ByteVector<Shapes.S64Bit> subSaturate(byte o, Mask<Byte,Shapes.S64Bit> m) { 189 return subSaturate(SPECIES.broadcast(o), m); 190 } 191 192 @Override 193 @ForceInline 194 public ByteVector<Shapes.S64Bit> mul(byte o) { 195 return mul(SPECIES.broadcast(o)); 196 } 197 198 @Override 199 @ForceInline 200 public ByteVector<Shapes.S64Bit> mul(byte o, Mask<Byte,Shapes.S64Bit> m) { 201 return mul(SPECIES.broadcast(o), m); 202 } 203 204 @Override 205 @ForceInline 206 public ByteVector<Shapes.S64Bit> min(byte o) { 207 return min(SPECIES.broadcast(o)); 208 } 209 210 @Override 211 @ForceInline 212 public ByteVector<Shapes.S64Bit> max(byte o) { 213 return max(SPECIES.broadcast(o)); 214 } 215 216 @Override 217 @ForceInline 218 public Mask<Byte, Shapes.S64Bit> equal(byte o) { 219 return equal(SPECIES.broadcast(o)); 220 } 221 222 @Override 223 @ForceInline 224 public Mask<Byte, Shapes.S64Bit> notEqual(byte o) { 225 return notEqual(SPECIES.broadcast(o)); 226 } 227 228 @Override 229 @ForceInline 230 public Mask<Byte, Shapes.S64Bit> lessThan(byte o) { 231 return lessThan(SPECIES.broadcast(o)); 232 } 233 234 @Override 235 @ForceInline 236 public Mask<Byte, Shapes.S64Bit> lessThanEq(byte o) { 237 return lessThanEq(SPECIES.broadcast(o)); 238 } 239 240 @Override 241 @ForceInline 242 public Mask<Byte, Shapes.S64Bit> greaterThan(byte o) { 243 return greaterThan(SPECIES.broadcast(o)); 244 } 245 246 @Override 247 @ForceInline 248 public Mask<Byte, Shapes.S64Bit> greaterThanEq(byte o) { 249 return greaterThanEq(SPECIES.broadcast(o)); 250 } 251 252 @Override 253 @ForceInline 254 public ByteVector<Shapes.S64Bit> blend(byte o, Mask<Byte,Shapes.S64Bit> m) { 255 return blend(SPECIES.broadcast(o), m); 256 } 257 258 259 @Override 260 @ForceInline 261 public ByteVector<Shapes.S64Bit> and(byte o) { 262 return and(SPECIES.broadcast(o)); 263 } 264 265 @Override 266 @ForceInline 267 public ByteVector<Shapes.S64Bit> and(byte o, Mask<Byte,Shapes.S64Bit> m) { 268 return and(SPECIES.broadcast(o), m); 269 } 270 271 @Override 272 @ForceInline 273 public ByteVector<Shapes.S64Bit> or(byte o) { 274 return or(SPECIES.broadcast(o)); 275 } 276 277 @Override 278 @ForceInline 279 public ByteVector<Shapes.S64Bit> or(byte o, Mask<Byte,Shapes.S64Bit> m) { 280 return or(SPECIES.broadcast(o), m); 281 } 282 283 @Override 284 @ForceInline 285 public ByteVector<Shapes.S64Bit> xor(byte o) { 286 return xor(SPECIES.broadcast(o)); 287 } 288 289 @Override 290 @ForceInline 291 public ByteVector<Shapes.S64Bit> xor(byte o, Mask<Byte,Shapes.S64Bit> m) { 292 return xor(SPECIES.broadcast(o), m); 293 } 294 295 296 // Unary operations 297 298 @Override 299 @ForceInline 300 public Byte64Vector abs() { 301 return (Byte64Vector) VectorIntrinsics.unaryOp( 302 VECTOR_OP_ABS, Byte64Vector.class, byte.class, LENGTH, 303 this, 304 v1 -> ((Byte64Vector)v1).uOp((i, a) -> (byte) Math.abs(a))); 305 } 306 307 308 309 @Override 310 @ForceInline 311 public Byte64Vector not() { 312 return (Byte64Vector) VectorIntrinsics.unaryOp( 313 VECTOR_OP_NOT, Byte64Vector.class, byte.class, LENGTH, 314 this, 315 v1 -> ((Byte64Vector)v1).uOp((i, a) -> (byte) ~a)); 316 } 317 // Binary operations 318 319 @Override 320 @ForceInline 321 public Byte64Vector add(Vector<Byte,Shapes.S64Bit> o) { 322 Objects.requireNonNull(o); 323 Byte64Vector v = (Byte64Vector)o; 324 return (Byte64Vector) VectorIntrinsics.binaryOp( 325 VECTOR_OP_ADD, Byte64Vector.class, byte.class, LENGTH, 326 this, v, 327 (v1, v2) -> ((Byte64Vector)v1).bOp(v2, (i, a, b) -> (byte)(a + b))); 328 } 329 330 @Override 331 @ForceInline 332 public Byte64Vector sub(Vector<Byte,Shapes.S64Bit> o) { 333 Objects.requireNonNull(o); 334 Byte64Vector v = (Byte64Vector)o; 335 return (Byte64Vector) VectorIntrinsics.binaryOp( 336 VECTOR_OP_SUB, Byte64Vector.class, byte.class, LENGTH, 337 this, v, 338 (v1, v2) -> ((Byte64Vector)v1).bOp(v2, (i, a, b) -> (byte)(a - b))); 339 } 340 341 @Override 342 @ForceInline 343 public Byte64Vector mul(Vector<Byte,Shapes.S64Bit> o) { 344 Objects.requireNonNull(o); 345 Byte64Vector v = (Byte64Vector)o; 346 return (Byte64Vector) VectorIntrinsics.binaryOp( 347 VECTOR_OP_MUL, Byte64Vector.class, byte.class, LENGTH, 348 this, v, 349 (v1, v2) -> ((Byte64Vector)v1).bOp(v2, (i, a, b) -> (byte)(a * b))); 350 } 351 352 @Override 353 @ForceInline 354 public Byte64Vector min(Vector<Byte,Shapes.S64Bit> o) { 355 Objects.requireNonNull(o); 356 Byte64Vector v = (Byte64Vector)o; 357 return (Byte64Vector) VectorIntrinsics.binaryOp( 358 VECTOR_OP_MIN, Byte64Vector.class, byte.class, LENGTH, 359 this, v, 360 (v1, v2) -> ((Byte64Vector)v1).bOp(v2, (i, a, b) -> (byte) ((a < b) ? a : b))); 361 } 362 363 @Override 364 @ForceInline 365 public Byte64Vector max(Vector<Byte,Shapes.S64Bit> o) { 366 Objects.requireNonNull(o); 367 Byte64Vector v = (Byte64Vector)o; 368 return (Byte64Vector) VectorIntrinsics.binaryOp( 369 VECTOR_OP_MAX, Byte64Vector.class, byte.class, LENGTH, 370 this, v, 371 (v1, v2) -> ((Byte64Vector)v1).bOp(v2, (i, a, b) -> (byte) ((a > b) ? a : b))); 372 } 373 374 375 376 @Override 377 @ForceInline 378 public Byte64Vector and(Vector<Byte,Shapes.S64Bit> o) { 379 Objects.requireNonNull(o); 380 Byte64Vector v = (Byte64Vector)o; 381 return (Byte64Vector) VectorIntrinsics.binaryOp( 382 VECTOR_OP_AND, Byte64Vector.class, byte.class, LENGTH, 383 this, v, 384 (v1, v2) -> ((Byte64Vector)v1).bOp(v2, (i, a, b) -> (byte)(a & b))); 385 } 386 387 @Override 388 @ForceInline 389 public Byte64Vector or(Vector<Byte,Shapes.S64Bit> o) { 390 Objects.requireNonNull(o); 391 Byte64Vector v = (Byte64Vector)o; 392 return (Byte64Vector) VectorIntrinsics.binaryOp( 393 VECTOR_OP_OR, Byte64Vector.class, byte.class, LENGTH, 394 this, v, 395 (v1, v2) -> ((Byte64Vector)v1).bOp(v2, (i, a, b) -> (byte)(a | b))); 396 } 397 398 @Override 399 @ForceInline 400 public Byte64Vector xor(Vector<Byte,Shapes.S64Bit> o) { 401 Objects.requireNonNull(o); 402 Byte64Vector v = (Byte64Vector)o; 403 return (Byte64Vector) VectorIntrinsics.binaryOp( 404 VECTOR_OP_XOR, Byte64Vector.class, byte.class, LENGTH, 405 this, v, 406 (v1, v2) -> ((Byte64Vector)v1).bOp(v2, (i, a, b) -> (byte)(a ^ b))); 407 } 408 409 @Override 410 @ForceInline 411 public Byte64Vector and(Vector<Byte,Shapes.S64Bit> v, Mask<Byte, Shapes.S64Bit> m) { 412 return blend(and(v), m); 413 } 414 415 @Override 416 @ForceInline 417 public Byte64Vector or(Vector<Byte,Shapes.S64Bit> v, Mask<Byte, Shapes.S64Bit> m) { 418 return blend(or(v), m); 419 } 420 421 @Override 422 @ForceInline 423 public Byte64Vector xor(Vector<Byte,Shapes.S64Bit> v, Mask<Byte, Shapes.S64Bit> m) { 424 return blend(xor(v), m); 425 } 426 427 @Override 428 @ForceInline 429 public Byte64Vector shiftL(int s) { 430 return (Byte64Vector) VectorIntrinsics.broadcastInt( 431 VECTOR_OP_LSHIFT, Byte64Vector.class, byte.class, LENGTH, 432 this, s, 433 (v, i) -> v.uOp((__, a) -> (byte) (a << i))); 434 } 435 436 @Override 437 @ForceInline 438 public Byte64Vector shiftR(int s) { 439 return (Byte64Vector) VectorIntrinsics.broadcastInt( 440 VECTOR_OP_URSHIFT, Byte64Vector.class, byte.class, LENGTH, 441 this, s, 442 (v, i) -> v.uOp((__, a) -> (byte) (a >>> i))); 443 } 444 445 @Override 446 @ForceInline 447 public Byte64Vector aShiftR(int s) { 448 return (Byte64Vector) VectorIntrinsics.broadcastInt( 449 VECTOR_OP_RSHIFT, Byte64Vector.class, byte.class, LENGTH, 450 this, s, 451 (v, i) -> v.uOp((__, a) -> (byte) (a >> i))); 452 } 453 454 // Ternary operations 455 456 457 // Type specific horizontal reductions 458 459 @Override 460 @ForceInline 461 public byte addAll() { 462 return (byte) VectorIntrinsics.reductionCoerced( 463 VECTOR_OP_ADD, Byte64Vector.class, byte.class, LENGTH, 464 this, 465 v -> (long) v.rOp((byte) 0, (i, a, b) -> (byte) (a + b))); 466 } 467 468 @Override 469 @ForceInline 470 public byte andAll() { 471 return (byte) VectorIntrinsics.reductionCoerced( 472 VECTOR_OP_AND, Byte64Vector.class, byte.class, LENGTH, 473 this, 474 v -> (long) v.rOp((byte) -1, (i, a, b) -> (byte) (a & b))); 475 } 476 477 // Memory operations 478 479 @Override 480 @ForceInline 481 public void intoArray(byte[] a, int ix) { 482 Objects.requireNonNull(a); 483 ix = VectorIntrinsics.checkIndex(ix, a.length, LENGTH); 484 VectorIntrinsics.store(Byte64Vector.class, byte.class, LENGTH, 485 a, ix, this, 486 (arr, idx, v) -> v.forEach((i, a_) -> ((byte[])arr)[idx + i] = a_)); 487 } 488 489 @Override 490 @ForceInline 491 public void intoArray(byte[] a, int ax, Mask<Byte, Shapes.S64Bit> m) { 492 // TODO: use better default impl: forEach(m, (i, a_) -> a[ax + i] = a_); 493 Byte64Vector oldVal = SPECIES.fromArray(a, ax); 494 Byte64Vector newVal = oldVal.blend(this, m); 495 newVal.intoArray(a, ax); 496 } 497 498 // 499 500 @Override 501 public String toString() { 502 return Arrays.toString(getElements()); 503 } 504 505 @Override 506 public boolean equals(Object o) { 507 if (this == o) return true; 508 if (o == null || this.getClass() != o.getClass()) return false; 509 510 Byte64Vector that = (Byte64Vector) o; 511 return Arrays.equals(this.getElements(), that.getElements()); 512 } 513 514 @Override 515 public int hashCode() { 516 return Arrays.hashCode(vec); 517 } 518 519 // Binary test 520 521 @Override 522 Byte64Mask bTest(Vector<Byte, Shapes.S64Bit> o, FBinTest f) { 523 byte[] vec1 = getElements(); 524 byte[] vec2 = ((Byte64Vector)o).getElements(); 525 boolean[] bits = new boolean[length()]; 526 for (int i = 0; i < length(); i++){ 527 bits[i] = f.apply(i, vec1[i], vec2[i]); 528 } 529 return new Byte64Mask(bits); 530 } 531 532 // Comparisons 533 534 @Override 535 @ForceInline 536 public Byte64Mask equal(Vector<Byte, Shapes.S64Bit> o) { 537 Objects.requireNonNull(o); 538 Byte64Vector v = (Byte64Vector)o; 539 540 return (Byte64Mask) VectorIntrinsics.compare( 541 BT_eq, Byte64Vector.class, Byte64Mask.class, byte.class, LENGTH, 542 this, v, 543 (v1, v2) -> v1.bTest(v2, (i, a, b) -> a == b)); 544 } 545 546 @Override 547 @ForceInline 548 public Byte64Mask notEqual(Vector<Byte, Shapes.S64Bit> o) { 549 Objects.requireNonNull(o); 550 Byte64Vector v = (Byte64Vector)o; 551 552 return (Byte64Mask) VectorIntrinsics.compare( 553 BT_ne, Byte64Vector.class, Byte64Mask.class, byte.class, LENGTH, 554 this, v, 555 (v1, v2) -> v1.bTest(v2, (i, a, b) -> a != b)); 556 } 557 558 @Override 559 @ForceInline 560 public Byte64Mask lessThan(Vector<Byte, Shapes.S64Bit> o) { 561 Objects.requireNonNull(o); 562 Byte64Vector v = (Byte64Vector)o; 563 564 return (Byte64Mask) VectorIntrinsics.compare( 565 BT_lt, Byte64Vector.class, Byte64Mask.class, byte.class, LENGTH, 566 this, v, 567 (v1, v2) -> v1.bTest(v2, (i, a, b) -> a < b)); 568 } 569 570 @Override 571 @ForceInline 572 public Byte64Mask lessThanEq(Vector<Byte, Shapes.S64Bit> o) { 573 Objects.requireNonNull(o); 574 Byte64Vector v = (Byte64Vector)o; 575 576 return (Byte64Mask) VectorIntrinsics.compare( 577 BT_le, Byte64Vector.class, Byte64Mask.class, byte.class, LENGTH, 578 this, v, 579 (v1, v2) -> v1.bTest(v2, (i, a, b) -> a <= b)); 580 } 581 582 @Override 583 @ForceInline 584 public Byte64Mask greaterThan(Vector<Byte, Shapes.S64Bit> o) { 585 Objects.requireNonNull(o); 586 Byte64Vector v = (Byte64Vector)o; 587 588 return (Byte64Mask) VectorIntrinsics.compare( 589 BT_gt, Byte64Vector.class, Byte64Mask.class, byte.class, LENGTH, 590 this, v, 591 (v1, v2) -> v1.bTest(v2, (i, a, b) -> a > b)); 592 } 593 594 @Override 595 @ForceInline 596 public Byte64Mask greaterThanEq(Vector<Byte, Shapes.S64Bit> o) { 597 Objects.requireNonNull(o); 598 Byte64Vector v = (Byte64Vector)o; 599 600 return (Byte64Mask) VectorIntrinsics.compare( 601 BT_ge, Byte64Vector.class, Byte64Mask.class, byte.class, LENGTH, 602 this, v, 603 (v1, v2) -> v1.bTest(v2, (i, a, b) -> a >= b)); 604 } 605 606 // Foreach 607 608 @Override 609 void forEach(FUnCon f) { 610 byte[] vec = getElements(); 611 for (int i = 0; i < length(); i++) { 612 f.apply(i, vec[i]); 613 } 614 } 615 616 @Override 617 void forEach(Mask<Byte, Shapes.S64Bit> o, FUnCon f) { 618 boolean[] mbits = ((Byte64Mask)o).getBits(); 619 forEach((i, a) -> { 620 if (mbits[i]) { f.apply(i, a); } 621 }); 622 } 623 624 625 626 @Override 627 public Byte64Vector rotateEL(int j) { 628 byte[] vec = getElements(); 629 byte[] res = new byte[length()]; 630 for (int i = 0; i < length(); i++){ 631 res[(j + i) % length()] = vec[i]; 632 } 633 return new Byte64Vector(res); 634 } 635 636 @Override 637 public Byte64Vector rotateER(int j) { 638 byte[] vec = getElements(); 639 byte[] res = new byte[length()]; 640 for (int i = 0; i < length(); i++){ 641 int z = i - j; 642 if(j < 0) { 643 res[length() + z] = vec[i]; 644 } else { 645 res[z] = vec[i]; 646 } 647 } 648 return new Byte64Vector(res); 649 } 650 651 @Override 652 public Byte64Vector shiftEL(int j) { 653 byte[] vec = getElements(); 654 byte[] res = new byte[length()]; 655 for (int i = 0; i < length() - j; i++) { 656 res[i] = vec[i + j]; 657 } 658 return new Byte64Vector(res); 659 } 660 661 @Override 662 public Byte64Vector shiftER(int j) { 663 byte[] vec = getElements(); 664 byte[] res = new byte[length()]; 665 for (int i = 0; i < length() - j; i++){ 666 res[i + j] = vec[i]; 667 } 668 return new Byte64Vector(res); 669 } 670 671 @Override 672 public Byte64Vector shuffle(Vector<Byte, Shapes.S64Bit> o, Shuffle<Byte, Shapes.S64Bit> s) { 673 Byte64Vector v = (Byte64Vector) o; 674 return uOp((i, a) -> { 675 byte[] vec = this.getElements(); 676 int e = s.getElement(i); 677 if(e >= 0 && e < length()) { 678 //from this 679 return vec[e]; 680 } else if(e < length() * 2) { 681 //from o 682 return v.getElements()[e - length()]; 683 } else { 684 throw new ArrayIndexOutOfBoundsException("Bad reordering for shuffle"); 685 } 686 }); 687 } 688 689 @Override 690 public Byte64Vector swizzle(Shuffle<Byte, Shapes.S64Bit> s) { 691 return uOp((i, a) -> { 692 byte[] vec = this.getElements(); 693 int e = s.getElement(i); 694 if(e >= 0 && e < length()) { 695 return vec[e]; 696 } else { 697 throw new ArrayIndexOutOfBoundsException("Bad reordering for shuffle"); 698 } 699 }); 700 } 701 702 @Override 703 @ForceInline 704 public Byte64Vector blend(Vector<Byte, Shapes.S64Bit> o1, Mask<Byte, Shapes.S64Bit> o2) { 705 Objects.requireNonNull(o1); 706 Objects.requireNonNull(o2); 707 Byte64Vector v = (Byte64Vector)o1; 708 Byte64Mask m = (Byte64Mask)o2; 709 710 return (Byte64Vector) VectorIntrinsics.blend( 711 Byte64Vector.class, Byte64Mask.class, byte.class, LENGTH, 712 this, v, m, 713 (v1, v2, m_) -> v1.bOp(v2, (i, a, b) -> m_.getElement(i) ? b : a)); 714 } 715 716 // Accessors 717 718 @Override 719 public byte get(int i) { 720 byte[] vec = getElements(); 721 return vec[i]; 722 } 723 724 @Override 725 public Byte64Vector with(int i, byte e) { 726 byte[] res = vec.clone(); 727 res[i] = e; 728 return new Byte64Vector(res); 729 } 730 731 // Mask 732 733 static final class Byte64Mask extends AbstractMask<Byte, Shapes.S64Bit> { 734 static final Byte64Mask TRUE_MASK = new Byte64Mask(true); 735 static final Byte64Mask FALSE_MASK = new Byte64Mask(false); 736 737 // FIXME: was temporarily put here to simplify rematerialization support in the JVM 738 private final boolean[] bits; // Don't access directly, use getBits() instead. 739 740 public Byte64Mask(boolean[] bits) { 741 this(bits, 0); 742 } 743 744 public Byte64Mask(boolean[] bits, int i) { 745 this.bits = Arrays.copyOfRange(bits, i, i + species().length()); 746 } 747 748 public Byte64Mask(boolean val) { 749 boolean[] bits = new boolean[species().length()]; 750 Arrays.fill(bits, val); 751 this.bits = bits; 752 } 753 754 boolean[] getBits() { 755 return VectorIntrinsics.maybeRebox(this).bits; 756 } 757 758 @Override 759 Byte64Mask uOp(MUnOp f) { 760 boolean[] res = new boolean[species().length()]; 761 boolean[] bits = getBits(); 762 for (int i = 0; i < species().length(); i++) { 763 res[i] = f.apply(i, bits[i]); 764 } 765 return new Byte64Mask(res); 766 } 767 768 @Override 769 Byte64Mask bOp(Mask<Byte, Shapes.S64Bit> o, MBinOp f) { 770 boolean[] res = new boolean[species().length()]; 771 boolean[] bits = getBits(); 772 boolean[] mbits = ((Byte64Mask)o).getBits(); 773 for (int i = 0; i < species().length(); i++) { 774 res[i] = f.apply(i, bits[i], mbits[i]); 775 } 776 return new Byte64Mask(res); 777 } 778 779 @Override 780 public Byte64Species species() { 781 return SPECIES; 782 } 783 784 @Override 785 public Byte64Vector toVector() { 786 byte[] res = new byte[species().length()]; 787 boolean[] bits = getBits(); 788 for (int i = 0; i < species().length(); i++) { 789 res[i] = (byte) (bits[i] ? -1 : 0); 790 } 791 return new Byte64Vector(res); 792 } 793 794 @Override 795 @ForceInline 796 @SuppressWarnings("unchecked") 797 public <Z> Mask<Z, Shapes.S64Bit> rebracket(Species<Z, Shapes.S64Bit> species) { 798 Objects.requireNonNull(species); 799 // TODO: check proper element type 800 return VectorIntrinsics.reinterpret( 801 Byte64Mask.class, byte.class, LENGTH, 802 species.elementType(), species.length(), this, 803 (m, t) -> m.reshape(species) 804 ); 805 } 806 807 // Unary operations 808 809 //Mask<E, S> not(); 810 811 // Binary operations 812 813 @Override 814 @ForceInline 815 public Byte64Mask and(Mask<Byte,Shapes.S64Bit> o) { 816 Objects.requireNonNull(o); 817 Byte64Mask m = (Byte64Mask)o; 818 return VectorIntrinsics.binaryOp(VECTOR_OP_AND, Byte64Mask.class, byte.class, LENGTH, 819 this, m, 820 (m1, m2) -> m1.bOp(m2, (i, a, b) -> a & b)); 821 } 822 823 @Override 824 @ForceInline 825 public Byte64Mask or(Mask<Byte,Shapes.S64Bit> o) { 826 Objects.requireNonNull(o); 827 Byte64Mask m = (Byte64Mask)o; 828 return VectorIntrinsics.binaryOp(VECTOR_OP_OR, Byte64Mask.class, byte.class, LENGTH, 829 this, m, 830 (m1, m2) -> m1.bOp(m2, (i, a, b) -> a | b)); 831 } 832 833 // Reductions 834 835 @Override 836 @ForceInline 837 public boolean anyTrue() { 838 return VectorIntrinsics.test(COND_notZero, Byte64Mask.class, byte.class, LENGTH, 839 this, this, 840 (m1, m2) -> super.anyTrue()); 841 } 842 843 @Override 844 @ForceInline 845 public boolean allTrue() { 846 return VectorIntrinsics.test(COND_carrySet, Byte64Mask.class, byte.class, LENGTH, 847 this, species().maskAllTrue(), 848 (m1, m2) -> super.allTrue()); 849 } 850 } 851 852 // Shuffle 853 854 static final class Byte64Shuffle extends AbstractShuffle<Byte, Shapes.S64Bit> { 855 static final IntVector.IntSpecies<Shapes.S64Bit> INT_SPECIES = IntVector.speciesInstance(Shapes.S_64_BIT); 856 857 public Byte64Shuffle(int[] reorder) { 858 super(reorder); 859 } 860 861 public Byte64Shuffle(int[] reorder, int i) { 862 super(reorder, i); 863 } 864 865 @Override 866 public Byte64Species species() { 867 return SPECIES; 868 } 869 870 @Override 871 public IntVector.IntSpecies<Shapes.S64Bit> intSpecies() { 872 return INT_SPECIES; 873 } 874 } 875 876 // Species 877 878 @Override 879 public Byte64Species species() { 880 return SPECIES; 881 } 882 883 static final class Byte64Species extends ByteSpecies<Shapes.S64Bit> { 884 static final int BIT_SIZE = Shapes.S_64_BIT.bitSize(); 885 886 static final int LENGTH = BIT_SIZE / Byte.SIZE; 887 888 @Override 889 public String toString() { 890 StringBuilder sb = new StringBuilder("Shape["); 891 sb.append(bitSize()).append(" bits, "); 892 sb.append(length()).append(" ").append(byte.class.getSimpleName()).append("s x "); 893 sb.append(elementSize()).append(" bits"); 894 sb.append("]"); 895 return sb.toString(); 896 } 897 898 @Override 899 @ForceInline 900 public int bitSize() { 901 return BIT_SIZE; 902 } 903 904 @Override 905 @ForceInline 906 public int length() { 907 return LENGTH; 908 } 909 910 @Override 911 @ForceInline 912 public Class<Byte> elementType() { 913 return byte.class; 914 } 915 916 @Override 917 @ForceInline 918 public int elementSize() { 919 return Byte.SIZE; 920 } 921 922 @Override 923 @ForceInline 924 public Shapes.S64Bit shape() { 925 return Shapes.S_64_BIT; 926 } 927 928 @Override 929 Byte64Vector op(FOp f) { 930 byte[] res = new byte[length()]; 931 for (int i = 0; i < length(); i++) { 932 res[i] = f.apply(i); 933 } 934 return new Byte64Vector(res); 935 } 936 937 @Override 938 Byte64Vector op(Mask<Byte, Shapes.S64Bit> o, FOp f) { 939 byte[] res = new byte[length()]; 940 boolean[] mbits = ((Byte64Mask)o).getBits(); 941 for (int i = 0; i < length(); i++) { 942 if (mbits[i]) { 943 res[i] = f.apply(i); 944 } 945 } 946 return new Byte64Vector(res); 947 } 948 949 // Factories 950 951 @Override 952 public Byte64Mask maskFromValues(boolean... bits) { 953 return new Byte64Mask(bits); 954 } 955 956 @Override 957 public Byte64Mask maskFromArray(boolean[] bits, int i) { 958 return new Byte64Mask(bits, i); 959 } 960 961 @Override 962 public Byte64Shuffle shuffleFromValues(int... ixs) { 963 return new Byte64Shuffle(ixs); 964 } 965 966 @Override 967 public Byte64Shuffle shuffleFromArray(int[] ixs, int i) { 968 return new Byte64Shuffle(ixs, i); 969 } 970 971 @Override 972 public Byte64Shuffle shuffleFromVector(Vector<Integer, Shapes.S64Bit> v) { 973 int[] a = ((IntVector<Shapes.S64Bit>) v).toArray(); 974 return new Byte64Shuffle(a, 0); 975 } 976 977 @Override 978 @ForceInline 979 public Byte64Vector zero() { 980 return VectorIntrinsics.broadcastCoerced(Byte64Vector.class, byte.class, LENGTH, 981 0, 982 (z -> ZERO)); 983 } 984 985 @Override 986 @ForceInline 987 public Byte64Vector broadcast(byte e) { 988 return VectorIntrinsics.broadcastCoerced( 989 Byte64Vector.class, byte.class, LENGTH, 990 e, 991 ((long bits) -> SPECIES.op(i -> (byte)bits))); 992 } 993 994 @Override 995 @ForceInline 996 public Byte64Mask maskAllTrue() { 997 return VectorIntrinsics.broadcastCoerced(Byte64Mask.class, byte.class, LENGTH, 998 (byte)-1, 999 (z -> Byte64Mask.TRUE_MASK)); 1000 } 1001 1002 @Override 1003 @ForceInline 1004 public Byte64Mask maskAllFalse() { 1005 return VectorIntrinsics.broadcastCoerced(Byte64Mask.class, byte.class, LENGTH, 1006 0, 1007 (z -> Byte64Mask.FALSE_MASK)); 1008 } 1009 1010 @Override 1011 @ForceInline 1012 public Byte64Vector fromArray(byte[] a, int ix) { 1013 Objects.requireNonNull(a); 1014 ix = VectorIntrinsics.checkIndex(ix, a.length, LENGTH); 1015 return (Byte64Vector) VectorIntrinsics.load(Byte64Vector.class, byte.class, LENGTH, 1016 a, ix, 1017 (arr, idx) -> super.fromArray((byte[]) arr, idx)); 1018 } 1019 1020 @Override 1021 @ForceInline 1022 public Byte64Vector fromArray(byte[] a, int ax, Mask<Byte, Shapes.S64Bit> m) { 1023 return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); 1024 } 1025 1026 @ForceInline 1027 @SuppressWarnings("unchecked") 1028 private <S extends Shape> Byte64Vector castFromByte(ByteVector<S> o) { 1029 if (o.bitSize() == 64) { 1030 Byte64Vector so = (Byte64Vector)o; 1031 return VectorIntrinsics.cast( 1032 Byte64Vector.class, byte.class, so.length(), 1033 byte.class, LENGTH, so, 1034 (v, t) -> (Byte64Vector)super.cast(v) 1035 ); 1036 } else if (o.bitSize() == 128) { 1037 Byte128Vector so = (Byte128Vector)o; 1038 return VectorIntrinsics.cast( 1039 Byte128Vector.class, byte.class, so.length(), 1040 byte.class, LENGTH, so, 1041 (v, t) -> (Byte64Vector)super.cast(v) 1042 ); 1043 } else if (o.bitSize() == 256) { 1044 Byte256Vector so = (Byte256Vector)o; 1045 return VectorIntrinsics.cast( 1046 Byte256Vector.class, byte.class, so.length(), 1047 byte.class, LENGTH, so, 1048 (v, t) -> (Byte64Vector)super.cast(v) 1049 ); 1050 } else if (o.bitSize() == 512) { 1051 Byte512Vector so = (Byte512Vector)o; 1052 return VectorIntrinsics.cast( 1053 Byte512Vector.class, byte.class, so.length(), 1054 byte.class, LENGTH, so, 1055 (v, t) -> (Byte64Vector)super.cast(v) 1056 ); 1057 } else { 1058 throw new InternalError("Unimplemented size"); 1059 } 1060 } 1061 1062 @ForceInline 1063 @SuppressWarnings("unchecked") 1064 private <S extends Shape> Byte64Vector castFromShort(ShortVector<S> o) { 1065 if (o.bitSize() == 64) { 1066 Short64Vector so = (Short64Vector)o; 1067 return VectorIntrinsics.cast( 1068 Short64Vector.class, short.class, so.length(), 1069 byte.class, LENGTH, so, 1070 (v, t) -> (Byte64Vector)super.cast(v) 1071 ); 1072 } else if (o.bitSize() == 128) { 1073 Short128Vector so = (Short128Vector)o; 1074 return VectorIntrinsics.cast( 1075 Short128Vector.class, short.class, so.length(), 1076 byte.class, LENGTH, so, 1077 (v, t) -> (Byte64Vector)super.cast(v) 1078 ); 1079 } else if (o.bitSize() == 256) { 1080 Short256Vector so = (Short256Vector)o; 1081 return VectorIntrinsics.cast( 1082 Short256Vector.class, short.class, so.length(), 1083 byte.class, LENGTH, so, 1084 (v, t) -> (Byte64Vector)super.cast(v) 1085 ); 1086 } else if (o.bitSize() == 512) { 1087 Short512Vector so = (Short512Vector)o; 1088 return VectorIntrinsics.cast( 1089 Short512Vector.class, short.class, so.length(), 1090 byte.class, LENGTH, so, 1091 (v, t) -> (Byte64Vector)super.cast(v) 1092 ); 1093 } else { 1094 throw new InternalError("Unimplemented size"); 1095 } 1096 } 1097 1098 @ForceInline 1099 @SuppressWarnings("unchecked") 1100 private <S extends Shape> Byte64Vector castFromInt(IntVector<S> o) { 1101 if (o.bitSize() == 64) { 1102 Int64Vector so = (Int64Vector)o; 1103 return VectorIntrinsics.cast( 1104 Int64Vector.class, int.class, so.length(), 1105 byte.class, LENGTH, so, 1106 (v, t) -> (Byte64Vector)super.cast(v) 1107 ); 1108 } else if (o.bitSize() == 128) { 1109 Int128Vector so = (Int128Vector)o; 1110 return VectorIntrinsics.cast( 1111 Int128Vector.class, int.class, so.length(), 1112 byte.class, LENGTH, so, 1113 (v, t) -> (Byte64Vector)super.cast(v) 1114 ); 1115 } else if (o.bitSize() == 256) { 1116 Int256Vector so = (Int256Vector)o; 1117 return VectorIntrinsics.cast( 1118 Int256Vector.class, int.class, so.length(), 1119 byte.class, LENGTH, so, 1120 (v, t) -> (Byte64Vector)super.cast(v) 1121 ); 1122 } else if (o.bitSize() == 512) { 1123 Int512Vector so = (Int512Vector)o; 1124 return VectorIntrinsics.cast( 1125 Int512Vector.class, int.class, so.length(), 1126 byte.class, LENGTH, so, 1127 (v, t) -> (Byte64Vector)super.cast(v) 1128 ); 1129 } else { 1130 throw new InternalError("Unimplemented size"); 1131 } 1132 } 1133 1134 @ForceInline 1135 @SuppressWarnings("unchecked") 1136 private <S extends Shape> Byte64Vector castFromLong(LongVector<S> o) { 1137 if (o.bitSize() == 64) { 1138 Long64Vector so = (Long64Vector)o; 1139 return VectorIntrinsics.cast( 1140 Long64Vector.class, long.class, so.length(), 1141 byte.class, LENGTH, so, 1142 (v, t) -> (Byte64Vector)super.cast(v) 1143 ); 1144 } else if (o.bitSize() == 128) { 1145 Long128Vector so = (Long128Vector)o; 1146 return VectorIntrinsics.cast( 1147 Long128Vector.class, long.class, so.length(), 1148 byte.class, LENGTH, so, 1149 (v, t) -> (Byte64Vector)super.cast(v) 1150 ); 1151 } else if (o.bitSize() == 256) { 1152 Long256Vector so = (Long256Vector)o; 1153 return VectorIntrinsics.cast( 1154 Long256Vector.class, long.class, so.length(), 1155 byte.class, LENGTH, so, 1156 (v, t) -> (Byte64Vector)super.cast(v) 1157 ); 1158 } else if (o.bitSize() == 512) { 1159 Long512Vector so = (Long512Vector)o; 1160 return VectorIntrinsics.cast( 1161 Long512Vector.class, long.class, so.length(), 1162 byte.class, LENGTH, so, 1163 (v, t) -> (Byte64Vector)super.cast(v) 1164 ); 1165 } else { 1166 throw new InternalError("Unimplemented size"); 1167 } 1168 } 1169 1170 @ForceInline 1171 @SuppressWarnings("unchecked") 1172 private <S extends Shape> Byte64Vector castFromFloat(FloatVector<S> o) { 1173 if (o.bitSize() == 64) { 1174 Float64Vector so = (Float64Vector)o; 1175 return VectorIntrinsics.cast( 1176 Float64Vector.class, float.class, so.length(), 1177 byte.class, LENGTH, so, 1178 (v, t) -> (Byte64Vector)super.cast(v) 1179 ); 1180 } else if (o.bitSize() == 128) { 1181 Float128Vector so = (Float128Vector)o; 1182 return VectorIntrinsics.cast( 1183 Float128Vector.class, float.class, so.length(), 1184 byte.class, LENGTH, so, 1185 (v, t) -> (Byte64Vector)super.cast(v) 1186 ); 1187 } else if (o.bitSize() == 256) { 1188 Float256Vector so = (Float256Vector)o; 1189 return VectorIntrinsics.cast( 1190 Float256Vector.class, float.class, so.length(), 1191 byte.class, LENGTH, so, 1192 (v, t) -> (Byte64Vector)super.cast(v) 1193 ); 1194 } else if (o.bitSize() == 512) { 1195 Float512Vector so = (Float512Vector)o; 1196 return VectorIntrinsics.cast( 1197 Float512Vector.class, float.class, so.length(), 1198 byte.class, LENGTH, so, 1199 (v, t) -> (Byte64Vector)super.cast(v) 1200 ); 1201 } else { 1202 throw new InternalError("Unimplemented size"); 1203 } 1204 } 1205 1206 @ForceInline 1207 @SuppressWarnings("unchecked") 1208 private <S extends Shape> Byte64Vector castFromDouble(DoubleVector<S> o) { 1209 if (o.bitSize() == 64) { 1210 Double64Vector so = (Double64Vector)o; 1211 return VectorIntrinsics.cast( 1212 Double64Vector.class, double.class, so.length(), 1213 byte.class, LENGTH, so, 1214 (v, t) -> (Byte64Vector)super.cast(v) 1215 ); 1216 } else if (o.bitSize() == 128) { 1217 Double128Vector so = (Double128Vector)o; 1218 return VectorIntrinsics.cast( 1219 Double128Vector.class, double.class, so.length(), 1220 byte.class, LENGTH, so, 1221 (v, t) -> (Byte64Vector)super.cast(v) 1222 ); 1223 } else if (o.bitSize() == 256) { 1224 Double256Vector so = (Double256Vector)o; 1225 return VectorIntrinsics.cast( 1226 Double256Vector.class, double.class, so.length(), 1227 byte.class, LENGTH, so, 1228 (v, t) -> (Byte64Vector)super.cast(v) 1229 ); 1230 } else if (o.bitSize() == 512) { 1231 Double512Vector so = (Double512Vector)o; 1232 return VectorIntrinsics.cast( 1233 Double512Vector.class, double.class, so.length(), 1234 byte.class, LENGTH, so, 1235 (v, t) -> (Byte64Vector)super.cast(v) 1236 ); 1237 } else { 1238 throw new InternalError("Unimplemented size"); 1239 } 1240 } 1241 1242 @Override 1243 @ForceInline 1244 @SuppressWarnings("unchecked") 1245 public <E, S extends Shape> Byte64Vector cast(Vector<E, S> o) { 1246 Objects.requireNonNull(o); 1247 if (o.elementType() == byte.class) { 1248 ByteVector<S> so = (ByteVector<S>)o; 1249 return castFromByte(so); 1250 } else if (o.elementType() == short.class) { 1251 ShortVector<S> so = (ShortVector<S>)o; 1252 return castFromShort(so); 1253 } else if (o.elementType() == int.class) { 1254 IntVector<S> so = (IntVector<S>)o; 1255 return castFromInt(so); 1256 } else if (o.elementType() == long.class) { 1257 LongVector<S> so = (LongVector<S>)o; 1258 return castFromLong(so); 1259 } else if (o.elementType() == float.class) { 1260 FloatVector<S> so = (FloatVector<S>)o; 1261 return castFromFloat(so); 1262 } else if (o.elementType() == double.class) { 1263 DoubleVector<S> so = (DoubleVector<S>)o; 1264 return castFromDouble(so); 1265 } else { 1266 throw new InternalError("Unimplemented type"); 1267 } 1268 } 1269 1270 @Override 1271 @ForceInline 1272 @SuppressWarnings("unchecked") 1273 public <F> Byte64Vector rebracket(Vector<F, Shapes.S64Bit> o) { 1274 Objects.requireNonNull(o); 1275 if (o.elementType() == byte.class) { 1276 Byte64Vector so = (Byte64Vector)o; 1277 return VectorIntrinsics.reinterpret( 1278 Byte64Vector.class, byte.class, so.length(), 1279 byte.class, LENGTH, so, 1280 (v, t) -> (Byte64Vector)reshape(v) 1281 ); 1282 } else if (o.elementType() == short.class) { 1283 Short64Vector so = (Short64Vector)o; 1284 return VectorIntrinsics.reinterpret( 1285 Short64Vector.class, short.class, so.length(), 1286 byte.class, LENGTH, so, 1287 (v, t) -> (Byte64Vector)reshape(v) 1288 ); 1289 } else if (o.elementType() == int.class) { 1290 Int64Vector so = (Int64Vector)o; 1291 return VectorIntrinsics.reinterpret( 1292 Int64Vector.class, int.class, so.length(), 1293 byte.class, LENGTH, so, 1294 (v, t) -> (Byte64Vector)reshape(v) 1295 ); 1296 } else if (o.elementType() == long.class) { 1297 Long64Vector so = (Long64Vector)o; 1298 return VectorIntrinsics.reinterpret( 1299 Long64Vector.class, long.class, so.length(), 1300 byte.class, LENGTH, so, 1301 (v, t) -> (Byte64Vector)reshape(v) 1302 ); 1303 } else if (o.elementType() == float.class) { 1304 Float64Vector so = (Float64Vector)o; 1305 return VectorIntrinsics.reinterpret( 1306 Float64Vector.class, float.class, so.length(), 1307 byte.class, LENGTH, so, 1308 (v, t) -> (Byte64Vector)reshape(v) 1309 ); 1310 } else if (o.elementType() == double.class) { 1311 Double64Vector so = (Double64Vector)o; 1312 return VectorIntrinsics.reinterpret( 1313 Double64Vector.class, double.class, so.length(), 1314 byte.class, LENGTH, so, 1315 (v, t) -> (Byte64Vector)reshape(v) 1316 ); 1317 } else { 1318 throw new InternalError("Unimplemented type"); 1319 } 1320 } 1321 1322 @Override 1323 @ForceInline 1324 @SuppressWarnings("unchecked") 1325 public <T extends Shape> Byte64Vector resize(Vector<Byte, T> o) { 1326 Objects.requireNonNull(o); 1327 if (o.bitSize() == 64) { 1328 Byte64Vector so = (Byte64Vector)o; 1329 return VectorIntrinsics.reinterpret( 1330 Byte64Vector.class, byte.class, so.length(), 1331 byte.class, LENGTH, so, 1332 (v, t) -> (Byte64Vector)reshape(v) 1333 ); 1334 } else if (o.bitSize() == 128) { 1335 Byte128Vector so = (Byte128Vector)o; 1336 return VectorIntrinsics.reinterpret( 1337 Byte128Vector.class, byte.class, so.length(), 1338 byte.class, LENGTH, so, 1339 (v, t) -> (Byte64Vector)reshape(v) 1340 ); 1341 } else if (o.bitSize() == 256) { 1342 Byte256Vector so = (Byte256Vector)o; 1343 return VectorIntrinsics.reinterpret( 1344 Byte256Vector.class, byte.class, so.length(), 1345 byte.class, LENGTH, so, 1346 (v, t) -> (Byte64Vector)reshape(v) 1347 ); 1348 } else if (o.bitSize() == 512) { 1349 Byte512Vector so = (Byte512Vector)o; 1350 return VectorIntrinsics.reinterpret( 1351 Byte512Vector.class, byte.class, so.length(), 1352 byte.class, LENGTH, so, 1353 (v, t) -> (Byte64Vector)reshape(v) 1354 ); 1355 } else { 1356 throw new InternalError("Unimplemented size"); 1357 } 1358 } 1359 } 1360 }