use of org.graalvm.compiler.core.common.type.PrimitiveStamp in project graal by oracle.
the class RawLoadNode method virtualize.
@Override
public void virtualize(VirtualizerTool tool) {
ValueNode alias = tool.getAlias(object());
if (alias instanceof VirtualObjectNode) {
VirtualObjectNode virtual = (VirtualObjectNode) alias;
ValueNode offsetValue = tool.getAlias(offset());
if (offsetValue.isConstant()) {
long off = offsetValue.asJavaConstant().asLong();
int entryIndex = virtual.entryIndexForOffset(tool.getArrayOffsetProvider(), off, accessKind());
if (entryIndex != -1) {
ValueNode entry = tool.getEntry(virtual, entryIndex);
JavaKind entryKind = virtual.entryKind(entryIndex);
if (entry.getStackKind() == getStackKind() || entryKind == accessKind()) {
if (!(entry.stamp(NodeView.DEFAULT).isCompatible(stamp(NodeView.DEFAULT)))) {
if (entry.stamp(NodeView.DEFAULT) instanceof PrimitiveStamp && stamp instanceof PrimitiveStamp) {
PrimitiveStamp p1 = (PrimitiveStamp) stamp;
PrimitiveStamp p2 = (PrimitiveStamp) entry.stamp(NodeView.DEFAULT);
int width1 = p1.getBits();
int width2 = p2.getBits();
if (width1 == width2) {
Node replacement = ReinterpretNode.create(p2, entry, NodeView.DEFAULT);
tool.replaceWith((ValueNode) replacement);
return;
} else {
// different bit width
return;
}
} else {
// cannot reinterpret for arbitrary objects
return;
}
}
tool.replaceWith(entry);
}
}
}
}
}
use of org.graalvm.compiler.core.common.type.PrimitiveStamp in project graal by oracle.
the class PrimitiveStampBoundaryTest method testShiftBoundaryValues.
private static void testShiftBoundaryValues(ShiftOp<?> shiftOp, HashSet<PrimitiveStamp> stamps, HashSet<IntegerStamp> shifts) {
for (PrimitiveStamp testStamp : stamps) {
if (testStamp instanceof IntegerStamp) {
IntegerStamp stamp = (IntegerStamp) testStamp;
for (IntegerStamp shiftStamp : shifts) {
IntegerStamp foldedStamp = (IntegerStamp) shiftOp.foldStamp(stamp, shiftStamp);
if (foldedStamp.isEmpty()) {
assertTrue(stamp.isEmpty() || shiftStamp.isEmpty());
continue;
}
checkShiftOperation(stamp.getBits(), shiftOp, foldedStamp, stamp.lowerBound(), shiftStamp.lowerBound());
checkShiftOperation(stamp.getBits(), shiftOp, foldedStamp, stamp.lowerBound(), shiftStamp.upperBound());
checkShiftOperation(stamp.getBits(), shiftOp, foldedStamp, stamp.upperBound(), shiftStamp.lowerBound());
checkShiftOperation(stamp.getBits(), shiftOp, foldedStamp, stamp.upperBound(), shiftStamp.upperBound());
}
}
}
}
use of org.graalvm.compiler.core.common.type.PrimitiveStamp in project graal by oracle.
the class PrimitiveStampBoundaryTest method testConvertBoundaryValues.
private static void testConvertBoundaryValues(ArithmeticOpTable.FloatConvertOp op, int bits, HashSet<PrimitiveStamp> stamps) {
for (PrimitiveStamp stamp : stamps) {
if (bits == stamp.getBits()) {
Stamp lower = boundaryStamp(stamp, false);
Stamp upper = boundaryStamp(stamp, true);
checkConvertOperation(op, op.foldStamp(stamp), lower);
checkConvertOperation(op, op.foldStamp(stamp), upper);
}
}
}
use of org.graalvm.compiler.core.common.type.PrimitiveStamp in project graal by oracle.
the class PrimitiveStampBoundaryTest method testUnaryBoundaryValues.
private static void testUnaryBoundaryValues(ArithmeticOpTable.UnaryOp<?> op, HashSet<PrimitiveStamp> stamps) {
for (PrimitiveStamp v1 : stamps) {
Stamp result = op.foldStamp(v1);
checkUnaryOperation(op, result, boundaryStamp(v1, false));
checkUnaryOperation(op, result, boundaryStamp(v1, true));
}
}
use of org.graalvm.compiler.core.common.type.PrimitiveStamp in project graal by oracle.
the class PrimitiveStampBoundaryTest method testConvertBoundaryValues.
private static void testConvertBoundaryValues(IntegerConvertOp<?> op, int inputBits, int resultBits, HashSet<PrimitiveStamp> stamps) {
for (PrimitiveStamp stamp : stamps) {
if (inputBits == stamp.getBits()) {
Stamp lower = boundaryStamp(stamp, false);
Stamp upper = boundaryStamp(stamp, true);
checkConvertOperation(op, inputBits, resultBits, op.foldStamp(inputBits, resultBits, stamp), lower);
checkConvertOperation(op, inputBits, resultBits, op.foldStamp(inputBits, resultBits, stamp), upper);
}
}
}
Aggregations