Mercurial > hg > truffle
annotate graal/GraalCompiler/src/com/sun/c1x/lir/LIRBlock.java @ 2761:d3398b21faf9
Re-enabled CFG optimization (now only on LIRBlock data structure).
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Sat, 21 May 2011 17:46:54 +0200 |
parents | 127db58b044e |
children | 43ffa0e47a46 |
rev | line source |
---|---|
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
1 /* |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
4 * |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
8 * |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
13 * accompanied this code). |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
14 * |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
18 * |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
21 * questions. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
22 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
23 package com.sun.c1x.lir; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
24 |
2718
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
25 import java.util.*; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
26 |
2677
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
2509
diff
changeset
|
27 import com.oracle.max.asm.*; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
28 import com.sun.c1x.alloc.*; |
2718
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
29 import com.sun.c1x.debug.*; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
30 import com.sun.c1x.ir.*; |
2761
d3398b21faf9
Re-enabled CFG optimization (now only on LIRBlock data structure).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2760
diff
changeset
|
31 import com.sun.c1x.util.*; |
2718
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
32 import com.sun.c1x.value.*; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
33 import com.sun.cri.ci.*; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
34 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
35 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
36 * The {@code LIRBlock} class definition. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
37 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
38 public final class LIRBlock { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
39 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
40 public final Label label = new Label(); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
41 private LIRList lir; |
2718
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
42 private final int blockID; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
43 private List<Instruction> instructions = new ArrayList<Instruction>(4); |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
44 private List<LIRBlock> predecessors = new ArrayList<LIRBlock>(); |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
45 private List<LIRBlock> successors = new ArrayList<LIRBlock>(); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
46 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
47 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
48 * Bit map specifying which {@linkplain OperandPool operands} are live upon entry to this block. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
49 * These are values used in this block or any of its successors where such value are not defined |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
50 * in this block. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
51 * The bit index of an operand is its {@linkplain OperandPool#operandNumber(com.sun.cri.ci.CiValue) operand number}. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
52 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
53 public CiBitMap liveIn; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
54 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
55 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
56 * Bit map specifying which {@linkplain OperandPool operands} are live upon exit from this block. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
57 * These are values used in a successor block that are either defined in this block or were live |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
58 * upon entry to this block. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
59 * The bit index of an operand is its {@linkplain OperandPool#operandNumber(com.sun.cri.ci.CiValue) operand number}. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
60 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
61 public CiBitMap liveOut; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
62 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
63 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
64 * Bit map specifying which {@linkplain OperandPool operands} are used (before being defined) in this block. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
65 * That is, these are the values that are live upon entry to the block. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
66 * The bit index of an operand is its {@linkplain OperandPool#operandNumber(com.sun.cri.ci.CiValue) operand number}. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
67 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
68 public CiBitMap liveGen; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
69 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
70 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
71 * Bit map specifying which {@linkplain OperandPool operands} are defined/overwritten in this block. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
72 * The bit index of an operand is its {@linkplain OperandPool#operandNumber(com.sun.cri.ci.CiValue) operand number}. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
73 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
74 public CiBitMap liveKill; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
75 |
2703
42450f536d24
More cleanup towards separation of graphbuilding<>graph<>lirgeneration
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2700
diff
changeset
|
76 private int firstLirInstructionID; |
42450f536d24
More cleanup towards separation of graphbuilding<>graph<>lirgeneration
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2700
diff
changeset
|
77 private int lastLirInstructionID; |
2707
7ed72769d51a
exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2677
diff
changeset
|
78 public int blockEntryPco; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
79 |
2718
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
80 public LIRBlock(int blockID) { |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
81 this.blockID = blockID; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
82 loopIndex = -1; |
2760
127db58b044e
One more step towards schedule.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2718
diff
changeset
|
83 linearScanNumber = blockID; |
2718
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
84 } |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
85 |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
86 public List<Instruction> getInstructions() { |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
87 return instructions; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
88 } |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
89 |
2703
42450f536d24
More cleanup towards separation of graphbuilding<>graph<>lirgeneration
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2700
diff
changeset
|
90 public int firstLirInstructionId() { |
42450f536d24
More cleanup towards separation of graphbuilding<>graph<>lirgeneration
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2700
diff
changeset
|
91 return firstLirInstructionID; |
42450f536d24
More cleanup towards separation of graphbuilding<>graph<>lirgeneration
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2700
diff
changeset
|
92 } |
42450f536d24
More cleanup towards separation of graphbuilding<>graph<>lirgeneration
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2700
diff
changeset
|
93 |
42450f536d24
More cleanup towards separation of graphbuilding<>graph<>lirgeneration
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2700
diff
changeset
|
94 public void setFirstLirInstructionId(int firstLirInstructionId) { |
42450f536d24
More cleanup towards separation of graphbuilding<>graph<>lirgeneration
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2700
diff
changeset
|
95 this.firstLirInstructionID = firstLirInstructionId; |
42450f536d24
More cleanup towards separation of graphbuilding<>graph<>lirgeneration
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2700
diff
changeset
|
96 } |
42450f536d24
More cleanup towards separation of graphbuilding<>graph<>lirgeneration
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2700
diff
changeset
|
97 |
42450f536d24
More cleanup towards separation of graphbuilding<>graph<>lirgeneration
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2700
diff
changeset
|
98 public int lastLirInstructionId() { |
42450f536d24
More cleanup towards separation of graphbuilding<>graph<>lirgeneration
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2700
diff
changeset
|
99 return lastLirInstructionID; |
42450f536d24
More cleanup towards separation of graphbuilding<>graph<>lirgeneration
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2700
diff
changeset
|
100 } |
42450f536d24
More cleanup towards separation of graphbuilding<>graph<>lirgeneration
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2700
diff
changeset
|
101 |
42450f536d24
More cleanup towards separation of graphbuilding<>graph<>lirgeneration
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2700
diff
changeset
|
102 public void setLastLirInstructionId(int lastLirInstructionId) { |
42450f536d24
More cleanup towards separation of graphbuilding<>graph<>lirgeneration
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2700
diff
changeset
|
103 this.lastLirInstructionID = lastLirInstructionId; |
42450f536d24
More cleanup towards separation of graphbuilding<>graph<>lirgeneration
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2700
diff
changeset
|
104 } |
2700 | 105 |
106 public int loopDepth; | |
107 public int loopIndex; | |
108 | |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
109 public LIRList lir() { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
110 return lir; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
111 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
112 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
113 public void setLir(LIRList lir) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
114 this.lir = lir; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
115 } |
2718
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
116 |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
117 public void setBlockEntryPco(int codePos) { |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
118 this.blockEntryPco = codePos; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
119 } |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
120 |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
121 public void printWithoutPhis(LogStream out) { |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
122 out.println("LIR Block " + blockID()); |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
123 } |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
124 |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
125 public int blockID() { |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
126 return blockID; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
127 } |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
128 |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
129 public int numberOfPreds() { |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
130 return predecessors.size(); |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
131 } |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
132 |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
133 public int numberOfSux() { |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
134 return successors.size(); |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
135 } |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
136 |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
137 public boolean isPredecessor(LIRBlock block) { |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
138 return predecessors.contains(block); |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
139 } |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
140 |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
141 public LIRBlock predAt(int i) { |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
142 return predecessors.get(i); |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
143 } |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
144 |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
145 public LIRBlock suxAt(int i) { |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
146 return successors.get(i); |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
147 } |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
148 |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
149 public List<LIRBlock> blockSuccessors() { |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
150 return successors; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
151 } |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
152 |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
153 public List<LIRBlock> blockPredecessors() { |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
154 return predecessors; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
155 } |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
156 |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
157 public int loopDepth() { |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
158 // TODO(tw): Set correct loop depth. |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
159 return 0; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
160 } |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
161 |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
162 public int loopIndex() { |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
163 // TODO(tw): Set correct loop index. |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
164 return -1; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
165 } |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
166 |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
167 public Label label() { |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
168 return label; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
169 } |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
170 |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
171 private int linearScanNumber = -1; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
172 private boolean linearScanLoopEnd; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
173 private boolean linearScanLoopHeader; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
174 private FrameState stateBefore; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
175 |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
176 public void setLinearScanNumber(int v) { |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
177 linearScanNumber = v; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
178 } |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
179 |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
180 public int linearScanNumber() { |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
181 return linearScanNumber; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
182 } |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
183 |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
184 public void setLinearScanLoopEnd() { |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
185 linearScanLoopEnd = true; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
186 } |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
187 |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
188 public boolean isLinearScanLoopEnd() { |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
189 return linearScanLoopEnd; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
190 } |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
191 |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
192 public void setLinearScanLoopHeader() { |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
193 this.linearScanLoopHeader = true; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
194 } |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
195 |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
196 public boolean isLinearScanLoopHeader() { |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
197 return linearScanLoopHeader; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
198 } |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
199 |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
200 public void setStateBefore(FrameState stateBefore) { |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
201 this.stateBefore = stateBefore; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
202 } |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
203 |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
204 public FrameState stateBefore() { |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
205 return stateBefore; |
c1ce2a53d6c3
Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2708
diff
changeset
|
206 } |
2761
d3398b21faf9
Re-enabled CFG optimization (now only on LIRBlock data structure).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2760
diff
changeset
|
207 |
d3398b21faf9
Re-enabled CFG optimization (now only on LIRBlock data structure).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2760
diff
changeset
|
208 public void replaceWith(LIRBlock other) { |
d3398b21faf9
Re-enabled CFG optimization (now only on LIRBlock data structure).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2760
diff
changeset
|
209 for (LIRBlock pred : predecessors) { |
d3398b21faf9
Re-enabled CFG optimization (now only on LIRBlock data structure).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2760
diff
changeset
|
210 Util.replaceAllInList(this, other, pred.successors); |
d3398b21faf9
Re-enabled CFG optimization (now only on LIRBlock data structure).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2760
diff
changeset
|
211 } |
d3398b21faf9
Re-enabled CFG optimization (now only on LIRBlock data structure).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2760
diff
changeset
|
212 for (int i = 0; i < other.predecessors.size(); ++i) { |
d3398b21faf9
Re-enabled CFG optimization (now only on LIRBlock data structure).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2760
diff
changeset
|
213 if (other.predecessors.get(i) == this) { |
d3398b21faf9
Re-enabled CFG optimization (now only on LIRBlock data structure).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2760
diff
changeset
|
214 other.predecessors.remove(i); |
d3398b21faf9
Re-enabled CFG optimization (now only on LIRBlock data structure).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2760
diff
changeset
|
215 other.predecessors.addAll(i, this.predecessors); |
d3398b21faf9
Re-enabled CFG optimization (now only on LIRBlock data structure).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2760
diff
changeset
|
216 } |
d3398b21faf9
Re-enabled CFG optimization (now only on LIRBlock data structure).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2760
diff
changeset
|
217 } |
d3398b21faf9
Re-enabled CFG optimization (now only on LIRBlock data structure).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2760
diff
changeset
|
218 successors.clear(); |
d3398b21faf9
Re-enabled CFG optimization (now only on LIRBlock data structure).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2760
diff
changeset
|
219 predecessors.clear(); |
d3398b21faf9
Re-enabled CFG optimization (now only on LIRBlock data structure).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2760
diff
changeset
|
220 } |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
221 } |