Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions src/hotspot/share/classfile/vmIntrinsics.hpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/hotspot/share/classfile/vmSymbols.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class SerializeClosure;
template(jdk_internal_vm_vector_VectorShuffle, "jdk/internal/vm/vector/VectorSupport$VectorShuffle") \
template(payload_name, "payload") \
template(ETYPE_name, "ETYPE") \
template(CTYPE_name, "CTYPE") \
template(VLENGTH_name, "VLENGTH") \
\
template(jdk_internal_vm_FillerObject, "jdk/internal/vm/FillerObject") \
Expand Down
815 changes: 496 additions & 319 deletions src/hotspot/share/opto/vectorIntrinsics.cpp

Large diffs are not rendered by default.

46 changes: 40 additions & 6 deletions src/hotspot/share/prims/vectorSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ BasicType VectorSupport::klass2bt(InstanceKlass* ik) {
assert(ik->is_subclass_of(vmClasses::vector_VectorPayload_klass()), "%s not a VectorPayload", ik->name()->as_C_string());
fieldDescriptor fd; // find_field initializes fd if found
// static final Class<?> ETYPE;
Klass* holder = ik->find_field(vmSymbols::ETYPE_name(), vmSymbols::class_signature(), &fd);
Klass* holder = ik->find_field(vmSymbols::CTYPE_name(), vmSymbols::class_signature(), &fd);

assert(holder != nullptr, "sanity");
assert(fd.is_static(), "");
Expand Down Expand Up @@ -199,13 +199,17 @@ bool VectorSupport::is_unsigned_op(jint id) {
}
}

