Search in sources :

Example 26 with NodeView

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

the class NarrowNode 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;
    }
    if (forValue instanceof NarrowNode) {
        // zzzzzzzz yyyyxxxx -(narrow)-> yyyyxxxx -(narrow)-> xxxx
        // ==> zzzzzzzz yyyyxxxx -(narrow)-> xxxx
        NarrowNode other = (NarrowNode) forValue;
        return new NarrowNode(other.getValue(), other.getInputBits(), getResultBits());
    } else if (forValue instanceof IntegerConvertNode) {
        // SignExtendNode or ZeroExtendNode
        IntegerConvertNode<?, ?> other = (IntegerConvertNode<?, ?>) forValue;
        if (other.getValue().hasExactlyOneUsage() && other.hasMoreThanOneUsage()) {
            // If the convert's usage count is <=1, it will be dead code eliminated.
            return this;
        }
        if (getResultBits() == other.getInputBits()) {
            // ==> no-op
            return other.getValue();
        } else if (getResultBits() < other.getInputBits()) {
            // ==> yyyyxxxx -(narrow)-> xxxx
            return new NarrowNode(other.getValue(), other.getInputBits(), getResultBits());
        } else {
            if (other instanceof SignExtendNode) {
                // ==> sxxx -(sign-extend)-> sssssxxx
                return SignExtendNode.create(other.getValue(), other.getInputBits(), getResultBits(), view);
            } else if (other instanceof ZeroExtendNode) {
                // ==> xxxx -(zero-extend)-> 0000xxxx
                return new ZeroExtendNode(other.getValue(), other.getInputBits(), getResultBits(), ((ZeroExtendNode) other).isInputAlwaysPositive());
            }
        }
    } else if (forValue instanceof AndNode) {
        AndNode andNode = (AndNode) forValue;
        IntegerStamp yStamp = (IntegerStamp) andNode.getY().stamp(view);
        IntegerStamp xStamp = (IntegerStamp) andNode.getX().stamp(view);
        long relevantMask = CodeUtil.mask(this.getResultBits());
        if ((relevantMask & yStamp.downMask()) == relevantMask) {
            return create(andNode.getX(), this.getResultBits(), view);
        } else if ((relevantMask & xStamp.downMask()) == relevantMask) {
            return create(andNode.getY(), this.getResultBits(), view);
        }
    }
    return this;
}
Also used : IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) ValueNode(org.graalvm.compiler.nodes.ValueNode) NodeView(org.graalvm.compiler.nodes.NodeView)

Example 27 with NodeView

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

the class ObjectEqualsNode method canonical.

@Override
public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) {
    NodeView view = NodeView.from(tool);
    ValueNode value = OP.canonical(tool.getConstantReflection(), tool.getMetaAccess(), tool.getOptions(), tool.smallestCompareWidth(), CanonicalCondition.EQ, false, forX, forY, view);
    if (value != null) {
        return value;
    }
    return this;
}
Also used : ValueNode(org.graalvm.compiler.nodes.ValueNode) NodeView(org.graalvm.compiler.nodes.NodeView)

Example 28 with NodeView

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

the class PointerEqualsNode method canonical.

@Override
public Node canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) {
    NodeView view = NodeView.from(tool);
    ValueNode value = OP.canonical(tool.getConstantReflection(), tool.getMetaAccess(), tool.getOptions(), tool.smallestCompareWidth(), CanonicalCondition.EQ, false, forX, forY, view);
    if (value != null) {
        return value;
    }
    return this;
}
Also used : ValueNode(org.graalvm.compiler.nodes.ValueNode) NodeView(org.graalvm.compiler.nodes.NodeView)

Example 29 with NodeView

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

the class RightShiftNode 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, getArithmeticOp(), stamp(view), forX, forY, view);
}
Also used : ValueNode(org.graalvm.compiler.nodes.ValueNode) NodeView(org.graalvm.compiler.nodes.NodeView)

Example 30 with NodeView

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

the class LoadHubNode method canonical.

@Override
public ValueNode canonical(CanonicalizerTool tool) {
    if (!GeneratePIC.getValue(tool.getOptions())) {
        NodeView view = NodeView.from(tool);
        MetaAccessProvider metaAccess = tool.getMetaAccess();
        ValueNode curValue = getValue();
        ValueNode newNode = findSynonym(curValue, stamp(view), metaAccess, tool.getConstantReflection());
        if (newNode != null) {
            return newNode;
        }
    }
    return this;
}
Also used : ValueNode(org.graalvm.compiler.nodes.ValueNode) NodeView(org.graalvm.compiler.nodes.NodeView) MetaAccessProvider(jdk.vm.ci.meta.MetaAccessProvider)

Aggregations

NodeView (org.graalvm.compiler.nodes.NodeView)37 ValueNode (org.graalvm.compiler.nodes.ValueNode)28 IntegerStamp (org.graalvm.compiler.core.common.type.IntegerStamp)6 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)4 Constant (jdk.vm.ci.meta.Constant)3 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)2 LogicNode (org.graalvm.compiler.nodes.LogicNode)2 AddNode (org.graalvm.compiler.nodes.calc.AddNode)2 MulNode (org.graalvm.compiler.nodes.calc.MulNode)2 ArrayList (java.util.ArrayList)1 Assumptions (jdk.vm.ci.meta.Assumptions)1 JavaConstant (jdk.vm.ci.meta.JavaConstant)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)1 Add (org.graalvm.compiler.core.common.type.ArithmeticOpTable.BinaryOp.Add)1 Mul (org.graalvm.compiler.core.common.type.ArithmeticOpTable.BinaryOp.Mul)1 Sub (org.graalvm.compiler.core.common.type.ArithmeticOpTable.BinaryOp.Sub)1 FloatStamp (org.graalvm.compiler.core.common.type.FloatStamp)1 ObjectStamp (org.graalvm.compiler.core.common.type.ObjectStamp)1 Stamp (org.graalvm.compiler.core.common.type.Stamp)1