< prev index next >

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java

Print this page
rev 50140 : Vector cast support

*** 1021,1030 **** --- 1021,1274 ---- @ForceInline public Byte64Vector fromArray(byte[] a, int ax, Mask<Byte, Shapes.S64Bit> m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private <S extends Shape> Byte64Vector castFromByte(ByteVector<S> o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private <S extends Shape> Byte64Vector castFromShort(ShortVector<S> o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private <S extends Shape> Byte64Vector castFromInt(IntVector<S> o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private <S extends Shape> Byte64Vector castFromLong(LongVector<S> o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private <S extends Shape> Byte64Vector castFromFloat(FloatVector<S> o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private <S extends Shape> Byte64Vector castFromDouble(DoubleVector<S> o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public <E, S extends Shape> Byte64Vector cast(Vector<E, S> o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector<S> so = (ByteVector<S>)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector<S> so = (ShortVector<S>)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector<S> so = (IntVector<S>)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector<S> so = (LongVector<S>)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector<S> so = (FloatVector<S>)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector<S> so = (DoubleVector<S>)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") public <F> Byte64Vector rebracket(Vector<F, Shapes.S64Bit> o) { Objects.requireNonNull(o);
*** 1069,1079 **** Double64Vector.class, double.class, so.length(), byte.class, LENGTH, so, (v, t) -> (Byte64Vector)reshape(v) ); } else { ! throw new InternalError("Unimplemented size"); } } @Override @ForceInline --- 1313,1323 ---- Double64Vector.class, double.class, so.length(), byte.class, LENGTH, so, (v, t) -> (Byte64Vector)reshape(v) ); } else { ! throw new InternalError("Unimplemented type"); } } @Override @ForceInline
< prev index next >