Mercurial > hg > graal-jvmci-8
comparison graal/GraalCompiler/src/com/sun/c1x/target/amd64/AMD64LIRGenerator.java @ 2867:5c545fef2c81
merge
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Tue, 07 Jun 2011 16:33:04 +0200 |
parents | 7f14e6b48a9c a97605b0489b |
children | fc75fd3fa5e4 |
comparison
equal
deleted
inserted
replaced
2866:7f14e6b48a9c | 2867:5c545fef2c81 |
---|---|
122 } | 122 } |
123 return false; | 123 return false; |
124 } | 124 } |
125 | 125 |
126 @Override | 126 @Override |
127 public void visitNegateOp(NegateOp x) { | 127 public void visitNegate(Negate x) { |
128 LIRItem value = new LIRItem(x.x(), this); | 128 LIRItem value = new LIRItem(x.x(), this); |
129 value.setDestroysRegister(); | 129 value.setDestroysRegister(); |
130 value.loadItem(); | 130 value.loadItem(); |
131 CiVariable reg = newVariable(x.kind); | 131 CiVariable reg = newVariable(x.kind); |
132 GlobalStub globalStub = null; | 132 GlobalStub globalStub = null; |
142 public boolean livesLonger(Value x, Value y) { | 142 public boolean livesLonger(Value x, Value y) { |
143 // TODO(tw): Estimate which value will live longer. | 143 // TODO(tw): Estimate which value will live longer. |
144 return false; | 144 return false; |
145 } | 145 } |
146 | 146 |
147 public void visitArithmeticOpFloat(ArithmeticOp x) { | 147 public void visitArithmeticOpFloat(Arithmetic x) { |
148 LIRItem left = new LIRItem(x.x(), this); | 148 LIRItem left = new LIRItem(x.x(), this); |
149 LIRItem right = new LIRItem(x.y(), this); | 149 LIRItem right = new LIRItem(x.y(), this); |
150 assert !left.isStack() || !right.isStack() : "can't both be memory operands"; | 150 assert !left.isStack() || !right.isStack() : "can't both be memory operands"; |
151 boolean mustLoadBoth = x.opcode == Bytecodes.FREM || x.opcode == Bytecodes.DREM; | 151 boolean mustLoadBoth = x.opcode == Bytecodes.FREM || x.opcode == Bytecodes.DREM; |
152 | 152 |
183 } | 183 } |
184 | 184 |
185 setResult(x, reg); | 185 setResult(x, reg); |
186 } | 186 } |
187 | 187 |
188 public void visitArithmeticOpLong(ArithmeticOp x) { | 188 public void visitArithmeticOpLong(Arithmetic x) { |
189 int opcode = x.opcode; | 189 int opcode = x.opcode; |
190 if (opcode == Bytecodes.LDIV || opcode == Bytecodes.LREM) { | 190 if (opcode == Bytecodes.LDIV || opcode == Bytecodes.LREM) { |
191 // emit inline 64-bit code | 191 // emit inline 64-bit code |
192 LIRDebugInfo info = stateFor(x); | 192 LIRDebugInfo info = stateFor(x); |
193 CiValue dividend = force(x.x(), RAX_L); // dividend must be in RAX | 193 CiValue dividend = force(x.x(), RAX_L); // dividend must be in RAX |
226 createResultVariable(x); | 226 createResultVariable(x); |
227 arithmeticOpLong(opcode, x.operand(), left, right.result(), null); | 227 arithmeticOpLong(opcode, x.operand(), left, right.result(), null); |
228 } | 228 } |
229 } | 229 } |
230 | 230 |
231 public void visitArithmeticOpInt(ArithmeticOp x) { | 231 public void visitArithmeticOpInt(Arithmetic x) { |
232 int opcode = x.opcode; | 232 int opcode = x.opcode; |
233 if (opcode == Bytecodes.IDIV || opcode == Bytecodes.IREM) { | 233 if (opcode == Bytecodes.IDIV || opcode == Bytecodes.IREM) { |
234 // emit code for integer division or modulus | 234 // emit code for integer division or modulus |
235 | 235 |
236 // Call 'stateFor' before 'force()' because 'stateFor()' may | 236 // Call 'stateFor' before 'force()' because 'stateFor()' may |
304 arithmeticOpInt(opcode, x.operand(), leftArg.result(), rightArg.result(), tmp); | 304 arithmeticOpInt(opcode, x.operand(), leftArg.result(), rightArg.result(), tmp); |
305 } | 305 } |
306 } | 306 } |
307 } | 307 } |
308 | 308 |
309 public void visitArithmeticOpWord(ArithmeticOp x) { | 309 public void visitArithmeticOpWord(Arithmetic x) { |
310 int opcode = x.opcode; | 310 int opcode = x.opcode; |
311 if (opcode == Bytecodes.WDIV || opcode == Bytecodes.WREM || opcode == Bytecodes.WDIVI || opcode == Bytecodes.WREMI) { | 311 if (opcode == Bytecodes.WDIV || opcode == Bytecodes.WREM || opcode == Bytecodes.WDIVI || opcode == Bytecodes.WREMI) { |
312 // emit code for long division or modulus | 312 // emit code for long division or modulus |
313 // emit inline 64-bit code | 313 // emit inline 64-bit code |
314 LIRDebugInfo info = stateFor(x); | 314 LIRDebugInfo info = stateFor(x); |
357 arithmeticOpLong(opcode, x.operand(), left, right.result(), null); | 357 arithmeticOpLong(opcode, x.operand(), left, right.result(), null); |
358 } | 358 } |
359 } | 359 } |
360 | 360 |
361 @Override | 361 @Override |
362 public void visitArithmeticOp(ArithmeticOp x) { | 362 public void visitArithmetic(Arithmetic x) { |
363 trySwap(x); | 363 trySwap(x); |
364 | 364 |
365 if (x.kind.isWord() || x.opcode == Bytecodes.WREMI) { | 365 if (x.kind.isWord() || x.opcode == Bytecodes.WREMI) { |
366 visitArithmeticOpWord(x); | 366 visitArithmeticOpWord(x); |
367 return; | 367 return; |
382 } | 382 } |
383 throw Util.shouldNotReachHere(); | 383 throw Util.shouldNotReachHere(); |
384 } | 384 } |
385 | 385 |
386 @Override | 386 @Override |
387 public void visitShiftOp(ShiftOp x) { | 387 public void visitShift(Shift x) { |
388 // count must always be in rcx | 388 // count must always be in rcx |
389 CiValue count = makeOperand(x.y()); | 389 CiValue count = makeOperand(x.y()); |
390 boolean mustLoadCount = !count.isConstant() || x.kind == CiKind.Long; | 390 boolean mustLoadCount = !count.isConstant() || x.kind == CiKind.Long; |
391 if (mustLoadCount) { | 391 if (mustLoadCount) { |
392 // count for long must be in register | 392 // count for long must be in register |
398 | 398 |
399 shiftOp(x.opcode, reg, value, count, ILLEGAL); | 399 shiftOp(x.opcode, reg, value, count, ILLEGAL); |
400 } | 400 } |
401 | 401 |
402 @Override | 402 @Override |
403 public void visitLogicOp(LogicOp x) { | 403 public void visitLogic(Logic x) { |
404 trySwap(x); | 404 trySwap(x); |
405 | 405 |
406 LIRItem right = new LIRItem(x.y(), this); | 406 LIRItem right = new LIRItem(x.y(), this); |
407 | 407 |
408 CiValue left = load(x.x()); | 408 CiValue left = load(x.x()); |
410 CiValue reg = createResultVariable(x); | 410 CiValue reg = createResultVariable(x); |
411 | 411 |
412 logicOp(x.opcode, reg, left, right.result()); | 412 logicOp(x.opcode, reg, left, right.result()); |
413 } | 413 } |
414 | 414 |
415 private void trySwap(Op2 x) { | 415 private void trySwap(Binary x) { |
416 // (tw) TODO: Check what this is for? | 416 // (tw) TODO: Check what this is for? |
417 } | 417 } |
418 | 418 |
419 @Override | 419 @Override |
420 public void visitCompareOp(CompareOp x) { | 420 public void visitMaterialize(Materialize x) { |
421 LIRItem left = new LIRItem(x.x(), this); | 421 LIRItem left = new LIRItem(x.x(), this); |
422 LIRItem right = new LIRItem(x.y(), this); | 422 LIRItem right = new LIRItem(x.y(), this); |
423 if (!x.kind.isVoid() && x.x().kind.isLong()) { | 423 if (!x.kind.isVoid() && x.x().kind.isLong()) { |
424 left.setDestroysRegister(); | 424 left.setDestroysRegister(); |
425 } | 425 } |