comparison graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java @ 2876:7d7cf33f8466

Subclasses for arithmetic
author Gilles Duboscq <gilles.duboscq@oracle.com>
date Tue, 07 Jun 2011 22:51:22 +0200
parents 7a4e6e11877f
children
comparison
equal deleted inserted replaced
2865:7a4e6e11877f 2876:7d7cf33f8466
530 throw Util.shouldNotReachHere(); 530 throw Util.shouldNotReachHere();
531 } 531 }
532 532
533 } 533 }
534 534
535 private void genArithmeticOp(CiKind kind, int opcode) { 535 private void genArithmeticOp(CiKind result, int opcode) {
536 genArithmeticOp(kind, opcode, false); 536 Value y = frameState.pop(result);
537 } 537 Value x = frameState.pop(result);
538 538 boolean isStrictFP = isStrict(method.accessFlags());
539 private void genArithmeticOp(CiKind kind, int opcode, boolean canTrap) { 539 Arithmetic v;
540 genArithmeticOp(kind, opcode, kind, kind, canTrap); 540 switch(opcode){
541 } 541 case IADD:
542 542 case LADD: v = new IntegerAdd(result, x, y, graph); break;
543 private void genArithmeticOp(CiKind result, int opcode, CiKind x, CiKind y, boolean canTrap) { 543 case FADD:
544 Value yValue = frameState.pop(y); 544 case DADD: v = new FloatAdd(result, x, y, isStrictFP, graph); break;
545 Value xValue = frameState.pop(x); 545 case ISUB:
546 Value result1 = append(new Arithmetic(opcode, result, xValue, yValue, isStrict(method.accessFlags()), canTrap, graph)); 546 case LSUB: v = new IntegerSub(result, x, y, graph); break;
547 case FSUB:
548 case DSUB: v = new FloatSub(result, x, y, isStrictFP, graph); break;
549 case IMUL:
550 case LMUL: v = new IntegerMul(result, x, y, graph); break;
551 case FMUL:
552 case DMUL: v = new FloatMul(result, x, y, isStrictFP, graph); break;
553 case IDIV:
554 case LDIV: v = new IntegerDiv(result, x, y, graph); break;
555 case FDIV:
556 case DDIV: v = new FloatDiv(result, x, y, isStrictFP, graph); break;
557 case IREM:
558 case LREM: v = new IntegerRem(result, x, y, graph); break;
559 case FREM:
560 case DREM: v = new FloatRem(result, x, y, isStrictFP, graph); break;
561 default:
562 throw new CiBailout("should not reach");
563 }
564 Value result1 = append(v);
547 frameState.push(result, result1); 565 frameState.push(result, result1);
548 } 566 }
549 567
550 private void genNegateOp(CiKind kind) { 568 private void genNegateOp(CiKind kind) {
551 frameState.push(kind, append(new Negate(frameState.pop(kind), graph))); 569 frameState.push(kind, append(new Negate(frameState.pop(kind), graph)));
602 private void genIncrement() { 620 private void genIncrement() {
603 int index = stream().readLocalIndex(); 621 int index = stream().readLocalIndex();
604 int delta = stream().readIncrement(); 622 int delta = stream().readIncrement();
605 Value x = frameState.localAt(index); 623 Value x = frameState.localAt(index);
606 Value y = append(Constant.forInt(delta, graph)); 624 Value y = append(Constant.forInt(delta, graph));
607 frameState.storeLocal(index, append(new Arithmetic(IADD, CiKind.Int, x, y, isStrict(method.accessFlags()), false, graph))); 625 frameState.storeLocal(index, append(new IntegerAdd(CiKind.Int, x, y, graph)));
608 } 626 }
609 627
610 private void genGoto(int fromBCI, int toBCI) { 628 private void genGoto(int fromBCI, int toBCI) {
611 appendGoto(createTargetAt(toBCI, frameState)); 629 appendGoto(createTargetAt(toBCI, frameState));
612 } 630 }
1352 case SWAP : stackOp(opcode); break; 1370 case SWAP : stackOp(opcode); break;
1353 case IADD : // fall through 1371 case IADD : // fall through
1354 case ISUB : // fall through 1372 case ISUB : // fall through
1355 case IMUL : genArithmeticOp(CiKind.Int, opcode); break; 1373 case IMUL : genArithmeticOp(CiKind.Int, opcode); break;
1356 case IDIV : // fall through 1374 case IDIV : // fall through
1357 case IREM : genArithmeticOp(CiKind.Int, opcode, true); break; 1375 case IREM : genArithmeticOp(CiKind.Int, opcode); break;
1358 case LADD : // fall through 1376 case LADD : // fall through
1359 case LSUB : // fall through 1377 case LSUB : // fall through
1360 case LMUL : genArithmeticOp(CiKind.Long, opcode); break; 1378 case LMUL : genArithmeticOp(CiKind.Long, opcode); break;
1361 case LDIV : // fall through 1379 case LDIV : // fall through
1362 case LREM : genArithmeticOp(CiKind.Long, opcode, true); break; 1380 case LREM : genArithmeticOp(CiKind.Long, opcode); break;
1363 case FADD : // fall through 1381 case FADD : // fall through
1364 case FSUB : // fall through 1382 case FSUB : // fall through
1365 case FMUL : // fall through 1383 case FMUL : // fall through
1366 case FDIV : // fall through 1384 case FDIV : // fall through
1367 case FREM : genArithmeticOp(CiKind.Float, opcode); break; 1385 case FREM : genArithmeticOp(CiKind.Float, opcode); break;