comparison graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java @ 2519:f6125fb5bfbc

Removed intrinsics.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 27 Apr 2011 16:25:32 +0200
parents 4fdef1464592
children 2f271a85d104
comparison
equal deleted inserted replaced
2516:a384fac3fd34 2519:f6125fb5bfbc
470 lir.cmp(i.condition(), left, right); 470 lir.cmp(i.condition(), left, right);
471 lir.cmove(i.condition(), tVal, fVal, reg); 471 lir.cmove(i.condition(), tVal, fVal, reg);
472 } 472 }
473 473
474 @Override 474 @Override
475 public void visitIntrinsic(Intrinsic x) {
476 Value[] vals = x.arguments();
477 XirSnippet snippet;
478
479 switch (x.intrinsic()) {
480 case java_lang_Float$intBitsToFloat:
481 case java_lang_Double$doubleToRawLongBits:
482 case java_lang_Double$longBitsToDouble:
483 case java_lang_Float$floatToRawIntBits: {
484 visitFPIntrinsics(x);
485 return;
486 }
487
488 case java_lang_System$currentTimeMillis: {
489 assert x.numberOfArguments() == 0 : "wrong type";
490 CiValue reg = callRuntimeWithResult(CiRuntimeCall.JavaTimeMillis, null, (CiValue[]) null);
491 CiValue result = createResultVariable(x);
492 lir.move(reg, result);
493 return;
494 }
495
496 case java_lang_System$nanoTime: {
497 assert x.numberOfArguments() == 0 : "wrong type";
498 CiValue reg = callRuntimeWithResult(CiRuntimeCall.JavaTimeNanos, null, (CiValue[]) null);
499 CiValue result = createResultVariable(x);
500 lir.move(reg, result);
501 return;
502 }
503
504 case java_lang_Object$init:
505 visitRegisterFinalizer(x);
506 return;
507
508 case java_lang_Math$log: // fall through
509 case java_lang_Math$log10: // fall through
510 case java_lang_Math$abs: // fall through
511 case java_lang_Math$sqrt: // fall through
512 case java_lang_Math$tan: // fall through
513 case java_lang_Math$sin: // fall through
514 case java_lang_Math$cos:
515 genMathIntrinsic(x);
516 return;
517
518 case sun_misc_Unsafe$compareAndSwapObject:
519 genCompareAndSwap(x, CiKind.Object);
520 return;
521 case sun_misc_Unsafe$compareAndSwapInt:
522 genCompareAndSwap(x, CiKind.Int);
523 return;
524 case sun_misc_Unsafe$compareAndSwapLong:
525 genCompareAndSwap(x, CiKind.Long);
526 return;
527
528 case java_lang_Thread$currentThread:
529 snippet = xir.genCurrentThread(site(x));
530 if (snippet != null) {
531 emitXir(snippet, x, null, null, true);
532 return;
533 }
534 break;
535
536 case java_lang_Object$getClass:
537 snippet = xir.genGetClass(site(x), toXirArgument(vals[0]));
538 if (snippet != null) {
539 emitXir(snippet, x, stateFor(x), null, true);
540 return;
541 }
542 break;
543 }
544
545
546 XirArgument[] args = new XirArgument[vals.length];
547 for (int i = 0; i < vals.length; i++) {
548 args[i] = toXirArgument(vals[i]);
549 }
550 snippet = xir.genIntrinsic(site(x), args, x.target());
551 if (snippet != null) {
552 emitXir(snippet, x, x.stateBefore() == null ? null : stateFor(x), null, true);
553 return;
554 }
555 x.setOperand(emitInvokeKnown(x.target(), x.stateBefore(), vals));
556 }
557
558 @Override
559 public void visitInvoke(Invoke x) { 475 public void visitInvoke(Invoke x) {
560 RiMethod target = x.target(); 476 RiMethod target = x.target();
561 LIRDebugInfo info = stateFor(x, x.stateBefore()); 477 LIRDebugInfo info = stateFor(x, x.stateBefore());
562 478
563 XirSnippet snippet = null; 479 XirSnippet snippet = null;
1265 CiVariable operand = newVariable(x.kind); 1181 CiVariable operand = newVariable(x.kind);
1266 setResult(x, operand); 1182 setResult(x, operand);
1267 return operand; 1183 return operand;
1268 } 1184 }
1269 1185
1270 private void visitFPIntrinsics(Intrinsic x) { 1186 @Override
1271 assert x.numberOfArguments() == 1 : "wrong type"; 1187 public void visitRegisterFinalizer(RegisterFinalizer x) {
1272 CiValue reg = createResultVariable(x); 1188 CiValue receiver = load(x.object());
1273 CiValue value = load(x.argumentAt(0));
1274 CiValue tmp = forceToSpill(value, x.kind, false);
1275 lir.move(tmp, reg);
1276 }
1277
1278 private void visitRegisterFinalizer(Intrinsic x) {
1279 assert x.numberOfArguments() == 1 : "wrong type";
1280 CiValue receiver = load(x.argumentAt(0));
1281 LIRDebugInfo info = stateFor(x, x.stateBefore()); 1189 LIRDebugInfo info = stateFor(x, x.stateBefore());
1282 callRuntime(CiRuntimeCall.RegisterFinalizer, info, receiver); 1190 callRuntime(CiRuntimeCall.RegisterFinalizer, info, receiver);
1283 setNoResult(x); 1191 setNoResult(x);
1284 } 1192 }
1285 1193
1878 1786
1879 protected abstract void genGetObjectUnsafe(CiValue dest, CiValue src, CiValue offset, CiKind kind, boolean isVolatile); 1787 protected abstract void genGetObjectUnsafe(CiValue dest, CiValue src, CiValue offset, CiKind kind, boolean isVolatile);
1880 1788
1881 protected abstract void genPutObjectUnsafe(CiValue src, CiValue offset, CiValue data, CiKind kind, boolean isVolatile); 1789 protected abstract void genPutObjectUnsafe(CiValue src, CiValue offset, CiValue data, CiKind kind, boolean isVolatile);
1882 1790
1883 protected abstract void genCompareAndSwap(Intrinsic x, CiKind kind);
1884
1885 protected abstract void genMathIntrinsic(Intrinsic x);
1886
1887 /** 1791 /**
1888 * Implements site-specific information for the XIR interface. 1792 * Implements site-specific information for the XIR interface.
1889 */ 1793 */
1890 static class XirSupport implements XirSite { 1794 static class XirSupport implements XirSite {
1891 Value current; 1795 Value current;