< prev index next >

src/cpu/x86/vm/c1_LIRGenerator_x86.cpp

Print this page




 217 
 218 void LIRGenerator::increment_counter(LIR_Address* addr, int step) {
 219   __ add((LIR_Opr)addr, LIR_OprFact::intConst(step), (LIR_Opr)addr);
 220 }
 221 
 222 void LIRGenerator::cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info) {
 223   __ cmp_mem_int(condition, base, disp, c, info);
 224 }
 225 
 226 
 227 void LIRGenerator::cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, int disp, BasicType type, CodeEmitInfo* info) {
 228   __ cmp_reg_mem(condition, reg, new LIR_Address(base, disp, type), info);
 229 }
 230 
 231 
 232 void LIRGenerator::cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, LIR_Opr disp, BasicType type, CodeEmitInfo* info) {
 233   __ cmp_reg_mem(condition, reg, new LIR_Address(base, disp, type), info);
 234 }
 235 
 236 
 237 bool LIRGenerator::strength_reduce_multiply(LIR_Opr left, int c, LIR_Opr result, LIR_Opr tmp) {
 238   if (tmp->is_valid()) {
 239     if (is_power_of_2(c + 1)) {
 240       __ move(left, tmp);
 241       __ shift_left(left, log2_intptr(c + 1), left);
 242       __ sub(left, tmp, result);
 243       return true;
 244     } else if (is_power_of_2(c - 1)) {
 245       __ move(left, tmp);
 246       __ shift_left(left, log2_intptr(c - 1), left);
 247       __ add(left, tmp, result);
 248       return true;
 249     }
 250   }
 251   return false;
 252 }
 253 
 254 
 255 void LIRGenerator::store_stack_parameter (LIR_Opr item, ByteSize offset_from_sp) {
 256   BasicType type = item->type();
 257   __ store(item, new LIR_Address(FrameMap::rsp_opr, in_bytes(offset_from_sp), type));
 258 }


 586   } else {
 587     // missing test if instr is commutative and if we should swap
 588     LIRItem left(x->x(),  this);
 589     LIRItem right(x->y(), this);
 590     LIRItem* left_arg = &left;
 591     LIRItem* right_arg = &right;
 592     if (x->is_commutative() && left.is_stack() && right.is_register()) {
 593       // swap them if left is real stack (or cached) and right is real register(not cached)
 594       left_arg = &right;
 595       right_arg = &left;
 596     }
 597 
 598     left_arg->load_item();
 599 
 600     // do not need to load right, as we can handle stack and constants
 601     if (x->op() == Bytecodes::_imul ) {
 602       // check if we can use shift instead
 603       bool use_constant = false;
 604       bool use_tmp = false;
 605       if (right_arg->is_constant()) {
 606         int iconst = right_arg->get_jint_constant();
 607         if (iconst > 0) {
 608           if (is_power_of_2(iconst)) {
 609             use_constant = true;
 610           } else if (is_power_of_2(iconst - 1) || is_power_of_2(iconst + 1)) {
 611             use_constant = true;
 612             use_tmp = true;
 613           }
 614         }
 615       }
 616       if (use_constant) {
 617         right_arg->dont_load_item();
 618       } else {
 619         right_arg->load_item();
 620       }
 621       LIR_Opr tmp = LIR_OprFact::illegalOpr;
 622       if (use_tmp) {
 623         tmp = new_register(T_INT);
 624       }
 625       rlock_result(x);
 626 
 627       arithmetic_op_int(x->op(), x->operand(), left_arg->result(), right_arg->result(), tmp);




 217 
 218 void LIRGenerator::increment_counter(LIR_Address* addr, int step) {
 219   __ add((LIR_Opr)addr, LIR_OprFact::intConst(step), (LIR_Opr)addr);
 220 }
 221 
 222 void LIRGenerator::cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info) {
 223   __ cmp_mem_int(condition, base, disp, c, info);
 224 }
 225 
 226 
 227 void LIRGenerator::cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, int disp, BasicType type, CodeEmitInfo* info) {
 228   __ cmp_reg_mem(condition, reg, new LIR_Address(base, disp, type), info);
 229 }
 230 
 231 
 232 void LIRGenerator::cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, LIR_Opr disp, BasicType type, CodeEmitInfo* info) {
 233   __ cmp_reg_mem(condition, reg, new LIR_Address(base, disp, type), info);
 234 }
 235 
 236 
 237 bool LIRGenerator::strength_reduce_multiply(LIR_Opr left, jint c, LIR_Opr result, LIR_Opr tmp) {
 238   if (tmp->is_valid() && c > 0 && c < max_jint) {
 239     if (is_power_of_2(c + 1)) {
 240       __ move(left, tmp);
 241       __ shift_left(left, log2_intptr(c + 1), left);
 242       __ sub(left, tmp, result);
 243       return true;
 244     } else if (is_power_of_2(c - 1)) {
 245       __ move(left, tmp);
 246       __ shift_left(left, log2_intptr(c - 1), left);
 247       __ add(left, tmp, result);
 248       return true;
 249     }
 250   }
 251   return false;
 252 }
 253 
 254 
 255 void LIRGenerator::store_stack_parameter (LIR_Opr item, ByteSize offset_from_sp) {
 256   BasicType type = item->type();
 257   __ store(item, new LIR_Address(FrameMap::rsp_opr, in_bytes(offset_from_sp), type));
 258 }


 586   } else {
 587     // missing test if instr is commutative and if we should swap
 588     LIRItem left(x->x(),  this);
 589     LIRItem right(x->y(), this);
 590     LIRItem* left_arg = &left;
 591     LIRItem* right_arg = &right;
 592     if (x->is_commutative() && left.is_stack() && right.is_register()) {
 593       // swap them if left is real stack (or cached) and right is real register(not cached)
 594       left_arg = &right;
 595       right_arg = &left;
 596     }
 597 
 598     left_arg->load_item();
 599 
 600     // do not need to load right, as we can handle stack and constants
 601     if (x->op() == Bytecodes::_imul ) {
 602       // check if we can use shift instead
 603       bool use_constant = false;
 604       bool use_tmp = false;
 605       if (right_arg->is_constant()) {
 606         jint iconst = right_arg->get_jint_constant();
 607         if (iconst > 0 && iconst < max_jint) {
 608           if (is_power_of_2(iconst)) {
 609             use_constant = true;
 610           } else if (is_power_of_2(iconst - 1) || is_power_of_2(iconst + 1)) {
 611             use_constant = true;
 612             use_tmp = true;
 613           }
 614         }
 615       }
 616       if (use_constant) {
 617         right_arg->dont_load_item();
 618       } else {
 619         right_arg->load_item();
 620       }
 621       LIR_Opr tmp = LIR_OprFact::illegalOpr;
 622       if (use_tmp) {
 623         tmp = new_register(T_INT);
 624       }
 625       rlock_result(x);
 626 
 627       arithmetic_op_int(x->op(), x->operand(), left_arg->result(), right_arg->result(), tmp);


< prev index next >