Mercurial > hg > truffle
annotate graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java @ 14058:d451a134a545
Remove unused import.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 25 Feb 2014 18:16:59 +0100 |
parents | 38c881305352 |
children | 0ddb3b3665bd |
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 |
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
|
27 import com.oracle.graal.lir.LIRInstruction.StateProcedure; |
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
|
28 import com.oracle.graal.lir.StandardOp.BlockEndOp; |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5539
diff
changeset
|
29 import com.oracle.graal.nodes.*; |
6529
2e96dc4eb8e2
renamed package: com.oracle.graal.lir.cfg -> com.oracle.graal.nodes.cfg
Doug Simon <doug.simon@oracle.com>
parents:
6411
diff
changeset
|
30 import com.oracle.graal.nodes.cfg.*; |
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 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
36 public class LIR { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4365
diff
changeset
|
38 public final ControlFlowGraph cfg; |
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 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6529
diff
changeset
|
41 * The nodes for the blocks. TODO: This should go away, we want all nodes connected with a |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6529
diff
changeset
|
42 * next-pointer. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 */ |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5539
diff
changeset
|
44 private final BlockMap<List<ScheduledNode>> blockToNodesMap; |
3733
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 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 * The linear-scan ordered list of blocks. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 */ |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4365
diff
changeset
|
49 private final List<Block> linearScanOrder; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 * The order in which the code is emitted. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 */ |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4365
diff
changeset
|
54 private final List<Block> codeEmittingOrder; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 |
11775
b04b94b71649
Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents:
9297
diff
changeset
|
56 private int firstVariableNumber; |
b04b94b71649
Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents:
9297
diff
changeset
|
57 |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
58 private int numVariables; |
4262
744dade427b8
another batch of work towards GraalCompilation removal:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4206
diff
changeset
|
59 |
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
|
60 public final BlockMap<List<LIRInstruction>> lirInstructions; |
c5afcc2ebd3d
change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents:
5795
diff
changeset
|
61 |
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
|
62 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
|
63 |
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
|
64 /** |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
65 * 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
|
66 */ |
11833
b71a1d889db2
SpeculationLog gives back the necessary Constant when calling maySpeculate. Remove the deoptimizationReasonfrom the DebugInfo
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11775
diff
changeset
|
67 public LIR(ControlFlowGraph cfg, BlockMap<List<ScheduledNode>> blockToNodesMap, List<Block> linearScanOrder, List<Block> codeEmittingOrder) { |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4365
diff
changeset
|
68 this.cfg = cfg; |
5248
066f1687ba24
rename: nodesFor -> blockToNodesMap
Doug Simon <doug.simon@oracle.com>
parents:
5233
diff
changeset
|
69 this.blockToNodesMap = blockToNodesMap; |
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 |
5248
066f1687ba24
rename: nodesFor -> blockToNodesMap
Doug Simon <doug.simon@oracle.com>
parents:
5233
diff
changeset
|
75 /** |
066f1687ba24
rename: nodesFor -> blockToNodesMap
Doug Simon <doug.simon@oracle.com>
parents:
5233
diff
changeset
|
76 * Gets the nodes in a given block. |
066f1687ba24
rename: nodesFor -> blockToNodesMap
Doug Simon <doug.simon@oracle.com>
parents:
5233
diff
changeset
|
77 */ |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5539
diff
changeset
|
78 public List<ScheduledNode> nodesFor(Block block) { |
5248
066f1687ba24
rename: nodesFor -> blockToNodesMap
Doug Simon <doug.simon@oracle.com>
parents:
5233
diff
changeset
|
79 return blockToNodesMap.get(block); |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4365
diff
changeset
|
80 } |
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4365
diff
changeset
|
81 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
82 /** |
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
|
83 * 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
|
84 */ |
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
|
85 public boolean hasDebugInfo() { |
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
|
86 for (Block b : 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
|
87 for (LIRInstruction op : lir(b)) { |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5711
diff
changeset
|
88 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
|
89 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
|
90 } |
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 } |
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
|
93 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
|
94 } |
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
|
95 |
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
|
96 public List<LIRInstruction> lir(Block 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
|
97 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
|
98 } |
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 public void setLir(Block block, List<LIRInstruction> 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
|
101 assert lir(block) == null : "lir instruction list should only be initialized once"; |
c5afcc2ebd3d
change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents:
5795
diff
changeset
|
102 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
|
103 } |
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 |
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
|
105 /** |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
106 * Gets the linear scan ordering of blocks as a list. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6529
diff
changeset
|
107 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
108 * @return the blocks in linear scan order |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
109 */ |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4365
diff
changeset
|
110 public List<Block> linearScanOrder() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
111 return linearScanOrder; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
112 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
113 |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4365
diff
changeset
|
114 public List<Block> codeEmittingOrder() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
115 return codeEmittingOrder; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
116 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
117 |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
118 public int numVariables() { |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
119 return numVariables; |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
120 } |
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 public int nextVariable() { |
11775
b04b94b71649
Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents:
9297
diff
changeset
|
123 return firstVariableNumber + numVariables++; |
b04b94b71649
Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents:
9297
diff
changeset
|
124 } |
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 public void setFirstVariableNumber(int num) { |
b04b94b71649
Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents:
9297
diff
changeset
|
127 firstVariableNumber = num; |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
128 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
129 |
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
|
130 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
|
131 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
|
132 } |
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 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6529
diff
changeset
|
135 * 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
|
136 * 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
|
137 */ |
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 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
|
139 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
|
140 } |
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
|
141 |
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
|
142 /** |
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 * 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
|
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 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
|
146 final LabelRef[] 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
|
147 op.forEachState(new StateProcedure() { |
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
|
148 @Override |
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
|
149 protected void doState(LIRFrameState state) { |
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 if (state.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
|
151 assert exceptionEdge[0] == 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
|
152 exceptionEdge[0] = state.exceptionEdge; |
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 } |
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 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
|
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 |
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
|
159 /** |
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 * 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
|
161 * 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
|
162 * 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
|
163 * 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
|
164 * <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
|
165 * 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
|
166 * 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
|
167 * 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
|
168 */ |
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
|
169 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
|
170 |
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 public static boolean verifyBlock(LIR lir, Block block) { |
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
|
172 List<LIRInstruction> ops = lir.lir(block); |
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 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
|
174 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
|
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 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
|
177 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
|
178 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
|
179 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
|
180 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
|
181 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
|
182 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
|
183 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
|
184 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
|
185 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
|
186 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
|
187 } |
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 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
|
189 } |
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
|
190 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
|
191 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
|
192 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
|
193 } |
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 |
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
|
195 public static boolean verifyBlocks(LIR lir, List<Block> blocks) { |
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 for (Block block : blocks) { |
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 for (Block sux : block.getSuccessors()) { |
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
|
198 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
|
199 } |
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 for (Block pred : block.getPredecessors()) { |
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
|
201 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
|
202 } |
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
|
203 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
|
204 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
|
205 } |
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
|
206 } |
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
|
207 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
|
208 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
209 } |