use of org.graalvm.compiler.nodes.ValueNode in project graal by oracle.
the class IntegerConvertNode method convert.
public static ValueNode convert(ValueNode input, Stamp stamp, boolean zeroExtend, NodeView view) {
IntegerStamp fromStamp = (IntegerStamp) input.stamp(view);
IntegerStamp toStamp = (IntegerStamp) stamp;
ValueNode result;
if (toStamp.getBits() == fromStamp.getBits()) {
result = input;
} else if (toStamp.getBits() < fromStamp.getBits()) {
result = new NarrowNode(input, fromStamp.getBits(), toStamp.getBits());
} else if (zeroExtend) {
// toStamp.getBits() > fromStamp.getBits()
result = ZeroExtendNode.create(input, toStamp.getBits(), view);
} else {
// toStamp.getBits() > fromStamp.getBits()
result = SignExtendNode.create(input, toStamp.getBits(), view);
}
IntegerStamp resultStamp = (IntegerStamp) result.stamp(view);
assert toStamp.getBits() == resultStamp.getBits();
return result;
}
use of org.graalvm.compiler.nodes.ValueNode in project graal by oracle.
the class UnpackEndianHalfNode method lower.
public void lower(ByteOrder byteOrder) {
ValueNode result = value;
if (value.getStackKind() == JavaKind.Double) {
result = graph().unique(new ReinterpretNode(JavaKind.Long, value));
}
if ((byteOrder == ByteOrder.BIG_ENDIAN) == firstHalf) {
result = graph().unique(new UnsignedRightShiftNode(result, ConstantNode.forInt(32, graph())));
}
result = IntegerConvertNode.convert(result, StampFactory.forKind(JavaKind.Int), graph(), NodeView.DEFAULT);
replaceAtUsagesAndDelete(result);
}
use of org.graalvm.compiler.nodes.ValueNode in project graal by oracle.
the class UnsignedRightShiftNode method canonical.
@Override
public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) {
NodeView view = NodeView.from(tool);
ValueNode ret = super.canonical(tool, forX, forY);
if (ret != this) {
return ret;
}
return canonical(this, this.getArithmeticOp(), this.stamp(view), forX, forY, view);
}
use of org.graalvm.compiler.nodes.ValueNode in project graal by oracle.
the class ZeroExtendNode method canonical.
@Override
public ValueNode canonical(CanonicalizerTool tool, ValueNode forValue) {
NodeView view = NodeView.from(tool);
ValueNode ret = super.canonical(tool, forValue);
if (ret != this) {
return ret;
}
return canonical(this, forValue, getInputBits(), getResultBits(), view, inputAlwaysPositive);
}
use of org.graalvm.compiler.nodes.ValueNode in project graal by oracle.
the class ZeroExtendNode method create.
public static ValueNode create(ValueNode input, int inputBits, int resultBits, NodeView view, boolean alwaysPositive) {
IntegerConvertOp<ZeroExtend> signExtend = ArithmeticOpTable.forStamp(input.stamp(view)).getZeroExtend();
ValueNode synonym = findSynonym(signExtend, input, inputBits, resultBits, signExtend.foldStamp(inputBits, resultBits, input.stamp(view)));
if (synonym != null) {
return synonym;
}
return canonical(null, input, inputBits, resultBits, view, alwaysPositive);
}
Aggregations