assembler_sparc.inline.hpp revision 1472:c18cbe5936b8
1341572Sslavash/*
2341572Sslavash * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
3341572Sslavash * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4341572Sslavash *
5341572Sslavash * This code is free software; you can redistribute it and/or modify it
6341572Sslavash * under the terms of the GNU General Public License version 2 only, as
7341572Sslavash * published by the Free Software Foundation.
8341572Sslavash *
9341572Sslavash * This code is distributed in the hope that it will be useful, but WITHOUT
10341572Sslavash * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11341572Sslavash * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12341572Sslavash * version 2 for more details (a copy is included in the LICENSE file that
13341572Sslavash * accompanied this code).
14341572Sslavash *
15341572Sslavash * You should have received a copy of the GNU General Public License version
16341572Sslavash * 2 along with this work; if not, write to the Free Software Foundation,
17341572Sslavash * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18341572Sslavash *
19341572Sslavash * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20341572Sslavash * or visit www.oracle.com if you need additional information or have any
21341572Sslavash * questions.
22341572Sslavash *
23341572Sslavash */
24341572Sslavash
25341572Sslavashinline void MacroAssembler::pd_patch_instruction(address branch, address target) {
26341572Sslavash  jint& stub_inst = *(jint*) branch;
27341572Sslavash  stub_inst = patched_branch(target - branch, stub_inst, 0);
28341572Sslavash}
29341572Sslavash
30341572Sslavash#ifndef PRODUCT
31341572Sslavashinline void MacroAssembler::pd_print_patched_instruction(address branch) {
32341572Sslavash  jint stub_inst = *(jint*) branch;
33341572Sslavash  print_instruction(stub_inst);
34341572Sslavash  ::tty->print("%s", " (unresolved)");
35341572Sslavash}
36341572Sslavash#endif // PRODUCT
37341572Sslavash
38341572Sslavashinline bool Address::is_simm13(int offset) { return Assembler::is_simm13(disp() + offset); }
39341572Sslavash
40341572Sslavash
41341572Sslavashinline int AddressLiteral::low10() const {
42341572Sslavash  return Assembler::low10(value());
43341572Sslavash}
44341572Sslavash
45341572Sslavash
46341572Sslavash// inlines for SPARC assembler -- dmu 5/97
47341572Sslavash
48341572Sslavashinline void Assembler::check_delay() {
49341572Sslavash# ifdef CHECK_DELAY
50341572Sslavash  guarantee( delay_state != at_delay_slot, "must say delayed() when filling delay slot");
51341572Sslavash  delay_state = no_delay;
52341572Sslavash# endif
53341572Sslavash}
54341572Sslavash
55341572Sslavashinline void Assembler::emit_long(int x) {
56341572Sslavash  check_delay();
57341572Sslavash  AbstractAssembler::emit_long(x);
58341572Sslavash}
59341572Sslavash
60341572Sslavashinline void Assembler::emit_data(int x, relocInfo::relocType rtype) {
61341572Sslavash  relocate(rtype);
62341572Sslavash  emit_long(x);
63341572Sslavash}
64341572Sslavash
65341572Sslavashinline void Assembler::emit_data(int x, RelocationHolder const& rspec) {
66341572Sslavash  relocate(rspec);
67341572Sslavash  emit_long(x);
68341572Sslavash}
69341572Sslavash
70341572Sslavash
71341572Sslavashinline void Assembler::add(Register s1, Register s2, Register d )                             { emit_long( op(arith_op) | rd(d) | op3(add_op3) | rs1(s1) | rs2(s2) ); }
72341572Sslavashinline void Assembler::add(Register s1, int simm13a, Register d, relocInfo::relocType rtype ) { emit_data( op(arith_op) | rd(d) | op3(add_op3) | rs1(s1) | immed(true) | simm(simm13a, 13), rtype ); }
73341572Sslavashinline void Assembler::add(Register s1, int simm13a, Register d, RelocationHolder const& rspec ) { emit_data( op(arith_op) | rd(d) | op3(add_op3) | rs1(s1) | immed(true) | simm(simm13a, 13), rspec ); }
74341572Sslavash
75341572Sslavashinline void Assembler::bpr( RCondition c, bool a, Predict p, Register s1, address d, relocInfo::relocType rt ) { v9_only();  emit_data( op(branch_op) | annul(a) | cond(c) | op2(bpr_op2) | wdisp16(intptr_t(d), intptr_t(pc())) | predict(p) | rs1(s1), rt);  has_delay_slot(); }
76341572Sslavashinline void Assembler::bpr( RCondition c, bool a, Predict p, Register s1, Label& L) { bpr( c, a, p, s1, target(L)); }
77341572Sslavash
78341572Sslavashinline void Assembler::fb( Condition c, bool a, address d, relocInfo::relocType rt ) { v9_dep();  emit_data( op(branch_op) | annul(a) | cond(c) | op2(fb_op2) | wdisp(intptr_t(d), intptr_t(pc()), 22), rt);  has_delay_slot(); }
79341572Sslavashinline void Assembler::fb( Condition c, bool a, Label& L ) { fb(c, a, target(L)); }
80341572Sslavash
81341572Sslavashinline void Assembler::fbp( Condition c, bool a, CC cc, Predict p, address d, relocInfo::relocType rt ) { v9_only();  emit_data( op(branch_op) | annul(a) | cond(c) | op2(fbp_op2) | branchcc(cc) | predict(p) | wdisp(intptr_t(d), intptr_t(pc()), 19), rt);  has_delay_slot(); }
82341572Sslavashinline void Assembler::fbp( Condition c, bool a, CC cc, Predict p, Label& L ) { fbp(c, a, cc, p, target(L)); }
83341572Sslavash
84341572Sslavashinline void Assembler::cb( Condition c, bool a, address d, relocInfo::relocType rt ) { v8_only();  emit_data( op(branch_op) | annul(a) | cond(c) | op2(cb_op2) | wdisp(intptr_t(d), intptr_t(pc()), 22), rt);  has_delay_slot(); }
85341572Sslavashinline void Assembler::cb( Condition c, bool a, Label& L ) { cb(c, a, target(L)); }
86341572Sslavash
87341572Sslavashinline void Assembler::br( Condition c, bool a, address d, relocInfo::relocType rt ) { v9_dep();   emit_data( op(branch_op) | annul(a) | cond(c) | op2(br_op2) | wdisp(intptr_t(d), intptr_t(pc()), 22), rt);  has_delay_slot(); }
88341572Sslavashinline void Assembler::br( Condition c, bool a, Label& L ) { br(c, a, target(L)); }
89341572Sslavash
90341572Sslavashinline void Assembler::bp( Condition c, bool a, CC cc, Predict p, address d, relocInfo::relocType rt ) { v9_only();  emit_data( op(branch_op) | annul(a) | cond(c) | op2(bp_op2) | branchcc(cc) | predict(p) | wdisp(intptr_t(d), intptr_t(pc()), 19), rt);  has_delay_slot(); }
91341572Sslavashinline void Assembler::bp( Condition c, bool a, CC cc, Predict p, Label& L ) { bp(c, a, cc, p, target(L)); }
92341572Sslavash
93341572Sslavashinline void Assembler::call( address d,  relocInfo::relocType rt ) { emit_data( op(call_op) | wdisp(intptr_t(d), intptr_t(pc()), 30), rt);  has_delay_slot(); assert(rt != relocInfo::virtual_call_type, "must use virtual_call_Relocation::spec"); }
94341572Sslavashinline void Assembler::call( Label& L,   relocInfo::relocType rt ) { call( target(L), rt); }
95341572Sslavash
96341572Sslavashinline void Assembler::flush( Register s1, Register s2) { emit_long( op(arith_op) | op3(flush_op3) | rs1(s1) | rs2(s2)); }
97341572Sslavashinline void Assembler::flush( Register s1, int simm13a) { emit_data( op(arith_op) | op3(flush_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
98341572Sslavash
99341572Sslavashinline void Assembler::jmpl( Register s1, Register s2, Register d                          ) { emit_long( op(arith_op) | rd(d) | op3(jmpl_op3) | rs1(s1) | rs2(s2));  has_delay_slot(); }
100341572Sslavashinline void Assembler::jmpl( Register s1, int simm13a, Register d, RelocationHolder const& rspec ) { emit_data( op(arith_op) | rd(d) | op3(jmpl_op3) | rs1(s1) | immed(true) | simm(simm13a, 13), rspec);  has_delay_slot(); }
101341572Sslavash
102341572Sslavashinline void Assembler::ldf(FloatRegisterImpl::Width w, Register s1, RegisterOrConstant s2, FloatRegister d) {
103341572Sslavash  if (s2.is_register()) ldf(w, s1, s2.as_register(), d);
104341572Sslavash  else                  ldf(w, s1, s2.as_constant(), d);
105341572Sslavash}
106341572Sslavash
107341572Sslavashinline void Assembler::ldf(FloatRegisterImpl::Width w, Register s1, Register s2, FloatRegister d) { emit_long( op(ldst_op) | fd(d, w) | alt_op3(ldf_op3, w) | rs1(s1) | rs2(s2) ); }
108341572Sslavashinline void Assembler::ldf(FloatRegisterImpl::Width w, Register s1, int simm13a, FloatRegister d, RelocationHolder const& rspec) { emit_data( op(ldst_op) | fd(d, w) | alt_op3(ldf_op3, w) | rs1(s1) | immed(true) | simm(simm13a, 13), rspec); }
109341572Sslavash
110341572Sslavashinline void Assembler::ldf(FloatRegisterImpl::Width w, const Address& a, FloatRegister d, int offset) { relocate(a.rspec(offset)); ldf( w, a.base(), a.disp() + offset, d); }
111341572Sslavash
112341572Sslavashinline void Assembler::ldfsr(  Register s1, Register s2) { v9_dep();   emit_long( op(ldst_op) |             op3(ldfsr_op3) | rs1(s1) | rs2(s2) ); }
113341572Sslavashinline void Assembler::ldfsr(  Register s1, int simm13a) { v9_dep();   emit_data( op(ldst_op) |             op3(ldfsr_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
114341572Sslavashinline void Assembler::ldxfsr( Register s1, Register s2) { v9_only();  emit_long( op(ldst_op) | rd(G1)    | op3(ldfsr_op3) | rs1(s1) | rs2(s2) ); }
115341572Sslavashinline void Assembler::ldxfsr( Register s1, int simm13a) { v9_only();  emit_data( op(ldst_op) | rd(G1)    | op3(ldfsr_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
116341572Sslavash
117341572Sslavashinline void Assembler::ldc(   Register s1, Register s2, int crd) { v8_only();  emit_long( op(ldst_op) | fcn(crd) | op3(ldc_op3  ) | rs1(s1) | rs2(s2) ); }
118341572Sslavashinline void Assembler::ldc(   Register s1, int simm13a, int crd) { v8_only();  emit_data( op(ldst_op) | fcn(crd) | op3(ldc_op3  ) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
119341572Sslavashinline void Assembler::lddc(  Register s1, Register s2, int crd) { v8_only();  emit_long( op(ldst_op) | fcn(crd) | op3(lddc_op3 ) | rs1(s1) | rs2(s2) ); }
120341572Sslavashinline void Assembler::lddc(  Register s1, int simm13a, int crd) { v8_only();  emit_data( op(ldst_op) | fcn(crd) | op3(lddc_op3 ) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
121341572Sslavashinline void Assembler::ldcsr( Register s1, Register s2, int crd) { v8_only();  emit_long( op(ldst_op) | fcn(crd) | op3(ldcsr_op3) | rs1(s1) | rs2(s2) ); }
122341572Sslavashinline void Assembler::ldcsr( Register s1, int simm13a, int crd) { v8_only();  emit_data( op(ldst_op) | fcn(crd) | op3(ldcsr_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
123341572Sslavash
124341572Sslavashinline void Assembler::ldsb(  Register s1, Register s2, Register d) { emit_long( op(ldst_op) | rd(d) | op3(ldsb_op3) | rs1(s1) | rs2(s2) ); }
125341572Sslavashinline void Assembler::ldsb(  Register s1, int simm13a, Register d) { emit_data( op(ldst_op) | rd(d) | op3(ldsb_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
126341572Sslavash
127341572Sslavashinline void Assembler::ldsh(  Register s1, Register s2, Register d) { emit_long( op(ldst_op) | rd(d) | op3(ldsh_op3) | rs1(s1) | rs2(s2) ); }
128341572Sslavashinline void Assembler::ldsh(  Register s1, int simm13a, Register d) { emit_data( op(ldst_op) | rd(d) | op3(ldsh_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
129341572Sslavashinline void Assembler::ldsw(  Register s1, Register s2, Register d) { emit_long( op(ldst_op) | rd(d) | op3(ldsw_op3) | rs1(s1) | rs2(s2) ); }
130341572Sslavashinline void Assembler::ldsw(  Register s1, int simm13a, Register d) { emit_data( op(ldst_op) | rd(d) | op3(ldsw_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
131341572Sslavashinline void Assembler::ldub(  Register s1, Register s2, Register d) { emit_long( op(ldst_op) | rd(d) | op3(ldub_op3) | rs1(s1) | rs2(s2) ); }
132341572Sslavashinline void Assembler::ldub(  Register s1, int simm13a, Register d) { emit_data( op(ldst_op) | rd(d) | op3(ldub_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
133341572Sslavashinline void Assembler::lduh(  Register s1, Register s2, Register d) { emit_long( op(ldst_op) | rd(d) | op3(lduh_op3) | rs1(s1) | rs2(s2) ); }
134341572Sslavashinline void Assembler::lduh(  Register s1, int simm13a, Register d) { emit_data( op(ldst_op) | rd(d) | op3(lduh_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
135341572Sslavashinline void Assembler::lduw(  Register s1, Register s2, Register d) { emit_long( op(ldst_op) | rd(d) | op3(lduw_op3) | rs1(s1) | rs2(s2) ); }
136341572Sslavashinline void Assembler::lduw(  Register s1, int simm13a, Register d) { emit_data( op(ldst_op) | rd(d) | op3(lduw_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
137341572Sslavash
138341572Sslavashinline void Assembler::ldx(   Register s1, Register s2, Register d) { v9_only();  emit_long( op(ldst_op) | rd(d) | op3(ldx_op3) | rs1(s1) | rs2(s2) ); }
139341572Sslavashinline void Assembler::ldx(   Register s1, int simm13a, Register d) { v9_only();  emit_data( op(ldst_op) | rd(d) | op3(ldx_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
140341572Sslavashinline void Assembler::ldd(   Register s1, Register s2, Register d) { v9_dep(); assert(d->is_even(), "not even"); emit_long( op(ldst_op) | rd(d) | op3(ldd_op3) | rs1(s1) | rs2(s2) ); }
141341572Sslavashinline void Assembler::ldd(   Register s1, int simm13a, Register d) { v9_dep(); assert(d->is_even(), "not even"); emit_data( op(ldst_op) | rd(d) | op3(ldd_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
142341572Sslavash
143341572Sslavash#ifdef _LP64
144341572Sslavash// Make all 32 bit loads signed so 64 bit registers maintain proper sign
145341572Sslavashinline void Assembler::ld(  Register s1, Register s2, Register d)      { ldsw( s1, s2, d); }
146341572Sslavashinline void Assembler::ld(  Register s1, int simm13a, Register d)      { ldsw( s1, simm13a, d); }
147341572Sslavash#else
148341572Sslavashinline void Assembler::ld(  Register s1, Register s2, Register d)      { lduw( s1, s2, d); }
149341572Sslavashinline void Assembler::ld(  Register s1, int simm13a, Register d)      { lduw( s1, simm13a, d); }
150341572Sslavash#endif
151341572Sslavash
152341572Sslavash#ifdef ASSERT
153341572Sslavash  // ByteSize is only a class when ASSERT is defined, otherwise it's an int.
154341572Sslavash# ifdef _LP64
155341572Sslavashinline void Assembler::ld(  Register s1, ByteSize simm13a, Register d) { ldsw( s1, in_bytes(simm13a), d); }
156341572Sslavash# else
157341572Sslavashinline void Assembler::ld(  Register s1, ByteSize simm13a, Register d) { lduw( s1, in_bytes(simm13a), d); }
158341572Sslavash# endif
159341572Sslavash#endif
160341572Sslavash
161341572Sslavashinline void Assembler::ld(  const Address& a, Register d, int offset) {
162341572Sslavash  if (a.has_index()) { assert(offset == 0, ""); ld(  a.base(), a.index(),         d); }
163341572Sslavash  else               {                          ld(  a.base(), a.disp() + offset, d); }
164341572Sslavash}
165341572Sslavashinline void Assembler::ldsb(const Address& a, Register d, int offset) {
166341572Sslavash  if (a.has_index()) { assert(offset == 0, ""); ldsb(a.base(), a.index(),         d); }
167341572Sslavash  else               {                          ldsb(a.base(), a.disp() + offset, d); }
168341572Sslavash}
169341572Sslavashinline void Assembler::ldsh(const Address& a, Register d, int offset) {
170341572Sslavash  if (a.has_index()) { assert(offset == 0, ""); ldsh(a.base(), a.index(),         d); }
171341572Sslavash  else               {                          ldsh(a.base(), a.disp() + offset, d); }
172341572Sslavash}
173341572Sslavashinline void Assembler::ldsw(const Address& a, Register d, int offset) {
174341572Sslavash  if (a.has_index()) { assert(offset == 0, ""); ldsw(a.base(), a.index(),         d); }
175341572Sslavash  else               {                          ldsw(a.base(), a.disp() + offset, d); }
176341572Sslavash}
177341572Sslavashinline void Assembler::ldub(const Address& a, Register d, int offset) {
178341572Sslavash  if (a.has_index()) { assert(offset == 0, ""); ldub(a.base(), a.index(),         d); }
179341572Sslavash  else               {                          ldub(a.base(), a.disp() + offset, d); }
180341572Sslavash}
181341572Sslavashinline void Assembler::lduh(const Address& a, Register d, int offset) {
182341572Sslavash  if (a.has_index()) { assert(offset == 0, ""); lduh(a.base(), a.index(),         d); }
183341572Sslavash  else               {                          lduh(a.base(), a.disp() + offset, d); }
184341572Sslavash}
185341572Sslavashinline void Assembler::lduw(const Address& a, Register d, int offset) {
186341572Sslavash  if (a.has_index()) { assert(offset == 0, ""); lduw(a.base(), a.index(),         d); }
187341572Sslavash  else               {                          lduw(a.base(), a.disp() + offset, d); }
188341572Sslavash}
189341572Sslavashinline void Assembler::ldd( const Address& a, Register d, int offset) {
190341572Sslavash  if (a.has_index()) { assert(offset == 0, ""); ldd( a.base(), a.index(),         d); }
191341572Sslavash  else               {                          ldd( a.base(), a.disp() + offset, d); }
192341572Sslavash}
193341572Sslavashinline void Assembler::ldx( const Address& a, Register d, int offset) {
194341572Sslavash  if (a.has_index()) { assert(offset == 0, ""); ldx( a.base(), a.index(),         d); }
195341572Sslavash  else               {                          ldx( a.base(), a.disp() + offset, d); }
196341572Sslavash}
197341572Sslavash
198341572Sslavashinline void Assembler::ldub(Register s1, RegisterOrConstant s2, Register d) { ldub(Address(s1, s2), d); }
199341572Sslavashinline void Assembler::ldsb(Register s1, RegisterOrConstant s2, Register d) { ldsb(Address(s1, s2), d); }
200341572Sslavashinline void Assembler::lduh(Register s1, RegisterOrConstant s2, Register d) { lduh(Address(s1, s2), d); }
201341572Sslavashinline void Assembler::ldsh(Register s1, RegisterOrConstant s2, Register d) { ldsh(Address(s1, s2), d); }
202341572Sslavashinline void Assembler::lduw(Register s1, RegisterOrConstant s2, Register d) { lduw(Address(s1, s2), d); }
203341572Sslavashinline void Assembler::ldsw(Register s1, RegisterOrConstant s2, Register d) { ldsw(Address(s1, s2), d); }
204341572Sslavashinline void Assembler::ldx( Register s1, RegisterOrConstant s2, Register d) { ldx( Address(s1, s2), d); }
205341572Sslavashinline void Assembler::ld(  Register s1, RegisterOrConstant s2, Register d) { ld(  Address(s1, s2), d); }
206341572Sslavashinline void Assembler::ldd( Register s1, RegisterOrConstant s2, Register d) { ldd( Address(s1, s2), d); }
207341572Sslavash
208341572Sslavash// form effective addresses this way:
209341572Sslavashinline void Assembler::add(Register s1, RegisterOrConstant s2, Register d, int offset) {
210341572Sslavash  if (s2.is_register())  add(s1, s2.as_register(),          d);
211341572Sslavash  else                 { add(s1, s2.as_constant() + offset, d); offset = 0; }
212341572Sslavash  if (offset != 0)       add(d,  offset,                    d);
213341572Sslavash}
214341572Sslavash
215341572Sslavashinline void Assembler::andn(Register s1, RegisterOrConstant s2, Register d) {
216341572Sslavash  if (s2.is_register())  andn(s1, s2.as_register(), d);
217341572Sslavash  else                   andn(s1, s2.as_constant(), d);
218341572Sslavash}
219341572Sslavash
220341572Sslavashinline void Assembler::ldstub(  Register s1, Register s2, Register d) { emit_long( op(ldst_op) | rd(d) | op3(ldstub_op3) | rs1(s1) | rs2(s2) ); }
221341572Sslavashinline void Assembler::ldstub(  Register s1, int simm13a, Register d) { emit_data( op(ldst_op) | rd(d) | op3(ldstub_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
222341572Sslavash
223341572Sslavash
224341572Sslavashinline void Assembler::prefetch(Register s1, Register s2, PrefetchFcn f) { v9_only();  emit_long( op(ldst_op) | fcn(f) | op3(prefetch_op3) | rs1(s1) | rs2(s2) ); }
225341572Sslavashinline void Assembler::prefetch(Register s1, int simm13a, PrefetchFcn f) { v9_only();  emit_data( op(ldst_op) | fcn(f) | op3(prefetch_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
226341572Sslavash
227341572Sslavashinline void Assembler::prefetch(const Address& a, PrefetchFcn f, int offset) { v9_only(); relocate(a.rspec(offset)); prefetch(a.base(), a.disp() + offset, f); }
228341572Sslavash
229341572Sslavash
230341572Sslavashinline void Assembler::rett( Register s1, Register s2                         ) { emit_long( op(arith_op) | op3(rett_op3) | rs1(s1) | rs2(s2));  has_delay_slot(); }
231341572Sslavashinline void Assembler::rett( Register s1, int simm13a, relocInfo::relocType rt) { emit_data( op(arith_op) | op3(rett_op3) | rs1(s1) | immed(true) | simm(simm13a, 13), rt);  has_delay_slot(); }
232341572Sslavash
233341572Sslavashinline void Assembler::sethi( int imm22a, Register d, RelocationHolder const& rspec ) { emit_data( op(branch_op) | rd(d) | op2(sethi_op2) | hi22(imm22a), rspec); }
234341572Sslavash
235341572Sslavash  // pp 222
236341572Sslavash
237341572Sslavashinline void Assembler::stf(    FloatRegisterImpl::Width w, FloatRegister d, Register s1, RegisterOrConstant s2) {
238341572Sslavash  if (s2.is_register()) stf(w, d, s1, s2.as_register());
239341572Sslavash  else                  stf(w, d, s1, s2.as_constant());
240341572Sslavash}
241341572Sslavash
242341572Sslavashinline void Assembler::stf(    FloatRegisterImpl::Width w, FloatRegister d, Register s1, Register s2) { emit_long( op(ldst_op) | fd(d, w) | alt_op3(stf_op3, w) | rs1(s1) | rs2(s2) ); }
243341572Sslavashinline void Assembler::stf(    FloatRegisterImpl::Width w, FloatRegister d, Register s1, int simm13a) { emit_data( op(ldst_op) | fd(d, w) | alt_op3(stf_op3, w) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
244341572Sslavash
245341572Sslavashinline void Assembler::stf(    FloatRegisterImpl::Width w, FloatRegister d, const Address& a, int offset) { relocate(a.rspec(offset)); stf(w, d, a.base(), a.disp() + offset); }
246341572Sslavash
247341572Sslavashinline void Assembler::stfsr(  Register s1, Register s2) { v9_dep();   emit_long( op(ldst_op) |             op3(stfsr_op3) | rs1(s1) | rs2(s2) ); }
248341572Sslavashinline void Assembler::stfsr(  Register s1, int simm13a) { v9_dep();   emit_data( op(ldst_op) |             op3(stfsr_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
249341572Sslavashinline void Assembler::stxfsr( Register s1, Register s2) { v9_only();  emit_long( op(ldst_op) | rd(G1)    | op3(stfsr_op3) | rs1(s1) | rs2(s2) ); }
250341572Sslavashinline void Assembler::stxfsr( Register s1, int simm13a) { v9_only();  emit_data( op(ldst_op) | rd(G1)    | op3(stfsr_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
251341572Sslavash
252341572Sslavash  // p 226
253341572Sslavash
254341572Sslavashinline void Assembler::stb(  Register d, Register s1, Register s2) { emit_long( op(ldst_op) | rd(d) | op3(stb_op3) | rs1(s1) | rs2(s2) ); }
255341572Sslavashinline void Assembler::stb(  Register d, Register s1, int simm13a) { emit_data( op(ldst_op) | rd(d) | op3(stb_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
256341572Sslavashinline void Assembler::sth(  Register d, Register s1, Register s2) { emit_long( op(ldst_op) | rd(d) | op3(sth_op3) | rs1(s1) | rs2(s2) ); }
257341572Sslavashinline void Assembler::sth(  Register d, Register s1, int simm13a) { emit_data( op(ldst_op) | rd(d) | op3(sth_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
258341572Sslavashinline void Assembler::stw(  Register d, Register s1, Register s2) { emit_long( op(ldst_op) | rd(d) | op3(stw_op3) | rs1(s1) | rs2(s2) ); }
259341572Sslavashinline void Assembler::stw(  Register d, Register s1, int simm13a) { emit_data( op(ldst_op) | rd(d) | op3(stw_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
260341572Sslavash
261341572Sslavash
262341572Sslavashinline void Assembler::stx(  Register d, Register s1, Register s2) { v9_only();  emit_long( op(ldst_op) | rd(d) | op3(stx_op3) | rs1(s1) | rs2(s2) ); }
263341572Sslavashinline void Assembler::stx(  Register d, Register s1, int simm13a) { v9_only();  emit_data( op(ldst_op) | rd(d) | op3(stx_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
264341572Sslavashinline void Assembler::std(  Register d, Register s1, Register s2) { v9_dep(); assert(d->is_even(), "not even"); emit_long( op(ldst_op) | rd(d) | op3(std_op3) | rs1(s1) | rs2(s2) ); }
265341572Sslavashinline void Assembler::std(  Register d, Register s1, int simm13a) { v9_dep(); assert(d->is_even(), "not even"); emit_data( op(ldst_op) | rd(d) | op3(std_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
266341572Sslavash
267341572Sslavashinline void Assembler::st( Register d, Register s1, Register s2)      { stw(d, s1, s2); }
268341572Sslavashinline void Assembler::st( Register d, Register s1, int simm13a)      { stw(d, s1, simm13a); }
269341572Sslavash
270341572Sslavash#ifdef ASSERT
271341572Sslavash// ByteSize is only a class when ASSERT is defined, otherwise it's an int.
272341572Sslavashinline void Assembler::st( Register d, Register s1, ByteSize simm13a) { stw(d, s1, in_bytes(simm13a)); }
273341572Sslavash#endif
274341572Sslavash
275341572Sslavashinline void Assembler::stb(Register d, const Address& a, int offset) {
276341572Sslavash  if (a.has_index()) { assert(offset == 0, ""); stb(d, a.base(), a.index()        ); }
277341572Sslavash  else               {                          stb(d, a.base(), a.disp() + offset); }
278341572Sslavash}
279341572Sslavashinline void Assembler::sth(Register d, const Address& a, int offset) {
280341572Sslavash  if (a.has_index()) { assert(offset == 0, ""); sth(d, a.base(), a.index()        ); }
281341572Sslavash  else               {                          sth(d, a.base(), a.disp() + offset); }
282341572Sslavash}
283341572Sslavashinline void Assembler::stw(Register d, const Address& a, int offset) {
284341572Sslavash  if (a.has_index()) { assert(offset == 0, ""); stw(d, a.base(), a.index()        ); }
285341572Sslavash  else               {                          stw(d, a.base(), a.disp() + offset); }
286341572Sslavash}
287341572Sslavashinline void Assembler::st( Register d, const Address& a, int offset) {
288341572Sslavash  if (a.has_index()) { assert(offset == 0, ""); st( d, a.base(), a.index()        ); }
289341572Sslavash  else               {                          st( d, a.base(), a.disp() + offset); }
290341572Sslavash}
291341572Sslavashinline void Assembler::std(Register d, const Address& a, int offset) {
292341572Sslavash  if (a.has_index()) { assert(offset == 0, ""); std(d, a.base(), a.index()        ); }
293341572Sslavash  else               {                          std(d, a.base(), a.disp() + offset); }
294341572Sslavash}
295341572Sslavashinline void Assembler::stx(Register d, const Address& a, int offset) {
296341572Sslavash  if (a.has_index()) { assert(offset == 0, ""); stx(d, a.base(), a.index()        ); }
297341572Sslavash  else               {                          stx(d, a.base(), a.disp() + offset); }
298341572Sslavash}
299341572Sslavash
300341572Sslavashinline void Assembler::stb(Register d, Register s1, RegisterOrConstant s2) { stb(d, Address(s1, s2)); }
301341572Sslavashinline void Assembler::sth(Register d, Register s1, RegisterOrConstant s2) { sth(d, Address(s1, s2)); }
302341572Sslavashinline void Assembler::stw(Register d, Register s1, RegisterOrConstant s2) { stw(d, Address(s1, s2)); }
303341572Sslavashinline void Assembler::stx(Register d, Register s1, RegisterOrConstant s2) { stx(d, Address(s1, s2)); }
304341572Sslavashinline void Assembler::std(Register d, Register s1, RegisterOrConstant s2) { std(d, Address(s1, s2)); }
305341572Sslavashinline void Assembler::st( Register d, Register s1, RegisterOrConstant s2) { st( d, Address(s1, s2)); }
306341572Sslavash
307341572Sslavash// v8 p 99
308341572Sslavash
309341572Sslavashinline void Assembler::stc(    int crd, Register s1, Register s2) { v8_only();  emit_long( op(ldst_op) | fcn(crd) | op3(stc_op3 ) | rs1(s1) | rs2(s2) ); }
310341572Sslavashinline void Assembler::stc(    int crd, Register s1, int simm13a) { v8_only();  emit_data( op(ldst_op) | fcn(crd) | op3(stc_op3 ) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
311341572Sslavashinline void Assembler::stdc(   int crd, Register s1, Register s2) { v8_only();  emit_long( op(ldst_op) | fcn(crd) | op3(stdc_op3) | rs1(s1) | rs2(s2) ); }
312341572Sslavashinline void Assembler::stdc(   int crd, Register s1, int simm13a) { v8_only();  emit_data( op(ldst_op) | fcn(crd) | op3(stdc_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
313341572Sslavashinline void Assembler::stcsr(  int crd, Register s1, Register s2) { v8_only();  emit_long( op(ldst_op) | fcn(crd) | op3(stcsr_op3) | rs1(s1) | rs2(s2) ); }
314341572Sslavashinline void Assembler::stcsr(  int crd, Register s1, int simm13a) { v8_only();  emit_data( op(ldst_op) | fcn(crd) | op3(stcsr_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
315341572Sslavashinline void Assembler::stdcq(  int crd, Register s1, Register s2) { v8_only();  emit_long( op(ldst_op) | fcn(crd) | op3(stdcq_op3) | rs1(s1) | rs2(s2) ); }
316341572Sslavashinline void Assembler::stdcq(  int crd, Register s1, int simm13a) { v8_only();  emit_data( op(ldst_op) | fcn(crd) | op3(stdcq_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
317341572Sslavash
318341572Sslavash
319341572Sslavash// pp 231
320341572Sslavash
321341572Sslavashinline void Assembler::swap(    Register s1, Register s2, Register d) { v9_dep();  emit_long( op(ldst_op) | rd(d) | op3(swap_op3) | rs1(s1) | rs2(s2) ); }
322341572Sslavashinline void Assembler::swap(    Register s1, int simm13a, Register d) { v9_dep();  emit_data( op(ldst_op) | rd(d) | op3(swap_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
323341572Sslavash
324341572Sslavashinline void Assembler::swap(    Address& a, Register d, int offset ) { relocate(a.rspec(offset)); swap(  a.base(), a.disp() + offset, d ); }
325341572Sslavash
326341572Sslavash
327341572Sslavash// Use the right loads/stores for the platform
328341572Sslavashinline void MacroAssembler::ld_ptr( Register s1, Register s2, Register d ) {
329341572Sslavash#ifdef _LP64
330341572Sslavash  Assembler::ldx(s1, s2, d);
331341572Sslavash#else
332341572Sslavash  Assembler::ld( s1, s2, d);
333341572Sslavash#endif
334341572Sslavash}
335341572Sslavash
336341572Sslavashinline void MacroAssembler::ld_ptr( Register s1, int simm13a, Register d ) {
337341572Sslavash#ifdef _LP64
338341572Sslavash  Assembler::ldx(s1, simm13a, d);
339341572Sslavash#else
340341572Sslavash  Assembler::ld( s1, simm13a, d);
341341572Sslavash#endif
342341572Sslavash}
343341572Sslavash
344341572Sslavash#ifdef ASSERT
345341572Sslavash// ByteSize is only a class when ASSERT is defined, otherwise it's an int.
346341572Sslavashinline void MacroAssembler::ld_ptr( Register s1, ByteSize simm13a, Register d ) {
347341572Sslavash  ld_ptr(s1, in_bytes(simm13a), d);
348341572Sslavash}
349341572Sslavash#endif
350341572Sslavash
351341572Sslavashinline void MacroAssembler::ld_ptr( Register s1, RegisterOrConstant s2, Register d ) {
352341572Sslavash#ifdef _LP64
353341572Sslavash  Assembler::ldx(s1, s2, d);
354341572Sslavash#else
355341572Sslavash  Assembler::ld( s1, s2, d);
356341572Sslavash#endif
357341572Sslavash}
358341572Sslavash
359341964Shselaskyinline void MacroAssembler::ld_ptr(const Address& a, Register d, int offset) {
360341964Shselasky#ifdef _LP64
361341964Shselasky  Assembler::ldx(a, d, offset);
362341964Shselasky#else
363341964Shselasky  Assembler::ld( a, d, offset);
364341964Shselasky#endif
365341964Shselasky}
366341964Shselasky
367341964Shselaskyinline void MacroAssembler::st_ptr( Register d, Register s1, Register s2 ) {
368341964Shselasky#ifdef _LP64
369341966Shselasky  Assembler::stx(d, s1, s2);
370341966Shselasky#else
371341966Shselasky  Assembler::st( d, s1, s2);
372341966Shselasky#endif
373341966Shselasky}
374341966Shselasky
375341966Shselaskyinline void MacroAssembler::st_ptr( Register d, Register s1, int simm13a ) {
376341966Shselasky#ifdef _LP64
377341966Shselasky  Assembler::stx(d, s1, simm13a);
378341966Shselasky#else
379341572Sslavash  Assembler::st( d, s1, simm13a);
380341572Sslavash#endif
381341572Sslavash}
382341572Sslavash
383341572Sslavash#ifdef ASSERT
384341572Sslavash// ByteSize is only a class when ASSERT is defined, otherwise it's an int.
385341572Sslavashinline void MacroAssembler::st_ptr( Register d, Register s1, ByteSize simm13a ) {
386341572Sslavash  st_ptr(d, s1, in_bytes(simm13a));
387341572Sslavash}
388341572Sslavash#endif
389
390inline void MacroAssembler::st_ptr( Register d, Register s1, RegisterOrConstant s2 ) {
391#ifdef _LP64
392  Assembler::stx(d, s1, s2);
393#else
394  Assembler::st( d, s1, s2);
395#endif
396}
397
398inline void MacroAssembler::st_ptr(Register d, const Address& a, int offset) {
399#ifdef _LP64
400  Assembler::stx(d, a, offset);
401#else
402  Assembler::st( d, a, offset);
403#endif
404}
405
406// Use the right loads/stores for the platform
407inline void MacroAssembler::ld_long( Register s1, Register s2, Register d ) {
408#ifdef _LP64
409  Assembler::ldx(s1, s2, d);
410#else
411  Assembler::ldd(s1, s2, d);
412#endif
413}
414
415inline void MacroAssembler::ld_long( Register s1, int simm13a, Register d ) {
416#ifdef _LP64
417  Assembler::ldx(s1, simm13a, d);
418#else
419  Assembler::ldd(s1, simm13a, d);
420#endif
421}
422
423inline void MacroAssembler::ld_long( Register s1, RegisterOrConstant s2, Register d ) {
424#ifdef _LP64
425  Assembler::ldx(s1, s2, d);
426#else
427  Assembler::ldd(s1, s2, d);
428#endif
429}
430
431inline void MacroAssembler::ld_long(const Address& a, Register d, int offset) {
432#ifdef _LP64
433  Assembler::ldx(a, d, offset);
434#else
435  Assembler::ldd(a, d, offset);
436#endif
437}
438
439inline void MacroAssembler::st_long( Register d, Register s1, Register s2 ) {
440#ifdef _LP64
441  Assembler::stx(d, s1, s2);
442#else
443  Assembler::std(d, s1, s2);
444#endif
445}
446
447inline void MacroAssembler::st_long( Register d, Register s1, int simm13a ) {
448#ifdef _LP64
449  Assembler::stx(d, s1, simm13a);
450#else
451  Assembler::std(d, s1, simm13a);
452#endif
453}
454
455inline void MacroAssembler::st_long( Register d, Register s1, RegisterOrConstant s2 ) {
456#ifdef _LP64
457  Assembler::stx(d, s1, s2);
458#else
459  Assembler::std(d, s1, s2);
460#endif
461}
462
463inline void MacroAssembler::st_long( Register d, const Address& a, int offset ) {
464#ifdef _LP64
465  Assembler::stx(d, a, offset);
466#else
467  Assembler::std(d, a, offset);
468#endif
469}
470
471// Functions for isolating 64 bit shifts for LP64
472
473inline void MacroAssembler::sll_ptr( Register s1, Register s2, Register d ) {
474#ifdef _LP64
475  Assembler::sllx(s1, s2, d);
476#else
477  Assembler::sll( s1, s2, d);
478#endif
479}
480
481inline void MacroAssembler::sll_ptr( Register s1, int imm6a,   Register d ) {
482#ifdef _LP64
483  Assembler::sllx(s1, imm6a, d);
484#else
485  Assembler::sll( s1, imm6a, d);
486#endif
487}
488
489inline void MacroAssembler::srl_ptr( Register s1, Register s2, Register d ) {
490#ifdef _LP64
491  Assembler::srlx(s1, s2, d);
492#else
493  Assembler::srl( s1, s2, d);
494#endif
495}
496
497inline void MacroAssembler::srl_ptr( Register s1, int imm6a,   Register d ) {
498#ifdef _LP64
499  Assembler::srlx(s1, imm6a, d);
500#else
501  Assembler::srl( s1, imm6a, d);
502#endif
503}
504
505inline void MacroAssembler::sll_ptr( Register s1, RegisterOrConstant s2, Register d ) {
506  if (s2.is_register())  sll_ptr(s1, s2.as_register(), d);
507  else                   sll_ptr(s1, s2.as_constant(), d);
508}
509
510// Use the right branch for the platform
511
512inline void MacroAssembler::br( Condition c, bool a, Predict p, address d, relocInfo::relocType rt ) {
513  if (VM_Version::v9_instructions_work())
514    Assembler::bp(c, a, icc, p, d, rt);
515  else
516    Assembler::br(c, a, d, rt);
517}
518
519inline void MacroAssembler::br( Condition c, bool a, Predict p, Label& L ) {
520  br(c, a, p, target(L));
521}
522
523
524// Branch that tests either xcc or icc depending on the
525// architecture compiled (LP64 or not)
526inline void MacroAssembler::brx( Condition c, bool a, Predict p, address d, relocInfo::relocType rt ) {
527#ifdef _LP64
528    Assembler::bp(c, a, xcc, p, d, rt);
529#else
530    MacroAssembler::br(c, a, p, d, rt);
531#endif
532}
533
534inline void MacroAssembler::brx( Condition c, bool a, Predict p, Label& L ) {
535  brx(c, a, p, target(L));
536}
537
538inline void MacroAssembler::ba( bool a, Label& L ) {
539  br(always, a, pt, L);
540}
541
542// Warning: V9 only functions
543inline void MacroAssembler::bp( Condition c, bool a, CC cc, Predict p, address d, relocInfo::relocType rt ) {
544  Assembler::bp(c, a, cc, p, d, rt);
545}
546
547inline void MacroAssembler::bp( Condition c, bool a, CC cc, Predict p, Label& L ) {
548  Assembler::bp(c, a, cc, p, L);
549}
550
551inline void MacroAssembler::fb( Condition c, bool a, Predict p, address d, relocInfo::relocType rt ) {
552  if (VM_Version::v9_instructions_work())
553    fbp(c, a, fcc0, p, d, rt);
554  else
555    Assembler::fb(c, a, d, rt);
556}
557
558inline void MacroAssembler::fb( Condition c, bool a, Predict p, Label& L ) {
559  fb(c, a, p, target(L));
560}
561
562inline void MacroAssembler::fbp( Condition c, bool a, CC cc, Predict p, address d, relocInfo::relocType rt ) {
563  Assembler::fbp(c, a, cc, p, d, rt);
564}
565
566inline void MacroAssembler::fbp( Condition c, bool a, CC cc, Predict p, Label& L ) {
567  Assembler::fbp(c, a, cc, p, L);
568}
569
570inline void MacroAssembler::jmp( Register s1, Register s2 ) { jmpl( s1, s2, G0 ); }
571inline void MacroAssembler::jmp( Register s1, int simm13a, RelocationHolder const& rspec ) { jmpl( s1, simm13a, G0, rspec); }
572
573// Call with a check to see if we need to deal with the added
574// expense of relocation and if we overflow the displacement
575// of the quick call instruction./
576// Check to see if we have to deal with relocations
577inline void MacroAssembler::call( address d, relocInfo::relocType rt ) {
578#ifdef _LP64
579  intptr_t disp;
580  // NULL is ok because it will be relocated later.
581  // Must change NULL to a reachable address in order to
582  // pass asserts here and in wdisp.
583  if ( d == NULL )
584    d = pc();
585
586  // Is this address within range of the call instruction?
587  // If not, use the expensive instruction sequence
588  disp = (intptr_t)d - (intptr_t)pc();
589  if ( disp != (intptr_t)(int32_t)disp ) {
590    relocate(rt);
591    AddressLiteral dest(d);
592    jumpl_to(dest, O7, O7);
593  }
594  else {
595    Assembler::call( d, rt );
596  }
597#else
598  Assembler::call( d, rt );
599#endif
600}
601
602inline void MacroAssembler::call( Label& L,   relocInfo::relocType rt ) {
603  MacroAssembler::call( target(L), rt);
604}
605
606
607
608inline void MacroAssembler::callr( Register s1, Register s2 ) { jmpl( s1, s2, O7 ); }
609inline void MacroAssembler::callr( Register s1, int simm13a, RelocationHolder const& rspec ) { jmpl( s1, simm13a, O7, rspec); }
610
611// prefetch instruction
612inline void MacroAssembler::iprefetch( address d, relocInfo::relocType rt ) {
613  if (VM_Version::v9_instructions_work())
614    Assembler::bp( never, true, xcc, pt, d, rt );
615}
616inline void MacroAssembler::iprefetch( Label& L) { iprefetch( target(L) ); }
617
618
619// clobbers o7 on V8!!
620// returns delta from gotten pc to addr after
621inline int MacroAssembler::get_pc( Register d ) {
622  int x = offset();
623  if (VM_Version::v9_instructions_work())
624    rdpc(d);
625  else {
626    Label lbl;
627    Assembler::call(lbl, relocInfo::none);  // No relocation as this is call to pc+0x8
628    if (d == O7)  delayed()->nop();
629    else          delayed()->mov(O7, d);
630    bind(lbl);
631  }
632  return offset() - x;
633}
634
635
636// Note:  All MacroAssembler::set_foo functions are defined out-of-line.
637
638
639// Loads the current PC of the following instruction as an immediate value in
640// 2 instructions.  All PCs in the CodeCache are within 2 Gig of each other.
641inline intptr_t MacroAssembler::load_pc_address( Register reg, int bytes_to_skip ) {
642  intptr_t thepc = (intptr_t)pc() + 2*BytesPerInstWord + bytes_to_skip;
643#ifdef _LP64
644  Unimplemented();
645#else
646  Assembler::sethi(  thepc & ~0x3ff, reg, internal_word_Relocation::spec((address)thepc));
647  Assembler::add(reg,thepc &  0x3ff, reg, internal_word_Relocation::spec((address)thepc));
648#endif
649  return thepc;
650}
651
652
653inline void MacroAssembler::load_contents(AddressLiteral& addrlit, Register d, int offset) {
654  assert_not_delayed();
655  sethi(addrlit, d);
656  ld(d, addrlit.low10() + offset, d);
657}
658
659
660inline void MacroAssembler::load_ptr_contents(AddressLiteral& addrlit, Register d, int offset) {
661  assert_not_delayed();
662  sethi(addrlit, d);
663  ld_ptr(d, addrlit.low10() + offset, d);
664}
665
666
667inline void MacroAssembler::store_contents(Register s, AddressLiteral& addrlit, Register temp, int offset) {
668  assert_not_delayed();
669  sethi(addrlit, temp);
670  st(s, temp, addrlit.low10() + offset);
671}
672
673
674inline void MacroAssembler::store_ptr_contents(Register s, AddressLiteral& addrlit, Register temp, int offset) {
675  assert_not_delayed();
676  sethi(addrlit, temp);
677  st_ptr(s, temp, addrlit.low10() + offset);
678}
679
680
681// This code sequence is relocatable to any address, even on LP64.
682inline void MacroAssembler::jumpl_to(AddressLiteral& addrlit, Register temp, Register d, int offset) {
683  assert_not_delayed();
684  // Force fixed length sethi because NativeJump and NativeFarCall don't handle
685  // variable length instruction streams.
686  patchable_sethi(addrlit, temp);
687  jmpl(temp, addrlit.low10() + offset, d);
688}
689
690
691inline void MacroAssembler::jump_to(AddressLiteral& addrlit, Register temp, int offset) {
692  jumpl_to(addrlit, temp, G0, offset);
693}
694
695
696inline void MacroAssembler::jump_indirect_to(Address& a, Register temp,
697                                             int ld_offset, int jmp_offset) {
698  assert_not_delayed();
699  //sethi(al);                   // sethi is caller responsibility for this one
700  ld_ptr(a, temp, ld_offset);
701  jmp(temp, jmp_offset);
702}
703
704
705inline void MacroAssembler::set_oop(jobject obj, Register d) {
706  set_oop(allocate_oop_address(obj), d);
707}
708
709
710inline void MacroAssembler::set_oop_constant(jobject obj, Register d) {
711  set_oop(constant_oop_address(obj), d);
712}
713
714
715inline void MacroAssembler::set_oop(const AddressLiteral& obj_addr, Register d) {
716  assert(obj_addr.rspec().type() == relocInfo::oop_type, "must be an oop reloc");
717  set(obj_addr, d);
718}
719
720
721inline void MacroAssembler::load_argument( Argument& a, Register  d ) {
722  if (a.is_register())
723    mov(a.as_register(), d);
724  else
725    ld (a.as_address(),  d);
726}
727
728inline void MacroAssembler::store_argument( Register s, Argument& a ) {
729  if (a.is_register())
730    mov(s, a.as_register());
731  else
732    st_ptr (s, a.as_address());         // ABI says everything is right justified.
733}
734
735inline void MacroAssembler::store_ptr_argument( Register s, Argument& a ) {
736  if (a.is_register())
737    mov(s, a.as_register());
738  else
739    st_ptr (s, a.as_address());
740}
741
742
743#ifdef _LP64
744inline void MacroAssembler::store_float_argument( FloatRegister s, Argument& a ) {
745  if (a.is_float_register())
746// V9 ABI has F1, F3, F5 are used to pass instead of O0, O1, O2
747    fmov(FloatRegisterImpl::S, s, a.as_float_register() );
748  else
749    // Floats are stored in the high half of the stack entry
750    // The low half is undefined per the ABI.
751    stf(FloatRegisterImpl::S, s, a.as_address(), sizeof(jfloat));
752}
753
754inline void MacroAssembler::store_double_argument( FloatRegister s, Argument& a ) {
755  if (a.is_float_register())
756// V9 ABI has D0, D2, D4 are used to pass instead of O0, O1, O2
757    fmov(FloatRegisterImpl::D, s, a.as_double_register() );
758  else
759    stf(FloatRegisterImpl::D, s, a.as_address());
760}
761
762inline void MacroAssembler::store_long_argument( Register s, Argument& a ) {
763  if (a.is_register())
764    mov(s, a.as_register());
765  else
766    stx(s, a.as_address());
767}
768#endif
769
770inline void MacroAssembler::clrb( Register s1, Register s2) {  stb( G0, s1, s2 ); }
771inline void MacroAssembler::clrh( Register s1, Register s2) {  sth( G0, s1, s2 ); }
772inline void MacroAssembler::clr(  Register s1, Register s2) {  stw( G0, s1, s2 ); }
773inline void MacroAssembler::clrx( Register s1, Register s2) {  stx( G0, s1, s2 ); }
774
775inline void MacroAssembler::clrb( Register s1, int simm13a) { stb( G0, s1, simm13a); }
776inline void MacroAssembler::clrh( Register s1, int simm13a) { sth( G0, s1, simm13a); }
777inline void MacroAssembler::clr(  Register s1, int simm13a) { stw( G0, s1, simm13a); }
778inline void MacroAssembler::clrx( Register s1, int simm13a) { stx( G0, s1, simm13a); }
779
780// returns if membar generates anything, obviously this code should mirror
781// membar below.
782inline bool MacroAssembler::membar_has_effect( Membar_mask_bits const7a ) {
783  if( !os::is_MP() ) return false;  // Not needed on single CPU
784  if( VM_Version::v9_instructions_work() ) {
785    const Membar_mask_bits effective_mask =
786        Membar_mask_bits(const7a & ~(LoadLoad | LoadStore | StoreStore));
787    return (effective_mask != 0);
788  } else {
789    return true;
790  }
791}
792
793inline void MacroAssembler::membar( Membar_mask_bits const7a ) {
794  // Uniprocessors do not need memory barriers
795  if (!os::is_MP()) return;
796  // Weakened for current Sparcs and TSO.  See the v9 manual, sections 8.4.3,
797  // 8.4.4.3, a.31 and a.50.
798  if( VM_Version::v9_instructions_work() ) {
799    // Under TSO, setting bit 3, 2, or 0 is redundant, so the only value
800    // of the mmask subfield of const7a that does anything that isn't done
801    // implicitly is StoreLoad.
802    const Membar_mask_bits effective_mask =
803        Membar_mask_bits(const7a & ~(LoadLoad | LoadStore | StoreStore));
804    if ( effective_mask != 0 ) {
805      Assembler::membar( effective_mask );
806    }
807  } else {
808    // stbar is the closest there is on v8.  Equivalent to membar(StoreStore).  We
809    // do not issue the stbar because to my knowledge all v8 machines implement TSO,
810    // which guarantees that all stores behave as if an stbar were issued just after
811    // each one of them.  On these machines, stbar ought to be a nop.  There doesn't
812    // appear to be an equivalent of membar(StoreLoad) on v8: TSO doesn't require it,
813    // it can't be specified by stbar, nor have I come up with a way to simulate it.
814    //
815    // Addendum.  Dave says that ldstub guarantees a write buffer flush to coherent
816    // space.  Put one here to be on the safe side.
817    Assembler::ldstub(SP, 0, G0);
818  }
819}
820