Search in sources :

Example 11 with LeftShiftNode

use of org.graalvm.compiler.nodes.calc.LeftShiftNode 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));
}
Also used : SignExtendNode(org.graalvm.compiler.nodes.calc.SignExtendNode) 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)

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