512 LIR_Opr tmp = LIR_OprFact::illegalOpr;
513 arithmetic_op_int(x->op(), x->operand(), left_arg->result(), right_arg->result(), tmp);
514 }
515 }
516 }
517
518 void LIRGenerator::do_ArithmeticOp(ArithmeticOp* x) {
519 // If an operand with use count 1 is the left operand, then it is
520 // likely that no move for 2-operand-LIR-form is necessary.
521 if (x->is_commutative() && x->y()->as_Constant() == NULL && x->x()->use_count() > x->y()->use_count()) {
522 x->swap_operands();
523 }
524
525 ValueTag tag = x->type()->tag();
526 assert(x->x()->type()->tag() == tag && x->y()->type()->tag() == tag, "wrong parameters");
527 switch (tag) {
528 case floatTag:
529 case doubleTag: do_ArithmeticOp_FPU(x); return;
530 case longTag: do_ArithmeticOp_Long(x); return;
531 case intTag: do_ArithmeticOp_Int(x); return;
532 }
533 ShouldNotReachHere();
534 }
535
536 // _ishl, _lshl, _ishr, _lshr, _iushr, _lushr
537 void LIRGenerator::do_ShiftOp(ShiftOp* x) {
538 // count must always be in rcx
539 LIRItem value(x->x(), this);
540 LIRItem count(x->y(), this);
541
542 ValueTag elemType = x->type()->tag();
543 bool must_load_count = !count.is_constant();
544 if (must_load_count) {
545 count.load_item();
546 } else {
547 count.dont_load_item();
548 }
549 value.load_item();
550 LIR_Opr reg = rlock_result(x);
551
552 shift_op(x->op(), reg, value.result(), count.result(), LIR_OprFact::illegalOpr);
553 }
625 }
626
627 void LIRGenerator::do_MathIntrinsic(Intrinsic* x) {
628 switch (x->id()) {
629 case vmIntrinsics::_dabs:
630 case vmIntrinsics::_dsqrt: {
631 assert(x->number_of_arguments() == 1, "wrong type");
632 LIRItem value(x->argument_at(0), this);
633 value.load_item();
634 LIR_Opr dst = rlock_result(x);
635
636 switch (x->id()) {
637 case vmIntrinsics::_dsqrt: {
638 __ sqrt(value.result(), dst, LIR_OprFact::illegalOpr);
639 break;
640 }
641 case vmIntrinsics::_dabs: {
642 __ abs(value.result(), dst, LIR_OprFact::illegalOpr);
643 break;
644 }
645 }
646 break;
647 }
648 case vmIntrinsics::_dlog10: // fall through
649 case vmIntrinsics::_dlog: // fall through
650 case vmIntrinsics::_dsin: // fall through
651 case vmIntrinsics::_dtan: // fall through
652 case vmIntrinsics::_dcos: // fall through
653 case vmIntrinsics::_dexp: {
654 assert(x->number_of_arguments() == 1, "wrong type");
655
656 address runtime_entry = NULL;
657 switch (x->id()) {
658 case vmIntrinsics::_dsin:
659 runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dsin);
660 break;
661 case vmIntrinsics::_dcos:
662 runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dcos);
663 break;
664 case vmIntrinsics::_dtan:
665 runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dtan);
666 break;
667 case vmIntrinsics::_dlog:
668 runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dlog);
669 break;
670 case vmIntrinsics::_dlog10:
671 runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dlog10);
672 break;
673 case vmIntrinsics::_dexp:
674 runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dexp);
675 break;
676 default:
677 ShouldNotReachHere();
678 }
679
680 LIR_Opr result = call_runtime(x->argument_at(0), runtime_entry, x->type(), NULL);
681 set_result(x, result);
682 break;
683 }
684 case vmIntrinsics::_dpow: {
685 assert(x->number_of_arguments() == 2, "wrong type");
686 address runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dpow);
687 LIR_Opr result = call_runtime(x->argument_at(0), x->argument_at(1), runtime_entry, x->type(), NULL);
688 set_result(x, result);
689 break;
690 }
691 }
692 }
693
694 void LIRGenerator::do_ArrayCopy(Intrinsic* x) {
695 assert(x->number_of_arguments() == 5, "wrong type");
696
697 // Copy stubs possibly call C code, e.g. G1 barriers, so we need to reserve room
698 // for the C ABI (see frame::z_abi_160).
699 BasicTypeArray sig; // Empty signature is precise enough.
700 frame_map()->c_calling_convention(&sig);
701
702 // Make all state_for calls early since they can emit code.
703 CodeEmitInfo* info = state_for (x, x->state());
704
705 LIRItem src(x->argument_at(0), this);
706 LIRItem src_pos(x->argument_at(1), this);
707 LIRItem dst(x->argument_at(2), this);
708 LIRItem dst_pos(x->argument_at(3), this);
709 LIRItem length(x->argument_at(4), this);
710
|
512 LIR_Opr tmp = LIR_OprFact::illegalOpr;
513 arithmetic_op_int(x->op(), x->operand(), left_arg->result(), right_arg->result(), tmp);
514 }
515 }
516 }
517
518 void LIRGenerator::do_ArithmeticOp(ArithmeticOp* x) {
519 // If an operand with use count 1 is the left operand, then it is
520 // likely that no move for 2-operand-LIR-form is necessary.
521 if (x->is_commutative() && x->y()->as_Constant() == NULL && x->x()->use_count() > x->y()->use_count()) {
522 x->swap_operands();
523 }
524
525 ValueTag tag = x->type()->tag();
526 assert(x->x()->type()->tag() == tag && x->y()->type()->tag() == tag, "wrong parameters");
527 switch (tag) {
528 case floatTag:
529 case doubleTag: do_ArithmeticOp_FPU(x); return;
530 case longTag: do_ArithmeticOp_Long(x); return;
531 case intTag: do_ArithmeticOp_Int(x); return;
532 default: ShouldNotReachHere();
533 }
534 }
535
536 // _ishl, _lshl, _ishr, _lshr, _iushr, _lushr
537 void LIRGenerator::do_ShiftOp(ShiftOp* x) {
538 // count must always be in rcx
539 LIRItem value(x->x(), this);
540 LIRItem count(x->y(), this);
541
542 ValueTag elemType = x->type()->tag();
543 bool must_load_count = !count.is_constant();
544 if (must_load_count) {
545 count.load_item();
546 } else {
547 count.dont_load_item();
548 }
549 value.load_item();
550 LIR_Opr reg = rlock_result(x);
551
552 shift_op(x->op(), reg, value.result(), count.result(), LIR_OprFact::illegalOpr);
553 }
625 }
626
627 void LIRGenerator::do_MathIntrinsic(Intrinsic* x) {
628 switch (x->id()) {
629 case vmIntrinsics::_dabs:
630 case vmIntrinsics::_dsqrt: {
631 assert(x->number_of_arguments() == 1, "wrong type");
632 LIRItem value(x->argument_at(0), this);
633 value.load_item();
634 LIR_Opr dst = rlock_result(x);
635
636 switch (x->id()) {
637 case vmIntrinsics::_dsqrt: {
638 __ sqrt(value.result(), dst, LIR_OprFact::illegalOpr);
639 break;
640 }
641 case vmIntrinsics::_dabs: {
642 __ abs(value.result(), dst, LIR_OprFact::illegalOpr);
643 break;
644 }
645 default:
646 ShouldNotReachHere();
647 }
648 break;
649 }
650 case vmIntrinsics::_dsin: // fall through
651 case vmIntrinsics::_dcos: // fall through
652 case vmIntrinsics::_dtan: // fall through
653 case vmIntrinsics::_dlog: // fall through
654 case vmIntrinsics::_dlog10: // fall through
655 case vmIntrinsics::_dexp: {
656 assert(x->number_of_arguments() == 1, "wrong type");
657
658 address runtime_entry = NULL;
659 switch (x->id()) {
660 case vmIntrinsics::_dsin:
661 runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dsin);
662 break;
663 case vmIntrinsics::_dcos:
664 runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dcos);
665 break;
666 case vmIntrinsics::_dtan:
667 runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dtan);
668 break;
669 case vmIntrinsics::_dlog:
670 runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dlog);
671 break;
672 case vmIntrinsics::_dlog10:
673 runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dlog10);
674 break;
675 case vmIntrinsics::_dexp:
676 runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dexp);
677 break;
678 default:
679 ShouldNotReachHere();
680 }
681
682 LIR_Opr result = call_runtime(x->argument_at(0), runtime_entry, x->type(), NULL);
683 set_result(x, result);
684 break;
685 }
686 case vmIntrinsics::_dpow: {
687 assert(x->number_of_arguments() == 2, "wrong type");
688 address runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dpow);
689 LIR_Opr result = call_runtime(x->argument_at(0), x->argument_at(1), runtime_entry, x->type(), NULL);
690 set_result(x, result);
691 break;
692 }
693 default: break;
694 }
695 }
696
697 void LIRGenerator::do_ArrayCopy(Intrinsic* x) {
698 assert(x->number_of_arguments() == 5, "wrong type");
699
700 // Copy stubs possibly call C code, e.g. G1 barriers, so we need to reserve room
701 // for the C ABI (see frame::z_abi_160).
702 BasicTypeArray sig; // Empty signature is precise enough.
703 frame_map()->c_calling_convention(&sig);
704
705 // Make all state_for calls early since they can emit code.
706 CodeEmitInfo* info = state_for (x, x->state());
707
708 LIRItem src(x->argument_at(0), this);
709 LIRItem src_pos(x->argument_at(1), this);
710 LIRItem dst(x->argument_at(2), this);
711 LIRItem dst_pos(x->argument_at(3), this);
712 LIRItem length(x->argument_at(4), this);
713
|