Search in sources :

Example 26 with AddNode

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

the class BasicInductionVariable method direction.

@Override
public Direction direction() {
    Stamp stamp = rawStride.stamp(NodeView.DEFAULT);
    if (stamp instanceof IntegerStamp) {
        IntegerStamp integerStamp = (IntegerStamp) stamp;
        Direction dir = null;
        if (integerStamp.isStrictlyPositive()) {
            dir = Direction.Up;
        } else if (integerStamp.isStrictlyNegative()) {
            dir = Direction.Down;
        }
        if (dir != null) {
            if (op instanceof AddNode) {
                return dir;
            } else {
                assert op instanceof SubNode;
                return dir.opposite();
            }
        }
    }
    return null;
}
Also used : Stamp(org.graalvm.compiler.core.common.type.Stamp) IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) SubNode(org.graalvm.compiler.nodes.calc.SubNode) IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) AddNode(org.graalvm.compiler.nodes.calc.AddNode)

Example 27 with AddNode

use of org.graalvm.compiler.nodes.calc.AddNode 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

AddNode (org.graalvm.compiler.nodes.calc.AddNode)27 ValueNode (org.graalvm.compiler.nodes.ValueNode)17 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)7 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)6 LeftShiftNode (org.graalvm.compiler.nodes.calc.LeftShiftNode)6 OffsetAddressNode (org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)5 IntegerStamp (org.graalvm.compiler.core.common.type.IntegerStamp)4 Node (org.graalvm.compiler.graph.Node)4 PhiNode (org.graalvm.compiler.nodes.PhiNode)4 AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)4 Test (org.junit.Test)4 JavaConstant (jdk.vm.ci.meta.JavaConstant)3 GetObjectAddressNode (org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode)3 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)3 Block (org.graalvm.compiler.nodes.cfg.Block)3 SchedulePhase (org.graalvm.compiler.phases.schedule.SchedulePhase)3 AMD64AddressNode (org.graalvm.compiler.core.amd64.AMD64AddressNode)2 Stamp (org.graalvm.compiler.core.common.type.Stamp)2 FrameState (org.graalvm.compiler.nodes.FrameState)2 NodeView (org.graalvm.compiler.nodes.NodeView)2