1 /*
   2  * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 package org.graalvm.compiler.nodes.spi;
  26 
  27 import java.util.Collection;
  28 import java.util.List;
  29 
  30 import org.graalvm.compiler.core.common.cfg.BlockMap;
  31 import org.graalvm.compiler.core.common.type.Stamp;
  32 import org.graalvm.compiler.graph.Node;
  33 import org.graalvm.compiler.graph.NodeSourcePosition;
  34 import org.graalvm.compiler.lir.LIRFrameState;
  35 import org.graalvm.compiler.lir.gen.LIRGeneratorTool;
  36 import org.graalvm.compiler.nodes.AbstractBeginNode;
  37 import org.graalvm.compiler.nodes.AbstractEndNode;
  38 import org.graalvm.compiler.nodes.AbstractMergeNode;
  39 import org.graalvm.compiler.nodes.BreakpointNode;
  40 import org.graalvm.compiler.nodes.DeoptimizingNode;
  41 import org.graalvm.compiler.nodes.FullInfopointNode;
  42 import org.graalvm.compiler.nodes.IfNode;
  43 import org.graalvm.compiler.nodes.Invoke;
  44 import org.graalvm.compiler.nodes.LoopEndNode;
  45 import org.graalvm.compiler.nodes.SafepointNode;
  46 import org.graalvm.compiler.nodes.StructuredGraph;
  47 import org.graalvm.compiler.nodes.ValueNode;
  48 import org.graalvm.compiler.nodes.calc.ConditionalNode;
  49 import org.graalvm.compiler.nodes.cfg.Block;
  50 import org.graalvm.compiler.nodes.extended.SwitchNode;
  51 import org.graalvm.compiler.options.OptionValues;
  52 
  53 import jdk.vm.ci.code.CallingConvention;
  54 import jdk.vm.ci.meta.Value;
  55 
  56 public interface NodeLIRBuilderTool extends NodeValueMap {
  57 
  58     // TODO (je) remove and move into the Node
  59     LIRFrameState state(DeoptimizingNode deopt);
  60 
  61     void emitIf(IfNode i);
  62 
  63     void emitConditional(ConditionalNode i);
  64 
  65     void emitSwitch(SwitchNode i);
  66 
  67     void emitInvoke(Invoke i);
  68 
  69     // Handling of block-end nodes still needs to be unified in the LIRGenerator.
  70     void visitMerge(AbstractMergeNode i);
  71 
  72     void visitEndNode(AbstractEndNode i);
  73 
  74     void visitLoopEnd(LoopEndNode i);
  75 
  76     // These methods define the contract a runtime specific backend must provide.
  77 
  78     void visitSafepointNode(SafepointNode i);
  79 
  80     void visitBreakpointNode(BreakpointNode i);
  81 
  82     void visitFullInfopointNode(FullInfopointNode i);
  83 
  84     void setSourcePosition(NodeSourcePosition position);
  85 
  86     LIRGeneratorTool getLIRGeneratorTool();
  87 
  88     void emitOverflowCheckBranch(AbstractBeginNode overflowSuccessor, AbstractBeginNode next, Stamp compareStamp, double probability);
  89 
  90     Value[] visitInvokeArguments(CallingConvention cc, Collection<ValueNode> arguments);
  91 
  92     void doBlock(Block block, StructuredGraph graph, BlockMap<List<Node>> blockMap);
  93 
  94     default OptionValues getOptions() {
  95         return getLIRGeneratorTool().getResult().getLIR().getOptions();
  96     }
  97 
  98     void emitReadExceptionObject(ValueNode node);
  99 }