int VectorSupport::vop2ideal(jint id, BasicType bt) {
int VectorSupport::vop2ideal(jint id, BasicType bt, int operType) {
VectorOperation vop = (VectorOperation)id;
switch (vop) {
case VECTOR_OP_ADD: {
switch (bt) {
case T_BYTE: // fall-through
case T_SHORT: // fall-through
case T_SHORT:
if (operType == VECTOR_TYPE_FP16) {
return Op_AddHF;
}
// fall-through
case T_INT: return Op_AddI;
case T_LONG: return Op_AddL;
case T_FLOAT: return Op_AddF;
Expand All @@ -217,7 +221,11 @@ int VectorSupport::vop2ideal(jint id, BasicType bt) {
case VECTOR_OP_SUB: {
switch (bt) {
case T_BYTE: // fall-through
case T_SHORT: // fall-through
case T_SHORT:
if (operType == VECTOR_TYPE_FP16) {
return Op_SubHF;
}
// fall-through
case T_INT: return Op_SubI;
case T_LONG: return Op_SubL;
case T_FLOAT: return Op_SubF;
Expand All @@ -229,7 +237,11 @@ int VectorSupport::vop2ideal(jint id, BasicType bt) {
case VECTOR_OP_MUL: {
switch (bt) {
case T_BYTE: // fall-through
case T_SHORT: // fall-through
case T_SHORT:
if (operType == VECTOR_TYPE_FP16) {
return Op_MulHF;
}
// fall-through
case T_INT: return Op_MulI;
case T_LONG: return Op_MulL;
case T_FLOAT: return Op_MulF;
Expand All @@ -241,7 +253,11 @@ int VectorSupport::vop2ideal(jint id, BasicType bt) {
case VECTOR_OP_DIV: {
switch (bt) {
case T_BYTE: // fall-through
case T_SHORT: // fall-through
case T_SHORT:
if (operType == VECTOR_TYPE_FP16) {
return Op_DivHF;
}
// fall-through
case T_INT: return Op_DivI;
case T_LONG: return Op_DivL;
case T_FLOAT: return Op_DivF;
Expand All @@ -254,6 +270,10 @@ int VectorSupport::vop2ideal(jint id, BasicType bt) {
switch (bt) {
case T_BYTE:
case T_SHORT:
if (operType == VECTOR_TYPE_FP16) {
return Op_MinHF;
}
// fall-through
case T_INT: return Op_MinI;
case T_LONG: return Op_MinL;
case T_FLOAT: return Op_MinF;
Expand All @@ -266,6 +286,10 @@ int VectorSupport::vop2ideal(jint id, BasicType bt) {
switch (bt) {
case T_BYTE:
case T_SHORT:
if (operType == VECTOR_TYPE_FP16) {
return Op_MaxHF;
}
// fall-through
case T_INT: return Op_MaxI;
case T_LONG: return Op_MaxL;
case T_FLOAT: return Op_MaxF;
Expand Down Expand Up @@ -298,6 +322,10 @@ int VectorSupport::vop2ideal(jint id, BasicType bt) {
switch (bt) {
case T_BYTE: // fall-through
case T_SHORT: // fall-through
if (operType == VECTOR_TYPE_FP16) {
return 0;
}
// fall-through
case T_INT: return Op_AbsI;
case T_LONG: return Op_AbsL;
case T_FLOAT: return Op_AbsF;
Expand All @@ -310,6 +338,10 @@ int VectorSupport::vop2ideal(jint id, BasicType bt) {
switch (bt) {
case T_BYTE: // fall-through
case T_SHORT: // fall-through
if (operType == VECTOR_TYPE_FP16) {
return 0;
}
// fall-through
case T_INT: return Op_NegI;
case T_LONG: return Op_NegL;
case T_FLOAT: return Op_NegF;
Expand Down Expand Up @@ -350,6 +382,7 @@ int VectorSupport::vop2ideal(jint id, BasicType bt) {
}
case VECTOR_OP_SQRT: {
switch (bt) {
case T_SHORT: return Op_SqrtHF;
case T_FLOAT: return Op_SqrtF;
case T_DOUBLE: return Op_SqrtD;
default: fatal("SQRT: %s", type2name(bt));
Expand All @@ -358,6 +391,7 @@ int VectorSupport::vop2ideal(jint id, BasicType bt) {
}
case VECTOR_OP_FMA: {
switch (bt) {
case T_SHORT: return Op_FmaHF;
case T_FLOAT: return Op_FmaF;
case T_DOUBLE: return Op_FmaD;
default: fatal("FMA: %s", type2name(bt));
Expand Down
9 changes: 8 additions & 1 deletion src/hotspot/share/prims/vectorSupport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,19 @@ class VectorSupport : AllStatic {
NUM_VEC_SIZES = 5
};

enum {
VECTOR_TYPE_PRIM = 1,
VECTOR_TYPE_FP16 = 2,
VECTOR_TYPE_FP8 = 3,
VECTOR_TYPE_INT8 = 4
};

enum {
MODE_BROADCAST = 0,
MODE_BITS_COERCED_LONG_TO_MASK = 1
};

static int vop2ideal(jint vop, BasicType bt);
static int vop2ideal(jint vop, BasicType bt, int operType = VECTOR_TYPE_PRIM);
static bool has_scalar_op(jint id);
static bool is_unsigned_op(jint id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,15 @@ public final class ScopedMemoryAccess {
@ForceInline
public static
<V extends VectorSupport.Vector<E>, E, S extends VectorSupport.VectorSpecies<E>>
V loadFromMemorySegment(Class<? extends V> vmClass, Class<E> e, int length,
V loadFromMemorySegment(Class<? extends V> vmClass, Class<?> c, int operType, int length,
AbstractMemorySegmentImpl msp, long offset,
S s,
VectorSupport.LoadOperation<AbstractMemorySegmentImpl, V, S> defaultImpl) {

try {
return loadFromMemorySegmentScopedInternal(
msp.sessionImpl(),
vmClass, e, length,
vmClass, c, operType, length,
msp, offset,
s,
defaultImpl);
Expand All @@ -348,14 +348,14 @@ public final class ScopedMemoryAccess {
private static
<V extends VectorSupport.Vector<E>, E, S extends VectorSupport.VectorSpecies<E>>
V loadFromMemorySegmentScopedInternal(MemorySessionImpl session,
Class<? extends V> vmClass, Class<E> e, int length,
Class<? extends V> vmClass, Class<?> c, int operType, int length,
AbstractMemorySegmentImpl msp, long offset,
S s,
VectorSupport.LoadOperation<AbstractMemorySegmentImpl, V, S> defaultImpl) {
try {
session.checkValidStateRaw();

return VectorSupport.load(vmClass, e, length,
return VectorSupport.load(vmClass, c, operType, length,
msp.unsafeGetBase(), msp.unsafeGetOffset() + offset, true,
msp, offset, s,
defaultImpl);
Expand All @@ -368,14 +368,14 @@ public final class ScopedMemoryAccess {
public static
<V extends VectorSupport.Vector<E>, E, S extends VectorSupport.VectorSpecies<E>,
M extends VectorSupport.VectorMask<E>>
V loadFromMemorySegmentMasked(Class<? extends V> vmClass, Class<M> maskClass, Class<E> e,
V loadFromMemorySegmentMasked(Class<? extends V> vmClass, Class<M> maskClass, Class<?> c, int operType,
int length, AbstractMemorySegmentImpl msp, long offset, M m, S s, int offsetInRange,
VectorSupport.LoadVectorMaskedOperation<AbstractMemorySegmentImpl, V, S, M> defaultImpl) {

try {
return loadFromMemorySegmentMaskedScopedInternal(
msp.sessionImpl(),
vmClass, maskClass, e, length,
vmClass, maskClass, c, operType, length,
msp, offset, m,
s, offsetInRange,
defaultImpl);
Expand All @@ -390,14 +390,14 @@ public final class ScopedMemoryAccess {
<V extends VectorSupport.Vector<E>, E, S extends VectorSupport.VectorSpecies<E>,
M extends VectorSupport.VectorMask<E>>
V loadFromMemorySegmentMaskedScopedInternal(MemorySessionImpl session, Class<? extends V> vmClass,
Class<M> maskClass, Class<E> e, int length,
Class<M> maskClass, Class<?> c, int operType, int length,
AbstractMemorySegmentImpl msp, long offset, M m,
S s, int offsetInRange,
VectorSupport.LoadVectorMaskedOperation<AbstractMemorySegmentImpl, V, S, M> defaultImpl) {
try {
session.checkValidStateRaw();

return VectorSupport.loadMasked(vmClass, maskClass, e, length,
return VectorSupport.loadMasked(vmClass, maskClass, c, operType, length,
msp.unsafeGetBase(), msp.unsafeGetOffset() + offset, true, m, offsetInRange,
msp, offset, s,
defaultImpl);
Expand All @@ -409,15 +409,15 @@ public final class ScopedMemoryAccess {
@ForceInline
public static
<V extends VectorSupport.Vector<E>, E>
void storeIntoMemorySegment(Class<? extends V> vmClass, Class<E> e, int length,
void storeIntoMemorySegment(Class<? extends V> vmClass, Class<?> c, int operType, int length,
V v,
AbstractMemorySegmentImpl msp, long offset,
VectorSupport.StoreVectorOperation<AbstractMemorySegmentImpl, V> defaultImpl) {

try {
storeIntoMemorySegmentScopedInternal(
msp.sessionImpl(),
vmClass, e, length,
vmClass, c, operType, length,
v,
msp, offset,
defaultImpl);
Expand All @@ -431,14 +431,14 @@ public final class ScopedMemoryAccess {
private static
<V extends VectorSupport.Vector<E>, E>
void storeIntoMemorySegmentScopedInternal(MemorySessionImpl session,
Class<? extends V> vmClass, Class<E> e, int length,
Class<? extends V> vmClass, Class<?> c, int operType, int length,
V v,
AbstractMemorySegmentImpl msp, long offset,
VectorSupport.StoreVectorOperation<AbstractMemorySegmentImpl, V> defaultImpl) {
try {
session.checkValidStateRaw();

VectorSupport.store(vmClass, e, length,
VectorSupport.store(vmClass, c, operType, length,
msp.unsafeGetBase(), msp.unsafeGetOffset() + offset, true,
v,
msp, offset,
Expand All @@ -451,15 +451,15 @@ public final class ScopedMemoryAccess {
@ForceInline
public static
<V extends VectorSupport.Vector<E>, E, M extends VectorSupport.VectorMask<E>>
void storeIntoMemorySegmentMasked(Class<? extends V> vmClass, Class<M> maskClass, Class<E> e,
int length, V v, M m,
void storeIntoMemorySegmentMasked(Class<? extends V> vmClass, Class<M> maskClass, Class<?> c,
int operType, int length, V v, M m,
AbstractMemorySegmentImpl msp, long offset,
VectorSupport.StoreVectorMaskedOperation<AbstractMemorySegmentImpl, V, M> defaultImpl) {

try {
storeIntoMemorySegmentMaskedScopedInternal(
msp.sessionImpl(),
vmClass, maskClass, e, length,
vmClass, maskClass, c, operType, length,
v, m,
msp, offset,
defaultImpl);
Expand All @@ -474,13 +474,13 @@ public final class ScopedMemoryAccess {
<V extends VectorSupport.Vector<E>, E, M extends VectorSupport.VectorMask<E>>
void storeIntoMemorySegmentMaskedScopedInternal(MemorySessionImpl session,
Class<? extends V> vmClass, Class<M> maskClass,
Class<E> e, int length, V v, M m,
Class<?> c, int operType, int length, V v, M m,
AbstractMemorySegmentImpl msp, long offset,
VectorSupport.StoreVectorMaskedOperation<AbstractMemorySegmentImpl, V, M> defaultImpl) {
try {
session.checkValidStateRaw();

VectorSupport.storeMasked(vmClass, maskClass, e, length,
VectorSupport.storeMasked(vmClass, maskClass, c, operType, length,
msp.unsafeGetBase(), msp.unsafeGetOffset() + offset, true,
v, m,
msp, offset,
Expand Down
Loading