comparison graal/GraalCompiler/src/com/sun/c1x/lir/LIRBranch.java @ 2725:c379183d1c54

Removed target block references from LIR to BlockBegin instructions. Now there is a getLIRBlock method in the LIRGenerator.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Thu, 19 May 2011 16:56:05 +0200
parents 0ea5f12e873a
children
comparison
equal deleted inserted replaced
2724:e2d20fc3760f 2725:c379183d1c54
38 private Label label; 38 private Label label;
39 39
40 /** 40 /**
41 * The target block of this branch. 41 * The target block of this branch.
42 */ 42 */
43 private BlockBegin block; 43 private LIRBlock block;
44 44
45 /** 45 /**
46 * This is the unordered block for a float branch. 46 * This is the unordered block for a float branch.
47 */ 47 */
48 private BlockBegin unorderedBlock; 48 private LIRBlock unorderedBlock;
49 49
50 50
51 public LIRBranch(Condition cond, Label label) { 51 public LIRBranch(Condition cond, Label label) {
52 this(cond, label, null); 52 this(cond, label, null);
53 } 53 }
71 * @param cond 71 * @param cond
72 * @param kind 72 * @param kind
73 * @param block 73 * @param block
74 * 74 *
75 */ 75 */
76 public LIRBranch(Condition cond, CiKind kind, BlockBegin block) { 76 public LIRBranch(Condition cond, CiKind kind, LIRBlock block) {
77 super(LIROpcode.Branch, CiValue.IllegalValue, null, false); 77 super(LIROpcode.Branch, CiValue.IllegalValue, null, false);
78 this.cond = cond; 78 this.cond = cond;
79 this.kind = kind; 79 this.kind = kind;
80 this.label = block.label(); 80 this.label = block.label();
81 this.block = block; 81 this.block = block;
82 this.unorderedBlock = null; 82 this.unorderedBlock = null;
83 } 83 }
84 84
85 public LIRBranch(Condition cond, CiKind kind, BlockBegin block, BlockBegin ublock) { 85 public LIRBranch(Condition cond, CiKind kind, LIRBlock block, LIRBlock ublock) {
86 super(LIROpcode.CondFloatBranch, CiValue.IllegalValue, null, false); 86 super(LIROpcode.CondFloatBranch, CiValue.IllegalValue, null, false);
87 this.cond = cond; 87 this.cond = cond;
88 this.kind = kind; 88 this.kind = kind;
89 this.label = block.label(); 89 this.label = block.label();
90 this.block = block; 90 this.block = block;
100 100
101 public Label label() { 101 public Label label() {
102 return label; 102 return label;
103 } 103 }
104 104
105 public BlockBegin block() { 105 public LIRBlock block() {
106 return block; 106 return block;
107 } 107 }
108 108
109 public BlockBegin unorderedBlock() { 109 public LIRBlock unorderedBlock() {
110 return unorderedBlock; 110 return unorderedBlock;
111 } 111 }
112 112
113 public void changeBlock(BlockBegin b) { 113 public void changeBlock(LIRBlock b) {
114 assert block != null : "must have old block"; 114 assert block != null : "must have old block";
115 assert block.label() == label() : "must be equal"; 115 assert block.label() == label() : "must be equal";
116 116
117 this.block = b; 117 this.block = b;
118 this.label = b.label(); 118 this.label = b.label();
119 } 119 }
120 120
121 public void changeUblock(BlockBegin b) { 121 public void changeUblock(LIRBlock b) {
122 assert unorderedBlock != null : "must have old block"; 122 assert unorderedBlock != null : "must have old block";
123 this.unorderedBlock = b; 123 this.unorderedBlock = b;
124 } 124 }
125 125
126 public void negateCondition() { 126 public void negateCondition() {
134 134
135 @Override 135 @Override
136 public String operationString(OperandFormatter operandFmt) { 136 public String operationString(OperandFormatter operandFmt) {
137 StringBuilder buf = new StringBuilder(cond().operator).append(' '); 137 StringBuilder buf = new StringBuilder(cond().operator).append(' ');
138 if (block() != null) { 138 if (block() != null) {
139 buf.append("[B").append(block.blockID).append(']'); 139 buf.append("[B").append(block.blockID()).append(']');
140 } else if (label().isBound()) { 140 } else if (label().isBound()) {
141 buf.append("[label:0x").append(Integer.toHexString(label().position())).append(']'); 141 buf.append("[label:0x").append(Integer.toHexString(label().position())).append(']');
142 } else { 142 } else {
143 buf.append("[label:??]"); 143 buf.append("[label:??]");
144 } 144 }
145 if (unorderedBlock() != null) { 145 if (unorderedBlock() != null) {
146 buf.append("unordered: [B").append(unorderedBlock().blockID).append(']'); 146 buf.append("unordered: [B").append(unorderedBlock().blockID()).append(']');
147 } 147 }
148 return buf.toString(); 148 return buf.toString();
149 } 149 }
150 150
151 public void substitute(BlockBegin oldBlock, BlockBegin newBlock) { 151 public void substitute(LIRBlock oldBlock, LIRBlock newBlock) {
152 if (block == oldBlock) { 152 if (block == oldBlock) {
153 block = newBlock; 153 block = newBlock;
154 LIRInstruction instr = newBlock.lir().instructionsList().get(0); 154 LIRInstruction instr = newBlock.lir().instructionsList().get(0);
155 assert instr instanceof LIRLabel : "first instruction of block must be label"; 155 assert instr instanceof LIRLabel : "first instruction of block must be label";
156 label = ((LIRLabel) instr).label(); 156 label = ((LIRLabel) instr).label();