< prev index next >

src/hotspot/cpu/x86/x86_64.ad

Print this page


   1 //
   2 // Copyright (c) 2003, 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 //


2324   enc_class Con16(immI src)
2325   %{
2326     // Output immediate
2327     $$$emit16$src$$constant;
2328   %}
2329 
2330   // How is this different from Con32??? XXX
2331   enc_class Con_d32(immI src)
2332   %{
2333     emit_d32(cbuf,$src$$constant);
2334   %}
2335 
2336   enc_class conmemref (rRegP t1) %{    // Con32(storeImmI)
2337     // Output immediate memory reference
2338     emit_rm(cbuf, 0x00, $t1$$reg, 0x05 );
2339     emit_d32(cbuf, 0x00);
2340   %}
2341 
2342   enc_class lock_prefix()
2343   %{
2344     if (os::is_MP()) {
2345       emit_opcode(cbuf, 0xF0); // lock
2346     }
2347   %}
2348 
2349   enc_class REX_mem(memory mem)
2350   %{
2351     if ($mem$$base >= 8) {
2352       if ($mem$$index < 8) {
2353         emit_opcode(cbuf, Assembler::REX_B);
2354       } else {
2355         emit_opcode(cbuf, Assembler::REX_XB);
2356       }
2357     } else {
2358       if ($mem$$index >= 8) {
2359         emit_opcode(cbuf, Assembler::REX_X);
2360       }
2361     }
2362   %}
2363 
2364   enc_class REX_mem_wide(memory mem)
2365   %{
2366     if ($mem$$base >= 8) {


6493 %}
6494 
6495 instruct membar_release_lock()
6496 %{
6497   match(MemBarReleaseLock);
6498   ins_cost(0);
6499 
6500   size(0);
6501   format %{ "MEMBAR-release (a FastUnlock follows so empty encoding)" %}
6502   ins_encode();
6503   ins_pipe(empty);
6504 %}
6505 
6506 instruct membar_volatile(rFlagsReg cr) %{
6507   match(MemBarVolatile);
6508   effect(KILL cr);
6509   ins_cost(400);
6510 
6511   format %{
6512     $$template
6513     if (os::is_MP()) {
6514       $$emit$$"lock addl [rsp + #0], 0\t! membar_volatile"
6515     } else {
6516       $$emit$$"MEMBAR-volatile ! (empty encoding)"
6517     }
6518   %}
6519   ins_encode %{
6520     __ membar(Assembler::StoreLoad);
6521   %}
6522   ins_pipe(pipe_slow);
6523 %}
6524 
6525 instruct unnecessary_membar_volatile()
6526 %{
6527   match(MemBarVolatile);
6528   predicate(Matcher::post_store_load_barrier(n));
6529   ins_cost(0);
6530 
6531   size(0);
6532   format %{ "MEMBAR-volatile (unnecessary so empty encoding)" %}
6533   ins_encode();
6534   ins_pipe(empty);
6535 %}
6536 
6537 instruct membar_storestore() %{


7693   match(Set oldval (CompareAndExchangeP mem_ptr (Binary oldval newval)));
7694   effect(KILL cr);
7695 
7696   format %{ "cmpxchgq $mem_ptr,$newval\t# "
7697             "If rax == $mem_ptr then store $newval into $mem_ptr\n\t" %}
7698   opcode(0x0F, 0xB1);
7699   ins_encode(lock_prefix,
7700              REX_reg_mem_wide(newval, mem_ptr),
7701              OpcP, OpcS,
7702              reg_mem(newval, mem_ptr)  // lock cmpxchg
7703           );
7704   ins_pipe( pipe_cmpxchg );
7705 %}
7706 
7707 instruct xaddB_no_res( memory mem, Universe dummy, immI add, rFlagsReg cr) %{
7708   predicate(n->as_LoadStore()->result_not_used());
7709   match(Set dummy (GetAndAddB mem add));
7710   effect(KILL cr);
7711   format %{ "ADDB  [$mem],$add" %}
7712   ins_encode %{
7713     if (os::is_MP()) { __ lock(); }
7714     __ addb($mem$$Address, $add$$constant);
7715   %}
7716   ins_pipe( pipe_cmpxchg );
7717 %}
7718 
7719 instruct xaddB( memory mem, rRegI newval, rFlagsReg cr) %{
7720   match(Set newval (GetAndAddB mem newval));
7721   effect(KILL cr);
7722   format %{ "XADDB  [$mem],$newval" %}
7723   ins_encode %{
7724     if (os::is_MP()) { __ lock(); }
7725     __ xaddb($mem$$Address, $newval$$Register);
7726   %}
7727   ins_pipe( pipe_cmpxchg );
7728 %}
7729 
7730 instruct xaddS_no_res( memory mem, Universe dummy, immI add, rFlagsReg cr) %{
7731   predicate(n->as_LoadStore()->result_not_used());
7732   match(Set dummy (GetAndAddS mem add));
7733   effect(KILL cr);
7734   format %{ "ADDW  [$mem],$add" %}
7735   ins_encode %{
7736     if (os::is_MP()) { __ lock(); }
7737     __ addw($mem$$Address, $add$$constant);
7738   %}
7739   ins_pipe( pipe_cmpxchg );
7740 %}
7741 
7742 instruct xaddS( memory mem, rRegI newval, rFlagsReg cr) %{
7743   match(Set newval (GetAndAddS mem newval));
7744   effect(KILL cr);
7745   format %{ "XADDW  [$mem],$newval" %}
7746   ins_encode %{
7747     if (os::is_MP()) { __ lock(); }
7748     __ xaddw($mem$$Address, $newval$$Register);
7749   %}
7750   ins_pipe( pipe_cmpxchg );
7751 %}
7752 
7753 instruct xaddI_no_res( memory mem, Universe dummy, immI add, rFlagsReg cr) %{
7754   predicate(n->as_LoadStore()->result_not_used());
7755   match(Set dummy (GetAndAddI mem add));
7756   effect(KILL cr);
7757   format %{ "ADDL  [$mem],$add" %}
7758   ins_encode %{
7759     if (os::is_MP()) { __ lock(); }
7760     __ addl($mem$$Address, $add$$constant);
7761   %}
7762   ins_pipe( pipe_cmpxchg );
7763 %}
7764 
7765 instruct xaddI( memory mem, rRegI newval, rFlagsReg cr) %{
7766   match(Set newval (GetAndAddI mem newval));
7767   effect(KILL cr);
7768   format %{ "XADDL  [$mem],$newval" %}
7769   ins_encode %{
7770     if (os::is_MP()) { __ lock(); }
7771     __ xaddl($mem$$Address, $newval$$Register);
7772   %}
7773   ins_pipe( pipe_cmpxchg );
7774 %}
7775 
7776 instruct xaddL_no_res( memory mem, Universe dummy, immL32 add, rFlagsReg cr) %{
7777   predicate(n->as_LoadStore()->result_not_used());
7778   match(Set dummy (GetAndAddL mem add));
7779   effect(KILL cr);
7780   format %{ "ADDQ  [$mem],$add" %}
7781   ins_encode %{
7782     if (os::is_MP()) { __ lock(); }
7783     __ addq($mem$$Address, $add$$constant);
7784   %}
7785   ins_pipe( pipe_cmpxchg );
7786 %}
7787 
7788 instruct xaddL( memory mem, rRegL newval, rFlagsReg cr) %{
7789   match(Set newval (GetAndAddL mem newval));
7790   effect(KILL cr);
7791   format %{ "XADDQ  [$mem],$newval" %}
7792   ins_encode %{
7793     if (os::is_MP()) { __ lock(); }
7794     __ xaddq($mem$$Address, $newval$$Register);
7795   %}
7796   ins_pipe( pipe_cmpxchg );
7797 %}
7798 
7799 instruct xchgB( memory mem, rRegI newval) %{
7800   match(Set newval (GetAndSetB mem newval));
7801   format %{ "XCHGB  $newval,[$mem]" %}
7802   ins_encode %{
7803     __ xchgb($newval$$Register, $mem$$Address);
7804   %}
7805   ins_pipe( pipe_cmpxchg );
7806 %}
7807 
7808 instruct xchgS( memory mem, rRegI newval) %{
7809   match(Set newval (GetAndSetS mem newval));
7810   format %{ "XCHGW  $newval,[$mem]" %}
7811   ins_encode %{
7812     __ xchgw($newval$$Register, $mem$$Address);
7813   %}


   1 //
   2 // Copyright (c) 2003, 2018, 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 //


2324   enc_class Con16(immI src)
2325   %{
2326     // Output immediate
2327     $$$emit16$src$$constant;
2328   %}
2329 
2330   // How is this different from Con32??? XXX
2331   enc_class Con_d32(immI src)
2332   %{
2333     emit_d32(cbuf,$src$$constant);
2334   %}
2335 
2336   enc_class conmemref (rRegP t1) %{    // Con32(storeImmI)
2337     // Output immediate memory reference
2338     emit_rm(cbuf, 0x00, $t1$$reg, 0x05 );
2339     emit_d32(cbuf, 0x00);
2340   %}
2341 
2342   enc_class lock_prefix()
2343   %{

2344     emit_opcode(cbuf, 0xF0); // lock

2345   %}
2346 
2347   enc_class REX_mem(memory mem)
2348   %{
2349     if ($mem$$base >= 8) {
2350       if ($mem$$index < 8) {
2351         emit_opcode(cbuf, Assembler::REX_B);
2352       } else {
2353         emit_opcode(cbuf, Assembler::REX_XB);
2354       }
2355     } else {
2356       if ($mem$$index >= 8) {
2357         emit_opcode(cbuf, Assembler::REX_X);
2358       }
2359     }
2360   %}
2361 
2362   enc_class REX_mem_wide(memory mem)
2363   %{
2364     if ($mem$$base >= 8) {


6491 %}
6492 
6493 instruct membar_release_lock()
6494 %{
6495   match(MemBarReleaseLock);
6496   ins_cost(0);
6497 
6498   size(0);
6499   format %{ "MEMBAR-release (a FastUnlock follows so empty encoding)" %}
6500   ins_encode();
6501   ins_pipe(empty);
6502 %}
6503 
6504 instruct membar_volatile(rFlagsReg cr) %{
6505   match(MemBarVolatile);
6506   effect(KILL cr);
6507   ins_cost(400);
6508 
6509   format %{
6510     $$template

6511     $$emit$$"lock addl [rsp + #0], 0\t! membar_volatile"



6512   %}
6513   ins_encode %{
6514     __ membar(Assembler::StoreLoad);
6515   %}
6516   ins_pipe(pipe_slow);
6517 %}
6518 
6519 instruct unnecessary_membar_volatile()
6520 %{
6521   match(MemBarVolatile);
6522   predicate(Matcher::post_store_load_barrier(n));
6523   ins_cost(0);
6524 
6525   size(0);
6526   format %{ "MEMBAR-volatile (unnecessary so empty encoding)" %}
6527   ins_encode();
6528   ins_pipe(empty);
6529 %}
6530 
6531 instruct membar_storestore() %{


7687   match(Set oldval (CompareAndExchangeP mem_ptr (Binary oldval newval)));
7688   effect(KILL cr);
7689 
7690   format %{ "cmpxchgq $mem_ptr,$newval\t# "
7691             "If rax == $mem_ptr then store $newval into $mem_ptr\n\t" %}
7692   opcode(0x0F, 0xB1);
7693   ins_encode(lock_prefix,
7694              REX_reg_mem_wide(newval, mem_ptr),
7695              OpcP, OpcS,
7696              reg_mem(newval, mem_ptr)  // lock cmpxchg
7697           );
7698   ins_pipe( pipe_cmpxchg );
7699 %}
7700 
7701 instruct xaddB_no_res( memory mem, Universe dummy, immI add, rFlagsReg cr) %{
7702   predicate(n->as_LoadStore()->result_not_used());
7703   match(Set dummy (GetAndAddB mem add));
7704   effect(KILL cr);
7705   format %{ "ADDB  [$mem],$add" %}
7706   ins_encode %{
7707     __ lock();
7708     __ addb($mem$$Address, $add$$constant);
7709   %}
7710   ins_pipe( pipe_cmpxchg );
7711 %}
7712 
7713 instruct xaddB( memory mem, rRegI newval, rFlagsReg cr) %{
7714   match(Set newval (GetAndAddB mem newval));
7715   effect(KILL cr);
7716   format %{ "XADDB  [$mem],$newval" %}
7717   ins_encode %{
7718     __ lock();
7719     __ xaddb($mem$$Address, $newval$$Register);
7720   %}
7721   ins_pipe( pipe_cmpxchg );
7722 %}
7723 
7724 instruct xaddS_no_res( memory mem, Universe dummy, immI add, rFlagsReg cr) %{
7725   predicate(n->as_LoadStore()->result_not_used());
7726   match(Set dummy (GetAndAddS mem add));
7727   effect(KILL cr);
7728   format %{ "ADDW  [$mem],$add" %}
7729   ins_encode %{
7730     __ lock();
7731     __ addw($mem$$Address, $add$$constant);
7732   %}
7733   ins_pipe( pipe_cmpxchg );
7734 %}
7735 
7736 instruct xaddS( memory mem, rRegI newval, rFlagsReg cr) %{
7737   match(Set newval (GetAndAddS mem newval));
7738   effect(KILL cr);
7739   format %{ "XADDW  [$mem],$newval" %}
7740   ins_encode %{
7741     __ lock();
7742     __ xaddw($mem$$Address, $newval$$Register);
7743   %}
7744   ins_pipe( pipe_cmpxchg );
7745 %}
7746 
7747 instruct xaddI_no_res( memory mem, Universe dummy, immI add, rFlagsReg cr) %{
7748   predicate(n->as_LoadStore()->result_not_used());
7749   match(Set dummy (GetAndAddI mem add));
7750   effect(KILL cr);
7751   format %{ "ADDL  [$mem],$add" %}
7752   ins_encode %{
7753     __ lock();
7754     __ addl($mem$$Address, $add$$constant);
7755   %}
7756   ins_pipe( pipe_cmpxchg );
7757 %}
7758 
7759 instruct xaddI( memory mem, rRegI newval, rFlagsReg cr) %{
7760   match(Set newval (GetAndAddI mem newval));
7761   effect(KILL cr);
7762   format %{ "XADDL  [$mem],$newval" %}
7763   ins_encode %{
7764     __ lock();
7765     __ xaddl($mem$$Address, $newval$$Register);
7766   %}
7767   ins_pipe( pipe_cmpxchg );
7768 %}
7769 
7770 instruct xaddL_no_res( memory mem, Universe dummy, immL32 add, rFlagsReg cr) %{
7771   predicate(n->as_LoadStore()->result_not_used());
7772   match(Set dummy (GetAndAddL mem add));
7773   effect(KILL cr);
7774   format %{ "ADDQ  [$mem],$add" %}
7775   ins_encode %{
7776     __ lock();
7777     __ addq($mem$$Address, $add$$constant);
7778   %}
7779   ins_pipe( pipe_cmpxchg );
7780 %}
7781 
7782 instruct xaddL( memory mem, rRegL newval, rFlagsReg cr) %{
7783   match(Set newval (GetAndAddL mem newval));
7784   effect(KILL cr);
7785   format %{ "XADDQ  [$mem],$newval" %}
7786   ins_encode %{
7787     __ lock();
7788     __ xaddq($mem$$Address, $newval$$Register);
7789   %}
7790   ins_pipe( pipe_cmpxchg );
7791 %}
7792 
7793 instruct xchgB( memory mem, rRegI newval) %{
7794   match(Set newval (GetAndSetB mem newval));
7795   format %{ "XCHGB  $newval,[$mem]" %}
7796   ins_encode %{
7797     __ xchgb($newval$$Register, $mem$$Address);
7798   %}
7799   ins_pipe( pipe_cmpxchg );
7800 %}
7801 
7802 instruct xchgS( memory mem, rRegI newval) %{
7803   match(Set newval (GetAndSetS mem newval));
7804   format %{ "XCHGW  $newval,[$mem]" %}
7805   ins_encode %{
7806     __ xchgw($newval$$Register, $mem$$Address);
7807   %}


< prev index next >