src/cpu/mips/vm/c1_LIRGenerator_mips.cpp

changeset 8865
ffcdff41a92f
parent 8863
5376ce0dc552
child 9130
4cd0a8696e8e
equal deleted inserted replaced
8864:e4aeef458496 8865:ffcdff41a92f
233 return new LIR_Address(base, 0, type); 233 return new LIR_Address(base, 0, type);
234 } 234 }
235 } 235 }
236 } 236 }
237 237
238 LIR_Address* LIRGenerator::emit_array_address(LIR_Opr array_opr, LIR_Opr index_opr,BasicType type, bool needs_card_mark) { 238 LIR_Address* LIRGenerator::emit_array_address(LIR_Opr array_opr, LIR_Opr index_opr,
239 int offset_in_bytes = arrayOopDesc::base_offset_in_bytes(type); 239 BasicType type, bool needs_card_mark) {
240 240 int elem_size = type2aelembytes(type);
241 LIR_Address* addr; 241 int shift = exact_log2(elem_size);
242
243 LIR_Opr base_opr;
244 int offset = arrayOopDesc::base_offset_in_bytes(type);
245
242 if (index_opr->is_constant()) { 246 if (index_opr->is_constant()) {
243 int elem_size = _type2aelembytes[type]; 247 int i = index_opr->as_constant_ptr()->as_jint();
244 addr = new LIR_Address(array_opr, 248 int array_offset = i * elem_size;
245 offset_in_bytes + index_opr->as_jint() * elem_size, type); 249 if (Assembler::is_simm16(array_offset + offset)) {
246 } else if( index_opr->is_register()){ 250 base_opr = array_opr;
251 offset = array_offset + offset;
252 } else {
253 base_opr = new_pointer_register();
254 if (Assembler::is_simm16(array_offset)) {
255 __ add(array_opr, LIR_OprFact::intptrConst(array_offset), base_opr);
256 } else {
257 __ move(LIR_OprFact::intptrConst(array_offset), base_opr);
258 __ add(base_opr, array_opr, base_opr);
259 }
260 }
261 } else {
247 #ifdef _LP64 262 #ifdef _LP64
248 LIR_Opr tmp = new_register(T_LONG); 263 if (index_opr->type() == T_INT) {
249 #else 264 LIR_Opr tmp = new_register(T_LONG);
250 LIR_Opr tmp = new_register(T_INT); 265 __ convert(Bytecodes::_i2l, index_opr, tmp);
266 index_opr = tmp;
267 }
251 #endif 268 #endif
252 __ move(index_opr, tmp); 269
253 __ shift_left(tmp, LIR_Address::scale(type),tmp); 270 base_opr = new_pointer_register();
254 __ add(tmp, array_opr, tmp); 271 assert (index_opr->is_register(), "Must be register");
255 addr = new LIR_Address(tmp, offset_in_bytes,type); 272 if (shift > 0) {
256 273 __ shift_left(index_opr, shift, base_opr);
257 } 274 __ add(base_opr, array_opr, base_opr);
258 else{ 275 } else {
259 addr = new LIR_Address(array_opr, 276 __ add(index_opr, array_opr, base_opr);
260 offset_in_bytes, type); 277 }
261 } 278 }
262
263 if (needs_card_mark) { 279 if (needs_card_mark) {
264 // This store will need a precise card mark, so go ahead and 280 // This store will need a precise card mark, so go ahead and
265 // compute the full adddres instead of computing once for the 281 // compute the full adddres instead of computing once for the
266 // store and again for the card mark. 282 // store and again for the card mark.
267 #ifdef _LP64 283 LIR_Opr ptr = new_pointer_register();
268 LIR_Opr tmp = new_register(T_ADDRESS); 284 __ add(base_opr, LIR_OprFact::intptrConst(offset), ptr);
269 #else 285 return new LIR_Address(ptr, type);
270 LIR_Opr tmp = new_register(T_INT); 286 } else {
271 #endif 287 return new LIR_Address(base_opr, offset, type);
272 __ leal(LIR_OprFact::address(addr), tmp); 288 }
273 return new LIR_Address(tmp, 0, type);
274 } else {
275 return addr;
276 }
277
278
279 } 289 }
280 290
281 291
282 LIR_Opr LIRGenerator::load_immediate(int x, BasicType type) { 292 LIR_Opr LIRGenerator::load_immediate(int x, BasicType type) {
283 LIR_Opr r; 293 LIR_Opr r;
290 } 300 }
291 return r; 301 return r;
292 } 302 }
293 303
294 void LIRGenerator::increment_counter(address counter, BasicType type, int step) { 304 void LIRGenerator::increment_counter(address counter, BasicType type, int step) {
295 LIR_Opr temp = new_register(T_INT); 305 #ifdef _LP64
306 LIR_Opr pointer = new_register(T_LONG);
307 #else
296 LIR_Opr pointer = new_register(T_INT); 308 LIR_Opr pointer = new_register(T_INT);
297 #ifndef _LP64
298 __ move(LIR_OprFact::intConst((int)counter), pointer);
299 #else
300 __ move(LIR_OprFact::longConst((long)counter), pointer);
301 #endif 309 #endif
302 LIR_Opr addr = (LIR_Opr)new LIR_Address(pointer, type); 310 __ move(LIR_OprFact::intptrConst(counter), pointer);
303 LIR_Opr c = LIR_OprFact::intConst((int)step); 311 LIR_Address* addr = new LIR_Address(pointer, type);
304 __ add(addr, c, addr); 312 increment_counter(addr, step);
305 } 313 }
306 314
315 //void LIRGenerator::increment_counter(address counter, BasicType type, int step) {
316 // LIR_Opr pointer = new_register(T_LONG);
317 // __ move(LIR_OprFact::longConst((long)counter), pointer);
318 // LIR_Opr addr = (LIR_Opr)new LIR_Address(pointer, type);
319 // LIR_Opr c = LIR_OprFact::intConst((int)step);
320 // __ add(addr, c, addr);
321 //}
307 322
308 void LIRGenerator::increment_counter(LIR_Address* addr, int step) { 323 void LIRGenerator::increment_counter(LIR_Address* addr, int step) {
309 Unimplemented(); 324 LIR_Opr temp = new_register(addr->type());
325 __ move(addr, temp);
326 __ add(temp, load_immediate(step, addr->type()), temp);
327 __ move(temp, addr);
310 } 328 }
311 329
312 330
313 bool LIRGenerator::strength_reduce_multiply(LIR_Opr left, int c, LIR_Opr result, LIR_Opr tmp) { 331 bool LIRGenerator::strength_reduce_multiply(LIR_Opr left, int c, LIR_Opr result, LIR_Opr tmp) {
314 if (tmp->is_valid()) { 332 if (tmp->is_valid()) {
524 entry = CAST_FROM_FN_PTR(address, SharedRuntime::lmul); 542 entry = CAST_FROM_FN_PTR(address, SharedRuntime::lmul);
525 break; 543 break;
526 default: 544 default:
527 ShouldNotReachHere(); 545 ShouldNotReachHere();
528 } 546 }
547
529 // order of arguments to runtime call is reversed. 548 // order of arguments to runtime call is reversed.
530 LIR_Opr result = call_runtime(x->y(), x->x(), entry, x->type(), NULL); 549 LIR_Opr result = call_runtime(x->y(), x->x(), entry, x->type(), NULL);
531 set_result(x, result); 550 set_result(x, result);
532 break; 551 break;
533 } 552 }
534 /* _ladd, _lsub is delete in sharedRuntime.hpp
535 case Bytecodes::_ladd: 553 case Bytecodes::_ladd:
536 case Bytecodes::_lsub: { 554 case Bytecodes::_lsub: {
537 address entry;
538 switch (x->op()) {
539 case Bytecodes::_ladd:
540 entry = CAST_FROM_FN_PTR(address, SharedRuntime::ladd);
541 break; // check if dividend is 0 is done elsewhere
542 case Bytecodes::_lsub:
543 entry = CAST_FROM_FN_PTR(address, SharedRuntime::lsub);
544 break; // check if dividend is 0 is done elsewhere
545 default:
546 ShouldNotReachHere();
547 }
548
549 // order of arguments to runtime call is reversed.
550 LIR_Opr result = call_runtime(x->y(), x->x(), entry, x->type(), NULL);
551 set_result(x, result);
552 break;
553 }*/
554
555 /* {
556 LIRItem left(x->x(), this); 555 LIRItem left(x->x(), this);
557 LIRItem right(x->y(), this); 556 LIRItem right(x->y(), this);
558 left.load_item(); 557 left.load_item();
559 right.load_item(); 558 right.load_item();
560 rlock_result(x); 559 rlock_result(x);
561 560
562 arithmetic_op_long(x->op(), x->operand(), left.result(), right.result(), NULL); 561 arithmetic_op_long(x->op(), x->operand(), left.result(), right.result(), NULL);
563 break; 562 break;
564 } 563 }
565 */ 564 default:
566 default: ShouldNotReachHere(); 565 ShouldNotReachHere();
567 } 566 }
568 } 567 }
569 568
570 569
571 570
618 } 617 }
619 618
620 619
621 // _ishl, _lshl, _ishr, _lshr, _iushr, _lushr 620 // _ishl, _lshl, _ishr, _lshr, _iushr, _lushr
622 void LIRGenerator::do_ShiftOp(ShiftOp* x) { 621 void LIRGenerator::do_ShiftOp(ShiftOp* x) {
623 if(x->op() == Bytecodes::_lshl
624 || x->op() == Bytecodes::_lshr
625 || x->op() == Bytecodes::_lushr) {
626 address entry;
627 /* lushr, lshr, lshl, is delete in ShredRuntime.hpp
628 switch (x->op()) {
629 case Bytecodes::_lshl:
630 entry = CAST_FROM_FN_PTR(address, SharedRuntime::lshl);
631 break; // check if dividend is 0 is done elsewhere
632 case Bytecodes::_lshr:
633 entry = CAST_FROM_FN_PTR(address, SharedRuntime::lshr);
634 break; // check if dividend is 0 is done elsewhere
635 case Bytecodes::_lushr:
636 entry = CAST_FROM_FN_PTR(address, SharedRuntime::lushr);
637 break;
638 default:
639 ShouldNotReachHere();
640 }
641 */
642 // order of arguments to runtime call is reversed.
643 LIR_Opr result = call_runtime(x->y(), x->x(), entry, x->type(), NULL);
644 set_result(x, result);
645 return;
646 }
647
648 // count must always be in rcx 622 // count must always be in rcx
649 LIRItem value(x->x(), this); 623 LIRItem value(x->x(), this);
650 LIRItem count(x->y(), this); 624 LIRItem count(x->y(), this);
651 625
652 ValueTag elemType = x->type()->tag(); 626 ValueTag elemType = x->type()->tag();
879 __ arraycopy(src.result(), src_pos.result(), dst.result(), dst_pos.result(), length.result(), rlock_callee_saved(T_INT), expected_type, flags, info); 853 __ arraycopy(src.result(), src_pos.result(), dst.result(), dst_pos.result(), length.result(), rlock_callee_saved(T_INT), expected_type, flags, info);
880 set_no_result(x); 854 set_no_result(x);
881 } 855 }
882 856
883 void LIRGenerator::do_update_CRC32(Intrinsic* x) { // Fu: 20130832 857 void LIRGenerator::do_update_CRC32(Intrinsic* x) { // Fu: 20130832
884 tty->print_cr("LIRGenerator::do_update_CRC32 unimplemented yet !");
885 Unimplemented(); 858 Unimplemented();
886 } 859 }
887 860
888 // _i2l, _i2f, _i2d, _l2i, _l2f, _l2d, _f2i, _f2l, _f2d, _d2i, _d2l, _d2f 861 // _i2l, _i2f, _i2d, _l2i, _l2f, _l2d, _f2i, _f2l, _f2d, _d2i, _d2l, _d2f
889 // _i2b, _i2c, _i2s 862 // _i2b, _i2c, _i2s
960 case Bytecodes::_d2l: 933 case Bytecodes::_d2l:
961 fixed_input = true; 934 fixed_input = true;
962 fixed_result = true; 935 fixed_result = true;
963 round_result = false; 936 round_result = false;
964 needs_stub = false; break; 937 needs_stub = false; break;
965 default: ShouldNotReachHere(); 938 default:
939 ShouldNotReachHere();
966 } 940 }
967 941
968 LIRItem value(x->value(), this); 942 LIRItem value(x->value(), this);
969 value.load_item(); 943 value.load_item();
970 LIR_Opr input = value.result(); 944 LIR_Opr input = value.result();
1013 // LIR_Opr tmp1 = new_register(T_INT); 987 // LIR_Opr tmp1 = new_register(T_INT);
1014 // LIR_Opr tmp2 = new_register(T_INT); 988 // LIR_Opr tmp2 = new_register(T_INT);
1015 // LIR_Opr tmp3 = new_register(T_INT); 989 // LIR_Opr tmp3 = new_register(T_INT);
1016 // LIR_Opr tmp4 = new_register(T_INT); 990 // LIR_Opr tmp4 = new_register(T_INT);
1017 #ifndef _LP64 991 #ifndef _LP64
1018 LIR_Opr klass_reg = FrameMap::_t4_oop_opr; 992 LIR_Opr klass_reg = FrameMap::_t4_metadata_opr;
1019 #else 993 #else
1020 LIR_Opr klass_reg = FrameMap::_a4_oop_opr; 994 LIR_Opr klass_reg = FrameMap::_a4_metadata_opr;
1021 #endif 995 #endif
1022 // new_instance(reg, x->klass(), FrameMap::_t0_oop_opr, FrameMap::_t1_oop_opr,FrameMap::_t2_oop_opr, LIR_OprFact::illegalOpr, klass_reg, info);
1023 guarantee(false, "not implemented yet.");
1024 /*
1025 new_instance(reg, 996 new_instance(reg,
1026 x->klass(), 997 x->klass(),
998 x->is_unresolved(),
1027 FrameMap::_t0_oop_opr, 999 FrameMap::_t0_oop_opr,
1028 FrameMap::_t1_oop_opr, 1000 FrameMap::_t1_oop_opr,
1029 FrameMap::_t2_oop_opr, 1001 FrameMap::_t2_oop_opr,
1030 FrameMap::_t3_oop_opr, 1002 FrameMap::_t3_oop_opr,
1031 #ifndef _LP64 1003 #ifndef _LP64
1035 FrameMap::_a5_oop_opr, 1007 FrameMap::_a5_oop_opr,
1036 FrameMap::_a6_oop_opr, 1008 FrameMap::_a6_oop_opr,
1037 #endif 1009 #endif
1038 klass_reg, 1010 klass_reg,
1039 info); 1011 info);
1040 */
1041 LIR_Opr result = rlock_result(x); 1012 LIR_Opr result = rlock_result(x);
1042 __ move(reg, result); 1013 __ move(reg, result);
1043 } 1014 }
1044 1015
1045 1016
1058 LIR_Opr tmp5 = FrameMap::_t6_oop_opr; 1029 LIR_Opr tmp5 = FrameMap::_t6_oop_opr;
1059 LIR_Opr klass_reg = FrameMap::_t4_oop_opr; 1030 LIR_Opr klass_reg = FrameMap::_t4_oop_opr;
1060 #else 1031 #else
1061 LIR_Opr tmp4 = FrameMap::_a5_oop_opr; 1032 LIR_Opr tmp4 = FrameMap::_a5_oop_opr;
1062 LIR_Opr tmp5 = FrameMap::_a6_oop_opr; 1033 LIR_Opr tmp5 = FrameMap::_a6_oop_opr;
1063 LIR_Opr klass_reg = FrameMap::_a4_oop_opr; 1034 LIR_Opr klass_reg = FrameMap::_a4_metadata_opr;
1064 #endif 1035 #endif
1065 LIR_Opr len = length.result(); 1036 LIR_Opr len = length.result();
1066 BasicType elem_type = x->elt_type(); 1037 BasicType elem_type = x->elt_type();
1067 1038
1068 __ metadata2reg(ciTypeArrayKlass::make(elem_type)->constant_encoding(), klass_reg); 1039 __ metadata2reg(ciTypeArrayKlass::make(elem_type)->constant_encoding(), klass_reg);
1095 LIR_Opr tmp5 = FrameMap::_t6_oop_opr; 1066 LIR_Opr tmp5 = FrameMap::_t6_oop_opr;
1096 LIR_Opr klass_reg = FrameMap::_t4_oop_opr; 1067 LIR_Opr klass_reg = FrameMap::_t4_oop_opr;
1097 #else 1068 #else
1098 LIR_Opr tmp4 = FrameMap::_a5_oop_opr; 1069 LIR_Opr tmp4 = FrameMap::_a5_oop_opr;
1099 LIR_Opr tmp5 = FrameMap::_a6_oop_opr; 1070 LIR_Opr tmp5 = FrameMap::_a6_oop_opr;
1100 LIR_Opr klass_reg = FrameMap::_a4_oop_opr; 1071 LIR_Opr klass_reg = FrameMap::_a4_metadata_opr;
1101 #endif 1072 #endif
1102 1073
1103 length.load_item_force(FrameMap::_t2_opr); 1074 length.load_item_force(FrameMap::_t2_opr);
1104 1075
1105 LIR_Opr len = length.result(); 1076 LIR_Opr len = length.result();
1143 LIRItem* size = items->at(i); 1114 LIRItem* size = items->at(i);
1144 size->load_nonconstant(); 1115 size->load_nonconstant();
1145 store_stack_parameter(size->result(), in_ByteSize(i*4)); 1116 store_stack_parameter(size->result(), in_ByteSize(i*4));
1146 } 1117 }
1147 1118
1148 LIR_Opr reg = result_register_for(x->type()); 1119 LIR_Opr klass_reg = FrameMap::_v0_metadata_opr;
1149 klass2reg_with_patching(reg, x->klass(), patching_info); 1120 klass2reg_with_patching(klass_reg, x->klass(), patching_info);
1150 1121
1151 // LIR_Opr rank = FrameMap::ebx_opr; 1122 // LIR_Opr rank = FrameMap::ebx_opr;
1152 LIR_Opr rank = FrameMap::_t2_opr; 1123 LIR_Opr rank = FrameMap::_t2_opr;
1153 __ move(LIR_OprFact::intConst(x->rank()), rank); 1124 __ move(LIR_OprFact::intConst(x->rank()), rank);
1154 // LIR_Opr varargs = FrameMap::ecx_opr; 1125 // LIR_Opr varargs = FrameMap::ecx_opr;
1155 LIR_Opr varargs = FrameMap::_t0_opr; 1126 LIR_Opr varargs = FrameMap::_t0_opr;
1156 __ move(FrameMap::_sp_opr, varargs); 1127 __ move(FrameMap::_sp_opr, varargs);
1157 LIR_OprList* args = new LIR_OprList(3); 1128 LIR_OprList* args = new LIR_OprList(3);
1158 args->append(reg); 1129 args->append(klass_reg);
1159 args->append(rank); 1130 args->append(rank);
1160 args->append(varargs); 1131 args->append(varargs);
1132 LIR_Opr reg = result_register_for(x->type());
1161 __ call_runtime(Runtime1::entry_for(Runtime1::new_multi_array_id), 1133 __ call_runtime(Runtime1::entry_for(Runtime1::new_multi_array_id),
1162 LIR_OprFact::illegalOpr, 1134 LIR_OprFact::illegalOpr,
1163 reg, args, info); 1135 reg, args, info);
1136
1164 LIR_Opr result = rlock_result(x); 1137 LIR_Opr result = rlock_result(x);
1165 __ move(reg, result); 1138 __ move(reg, result);
1166 } 1139 }
1167 1140
1168 void LIRGenerator::do_BlockBegin(BlockBegin* x) { 1141 void LIRGenerator::do_BlockBegin(BlockBegin* x) {

mercurial