1 //
2 // Copyright (c) 2018, Red Hat, Inc. 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 //
23 //
24
25 source_hpp %{
26 #include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp"
27 #include "gc/shenandoah/c2/shenandoahSupport.hpp"
28 %}
29
30 instruct compareAndSwapP_shenandoah(rRegI res,
31 memory mem_ptr,
32 rRegP tmp1, rRegP tmp2,
33 rax_RegP oldval, rRegP newval,
34 rFlagsReg cr)
35 %{
36 match(Set res (ShenandoahCompareAndSwapP mem_ptr (Binary oldval newval)));
37 match(Set res (ShenandoahWeakCompareAndSwapP mem_ptr (Binary oldval newval)));
38 effect(TEMP tmp1, TEMP tmp2, KILL cr, KILL oldval);
39
40 format %{ "shenandoah_cas_oop $mem_ptr,$newval" %}
41
42 ins_encode %{
43 ShenandoahBarrierSet::assembler()->cmpxchg_oop(masm,
44 $res$$Register, $mem_ptr$$Address, $oldval$$Register, $newval$$Register,
45 false, // swap
46 $tmp1$$Register, $tmp2$$Register
47 );
48 %}
49 ins_pipe( pipe_cmpxchg );
50 %}
51
52 instruct compareAndSwapN_shenandoah(rRegI res,
53 memory mem_ptr,
54 rRegP tmp1, rRegP tmp2,
55 rax_RegN oldval, rRegN newval,
56 rFlagsReg cr) %{
57 match(Set res (ShenandoahCompareAndSwapN mem_ptr (Binary oldval newval)));
58 match(Set res (ShenandoahWeakCompareAndSwapN mem_ptr (Binary oldval newval)));
59 effect(TEMP tmp1, TEMP tmp2, KILL cr, KILL oldval);
60
61 format %{ "shenandoah_cas_oop $mem_ptr,$newval" %}
62
63 ins_encode %{
64 ShenandoahBarrierSet::assembler()->cmpxchg_oop(masm,
65 $res$$Register, $mem_ptr$$Address, $oldval$$Register, $newval$$Register,
66 false, // swap
67 $tmp1$$Register, $tmp2$$Register
68 );
69 %}
70 ins_pipe( pipe_cmpxchg );
71 %}
72
73 instruct compareAndExchangeN_shenandoah(memory mem_ptr,
74 rax_RegN oldval, rRegN newval,
75 rRegP tmp1, rRegP tmp2,
76 rFlagsReg cr) %{
77 match(Set oldval (ShenandoahCompareAndExchangeN mem_ptr (Binary oldval newval)));
78 effect(TEMP tmp1, TEMP tmp2, KILL cr);
79
80 format %{ "shenandoah_cas_oop $mem_ptr,$newval" %}
81
82 ins_encode %{
83 ShenandoahBarrierSet::assembler()->cmpxchg_oop(masm,
84 noreg, $mem_ptr$$Address, $oldval$$Register, $newval$$Register,
85 true, // exchange
86 $tmp1$$Register, $tmp2$$Register
87 );
88 %}
89 ins_pipe( pipe_cmpxchg );
90 %}
91
92 instruct compareAndExchangeP_shenandoah(memory mem_ptr,
93 rax_RegP oldval, rRegP newval,
94 rRegP tmp1, rRegP tmp2,
95 rFlagsReg cr)
96 %{
97 match(Set oldval (ShenandoahCompareAndExchangeP mem_ptr (Binary oldval newval)));
98 effect(KILL cr, TEMP tmp1, TEMP tmp2);
99 ins_cost(1000);
100
101 format %{ "shenandoah_cas_oop $mem_ptr,$newval" %}
102
103 ins_encode %{
104 ShenandoahBarrierSet::assembler()->cmpxchg_oop(masm,
105 noreg, $mem_ptr$$Address, $oldval$$Register, $newval$$Register,
106 true, // exchange
107 $tmp1$$Register, $tmp2$$Register
108 );
109 %}
110 ins_pipe( pipe_cmpxchg );
111 %}