annotate graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java @ 19549:1cf73c50e3dc

Move SpillMoveFactory from LIR to LIRGeneratorTool.
author Josef Eisl <josef.eisl@jku.at>
date Thu, 12 Feb 2015 15:38:27 +0100
parents 312cf5a0376e
children a33fe10c4d93
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
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
27 import com.oracle.graal.compiler.common.cfg.*;
18431
84ac6a1a0dcb Introduce FrameMappingTool.
Josef Eisl <josef.eisl@jku.at>
parents: 17296
diff changeset
28 import com.oracle.graal.lir.StandardOp.BlockEndOp;
84ac6a1a0dcb Introduce FrameMappingTool.
Josef Eisl <josef.eisl@jku.at>
parents: 17296
diff changeset
29 import com.oracle.graal.lir.StandardOp.LabelOp;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6529
diff changeset
32 * 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
33 * optimization, and finalization.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34 */
19020
312cf5a0376e Remove FrameMapBuilder.requireMapping() (only LIR needs to be updated).
Josef Eisl <josef.eisl@jku.at>
parents: 18446
diff changeset
35 public class LIR {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36
14791
be2be30c653d Introduce AbstractControlFlowGraph.
Josef Eisl <josef.eisl@jku.at>
parents: 14786
diff changeset
37 private final AbstractControlFlowGraph<?> cfg;
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4365
diff changeset
38
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
39 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40 * The linear-scan ordered list of blocks.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41 */
14786
a6595f1b55b0 Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents: 14152
diff changeset
42 private final List<? extends AbstractBlock<?>> linearScanOrder;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
43
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 * The order in which the code is emitted.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
46 */
14786
a6595f1b55b0 Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents: 14152
diff changeset
47 private final List<? extends AbstractBlock<?>> codeEmittingOrder;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
48
11775
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 9297
diff changeset
49 private int firstVariableNumber;
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 9297
diff changeset
50
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
51 private int numVariables;
4262
744dade427b8 another batch of work towards GraalCompilation removal:
Lukas Stadler <lukas.stadler@jku.at>
parents: 4206
diff changeset
52
14145
4ff08c0366ae Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14144
diff changeset
53 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
54
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
55 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
56
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
57 /**
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
58 * 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
59 */
14791
be2be30c653d Introduce AbstractControlFlowGraph.
Josef Eisl <josef.eisl@jku.at>
parents: 14786
diff changeset
60 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
61 this.cfg = cfg;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
62 this.codeEmittingOrder = codeEmittingOrder;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
63 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
64 this.lirInstructions = new BlockMap<>(cfg);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66
14791
be2be30c653d Introduce AbstractControlFlowGraph.
Josef Eisl <josef.eisl@jku.at>
parents: 14786
diff changeset
67 public AbstractControlFlowGraph<?> getControlFlowGraph() {
14145
4ff08c0366ae Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14144
diff changeset
68 return cfg;
4ff08c0366ae Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14144
diff changeset
69 }
4ff08c0366ae Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14144
diff changeset
70
5248
066f1687ba24 rename: nodesFor -> blockToNodesMap
Doug Simon <doug.simon@oracle.com>
parents: 5233
diff changeset
71 /**
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
72 * 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
73 */
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
74 public boolean hasDebugInfo() {
14786
a6595f1b55b0 Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents: 14152
diff changeset
75 for (AbstractBlock<?> b : linearScanOrder()) {
14806
a8723f1ff542 LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents: 14801
diff changeset
76 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
77 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
78 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
79 }
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
80 }
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 }
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
82 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
83 }
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
84
14806
a8723f1ff542 LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents: 14801
diff changeset
85 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
86 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
87 }
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 5795
diff changeset
88
14806
a8723f1ff542 LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents: 14801
diff changeset
89 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
90 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
91 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
92 }
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 5795
diff changeset
93
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
94 /**
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
95 * 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
96 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
97 * @return the blocks in linear scan order
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
98 */
14786
a6595f1b55b0 Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents: 14152
diff changeset
99 public List<? extends AbstractBlock<?>> linearScanOrder() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
100 return linearScanOrder;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
101 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
102
14786
a6595f1b55b0 Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents: 14152
diff changeset
103 public List<? extends AbstractBlock<?>> codeEmittingOrder() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
104 return codeEmittingOrder;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
105 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
106
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
107 public int numVariables() {
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
108 return numVariables;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
109 }
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
110
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
111 public int nextVariable() {
11775
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 9297
diff changeset
112 return firstVariableNumber + numVariables++;
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 9297
diff changeset
113 }
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 9297
diff changeset
114
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 9297
diff changeset
115 public void setFirstVariableNumber(int num) {
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 9297
diff changeset
116 firstVariableNumber = num;
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
117 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
118
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
119 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
120 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
121 }
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
122
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
123 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6529
diff changeset
124 * 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
125 * 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
126 */
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
127 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
128 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
129 }
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
130
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
131 /**
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
132 * 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
133 */
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
134 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
135 final LabelRef[] exceptionEdge = {null};
17296
e03a25f5a260 Replace anonymous StateProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents: 17279
diff changeset
136 op.forEachState(state -> {
e03a25f5a260 Replace anonymous StateProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents: 17279
diff changeset
137 if (state.exceptionEdge != null) {
e03a25f5a260 Replace anonymous StateProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents: 17279
diff changeset
138 assert exceptionEdge[0] == null;
e03a25f5a260 Replace anonymous StateProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents: 17279
diff changeset
139 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
140 }
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
141 });
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
142 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
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
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 * 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
147 * 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
148 * 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
149 * 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
150 * <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
151 * 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
152 * 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
153 * 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
154 */
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
155 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
156
14786
a6595f1b55b0 Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents: 14152
diff changeset
157 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
158 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
159 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
160 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
161 }
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 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
163 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
164 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
165 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
166 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
167 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
168 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
169 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
170 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
171 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
172 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
173 }
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 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
175 }
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
176 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
177 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
178 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
179 }
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
180
14786
a6595f1b55b0 Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents: 14152
diff changeset
181 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
182 for (AbstractBlock<?> block : blocks) {
a6595f1b55b0 Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents: 14152
diff changeset
183 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
184 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
185 }
14786
a6595f1b55b0 Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents: 14152
diff changeset
186 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
187 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
188 }
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
189 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
190 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
191 }
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
192 }
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
193 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
194 }
14145
4ff08c0366ae Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14144
diff changeset
195
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
196 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
197
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
198 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
199 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
200 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
201 ((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
202 }
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
203 }
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
204 }
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
205 }
18431
84ac6a1a0dcb Introduce FrameMappingTool.
Josef Eisl <josef.eisl@jku.at>
parents: 17296
diff changeset
206
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
207 }