< 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 //


 525 reg_class int_rbx_reg(RBX);
 526 
 527 // Singleton class for RCX int register
 528 reg_class int_rcx_reg(RCX);
 529 
 530 // Singleton class for RCX int register
 531 reg_class int_rdx_reg(RDX);
 532 
 533 // Singleton class for RCX int register
 534 reg_class int_rdi_reg(RDI);
 535 
 536 // Singleton class for instruction pointer
 537 // reg_class ip_reg(RIP);
 538 
 539 %}
 540 
 541 source_hpp %{
 542 #if INCLUDE_ZGC
 543 #include "gc/z/zBarrierSetAssembler.hpp"
 544 #endif



 545 %}
 546 
 547 //----------SOURCE BLOCK-------------------------------------------------------
 548 // This is a block of C++ code which provides values, functions, and
 549 // definitions necessary in the rest of the architecture description
 550 source %{
 551 #define   RELOC_IMM64    Assembler::imm_operand
 552 #define   RELOC_DISP32   Assembler::disp32_operand
 553 
 554 #define __ _masm.
 555 
 556 static bool generate_vzeroupper(Compile* C) {
 557   return (VM_Version::supports_vzeroupper() && (C->max_vector_size() > 16 || C->clear_upper_avx() == true)) ? true: false;  // Generate vzeroupper
 558 }
 559 
 560 static int clear_avx_size() {
 561   return generate_vzeroupper(Compile::current()) ? 3: 0;  // vzeroupper
 562 }
 563 
 564 // !!!!! Special hack to get all types of calls to specify the byte offset


7563   predicate(VM_Version::supports_cx8());
7564   match(Set res (CompareAndSwapP mem_ptr (Binary oldval newval)));
7565   match(Set res (WeakCompareAndSwapP mem_ptr (Binary oldval newval)));
7566   effect(KILL cr, KILL oldval);
7567 
7568   format %{ "cmpxchgq $mem_ptr,$newval\t# "
7569             "If rax == $mem_ptr then store $newval into $mem_ptr\n\t"
7570             "sete    $res\n\t"
7571             "movzbl  $res, $res" %}
7572   opcode(0x0F, 0xB1);
7573   ins_encode(lock_prefix,
7574              REX_reg_mem_wide(newval, mem_ptr),
7575              OpcP, OpcS,
7576              reg_mem(newval, mem_ptr),
7577              REX_breg(res), Opcode(0x0F), Opcode(0x94), reg(res), // sete
7578              REX_reg_breg(res, res), // movzbl
7579              Opcode(0xF), Opcode(0xB6), reg_reg(res, res));
7580   ins_pipe( pipe_cmpxchg );
7581 %}
7582 



























