use of jdk.vm.ci.meta.Constant in project graal by oracle.
the class PrimitiveStampBoundaryTest method checkUnaryOperation.
private static void checkUnaryOperation(ArithmeticOpTable.UnaryOp<?> op, Stamp result, Stamp v1stamp) {
Stamp folded = op.foldStamp(v1stamp);
Constant v1constant = v1stamp.asConstant();
if (v1constant != null) {
Constant constant = op.foldConstant(v1constant);
if (constant != null) {
Constant constant2 = folded.asConstant();
if (constant2 == null && v1stamp instanceof FloatStamp) {
JavaConstant c = (JavaConstant) constant;
assertTrue((c.getJavaKind() == JavaKind.Double && Double.isNaN(c.asDouble())) || (c.getJavaKind() == JavaKind.Float && Float.isNaN(c.asFloat())));
} else {
assertTrue(constant2 != null, "should constant fold %s %s %s", op, v1stamp, folded);
assertTrue(constant.equals(constant2), "should produce same constant %s %s %s %s", op, v1stamp, constant, constant2);
}
}
} else {
assertTrue(v1stamp.isEmpty() || v1stamp instanceof FloatStamp);
}
assertTrue(result.meet(folded).equals(result), "result out of range %s %s %s %s %s", op, v1stamp, folded, result, result.meet(folded));
}
use of jdk.vm.ci.meta.Constant in project graal by oracle.
the class MoveResolver method addMapping.
public void addMapping(Interval fromInterval, Interval toInterval) {
DebugContext debug = allocator.getDebug();
if (isIllegal(toInterval.location()) && toInterval.canMaterialize()) {
if (debug.isLogEnabled()) {
debug.log("no store to rematerializable interval %s needed", toInterval);
}
return;
}
if (isIllegal(fromInterval.location()) && fromInterval.canMaterialize()) {
// Instead of a reload, re-materialize the value
Constant rematValue = fromInterval.getMaterializedValue();
addMapping(rematValue, toInterval);
return;
}
if (debug.isLogEnabled()) {
debug.log("add move mapping from %s to %s", fromInterval, toInterval);
}
assert !fromInterval.operand.equals(toInterval.operand) : "from and to interval equal: " + fromInterval;
assert LIRKind.verifyMoveKinds(toInterval.kind(), fromInterval.kind(), allocator.getRegisterAllocationConfig()) : String.format("Kind mismatch: %s vs. %s, from=%s, to=%s", fromInterval.kind(), toInterval.kind(), fromInterval, toInterval);
mappingFrom.add(fromInterval);
mappingFromOpr.add(null);
mappingTo.add(toInterval);
}
use of jdk.vm.ci.meta.Constant in project graal by oracle.
the class MulNode method canonical.
private static ValueNode canonical(MulNode self, BinaryOp<Mul> op, Stamp stamp, ValueNode forX, ValueNode forY, NodeView view) {
if (forY.isConstant()) {
Constant c = forY.asConstant();
if (op.isNeutral(c)) {
return forX;
}
if (c instanceof PrimitiveConstant && ((PrimitiveConstant) c).getJavaKind().isNumericInteger()) {
long i = ((PrimitiveConstant) c).asLong();
ValueNode result = canonical(stamp, forX, i, view);
if (result != null) {
return result;
}
}
if (op.isAssociative()) {
// canonicalize expressions like "(a * 1) * 2"
return reassociate(self != null ? self : (MulNode) new MulNode(forX, forY).maybeCommuteInputs(), ValueNode.isConstantPredicate(), forX, forY, view);
}
}
return self != null ? self : new MulNode(forX, forY).maybeCommuteInputs();
}
use of jdk.vm.ci.meta.Constant in project graal by oracle.
the class FloatStamp method maybeFoldConstant.
private static Stamp maybeFoldConstant(BinaryOp<?> op, FloatStamp stamp1, FloatStamp stamp2) {
if (stamp1.isConstant() && stamp2.isConstant()) {
JavaConstant constant1 = stamp1.asConstant();
JavaConstant constant2 = stamp2.asConstant();
Constant folded = op.foldConstant(constant1, constant2);
if (folded != null) {
FloatStamp stamp = stampForConstant(folded);
if (stamp != null && stamp.isConstant()) {
assert stamp.asConstant().equals(folded);
return stamp;
}
}
}
return null;
}
use of jdk.vm.ci.meta.Constant in project graal by oracle.
the class FloatStamp method maybeFoldConstant.
private static Stamp maybeFoldConstant(UnaryOp<?> op, FloatStamp stamp) {
if (stamp.isConstant()) {
JavaConstant constant = stamp.asConstant();
Constant folded = op.foldConstant(constant);
if (folded != null) {
return FloatStamp.stampForConstant(folded);
}
}
return null;
}
Aggregations