1107 0,
1108 (z -> Int256Mask.FALSE_MASK));
1109 }
1110
1111 @Override
1112 @ForceInline
1113 public Int256Vector fromArray(int[] a, int ix) {
1114 Objects.requireNonNull(a);
1115 ix = VectorIntrinsics.checkIndex(ix, a.length, LENGTH);
1116 return (Int256Vector) VectorIntrinsics.load(Int256Vector.class, int.class, LENGTH,
1117 a, ix,
1118 (arr, idx) -> super.fromArray((int[]) arr, idx));
1119 }
1120
1121 @Override
1122 @ForceInline
1123 public Int256Vector fromArray(int[] a, int ax, Mask<Integer, Shapes.S256Bit> m) {
1124 return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]);
1125 }
1126
1127 @Override
1128 @ForceInline
1129 @SuppressWarnings("unchecked")
1130 public <F> Int256Vector rebracket(Vector<F, Shapes.S256Bit> o) {
1131 Objects.requireNonNull(o);
1132 if (o.elementType() == byte.class) {
1133 Byte256Vector so = (Byte256Vector)o;
1134 return VectorIntrinsics.reinterpret(
1135 Byte256Vector.class, byte.class, so.length(),
1136 int.class, LENGTH, so,
1137 (v, t) -> (Int256Vector)reshape(v)
1138 );
1139 } else if (o.elementType() == short.class) {
1140 Short256Vector so = (Short256Vector)o;
1141 return VectorIntrinsics.reinterpret(
1142 Short256Vector.class, short.class, so.length(),
1143 int.class, LENGTH, so,
1144 (v, t) -> (Int256Vector)reshape(v)
1145 );
1146 } else if (o.elementType() == int.class) {
1155 return VectorIntrinsics.reinterpret(
1156 Long256Vector.class, long.class, so.length(),
1157 int.class, LENGTH, so,
1158 (v, t) -> (Int256Vector)reshape(v)
1159 );
1160 } else if (o.elementType() == float.class) {
1161 Float256Vector so = (Float256Vector)o;
1162 return VectorIntrinsics.reinterpret(
1163 Float256Vector.class, float.class, so.length(),
1164 int.class, LENGTH, so,
1165 (v, t) -> (Int256Vector)reshape(v)
1166 );
1167 } else if (o.elementType() == double.class) {
1168 Double256Vector so = (Double256Vector)o;
1169 return VectorIntrinsics.reinterpret(
1170 Double256Vector.class, double.class, so.length(),
1171 int.class, LENGTH, so,
1172 (v, t) -> (Int256Vector)reshape(v)
1173 );
1174 } else {
1175 throw new InternalError("Unimplemented size");
1176 }
1177 }
1178
1179 @Override
1180 @ForceInline
1181 @SuppressWarnings("unchecked")
1182 public <T extends Shape> Int256Vector resize(Vector<Integer, T> o) {
1183 Objects.requireNonNull(o);
1184 if (o.bitSize() == 64) {
1185 Int64Vector so = (Int64Vector)o;
1186 return VectorIntrinsics.reinterpret(
1187 Int64Vector.class, int.class, so.length(),
1188 int.class, LENGTH, so,
1189 (v, t) -> (Int256Vector)reshape(v)
1190 );
1191 } else if (o.bitSize() == 128) {
1192 Int128Vector so = (Int128Vector)o;
1193 return VectorIntrinsics.reinterpret(
1194 Int128Vector.class, int.class, so.length(),
1195 int.class, LENGTH, so,
|
1107 0,
1108 (z -> Int256Mask.FALSE_MASK));
1109 }
1110
1111 @Override
1112 @ForceInline
1113 public Int256Vector fromArray(int[] a, int ix) {
1114 Objects.requireNonNull(a);
1115 ix = VectorIntrinsics.checkIndex(ix, a.length, LENGTH);
1116 return (Int256Vector) VectorIntrinsics.load(Int256Vector.class, int.class, LENGTH,
1117 a, ix,
1118 (arr, idx) -> super.fromArray((int[]) arr, idx));
1119 }
1120
1121 @Override
1122 @ForceInline
1123 public Int256Vector fromArray(int[] a, int ax, Mask<Integer, Shapes.S256Bit> m) {
1124 return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]);
1125 }
1126
1127 @ForceInline
1128 @SuppressWarnings("unchecked")
1129 private <S extends Shape> Int256Vector castFromByte(ByteVector<S> o) {
1130 if (o.bitSize() == 64) {
1131 Byte64Vector so = (Byte64Vector)o;
1132 return VectorIntrinsics.cast(
1133 Byte64Vector.class, byte.class, so.length(),
1134 int.class, LENGTH, so,
1135 (v, t) -> (Int256Vector)super.cast(v)
1136 );
1137 } else if (o.bitSize() == 128) {
1138 Byte128Vector so = (Byte128Vector)o;
1139 return VectorIntrinsics.cast(
1140 Byte128Vector.class, byte.class, so.length(),
1141 int.class, LENGTH, so,
1142 (v, t) -> (Int256Vector)super.cast(v)
1143 );
1144 } else if (o.bitSize() == 256) {
1145 Byte256Vector so = (Byte256Vector)o;
1146 return VectorIntrinsics.cast(
1147 Byte256Vector.class, byte.class, so.length(),
1148 int.class, LENGTH, so,
1149 (v, t) -> (Int256Vector)super.cast(v)
1150 );
1151 } else if (o.bitSize() == 512) {
1152 Byte512Vector so = (Byte512Vector)o;
1153 return VectorIntrinsics.cast(
1154 Byte512Vector.class, byte.class, so.length(),
1155 int.class, LENGTH, so,
1156 (v, t) -> (Int256Vector)super.cast(v)
1157 );
1158 } else {
1159 throw new InternalError("Unimplemented size");
1160 }
1161 }
1162
1163 @ForceInline
1164 @SuppressWarnings("unchecked")
1165 private <S extends Shape> Int256Vector castFromShort(ShortVector<S> o) {
1166 if (o.bitSize() == 64) {
1167 Short64Vector so = (Short64Vector)o;
1168 return VectorIntrinsics.cast(
1169 Short64Vector.class, short.class, so.length(),
1170 int.class, LENGTH, so,
1171 (v, t) -> (Int256Vector)super.cast(v)
1172 );
1173 } else if (o.bitSize() == 128) {
1174 Short128Vector so = (Short128Vector)o;
1175 return VectorIntrinsics.cast(
1176 Short128Vector.class, short.class, so.length(),
1177 int.class, LENGTH, so,
1178 (v, t) -> (Int256Vector)super.cast(v)
1179 );
1180 } else if (o.bitSize() == 256) {
1181 Short256Vector so = (Short256Vector)o;
1182 return VectorIntrinsics.cast(
1183 Short256Vector.class, short.class, so.length(),
1184 int.class, LENGTH, so,
1185 (v, t) -> (Int256Vector)super.cast(v)
1186 );
1187 } else if (o.bitSize() == 512) {
1188 Short512Vector so = (Short512Vector)o;
1189 return VectorIntrinsics.cast(
1190 Short512Vector.class, short.class, so.length(),
1191 int.class, LENGTH, so,
1192 (v, t) -> (Int256Vector)super.cast(v)
1193 );
1194 } else {
1195 throw new InternalError("Unimplemented size");
1196 }
1197 }
1198
1199 @ForceInline
1200 @SuppressWarnings("unchecked")
1201 private <S extends Shape> Int256Vector castFromInt(IntVector<S> o) {
1202 if (o.bitSize() == 64) {
1203 Int64Vector so = (Int64Vector)o;
1204 return VectorIntrinsics.cast(
1205 Int64Vector.class, int.class, so.length(),
1206 int.class, LENGTH, so,
1207 (v, t) -> (Int256Vector)super.cast(v)
1208 );
1209 } else if (o.bitSize() == 128) {
1210 Int128Vector so = (Int128Vector)o;
1211 return VectorIntrinsics.cast(
1212 Int128Vector.class, int.class, so.length(),
1213 int.class, LENGTH, so,
1214 (v, t) -> (Int256Vector)super.cast(v)
1215 );
1216 } else if (o.bitSize() == 256) {
1217 Int256Vector so = (Int256Vector)o;
1218 return VectorIntrinsics.cast(
1219 Int256Vector.class, int.class, so.length(),
1220 int.class, LENGTH, so,
1221 (v, t) -> (Int256Vector)super.cast(v)
1222 );
1223 } else if (o.bitSize() == 512) {
1224 Int512Vector so = (Int512Vector)o;
1225 return VectorIntrinsics.cast(
1226 Int512Vector.class, int.class, so.length(),
1227 int.class, LENGTH, so,
1228 (v, t) -> (Int256Vector)super.cast(v)
1229 );
1230 } else {
1231 throw new InternalError("Unimplemented size");
1232 }
1233 }
1234
1235 @ForceInline
1236 @SuppressWarnings("unchecked")
1237 private <S extends Shape> Int256Vector castFromLong(LongVector<S> o) {
1238 if (o.bitSize() == 64) {
1239 Long64Vector so = (Long64Vector)o;
1240 return VectorIntrinsics.cast(
1241 Long64Vector.class, long.class, so.length(),
1242 int.class, LENGTH, so,
1243 (v, t) -> (Int256Vector)super.cast(v)
1244 );
1245 } else if (o.bitSize() == 128) {
1246 Long128Vector so = (Long128Vector)o;
1247 return VectorIntrinsics.cast(
1248 Long128Vector.class, long.class, so.length(),
1249 int.class, LENGTH, so,
1250 (v, t) -> (Int256Vector)super.cast(v)
1251 );
1252 } else if (o.bitSize() == 256) {
1253 Long256Vector so = (Long256Vector)o;
1254 return VectorIntrinsics.cast(
1255 Long256Vector.class, long.class, so.length(),
1256 int.class, LENGTH, so,
1257 (v, t) -> (Int256Vector)super.cast(v)
1258 );
1259 } else if (o.bitSize() == 512) {
1260 Long512Vector so = (Long512Vector)o;
1261 return VectorIntrinsics.cast(
1262 Long512Vector.class, long.class, so.length(),
1263 int.class, LENGTH, so,
1264 (v, t) -> (Int256Vector)super.cast(v)
1265 );
1266 } else {
1267 throw new InternalError("Unimplemented size");
1268 }
1269 }
1270
1271 @ForceInline
1272 @SuppressWarnings("unchecked")
1273 private <S extends Shape> Int256Vector castFromFloat(FloatVector<S> o) {
1274 if (o.bitSize() == 64) {
1275 Float64Vector so = (Float64Vector)o;
1276 return VectorIntrinsics.cast(
1277 Float64Vector.class, float.class, so.length(),
1278 int.class, LENGTH, so,
1279 (v, t) -> (Int256Vector)super.cast(v)
1280 );
1281 } else if (o.bitSize() == 128) {
1282 Float128Vector so = (Float128Vector)o;
1283 return VectorIntrinsics.cast(
1284 Float128Vector.class, float.class, so.length(),
1285 int.class, LENGTH, so,
1286 (v, t) -> (Int256Vector)super.cast(v)
1287 );
1288 } else if (o.bitSize() == 256) {
1289 Float256Vector so = (Float256Vector)o;
1290 return VectorIntrinsics.cast(
1291 Float256Vector.class, float.class, so.length(),
1292 int.class, LENGTH, so,
1293 (v, t) -> (Int256Vector)super.cast(v)
1294 );
1295 } else if (o.bitSize() == 512) {
1296 Float512Vector so = (Float512Vector)o;
1297 return VectorIntrinsics.cast(
1298 Float512Vector.class, float.class, so.length(),
1299 int.class, LENGTH, so,
1300 (v, t) -> (Int256Vector)super.cast(v)
1301 );
1302 } else {
1303 throw new InternalError("Unimplemented size");
1304 }
1305 }
1306
1307 @ForceInline
1308 @SuppressWarnings("unchecked")
1309 private <S extends Shape> Int256Vector castFromDouble(DoubleVector<S> o) {
1310 if (o.bitSize() == 64) {
1311 Double64Vector so = (Double64Vector)o;
1312 return VectorIntrinsics.cast(
1313 Double64Vector.class, double.class, so.length(),
1314 int.class, LENGTH, so,
1315 (v, t) -> (Int256Vector)super.cast(v)
1316 );
1317 } else if (o.bitSize() == 128) {
1318 Double128Vector so = (Double128Vector)o;
1319 return VectorIntrinsics.cast(
1320 Double128Vector.class, double.class, so.length(),
1321 int.class, LENGTH, so,
1322 (v, t) -> (Int256Vector)super.cast(v)
1323 );
1324 } else if (o.bitSize() == 256) {
1325 Double256Vector so = (Double256Vector)o;
1326 return VectorIntrinsics.cast(
1327 Double256Vector.class, double.class, so.length(),
1328 int.class, LENGTH, so,
1329 (v, t) -> (Int256Vector)super.cast(v)
1330 );
1331 } else if (o.bitSize() == 512) {
1332 Double512Vector so = (Double512Vector)o;
1333 return VectorIntrinsics.cast(
1334 Double512Vector.class, double.class, so.length(),
1335 int.class, LENGTH, so,
1336 (v, t) -> (Int256Vector)super.cast(v)
1337 );
1338 } else {
1339 throw new InternalError("Unimplemented size");
1340 }
1341 }
1342
1343 @Override
1344 @ForceInline
1345 @SuppressWarnings("unchecked")
1346 public <E, S extends Shape> Int256Vector cast(Vector<E, S> o) {
1347 Objects.requireNonNull(o);
1348 if (o.elementType() == byte.class) {
1349 ByteVector<S> so = (ByteVector<S>)o;
1350 return castFromByte(so);
1351 } else if (o.elementType() == short.class) {
1352 ShortVector<S> so = (ShortVector<S>)o;
1353 return castFromShort(so);
1354 } else if (o.elementType() == int.class) {
1355 IntVector<S> so = (IntVector<S>)o;
1356 return castFromInt(so);
1357 } else if (o.elementType() == long.class) {
1358 LongVector<S> so = (LongVector<S>)o;
1359 return castFromLong(so);
1360 } else if (o.elementType() == float.class) {
1361 FloatVector<S> so = (FloatVector<S>)o;
1362 return castFromFloat(so);
1363 } else if (o.elementType() == double.class) {
1364 DoubleVector<S> so = (DoubleVector<S>)o;
1365 return castFromDouble(so);
1366 } else {
1367 throw new InternalError("Unimplemented type");
1368 }
1369 }
1370
1371 @Override
1372 @ForceInline
1373 @SuppressWarnings("unchecked")
1374 public <F> Int256Vector rebracket(Vector<F, Shapes.S256Bit> o) {
1375 Objects.requireNonNull(o);
1376 if (o.elementType() == byte.class) {
1377 Byte256Vector so = (Byte256Vector)o;
1378 return VectorIntrinsics.reinterpret(
1379 Byte256Vector.class, byte.class, so.length(),
1380 int.class, LENGTH, so,
1381 (v, t) -> (Int256Vector)reshape(v)
1382 );
1383 } else if (o.elementType() == short.class) {
1384 Short256Vector so = (Short256Vector)o;
1385 return VectorIntrinsics.reinterpret(
1386 Short256Vector.class, short.class, so.length(),
1387 int.class, LENGTH, so,
1388 (v, t) -> (Int256Vector)reshape(v)
1389 );
1390 } else if (o.elementType() == int.class) {
1399 return VectorIntrinsics.reinterpret(
1400 Long256Vector.class, long.class, so.length(),
1401 int.class, LENGTH, so,
1402 (v, t) -> (Int256Vector)reshape(v)
1403 );
1404 } else if (o.elementType() == float.class) {
1405 Float256Vector so = (Float256Vector)o;
1406 return VectorIntrinsics.reinterpret(
1407 Float256Vector.class, float.class, so.length(),
1408 int.class, LENGTH, so,
1409 (v, t) -> (Int256Vector)reshape(v)
1410 );
1411 } else if (o.elementType() == double.class) {
1412 Double256Vector so = (Double256Vector)o;
1413 return VectorIntrinsics.reinterpret(
1414 Double256Vector.class, double.class, so.length(),
1415 int.class, LENGTH, so,
1416 (v, t) -> (Int256Vector)reshape(v)
1417 );
1418 } else {
1419 throw new InternalError("Unimplemented type");
1420 }
1421 }
1422
1423 @Override
1424 @ForceInline
1425 @SuppressWarnings("unchecked")
1426 public <T extends Shape> Int256Vector resize(Vector<Integer, T> o) {
1427 Objects.requireNonNull(o);
1428 if (o.bitSize() == 64) {
1429 Int64Vector so = (Int64Vector)o;
1430 return VectorIntrinsics.reinterpret(
1431 Int64Vector.class, int.class, so.length(),
1432 int.class, LENGTH, so,
1433 (v, t) -> (Int256Vector)reshape(v)
1434 );
1435 } else if (o.bitSize() == 128) {
1436 Int128Vector so = (Int128Vector)o;
1437 return VectorIntrinsics.reinterpret(
1438 Int128Vector.class, int.class, so.length(),
1439 int.class, LENGTH, so,
|