Search in sources :

Example 6 with LeftShiftNode

use of org.graalvm.compiler.nodes.calc.LeftShiftNode in project graal by oracle.

the class AMD64AddressLoweringTest method convertNegatedBaseAndNegatedShiftedIndexToDisplacement.

@Test
public void convertNegatedBaseAndNegatedShiftedIndexToDisplacement() {
    ValueNode base = graph.addOrUniqueWithInputs(new NegateNode(const64(1000)));
    ValueNode index = graph.addOrUniqueWithInputs(new NegateNode(new LeftShiftNode(const64(10), const32(2))));
    AddressNode result = lowering.lower(base, index);
    assertAddress(result, null, null, Scale.Times4, -1040);
}
Also used : ValueNode(org.graalvm.compiler.nodes.ValueNode) NegateNode(org.graalvm.compiler.nodes.calc.NegateNode) AMD64AddressNode(org.graalvm.compiler.core.amd64.AMD64AddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) LeftShiftNode(org.graalvm.compiler.nodes.calc.LeftShiftNode) Test(org.junit.Test) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest)

Example 7 with LeftShiftNode

use of org.graalvm.compiler.nodes.calc.LeftShiftNode in project graal by oracle.

the class AMD64AddressLoweringTest method convertNegatedShiftedBaseAndNegatedIndexToDisplacement.

@Test
public void convertNegatedShiftedBaseAndNegatedIndexToDisplacement() {
    ValueNode base = graph.addOrUniqueWithInputs(new NegateNode(new LeftShiftNode(const64(10), const32(2))));
    ValueNode index = graph.addOrUniqueWithInputs(new NegateNode(const64(1000)));
    AddressNode result = lowering.lower(base, index);
    assertAddress(result, null, null, Scale.Times4, -1040);
}
Also used : ValueNode(org.graalvm.compiler.nodes.ValueNode) NegateNode(org.graalvm.compiler.nodes.calc.NegateNode) AMD64AddressNode(org.graalvm.compiler.core.amd64.AMD64AddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) LeftShiftNode(org.graalvm.compiler.nodes.calc.LeftShiftNode) Test(org.junit.Test) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest)

Example 8 with LeftShiftNode

use of org.graalvm.compiler.nodes.calc.LeftShiftNode in project graal by oracle.

the class AMD64AddressLoweringTest method convertTwoLevelsOfNegatedShiftedBaseAndNegatedIndexToDisplacement.

@Test
public void convertTwoLevelsOfNegatedShiftedBaseAndNegatedIndexToDisplacement() {
    ValueNode base = graph.addOrUniqueWithInputs(new NegateNode(new LeftShiftNode(new NegateNode(new LeftShiftNode(const64(500), const32(1))), const32(1))));
    ValueNode index = graph.addOrUniqueWithInputs(new NegateNode(new AddNode(new NegateNode(const64(13)), const64(3))));
    AddressNode result = lowering.lower(base, index);
    assertAddress(result, null, null, Scale.Times4, 2010);
}
Also used : ValueNode(org.graalvm.compiler.nodes.ValueNode) NegateNode(org.graalvm.compiler.nodes.calc.NegateNode) AMD64AddressNode(org.graalvm.compiler.core.amd64.AMD64AddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) LeftShiftNode(org.graalvm.compiler.nodes.calc.LeftShiftNode) AddNode(org.graalvm.compiler.nodes.calc.AddNode) Test(org.junit.Test) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest)

Example 9 with LeftShiftNode

use of org.graalvm.compiler.nodes.calc.LeftShiftNode in project graal by oracle.

the class CheckcastArrayCopyCallNode method computeBase.

