src/hotspot/cpu/x86/x86_32.ad
changeset 51996 84743156e780
parent 51857 9978fea8a371
child 52180 a817954f4081
equal deleted inserted replaced
51995:f7babf9d1592 51996:84743156e780
  2085     emit_rm(cbuf, 0x00, $t1$$reg, 0x05 );
  2085     emit_rm(cbuf, 0x00, $t1$$reg, 0x05 );
  2086     emit_d32(cbuf, 0x00);
  2086     emit_d32(cbuf, 0x00);
  2087   %}
  2087   %}
  2088 
  2088 
  2089   enc_class lock_prefix( ) %{
  2089   enc_class lock_prefix( ) %{
  2090     if( os::is_MP() )
  2090     emit_opcode(cbuf,0xF0);         // [Lock]
  2091       emit_opcode(cbuf,0xF0);         // [Lock]
       
  2092   %}
  2091   %}
  2093 
  2092 
  2094   // Cmp-xchg long value.
  2093   // Cmp-xchg long value.
  2095   // Note: we need to swap rbx, and rcx before and after the
  2094   // Note: we need to swap rbx, and rcx before and after the
  2096   //       cmpxchg8 instruction because the instruction uses
  2095   //       cmpxchg8 instruction because the instruction uses
  2100 
  2099 
  2101     // XCHG  rbx,ecx
  2100     // XCHG  rbx,ecx
  2102     emit_opcode(cbuf,0x87);
  2101     emit_opcode(cbuf,0x87);
  2103     emit_opcode(cbuf,0xD9);
  2102     emit_opcode(cbuf,0xD9);
  2104     // [Lock]
  2103     // [Lock]
  2105     if( os::is_MP() )
  2104     emit_opcode(cbuf,0xF0);
  2106       emit_opcode(cbuf,0xF0);
       
  2107     // CMPXCHG8 [Eptr]
  2105     // CMPXCHG8 [Eptr]
  2108     emit_opcode(cbuf,0x0F);
  2106     emit_opcode(cbuf,0x0F);
  2109     emit_opcode(cbuf,0xC7);
  2107     emit_opcode(cbuf,0xC7);
  2110     emit_rm( cbuf, 0x0, 1, $mem_ptr$$reg );
  2108     emit_rm( cbuf, 0x0, 1, $mem_ptr$$reg );
  2111     // XCHG  rbx,ecx
  2109     // XCHG  rbx,ecx
  2113     emit_opcode(cbuf,0xD9);
  2111     emit_opcode(cbuf,0xD9);
  2114   %}
  2112   %}
  2115 
  2113 
  2116   enc_class enc_cmpxchg(eSIRegP mem_ptr) %{
  2114   enc_class enc_cmpxchg(eSIRegP mem_ptr) %{
  2117     // [Lock]
  2115     // [Lock]
  2118     if( os::is_MP() )
  2116     emit_opcode(cbuf,0xF0);
  2119       emit_opcode(cbuf,0xF0);
       
  2120 
  2117 
  2121     // CMPXCHG [Eptr]
  2118     // CMPXCHG [Eptr]
  2122     emit_opcode(cbuf,0x0F);
  2119     emit_opcode(cbuf,0x0F);
  2123     emit_opcode(cbuf,0xB1);
  2120     emit_opcode(cbuf,0xB1);
  2124     emit_rm( cbuf, 0x0, 1, $mem_ptr$$reg );
  2121     emit_rm( cbuf, 0x0, 1, $mem_ptr$$reg );
  2125   %}
  2122   %}
  2126 
  2123 
  2127   enc_class enc_cmpxchgb(eSIRegP mem_ptr) %{
  2124   enc_class enc_cmpxchgb(eSIRegP mem_ptr) %{
  2128     // [Lock]
  2125     // [Lock]
  2129     if( os::is_MP() )
  2126     emit_opcode(cbuf,0xF0);
  2130       emit_opcode(cbuf,0xF0);
       
  2131 
  2127 
  2132     // CMPXCHGB [Eptr]
  2128     // CMPXCHGB [Eptr]
  2133     emit_opcode(cbuf,0x0F);
  2129     emit_opcode(cbuf,0x0F);
  2134     emit_opcode(cbuf,0xB0);
  2130     emit_opcode(cbuf,0xB0);
  2135     emit_rm( cbuf, 0x0, 1, $mem_ptr$$reg );
  2131     emit_rm( cbuf, 0x0, 1, $mem_ptr$$reg );
  2136   %}
  2132   %}
  2137 
  2133 
  2138   enc_class enc_cmpxchgw(eSIRegP mem_ptr) %{
  2134   enc_class enc_cmpxchgw(eSIRegP mem_ptr) %{
  2139     // [Lock]
  2135     // [Lock]
  2140     if( os::is_MP() )
  2136     emit_opcode(cbuf,0xF0);
  2141       emit_opcode(cbuf,0xF0);
       
  2142 
  2137 
  2143     // 16-bit mode
  2138     // 16-bit mode
  2144     emit_opcode(cbuf, 0x66);
  2139     emit_opcode(cbuf, 0x66);
  2145 
  2140 
  2146     // CMPXCHGW [Eptr]
  2141     // CMPXCHGW [Eptr]
  6762   effect(KILL cr);
  6757   effect(KILL cr);
  6763   ins_cost(400);
  6758   ins_cost(400);
  6764 
  6759 
  6765   format %{
  6760   format %{
  6766     $$template
  6761     $$template
  6767     if (os::is_MP()) {
  6762     $$emit$$"LOCK ADDL [ESP + #0], 0\t! membar_volatile"
  6768       $$emit$$"LOCK ADDL [ESP + #0], 0\t! membar_volatile"
       
  6769     } else {
       
  6770       $$emit$$"MEMBAR-volatile ! (empty encoding)"
       
  6771     }
       
  6772   %}
  6763   %}
  6773   ins_encode %{
  6764   ins_encode %{
  6774     __ membar(Assembler::StoreLoad);
  6765     __ membar(Assembler::StoreLoad);
  6775   %}
  6766   %}
  6776   ins_pipe(pipe_slow);
  6767   ins_pipe(pipe_slow);
  7371     // Note: we need to swap rbx, and rcx before and after the
  7362     // Note: we need to swap rbx, and rcx before and after the
  7372     //       cmpxchg8 instruction because the instruction uses
  7363     //       cmpxchg8 instruction because the instruction uses
  7373     //       rcx as the high order word of the new value to store but
  7364     //       rcx as the high order word of the new value to store but
  7374     //       our register encoding uses rbx.
  7365     //       our register encoding uses rbx.
  7375     __ xchgl(as_Register(EBX_enc), as_Register(ECX_enc));
  7366     __ xchgl(as_Register(EBX_enc), as_Register(ECX_enc));
  7376     if( os::is_MP() )
  7367     __ lock();
  7377       __ lock();
       
  7378     __ cmpxchg8($mem$$Address);
  7368     __ cmpxchg8($mem$$Address);
  7379     __ xchgl(as_Register(EBX_enc), as_Register(ECX_enc));
  7369     __ xchgl(as_Register(EBX_enc), as_Register(ECX_enc));
  7380   %}
  7370   %}
  7381   ins_pipe( pipe_cmpxchg );
  7371   ins_pipe( pipe_cmpxchg );
  7382 %}
  7372 %}
  7497   predicate(n->as_LoadStore()->result_not_used());
  7487   predicate(n->as_LoadStore()->result_not_used());
  7498   match(Set dummy (GetAndAddB mem add));
  7488   match(Set dummy (GetAndAddB mem add));
  7499   effect(KILL cr);
  7489   effect(KILL cr);
  7500   format %{ "ADDB  [$mem],$add" %}
  7490   format %{ "ADDB  [$mem],$add" %}
  7501   ins_encode %{
  7491   ins_encode %{
  7502     if (os::is_MP()) { __ lock(); }
  7492     __ lock();
  7503     __ addb($mem$$Address, $add$$constant);
  7493     __ addb($mem$$Address, $add$$constant);
  7504   %}
  7494   %}
  7505   ins_pipe( pipe_cmpxchg );
  7495   ins_pipe( pipe_cmpxchg );
  7506 %}
  7496 %}
  7507 
  7497 
  7509 instruct xaddB( memory mem, xRegI newval, eFlagsReg cr) %{
  7499 instruct xaddB( memory mem, xRegI newval, eFlagsReg cr) %{
  7510   match(Set newval (GetAndAddB mem newval));
  7500   match(Set newval (GetAndAddB mem newval));
  7511   effect(KILL cr);
  7501   effect(KILL cr);
  7512   format %{ "XADDB  [$mem],$newval" %}
  7502   format %{ "XADDB  [$mem],$newval" %}
  7513   ins_encode %{
  7503   ins_encode %{
  7514     if (os::is_MP()) { __ lock(); }
  7504     __ lock();
  7515     __ xaddb($mem$$Address, $newval$$Register);
  7505     __ xaddb($mem$$Address, $newval$$Register);
  7516   %}
  7506   %}
  7517   ins_pipe( pipe_cmpxchg );
  7507   ins_pipe( pipe_cmpxchg );
  7518 %}
  7508 %}
  7519 
  7509 
  7521   predicate(n->as_LoadStore()->result_not_used());
  7511   predicate(n->as_LoadStore()->result_not_used());
  7522   match(Set dummy (GetAndAddS mem add));
  7512   match(Set dummy (GetAndAddS mem add));
  7523   effect(KILL cr);
  7513   effect(KILL cr);
  7524   format %{ "ADDS  [$mem],$add" %}
  7514   format %{ "ADDS  [$mem],$add" %}
  7525   ins_encode %{
  7515   ins_encode %{
  7526     if (os::is_MP()) { __ lock(); }
  7516     __ lock();
  7527     __ addw($mem$$Address, $add$$constant);
  7517     __ addw($mem$$Address, $add$$constant);
  7528   %}
  7518   %}
  7529   ins_pipe( pipe_cmpxchg );
  7519   ins_pipe( pipe_cmpxchg );
  7530 %}
  7520 %}
  7531 
  7521 
  7532 instruct xaddS( memory mem, rRegI newval, eFlagsReg cr) %{
  7522 instruct xaddS( memory mem, rRegI newval, eFlagsReg cr) %{
  7533   match(Set newval (GetAndAddS mem newval));
  7523   match(Set newval (GetAndAddS mem newval));
  7534   effect(KILL cr);
  7524   effect(KILL cr);
  7535   format %{ "XADDS  [$mem],$newval" %}
  7525   format %{ "XADDS  [$mem],$newval" %}
  7536   ins_encode %{
  7526   ins_encode %{
  7537     if (os::is_MP()) { __ lock(); }
  7527     __ lock();
  7538     __ xaddw($mem$$Address, $newval$$Register);
  7528     __ xaddw($mem$$Address, $newval$$Register);
  7539   %}
  7529   %}
  7540   ins_pipe( pipe_cmpxchg );
  7530   ins_pipe( pipe_cmpxchg );
  7541 %}
  7531 %}
  7542 
  7532 
  7544   predicate(n->as_LoadStore()->result_not_used());
  7534   predicate(n->as_LoadStore()->result_not_used());
  7545   match(Set dummy (GetAndAddI mem add));
  7535   match(Set dummy (GetAndAddI mem add));
  7546   effect(KILL cr);
  7536   effect(KILL cr);
  7547   format %{ "ADDL  [$mem],$add" %}
  7537   format %{ "ADDL  [$mem],$add" %}
  7548   ins_encode %{
  7538   ins_encode %{
  7549     if (os::is_MP()) { __ lock(); }
  7539     __ lock();
  7550     __ addl($mem$$Address, $add$$constant);
  7540     __ addl($mem$$Address, $add$$constant);
  7551   %}
  7541   %}
  7552   ins_pipe( pipe_cmpxchg );
  7542   ins_pipe( pipe_cmpxchg );
  7553 %}
  7543 %}
  7554 
  7544 
  7555 instruct xaddI( memory mem, rRegI newval, eFlagsReg cr) %{
  7545 instruct xaddI( memory mem, rRegI newval, eFlagsReg cr) %{
  7556   match(Set newval (GetAndAddI mem newval));
  7546   match(Set newval (GetAndAddI mem newval));
  7557   effect(KILL cr);
  7547   effect(KILL cr);
  7558   format %{ "XADDL  [$mem],$newval" %}
  7548   format %{ "XADDL  [$mem],$newval" %}
  7559   ins_encode %{
  7549   ins_encode %{
  7560     if (os::is_MP()) { __ lock(); }
  7550     __ lock();
  7561     __ xaddl($mem$$Address, $newval$$Register);
  7551     __ xaddl($mem$$Address, $newval$$Register);
  7562   %}
  7552   %}
  7563   ins_pipe( pipe_cmpxchg );
  7553   ins_pipe( pipe_cmpxchg );
  7564 %}
  7554 %}
  7565 
  7555