< prev index next >
src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java
Print this page
rev 55589 : Species-phase2
rev 55591 : XxxSpecies made package private
*** 36,58 ****
import jdk.internal.vm.annotation.ForceInline;
import static jdk.incubator.vector.VectorIntrinsics.*;
@SuppressWarnings("cast")
final class Int64Vector extends IntVector {
! static final Int64Species SPECIES = new Int64Species();
static final Int64Vector ZERO = new Int64Vector();
static final int LENGTH = SPECIES.length();
// Index vector species
! private static final IntVector.IntSpecies INDEX_SPEC;
static {
int bitSize = Vector.bitSizeForVectorLength(int.class, LENGTH);
! Vector.Shape shape = Shape.forBitSize(bitSize);
! INDEX_SPEC = (IntVector.IntSpecies) Species.of(int.class, shape);
}
private final int[] vec; // Don't access directly, use getElements() instead.
private int[] getElements() {
return VectorIntrinsics.maybeRebox(this).vec;
}
--- 36,59 ----
import jdk.internal.vm.annotation.ForceInline;
import static jdk.incubator.vector.VectorIntrinsics.*;
@SuppressWarnings("cast")
final class Int64Vector extends IntVector {
! private static final Species<Integer> SPECIES = IntVector.SPECIES_64;
static final Int64Vector ZERO = new Int64Vector();
static final int LENGTH = SPECIES.length();
// Index vector species
! private static final IntVector.IntSpecies INDEX_SPECIES;
!
static {
int bitSize = Vector.bitSizeForVectorLength(int.class, LENGTH);
! INDEX_SPECIES = (IntVector.IntSpecies) IntVector.species(Shape.forBitSize(bitSize));
}
+
private final int[] vec; // Don't access directly, use getElements() instead.
private int[] getElements() {
return VectorIntrinsics.maybeRebox(this).vec;
}
*** 160,170 ****
throw new IllegalArgumentException("Vector length this species length differ");
return VectorIntrinsics.cast(
Int64Vector.class,
int.class, LENGTH,
! s.vectorType(),
s.elementType(), LENGTH,
this, s,
(species, vector) -> vector.castDefault(species)
);
}
--- 161,171 ----
throw new IllegalArgumentException("Vector length this species length differ");
return VectorIntrinsics.cast(
Int64Vector.class,
int.class, LENGTH,
! s.boxType(),
s.elementType(), LENGTH,
this, s,
(species, vector) -> vector.castDefault(species)
);
}
*** 178,218 ****
if (stype == byte.class) {
byte[] a = new byte[limit];
for (int i = 0; i < limit; i++) {
a[i] = (byte) this.get(i);
}
! return (Vector) ByteVector.fromArray((ByteVector.ByteSpecies) s, a, 0);
} else if (stype == short.class) {
short[] a = new short[limit];
for (int i = 0; i < limit; i++) {
a[i] = (short) this.get(i);
}
! return (Vector) ShortVector.fromArray((ShortVector.ShortSpecies) s, a, 0);
} else if (stype == int.class) {
int[] a = new int[limit];
for (int i = 0; i < limit; i++) {
a[i] = (int) this.get(i);
}
! return (Vector) IntVector.fromArray((IntVector.IntSpecies) s, a, 0);
} else if (stype == long.class) {
long[] a = new long[limit];
for (int i = 0; i < limit; i++) {
a[i] = (long) this.get(i);
}
! return (Vector) LongVector.fromArray((LongVector.LongSpecies) s, a, 0);
} else if (stype == float.class) {
float[] a = new float[limit];
for (int i = 0; i < limit; i++) {
a[i] = (float) this.get(i);
}
! return (Vector) FloatVector.fromArray((FloatVector.FloatSpecies) s, a, 0);
} else if (stype == double.class) {
double[] a = new double[limit];
for (int i = 0; i < limit; i++) {
a[i] = (double) this.get(i);
}
! return (Vector) DoubleVector.fromArray((DoubleVector.DoubleSpecies) s, a, 0);
} else {
throw new UnsupportedOperationException("Bad lane type for casting.");
}
}
--- 179,219 ----
if (stype == byte.class) {
byte[] a = new byte[limit];
for (int i = 0; i < limit; i++) {
a[i] = (byte) this.get(i);
}
! return (Vector) ByteVector.fromArray((Species<Byte>) s, a, 0);
} else if (stype == short.class) {
short[] a = new short[limit];
for (int i = 0; i < limit; i++) {
a[i] = (short) this.get(i);
}
! return (Vector) ShortVector.fromArray((Species<Short>) s, a, 0);
} else if (stype == int.class) {
int[] a = new int[limit];
for (int i = 0; i < limit; i++) {
a[i] = (int) this.get(i);
}
! return (Vector) IntVector.fromArray((Species<Integer>) s, a, 0);
} else if (stype == long.class) {
long[] a = new long[limit];
for (int i = 0; i < limit; i++) {
a[i] = (long) this.get(i);
}
! return (Vector) LongVector.fromArray((Species<Long>) s, a, 0);
} else if (stype == float.class) {
float[] a = new float[limit];
for (int i = 0; i < limit; i++) {
a[i] = (float) this.get(i);
}
! return (Vector) FloatVector.fromArray((Species<Float>) s, a, 0);
} else if (stype == double.class) {
double[] a = new double[limit];
for (int i = 0; i < limit; i++) {
a[i] = (double) this.get(i);
}
! return (Vector) DoubleVector.fromArray((Species<Double>) s, a, 0);
} else {
throw new UnsupportedOperationException("Bad lane type for casting.");
}
}
*** 298,356 ****
@Override
@ForceInline
public IntVector reshape(Species<Integer> s) {
Objects.requireNonNull(s);
! if (s.bitSize() == 64 && (s instanceof Int64Vector.Int64Species)) {
! Int64Vector.Int64Species ts = (Int64Vector.Int64Species)s;
return VectorIntrinsics.reinterpret(
Int64Vector.class,
int.class, LENGTH,
Int64Vector.class,
int.class, Int64Vector.LENGTH,
! this, ts,
(species, vector) -> (IntVector) vector.defaultReinterpret(species)
);
! } else if (s.bitSize() == 128 && (s instanceof Int128Vector.Int128Species)) {
! Int128Vector.Int128Species ts = (Int128Vector.Int128Species)s;
return VectorIntrinsics.reinterpret(
Int64Vector.class,
int.class, LENGTH,
Int128Vector.class,
int.class, Int128Vector.LENGTH,
! this, ts,
(species, vector) -> (IntVector) vector.defaultReinterpret(species)
);
! } else if (s.bitSize() == 256 && (s instanceof Int256Vector.Int256Species)) {
! Int256Vector.Int256Species ts = (Int256Vector.Int256Species)s;
return VectorIntrinsics.reinterpret(
Int64Vector.class,
int.class, LENGTH,
Int256Vector.class,
int.class, Int256Vector.LENGTH,
! this, ts,
(species, vector) -> (IntVector) vector.defaultReinterpret(species)
);
! } else if (s.bitSize() == 512 && (s instanceof Int512Vector.Int512Species)) {
! Int512Vector.Int512Species ts = (Int512Vector.Int512Species)s;
return VectorIntrinsics.reinterpret(
Int64Vector.class,
int.class, LENGTH,
Int512Vector.class,
int.class, Int512Vector.LENGTH,
! this, ts,
(species, vector) -> (IntVector) vector.defaultReinterpret(species)
);
} else if ((s.bitSize() > 0) && (s.bitSize() <= 2048)
! && (s.bitSize() % 128 == 0) && (s instanceof IntMaxVector.IntMaxSpecies)) {
! IntMaxVector.IntMaxSpecies ts = (IntMaxVector.IntMaxSpecies)s;
return VectorIntrinsics.reinterpret(
Int64Vector.class,
int.class, LENGTH,
IntMaxVector.class,
int.class, IntMaxVector.LENGTH,
! this, ts,
(species, vector) -> (IntVector) vector.defaultReinterpret(species)
);
} else {
throw new InternalError("Unimplemented size");
}
--- 299,352 ----
@Override
@ForceInline
public IntVector reshape(Species<Integer> s) {
Objects.requireNonNull(s);
! if (s.bitSize() == 64 && (s.boxType() == Int64Vector.class)) {
return VectorIntrinsics.reinterpret(
Int64Vector.class,
int.class, LENGTH,
Int64Vector.class,
int.class, Int64Vector.LENGTH,
! this, s,
(species, vector) -> (IntVector) vector.defaultReinterpret(species)
);
! } else if (s.bitSize() == 128 && (s.boxType() == Int128Vector.class)) {
return VectorIntrinsics.reinterpret(
Int64Vector.class,
int.class, LENGTH,
Int128Vector.class,
int.class, Int128Vector.LENGTH,
! this, s,
(species, vector) -> (IntVector) vector.defaultReinterpret(species)
);
! } else if (s.bitSize() == 256 && (s.boxType() == Int256Vector.class)) {
return VectorIntrinsics.reinterpret(
Int64Vector.class,
int.class, LENGTH,
Int256Vector.class,
int.class, Int256Vector.LENGTH,
! this, s,
(species, vector) -> (IntVector) vector.defaultReinterpret(species)
);
! } else if (s.bitSize() == 512 && (s.boxType() == Int512Vector.class)) {
return VectorIntrinsics.reinterpret(
Int64Vector.class,
int.class, LENGTH,
Int512Vector.class,
int.class, Int512Vector.LENGTH,
! this, s,
(species, vector) -> (IntVector) vector.defaultReinterpret(species)
);
} else if ((s.bitSize() > 0) && (s.bitSize() <= 2048)
! && (s.bitSize() % 128 == 0) && (s.boxType() == IntMaxVector.class)) {
return VectorIntrinsics.reinterpret(
Int64Vector.class,
int.class, LENGTH,
IntMaxVector.class,
int.class, IntMaxVector.LENGTH,
! this, s,
(species, vector) -> (IntVector) vector.defaultReinterpret(species)
);
} else {
throw new InternalError("Unimplemented size");
}
*** 359,490 ****
// Binary operations with scalars
@Override
@ForceInline
public IntVector add(int o) {
! return add(SPECIES.broadcast(o));
}
@Override
@ForceInline
public IntVector add(int o, Mask<Integer> m) {
! return add(SPECIES.broadcast(o), m);
}
@Override
@ForceInline
public IntVector sub(int o) {
! return sub(SPECIES.broadcast(o));
}
@Override
@ForceInline
public IntVector sub(int o, Mask<Integer> m) {
! return sub(SPECIES.broadcast(o), m);
}
@Override
@ForceInline
public IntVector mul(int o) {
! return mul(SPECIES.broadcast(o));
}
@Override
@ForceInline
public IntVector mul(int o, Mask<Integer> m) {
! return mul(SPECIES.broadcast(o), m);
}
@Override
@ForceInline
public IntVector min(int o) {
! return min(SPECIES.broadcast(o));
}
@Override
@ForceInline
public IntVector max(int o) {
! return max(SPECIES.broadcast(o));
}
@Override
@ForceInline
public Mask<Integer> equal(int o) {
! return equal(SPECIES.broadcast(o));
}
@Override
@ForceInline
public Mask<Integer> notEqual(int o) {
! return notEqual(SPECIES.broadcast(o));
}
@Override
@ForceInline
public Mask<Integer> lessThan(int o) {
! return lessThan(SPECIES.broadcast(o));
}
@Override
@ForceInline
public Mask<Integer> lessThanEq(int o) {
! return lessThanEq(SPECIES.broadcast(o));
}
@Override
@ForceInline
public Mask<Integer> greaterThan(int o) {
! return greaterThan(SPECIES.broadcast(o));
}
@Override
@ForceInline
public Mask<Integer> greaterThanEq(int o) {
! return greaterThanEq(SPECIES.broadcast(o));
}
@Override
@ForceInline
public IntVector blend(int o, Mask<Integer> m) {
! return blend(SPECIES.broadcast(o), m);
}
@Override
@ForceInline
public IntVector and(int o) {
! return and(SPECIES.broadcast(o));
}
@Override
@ForceInline
public IntVector and(int o, Mask<Integer> m) {
! return and(SPECIES.broadcast(o), m);
}
@Override
@ForceInline
public IntVector or(int o) {
! return or(SPECIES.broadcast(o));
}
@Override
@ForceInline
public IntVector or(int o, Mask<Integer> m) {
! return or(SPECIES.broadcast(o), m);
}
@Override
@ForceInline
public IntVector xor(int o) {
! return xor(SPECIES.broadcast(o));
}
@Override
@ForceInline
public IntVector xor(int o, Mask<Integer> m) {
! return xor(SPECIES.broadcast(o), m);
}
@Override
@ForceInline
public Int64Vector neg() {
--- 355,486 ----
// Binary operations with scalars
@Override
@ForceInline
public IntVector add(int o) {
! return add((Int64Vector)IntVector.broadcast(SPECIES, o));
}
@Override
@ForceInline
public IntVector add(int o, Mask<Integer> m) {
! return add((Int64Vector)IntVector.broadcast(SPECIES, o), m);
}
@Override
@ForceInline
public IntVector sub(int o) {
! return sub((Int64Vector)IntVector.broadcast(SPECIES, o));
}
@Override
@ForceInline
public IntVector sub(int o, Mask<Integer> m) {
! return sub((Int64Vector)IntVector.broadcast(SPECIES, o), m);
}
@Override
@ForceInline
public IntVector mul(int o) {
! return mul((Int64Vector)IntVector.broadcast(SPECIES, o));
}
@Override
@ForceInline
public IntVector mul(int o, Mask<Integer> m) {
! return mul((Int64Vector)IntVector.broadcast(SPECIES, o), m);
}
@Override
@ForceInline
public IntVector min(int o) {
! return min((Int64Vector)IntVector.broadcast(SPECIES, o));
}
@Override
@ForceInline
public IntVector max(int o) {
! return max((Int64Vector)IntVector.broadcast(SPECIES, o));
}
@Override
@ForceInline
public Mask<Integer> equal(int o) {
! return equal((Int64Vector)IntVector.broadcast(SPECIES, o));
}
@Override
@ForceInline
public Mask<Integer> notEqual(int o) {
! return notEqual((Int64Vector)IntVector.broadcast(SPECIES, o));
}
@Override
@ForceInline
public Mask<Integer> lessThan(int o) {
! return lessThan((Int64Vector)IntVector.broadcast(SPECIES, o));
}
@Override
@ForceInline
public Mask<Integer> lessThanEq(int o) {
! return lessThanEq((Int64Vector)IntVector.broadcast(SPECIES, o));
}
@Override
@ForceInline
public Mask<Integer> greaterThan(int o) {
! return greaterThan((Int64Vector)IntVector.broadcast(SPECIES, o));
}
@Override
@ForceInline
public Mask<Integer> greaterThanEq(int o) {
! return greaterThanEq((Int64Vector)IntVector.broadcast(SPECIES, o));
}
@Override
@ForceInline
public IntVector blend(int o, Mask<Integer> m) {
! return blend((Int64Vector)IntVector.broadcast(SPECIES, o), m);
}
@Override
@ForceInline
public IntVector and(int o) {
! return and((Int64Vector)IntVector.broadcast(SPECIES, o));
}
@Override
@ForceInline
public IntVector and(int o, Mask<Integer> m) {
! return and((Int64Vector)IntVector.broadcast(SPECIES, o), m);
}
@Override
@ForceInline
public IntVector or(int o) {
! return or((Int64Vector)IntVector.broadcast(SPECIES, o));
}
@Override
@ForceInline
public IntVector or(int o, Mask<Integer> m) {
! return or((Int64Vector)IntVector.broadcast(SPECIES, o), m);
}
@Override
@ForceInline
public IntVector xor(int o) {
! return xor((Int64Vector)IntVector.broadcast(SPECIES, o));
}
@Override
@ForceInline
public IntVector xor(int o, Mask<Integer> m) {
! return xor((Int64Vector)IntVector.broadcast(SPECIES, o), m);
}
@Override
@ForceInline
public Int64Vector neg() {
*** 715,725 ****
@Override
@ForceInline
public Int64Vector shiftL(Vector<Integer> s) {
Int64Vector shiftv = (Int64Vector)s;
// As per shift specification for Java, mask the shift count.
! shiftv = shiftv.and(species().broadcast(0x1f));
return VectorIntrinsics.binaryOp(
VECTOR_OP_LSHIFT, Int64Vector.class, int.class, LENGTH,
this, shiftv,
(v1, v2) -> v1.bOp(v2,(i,a, b) -> (int) (a << b)));
}
--- 711,721 ----
@Override
@ForceInline
public Int64Vector shiftL(Vector<Integer> s) {
Int64Vector shiftv = (Int64Vector)s;
// As per shift specification for Java, mask the shift count.
! shiftv = shiftv.and(IntVector.broadcast(SPECIES, 0x1f));
return VectorIntrinsics.binaryOp(
VECTOR_OP_LSHIFT, Int64Vector.class, int.class, LENGTH,
this, shiftv,
(v1, v2) -> v1.bOp(v2,(i,a, b) -> (int) (a << b)));
}
*** 727,737 ****
@Override
@ForceInline
public Int64Vector shiftR(Vector<Integer> s) {
Int64Vector shiftv = (Int64Vector)s;
// As per shift specification for Java, mask the shift count.
! shiftv = shiftv.and(species().broadcast(0x1f));
return VectorIntrinsics.binaryOp(
VECTOR_OP_URSHIFT, Int64Vector.class, int.class, LENGTH,
this, shiftv,
(v1, v2) -> v1.bOp(v2,(i,a, b) -> (int) (a >>> b)));
}
--- 723,733 ----
@Override
@ForceInline
public Int64Vector shiftR(Vector<Integer> s) {
Int64Vector shiftv = (Int64Vector)s;
// As per shift specification for Java, mask the shift count.
! shiftv = shiftv.and(IntVector.broadcast(SPECIES, 0x1f));
return VectorIntrinsics.binaryOp(
VECTOR_OP_URSHIFT, Int64Vector.class, int.class, LENGTH,
this, shiftv,
(v1, v2) -> v1.bOp(v2,(i,a, b) -> (int) (a >>> b)));
}
*** 739,749 ****
@Override
@ForceInline
public Int64Vector aShiftR(Vector<Integer> s) {
Int64Vector shiftv = (Int64Vector)s;
// As per shift specification for Java, mask the shift count.
! shiftv = shiftv.and(species().broadcast(0x1f));
return VectorIntrinsics.binaryOp(
VECTOR_OP_RSHIFT, Int64Vector.class, int.class, LENGTH,
this, shiftv,
(v1, v2) -> v1.bOp(v2,(i,a, b) -> (int) (a >> b)));
}
--- 735,745 ----
@Override
@ForceInline
public Int64Vector aShiftR(Vector<Integer> s) {
Int64Vector shiftv = (Int64Vector)s;
// As per shift specification for Java, mask the shift count.
! shiftv = shiftv.and(IntVector.broadcast(SPECIES, 0x1f));
return VectorIntrinsics.binaryOp(
VECTOR_OP_RSHIFT, Int64Vector.class, int.class, LENGTH,
this, shiftv,
(v1, v2) -> v1.bOp(v2,(i,a, b) -> (int) (a >> b)));
}
*** 771,781 ****
}
@Override
@ForceInline
public int andAll(Mask<Integer> m) {
! return SPECIES.broadcast((int) -1).blend(this, m).andAll();
}
@Override
@ForceInline
public int minAll() {
--- 767,777 ----
}
@Override
@ForceInline
public int andAll(Mask<Integer> m) {
! return blend((Int64Vector)IntVector.broadcast(SPECIES, (int) -1), m).andAll();
}
@Override
@ForceInline
public int minAll() {
*** 813,823 ****
}
@Override
@ForceInline
public int orAll(Mask<Integer> m) {
! return SPECIES.broadcast((int) 0).blend(this, m).orAll();
}
@Override
@ForceInline
public int xorAll() {
--- 809,819 ----
}
@Override
@ForceInline
public int orAll(Mask<Integer> m) {
! return blend((Int64Vector)IntVector.broadcast(SPECIES, (int) 0), m).orAll();
}
@Override
@ForceInline
public int xorAll() {
*** 828,864 ****
}
@Override
@ForceInline
public int xorAll(Mask<Integer> m) {
! return SPECIES.broadcast((int) 0).blend(this, m).xorAll();
}
@Override
@ForceInline
public int addAll(Mask<Integer> m) {
! return SPECIES.broadcast((int) 0).blend(this, m).addAll();
}
@Override
@ForceInline
public int mulAll(Mask<Integer> m) {
! return SPECIES.broadcast((int) 1).blend(this, m).mulAll();
}
@Override
@ForceInline
public int minAll(Mask<Integer> m) {
! return SPECIES.broadcast(Integer.MAX_VALUE).blend(this, m).minAll();
}
@Override
@ForceInline
public int maxAll(Mask<Integer> m) {
! return SPECIES.broadcast(Integer.MIN_VALUE).blend(this, m).maxAll();
}
@Override
@ForceInline
public Shuffle<Integer> toShuffle() {
--- 824,860 ----
}
@Override
@ForceInline
public int xorAll(Mask<Integer> m) {
! return blend((Int64Vector)IntVector.broadcast(SPECIES, (int) 0), m).xorAll();
}
@Override
@ForceInline
public int addAll(Mask<Integer> m) {
! return blend((Int64Vector)IntVector.broadcast(SPECIES, (int) 0), m).addAll();
}
@Override
@ForceInline
public int mulAll(Mask<Integer> m) {
! return blend((Int64Vector)IntVector.broadcast(SPECIES, (int) 1), m).mulAll();
}
@Override
@ForceInline
public int minAll(Mask<Integer> m) {
! return blend((Int64Vector)IntVector.broadcast(SPECIES, Integer.MAX_VALUE), m).minAll();
}
@Override
@ForceInline
public int maxAll(Mask<Integer> m) {
! return blend((Int64Vector)IntVector.broadcast(SPECIES, Integer.MIN_VALUE), m).maxAll();
}
@Override
@ForceInline
public Shuffle<Integer> toShuffle() {
*** 899,909 ****
public void intoArray(int[] a, int ix, int[] b, int iy) {
Objects.requireNonNull(a);
Objects.requireNonNull(b);
// Index vector: vix[0:n] = i -> ix + indexMap[iy + i]
! IntVector vix = IntVector.fromArray(INDEX_SPEC, b, iy).add(ix);
vix = VectorIntrinsics.checkIndex(vix, a.length);
VectorIntrinsics.storeWithMap(Int64Vector.class, int.class, LENGTH, Int64Vector.class,
a, Unsafe.ARRAY_INT_BASE_OFFSET, vix,
--- 895,905 ----
public void intoArray(int[] a, int ix, int[] b, int iy) {
Objects.requireNonNull(a);
Objects.requireNonNull(b);
// Index vector: vix[0:n] = i -> ix + indexMap[iy + i]
! IntVector vix = IntVector.fromArray(INDEX_SPECIES, b, iy).add(ix);
vix = VectorIntrinsics.checkIndex(vix, a.length);
VectorIntrinsics.storeWithMap(Int64Vector.class, int.class, LENGTH, Int64Vector.class,
a, Unsafe.ARRAY_INT_BASE_OFFSET, vix,
*** 1272,1282 ****
}
return new Int64Mask(res);
}
@Override
! public Int64Species species() {
return SPECIES;
}
@Override
public Int64Vector toVector() {
--- 1268,1278 ----
}
return new Int64Mask(res);
}
@Override
! public Species<Integer> species() {
return SPECIES;
}
@Override
public Int64Vector toVector() {
*** 1288,1297 ****
--- 1284,1318 ----
res[i] = (int) (bits[i] ? -1 : 0);
}
return new Int64Vector(res);
}
+ @Override
+ @ForceInline
+ @SuppressWarnings("unchecked")
+ public <E> Mask<E> cast(Species<E> species) {
+ if (length() != species.length())
+ throw new IllegalArgumentException("Mask length and species length differ");
+ Class<?> stype = species.elementType();
+ boolean [] maskArray = toArray();
+ if (stype == byte.class) {
+ return (Mask <E>) new Byte64Vector.Byte64Mask(maskArray);
+ } else if (stype == short.class) {
+ return (Mask <E>) new Short64Vector.Short64Mask(maskArray);
+ } else if (stype == int.class) {
+ return (Mask <E>) new Int64Vector.Int64Mask(maskArray);
+ } else if (stype == long.class) {
+ return (Mask <E>) new Long64Vector.Long64Mask(maskArray);
+ } else if (stype == float.class) {
+ return (Mask <E>) new Float64Vector.Float64Mask(maskArray);
+ } else if (stype == double.class) {
+ return (Mask <E>) new Double64Vector.Double64Mask(maskArray);
+ } else {
+ throw new UnsupportedOperationException("Bad lane type for casting.");
+ }
+ }
+
// Unary operations
@Override
@ForceInline
public Int64Mask not() {
*** 1360,1370 ****
public Int64Shuffle(IntUnaryOperator f) {
super(f);
}
@Override
! public Int64Species species() {
return SPECIES;
}
@Override
public IntVector toVector() {
--- 1381,1391 ----
public Int64Shuffle(IntUnaryOperator f) {
super(f);
}
@Override
! public Species<Integer> species() {
return SPECIES;
}
@Override
public IntVector toVector() {
*** 1374,1383 ****
--- 1395,1429 ----
}
return IntVector.fromArray(SPECIES, va, 0);
}
@Override
+ @ForceInline
+ @SuppressWarnings("unchecked")
+ public <F> Shuffle<F> cast(Species<F> species) {
+ if (length() != species.length())
+ throw new IllegalArgumentException("Shuffle length and species length differ");
+ Class<?> stype = species.elementType();
+ int [] shuffleArray = toArray();
+ if (stype == byte.class) {
+ return (Shuffle<F>) new Byte64Vector.Byte64Shuffle(shuffleArray);
+ } else if (stype == short.class) {
+ return (Shuffle<F>) new Short64Vector.Short64Shuffle(shuffleArray);
+ } else if (stype == int.class) {
+ return (Shuffle<F>) new Int64Vector.Int64Shuffle(shuffleArray);
+ } else if (stype == long.class) {
+ return (Shuffle<F>) new Long64Vector.Long64Shuffle(shuffleArray);
+ } else if (stype == float.class) {
+ return (Shuffle<F>) new Float64Vector.Float64Shuffle(shuffleArray);
+ } else if (stype == double.class) {
+ return (Shuffle<F>) new Double64Vector.Double64Shuffle(shuffleArray);
+ } else {
+ throw new UnsupportedOperationException("Bad lane type for casting.");
+ }
+ }
+
+ @Override
public Int64Shuffle rearrange(Vector.Shuffle<Integer> o) {
Int64Shuffle s = (Int64Shuffle) o;
byte[] r = new byte[reorder.length];
for (int i = 0; i < reorder.length; i++) {
r[i] = reorder[s.reorder[i]];
*** 1387,1541 ****
}
// Species
@Override
! public Int64Species species() {
return SPECIES;
}
-
- static final class Int64Species extends IntSpecies {
- static final int BIT_SIZE = Shape.S_64_BIT.bitSize();
-
- static final int LENGTH = BIT_SIZE / Integer.SIZE;
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder("Shape[");
- sb.append(bitSize()).append(" bits, ");
- sb.append(length()).append(" ").append(int.class.getSimpleName()).append("s x ");
- sb.append(elementSize()).append(" bits");
- sb.append("]");
- return sb.toString();
- }
-
- @Override
- @ForceInline
- public int bitSize() {
- return BIT_SIZE;
- }
-
- @Override
- @ForceInline
- public int length() {
- return LENGTH;
- }
-
- @Override
- @ForceInline
- public Class<Integer> elementType() {
- return int.class;
- }
-
- @Override
- @ForceInline
- public Class<?> boxType() {
- return Int64Vector.class;
- }
-
- @Override
- @ForceInline
- public Class<?> maskType() {
- return Int64Mask.class;
- }
-
- @Override
- @ForceInline
- public int elementSize() {
- return Integer.SIZE;
- }
-
- @Override
- @ForceInline
- @SuppressWarnings("unchecked")
- Class<?> vectorType() {
- return Int64Vector.class;
- }
-
- @Override
- @ForceInline
- public Shape shape() {
- return Shape.S_64_BIT;
- }
-
- @Override
- IntVector.IntSpecies indexSpecies() {
- return INDEX_SPEC;
- }
-
- @Override
- Int64Vector op(FOp f) {
- int[] res = new int[length()];
- for (int i = 0; i < length(); i++) {
- res[i] = f.apply(i);
- }
- return new Int64Vector(res);
- }
-
- @Override
- Int64Vector op(Mask<Integer> o, FOp f) {
- int[] res = new int[length()];
- boolean[] mbits = ((Int64Mask)o).getBits();
- for (int i = 0; i < length(); i++) {
- if (mbits[i]) {
- res[i] = f.apply(i);
- }
- }
- return new Int64Vector(res);
- }
-
- @Override
- Int64Mask opm(FOpm f) {
- boolean[] res = new boolean[length()];
- for (int i = 0; i < length(); i++) {
- res[i] = (boolean)f.apply(i);
- }
- return new Int64Mask(res);
- }
-
- // Factories
-
- @Override
- @ForceInline
- public Int64Vector zero() {
- return VectorIntrinsics.broadcastCoerced(Int64Vector.class, int.class, LENGTH,
- 0, SPECIES,
- ((bits, s) -> ((Int64Species)s).op(i -> (int)bits)));
- }
-
- @Override
- @ForceInline
- public Int64Vector broadcast(int e) {
- return VectorIntrinsics.broadcastCoerced(
- Int64Vector.class, int.class, LENGTH,
- e, SPECIES,
- ((bits, s) -> ((Int64Species)s).op(i -> (int)bits)));
- }
-
- @Override
- @ForceInline
- public Int64Vector scalars(int... es) {
- Objects.requireNonNull(es);
- int ix = VectorIntrinsics.checkIndex(0, es.length, LENGTH);
- return VectorIntrinsics.load(Int64Vector.class, int.class, LENGTH,
- es, Unsafe.ARRAY_INT_BASE_OFFSET,
- es, ix, SPECIES,
- (c, idx, s) -> ((Int64Species)s).op(n -> c[idx + n]));
- }
-
- @Override
- @ForceInline
- public <E> Int64Mask cast(Mask<E> m) {
- if (m.length() != LENGTH)
- throw new IllegalArgumentException("Mask length this species length differ");
- return new Int64Mask(m.toArray());
- }
-
- @Override
- @ForceInline
- public <E> Int64Shuffle cast(Shuffle<E> s) {
- if (s.length() != LENGTH)
- throw new IllegalArgumentException("Shuffle length this species length differ");
- return new Int64Shuffle(s.toArray());
- }
- }
}
--- 1433,1441 ----
}
// Species
@Override
! public Species<Integer> species() {
return SPECIES;
}
}
< prev index next >