7583 instruct compareAndSwapL(rRegI res,
7584                          memory mem_ptr,
7585                          rax_RegL oldval, rRegL newval,
7586                          rFlagsReg cr)
7587 %{
7588   predicate(VM_Version::supports_cx8());
7589   match(Set res (CompareAndSwapL mem_ptr (Binary oldval newval)));
7590   match(Set res (WeakCompareAndSwapL mem_ptr (Binary oldval newval)));
7591   effect(KILL cr, KILL oldval);
7592 
7593   format %{ "cmpxchgq $mem_ptr,$newval\t# "
7594             "If rax == $mem_ptr then store $newval into $mem_ptr\n\t"
7595             "sete    $res\n\t"
7596             "movzbl  $res, $res" %}
7597   opcode(0x0F, 0xB1);
7598   ins_encode(lock_prefix,
7599              REX_reg_mem_wide(newval, mem_ptr),
7600              OpcP, OpcS,
7601              reg_mem(newval, mem_ptr),
7602              REX_breg(res), Opcode(0x0F), Opcode(0x94), reg(res), // sete


7684                           rFlagsReg cr) %{
7685   match(Set res (CompareAndSwapN mem_ptr (Binary oldval newval)));
7686   match(Set res (WeakCompareAndSwapN mem_ptr (Binary oldval newval)));
7687   effect(KILL cr, KILL oldval);
7688 
7689   format %{ "cmpxchgl $mem_ptr,$newval\t# "
7690             "If rax == $mem_ptr then store $newval into $mem_ptr\n\t"
7691             "sete    $res\n\t"
7692             "movzbl  $res, $res" %}
7693   opcode(0x0F, 0xB1);
7694   ins_encode(lock_prefix,
7695              REX_reg_mem(newval, mem_ptr),
7696              OpcP, OpcS,
7697              reg_mem(newval, mem_ptr),
7698              REX_breg(res), Opcode(0x0F), Opcode(0x94), reg(res), // sete
7699              REX_reg_breg(res, res), // movzbl
7700              Opcode(0xF), Opcode(0xB6), reg_reg(res, res));
7701   ins_pipe( pipe_cmpxchg );
7702 %}
7703 

























7704 instruct compareAndExchangeB(
7705                          memory mem_ptr,
7706                          rax_RegI oldval, rRegI newval,
7707                          rFlagsReg cr)
7708 %{
7709   match(Set oldval (CompareAndExchangeB mem_ptr (Binary oldval newval)));
7710   effect(KILL cr);
7711 
7712   format %{ "cmpxchgb $mem_ptr,$newval\t# "
7713             "If rax == $mem_ptr then store $newval into $mem_ptr\n\t"  %}
7714   opcode(0x0F, 0xB0);
7715   ins_encode(lock_prefix,
7716              REX_breg_mem(newval, mem_ptr),
7717              OpcP, OpcS,
7718              reg_mem(newval, mem_ptr) // lock cmpxchg
7719              );
7720   ins_pipe( pipe_cmpxchg );
7721 %}
7722 
7723 instruct compareAndExchangeS(


7780 %}
7781 
7782 instruct compareAndExchangeN(
7783                           memory mem_ptr,
7784                           rax_RegN oldval, rRegN newval,
7785                           rFlagsReg cr) %{
7786   match(Set oldval (CompareAndExchangeN mem_ptr (Binary oldval newval)));
7787   effect(KILL cr);
7788 
7789   format %{ "cmpxchgl $mem_ptr,$newval\t# "
7790             "If rax == $mem_ptr then store $newval into $mem_ptr\n\t" %}
7791   opcode(0x0F, 0xB1);
7792   ins_encode(lock_prefix,
7793              REX_reg_mem(newval, mem_ptr),
7794              OpcP, OpcS,
7795              reg_mem(newval, mem_ptr)  // lock cmpxchg
7796           );
7797   ins_pipe( pipe_cmpxchg );
7798 %}
7799 























7800 instruct compareAndExchangeP(
7801                          memory mem_ptr,
7802                          rax_RegP oldval, rRegP newval,
7803                          rFlagsReg cr)
7804 %{
7805   predicate(VM_Version::supports_cx8());
7806   match(Set oldval (CompareAndExchangeP mem_ptr (Binary oldval newval)));
7807   effect(KILL cr);
7808 
7809   format %{ "cmpxchgq $mem_ptr,$newval\t# "
7810             "If rax == $mem_ptr then store $newval into $mem_ptr\n\t" %}
7811   opcode(0x0F, 0xB1);
7812   ins_encode(lock_prefix,
7813              REX_reg_mem_wide(newval, mem_ptr),
7814              OpcP, OpcS,
7815              reg_mem(newval, mem_ptr)  // lock cmpxchg
7816           );


























7817   ins_pipe( pipe_cmpxchg );
7818 %}
7819 
7820 instruct xaddB_no_res( memory mem, Universe dummy, immI add, rFlagsReg cr) %{
7821   predicate(n->as_LoadStore()->result_not_used());
7822   match(Set dummy (GetAndAddB mem add));
7823   effect(KILL cr);
7824   format %{ "ADDB  [$mem],$add" %}
7825   ins_encode %{
7826     if (os::is_MP()) { __ lock(); }
7827     __ addb($mem$$Address, $add$$constant);
7828   %}
7829   ins_pipe( pipe_cmpxchg );
7830 %}
7831 
7832 instruct xaddB( memory mem, rRegI newval, rFlagsReg cr) %{
7833   match(Set newval (GetAndAddB mem newval));
7834   effect(KILL cr);
7835   format %{ "XADDB  [$mem],$newval" %}
7836   ins_encode %{


   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 //


 525 reg_class int_rbx_reg(RBX);
 526 
 527 // Singleton class for RCX int register
 528 reg_class int_rcx_reg(RCX);
 529 
 530 // Singleton class for RCX int register
 531 reg_class int_rdx_reg(RDX);
 532 
 533 // Singleton class for RCX int register
 534 reg_class int_rdi_reg(RDI);
 535 
 536 // Singleton class for instruction pointer
 537 // reg_class ip_reg(RIP);
 538 
 539 %}
 540 
 541 source_hpp %{
 542 #if INCLUDE_ZGC
 543 #include "gc/z/zBarrierSetAssembler.hpp"
 544 #endif
 545 #if INCLUDE_SHENANDOAHGC
 546 #include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp"
 547 #endif
 548 %}
 549 
 550 //----------SOURCE BLOCK-------------------------------------------------------
 551 // This is a block of C++ code which provides values, functions, and
 552 // definitions necessary in the rest of the architecture description
 553 source %{
 554 #define   RELOC_IMM64    Assembler::imm_operand
 555 #define   RELOC_DISP32   Assembler::disp32_operand
 556 
 557 #define __ _masm.
 558 
 559 static bool generate_vzeroupper(Compile* C) {
 560   return (VM_Version::supports_vzeroupper() && (C->max_vector_size() > 16 || C->clear_upper_avx() == true)) ? true: false;  // Generate vzeroupper
 561 }
 562 
 563 static int clear_avx_size() {
 564   return generate_vzeroupper(Compile::current()) ? 3: 0;  // vzeroupper
 565 }
 566 
 567 // !!!!! Special hack to get all types of calls to specify the byte offset


7566   predicate(VM_Version::supports_cx8());
7567   match(Set res (CompareAndSwapP mem_ptr (Binary oldval newval)));
7568   match(Set res (WeakCompareAndSwapP mem_ptr (Binary oldval newval)));
7569   effect(KILL cr, KILL oldval);
7570 
7571   format %{ "cmpxchgq $mem_ptr,$newval\t# "
7572             "If rax == $mem_ptr then store $newval into $mem_ptr\n\t"
7573             "sete    $res\n\t"
7574             "movzbl  $res, $res" %}
7575   opcode(0x0F, 0xB1);
7576   ins_encode(lock_prefix,
7577              REX_reg_mem_wide(newval, mem_ptr),
7578              OpcP, OpcS,
7579              reg_mem(newval, mem_ptr),
7580              REX_breg(res), Opcode(0x0F), Opcode(0x94), reg(res), // sete
7581              REX_reg_breg(res, res), // movzbl
7582              Opcode(0xF), Opcode(0xB6), reg_reg(res, res));
7583   ins_pipe( pipe_cmpxchg );
7584 %}
7585 
7586 instruct compareAndSwapP_shenandoah(rRegI res,
7587                                     memory mem_ptr,
7588                                     rRegP tmp1, rRegP tmp2,
7589                                     rax_RegP oldval, rRegP newval,
7590                                     rFlagsReg cr)
7591 %{
7592   predicate(VM_Version::supports_cx8());
7593   match(Set res (ShenandoahCompareAndSwapP mem_ptr (Binary oldval newval)));
7594   match(Set res (ShenandoahWeakCompareAndSwapP mem_ptr (Binary oldval newval)));
7595   effect(TEMP tmp1, TEMP tmp2, KILL cr, KILL oldval);
7596 
7597   format %{ "shenandoah_cas_oop $mem_ptr,$newval" %}
7598 
7599   ins_encode %{
7600 #if INCLUDE_SHENANDOAHGC
7601     ShenandoahBarrierSet::assembler()->cmpxchg_oop(&_masm,
7602                                                    $res$$Register, $mem_ptr$$Address, $oldval$$Register, $newval$$Register,
7603                                                    false, // swap
7604                                                    $tmp1$$Register, $tmp2$$Register
7605                                                    );
7606 #else
7607     ShouldNotReachHere();
7608 #endif
7609   %}
7610   ins_pipe( pipe_cmpxchg );
7611 %}
7612 
7613 instruct compareAndSwapL(rRegI res,
7614                          memory mem_ptr,
7615                          rax_RegL oldval, rRegL newval,
7616                          rFlagsReg cr)
7617 %{
7618   predicate(VM_Version::supports_cx8());
7619   match(Set res (CompareAndSwapL mem_ptr (Binary oldval newval)));
7620   match(Set res (WeakCompareAndSwapL mem_ptr (Binary oldval newval)));
7621   effect(KILL cr, KILL oldval);
7622 
7623   format %{ "cmpxchgq $mem_ptr,$newval\t# "
7624             "If rax == $mem_ptr then store $newval into $mem_ptr\n\t"
7625             "sete    $res\n\t"
7626             "movzbl  $res, $res" %}
7627   opcode(0x0F, 0xB1);
7628   ins_encode(lock_prefix,
7629              REX_reg_mem_wide(newval, mem_ptr),
7630              OpcP, OpcS,
7631              reg_mem(newval, mem_ptr),
7632              REX_breg(res), Opcode(0x0F), Opcode(0x94), reg(res), // sete


7714                           rFlagsReg cr) %{
7715   match(Set res (CompareAndSwapN mem_ptr (Binary oldval newval)));
7716   match(Set res (WeakCompareAndSwapN mem_ptr (Binary oldval newval)));
7717   effect(KILL cr, KILL oldval);
7718 
7719   format %{ "cmpxchgl $mem_ptr,$newval\t# "
7720             "If rax == $mem_ptr then store $newval into $mem_ptr\n\t"
7721             "sete    $res\n\t"
7722             "movzbl  $res, $res" %}
7723   opcode(0x0F, 0xB1);
7724   ins_encode(lock_prefix,
7725              REX_reg_mem(newval, mem_ptr),
7726              OpcP, OpcS,
7727              reg_mem(newval, mem_ptr),
7728              REX_breg(res), Opcode(0x0F), Opcode(0x94), reg(res), // sete
7729              REX_reg_breg(res, res), // movzbl
7730              Opcode(0xF), Opcode(0xB6), reg_reg(res, res));
7731   ins_pipe( pipe_cmpxchg );
7732 %}
7733 
7734 instruct compareAndSwapN_shenandoah(rRegI res,
7735                                     memory mem_ptr,
7736                                     rRegP tmp1, rRegP tmp2,
7737                                     rax_RegN oldval, rRegN newval,
7738                                     rFlagsReg cr) %{
7739   match(Set res (ShenandoahCompareAndSwapN mem_ptr (Binary oldval newval)));
7740   match(Set res (ShenandoahWeakCompareAndSwapN mem_ptr (Binary oldval newval)));
7741   effect(TEMP tmp1, TEMP tmp2, KILL cr, KILL oldval);
7742 
7743   format %{ "shenandoah_cas_oop $mem_ptr,$newval" %}
7744 
7745   ins_encode %{
7746 #if INCLUDE_SHENANDOAHGC
7747     ShenandoahBarrierSet::assembler()->cmpxchg_oop(&_masm,
7748                                                    $res$$Register, $mem_ptr$$Address, $oldval$$Register, $newval$$Register,
7749                                                    false, // swap
7750                                                    $tmp1$$Register, $tmp2$$Register
7751                                                    );
7752 #else
7753     ShouldNotReachHere();
7754 #endif
7755   %}
7756   ins_pipe( pipe_cmpxchg );
7757 %}
7758 
7759 instruct compareAndExchangeB(
7760                          memory mem_ptr,
7761                          rax_RegI oldval, rRegI newval,
7762                          rFlagsReg cr)
7763 %{
7764   match(Set oldval (CompareAndExchangeB mem_ptr (Binary oldval newval)));
7765   effect(KILL cr);
7766 
7767   format %{ "cmpxchgb $mem_ptr,$newval\t# "
7768             "If rax == $mem_ptr then store $newval into $mem_ptr\n\t"  %}
7769   opcode(0x0F, 0xB0);
7770   ins_encode(lock_prefix,
7771              REX_breg_mem(newval, mem_ptr),
7772              OpcP, OpcS,
7773              reg_mem(newval, mem_ptr) // lock cmpxchg
7774              );
7775   ins_pipe( pipe_cmpxchg );
7776 %}
7777 
7778 instruct compareAndExchangeS(


7835 %}
7836 
7837 instruct compareAndExchangeN(
7838                           memory mem_ptr,
7839                           rax_RegN oldval, rRegN newval,
7840                           rFlagsReg cr) %{
7841   match(Set oldval (CompareAndExchangeN mem_ptr (Binary oldval newval)));
7842   effect(KILL cr);
7843 
7844   format %{ "cmpxchgl $mem_ptr,$newval\t# "
7845             "If rax == $mem_ptr then store $newval into $mem_ptr\n\t" %}
7846   opcode(0x0F, 0xB1);
7847   ins_encode(lock_prefix,
7848              REX_reg_mem(newval, mem_ptr),
7849              OpcP, OpcS,
7850              reg_mem(newval, mem_ptr)  // lock cmpxchg
7851           );
7852   ins_pipe( pipe_cmpxchg );
7853 %}
7854 
7855 instruct compareAndExchangeN_shenandoah(memory mem_ptr,
7856                                         rax_RegN oldval, rRegN newval,
7857                                         rRegP tmp1, rRegP tmp2,
7858                                         rFlagsReg cr) %{
7859   match(Set oldval (ShenandoahCompareAndExchangeN mem_ptr (Binary oldval newval)));
7860   effect(TEMP tmp1, TEMP tmp2, KILL cr);
7861 
7862   format %{ "shenandoah_cas_oop $mem_ptr,$newval" %}
7863 
7864   ins_encode %{
7865 #if INCLUDE_SHENANDOAHGC
7866     ShenandoahBarrierSet::assembler()->cmpxchg_oop(&_masm,
7867                                                    NULL, $mem_ptr$$Address, $oldval$$Register, $newval$$Register,
7868                                                    true, // exchange
7869                                                    $tmp1$$Register, $tmp2$$Register
7870                                                    );
7871 #else
7872     ShouldNotReachHere();
7873 #endif
7874   %}
7875   ins_pipe( pipe_cmpxchg );
7876 %}
7877 
7878 instruct compareAndExchangeP(
7879                          memory mem_ptr,
7880                          rax_RegP oldval, rRegP newval,
7881                          rFlagsReg cr)
7882 %{
7883   predicate(VM_Version::supports_cx8());
7884   match(Set oldval (CompareAndExchangeP mem_ptr (Binary oldval newval)));
7885   effect(KILL cr);
7886 
7887   format %{ "cmpxchgq $mem_ptr,$newval\t# "
7888             "If rax == $mem_ptr then store $newval into $mem_ptr\n\t" %}
7889   opcode(0x0F, 0xB1);
7890   ins_encode(lock_prefix,
7891              REX_reg_mem_wide(newval, mem_ptr),
7892              OpcP, OpcS,
7893              reg_mem(newval, mem_ptr)  // lock cmpxchg
7894           );
7895   ins_pipe( pipe_cmpxchg );
7896 %}
7897 
7898 instruct compareAndExchangeP_shenandoah(memory mem_ptr,
7899                                         rax_RegP oldval, rRegP newval,
7900                                         rRegP tmp1, rRegP tmp2,
7901                                         rFlagsReg cr)
7902 %{
7903   predicate(VM_Version::supports_cx8());
7904   match(Set oldval (ShenandoahCompareAndExchangeP mem_ptr (Binary oldval newval)));
7905   effect(KILL cr, TEMP tmp1, TEMP tmp2);
7906   ins_cost(1000);
7907 
7908   format %{ "shenandoah_cas_oop $mem_ptr,$newval" %}
7909 
7910   ins_encode %{
7911 #if INCLUDE_SHENANDOAHGC
7912     ShenandoahBarrierSet::assembler()->cmpxchg_oop(&_masm,
7913                                                    NULL, $mem_ptr$$Address, $oldval$$Register, $newval$$Register,
7914                                                    true,  // exchange
7915                                                    $tmp1$$Register, $tmp2$$Register
7916                                                    );
7917 #else
7918     ShouldNotReachHere();
7919 #endif
7920   %}
7921   ins_pipe( pipe_cmpxchg );
7922 %}
7923 
7924 instruct xaddB_no_res( memory mem, Universe dummy, immI add, rFlagsReg cr) %{
7925   predicate(n->as_LoadStore()->result_not_used());
7926   match(Set dummy (GetAndAddB mem add));
7927   effect(KILL cr);
7928   format %{ "ADDB  [$mem],$add" %}
7929   ins_encode %{
7930     if (os::is_MP()) { __ lock(); }
7931     __ addb($mem$$Address, $add$$constant);
7932   %}
7933   ins_pipe( pipe_cmpxchg );
7934 %}
7935 
7936 instruct xaddB( memory mem, rRegI newval, rFlagsReg cr) %{
7937   match(Set newval (GetAndAddB mem newval));
7938   effect(KILL cr);
7939   format %{ "XADDB  [$mem],$newval" %}
7940   ins_encode %{


< prev index next >