Search in sources :

Example 1 with HIRLoop

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

the class FloatingReadPhase method run.

@Override
@SuppressWarnings("try")
protected void run(StructuredGraph graph) {
    EconomicMap<LoopBeginNode, EconomicSet<LocationIdentity>> modifiedInLoops = null;
    if (graph.hasLoops()) {
        modifiedInLoops = EconomicMap.create(Equivalence.IDENTITY);
        ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, false, false);
        for (Loop<?> l : cfg.getLoops()) {
            HIRLoop loop = (HIRLoop) l;
            processLoop(loop, modifiedInLoops);
        }
    }
    HashSetNodeEventListener listener = new HashSetNodeEventListener(EnumSet.of(NODE_ADDED, ZERO_USAGES));
    try (NodeEventScope nes = graph.trackNodeEvents(listener)) {
        ReentrantNodeIterator.apply(new FloatingReadClosure(modifiedInLoops, createFloatingReads, createMemoryMapNodes), graph.start(), new MemoryMapImpl(graph.start()));
    }
    for (Node n : removeExternallyUsedNodes(listener.getNodes())) {
        if (n.isAlive() && n instanceof FloatingNode) {
            n.replaceAtUsages(null);
            GraphUtil.killWithUnusedFloatingInputs(n);
        }
    }
    if (createFloatingReads) {
        assert !graph.isAfterFloatingReadPhase();
        graph.setAfterFloatingReadPhase(true);
    }
}
Also used : HashSetNodeEventListener(org.graalvm.compiler.phases.common.util.HashSetNodeEventListener) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) NodeEventScope(org.graalvm.compiler.graph.Graph.NodeEventScope) ControlFlowGraph(org.graalvm.compiler.nodes.cfg.ControlFlowGraph) FloatingAccessNode(org.graalvm.compiler.nodes.memory.FloatingAccessNode) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) MemoryPhiNode(org.graalvm.compiler.nodes.memory.MemoryPhiNode) StartNode(org.graalvm.compiler.nodes.StartNode) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) MemoryNode(org.graalvm.compiler.nodes.memory.MemoryNode) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode) InvokeWithExceptionNode(org.graalvm.compiler.nodes.InvokeWithExceptionNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) MemoryAnchorNode(org.graalvm.compiler.nodes.memory.MemoryAnchorNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) MemoryMapNode(org.graalvm.compiler.nodes.memory.MemoryMapNode) LoopEndNode(org.graalvm.compiler.nodes.LoopEndNode) FloatableAccessNode(org.graalvm.compiler.nodes.memory.FloatableAccessNode) LoopExitNode(org.graalvm.compiler.nodes.LoopExitNode) Node(org.graalvm.compiler.graph.Node) PhiNode(org.graalvm.compiler.nodes.PhiNode) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) EconomicSet(org.graalvm.collections.EconomicSet) HIRLoop(org.graalvm.compiler.nodes.cfg.HIRLoop)

Example 2 with HIRLoop

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

the class FloatingReadPhase method processLoop.

private EconomicSet<LocationIdentity> processLoop(HIRLoop loop, EconomicMap<LoopBeginNode, EconomicSet<LocationIdentity>> modifiedInLoops) {
    LoopBeginNode loopBegin = (LoopBeginNode) loop.getHeader().getBeginNode();
    EconomicSet<LocationIdentity> result = modifiedInLoops.get(loopBegin);
    if (result != null) {
        return result;
    }
    result = EconomicSet.create(Equivalence.DEFAULT);
    for (Loop<Block> inner : loop.getChildren()) {
        result.addAll(processLoop((HIRLoop) inner, modifiedInLoops));
    }
    for (Block b : loop.getBlocks()) {
        if (b.getLoop() == loop) {
            processBlock(b, result);
        }
    }
    modifiedInLoops.put(loopBegin, result);
    return result;
}
Also used : LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) LocationIdentity(org.graalvm.word.LocationIdentity) Block(org.graalvm.compiler.nodes.cfg.Block) HIRLoop(org.graalvm.compiler.nodes.cfg.HIRLoop)

Aggregations

LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)2 HIRLoop (org.graalvm.compiler.nodes.cfg.HIRLoop)2 EconomicSet (org.graalvm.collections.EconomicSet)1 NodeEventScope (org.graalvm.compiler.graph.Graph.NodeEventScope)1 Node (org.graalvm.compiler.graph.Node)1 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)1 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)1 FixedNode (org.graalvm.compiler.nodes.FixedNode)1 InvokeWithExceptionNode (org.graalvm.compiler.nodes.InvokeWithExceptionNode)1 LoopEndNode (org.graalvm.compiler.nodes.LoopEndNode)1 LoopExitNode (org.graalvm.compiler.nodes.LoopExitNode)1 PhiNode (org.graalvm.compiler.nodes.PhiNode)1 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)1 StartNode (org.graalvm.compiler.nodes.StartNode)1 FloatingNode (org.graalvm.compiler.nodes.calc.FloatingNode)1 Block (org.graalvm.compiler.nodes.cfg.Block)1 ControlFlowGraph (org.graalvm.compiler.nodes.cfg.ControlFlowGraph)1 FloatableAccessNode (org.graalvm.compiler.nodes.memory.FloatableAccessNode)1 FloatingAccessNode (org.graalvm.compiler.nodes.memory.FloatingAccessNode)1 FloatingReadNode (org.graalvm.compiler.nodes.memory.FloatingReadNode)1