use of org.graalvm.compiler.nodes.calc.SignExtendNode in project graal by oracle.
the class SPARCIntegerCompareCanonicalizationPhase method min32.
private static void min32(CompareNode enode, ValueNode v) {
Stamp s = v.stamp(NodeView.DEFAULT);
if (s instanceof IntegerStamp) {
int bits = ((IntegerStamp) s).getBits();
if (bits != 32 && bits != 64) {
if (bits <= 32) {
bits = 32;
} else {
bits = 64;
}
ValueNode replacement;
if (v instanceof ConstantNode) {
JavaConstant newConst;
if (bits == 32) {
newConst = JavaConstant.forInt(v.asJavaConstant().asInt());
} else if (bits == 64) {
newConst = JavaConstant.forLong(v.asJavaConstant().asLong());
} else {
throw GraalError.shouldNotReachHere();
}
long mask = CodeUtil.mask(bits);
replacement = v.graph().addOrUnique(new ConstantNode(newConst, IntegerStamp.stampForMask(bits, newConst.asLong() & mask, newConst.asLong() & mask)));
} else {
replacement = v.graph().addOrUnique(new SignExtendNode(v, bits));
}
v.replaceAtUsages(replacement, x -> x == enode);
}
}
}
use of org.graalvm.compiler.nodes.calc.SignExtendNode in project graal by oracle.
the class DefaultJavaLoweringProvider method createArrayAddress.
public AddressNode createArrayAddress(StructuredGraph graph, ValueNode array, JavaKind elementKind, ValueNode index) {
ValueNode wordIndex;
if (target.wordSize > 4) {
wordIndex = graph.unique(new SignExtendNode(index, target.wordSize * 8));
} else {
assert target.wordSize == 4 : "unsupported word size";
wordIndex = index;
}
int shift = CodeUtil.log2(arrayScalingFactor(elementKind));
ValueNode scaledIndex = graph.unique(new LeftShiftNode(wordIndex, ConstantNode.forInt(shift, graph)));
int base = arrayBaseOffset(elementKind);
ValueNode offset = graph.unique(new AddNode(scaledIndex, ConstantNode.forIntegerKind(target.wordJavaKind, base, graph)));
return graph.unique(new OffsetAddressNode(array, offset));
}
use of org.graalvm.compiler.nodes.calc.SignExtendNode in project graal by oracle.
the class PointerTest method assertWrite.
private void assertWrite(StructuredGraph graph, boolean indexConvert, LocationIdentity locationIdentity) {
WordCastNode cast = (WordCastNode) graph.start().next();
JavaWriteNode write = (JavaWriteNode) cast.next();
Assert.assertEquals(graph.getParameter(2), write.value());
Assert.assertEquals(BytecodeFrame.AFTER_BCI, write.stateAfter().bci);
OffsetAddressNode address = (OffsetAddressNode) write.getAddress();
Assert.assertEquals(cast, address.getBase());
Assert.assertEquals(graph.getParameter(0), cast.getInput());
Assert.assertEquals(target.wordJavaKind, cast.stamp(NodeView.DEFAULT).getStackKind());
Assert.assertEquals(locationIdentity, write.getLocationIdentity());
if (indexConvert) {
SignExtendNode convert = (SignExtendNode) address.getOffset();
Assert.assertEquals(convert.getInputBits(), 32);
Assert.assertEquals(convert.getResultBits(), 64);
Assert.assertEquals(graph.getParameter(1), convert.getValue());
} else {
Assert.assertEquals(graph.getParameter(1), address.getOffset());
}
ReturnNode ret = (ReturnNode) write.next();
Assert.assertEquals(null, ret.result());
}
Aggregations