use of org.graalvm.compiler.core.common.type.IntegerStamp in project graal by oracle.
the class ReinterpretStampDoubleToLongTest method run.
@Test
public void run() {
ParameterNode param = new ParameterNode(0, StampPair.createSingle(inputStamp));
ValueNode reinterpret = ReinterpretNode.create(JavaKind.Long, param, NodeView.DEFAULT);
IntegerStamp resultStamp = (IntegerStamp) reinterpret.stamp(NodeView.DEFAULT);
Assert.assertEquals(Long.SIZE, resultStamp.getBits());
for (long result : interestingLongs) {
double input = Double.longBitsToDouble(result);
if (inputStamp.contains(input) && !resultStamp.contains(result)) {
Assert.fail(String.format("value %f (0x%x) is in input stamp, but not in result stamp (%s)", input, result, resultStamp));
}
}
}
use of org.graalvm.compiler.core.common.type.IntegerStamp in project graal by oracle.
the class ReinterpretStampFloatToIntTest method run.
@Test
public void run() {
ParameterNode param = new ParameterNode(0, StampPair.createSingle(inputStamp));
ValueNode reinterpret = ReinterpretNode.create(JavaKind.Int, param, NodeView.DEFAULT);
reinterpret.inferStamp();
IntegerStamp resultStamp = (IntegerStamp) reinterpret.stamp(NodeView.DEFAULT);
Assert.assertEquals(Integer.SIZE, resultStamp.getBits());
for (int result : interestingInts) {
float input = Float.intBitsToFloat(result);
if (inputStamp.contains(input) && !resultStamp.contains(result)) {
Assert.fail(String.format("value %f (0x%x) is in input stamp, but not in result stamp (%s)", input, result, resultStamp));
}
}
}
use of org.graalvm.compiler.core.common.type.IntegerStamp in project graal by oracle.
the class IntegerStampTest method narrowingKindConversion.
private static Stamp narrowingKindConversion(IntegerStamp stamp, JavaKind kind) {
Stamp narrow = IntegerStamp.OPS.getNarrow().foldStamp(stamp.getBits(), kind.getBitCount(), stamp);
IntegerConvertOp<?> implicitExtend = kind.isUnsigned() ? IntegerStamp.OPS.getZeroExtend() : IntegerStamp.OPS.getSignExtend();
return implicitExtend.foldStamp(kind.getBitCount(), 32, narrow);
}
use of org.graalvm.compiler.core.common.type.IntegerStamp in project graal by oracle.
the class IntegerStampTest method testJoinWeirdMasks.
@Test
public void testJoinWeirdMasks() {
IntegerStamp minusOneOrThree = IntegerStamp.create(32, -1, 3, 0x3, 0xFFFFFFFFL);
IntegerStamp twoOrThree = IntegerStamp.create(32, 2, 3, 0x2, 0x3);
IntegerStamp three = IntegerStamp.create(32, 3, 3, 0x3, 0x3);
assertEquals(three, minusOneOrThree.join(twoOrThree));
IntegerStamp minusOneOrThreeOrOne = IntegerStamp.create(32, -1, 3, 0x1, 0xFFFFFFFFL);
assertEquals(three, minusOneOrThreeOrOne.join(twoOrThree));
IntegerStamp a = IntegerStamp.create(32, 0b101, 0b110, 0b100, 0b111);
IntegerStamp b = IntegerStamp.create(32, 0b011, 0b110, 0b010, 0b111);
// This exercises a special case:
// The new lowest bound is max(0b101, 0b011) = 0b101
// The new down mask is (0b100 | 0b010) = 0b110
// Now based on lowest bound and down mask, we know that the new lowest bound is 0b110
// Just making an or with the new down mask would give however (0b110 | 0b101) = 0b111 and
// would therefore be wrong.
// New upper bound is 0b110.
IntegerStamp result = IntegerStamp.create(32, 0b110, 0b110, 0b110, 0b110);
assertEquals(result, a.join(b));
}
use of org.graalvm.compiler.core.common.type.IntegerStamp in project graal by oracle.
the class ConstantNode method forPrimitive.
/**
* Returns a node for a primitive of a given type.
*/
public static ConstantNode forPrimitive(Stamp stamp, Constant constant) {
if (stamp instanceof IntegerStamp) {
PrimitiveConstant primitive = (PrimitiveConstant) constant;
assert primitive.getJavaKind().isNumericInteger() && stamp.getStackKind() == primitive.getJavaKind().getStackKind();
IntegerStamp istamp = (IntegerStamp) stamp;
return forIntegerBits(istamp.getBits(), primitive);
} else if (stamp instanceof FloatStamp) {
PrimitiveConstant primitive = (PrimitiveConstant) constant;
assert primitive.getJavaKind().isNumericFloat() && stamp.getStackKind() == primitive.getJavaKind();
return forConstant(primitive, null);
} else {
assert !(stamp instanceof AbstractObjectStamp);
return new ConstantNode(constant, stamp.constant(constant, null));
}
}
Aggregations