< prev index next >

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template

Print this page




 154 
 155     @Override
 156     $type$ rOp($type$ v, FBinOp f) {
 157         $type$[] vec = getElements();
 158         for (int i = 0; i < length(); i++) {
 159             v = f.apply(i, v, vec[i]);
 160         }
 161         return v;
 162     }
 163 
 164     @Override
 165     @ForceInline
 166     public <F> Vector<F> cast(VectorSpecies<F> s) {
 167         Objects.requireNonNull(s);
 168         if (s.length() != LENGTH)
 169             throw new IllegalArgumentException("Vector length this species length differ");
 170 
 171         return VectorIntrinsics.cast(
 172             $vectortype$.class,
 173             $type$.class, LENGTH,
 174             s.boxType(),
 175             s.elementType(), LENGTH,
 176             this, s,
 177             (species, vector) -> vector.castDefault(species)
 178         );
 179     }
 180 
 181     @SuppressWarnings("unchecked")
 182     @ForceInline
 183     private <F> Vector<F> castDefault(VectorSpecies<F> s) {
 184         int limit = s.length();
 185 
 186         Class<?> stype = s.elementType();
 187         if (stype == byte.class) {
 188             byte[] a = new byte[limit];
 189             for (int i = 0; i < limit; i++) {
 190                 a[i] = (byte) this.lane(i);
 191             }
 192             return (Vector) ByteVector.fromArray((VectorSpecies<Byte>) s, a, 0);
 193         } else if (stype == short.class) {
 194             short[] a = new short[limit];


 292                 (species, vector) -> vector.defaultReinterpret(species)
 293             );
 294         } else if (stype == double.class) {
 295             return VectorIntrinsics.reinterpret(
 296                 $vectortype$.class,
 297                 $type$.class, LENGTH,
 298                 Double$bits$Vector.class,
 299                 double.class, Double$bits$Vector.LENGTH,
 300                 this, s,
 301                 (species, vector) -> vector.defaultReinterpret(species)
 302             );
 303         } else {
 304             throw new UnsupportedOperationException("Bad lane type for casting.");
 305         }
 306     }
 307 
 308     @Override
 309     @ForceInline
 310     public $abstractvectortype$ reshape(VectorSpecies<$Boxtype$> s) {
 311         Objects.requireNonNull(s);
 312         if (s.bitSize() == 64 && (s.boxType() == $Type$64Vector.class)) {
 313             return VectorIntrinsics.reinterpret(
 314                 $vectortype$.class,
 315                 $type$.class, LENGTH,
 316                 $Type$64Vector.class,
 317                 $type$.class, $Type$64Vector.LENGTH,
 318                 this, s,
 319                 (species, vector) -> ($abstractvectortype$) vector.defaultReinterpret(species)
 320             );
 321         } else if (s.bitSize() == 128 && (s.boxType() == $Type$128Vector.class)) {
 322             return VectorIntrinsics.reinterpret(
 323                 $vectortype$.class,
 324                 $type$.class, LENGTH,
 325                 $Type$128Vector.class,
 326                 $type$.class, $Type$128Vector.LENGTH,
 327                 this, s,
 328                 (species, vector) -> ($abstractvectortype$) vector.defaultReinterpret(species)
 329             );
 330         } else if (s.bitSize() == 256 && (s.boxType() == $Type$256Vector.class)) {
 331             return VectorIntrinsics.reinterpret(
 332                 $vectortype$.class,
 333                 $type$.class, LENGTH,
 334                 $Type$256Vector.class,
 335                 $type$.class, $Type$256Vector.LENGTH,
 336                 this, s,
 337                 (species, vector) -> ($abstractvectortype$) vector.defaultReinterpret(species)
 338             );
 339         } else if (s.bitSize() == 512 && (s.boxType() == $Type$512Vector.class)) {
 340             return VectorIntrinsics.reinterpret(
 341                 $vectortype$.class,
 342                 $type$.class, LENGTH,
 343                 $Type$512Vector.class,
 344                 $type$.class, $Type$512Vector.LENGTH,
 345                 this, s,
 346                 (species, vector) -> ($abstractvectortype$) vector.defaultReinterpret(species)
 347             );
 348         } else if ((s.bitSize() > 0) && (s.bitSize() <= 2048)
 349                 && (s.bitSize() % 128 == 0) && (s.boxType() == $Type$MaxVector.class)) {
 350             return VectorIntrinsics.reinterpret(
 351                 $vectortype$.class,
 352                 $type$.class, LENGTH,
 353                 $Type$MaxVector.class,
 354                 $type$.class, $Type$MaxVector.LENGTH,
 355                 this, s,
 356                 (species, vector) -> ($abstractvectortype$) vector.defaultReinterpret(species)
 357             );
 358         } else {
 359             throw new InternalError("Unimplemented size");
 360         }
 361     }
 362 
 363     // Binary operations with scalars
 364 
 365     @Override
 366     @ForceInline
 367     public $abstractvectortype$ add($type$ o) {
 368         return add(($vectortype$)$abstractvectortype$.broadcast(SPECIES, o));
 369     }


 929     public $vectortype$ and(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m) {
 930         return blend(and(v), m);
 931     }
 932 
 933     @Override
 934     @ForceInline
 935     public $vectortype$ or(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m) {
 936         return blend(or(v), m);
 937     }
 938 
 939     @Override
 940     @ForceInline
 941     public $vectortype$ xor(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m) {
 942         return blend(xor(v), m);
 943     }
 944 #end[BITWISE]
 945 
 946 #if[byte]
 947     @Override
 948     @ForceInline
 949     public $vectortype$ shiftL(int s) {
 950         return VectorIntrinsics.broadcastInt(
 951             VECTOR_OP_LSHIFT, $vectortype$.class, $type$.class, LENGTH,
 952             this, s,
 953             (v, i) -> v.uOp((__, a) -> ($type$) (a << (i & 7))));
 954     }
 955 
 956     @Override
 957     @ForceInline
 958     public $vectortype$ shiftL(int s, VectorMask<$Boxtype$> m) {
 959         return blend(shiftL(s), m);
 960     }
 961 
 962     @Override
 963     @ForceInline
 964     public $vectortype$ shiftR(int s) {









 965         return VectorIntrinsics.broadcastInt(
 966             VECTOR_OP_URSHIFT, $vectortype$.class, $type$.class, LENGTH,
 967             this, s,
 968             (v, i) -> v.uOp((__, a) -> ($type$) ((a & 0xFF) >>> (i & 7))));
 969     }
 970 
 971     @Override
 972     @ForceInline
 973     public $vectortype$ shiftR(int s, VectorMask<$Boxtype$> m) {
 974         return blend(shiftR(s), m);
 975     }
 976 
 977     @Override
 978     @ForceInline
 979     public $vectortype$ aShiftR(int s) {









 980         return VectorIntrinsics.broadcastInt(
 981             VECTOR_OP_RSHIFT, $vectortype$.class, $type$.class, LENGTH,
 982             this, s,
 983             (v, i) -> v.uOp((__, a) -> ($type$) (a >> (i & 7))));
 984     }
 985 
 986     @Override
 987     @ForceInline
 988     public $vectortype$ aShiftR(int s, VectorMask<$Boxtype$> m) {
 989         return blend(aShiftR(s), m);
 990     }










 991 #end[byte]
 992 #if[short]
 993     @Override
 994     @ForceInline
 995     public $vectortype$ shiftL(int s) {
 996         return VectorIntrinsics.broadcastInt(
 997             VECTOR_OP_LSHIFT, $vectortype$.class, $type$.class, LENGTH,
 998             this, s,
 999             (v, i) -> v.uOp((__, a) -> ($type$) (a << (i & 15))));
1000     }
1001 
1002     @Override
1003     @ForceInline
1004     public $vectortype$ shiftL(int s, VectorMask<$Boxtype$> m) {
1005         return blend(shiftL(s), m);
1006     }
1007 
1008     @Override
1009     @ForceInline
1010     public $vectortype$ shiftR(int s) {









1011         return VectorIntrinsics.broadcastInt(
1012             VECTOR_OP_URSHIFT, $vectortype$.class, $type$.class, LENGTH,
1013             this, s,
1014             (v, i) -> v.uOp((__, a) -> ($type$) ((a & 0xFFFF) >>> (i & 15))));






1015     }
1016 
1017     @Override
1018     @ForceInline
1019     public $vectortype$ shiftR(int s, VectorMask<$Boxtype$> m) {
1020         return blend(shiftR(s), m);



1021     }
1022 
1023     @Override
1024     @ForceInline
1025     public $vectortype$ aShiftR(int s) {
1026         return VectorIntrinsics.broadcastInt(
1027             VECTOR_OP_RSHIFT, $vectortype$.class, $type$.class, LENGTH,
1028             this, s,
1029             (v, i) -> v.uOp((__, a) -> ($type$) (a >> (i & 15))));
1030     }
1031 
1032     @Override
1033     @ForceInline
1034     public $vectortype$ aShiftR(int s, VectorMask<$Boxtype$> m) {
1035         return blend(aShiftR(s), m);









1036     }
1037 #end[short]
1038 #if[intOrLong]
1039     @Override
1040     @ForceInline
1041     public $vectortype$ shiftL(int s) {
1042         return VectorIntrinsics.broadcastInt(
1043             VECTOR_OP_LSHIFT, $vectortype$.class, $type$.class, LENGTH,
1044             this, s,
1045             (v, i) -> v.uOp((__, a) -> ($type$) (a << i)));
1046     }
1047 
1048     @Override
1049     @ForceInline
1050     public $vectortype$ shiftL(int s, VectorMask<$Boxtype$> m) {
1051         return blend(shiftL(s), m);
1052     }
1053 
1054     @Override
1055     @ForceInline
1056     public $vectortype$ shiftR(int s) {
1057         return VectorIntrinsics.broadcastInt(
1058             VECTOR_OP_URSHIFT, $vectortype$.class, $type$.class, LENGTH,
1059             this, s,
1060             (v, i) -> v.uOp((__, a) -> ($type$) (a >>> i)));
1061     }
1062 
1063     @Override
1064     @ForceInline
1065     public $vectortype$ shiftR(int s, VectorMask<$Boxtype$> m) {
1066         return blend(shiftR(s), m);
1067     }
1068 
1069     @Override
1070     @ForceInline
1071     public $vectortype$ aShiftR(int s) {
1072         return VectorIntrinsics.broadcastInt(
1073             VECTOR_OP_RSHIFT, $vectortype$.class, $type$.class, LENGTH,
1074             this, s,
1075             (v, i) -> v.uOp((__, a) -> ($type$) (a >> i)));
1076     }
1077 
1078     @Override
1079     @ForceInline
1080     public $vectortype$ aShiftR(int s, VectorMask<$Boxtype$> m) {
1081         return blend(aShiftR(s), m);
1082     }
1083 
1084     @Override
1085     @ForceInline
1086     public $vectortype$ shiftL(Vector<$Boxtype$> s) {
1087         $vectortype$ shiftv = ($vectortype$)s;
1088         // As per shift specification for Java, mask the shift count.
1089         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, {#if[int]?0x1f:0x3f}));
1090         return VectorIntrinsics.binaryOp(
1091             VECTOR_OP_LSHIFT, $vectortype$.class, $type$.class, LENGTH,
1092             this, shiftv,
1093             (v1, v2) -> v1.bOp(v2,(i,a, b) -> ($type$) (a << b)));
1094     }
1095 
1096     @Override
1097     @ForceInline
1098     public $vectortype$ shiftR(Vector<$Boxtype$> s) {
1099         $vectortype$ shiftv = ($vectortype$)s;
1100         // As per shift specification for Java, mask the shift count.
1101         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, {#if[int]?0x1f:0x3f}));
1102         return VectorIntrinsics.binaryOp(
1103             VECTOR_OP_URSHIFT, $vectortype$.class, $type$.class, LENGTH,
1104             this, shiftv,
1105             (v1, v2) -> v1.bOp(v2,(i,a, b) -> ($type$) (a >>> b)));
1106     }
1107 
1108     @Override
1109     @ForceInline
1110     public $vectortype$ aShiftR(Vector<$Boxtype$> s) {
1111         $vectortype$ shiftv = ($vectortype$)s;
1112         // As per shift specification for Java, mask the shift count.
1113         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, {#if[int]?0x1f:0x3f}));
1114         return VectorIntrinsics.binaryOp(
1115             VECTOR_OP_RSHIFT, $vectortype$.class, $type$.class, LENGTH,
1116             this, shiftv,
1117             (v1, v2) -> v1.bOp(v2,(i,a, b) -> ($type$) (a >> b)));
1118     }
1119 #end[intOrLong]
1120     // Ternary operations
1121 
1122 #if[FP]
1123     @Override
1124     @ForceInline
1125     public $vectortype$ fma(Vector<$Boxtype$> o1, Vector<$Boxtype$> o2) {
1126         Objects.requireNonNull(o1);
1127         Objects.requireNonNull(o2);
1128         $vectortype$ v1 = ($vectortype$)o1;
1129         $vectortype$ v2 = ($vectortype$)o2;
1130         return VectorIntrinsics.ternaryOp(


1552         $bitstype$[] res = new $bitstype$[this.species().length()];
1553         for(int i = 0; i < this.species().length(); i++){
1554             res[i] = $Type$.$type$To$Bitstype$Bits(vec[i]);
1555         }
1556         return new $bitsvectortype$(res);
1557     }
1558 #end[FP]
1559 
1560 #if[intOrLong]
1561     $fpvectortype$ toFP() {
1562         $type$[] vec = getElements();
1563         $fptype$[] res = new $fptype$[this.species().length()];
1564         for(int i = 0; i < this.species().length(); i++){
1565             res[i] = $Boxfptype$.$bitstype$BitsTo$Fptype$(vec[i]);
1566         }
1567         return new $fpvectortype$(res);
1568     }
1569 #end[intOrLong]
1570 
1571     @Override
1572     public $vectortype$ rotateEL(int j) {
1573         $type$[] vec = getElements();
1574         $type$[] res = new $type$[length()];
1575         for (int i = 0; i < length(); i++){
1576             res[(j + i) % length()] = vec[i];
1577         }
1578         return new $vectortype$(res);
1579     }
1580 
1581     @Override
1582     public $vectortype$ rotateER(int j) {
1583         $type$[] vec = getElements();
1584         $type$[] res = new $type$[length()];
1585         for (int i = 0; i < length(); i++){
1586             int z = i - j;
1587             if(j < 0) {
1588                 res[length() + z] = vec[i];
1589             } else {
1590                 res[z] = vec[i];
1591             }
1592         }
1593         return new $vectortype$(res);
1594     }
1595 
1596     @Override
1597     public $vectortype$ shiftEL(int j) {
1598         $type$[] vec = getElements();
1599         $type$[] res = new $type$[length()];
1600         for (int i = 0; i < length() - j; i++) {
1601             res[i] = vec[i + j];
1602         }
1603         return new $vectortype$(res);
1604     }
1605 
1606     @Override
1607     public $vectortype$ shiftER(int j) {
1608         $type$[] vec = getElements();
1609         $type$[] res = new $type$[length()];
1610         for (int i = 0; i < length() - j; i++){
1611             res[i + j] = vec[i];
1612         }
1613         return new $vectortype$(res);
1614     }
1615 
1616     @Override
1617     @ForceInline
1618     public $vectortype$ rearrange(Vector<$Boxtype$> v,
1619                                   VectorShuffle<$Boxtype$> s, VectorMask<$Boxtype$> m) {
1620         return this.rearrange(s).blend(v.rearrange(s), m);
1621     }
1622 
1623     @Override
1624     @ForceInline
1625     public $vectortype$ rearrange(VectorShuffle<$Boxtype$> o1) {
1626         Objects.requireNonNull(o1);
1627         $shuffletype$ s =  ($shuffletype$)o1;




 154 
 155     @Override
 156     $type$ rOp($type$ v, FBinOp f) {
 157         $type$[] vec = getElements();
 158         for (int i = 0; i < length(); i++) {
 159             v = f.apply(i, v, vec[i]);
 160         }
 161         return v;
 162     }
 163 
 164     @Override
 165     @ForceInline
 166     public <F> Vector<F> cast(VectorSpecies<F> s) {
 167         Objects.requireNonNull(s);
 168         if (s.length() != LENGTH)
 169             throw new IllegalArgumentException("Vector length this species length differ");
 170 
 171         return VectorIntrinsics.cast(
 172             $vectortype$.class,
 173             $type$.class, LENGTH,
 174             s.vectorType(),
 175             s.elementType(), LENGTH,
 176             this, s,
 177             (species, vector) -> vector.castDefault(species)
 178         );
 179     }
 180 
 181     @SuppressWarnings("unchecked")
 182     @ForceInline
 183     private <F> Vector<F> castDefault(VectorSpecies<F> s) {
 184         int limit = s.length();
 185 
 186         Class<?> stype = s.elementType();
 187         if (stype == byte.class) {
 188             byte[] a = new byte[limit];
 189             for (int i = 0; i < limit; i++) {
 190                 a[i] = (byte) this.lane(i);
 191             }
 192             return (Vector) ByteVector.fromArray((VectorSpecies<Byte>) s, a, 0);
 193         } else if (stype == short.class) {
 194             short[] a = new short[limit];


 292                 (species, vector) -> vector.defaultReinterpret(species)
 293             );
 294         } else if (stype == double.class) {
 295             return VectorIntrinsics.reinterpret(
 296                 $vectortype$.class,
 297                 $type$.class, LENGTH,
 298                 Double$bits$Vector.class,
 299                 double.class, Double$bits$Vector.LENGTH,
 300                 this, s,
 301                 (species, vector) -> vector.defaultReinterpret(species)
 302             );
 303         } else {
 304             throw new UnsupportedOperationException("Bad lane type for casting.");
 305         }
 306     }
 307 
 308     @Override
 309     @ForceInline
 310     public $abstractvectortype$ reshape(VectorSpecies<$Boxtype$> s) {
 311         Objects.requireNonNull(s);
 312         if (s.bitSize() == 64 && (s.vectorType() == $Type$64Vector.class)) {
 313             return VectorIntrinsics.reinterpret(
 314                 $vectortype$.class,
 315                 $type$.class, LENGTH,
 316                 $Type$64Vector.class,
 317                 $type$.class, $Type$64Vector.LENGTH,
 318                 this, s,
 319                 (species, vector) -> ($abstractvectortype$) vector.defaultReinterpret(species)
 320             );
 321         } else if (s.bitSize() == 128 && (s.vectorType() == $Type$128Vector.class)) {
 322             return VectorIntrinsics.reinterpret(
 323                 $vectortype$.class,
 324                 $type$.class, LENGTH,
 325                 $Type$128Vector.class,
 326                 $type$.class, $Type$128Vector.LENGTH,
 327                 this, s,
 328                 (species, vector) -> ($abstractvectortype$) vector.defaultReinterpret(species)
 329             );
 330         } else if (s.bitSize() == 256 && (s.vectorType() == $Type$256Vector.class)) {
 331             return VectorIntrinsics.reinterpret(
 332                 $vectortype$.class,
 333                 $type$.class, LENGTH,
 334                 $Type$256Vector.class,
 335                 $type$.class, $Type$256Vector.LENGTH,
 336                 this, s,
 337                 (species, vector) -> ($abstractvectortype$) vector.defaultReinterpret(species)
 338             );
 339         } else if (s.bitSize() == 512 && (s.vectorType() == $Type$512Vector.class)) {
 340             return VectorIntrinsics.reinterpret(
 341                 $vectortype$.class,
 342                 $type$.class, LENGTH,
 343                 $Type$512Vector.class,
 344                 $type$.class, $Type$512Vector.LENGTH,
 345                 this, s,
 346                 (species, vector) -> ($abstractvectortype$) vector.defaultReinterpret(species)
 347             );
 348         } else if ((s.bitSize() > 0) && (s.bitSize() <= 2048)
 349                 && (s.bitSize() % 128 == 0) && (s.vectorType() == $Type$MaxVector.class)) {
 350             return VectorIntrinsics.reinterpret(
 351                 $vectortype$.class,
 352                 $type$.class, LENGTH,
 353                 $Type$MaxVector.class,
 354                 $type$.class, $Type$MaxVector.LENGTH,
 355                 this, s,
 356                 (species, vector) -> ($abstractvectortype$) vector.defaultReinterpret(species)
 357             );
 358         } else {
 359             throw new InternalError("Unimplemented size");
 360         }
 361     }
 362 
 363     // Binary operations with scalars
 364 
 365     @Override
 366     @ForceInline
 367     public $abstractvectortype$ add($type$ o) {
 368         return add(($vectortype$)$abstractvectortype$.broadcast(SPECIES, o));
 369     }


 929     public $vectortype$ and(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m) {
 930         return blend(and(v), m);
 931     }
 932 
 933     @Override
 934     @ForceInline
 935     public $vectortype$ or(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m) {
 936         return blend(or(v), m);
 937     }
 938 
 939     @Override
 940     @ForceInline
 941     public $vectortype$ xor(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m) {
 942         return blend(xor(v), m);
 943     }
 944 #end[BITWISE]
 945 
 946 #if[byte]
 947     @Override
 948     @ForceInline
 949     public $vectortype$ shiftLeft(int s) {
 950         return VectorIntrinsics.broadcastInt(
 951             VECTOR_OP_LSHIFT, $vectortype$.class, $type$.class, LENGTH,
 952             this, s,
 953             (v, i) -> v.uOp((__, a) -> ($type$) (a << (i & 0x7))));
 954     }
 955 
 956     @Override
 957     @ForceInline
 958     public $vectortype$ shiftLeft(int s, VectorMask<$Boxtype$> m) {
 959         return blend(shiftLeft(s), m);
 960     }
 961 
 962     @Override
 963     @ForceInline
 964     public $vectortype$ shiftLeft(Vector<$Boxtype$> s) {
 965         $vectortype$ shiftv = ($vectortype$)s;
 966         // As per shift specification for Java, mask the shift count.
 967         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, ($type$) 0x7));
 968         return this.bOp(shiftv, (i, a, b) -> ($type$) (a << (b & 0x7)));
 969     }
 970 
 971     @Override
 972     @ForceInline
 973     public $vectortype$ shiftRight(int s) {
 974         return VectorIntrinsics.broadcastInt(
 975             VECTOR_OP_URSHIFT, $vectortype$.class, $type$.class, LENGTH,
 976             this, s,
 977             (v, i) -> v.uOp((__, a) -> ($type$) ((a & 0xFF) >>> (i & 0x7))));
 978     }
 979 
 980     @Override
 981     @ForceInline
 982     public $vectortype$ shiftRight(int s, VectorMask<$Boxtype$> m) {
 983         return blend(shiftRight(s), m);
 984     }
 985 
 986     @Override
 987     @ForceInline
 988     public $vectortype$ shiftRight(Vector<$Boxtype$> s) {
 989         $vectortype$ shiftv = ($vectortype$)s;
 990         // As per shift specification for Java, mask the shift count.
 991         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, ($type$) 0x7));
 992         return this.bOp(shiftv, (i, a, b) -> ($type$) (a >>> (b & 0x7)));
 993     }
 994 
 995     @Override
 996     @ForceInline
 997     public $vectortype$ shiftArithmeticRight(int s) {
 998         return VectorIntrinsics.broadcastInt(
 999             VECTOR_OP_RSHIFT, $vectortype$.class, $type$.class, LENGTH,
1000             this, s,
1001             (v, i) -> v.uOp((__, a) -> ($type$) (a >> (i & 0x7))));
1002     }
1003 
1004     @Override
1005     @ForceInline
1006     public $vectortype$ shiftArithmeticRight(int s, VectorMask<$Boxtype$> m) {
1007         return blend(shiftArithmeticRight(s), m);
1008     }
1009 
1010     @Override
1011     @ForceInline
1012     public $vectortype$ shiftArithmeticRight(Vector<$Boxtype$> s) {
1013         $vectortype$ shiftv = ($vectortype$)s;
1014         // As per shift specification for Java, mask the shift count.
1015         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, ($type$) 0x7));
1016         return this.bOp(shiftv, (i, a, b) -> ($type$) (a >> (b & 0x7)));
1017     }
1018 
1019 #end[byte]
1020 #if[short]
1021     @Override
1022     @ForceInline
1023     public $vectortype$ shiftLeft(int s) {
1024         return VectorIntrinsics.broadcastInt(
1025             VECTOR_OP_LSHIFT, $vectortype$.class, $type$.class, LENGTH,
1026             this, s,
1027             (v, i) -> v.uOp((__, a) -> ($type$) (a << (i & 0xF))));
1028     }
1029 
1030     @Override
1031     @ForceInline
1032     public $vectortype$ shiftLeft(int s, VectorMask<$Boxtype$> m) {
1033         return blend(shiftLeft(s), m);
1034     }
1035 
1036     @Override
1037     @ForceInline
1038     public $vectortype$ shiftLeft(Vector<$Boxtype$> s) {
1039         $vectortype$ shiftv = ($vectortype$)s;
1040         // As per shift specification for Java, mask the shift count.
1041         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, ($type$) 0xF));
1042         return this.bOp(shiftv, (i, a, b) -> ($type$) (a << (b & 0xF)));
1043     }
1044 
1045     @Override
1046     @ForceInline
1047     public $vectortype$ shiftRight(int s) {
1048         return VectorIntrinsics.broadcastInt(
1049             VECTOR_OP_URSHIFT, $vectortype$.class, $type$.class, LENGTH,
1050             this, s,
1051             (v, i) -> v.uOp((__, a) -> ($type$) ((a & 0xFFFF) >>> (i & 0xF))));
1052     }
1053 
1054     @Override
1055     @ForceInline
1056     public $vectortype$ shiftRight(int s, VectorMask<$Boxtype$> m) {
1057         return blend(shiftRight(s), m);
1058     }
1059 
1060     @Override
1061     @ForceInline
1062     public $vectortype$ shiftRight(Vector<$Boxtype$> s) {
1063         $vectortype$ shiftv = ($vectortype$)s;
1064         // As per shift specification for Java, mask the shift count.
1065         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, ($type$) 0xF));
1066         return this.bOp(shiftv, (i, a, b) -> ($type$) (a >>> (b & 0xF)));
1067     }
1068 
1069     @Override
1070     @ForceInline
1071     public $vectortype$ shiftArithmeticRight(int s) {
1072         return VectorIntrinsics.broadcastInt(
1073             VECTOR_OP_RSHIFT, $vectortype$.class, $type$.class, LENGTH,
1074             this, s,
1075             (v, i) -> v.uOp((__, a) -> ($type$) (a >> (i & 0xF))));
1076     }
1077 
1078     @Override
1079     @ForceInline
1080     public $vectortype$ shiftArithmeticRight(int s, VectorMask<$Boxtype$> m) {
1081         return blend(shiftArithmeticRight(s), m);
1082     }
1083 
1084     @Override
1085     @ForceInline
1086     public $vectortype$ shiftArithmeticRight(Vector<$Boxtype$> s) {
1087         $vectortype$ shiftv = ($vectortype$)s;
1088         // As per shift specification for Java, mask the shift count.
1089         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, ($type$) 0xF));
1090         return this.bOp(shiftv, (i, a, b) -> ($type$) (a >> (b & 0xF)));
1091     }
1092 #end[short]
1093 #if[intOrLong]
1094     @Override
1095     @ForceInline
1096     public $vectortype$ shiftLeft(int s) {
1097         return VectorIntrinsics.broadcastInt(
1098             VECTOR_OP_LSHIFT, $vectortype$.class, $type$.class, LENGTH,
1099             this, s,
1100             (v, i) -> v.uOp((__, a) -> ($type$) (a << i)));
1101     }
1102 
1103     @Override
1104     @ForceInline
1105     public $vectortype$ shiftLeft(int s, VectorMask<$Boxtype$> m) {
1106         return blend(shiftLeft(s), m);
1107     }
1108 
1109     @Override
1110     @ForceInline
1111     public $vectortype$ shiftRight(int s) {
1112         return VectorIntrinsics.broadcastInt(
1113             VECTOR_OP_URSHIFT, $vectortype$.class, $type$.class, LENGTH,
1114             this, s,
1115             (v, i) -> v.uOp((__, a) -> ($type$) (a >>> i)));
1116     }
1117 
1118     @Override
1119     @ForceInline
1120     public $vectortype$ shiftRight(int s, VectorMask<$Boxtype$> m) {
1121         return blend(shiftRight(s), m);
1122     }
1123 
1124     @Override
1125     @ForceInline
1126     public $vectortype$ shiftArithmeticRight(int s) {
1127         return VectorIntrinsics.broadcastInt(
1128             VECTOR_OP_RSHIFT, $vectortype$.class, $type$.class, LENGTH,
1129             this, s,
1130             (v, i) -> v.uOp((__, a) -> ($type$) (a >> i)));
1131     }
1132 
1133     @Override
1134     @ForceInline
1135     public $vectortype$ shiftArithmeticRight(int s, VectorMask<$Boxtype$> m) {
1136         return blend(shiftArithmeticRight(s), m);
1137     }
1138 
1139     @Override
1140     @ForceInline
1141     public $vectortype$ shiftLeft(Vector<$Boxtype$> s) {
1142         $vectortype$ shiftv = ($vectortype$)s;
1143         // As per shift specification for Java, mask the shift count.
1144         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, {#if[int]?0x1f:0x3f}));
1145         return VectorIntrinsics.binaryOp(
1146             VECTOR_OP_LSHIFT, $vectortype$.class, $type$.class, LENGTH,
1147             this, shiftv,
1148             (v1, v2) -> v1.bOp(v2,(i,a, b) -> ($type$) (a << b)));
1149     }
1150 
1151     @Override
1152     @ForceInline
1153     public $vectortype$ shiftRight(Vector<$Boxtype$> s) {
1154         $vectortype$ shiftv = ($vectortype$)s;
1155         // As per shift specification for Java, mask the shift count.
1156         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, {#if[int]?0x1f:0x3f}));
1157         return VectorIntrinsics.binaryOp(
1158             VECTOR_OP_URSHIFT, $vectortype$.class, $type$.class, LENGTH,
1159             this, shiftv,
1160             (v1, v2) -> v1.bOp(v2,(i,a, b) -> ($type$) (a >>> b)));
1161     }
1162 
1163     @Override
1164     @ForceInline
1165     public $vectortype$ shiftArithmeticRight(Vector<$Boxtype$> s) {
1166         $vectortype$ shiftv = ($vectortype$)s;
1167         // As per shift specification for Java, mask the shift count.
1168         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, {#if[int]?0x1f:0x3f}));
1169         return VectorIntrinsics.binaryOp(
1170             VECTOR_OP_RSHIFT, $vectortype$.class, $type$.class, LENGTH,
1171             this, shiftv,
1172             (v1, v2) -> v1.bOp(v2,(i,a, b) -> ($type$) (a >> b)));
1173     }
1174 #end[intOrLong]
1175     // Ternary operations
1176 
1177 #if[FP]
1178     @Override
1179     @ForceInline
1180     public $vectortype$ fma(Vector<$Boxtype$> o1, Vector<$Boxtype$> o2) {
1181         Objects.requireNonNull(o1);
1182         Objects.requireNonNull(o2);
1183         $vectortype$ v1 = ($vectortype$)o1;
1184         $vectortype$ v2 = ($vectortype$)o2;
1185         return VectorIntrinsics.ternaryOp(


1607         $bitstype$[] res = new $bitstype$[this.species().length()];
1608         for(int i = 0; i < this.species().length(); i++){
1609             res[i] = $Type$.$type$To$Bitstype$Bits(vec[i]);
1610         }
1611         return new $bitsvectortype$(res);
1612     }
1613 #end[FP]
1614 
1615 #if[intOrLong]
1616     $fpvectortype$ toFP() {
1617         $type$[] vec = getElements();
1618         $fptype$[] res = new $fptype$[this.species().length()];
1619         for(int i = 0; i < this.species().length(); i++){
1620             res[i] = $Boxfptype$.$bitstype$BitsTo$Fptype$(vec[i]);
1621         }
1622         return new $fpvectortype$(res);
1623     }
1624 #end[intOrLong]
1625 
1626     @Override
1627     public $vectortype$ rotateLanesLeft(int j) {
1628         $type$[] vec = getElements();
1629         $type$[] res = new $type$[length()];
1630         for (int i = 0; i < length(); i++){
1631             res[(j + i) % length()] = vec[i];
1632         }
1633         return new $vectortype$(res);
1634     }
1635 
1636     @Override
1637     public $vectortype$ rotateLanesRight(int j) {
1638         $type$[] vec = getElements();
1639         $type$[] res = new $type$[length()];
1640         for (int i = 0; i < length(); i++){
1641             int z = i - j;
1642             if(j < 0) {
1643                 res[length() + z] = vec[i];
1644             } else {
1645                 res[z] = vec[i];
1646             }
1647         }
1648         return new $vectortype$(res);
1649     }
1650 
1651     @Override
1652     public $vectortype$ shiftLanesLeft(int j) {
1653         $type$[] vec = getElements();
1654         $type$[] res = new $type$[length()];
1655         for (int i = 0; i < length() - j; i++) {
1656             res[i] = vec[i + j];
1657         }
1658         return new $vectortype$(res);
1659     }
1660 
1661     @Override
1662     public $vectortype$ shiftLanesRight(int j) {
1663         $type$[] vec = getElements();
1664         $type$[] res = new $type$[length()];
1665         for (int i = 0; i < length() - j; i++){
1666             res[i + j] = vec[i];
1667         }
1668         return new $vectortype$(res);
1669     }
1670 
1671     @Override
1672     @ForceInline
1673     public $vectortype$ rearrange(Vector<$Boxtype$> v,
1674                                   VectorShuffle<$Boxtype$> s, VectorMask<$Boxtype$> m) {
1675         return this.rearrange(s).blend(v.rearrange(s), m);
1676     }
1677 
1678     @Override
1679     @ForceInline
1680     public $vectortype$ rearrange(VectorShuffle<$Boxtype$> o1) {
1681         Objects.requireNonNull(o1);
1682         $shuffletype$ s =  ($shuffletype$)o1;


< prev index next >