Search in sources :

Example 1 with NodeInputList

use of org.graalvm.compiler.graph.NodeInputList in project graal by oracle.

the class LoopDetector method makeFloatingNodeInputs.

protected void makeFloatingNodeInputs(MethodScope methodScope, LoopScope loopScope, Node node) {
    Edges edges = node.getNodeClass().getInputEdges();
    if (node instanceof PhiNode) {
        /*
             * The inputs of phi functions are filled manually when the end nodes are processed.
             * However, the values must not be null, so initialize them with an empty list.
             */
        assert edges.getDirectCount() == 1 : "PhiNode has one direct input (the MergeNode)";
        assert edges.getCount() - edges.getDirectCount() == 1 : "PhiNode has one variable size input (the values)";
        edges.initializeList(node, edges.getDirectCount(), new NodeInputList<>(node));
    } else {
        for (int index = 0; index < edges.getDirectCount(); index++) {
            int orderId = readOrderId(methodScope);
            Node value = ensureNodeCreated(methodScope, loopScope, orderId);
            edges.initializeNode(node, index, value);
        }
        for (int index = edges.getDirectCount(); index < edges.getCount(); index++) {
            int size = methodScope.reader.getSVInt();
            if (size != -1) {
                NodeList<Node> nodeList = new NodeInputList<>(node, size);
                edges.initializeList(node, index, nodeList);
                for (int idx = 0; idx < size; idx++) {
                    int orderId = readOrderId(methodScope);
                    Node value = ensureNodeCreated(methodScope, loopScope, orderId);
                    nodeList.initialize(idx, value);
                }
            }
        }
    }
}
Also used : IntegerSwitchNode(org.graalvm.compiler.nodes.extended.IntegerSwitchNode) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) Node(org.graalvm.compiler.graph.Node) NodeInputList(org.graalvm.compiler.graph.NodeInputList) Edges(org.graalvm.compiler.graph.Edges)

Example 2 with NodeInputList

use of org.graalvm.compiler.graph.NodeInputList in project graal by oracle.

the class LoopDetector method makeFixedNodeInputs.

/**
 * Process the input edges of a node. Input nodes that have not yet been created must be
 * non-fixed nodes (because fixed nodes are processed in reverse postorder. Such non-fixed nodes
 * are created on demand (recursively since they can themselves reference not yet created
 * nodes).
 */
protected void makeFixedNodeInputs(MethodScope methodScope, LoopScope loopScope, Node node) {
    Edges edges = node.getNodeClass().getInputEdges();
    for (int index = 0; index < edges.getDirectCount(); index++) {
        if (skipDirectEdge(node, edges, index)) {
            continue;
        }
        int orderId = readOrderId(methodScope);
        Node value = ensureNodeCreated(methodScope, loopScope, orderId);
        edges.initializeNode(node, index, value);
        if (value != null && !value.isDeleted()) {
            edges.update(node, null, value);
        }
    }
    if (node instanceof AbstractMergeNode) {
        /* The ends of merge nodes are filled manually when the ends are processed. */
        assert edges.getCount() - edges.getDirectCount() == 1 : "MergeNode has one variable size input (the ends)";
        assert Edges.getNodeList(node, edges.getOffsets(), edges.getDirectCount()) != null : "Input list must have been already created";
    } else {
        for (int index = edges.getDirectCount(); index < edges.getCount(); index++) {
            int size = methodScope.reader.getSVInt();
            if (size != -1) {
                NodeList<Node> nodeList = new NodeInputList<>(node, size);
                edges.initializeList(node, index, nodeList);
                for (int idx = 0; idx < size; idx++) {
                    int orderId = readOrderId(methodScope);
                    Node value = ensureNodeCreated(methodScope, loopScope, orderId);
                    nodeList.initialize(idx, value);
                    if (value != null && !value.isDeleted()) {
                        edges.update(node, null, value);
                    }
                }
            }
        }
    }
}
Also used : IntegerSwitchNode(org.graalvm.compiler.nodes.extended.IntegerSwitchNode) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) Node(org.graalvm.compiler.graph.Node) NodeInputList(org.graalvm.compiler.graph.NodeInputList) Edges(org.graalvm.compiler.graph.Edges)

Aggregations

Edges (org.graalvm.compiler.graph.Edges)2 Node (org.graalvm.compiler.graph.Node)2 NodeInputList (org.graalvm.compiler.graph.NodeInputList)2 FloatingNode (org.graalvm.compiler.nodes.calc.FloatingNode)2 IntegerSwitchNode (org.graalvm.compiler.nodes.extended.IntegerSwitchNode)2