src/cpu/x86/vm/c1_LIRAssembler_x86.cpp

Print this page
rev 3227 : 7133857: exp() and pow() should use the x87 ISA on x86
Summary: use x87 instructions to implement exp() and pow() in interpreter/c1/c2.
Reviewed-by:


2416   } else if (value->is_double_fpu()) {
2417     assert(value->fpu_regnrLo() == 0 && dest->fpu_regnrLo() == 0, "both must be on TOS");
2418     switch(code) {
2419       case lir_log   : __ flog() ; break;
2420       case lir_log10 : __ flog10() ; break;
2421       case lir_abs   : __ fabs() ; break;
2422       case lir_sqrt  : __ fsqrt(); break;
2423       case lir_sin   :
2424         // Should consider not saving rbx, if not necessary
2425         __ trigfunc('s', op->as_Op2()->fpu_stack_size());
2426         break;
2427       case lir_cos :
2428         // Should consider not saving rbx, if not necessary
2429         assert(op->as_Op2()->fpu_stack_size() <= 6, "sin and cos need two free stack slots");
2430         __ trigfunc('c', op->as_Op2()->fpu_stack_size());
2431         break;
2432       case lir_tan :
2433         // Should consider not saving rbx, if not necessary
2434         __ trigfunc('t', op->as_Op2()->fpu_stack_size());
2435         break;






2436       default      : ShouldNotReachHere();
2437     }
2438   } else {
2439     Unimplemented();
2440   }
2441 }
2442 
2443 void LIR_Assembler::logic_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dst) {
2444   // assert(left->destroys_register(), "check");
2445   if (left->is_single_cpu()) {
2446     Register reg = left->as_register();
2447     if (right->is_constant()) {
2448       int val = right->as_constant_ptr()->as_jint();
2449       switch (code) {
2450         case lir_logic_and: __ andl (reg, val); break;
2451         case lir_logic_or:  __ orl  (reg, val); break;
2452         case lir_logic_xor: __ xorl (reg, val); break;
2453         default: ShouldNotReachHere();
2454       }
2455     } else if (right->is_stack()) {




2416   } else if (value->is_double_fpu()) {
2417     assert(value->fpu_regnrLo() == 0 && dest->fpu_regnrLo() == 0, "both must be on TOS");
2418     switch(code) {
2419       case lir_log   : __ flog() ; break;
2420       case lir_log10 : __ flog10() ; break;
2421       case lir_abs   : __ fabs() ; break;
2422       case lir_sqrt  : __ fsqrt(); break;
2423       case lir_sin   :
2424         // Should consider not saving rbx, if not necessary
2425         __ trigfunc('s', op->as_Op2()->fpu_stack_size());
2426         break;
2427       case lir_cos :
2428         // Should consider not saving rbx, if not necessary
2429         assert(op->as_Op2()->fpu_stack_size() <= 6, "sin and cos need two free stack slots");
2430         __ trigfunc('c', op->as_Op2()->fpu_stack_size());
2431         break;
2432       case lir_tan :
2433         // Should consider not saving rbx, if not necessary
2434         __ trigfunc('t', op->as_Op2()->fpu_stack_size());
2435         break;
2436       case lir_exp :
2437         __ exp_with_fallback(op->as_Op2()->fpu_stack_size());
2438         break;
2439       case lir_pow :
2440         __ pow_with_fallback(op->as_Op2()->fpu_stack_size());
2441         break;
2442       default      : ShouldNotReachHere();
2443     }
2444   } else {
2445     Unimplemented();
2446   }
2447 }
2448 
2449 void LIR_Assembler::logic_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dst) {
2450   // assert(left->destroys_register(), "check");
2451   if (left->is_single_cpu()) {
2452     Register reg = left->as_register();
2453     if (right->is_constant()) {
2454       int val = right->as_constant_ptr()->as_jint();
2455       switch (code) {
2456         case lir_logic_and: __ andl (reg, val); break;
2457         case lir_logic_or:  __ orl  (reg, val); break;
2458         case lir_logic_xor: __ xorl (reg, val); break;
2459         default: ShouldNotReachHere();
2460       }
2461     } else if (right->is_stack()) {