1039 1040 @Override 1041 void forEach(FUnCon f) { 1042 byte[] vec = getElements(); 1043 for (int i = 0; i < length(); i++) { 1044 f.apply(i, vec[i]); 1045 } 1046 } 1047 1048 @Override 1049 void forEach(VectorMask<Byte> o, FUnCon f) { 1050 boolean[] mbits = ((Byte128Mask)o).getBits(); 1051 forEach((i, a) -> { 1052 if (mbits[i]) { f.apply(i, a); } 1053 }); 1054 } 1055 1056 1057 1058 @Override 1059 public Byte128Vector rotateLanesLeft(int j) { 1060 byte[] vec = getElements(); 1061 byte[] res = new byte[length()]; 1062 for (int i = 0; i < length(); i++){ 1063 res[(j + i) % length()] = vec[i]; 1064 } 1065 return new Byte128Vector(res); 1066 } 1067 1068 @Override 1069 public Byte128Vector rotateLanesRight(int j) { 1070 byte[] vec = getElements(); 1071 byte[] res = new byte[length()]; 1072 for (int i = 0; i < length(); i++){ 1073 int z = i - j; 1074 if(j < 0) { 1075 res[length() + z] = vec[i]; 1076 } else { 1077 res[z] = vec[i]; 1078 } 1079 } 1080 return new Byte128Vector(res); 1081 } 1082 1083 @Override 1084 public Byte128Vector shiftLanesLeft(int j) { 1085 byte[] vec = getElements(); 1086 byte[] res = new byte[length()]; 1087 for (int i = 0; i < length() - j; i++) { 1088 res[i] = vec[i + j]; 1089 } 1090 return new Byte128Vector(res); 1091 } 1092 1093 @Override 1094 public Byte128Vector shiftLanesRight(int j) { 1095 byte[] vec = getElements(); 1096 byte[] res = new byte[length()]; 1097 for (int i = 0; i < length() - j; i++){ 1098 res[i + j] = vec[i]; 1099 } 1100 return new Byte128Vector(res); 1101 } 1102 1103 @Override 1104 @ForceInline 1105 public Byte128Vector rearrange(Vector<Byte> v, 1106 VectorShuffle<Byte> s, VectorMask<Byte> m) { 1107 return this.rearrange(s).blend(v.rearrange(s), m); 1108 } 1109 1110 @Override 1111 @ForceInline 1112 public Byte128Vector rearrange(VectorShuffle<Byte> o1) { 1113 Objects.requireNonNull(o1); 1114 Byte128Shuffle s = (Byte128Shuffle)o1; 1115 1116 return VectorIntrinsics.rearrangeOp( 1117 Byte128Vector.class, Byte128Shuffle.class, byte.class, LENGTH, 1118 this, s, 1119 (v1, s_) -> v1.uOp((i, a) -> { 1120 int ei = s_.lane(i); 1319 super(reorder); 1320 } 1321 1322 public Byte128Shuffle(int[] reorder) { 1323 super(reorder); 1324 } 1325 1326 public Byte128Shuffle(int[] reorder, int i) { 1327 super(reorder, i); 1328 } 1329 1330 public Byte128Shuffle(IntUnaryOperator f) { 1331 super(f); 1332 } 1333 1334 @Override 1335 public VectorSpecies<Byte> species() { 1336 return SPECIES; 1337 } 1338 1339 @Override 1340 public ByteVector toVector() { 1341 byte[] va = new byte[SPECIES.length()]; 1342 for (int i = 0; i < va.length; i++) { 1343 va[i] = (byte) lane(i); 1344 } 1345 return ByteVector.fromArray(SPECIES, va, 0); 1346 } 1347 1348 @Override 1349 @ForceInline 1350 @SuppressWarnings("unchecked") 1351 public <F> VectorShuffle<F> cast(VectorSpecies<F> species) { 1352 if (length() != species.length()) 1353 throw new IllegalArgumentException("Shuffle length and species length differ"); 1354 Class<?> stype = species.elementType(); 1355 int [] shuffleArray = toArray(); 1356 if (stype == byte.class) { 1357 return (VectorShuffle<F>) new Byte128Vector.Byte128Shuffle(shuffleArray); 1358 } else if (stype == short.class) { 1359 return (VectorShuffle<F>) new Short128Vector.Short128Shuffle(shuffleArray); 1360 } else if (stype == int.class) { 1361 return (VectorShuffle<F>) new Int128Vector.Int128Shuffle(shuffleArray); 1362 } else if (stype == long.class) { 1363 return (VectorShuffle<F>) new Long128Vector.Long128Shuffle(shuffleArray); 1364 } else if (stype == float.class) { 1365 return (VectorShuffle<F>) new Float128Vector.Float128Shuffle(shuffleArray); 1366 } else if (stype == double.class) { 1367 return (VectorShuffle<F>) new Double128Vector.Double128Shuffle(shuffleArray); 1368 } else { 1369 throw new UnsupportedOperationException("Bad lane type for casting."); 1370 } 1371 } 1372 1373 @Override 1374 public Byte128Shuffle rearrange(VectorShuffle<Byte> o) { 1375 Byte128Shuffle s = (Byte128Shuffle) o; 1376 byte[] r = new byte[reorder.length]; 1377 for (int i = 0; i < reorder.length; i++) { 1378 r[i] = reorder[s.reorder[i]]; 1379 } 1380 return new Byte128Shuffle(r); 1381 } 1382 } 1383 1384 // VectorSpecies 1385 1386 @Override 1387 public VectorSpecies<Byte> species() { 1388 return SPECIES; 1389 } 1390 } | 1039 1040 @Override 1041 void forEach(FUnCon f) { 1042 byte[] vec = getElements(); 1043 for (int i = 0; i < length(); i++) { 1044 f.apply(i, vec[i]); 1045 } 1046 } 1047 1048 @Override 1049 void forEach(VectorMask<Byte> o, FUnCon f) { 1050 boolean[] mbits = ((Byte128Mask)o).getBits(); 1051 forEach((i, a) -> { 1052 if (mbits[i]) { f.apply(i, a); } 1053 }); 1054 } 1055 1056 1057 1058 @Override 1059 @ForceInline 1060 public Byte128Vector rotateLanesLeft(int j) { 1061 int L = length(); 1062 if (j < 0) { 1063 throw new IllegalArgumentException("Index " + j + " must be zero or positive"); 1064 } else { 1065 j = j & (L-1); 1066 VectorShuffle<Byte> PermMask = VectorShuffle.shuffleIota(SPECIES, L - j); 1067 return this.rearrange(PermMask); 1068 } 1069 } 1070 1071 @Override 1072 @ForceInline 1073 public Byte128Vector rotateLanesRight(int j) { 1074 int L = length(); 1075 if (j < 0) { 1076 throw new IllegalArgumentException("Index " + j + " must be zero or positive"); 1077 } else { 1078 j = j & (L-1); 1079 VectorShuffle<Byte> PermMask = VectorShuffle.shuffleIota(SPECIES, j); 1080 return this.rearrange(PermMask); 1081 } 1082 } 1083 1084 @Override 1085 @ForceInline 1086 @SuppressWarnings("unchecked") 1087 public Byte128Vector shiftLanesLeft(int j) { 1088 int L = length(); 1089 if (j < 0) { 1090 throw new IllegalArgumentException("Index " + j + " must be zero or positive"); 1091 } else if ( j >= L ) { 1092 return ZERO; 1093 } else { 1094 Byte128Shuffle Iota = (Byte128Shuffle)(VectorShuffle.shuffleIota(SPECIES, L-j)); 1095 VectorMask<Byte> BlendMask = Iota.toVector().lessThan(Byte128Vector.broadcast(SPECIES, (byte)(L-j))); 1096 Iota = (Byte128Shuffle)(VectorShuffle.shuffleIota(SPECIES, L -j)); 1097 return ZERO.blend(this.rearrange(Iota),BlendMask); 1098 } 1099 } 1100 1101 @Override 1102 @ForceInline 1103 @SuppressWarnings("unchecked") 1104 public Byte128Vector shiftLanesRight(int j) { 1105 int L = length(); 1106 if (j < 0) { 1107 throw new IllegalArgumentException("Index " + j + " must be zero or positive"); 1108 } else if ( j >= L ) { 1109 return ZERO; 1110 } else { 1111 Byte128Shuffle Iota = (Byte128Shuffle)(VectorShuffle.shuffleIota(SPECIES, j)); 1112 VectorMask<Byte> BlendMask = Iota.toVector().greaterThanEq(Byte128Vector.broadcast(SPECIES, (byte)(j))); 1113 Iota = (Byte128Shuffle)(VectorShuffle.shuffleIota(SPECIES, j)); 1114 return ZERO.blend(this.rearrange(Iota),BlendMask); 1115 } 1116 } 1117 1118 @Override 1119 @ForceInline 1120 public Byte128Vector rearrange(Vector<Byte> v, 1121 VectorShuffle<Byte> s, VectorMask<Byte> m) { 1122 return this.rearrange(s).blend(v.rearrange(s), m); 1123 } 1124 1125 @Override 1126 @ForceInline 1127 public Byte128Vector rearrange(VectorShuffle<Byte> o1) { 1128 Objects.requireNonNull(o1); 1129 Byte128Shuffle s = (Byte128Shuffle)o1; 1130 1131 return VectorIntrinsics.rearrangeOp( 1132 Byte128Vector.class, Byte128Shuffle.class, byte.class, LENGTH, 1133 this, s, 1134 (v1, s_) -> v1.uOp((i, a) -> { 1135 int ei = s_.lane(i); 1334 super(reorder); 1335 } 1336 1337 public Byte128Shuffle(int[] reorder) { 1338 super(reorder); 1339 } 1340 1341 public Byte128Shuffle(int[] reorder, int i) { 1342 super(reorder, i); 1343 } 1344 1345 public Byte128Shuffle(IntUnaryOperator f) { 1346 super(f); 1347 } 1348 1349 @Override 1350 public VectorSpecies<Byte> species() { 1351 return SPECIES; 1352 } 1353 1354 private ByteVector toVector_helper() { 1355 byte[] va = new byte[SPECIES.length()]; 1356 for (int i = 0; i < va.length; i++) { 1357 va[i] = (byte) lane(i); 1358 } 1359 return ByteVector.fromArray(SPECIES, va, 0); 1360 } 1361 1362 @Override 1363 @ForceInline 1364 public ByteVector toVector() { 1365 return VectorIntrinsics.shuffleToVector(Byte128Vector.class, byte.class, Byte128Shuffle.class, this, 1366 SPECIES.length(), 1367 (s) -> (((Byte128Shuffle)(s)).toVector_helper())); 1368 } 1369 1370 @Override 1371 @ForceInline 1372 @SuppressWarnings("unchecked") 1373 public <F> VectorShuffle<F> cast(VectorSpecies<F> species) { 1374 if (length() != species.length()) 1375 throw new IllegalArgumentException("Shuffle length and species length differ"); 1376 Class<?> stype = species.elementType(); 1377 int [] shuffleArray = toArray(); 1378 if (stype == byte.class) { 1379 return (VectorShuffle<F>) new Byte128Vector.Byte128Shuffle(shuffleArray); 1380 } else if (stype == short.class) { 1381 return (VectorShuffle<F>) new Short128Vector.Short128Shuffle(shuffleArray); 1382 } else if (stype == int.class) { 1383 return (VectorShuffle<F>) new Int128Vector.Int128Shuffle(shuffleArray); 1384 } else if (stype == long.class) { 1385 return (VectorShuffle<F>) new Long128Vector.Long128Shuffle(shuffleArray); 1386 } else if (stype == float.class) { 1387 return (VectorShuffle<F>) new Float128Vector.Float128Shuffle(shuffleArray); 1388 } else if (stype == double.class) { 1389 return (VectorShuffle<F>) new Double128Vector.Double128Shuffle(shuffleArray); 1390 } else { 1391 throw new UnsupportedOperationException("Bad lane type for casting."); 1392 } 1393 } 1394 1395 1396 @Override 1397 public Byte128Shuffle rearrange(VectorShuffle<Byte> o) { 1398 Byte128Shuffle s = (Byte128Shuffle) o; 1399 byte[] r = new byte[reorder.length]; 1400 for (int i = 0; i < reorder.length; i++) { 1401 r[i] = reorder[s.reorder[i]]; 1402 } 1403 return new Byte128Shuffle(r); 1404 } 1405 } 1406 1407 // VectorSpecies 1408 1409 @Override 1410 public VectorSpecies<Byte> species() { 1411 return SPECIES; 1412 } 1413 } |