Search in sources :

Example 1 with SignedRemNode

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

Aggregations

JavaKind (jdk.vm.ci.meta.JavaKind)1 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)1 SignedDivNode (org.graalvm.compiler.nodes.calc.SignedDivNode)1 SignedRemNode (org.graalvm.compiler.nodes.calc.SignedRemNode)1 UnsignedDivNode (org.graalvm.compiler.nodes.calc.UnsignedDivNode)1 UnsignedRemNode (org.graalvm.compiler.nodes.calc.UnsignedRemNode)1 SnippetTemplate (org.graalvm.compiler.replacements.SnippetTemplate)1 Arguments (org.graalvm.compiler.replacements.SnippetTemplate.Arguments)1