annotate graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java @ 19020:312cf5a0376e

Remove FrameMapBuilder.requireMapping() (only LIR needs to be updated).
author Josef Eisl <josef.eisl@jku.at>
date Wed, 03 Dec 2014 20:21:24 +0100
parents 163d1a082ccc
children 1cf73c50e3dc 4d70d150944f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
2 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
23 package com.oracle.graal.lir;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
25 import java.util.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
26
14121
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14058
diff changeset
27 import com.oracle.graal.api.meta.*;
15192
644dfe49c0f4 Move packages com.oracle.graal.cfg to com.oracle.graal.compiler.common.cfg.
Josef Eisl <josef.eisl@jku.at>
parents: 15157
diff changeset
28 import com.oracle.graal.compiler.common.cfg.*;
18431
84ac6a1a0dcb Introduce FrameMappingTool.
Josef Eisl <josef.eisl@jku.at>
parents: 17296
diff changeset
29 import com.oracle.graal.lir.StandardOp.BlockEndOp;
84ac6a1a0dcb Introduce FrameMappingTool.
Josef Eisl <josef.eisl@jku.at>
parents: 17296
diff changeset
30 import com.oracle.graal.lir.StandardOp.LabelOp;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6529
diff changeset
33 * This class implements the overall container for the LIR graph and directs its construction,
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6529
diff changeset
34 * optimization, and finalization.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35 */
19020
312cf5a0376e Remove FrameMapBuilder.requireMapping() (only LIR needs to be updated).
Josef Eisl <josef.eisl@jku.at>
parents: 18446
diff changeset
36 public class LIR {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37
14791
be2be30c653d Introduce AbstractControlFlowGraph.
Josef Eisl <josef.eisl@jku.at>
parents: 14786
diff changeset
38 private final AbstractControlFlowGraph<?> cfg;
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4365
diff changeset
39
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41 * The linear-scan ordered list of blocks.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
42 */
14786
a6595f1b55b0 Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents: 14152
diff changeset
43 private final List<? extends AbstractBlock<?>> linearScanOrder;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
44
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
45 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
46 * The order in which the code is emitted.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
47 */
14786
a6595f1b55b0 Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents: 14152
diff changeset
48 private final List<? extends AbstractBlock<?>> codeEmittingOrder;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
49
11775
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 9297
diff changeset
50 private int firstVariableNumber;
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 9297
diff changeset
51
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
52 private int numVariables;
4262
744dade427b8 another batch of work towards GraalCompilation removal:
Lukas Stadler <lukas.stadler@jku.at>
parents: 4206
diff changeset
53
14145
4ff08c0366ae Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14144
diff changeset
54 private SpillMoveFactory spillMoveFactory;
14121
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14058
diff changeset
55
14145
4ff08c0366ae Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14144
diff changeset
56 private final BlockMap<List<LIRInstruction>> lirInstructions;
6411
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 5795
diff changeset
57
14121
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14058
diff changeset
58 public interface SpillMoveFactory {
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14058
diff changeset
59
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14058
diff changeset
60 LIRInstruction createMove(AllocatableValue result, Value input);
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14058
diff changeset
61 }
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14058
diff changeset
62
5251
467de393651a optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents: 5248
diff changeset
63 private boolean hasArgInCallerFrame;
467de393651a optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents: 5248
diff changeset
64
5233
efbb1e33e2f3 removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents: 5061
diff changeset
65 /**
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66 * Creates a new LIR instance for the specified compilation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67 */
14791
be2be30c653d Introduce AbstractControlFlowGraph.
Josef Eisl <josef.eisl@jku.at>
parents: 14786
diff changeset
68 public LIR(AbstractControlFlowGraph<?> cfg, List<? extends AbstractBlock<?>> linearScanOrder, List<? extends AbstractBlock<?>> codeEmittingOrder) {
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4365
diff changeset
69 this.cfg = cfg;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
70 this.codeEmittingOrder = codeEmittingOrder;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
71 this.linearScanOrder = linearScanOrder;
6411
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 5795
diff changeset
72 this.lirInstructions = new BlockMap<>(cfg);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
73 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
74
14791
be2be30c653d Introduce AbstractControlFlowGraph.
Josef Eisl <josef.eisl@jku.at>
parents: 14786
diff changeset
75 public AbstractControlFlowGraph<?> getControlFlowGraph() {
14145
4ff08c0366ae Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14144
diff changeset
76 return cfg;
4ff08c0366ae Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14144
diff changeset
77 }
4ff08c0366ae Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14144
diff changeset
78
5248
066f1687ba24 rename: nodesFor -> blockToNodesMap
Doug Simon <doug.simon@oracle.com>
parents: 5233
diff changeset
79 /**
8290
9882af5c8504 AMD64 HotSpot backend now models RBP as an incoming parameter that must be preserved until the end of the method. For non-leaf methods, the value is preserved in the special stack slot required by the HotSpot runtime for walking/inspecting frames of such methods.
Doug Simon <doug.simon@oracle.com>
parents: 8217
diff changeset
80 * Determines if any instruction in the LIR has debug info associated with it.
5233
efbb1e33e2f3 removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents: 5061
diff changeset
81 */
5251
467de393651a optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents: 5248
diff changeset
82 public boolean hasDebugInfo() {
14786
a6595f1b55b0 Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents: 14152
diff changeset
83 for (AbstractBlock<?> b : linearScanOrder()) {
14806
a8723f1ff542 LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents: 14801
diff changeset
84 for (LIRInstruction op : getLIRforBlock(b)) {
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
85 if (op.hasState()) {
5233
efbb1e33e2f3 removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents: 5061
diff changeset
86 return true;
efbb1e33e2f3 removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents: 5061
diff changeset
87 }
efbb1e33e2f3 removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents: 5061
diff changeset
88 }
efbb1e33e2f3 removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents: 5061
diff changeset
89 }
efbb1e33e2f3 removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents: 5061
diff changeset
90 return false;
efbb1e33e2f3 removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents: 5061
diff changeset
91 }
efbb1e33e2f3 removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents: 5061
diff changeset
92
14145
4ff08c0366ae Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14144
diff changeset
93 public SpillMoveFactory getSpillMoveFactory() {
4ff08c0366ae Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14144
diff changeset
94 return spillMoveFactory;
4ff08c0366ae Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14144
diff changeset
95 }
4ff08c0366ae Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14144
diff changeset
96
14806
a8723f1ff542 LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents: 14801
diff changeset
97 public List<LIRInstruction> getLIRforBlock(AbstractBlock<?> block) {
6411
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 5795
diff changeset
98 return lirInstructions.get(block);
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 5795
diff changeset
99 }
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 5795
diff changeset
100
14806
a8723f1ff542 LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents: 14801
diff changeset
101 public void setLIRforBlock(AbstractBlock<?> block, List<LIRInstruction> list) {
a8723f1ff542 LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents: 14801
diff changeset
102 assert getLIRforBlock(block) == null : "lir instruction list should only be initialized once";
6411
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 5795
diff changeset
103 lirInstructions.put(block, list);
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 5795
diff changeset
104 }
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 5795
diff changeset
105
5233
efbb1e33e2f3 removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents: 5061
diff changeset
106 /**
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
107 * Gets the linear scan ordering of blocks as a list.
15157
f4e31f06b019 Create com.oracle.graal.cfg project and move CFG related files.
Josef Eisl <josef.eisl@jku.at>
parents: 14806
diff changeset
108 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
109 * @return the blocks in linear scan order
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
110 */
14786
a6595f1b55b0 Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents: 14152
diff changeset
111 public List<? extends AbstractBlock<?>> linearScanOrder() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
112 return linearScanOrder;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
113 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
114
14786
a6595f1b55b0 Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents: 14152
diff changeset
115 public List<? extends AbstractBlock<?>> codeEmittingOrder() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
116 return codeEmittingOrder;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
117 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
118
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
119 public int numVariables() {
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
120 return numVariables;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
121 }
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
122
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
123 public int nextVariable() {
11775
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 9297
diff changeset
124 return firstVariableNumber + numVariables++;
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 9297
diff changeset
125 }
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 9297
diff changeset
126
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 9297
diff changeset
127 public void setFirstVariableNumber(int num) {
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 9297
diff changeset
128 firstVariableNumber = num;
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
129 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
130
5251
467de393651a optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents: 5248
diff changeset
131 public void setHasArgInCallerFrame() {
467de393651a optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents: 5248
diff changeset
132 hasArgInCallerFrame = true;
467de393651a optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents: 5248
diff changeset
133 }
467de393651a optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents: 5248
diff changeset
134
467de393651a optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents: 5248
diff changeset
135 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6529
diff changeset
136 * Determines if any of the parameters to the method are passed via the stack where the
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6529
diff changeset
137 * parameters are located in the caller's frame.
5251
467de393651a optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents: 5248
diff changeset
138 */
467de393651a optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents: 5248
diff changeset
139 public boolean hasArgInCallerFrame() {
467de393651a optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents: 5248
diff changeset
140 return hasArgInCallerFrame;
467de393651a optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents: 5248
diff changeset
141 }
13268
68b964b6dc8e introduced BlockEndOp interface and require that every LIR block is terminated by such an operation
Doug Simon <doug.simon@oracle.com>
parents: 13234
diff changeset
142
13317
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
143 /**
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
144 * Gets the exception edge (if any) originating at a given operation.
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
145 */
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
146 public static LabelRef getExceptionEdge(LIRInstruction op) {
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
147 final LabelRef[] exceptionEdge = {null};
17296
e03a25f5a260 Replace anonymous StateProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents: 17279
diff changeset
148 op.forEachState(state -> {
e03a25f5a260 Replace anonymous StateProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents: 17279
diff changeset
149 if (state.exceptionEdge != null) {
e03a25f5a260 Replace anonymous StateProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents: 17279
diff changeset
150 assert exceptionEdge[0] == null;
e03a25f5a260 Replace anonymous StateProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents: 17279
diff changeset
151 exceptionEdge[0] = state.exceptionEdge;
13317
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
152 }
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
153 });
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
154 return exceptionEdge[0];
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
155 }
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
156
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
157 /**
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
158 * The maximum distance an operation with an {@linkplain #getExceptionEdge(LIRInstruction)
13354
5a7508f1a7ff Fix LIR assertion (distance between an operation with an exception edge and the last introduction of a LIR block)
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 13318
diff changeset
159 * exception edge} can be from the last instruction of a LIR block. The value of 3 is based on a
5a7508f1a7ff Fix LIR assertion (distance between an operation with an exception edge and the last introduction of a LIR block)
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 13318
diff changeset
160 * non-void call operation that has an exception edge. Such a call may move the result to
5a7508f1a7ff Fix LIR assertion (distance between an operation with an exception edge and the last introduction of a LIR block)
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 13318
diff changeset
161 * another register and then spill it.
13317
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
162 * <p>
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
163 * The rationale for such a constant is to limit the search for an insertion point when adding
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
164 * move operations at the end of a block. Such moves must be inserted before all control flow
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
165 * instructions.
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
166 */
13354
5a7508f1a7ff Fix LIR assertion (distance between an operation with an exception edge and the last introduction of a LIR block)
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 13318
diff changeset
167 public static final int MAX_EXCEPTION_EDGE_OP_DISTANCE_FROM_END = 3;
13317
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
168
14786
a6595f1b55b0 Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents: 14152
diff changeset
169 public static boolean verifyBlock(LIR lir, AbstractBlock<?> block) {
14806
a8723f1ff542 LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents: 14801
diff changeset
170 List<LIRInstruction> ops = lir.getLIRforBlock(block);
13268
68b964b6dc8e introduced BlockEndOp interface and require that every LIR block is terminated by such an operation
Doug Simon <doug.simon@oracle.com>
parents: 13234
diff changeset
171 if (ops.size() == 0) {
13317
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
172 return false;
13268
68b964b6dc8e introduced BlockEndOp interface and require that every LIR block is terminated by such an operation
Doug Simon <doug.simon@oracle.com>
parents: 13234
diff changeset
173 }
13317
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
174 LIRInstruction opWithExceptionEdge = null;
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
175 int index = 0;
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
176 int lastIndex = ops.size() - 1;
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
177 for (LIRInstruction op : ops.subList(0, lastIndex)) {
13268
68b964b6dc8e introduced BlockEndOp interface and require that every LIR block is terminated by such an operation
Doug Simon <doug.simon@oracle.com>
parents: 13234
diff changeset
178 assert !(op instanceof BlockEndOp) : op.getClass();
13317
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
179 LabelRef exceptionEdge = getExceptionEdge(op);
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
180 if (exceptionEdge != null) {
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
181 assert opWithExceptionEdge == null : "multiple ops with an exception edge not allowed";
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
182 opWithExceptionEdge = op;
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
183 int distanceFromEnd = lastIndex - index;
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
184 assert distanceFromEnd <= MAX_EXCEPTION_EDGE_OP_DISTANCE_FROM_END;
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
185 }
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
186 index++;
13268
68b964b6dc8e introduced BlockEndOp interface and require that every LIR block is terminated by such an operation
Doug Simon <doug.simon@oracle.com>
parents: 13234
diff changeset
187 }
13317
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
188 LIRInstruction end = ops.get(lastIndex);
13268
68b964b6dc8e introduced BlockEndOp interface and require that every LIR block is terminated by such an operation
Doug Simon <doug.simon@oracle.com>
parents: 13234
diff changeset
189 assert end instanceof BlockEndOp : end.getClass();
68b964b6dc8e introduced BlockEndOp interface and require that every LIR block is terminated by such an operation
Doug Simon <doug.simon@oracle.com>
parents: 13234
diff changeset
190 return true;
68b964b6dc8e introduced BlockEndOp interface and require that every LIR block is terminated by such an operation
Doug Simon <doug.simon@oracle.com>
parents: 13234
diff changeset
191 }
68b964b6dc8e introduced BlockEndOp interface and require that every LIR block is terminated by such an operation
Doug Simon <doug.simon@oracle.com>
parents: 13234
diff changeset
192
14786
a6595f1b55b0 Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents: 14152
diff changeset
193 public static boolean verifyBlocks(LIR lir, List<? extends AbstractBlock<?>> blocks) {
a6595f1b55b0 Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents: 14152
diff changeset
194 for (AbstractBlock<?> block : blocks) {
a6595f1b55b0 Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents: 14152
diff changeset
195 for (AbstractBlock<?> sux : block.getSuccessors()) {
13268
68b964b6dc8e introduced BlockEndOp interface and require that every LIR block is terminated by such an operation
Doug Simon <doug.simon@oracle.com>
parents: 13234
diff changeset
196 assert blocks.contains(sux) : "missing successor from: " + block + "to: " + sux;
68b964b6dc8e introduced BlockEndOp interface and require that every LIR block is terminated by such an operation
Doug Simon <doug.simon@oracle.com>
parents: 13234
diff changeset
197 }
14786
a6595f1b55b0 Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents: 14152
diff changeset
198 for (AbstractBlock<?> pred : block.getPredecessors()) {
13268
68b964b6dc8e introduced BlockEndOp interface and require that every LIR block is terminated by such an operation
Doug Simon <doug.simon@oracle.com>
parents: 13234
diff changeset
199 assert blocks.contains(pred) : "missing predecessor from: " + block + "to: " + pred;
68b964b6dc8e introduced BlockEndOp interface and require that every LIR block is terminated by such an operation
Doug Simon <doug.simon@oracle.com>
parents: 13234
diff changeset
200 }
13317
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
201 if (!verifyBlock(lir, block)) {
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
202 return false;
755645fa92d6 the load of a constant is commoned to the nearest block dominating all usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13268
diff changeset
203 }
13268
68b964b6dc8e introduced BlockEndOp interface and require that every LIR block is terminated by such an operation
Doug Simon <doug.simon@oracle.com>
parents: 13234
diff changeset
204 }
68b964b6dc8e introduced BlockEndOp interface and require that every LIR block is terminated by such an operation
Doug Simon <doug.simon@oracle.com>
parents: 13234
diff changeset
205 return true;
68b964b6dc8e introduced BlockEndOp interface and require that every LIR block is terminated by such an operation
Doug Simon <doug.simon@oracle.com>
parents: 13234
diff changeset
206 }
14145
4ff08c0366ae Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14144
diff changeset
207
4ff08c0366ae Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14144
diff changeset
208 public void setSpillMoveFactory(SpillMoveFactory spillMoveFactory) {
4ff08c0366ae Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14144
diff changeset
209 this.spillMoveFactory = spillMoveFactory;
4ff08c0366ae Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14144
diff changeset
210 }
17207
5a7b82c1514e [SPARC] Add functionality to be able to do assembly in two passes (knowing offsets of forward branches)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16796
diff changeset
211
5a7b82c1514e [SPARC] Add functionality to be able to do assembly in two passes (knowing offsets of forward branches)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16796
diff changeset
212 public void resetLabels() {
5a7b82c1514e [SPARC] Add functionality to be able to do assembly in two passes (knowing offsets of forward branches)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16796
diff changeset
213
5a7b82c1514e [SPARC] Add functionality to be able to do assembly in two passes (knowing offsets of forward branches)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16796
diff changeset
214 for (AbstractBlock<?> block : codeEmittingOrder()) {
5a7b82c1514e [SPARC] Add functionality to be able to do assembly in two passes (knowing offsets of forward branches)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16796
diff changeset
215 for (LIRInstruction inst : lirInstructions.get(block)) {
5a7b82c1514e [SPARC] Add functionality to be able to do assembly in two passes (knowing offsets of forward branches)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16796
diff changeset
216 if (inst instanceof LabelOp) {
5a7b82c1514e [SPARC] Add functionality to be able to do assembly in two passes (knowing offsets of forward branches)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16796
diff changeset
217 ((LabelOp) inst).getLabel().reset();
5a7b82c1514e [SPARC] Add functionality to be able to do assembly in two passes (knowing offsets of forward branches)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16796
diff changeset
218 }
5a7b82c1514e [SPARC] Add functionality to be able to do assembly in two passes (knowing offsets of forward branches)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16796
diff changeset
219 }
5a7b82c1514e [SPARC] Add functionality to be able to do assembly in two passes (knowing offsets of forward branches)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16796
diff changeset
220 }
5a7b82c1514e [SPARC] Add functionality to be able to do assembly in two passes (knowing offsets of forward branches)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16796
diff changeset
221 }
18431
84ac6a1a0dcb Introduce FrameMappingTool.
Josef Eisl <josef.eisl@jku.at>
parents: 17296
diff changeset
222
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
223 }