Search in sources :

Example 1 with Arguments

use of org.graalvm.compiler.replacements.SnippetTemplate.Arguments in project graal by oracle.

the class AArch64FloatArithmeticSnippets method lower.

public void lower(RemNode node, LoweringTool tool) {
    JavaKind kind = node.stamp(NodeView.DEFAULT).getStackKind();
    assert kind == JavaKind.Float || kind == JavaKind.Double;
    if (node instanceof SafeNode) {
        // We already introduced the necessary checks, nothing to do.
        return;
    }
    SnippetTemplate.SnippetInfo snippet = kind == JavaKind.Float ? frem : drem;
    StructuredGraph graph = node.graph();
    Arguments args = new Arguments(snippet, graph.getGuardsStage(), tool.getLoweringStage());
    args.add("x", node.getX());
    args.add("y", node.getY());
    template(node, args).instantiate(providers.getMetaAccess(), node, SnippetTemplate.DEFAULT_REPLACER, tool, args);
}
Also used : SnippetTemplate(org.graalvm.compiler.replacements.SnippetTemplate) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) Arguments(org.graalvm.compiler.replacements.SnippetTemplate.Arguments) JavaKind(jdk.vm.ci.meta.JavaKind)

Example 2 with Arguments

use of org.graalvm.compiler.replacements.SnippetTemplate.Arguments in project graal by oracle.

the class AArch64IntegerArithmeticSnippets method lower.

public void lower(FixedBinaryNode node, LoweringTool tool) {
    JavaKind kind = node.stamp(NodeView.DEFAULT).getStackKind();
    assert kind == JavaKind.Int || kind == JavaKind.Long;
    SnippetTemplate.SnippetInfo snippet;
    if (node instanceof SafeNode) {
        // We already introduced the zero division check, nothing to do.
        return;
    } else if (node instanceof SignedDivNode) {
        snippet = kind == JavaKind.Int ? idiv : ldiv;
    } else if (node instanceof SignedRemNode) {
        snippet = kind == JavaKind.Int ? irem : lrem;
    } else if (node instanceof UnsignedDivNode) {
        snippet = kind == JavaKind.Int ? uidiv : uldiv;
    } else if (node instanceof UnsignedRemNode) {
        snippet = kind == JavaKind.Int ? uirem : ulrem;
    } else {
        throw GraalError.shouldNotReachHere();
    }
    StructuredGraph graph = node.graph();
    Arguments args = new Arguments(snippet, graph.getGuardsStage(), tool.getLoweringStage());
    args.add("x", node.getX());
    args.add("y", node.getY());
    template(node, args).instantiate(providers.getMetaAccess(), node, SnippetTemplate.DEFAULT_REPLACER, args);
}
Also used : SnippetTemplate(org.graalvm.compiler.replacements.SnippetTemplate) UnsignedRemNode(org.graalvm.compiler.nodes.calc.UnsignedRemNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) Arguments(org.graalvm.compiler.replacements.SnippetTemplate.Arguments) SignedRemNode(org.graalvm.compiler.nodes.calc.SignedRemNode) UnsignedDivNode(org.graalvm.compiler.nodes.calc.UnsignedDivNode) JavaKind(jdk.vm.ci.meta.JavaKind) SignedDivNode(org.graalvm.compiler.nodes.calc.SignedDivNode)

Example 3 with Arguments

use of org.graalvm.compiler.replacements.SnippetTemplate.Arguments in project graal by oracle.

the class InstanceOfSnippetsTemplates method lower.

public void lower(FloatingNode instanceOf, LoweringTool tool) {
    assert instanceOf instanceof InstanceOfNode || instanceOf instanceof InstanceOfDynamicNode || instanceOf instanceof ClassIsAssignableFromNode;
    List<Node> usages = instanceOf.usages().snapshot();
    Instantiation instantiation = new Instantiation();
    for (Node usage : usages) {
        final StructuredGraph graph = (StructuredGraph) usage.graph();
        InstanceOfUsageReplacer replacer = createReplacer(instanceOf, instantiation, usage, graph);
        if (instantiation.isInitialized()) {
            // No need to re-instantiate the snippet - just re-use its result
            replacer.replaceUsingInstantiation();
        } else {
            Arguments args = makeArguments(replacer, tool);
            template(instanceOf, args).instantiate(providers.getMetaAccess(), instanceOf, replacer, tool, args);
        }
    }
    assert instanceOf.hasNoUsages();
    if (!instanceOf.isDeleted()) {
        GraphUtil.killWithUnusedFloatingInputs(instanceOf);
    }
}
Also used : ClassIsAssignableFromNode(org.graalvm.compiler.nodes.java.ClassIsAssignableFromNode) InstanceOfDynamicNode(org.graalvm.compiler.nodes.java.InstanceOfDynamicNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CompareNode(org.graalvm.compiler.nodes.calc.CompareNode) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) LogicConstantNode(org.graalvm.compiler.nodes.LogicConstantNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) ConditionAnchorNode(org.graalvm.compiler.nodes.ConditionAnchorNode) ClassIsAssignableFromNode(org.graalvm.compiler.nodes.java.ClassIsAssignableFromNode) CompareNode.createCompareNode(org.graalvm.compiler.nodes.calc.CompareNode.createCompareNode) InstanceOfDynamicNode(org.graalvm.compiler.nodes.java.InstanceOfDynamicNode) InstanceOfNode(org.graalvm.compiler.nodes.java.InstanceOfNode) ConditionalNode(org.graalvm.compiler.nodes.calc.ConditionalNode) IfNode(org.graalvm.compiler.nodes.IfNode) FixedGuardNode(org.graalvm.compiler.nodes.FixedGuardNode) ShortCircuitOrNode(org.graalvm.compiler.nodes.ShortCircuitOrNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) Node(org.graalvm.compiler.graph.Node) PhiNode(org.graalvm.compiler.nodes.PhiNode) Arguments(org.graalvm.compiler.replacements.SnippetTemplate.Arguments) InstanceOfNode(org.graalvm.compiler.nodes.java.InstanceOfNode)

Aggregations

StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)3 Arguments (org.graalvm.compiler.replacements.SnippetTemplate.Arguments)3 JavaKind (jdk.vm.ci.meta.JavaKind)2 SnippetTemplate (org.graalvm.compiler.replacements.SnippetTemplate)2 Node (org.graalvm.compiler.graph.Node)1 ConditionAnchorNode (org.graalvm.compiler.nodes.ConditionAnchorNode)1 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)1 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)1 IfNode (org.graalvm.compiler.nodes.IfNode)1 LogicConstantNode (org.graalvm.compiler.nodes.LogicConstantNode)1 LogicNode (org.graalvm.compiler.nodes.LogicNode)1 PhiNode (org.graalvm.compiler.nodes.PhiNode)1 ShortCircuitOrNode (org.graalvm.compiler.nodes.ShortCircuitOrNode)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)1 CompareNode (org.graalvm.compiler.nodes.calc.CompareNode)1 CompareNode.createCompareNode (org.graalvm.compiler.nodes.calc.CompareNode.createCompareNode)1 ConditionalNode (org.graalvm.compiler.nodes.calc.ConditionalNode)1 FloatingNode (org.graalvm.compiler.nodes.calc.FloatingNode)1 SignedDivNode (org.graalvm.compiler.nodes.calc.SignedDivNode)1 SignedRemNode (org.graalvm.compiler.nodes.calc.SignedRemNode)1