1 /*
2 * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
632 arithmetic_op_int(x->op(), x->operand(), left_arg->result(), right_arg->result(), tmp);
633 }
634 }
635 }
636
637
638 void LIRGenerator::do_ArithmeticOp(ArithmeticOp* x) {
639 // when an operand with use count 1 is the left operand, then it is
640 // likely that no move for 2-operand-LIR-form is necessary
641 if (x->is_commutative() && x->y()->as_Constant() == NULL && x->x()->use_count() > x->y()->use_count()) {
642 x->swap_operands();
643 }
644
645 ValueTag tag = x->type()->tag();
646 assert(x->x()->type()->tag() == tag && x->y()->type()->tag() == tag, "wrong parameters");
647 switch (tag) {
648 case floatTag:
649 case doubleTag: do_ArithmeticOp_FPU(x); return;
650 case longTag: do_ArithmeticOp_Long(x); return;
651 case intTag: do_ArithmeticOp_Int(x); return;
652 }
653 ShouldNotReachHere();
654 }
655
656
657 // _ishl, _lshl, _ishr, _lshr, _iushr, _lushr
658 void LIRGenerator::do_ShiftOp(ShiftOp* x) {
659 // count must always be in rcx
660 LIRItem value(x->x(), this);
661 LIRItem count(x->y(), this);
662
663 ValueTag elemType = x->type()->tag();
664 bool must_load_count = !count.is_constant() || elemType == longTag;
665 if (must_load_count) {
666 // count for long must be in register
667 count.load_item_force(shiftCountOpr());
668 } else {
669 count.dont_load_item();
670 }
671 value.load_item();
672 LIR_Opr reg = rlock_result(x);
673
|
1 /*
2 * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
632 arithmetic_op_int(x->op(), x->operand(), left_arg->result(), right_arg->result(), tmp);
633 }
634 }
635 }
636
637
638 void LIRGenerator::do_ArithmeticOp(ArithmeticOp* x) {
639 // when an operand with use count 1 is the left operand, then it is
640 // likely that no move for 2-operand-LIR-form is necessary
641 if (x->is_commutative() && x->y()->as_Constant() == NULL && x->x()->use_count() > x->y()->use_count()) {
642 x->swap_operands();
643 }
644
645 ValueTag tag = x->type()->tag();
646 assert(x->x()->type()->tag() == tag && x->y()->type()->tag() == tag, "wrong parameters");
647 switch (tag) {
648 case floatTag:
649 case doubleTag: do_ArithmeticOp_FPU(x); return;
650 case longTag: do_ArithmeticOp_Long(x); return;
651 case intTag: do_ArithmeticOp_Int(x); return;
652 default: ShouldNotReachHere(); return;
653 }
654 }
655
656
657 // _ishl, _lshl, _ishr, _lshr, _iushr, _lushr
658 void LIRGenerator::do_ShiftOp(ShiftOp* x) {
659 // count must always be in rcx
660 LIRItem value(x->x(), this);
661 LIRItem count(x->y(), this);
662
663 ValueTag elemType = x->type()->tag();
664 bool must_load_count = !count.is_constant() || elemType == longTag;
665 if (must_load_count) {
666 // count for long must be in register
667 count.load_item_force(shiftCountOpr());
668 } else {
669 count.dont_load_item();
670 }
671 value.load_item();
672 LIR_Opr reg = rlock_result(x);
673
|