comparison graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java @ 2984:f49685081630

Merge
author Gilles Duboscq <gilles.duboscq@oracle.com>
date Wed, 15 Jun 2011 19:54:42 +0200
parents 57c2e3409be7 11dfbb40ca69
children 499851efab4d 183389909fe3
comparison
equal deleted inserted replaced
2977:f01de7799e05 2984:f49685081630
223 if (GraalOptions.TraceLIRGeneratorLevel >= 1) { 223 if (GraalOptions.TraceLIRGeneratorLevel >= 1) {
224 TTY.println("BEGIN Generating LIR for block B" + block.blockID()); 224 TTY.println("BEGIN Generating LIR for block B" + block.blockID());
225 } 225 }
226 226
227 if (block.blockPredecessors().size() > 1) { 227 if (block.blockPredecessors().size() > 1) {
228 if (GraalOptions.TraceLIRGeneratorLevel >= 2) {
229 TTY.println("STATE RESET");
230 }
228 lastState = null; 231 lastState = null;
229 } 232 }
230 233
231 for (Node instr : block.getInstructions()) { 234 for (Node instr : block.getInstructions()) {
235 if (GraalOptions.TraceLIRGeneratorLevel >= 3) {
236 TTY.println("LIRGen for " + instr);
237 }
232 FrameState stateAfter = null; 238 FrameState stateAfter = null;
233 if (instr instanceof Instruction) { 239 if (instr instanceof Instruction) {
234 stateAfter = ((Instruction) instr).stateAfter(); 240 stateAfter = ((Instruction) instr).stateAfter();
235 } 241 }
236 FrameState stateBefore = null; 242 FrameState stateBefore = null;
1009 XirSnippet prologue = xir.genPrologue(null, compilation.method); 1015 XirSnippet prologue = xir.genPrologue(null, compilation.method);
1010 if (prologue != null) { 1016 if (prologue != null) {
1011 emitXir(prologue, null, null, null, false); 1017 emitXir(prologue, null, null, null, false);
1012 } 1018 }
1013 FrameState fs = setOperandsForLocals(); 1019 FrameState fs = setOperandsForLocals();
1020 if (GraalOptions.TraceLIRGeneratorLevel >= 2) {
1021 TTY.println("STATE CHANGE (setOperandsForLocals)");
1022 if (GraalOptions.TraceLIRGeneratorLevel >= 3) {
1023 TTY.println(fs.toString());
1024 }
1025 }
1014 lastState = fs; 1026 lastState = fs;
1015 } else if (block.blockPredecessors().size() == 1) { 1027 } else if (block.blockPredecessors().size() == 1) {
1016 FrameState fs = block.blockPredecessors().get(0).lastState(); 1028 FrameState fs = block.blockPredecessors().get(0).lastState();
1017 assert fs != null; 1029 assert fs != null;
1030 if (GraalOptions.TraceLIRGeneratorLevel >= 2) {
1031 TTY.println("STATE CHANGE (singlePred)");
1032 if (GraalOptions.TraceLIRGeneratorLevel >= 3) {
1033 TTY.println(fs.toString());
1034 }
1035 }
1018 lastState = fs; 1036 lastState = fs;
1019 } 1037 }
1020 } 1038 }
1021 1039
1022 /** 1040 /**
1181 // idiv and irem are handled elsewhere 1199 // idiv and irem are handled elsewhere
1182 Util.shouldNotReachHere(); 1200 Util.shouldNotReachHere();
1183 } 1201 }
1184 } 1202 }
1185 1203
1186 protected void arithmeticOpLong(int code, CiValue result, CiValue left, CiValue right, LIRDebugInfo info) { 1204 protected void arithmeticOpLong(int code, CiValue result, CiValue left, CiValue right) {
1187 CiValue leftOp = left; 1205 CiValue leftOp = left;
1188 1206
1189 if (isTwoOperand && leftOp != result) { 1207 if (isTwoOperand && leftOp != result) {
1190 assert right != result : "malformed"; 1208 assert right != result : "malformed";
1191 lir.move(leftOp, result); 1209 lir.move(leftOp, result);
1439 } 1457 }
1440 } 1458 }
1441 } 1459 }
1442 } 1460 }
1443 resolver.dispose(); 1461 resolver.dispose();
1462 //TODO (gd) remove that later
1463 if (merge instanceof LoopBegin) {
1464 for (Node usage : merge.usages()) {
1465 if (usage instanceof LoopCounter) {
1466 LoopCounter counter = (LoopCounter) usage;
1467 if (counter.operand().isIllegal()) {
1468 createResultVariable(counter);
1469 }
1470 if (nextSuccIndex == 0) { // (gd) nasty
1471 lir.move(operandForInstruction(counter.init()), counter.operand());
1472 } else {
1473 if (counter.kind == CiKind.Int) {
1474 this.arithmeticOpInt(IADD, counter.operand(), counter.operand(), operandForInstruction(counter.stride()), CiValue.IllegalValue);
1475 } else {
1476 assert counter.kind == CiKind.Long;
1477 this.arithmeticOpLong(LADD, counter.operand(), counter.operand(), operandForInstruction(counter.stride()));
1478 }
1479 }
1480 }
1481 }
1482 }
1444 } 1483 }
1445 1484
1446 /** 1485 /**
1447 * Creates a new {@linkplain CiVariable variable}. 1486 * Creates a new {@linkplain CiVariable variable}.
1448 * 1487 *
1457 CiValue operand = x.operand(); 1496 CiValue operand = x.operand();
1458 if (operand.isIllegal()) { 1497 if (operand.isIllegal()) {
1459 if (x instanceof Constant) { 1498 if (x instanceof Constant) {
1460 x.setOperand(x.asConstant()); 1499 x.setOperand(x.asConstant());
1461 } else { 1500 } else {
1462 assert x instanceof Phi || x instanceof Local : "only for Phi and Local"; 1501 assert x instanceof Phi || x instanceof Local : "only for Phi and Local : " + x;
1463 // allocate a variable for this local or phi 1502 // allocate a variable for this local or phi
1464 createResultVariable(x); 1503 createResultVariable(x);
1465 } 1504 }
1466 } 1505 }
1467 return x.operand(); 1506 return x.operand();
1469 1508
1470 private CiValue operandForPhi(Phi phi) { 1509 private CiValue operandForPhi(Phi phi) {
1471 assert !phi.isDead() : "dead phi: " + phi.id(); 1510 assert !phi.isDead() : "dead phi: " + phi.id();
1472 if (phi.operand().isIllegal()) { 1511 if (phi.operand().isIllegal()) {
1473 // allocate a variable for this phi 1512 // allocate a variable for this phi
1474 CiVariable operand = newVariable(phi.kind); 1513 createResultVariable(phi);
1475 setResult(phi, operand);
1476 } 1514 }
1477 return phi.operand(); 1515 return phi.operand();
1478 } 1516 }
1479 1517
1480 protected void postGCWriteBarrier(CiValue addr, CiValue newVal) { 1518 protected void postGCWriteBarrier(CiValue addr, CiValue newVal) {