src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/LIR.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/LIR.java

Print this page




  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 package org.graalvm.compiler.lir;
  24 
  25 import java.util.ArrayList;
  26 import java.util.Arrays;
  27 import java.util.List;
  28 
  29 import org.graalvm.compiler.core.common.cfg.AbstractBlockBase;
  30 import org.graalvm.compiler.core.common.cfg.AbstractControlFlowGraph;
  31 import org.graalvm.compiler.core.common.cfg.BlockMap;

  32 import org.graalvm.compiler.lir.StandardOp.BlockEndOp;
  33 import org.graalvm.compiler.lir.StandardOp.LabelOp;
  34 import org.graalvm.compiler.lir.gen.LIRGenerator;
  35 import org.graalvm.compiler.options.OptionValues;
  36 
  37 /**
  38  * This class implements the overall container for the LIR graph and directs its construction,
  39  * optimization, and finalization.
  40  */
  41 public final class LIR extends LIRGenerator.VariableProvider {
  42 
  43     private final AbstractControlFlowGraph<?> cfg;
  44 
  45     /**
  46      * The linear-scan ordered list of blocks.
  47      */
  48     private final AbstractBlockBase<?>[] linearScanOrder;
  49 
  50     /**
  51      * The order in which the code is emitted.
  52      */
  53     private final AbstractBlockBase<?>[] codeEmittingOrder;
  54 
  55     /**
  56      * Map from {@linkplain AbstractBlockBase block} to {@linkplain LIRInstruction}s. Note that we
  57      * are using {@link ArrayList} instead of {@link List} to avoid interface dispatch.
  58      */
  59     private final BlockMap<ArrayList<LIRInstruction>> lirInstructions;
  60 
  61     private boolean hasArgInCallerFrame;
  62 
  63     private final OptionValues options;
  64 


  65     /**
  66      * Creates a new LIR instance for the specified compilation.
  67      */
  68     public LIR(AbstractControlFlowGraph<?> cfg, AbstractBlockBase<?>[] linearScanOrder, AbstractBlockBase<?>[] codeEmittingOrder, OptionValues options) {
  69         this.cfg = cfg;
  70         this.codeEmittingOrder = codeEmittingOrder;
  71         this.linearScanOrder = linearScanOrder;
  72         this.lirInstructions = new BlockMap<>(cfg);
  73         this.options = options;

  74     }
  75 
  76     public AbstractControlFlowGraph<?> getControlFlowGraph() {
  77         return cfg;
  78     }
  79 
  80     public OptionValues getOptions() {
  81         return options;
  82     }
  83 




  84     /**
  85      * Determines if any instruction in the LIR has debug info associated with it.
  86      */
  87     public boolean hasDebugInfo() {
  88         for (AbstractBlockBase<?> b : linearScanOrder()) {
  89             for (LIRInstruction op : getLIRforBlock(b)) {
  90                 if (op.hasState()) {
  91                     return true;
  92                 }
  93             }
  94         }
  95         return false;
  96     }
  97 
  98     public ArrayList<LIRInstruction> getLIRforBlock(AbstractBlockBase<?> block) {
  99         return lirInstructions.get(block);
 100     }
 101 
 102     public void setLIRforBlock(AbstractBlockBase<?> block, ArrayList<LIRInstruction> list) {
 103         assert getLIRforBlock(block) == null : "lir instruction list should only be initialized once";




  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 package org.graalvm.compiler.lir;
  24 
  25 import java.util.ArrayList;
  26 import java.util.Arrays;
  27 import java.util.List;
  28 
  29 import org.graalvm.compiler.core.common.cfg.AbstractBlockBase;
  30 import org.graalvm.compiler.core.common.cfg.AbstractControlFlowGraph;
  31 import org.graalvm.compiler.core.common.cfg.BlockMap;
  32 import org.graalvm.compiler.debug.DebugContext;
  33 import org.graalvm.compiler.lir.StandardOp.BlockEndOp;
  34 import org.graalvm.compiler.lir.StandardOp.LabelOp;
  35 import org.graalvm.compiler.lir.gen.LIRGenerator;
  36 import org.graalvm.compiler.options.OptionValues;
  37 
  38 /**
  39  * This class implements the overall container for the LIR graph and directs its construction,
  40  * optimization, and finalization.
  41  */
  42 public final class LIR extends LIRGenerator.VariableProvider {
  43 
  44     private final AbstractControlFlowGraph<?> cfg;
  45 
  46     /**
  47      * The linear-scan ordered list of blocks.
  48      */
  49     private final AbstractBlockBase<?>[] linearScanOrder;
  50 
  51     /**
  52      * The order in which the code is emitted.
  53      */
  54     private final AbstractBlockBase<?>[] codeEmittingOrder;
  55 
  56     /**
  57      * Map from {@linkplain AbstractBlockBase block} to {@linkplain LIRInstruction}s. Note that we
  58      * are using {@link ArrayList} instead of {@link List} to avoid interface dispatch.
  59      */
  60     private final BlockMap<ArrayList<LIRInstruction>> lirInstructions;
  61 
  62     private boolean hasArgInCallerFrame;
  63 
  64     private final OptionValues options;
  65 
  66     private final DebugContext debug;
  67 
  68     /**
  69      * Creates a new LIR instance for the specified compilation.
  70      */
  71     public LIR(AbstractControlFlowGraph<?> cfg, AbstractBlockBase<?>[] linearScanOrder, AbstractBlockBase<?>[] codeEmittingOrder, OptionValues options, DebugContext debug) {
  72         this.cfg = cfg;
  73         this.codeEmittingOrder = codeEmittingOrder;
  74         this.linearScanOrder = linearScanOrder;
  75         this.lirInstructions = new BlockMap<>(cfg);
  76         this.options = options;
  77         this.debug = debug;
  78     }
  79 
  80     public AbstractControlFlowGraph<?> getControlFlowGraph() {
  81         return cfg;
  82     }
  83 
  84     public OptionValues getOptions() {
  85         return options;
  86     }
  87 
  88     public DebugContext getDebug() {
  89         return debug;
  90     }
  91 
  92     /**
  93      * Determines if any instruction in the LIR has debug info associated with it.
  94      */
  95     public boolean hasDebugInfo() {
  96         for (AbstractBlockBase<?> b : linearScanOrder()) {
  97             for (LIRInstruction op : getLIRforBlock(b)) {
  98                 if (op.hasState()) {
  99                     return true;
 100                 }
 101             }
 102         }
 103         return false;
 104     }
 105 
 106     public ArrayList<LIRInstruction> getLIRforBlock(AbstractBlockBase<?> block) {
 107         return lirInstructions.get(block);
 108     }
 109 
 110     public void setLIRforBlock(AbstractBlockBase<?> block, ArrayList<LIRInstruction> list) {
 111         assert getLIRforBlock(block) == null : "lir instruction list should only be initialized once";


src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/LIR.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File