Mercurial > hg > truffle
annotate graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java @ 14791:be2be30c653d
Introduce AbstractControlFlowGraph.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Wed, 12 Mar 2014 20:40:01 +0100 |
parents | a6595f1b55b0 |
children | 66d3397c2c0d |
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.*; |
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
|
28 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
|
29 import com.oracle.graal.lir.StandardOp.BlockEndOp; |
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 |
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()) { |
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
|
84 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
|
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 |
14152
42013bd831d6
Make LinearScan use AbstractBlock.
Josef Eisl <josef.eisl@jku.at>
parents:
14145
diff
changeset
|
97 public List<LIRInstruction> lir(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 |
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 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
|
102 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
|
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. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6529
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}; |
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 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
|
149 @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
|
150 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
|
151 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
|
152 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
|
153 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
|
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 }); |
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 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
|
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 /** |
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
|
161 * 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
|
162 * 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
|
163 * 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
|
164 * 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
|
165 * <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
|
166 * 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
|
167 * 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
|
168 * 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
|
169 */ |
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
|
170 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
|
171 |
14786
a6595f1b55b0
Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents:
14152
diff
changeset
|
172 public static boolean verifyBlock(LIR lir, AbstractBlock<?> 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
|
173 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
|
174 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
|
175 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
|
176 } |
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
|
177 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
|
178 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
|
179 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
|
180 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
|
181 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
|
182 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
|
183 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
|
184 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
|
185 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
|
186 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
|
187 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
|
188 } |
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 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
|
190 } |
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
|
191 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
|
192 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
|
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 } |
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 |
14786
a6595f1b55b0
Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents:
14152
diff
changeset
|
196 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
|
197 for (AbstractBlock<?> block : blocks) { |
a6595f1b55b0
Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents:
14152
diff
changeset
|
198 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
|
199 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
|
200 } |
14786
a6595f1b55b0
Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents:
14152
diff
changeset
|
201 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
|
202 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
|
203 } |
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
|
204 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
|
205 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
|
206 } |
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
|
207 } |
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 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
|
209 } |
14145
4ff08c0366ae
Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14144
diff
changeset
|
210 |
4ff08c0366ae
Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14144
diff
changeset
|
211 public void setSpillMoveFactory(SpillMoveFactory spillMoveFactory) { |
4ff08c0366ae
Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14144
diff
changeset
|
212 this.spillMoveFactory = spillMoveFactory; |
4ff08c0366ae
Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14144
diff
changeset
|
213 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
214 } |