private ValueNode computeBase(ValueNode base, ValueNode pos) {
    FixedWithNextNode basePtr = graph().add(new GetObjectAddressNode(base));
    graph().addBeforeFixed(this, basePtr);
    int shift = CodeUtil.log2(getArrayIndexScale(JavaKind.Object));
    ValueNode extendedPos = IntegerConvertNode.convert(pos, StampFactory.forKind(runtime.getTarget().wordJavaKind), graph(), NodeView.DEFAULT);
    ValueNode scaledIndex = graph().unique(new LeftShiftNode(extendedPos, ConstantNode.forInt(shift, graph())));
    ValueNode offset = graph().unique(new AddNode(scaledIndex, ConstantNode.forIntegerBits(PrimitiveStamp.getBits(scaledIndex.stamp(NodeView.DEFAULT)), getArrayBaseOffset(JavaKind.Object), graph())));
    return graph().unique(new OffsetAddressNode(basePtr, offset));
}
Also used : FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) LeftShiftNode(org.graalvm.compiler.nodes.calc.LeftShiftNode) AddNode(org.graalvm.compiler.nodes.calc.AddNode) GetObjectAddressNode(org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode) AbstractMemoryCheckpoint(org.graalvm.compiler.nodes.memory.AbstractMemoryCheckpoint) MemoryCheckpoint(org.graalvm.compiler.nodes.memory.MemoryCheckpoint)

Example 10 with LeftShiftNode

use of org.graalvm.compiler.nodes.calc.LeftShiftNode in project graal by oracle.

the class HotSpotGraphBuilderPlugins method readMetaspaceConstantPoolElement.

/**
 * Emits a node representing an element in a metaspace {@code ConstantPool}.
 *
 * @param constantPoolOop value of the {@code constantPoolOop} field in a ConstantPool value
 */
private static boolean readMetaspaceConstantPoolElement(GraphBuilderContext b, ValueNode constantPoolOop, ValueNode index, JavaKind elementKind, WordTypes wordTypes, GraalHotSpotVMConfig config) {
    ValueNode constants = getMetaspaceConstantPool(b, constantPoolOop, wordTypes, config);
    int shift = CodeUtil.log2(wordTypes.getWordKind().getByteCount());
    ValueNode scaledIndex = b.add(new LeftShiftNode(IntegerConvertNode.convert(index, StampFactory.forKind(JavaKind.Long), NodeView.DEFAULT), b.add(ConstantNode.forInt(shift))));
    ValueNode offset = b.add(new AddNode(scaledIndex, b.add(ConstantNode.forLong(config.constantPoolSize))));
    AddressNode elementAddress = b.add(new OffsetAddressNode(constants, offset));
    boolean notCompressible = false;
    ValueNode elementValue = WordOperationPlugin.readOp(b, elementKind, elementAddress, NamedLocationIdentity.getArrayLocation(elementKind), BarrierType.NONE, notCompressible);
    b.addPush(elementKind, elementValue);
    return true;
}
Also used : OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) LeftShiftNode(org.graalvm.compiler.nodes.calc.LeftShiftNode) AddNode(org.graalvm.compiler.nodes.calc.AddNode)

Aggregations

ValueNode (org.graalvm.compiler.nodes.ValueNode)11 LeftShiftNode (org.graalvm.compiler.nodes.calc.LeftShiftNode)11 AddNode (org.graalvm.compiler.nodes.calc.AddNode)6 AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)6 AMD64AddressNode (org.graalvm.compiler.core.amd64.AMD64AddressNode)5 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)5 Test (org.junit.Test)5 NegateNode (org.graalvm.compiler.nodes.calc.NegateNode)4 OffsetAddressNode (org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)4 Stamp (org.graalvm.compiler.core.common.type.Stamp)2 GetObjectAddressNode (org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode)2 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)2 AbstractMemoryCheckpoint (org.graalvm.compiler.nodes.memory.AbstractMemoryCheckpoint)2 MemoryCheckpoint (org.graalvm.compiler.nodes.memory.MemoryCheckpoint)2 CInterfaceLocationIdentity (com.oracle.svm.core.c.struct.CInterfaceLocationIdentity)1 JavaKind (jdk.vm.ci.meta.JavaKind)1 Scale (org.graalvm.compiler.asm.amd64.AMD64Address.Scale)1 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)1 AndNode (org.graalvm.compiler.nodes.calc.AndNode)1 OrNode (org.graalvm.compiler.nodes.calc.OrNode)1