src/cpu/sparc/vm/assembler_sparc.inline.hpp

Tue, 21 Apr 2009 11:16:30 -0700

author
twisti
date
Tue, 21 Apr 2009 11:16:30 -0700
changeset 1162
6b2273dd6fa9
parent 1145
e5b0439ef4ae
child 1441
dcf03e02b020
permissions
-rw-r--r--

6822110: Add AddressLiteral class on SPARC
Summary: The Address class on SPARC currently handles both, addresses and address literals, what makes the Address class more complicated than it has to be.
Reviewed-by: never, kvn

duke@435 1 /*
jrose@1100 2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 inline void MacroAssembler::pd_patch_instruction(address branch, address target) {
duke@435 26 jint& stub_inst = *(jint*) branch;
duke@435 27 stub_inst = patched_branch(target - branch, stub_inst, 0);
duke@435 28 }
duke@435 29
duke@435 30 #ifndef PRODUCT
duke@435 31 inline void MacroAssembler::pd_print_patched_instruction(address branch) {
duke@435 32 jint stub_inst = *(jint*) branch;
duke@435 33 print_instruction(stub_inst);
duke@435 34 ::tty->print("%s", " (unresolved)");
duke@435 35 }
duke@435 36 #endif // PRODUCT
duke@435 37
duke@435 38 inline bool Address::is_simm13(int offset) { return Assembler::is_simm13(disp() + offset); }
duke@435 39
duke@435 40
twisti@1162 41 inline int AddressLiteral::low10() const {
twisti@1162 42 return Assembler::low10(value());
twisti@1162 43 }
twisti@1162 44
twisti@1162 45
duke@435 46 // inlines for SPARC assembler -- dmu 5/97
duke@435 47
duke@435 48 inline void Assembler::check_delay() {
duke@435 49 # ifdef CHECK_DELAY
duke@435 50 guarantee( delay_state != at_delay_slot, "must say delayed() when filling delay slot");
duke@435 51 delay_state = no_delay;
duke@435 52 # endif
duke@435 53 }
duke@435 54
duke@435 55 inline void Assembler::emit_long(int x) {
duke@435 56 check_delay();
duke@435 57 AbstractAssembler::emit_long(x);
duke@435 58 }
duke@435 59
duke@435 60 inline void Assembler::emit_data(int x, relocInfo::relocType rtype) {
duke@435 61 relocate(rtype);
duke@435 62 emit_long(x);
duke@435 63 }
duke@435 64
duke@435 65 inline void Assembler::emit_data(int x, RelocationHolder const& rspec) {
duke@435 66 relocate(rspec);
duke@435 67 emit_long(x);
duke@435 68 }
duke@435 69
duke@435 70
twisti@1162 71 inline void Assembler::add(Register s1, Register s2, Register d ) { emit_long( op(arith_op) | rd(d) | op3(add_op3) | rs1(s1) | rs2(s2) ); }
twisti@1162 72 inline 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 ); }
twisti@1162 73 inline 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 ); }
duke@435 74
duke@435 75 inline 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(); }
duke@435 76 inline void Assembler::bpr( RCondition c, bool a, Predict p, Register s1, Label& L) { bpr( c, a, p, s1, target(L)); }
duke@435 77
duke@435 78 inline 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(); }
duke@435 79 inline void Assembler::fb( Condition c, bool a, Label& L ) { fb(c, a, target(L)); }
duke@435 80
duke@435 81 inline 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(); }
duke@435 82 inline void Assembler::fbp( Condition c, bool a, CC cc, Predict p, Label& L ) { fbp(c, a, cc, p, target(L)); }
duke@435 83
duke@435 84 inline 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(); }
duke@435 85 inline void Assembler::cb( Condition c, bool a, Label& L ) { cb(c, a, target(L)); }
duke@435 86
duke@435 87 inline 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(); }
duke@435 88 inline void Assembler::br( Condition c, bool a, Label& L ) { br(c, a, target(L)); }
duke@435 89
duke@435 90 inline 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(); }
duke@435 91 inline void Assembler::bp( Condition c, bool a, CC cc, Predict p, Label& L ) { bp(c, a, cc, p, target(L)); }
duke@435 92
duke@435 93 inline 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"); }
duke@435 94 inline void Assembler::call( Label& L, relocInfo::relocType rt ) { call( target(L), rt); }
duke@435 95
duke@435 96 inline void Assembler::flush( Register s1, Register s2) { emit_long( op(arith_op) | op3(flush_op3) | rs1(s1) | rs2(s2)); }
duke@435 97 inline void Assembler::flush( Register s1, int simm13a) { emit_data( op(arith_op) | op3(flush_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
duke@435 98
duke@435 99 inline 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(); }
duke@435 100 inline 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(); }
duke@435 101
twisti@1162 102 inline 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) ); }
twisti@1162 103 inline 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); }
duke@435 104
twisti@1162 105 inline 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); }
duke@435 106
duke@435 107 inline void Assembler::ldfsr( Register s1, Register s2) { v9_dep(); emit_long( op(ldst_op) | op3(ldfsr_op3) | rs1(s1) | rs2(s2) ); }
duke@435 108 inline void Assembler::ldfsr( Register s1, int simm13a) { v9_dep(); emit_data( op(ldst_op) | op3(ldfsr_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
duke@435 109 inline void Assembler::ldxfsr( Register s1, Register s2) { v9_only(); emit_long( op(ldst_op) | rd(G1) | op3(ldfsr_op3) | rs1(s1) | rs2(s2) ); }
duke@435 110 inline 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)); }
duke@435 111
duke@435 112 inline 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) ); }
duke@435 113 inline 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)); }
duke@435 114 inline 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) ); }
duke@435 115 inline 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)); }
duke@435 116 inline 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) ); }
duke@435 117 inline 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)); }
duke@435 118
duke@435 119 inline void Assembler::ldsb( Register s1, Register s2, Register d) { emit_long( op(ldst_op) | rd(d) | op3(ldsb_op3) | rs1(s1) | rs2(s2) ); }
duke@435 120 inline 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)); }
duke@435 121
duke@435 122 inline void Assembler::ldsh( Register s1, Register s2, Register d) { emit_long( op(ldst_op) | rd(d) | op3(ldsh_op3) | rs1(s1) | rs2(s2) ); }
duke@435 123 inline 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)); }
duke@435 124 inline void Assembler::ldsw( Register s1, Register s2, Register d) { emit_long( op(ldst_op) | rd(d) | op3(ldsw_op3) | rs1(s1) | rs2(s2) ); }
duke@435 125 inline 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)); }
duke@435 126 inline void Assembler::ldub( Register s1, Register s2, Register d) { emit_long( op(ldst_op) | rd(d) | op3(ldub_op3) | rs1(s1) | rs2(s2) ); }
duke@435 127 inline 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)); }
duke@435 128 inline void Assembler::lduh( Register s1, Register s2, Register d) { emit_long( op(ldst_op) | rd(d) | op3(lduh_op3) | rs1(s1) | rs2(s2) ); }
duke@435 129 inline 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)); }
duke@435 130 inline void Assembler::lduw( Register s1, Register s2, Register d) { emit_long( op(ldst_op) | rd(d) | op3(lduw_op3) | rs1(s1) | rs2(s2) ); }
duke@435 131 inline 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)); }
duke@435 132
duke@435 133 inline 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) ); }
duke@435 134 inline 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)); }
duke@435 135 inline 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) ); }
duke@435 136 inline 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)); }
duke@435 137
duke@435 138 #ifdef _LP64
duke@435 139 // Make all 32 bit loads signed so 64 bit registers maintain proper sign
twisti@1162 140 inline void Assembler::ld( Register s1, Register s2, Register d) { ldsw( s1, s2, d); }
twisti@1162 141 inline void Assembler::ld( Register s1, int simm13a, Register d) { ldsw( s1, simm13a, d); }
duke@435 142 #else
twisti@1162 143 inline void Assembler::ld( Register s1, Register s2, Register d) { lduw( s1, s2, d); }
twisti@1162 144 inline void Assembler::ld( Register s1, int simm13a, Register d) { lduw( s1, simm13a, d); }
duke@435 145 #endif
duke@435 146
twisti@1162 147 #ifdef ASSERT
twisti@1162 148 // ByteSize is only a class when ASSERT is defined, otherwise it's an int.
twisti@1162 149 # ifdef _LP64
twisti@1162 150 inline void Assembler::ld( Register s1, ByteSize simm13a, Register d) { ldsw( s1, in_bytes(simm13a), d); }
twisti@1162 151 # else
twisti@1162 152 inline void Assembler::ld( Register s1, ByteSize simm13a, Register d) { lduw( s1, in_bytes(simm13a), d); }
twisti@1162 153 # endif
twisti@1162 154 #endif
twisti@1162 155
twisti@1162 156 inline void Assembler::ld( const Address& a, Register d, int offset) {
twisti@1162 157 if (a.has_index()) { assert(offset == 0, ""); ld( a.base(), a.index(), d); }
twisti@1162 158 else { ld( a.base(), a.disp() + offset, d); }
jrose@1057 159 }
twisti@1162 160 inline void Assembler::ldsb(const Address& a, Register d, int offset) {
twisti@1162 161 if (a.has_index()) { assert(offset == 0, ""); ldsb(a.base(), a.index(), d); }
twisti@1162 162 else { ldsb(a.base(), a.disp() + offset, d); }
jrose@1057 163 }
twisti@1162 164 inline void Assembler::ldsh(const Address& a, Register d, int offset) {
twisti@1162 165 if (a.has_index()) { assert(offset == 0, ""); ldsh(a.base(), a.index(), d); }
twisti@1162 166 else { ldsh(a.base(), a.disp() + offset, d); }
jrose@1057 167 }
twisti@1162 168 inline void Assembler::ldsw(const Address& a, Register d, int offset) {
twisti@1162 169 if (a.has_index()) { assert(offset == 0, ""); ldsw(a.base(), a.index(), d); }
twisti@1162 170 else { ldsw(a.base(), a.disp() + offset, d); }
jrose@1057 171 }
twisti@1162 172 inline void Assembler::ldub(const Address& a, Register d, int offset) {
twisti@1162 173 if (a.has_index()) { assert(offset == 0, ""); ldub(a.base(), a.index(), d); }
twisti@1162 174 else { ldub(a.base(), a.disp() + offset, d); }
jrose@1057 175 }
twisti@1162 176 inline void Assembler::lduh(const Address& a, Register d, int offset) {
twisti@1162 177 if (a.has_index()) { assert(offset == 0, ""); lduh(a.base(), a.index(), d); }
twisti@1162 178 else { lduh(a.base(), a.disp() + offset, d); }
jrose@1057 179 }
twisti@1162 180 inline void Assembler::lduw(const Address& a, Register d, int offset) {
twisti@1162 181 if (a.has_index()) { assert(offset == 0, ""); lduw(a.base(), a.index(), d); }
twisti@1162 182 else { lduw(a.base(), a.disp() + offset, d); }
jrose@1057 183 }
twisti@1162 184 inline void Assembler::ldd( const Address& a, Register d, int offset) {
twisti@1162 185 if (a.has_index()) { assert(offset == 0, ""); ldd( a.base(), a.index(), d); }
twisti@1162 186 else { ldd( a.base(), a.disp() + offset, d); }
jrose@1057 187 }
twisti@1162 188 inline void Assembler::ldx( const Address& a, Register d, int offset) {
twisti@1162 189 if (a.has_index()) { assert(offset == 0, ""); ldx( a.base(), a.index(), d); }
twisti@1162 190 else { ldx( a.base(), a.disp() + offset, d); }
jrose@1057 191 }
jrose@1057 192
twisti@1162 193 inline void Assembler::ldub(Register s1, RegisterOrConstant s2, Register d) { ldub(Address(s1, s2), d); }
twisti@1162 194 inline void Assembler::ldsb(Register s1, RegisterOrConstant s2, Register d) { ldsb(Address(s1, s2), d); }
twisti@1162 195 inline void Assembler::lduh(Register s1, RegisterOrConstant s2, Register d) { lduh(Address(s1, s2), d); }
twisti@1162 196 inline void Assembler::ldsh(Register s1, RegisterOrConstant s2, Register d) { ldsh(Address(s1, s2), d); }
twisti@1162 197 inline void Assembler::lduw(Register s1, RegisterOrConstant s2, Register d) { lduw(Address(s1, s2), d); }
twisti@1162 198 inline void Assembler::ldsw(Register s1, RegisterOrConstant s2, Register d) { ldsw(Address(s1, s2), d); }
twisti@1162 199 inline void Assembler::ldx( Register s1, RegisterOrConstant s2, Register d) { ldx( Address(s1, s2), d); }
twisti@1162 200 inline void Assembler::ld( Register s1, RegisterOrConstant s2, Register d) { ld( Address(s1, s2), d); }
twisti@1162 201 inline void Assembler::ldd( Register s1, RegisterOrConstant s2, Register d) { ldd( Address(s1, s2), d); }
twisti@1162 202
jrose@1057 203 // form effective addresses this way:
jrose@1100 204 inline void Assembler::add( Register s1, RegisterOrConstant s2, Register d, int offset) {
jrose@1057 205 if (s2.is_register()) add(s1, s2.as_register(), d);
jrose@1057 206 else { add(s1, s2.as_constant() + offset, d); offset = 0; }
jrose@1057 207 if (offset != 0) add(d, offset, d);
jrose@1057 208 }
duke@435 209
duke@435 210 inline void Assembler::ldstub( Register s1, Register s2, Register d) { emit_long( op(ldst_op) | rd(d) | op3(ldstub_op3) | rs1(s1) | rs2(s2) ); }
duke@435 211 inline 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)); }
duke@435 212
duke@435 213
duke@435 214 inline 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) ); }
duke@435 215 inline 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)); }
duke@435 216
duke@435 217 inline void Assembler::prefetch(const Address& a, PrefetchFcn f, int offset) { v9_only(); relocate(a.rspec(offset)); prefetch(a.base(), a.disp() + offset, f); }
duke@435 218
duke@435 219
duke@435 220 inline void Assembler::rett( Register s1, Register s2 ) { emit_long( op(arith_op) | op3(rett_op3) | rs1(s1) | rs2(s2)); has_delay_slot(); }
duke@435 221 inline 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(); }
duke@435 222
duke@435 223 inline void Assembler::sethi( int imm22a, Register d, RelocationHolder const& rspec ) { emit_data( op(branch_op) | rd(d) | op2(sethi_op2) | hi22(imm22a), rspec); }
duke@435 224
duke@435 225 // pp 222
duke@435 226
duke@435 227 inline 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) ); }
duke@435 228 inline 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)); }
duke@435 229
duke@435 230 inline 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); }
duke@435 231
duke@435 232 inline void Assembler::stfsr( Register s1, Register s2) { v9_dep(); emit_long( op(ldst_op) | op3(stfsr_op3) | rs1(s1) | rs2(s2) ); }
duke@435 233 inline void Assembler::stfsr( Register s1, int simm13a) { v9_dep(); emit_data( op(ldst_op) | op3(stfsr_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
duke@435 234 inline void Assembler::stxfsr( Register s1, Register s2) { v9_only(); emit_long( op(ldst_op) | rd(G1) | op3(stfsr_op3) | rs1(s1) | rs2(s2) ); }
duke@435 235 inline 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)); }
duke@435 236
duke@435 237 // p 226
duke@435 238
duke@435 239 inline void Assembler::stb( Register d, Register s1, Register s2) { emit_long( op(ldst_op) | rd(d) | op3(stb_op3) | rs1(s1) | rs2(s2) ); }
duke@435 240 inline 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)); }
duke@435 241 inline void Assembler::sth( Register d, Register s1, Register s2) { emit_long( op(ldst_op) | rd(d) | op3(sth_op3) | rs1(s1) | rs2(s2) ); }
duke@435 242 inline 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)); }
duke@435 243 inline void Assembler::stw( Register d, Register s1, Register s2) { emit_long( op(ldst_op) | rd(d) | op3(stw_op3) | rs1(s1) | rs2(s2) ); }
duke@435 244 inline 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)); }
duke@435 245
duke@435 246
duke@435 247 inline 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) ); }
duke@435 248 inline 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)); }
duke@435 249 inline 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) ); }
duke@435 250 inline 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)); }
duke@435 251
twisti@1162 252 inline void Assembler::st( Register d, Register s1, Register s2) { stw(d, s1, s2); }
twisti@1162 253 inline void Assembler::st( Register d, Register s1, int simm13a) { stw(d, s1, simm13a); }
duke@435 254
twisti@1162 255 #ifdef ASSERT
twisti@1162 256 // ByteSize is only a class when ASSERT is defined, otherwise it's an int.
twisti@1162 257 inline void Assembler::st( Register d, Register s1, ByteSize simm13a) { stw(d, s1, in_bytes(simm13a)); }
twisti@1162 258 #endif
twisti@1162 259
twisti@1162 260 inline void Assembler::stb(Register d, const Address& a, int offset) {
twisti@1162 261 if (a.has_index()) { assert(offset == 0, ""); stb(d, a.base(), a.index() ); }
twisti@1162 262 else { stb(d, a.base(), a.disp() + offset); }
jrose@1057 263 }
twisti@1162 264 inline void Assembler::sth(Register d, const Address& a, int offset) {
twisti@1162 265 if (a.has_index()) { assert(offset == 0, ""); sth(d, a.base(), a.index() ); }
twisti@1162 266 else { sth(d, a.base(), a.disp() + offset); }
jrose@1057 267 }
twisti@1162 268 inline void Assembler::stw(Register d, const Address& a, int offset) {
twisti@1162 269 if (a.has_index()) { assert(offset == 0, ""); stw(d, a.base(), a.index() ); }
twisti@1162 270 else { stw(d, a.base(), a.disp() + offset); }
jrose@1057 271 }
twisti@1162 272 inline void Assembler::st( Register d, const Address& a, int offset) {
twisti@1162 273 if (a.has_index()) { assert(offset == 0, ""); st( d, a.base(), a.index() ); }
twisti@1162 274 else { st( d, a.base(), a.disp() + offset); }
jrose@1057 275 }
twisti@1162 276 inline void Assembler::std(Register d, const Address& a, int offset) {
twisti@1162 277 if (a.has_index()) { assert(offset == 0, ""); std(d, a.base(), a.index() ); }
twisti@1162 278 else { std(d, a.base(), a.disp() + offset); }
twisti@1162 279 }
twisti@1162 280 inline void Assembler::stx(Register d, const Address& a, int offset) {
twisti@1162 281 if (a.has_index()) { assert(offset == 0, ""); stx(d, a.base(), a.index() ); }
twisti@1162 282 else { stx(d, a.base(), a.disp() + offset); }
jrose@1057 283 }
jrose@1057 284
twisti@1162 285 inline void Assembler::stb(Register d, Register s1, RegisterOrConstant s2) { stb(d, Address(s1, s2)); }
twisti@1162 286 inline void Assembler::sth(Register d, Register s1, RegisterOrConstant s2) { sth(d, Address(s1, s2)); }
twisti@1162 287 inline void Assembler::stx(Register d, Register s1, RegisterOrConstant s2) { stx(d, Address(s1, s2)); }
twisti@1162 288 inline void Assembler::std(Register d, Register s1, RegisterOrConstant s2) { std(d, Address(s1, s2)); }
twisti@1162 289 inline void Assembler::st( Register d, Register s1, RegisterOrConstant s2) { st( d, Address(s1, s2)); }
duke@435 290
duke@435 291 // v8 p 99
duke@435 292
duke@435 293 inline 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) ); }
duke@435 294 inline 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)); }
duke@435 295 inline 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) ); }
duke@435 296 inline 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)); }
duke@435 297 inline 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) ); }
duke@435 298 inline 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)); }
duke@435 299 inline 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) ); }
duke@435 300 inline 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)); }
duke@435 301
duke@435 302
duke@435 303 // pp 231
duke@435 304
duke@435 305 inline 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) ); }
duke@435 306 inline 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)); }
duke@435 307
duke@435 308 inline void Assembler::swap( Address& a, Register d, int offset ) { relocate(a.rspec(offset)); swap( a.base(), a.disp() + offset, d ); }
duke@435 309
duke@435 310
duke@435 311 // Use the right loads/stores for the platform
duke@435 312 inline void MacroAssembler::ld_ptr( Register s1, Register s2, Register d ) {
duke@435 313 #ifdef _LP64
twisti@1162 314 Assembler::ldx(s1, s2, d);
duke@435 315 #else
twisti@1162 316 Assembler::ld( s1, s2, d);
duke@435 317 #endif
duke@435 318 }
duke@435 319
duke@435 320 inline void MacroAssembler::ld_ptr( Register s1, int simm13a, Register d ) {
duke@435 321 #ifdef _LP64
twisti@1162 322 Assembler::ldx(s1, simm13a, d);
duke@435 323 #else
twisti@1162 324 Assembler::ld( s1, simm13a, d);
duke@435 325 #endif
duke@435 326 }
duke@435 327
twisti@1162 328 #ifdef ASSERT
twisti@1162 329 // ByteSize is only a class when ASSERT is defined, otherwise it's an int.
twisti@1162 330 inline void MacroAssembler::ld_ptr( Register s1, ByteSize simm13a, Register d ) {
twisti@1162 331 ld_ptr(s1, in_bytes(simm13a), d);
twisti@1162 332 }
twisti@1162 333 #endif
twisti@1162 334
jrose@1100 335 inline void MacroAssembler::ld_ptr( Register s1, RegisterOrConstant s2, Register d ) {
jrose@1057 336 #ifdef _LP64
twisti@1162 337 Assembler::ldx(s1, s2, d);
jrose@1057 338 #else
twisti@1162 339 Assembler::ld( s1, s2, d);
jrose@1057 340 #endif
jrose@1057 341 }
jrose@1057 342
twisti@1162 343 inline void MacroAssembler::ld_ptr(const Address& a, Register d, int offset) {
duke@435 344 #ifdef _LP64
twisti@1162 345 Assembler::ldx(a, d, offset);
duke@435 346 #else
twisti@1162 347 Assembler::ld( a, d, offset);
duke@435 348 #endif
duke@435 349 }
duke@435 350
duke@435 351 inline void MacroAssembler::st_ptr( Register d, Register s1, Register s2 ) {
duke@435 352 #ifdef _LP64
twisti@1162 353 Assembler::stx(d, s1, s2);
duke@435 354 #else
duke@435 355 Assembler::st( d, s1, s2);
duke@435 356 #endif
duke@435 357 }
duke@435 358
duke@435 359 inline void MacroAssembler::st_ptr( Register d, Register s1, int simm13a ) {
duke@435 360 #ifdef _LP64
twisti@1162 361 Assembler::stx(d, s1, simm13a);
duke@435 362 #else
duke@435 363 Assembler::st( d, s1, simm13a);
duke@435 364 #endif
duke@435 365 }
duke@435 366
twisti@1162 367 #ifdef ASSERT
twisti@1162 368 // ByteSize is only a class when ASSERT is defined, otherwise it's an int.
twisti@1162 369 inline void MacroAssembler::st_ptr( Register d, Register s1, ByteSize simm13a ) {
twisti@1162 370 st_ptr(d, s1, in_bytes(simm13a));
twisti@1162 371 }
twisti@1162 372 #endif
twisti@1162 373
jrose@1100 374 inline void MacroAssembler::st_ptr( Register d, Register s1, RegisterOrConstant s2 ) {
jrose@1057 375 #ifdef _LP64
twisti@1162 376 Assembler::stx(d, s1, s2);
jrose@1057 377 #else
jrose@1057 378 Assembler::st( d, s1, s2);
jrose@1057 379 #endif
jrose@1057 380 }
jrose@1057 381
twisti@1162 382 inline void MacroAssembler::st_ptr(Register d, const Address& a, int offset) {
duke@435 383 #ifdef _LP64
twisti@1162 384 Assembler::stx(d, a, offset);
duke@435 385 #else
twisti@1162 386 Assembler::st( d, a, offset);
duke@435 387 #endif
duke@435 388 }
duke@435 389
duke@435 390 // Use the right loads/stores for the platform
duke@435 391 inline void MacroAssembler::ld_long( Register s1, Register s2, Register d ) {
duke@435 392 #ifdef _LP64
duke@435 393 Assembler::ldx(s1, s2, d);
duke@435 394 #else
duke@435 395 Assembler::ldd(s1, s2, d);
duke@435 396 #endif
duke@435 397 }
duke@435 398
duke@435 399 inline void MacroAssembler::ld_long( Register s1, int simm13a, Register d ) {
duke@435 400 #ifdef _LP64
duke@435 401 Assembler::ldx(s1, simm13a, d);
duke@435 402 #else
duke@435 403 Assembler::ldd(s1, simm13a, d);
duke@435 404 #endif
duke@435 405 }
duke@435 406
jrose@1100 407 inline void MacroAssembler::ld_long( Register s1, RegisterOrConstant s2, Register d ) {
jrose@1057 408 #ifdef _LP64
jrose@1057 409 Assembler::ldx(s1, s2, d);
jrose@1057 410 #else
jrose@1057 411 Assembler::ldd(s1, s2, d);
jrose@1057 412 #endif
jrose@1057 413 }
jrose@1057 414
twisti@1162 415 inline void MacroAssembler::ld_long(const Address& a, Register d, int offset) {
duke@435 416 #ifdef _LP64
twisti@1162 417 Assembler::ldx(a, d, offset);
duke@435 418 #else
twisti@1162 419 Assembler::ldd(a, d, offset);
duke@435 420 #endif
duke@435 421 }
duke@435 422
duke@435 423 inline void MacroAssembler::st_long( Register d, Register s1, Register s2 ) {
duke@435 424 #ifdef _LP64
duke@435 425 Assembler::stx(d, s1, s2);
duke@435 426 #else
duke@435 427 Assembler::std(d, s1, s2);
duke@435 428 #endif
duke@435 429 }
duke@435 430
duke@435 431 inline void MacroAssembler::st_long( Register d, Register s1, int simm13a ) {
duke@435 432 #ifdef _LP64
duke@435 433 Assembler::stx(d, s1, simm13a);
duke@435 434 #else
duke@435 435 Assembler::std(d, s1, simm13a);
duke@435 436 #endif
duke@435 437 }
duke@435 438
jrose@1100 439 inline void MacroAssembler::st_long( Register d, Register s1, RegisterOrConstant s2 ) {
jrose@1057 440 #ifdef _LP64
jrose@1057 441 Assembler::stx(d, s1, s2);
jrose@1057 442 #else
jrose@1057 443 Assembler::std(d, s1, s2);
jrose@1057 444 #endif
jrose@1057 445 }
jrose@1057 446
duke@435 447 inline void MacroAssembler::st_long( Register d, const Address& a, int offset ) {
duke@435 448 #ifdef _LP64
duke@435 449 Assembler::stx(d, a, offset);
duke@435 450 #else
duke@435 451 Assembler::std(d, a, offset);
duke@435 452 #endif
duke@435 453 }
duke@435 454
duke@435 455 // Functions for isolating 64 bit shifts for LP64
duke@435 456
duke@435 457 inline void MacroAssembler::sll_ptr( Register s1, Register s2, Register d ) {
duke@435 458 #ifdef _LP64
duke@435 459 Assembler::sllx(s1, s2, d);
duke@435 460 #else
twisti@1162 461 Assembler::sll( s1, s2, d);
duke@435 462 #endif
duke@435 463 }
duke@435 464
duke@435 465 inline void MacroAssembler::sll_ptr( Register s1, int imm6a, Register d ) {
duke@435 466 #ifdef _LP64
duke@435 467 Assembler::sllx(s1, imm6a, d);
duke@435 468 #else
twisti@1162 469 Assembler::sll( s1, imm6a, d);
duke@435 470 #endif
duke@435 471 }
duke@435 472
duke@435 473 inline void MacroAssembler::srl_ptr( Register s1, Register s2, Register d ) {
duke@435 474 #ifdef _LP64
duke@435 475 Assembler::srlx(s1, s2, d);
duke@435 476 #else
twisti@1162 477 Assembler::srl( s1, s2, d);
duke@435 478 #endif
duke@435 479 }
duke@435 480
duke@435 481 inline void MacroAssembler::srl_ptr( Register s1, int imm6a, Register d ) {
duke@435 482 #ifdef _LP64
duke@435 483 Assembler::srlx(s1, imm6a, d);
duke@435 484 #else
twisti@1162 485 Assembler::srl( s1, imm6a, d);
duke@435 486 #endif
duke@435 487 }
duke@435 488
jrose@1100 489 inline void MacroAssembler::sll_ptr( Register s1, RegisterOrConstant s2, Register d ) {
jrose@1058 490 if (s2.is_register()) sll_ptr(s1, s2.as_register(), d);
jrose@1058 491 else sll_ptr(s1, s2.as_constant(), d);
jrose@1058 492 }
jrose@1058 493
duke@435 494 // Use the right branch for the platform
duke@435 495
duke@435 496 inline void MacroAssembler::br( Condition c, bool a, Predict p, address d, relocInfo::relocType rt ) {
duke@435 497 if (VM_Version::v9_instructions_work())
duke@435 498 Assembler::bp(c, a, icc, p, d, rt);
duke@435 499 else
duke@435 500 Assembler::br(c, a, d, rt);
duke@435 501 }
duke@435 502
duke@435 503 inline void MacroAssembler::br( Condition c, bool a, Predict p, Label& L ) {
duke@435 504 br(c, a, p, target(L));
duke@435 505 }
duke@435 506
duke@435 507
duke@435 508 // Branch that tests either xcc or icc depending on the
duke@435 509 // architecture compiled (LP64 or not)
duke@435 510 inline void MacroAssembler::brx( Condition c, bool a, Predict p, address d, relocInfo::relocType rt ) {
duke@435 511 #ifdef _LP64
duke@435 512 Assembler::bp(c, a, xcc, p, d, rt);
duke@435 513 #else
duke@435 514 MacroAssembler::br(c, a, p, d, rt);
duke@435 515 #endif
duke@435 516 }
duke@435 517
duke@435 518 inline void MacroAssembler::brx( Condition c, bool a, Predict p, Label& L ) {
duke@435 519 brx(c, a, p, target(L));
duke@435 520 }
duke@435 521
duke@435 522 inline void MacroAssembler::ba( bool a, Label& L ) {
duke@435 523 br(always, a, pt, L);
duke@435 524 }
duke@435 525
duke@435 526 // Warning: V9 only functions
duke@435 527 inline void MacroAssembler::bp( Condition c, bool a, CC cc, Predict p, address d, relocInfo::relocType rt ) {
duke@435 528 Assembler::bp(c, a, cc, p, d, rt);
duke@435 529 }
duke@435 530
duke@435 531 inline void MacroAssembler::bp( Condition c, bool a, CC cc, Predict p, Label& L ) {
duke@435 532 Assembler::bp(c, a, cc, p, L);
duke@435 533 }
duke@435 534
duke@435 535 inline void MacroAssembler::fb( Condition c, bool a, Predict p, address d, relocInfo::relocType rt ) {
duke@435 536 if (VM_Version::v9_instructions_work())
duke@435 537 fbp(c, a, fcc0, p, d, rt);
duke@435 538 else
duke@435 539 Assembler::fb(c, a, d, rt);
duke@435 540 }
duke@435 541
duke@435 542 inline void MacroAssembler::fb( Condition c, bool a, Predict p, Label& L ) {
duke@435 543 fb(c, a, p, target(L));
duke@435 544 }
duke@435 545
duke@435 546 inline void MacroAssembler::fbp( Condition c, bool a, CC cc, Predict p, address d, relocInfo::relocType rt ) {
duke@435 547 Assembler::fbp(c, a, cc, p, d, rt);
duke@435 548 }
duke@435 549
duke@435 550 inline void MacroAssembler::fbp( Condition c, bool a, CC cc, Predict p, Label& L ) {
duke@435 551 Assembler::fbp(c, a, cc, p, L);
duke@435 552 }
duke@435 553
duke@435 554 inline void MacroAssembler::jmp( Register s1, Register s2 ) { jmpl( s1, s2, G0 ); }
duke@435 555 inline void MacroAssembler::jmp( Register s1, int simm13a, RelocationHolder const& rspec ) { jmpl( s1, simm13a, G0, rspec); }
duke@435 556
duke@435 557 // Call with a check to see if we need to deal with the added
duke@435 558 // expense of relocation and if we overflow the displacement
duke@435 559 // of the quick call instruction./
duke@435 560 // Check to see if we have to deal with relocations
duke@435 561 inline void MacroAssembler::call( address d, relocInfo::relocType rt ) {
duke@435 562 #ifdef _LP64
duke@435 563 intptr_t disp;
duke@435 564 // NULL is ok because it will be relocated later.
duke@435 565 // Must change NULL to a reachable address in order to
duke@435 566 // pass asserts here and in wdisp.
duke@435 567 if ( d == NULL )
duke@435 568 d = pc();
duke@435 569
duke@435 570 // Is this address within range of the call instruction?
duke@435 571 // If not, use the expensive instruction sequence
duke@435 572 disp = (intptr_t)d - (intptr_t)pc();
duke@435 573 if ( disp != (intptr_t)(int32_t)disp ) {
duke@435 574 relocate(rt);
twisti@1162 575 AddressLiteral dest(d);
twisti@1162 576 jumpl_to(dest, O7, O7);
duke@435 577 }
duke@435 578 else {
duke@435 579 Assembler::call( d, rt );
duke@435 580 }
duke@435 581 #else
duke@435 582 Assembler::call( d, rt );
duke@435 583 #endif
duke@435 584 }
duke@435 585
duke@435 586 inline void MacroAssembler::call( Label& L, relocInfo::relocType rt ) {
duke@435 587 MacroAssembler::call( target(L), rt);
duke@435 588 }
duke@435 589
duke@435 590
duke@435 591
duke@435 592 inline void MacroAssembler::callr( Register s1, Register s2 ) { jmpl( s1, s2, O7 ); }
duke@435 593 inline void MacroAssembler::callr( Register s1, int simm13a, RelocationHolder const& rspec ) { jmpl( s1, simm13a, O7, rspec); }
duke@435 594
duke@435 595 // prefetch instruction
duke@435 596 inline void MacroAssembler::iprefetch( address d, relocInfo::relocType rt ) {
duke@435 597 if (VM_Version::v9_instructions_work())
duke@435 598 Assembler::bp( never, true, xcc, pt, d, rt );
duke@435 599 }
duke@435 600 inline void MacroAssembler::iprefetch( Label& L) { iprefetch( target(L) ); }
duke@435 601
duke@435 602
duke@435 603 // clobbers o7 on V8!!
duke@435 604 // returns delta from gotten pc to addr after
duke@435 605 inline int MacroAssembler::get_pc( Register d ) {
duke@435 606 int x = offset();
duke@435 607 if (VM_Version::v9_instructions_work())
duke@435 608 rdpc(d);
duke@435 609 else {
duke@435 610 Label lbl;
duke@435 611 Assembler::call(lbl, relocInfo::none); // No relocation as this is call to pc+0x8
duke@435 612 if (d == O7) delayed()->nop();
duke@435 613 else delayed()->mov(O7, d);
duke@435 614 bind(lbl);
duke@435 615 }
duke@435 616 return offset() - x;
duke@435 617 }
duke@435 618
duke@435 619
duke@435 620 // Note: All MacroAssembler::set_foo functions are defined out-of-line.
duke@435 621
duke@435 622
duke@435 623 // Loads the current PC of the following instruction as an immediate value in
duke@435 624 // 2 instructions. All PCs in the CodeCache are within 2 Gig of each other.
duke@435 625 inline intptr_t MacroAssembler::load_pc_address( Register reg, int bytes_to_skip ) {
duke@435 626 intptr_t thepc = (intptr_t)pc() + 2*BytesPerInstWord + bytes_to_skip;
duke@435 627 #ifdef _LP64
duke@435 628 Unimplemented();
duke@435 629 #else
duke@435 630 Assembler::sethi( thepc & ~0x3ff, reg, internal_word_Relocation::spec((address)thepc));
duke@435 631 Assembler::add(reg,thepc & 0x3ff, reg, internal_word_Relocation::spec((address)thepc));
duke@435 632 #endif
duke@435 633 return thepc;
duke@435 634 }
duke@435 635
twisti@1162 636
twisti@1162 637 inline void MacroAssembler::load_contents(AddressLiteral& addrlit, Register d, int offset) {
duke@435 638 assert_not_delayed();
twisti@1162 639 sethi(addrlit, d);
twisti@1162 640 ld(d, addrlit.low10() + offset, d);
duke@435 641 }
duke@435 642
duke@435 643
twisti@1162 644 inline void MacroAssembler::load_ptr_contents(AddressLiteral& addrlit, Register d, int offset) {
duke@435 645 assert_not_delayed();
twisti@1162 646 sethi(addrlit, d);
twisti@1162 647 ld_ptr(d, addrlit.low10() + offset, d);
duke@435 648 }
duke@435 649
duke@435 650
twisti@1162 651 inline void MacroAssembler::store_contents(Register s, AddressLiteral& addrlit, Register temp, int offset) {
duke@435 652 assert_not_delayed();
twisti@1162 653 sethi(addrlit, temp);
twisti@1162 654 st(s, temp, addrlit.low10() + offset);
duke@435 655 }
duke@435 656
duke@435 657
twisti@1162 658 inline void MacroAssembler::store_ptr_contents(Register s, AddressLiteral& addrlit, Register temp, int offset) {
duke@435 659 assert_not_delayed();
twisti@1162 660 sethi(addrlit, temp);
twisti@1162 661 st_ptr(s, temp, addrlit.low10() + offset);
duke@435 662 }
duke@435 663
duke@435 664
duke@435 665 // This code sequence is relocatable to any address, even on LP64.
twisti@1162 666 inline void MacroAssembler::jumpl_to(AddressLiteral& addrlit, Register temp, Register d, int offset) {
duke@435 667 assert_not_delayed();
duke@435 668 // Force fixed length sethi because NativeJump and NativeFarCall don't handle
duke@435 669 // variable length instruction streams.
twisti@1162 670 patchable_sethi(addrlit, temp);
twisti@1162 671 jmpl(temp, addrlit.low10() + offset, d);
duke@435 672 }
duke@435 673
duke@435 674
twisti@1162 675 inline void MacroAssembler::jump_to(AddressLiteral& addrlit, Register temp, int offset) {
twisti@1162 676 jumpl_to(addrlit, temp, G0, offset);
duke@435 677 }
duke@435 678
duke@435 679
twisti@1162 680 inline void MacroAssembler::jump_indirect_to(Address& a, Register temp,
twisti@1162 681 int ld_offset, int jmp_offset) {
jrose@1145 682 assert_not_delayed();
twisti@1162 683 //sethi(al); // sethi is caller responsibility for this one
jrose@1145 684 ld_ptr(a, temp, ld_offset);
jrose@1145 685 jmp(temp, jmp_offset);
jrose@1145 686 }
jrose@1145 687
jrose@1145 688
twisti@1162 689 inline void MacroAssembler::set_oop(jobject obj, Register d) {
twisti@1162 690 set_oop(allocate_oop_address(obj), d);
duke@435 691 }
duke@435 692
duke@435 693
twisti@1162 694 inline void MacroAssembler::set_oop_constant(jobject obj, Register d) {
twisti@1162 695 set_oop(constant_oop_address(obj), d);
duke@435 696 }
duke@435 697
duke@435 698
twisti@1162 699 inline void MacroAssembler::set_oop(AddressLiteral& obj_addr, Register d) {
twisti@1162 700 assert(obj_addr.rspec().type() == relocInfo::oop_type, "must be an oop reloc");
twisti@1162 701 set(obj_addr, d);
duke@435 702 }
duke@435 703
duke@435 704
duke@435 705 inline void MacroAssembler::load_argument( Argument& a, Register d ) {
duke@435 706 if (a.is_register())
duke@435 707 mov(a.as_register(), d);
duke@435 708 else
duke@435 709 ld (a.as_address(), d);
duke@435 710 }
duke@435 711
duke@435 712 inline void MacroAssembler::store_argument( Register s, Argument& a ) {
duke@435 713 if (a.is_register())
duke@435 714 mov(s, a.as_register());
duke@435 715 else
duke@435 716 st_ptr (s, a.as_address()); // ABI says everything is right justified.
duke@435 717 }
duke@435 718
duke@435 719 inline void MacroAssembler::store_ptr_argument( Register s, Argument& a ) {
duke@435 720 if (a.is_register())
duke@435 721 mov(s, a.as_register());
duke@435 722 else
duke@435 723 st_ptr (s, a.as_address());
duke@435 724 }
duke@435 725
duke@435 726
duke@435 727 #ifdef _LP64
duke@435 728 inline void MacroAssembler::store_float_argument( FloatRegister s, Argument& a ) {
duke@435 729 if (a.is_float_register())
duke@435 730 // V9 ABI has F1, F3, F5 are used to pass instead of O0, O1, O2
duke@435 731 fmov(FloatRegisterImpl::S, s, a.as_float_register() );
duke@435 732 else
duke@435 733 // Floats are stored in the high half of the stack entry
duke@435 734 // The low half is undefined per the ABI.
duke@435 735 stf(FloatRegisterImpl::S, s, a.as_address(), sizeof(jfloat));
duke@435 736 }
duke@435 737
duke@435 738 inline void MacroAssembler::store_double_argument( FloatRegister s, Argument& a ) {
duke@435 739 if (a.is_float_register())
duke@435 740 // V9 ABI has D0, D2, D4 are used to pass instead of O0, O1, O2
duke@435 741 fmov(FloatRegisterImpl::D, s, a.as_double_register() );
duke@435 742 else
duke@435 743 stf(FloatRegisterImpl::D, s, a.as_address());
duke@435 744 }
duke@435 745
duke@435 746 inline void MacroAssembler::store_long_argument( Register s, Argument& a ) {
duke@435 747 if (a.is_register())
duke@435 748 mov(s, a.as_register());
duke@435 749 else
duke@435 750 stx(s, a.as_address());
duke@435 751 }
duke@435 752 #endif
duke@435 753
duke@435 754 inline void MacroAssembler::clrb( Register s1, Register s2) { stb( G0, s1, s2 ); }
duke@435 755 inline void MacroAssembler::clrh( Register s1, Register s2) { sth( G0, s1, s2 ); }
duke@435 756 inline void MacroAssembler::clr( Register s1, Register s2) { stw( G0, s1, s2 ); }
duke@435 757 inline void MacroAssembler::clrx( Register s1, Register s2) { stx( G0, s1, s2 ); }
duke@435 758
duke@435 759 inline void MacroAssembler::clrb( Register s1, int simm13a) { stb( G0, s1, simm13a); }
duke@435 760 inline void MacroAssembler::clrh( Register s1, int simm13a) { sth( G0, s1, simm13a); }
duke@435 761 inline void MacroAssembler::clr( Register s1, int simm13a) { stw( G0, s1, simm13a); }
duke@435 762 inline void MacroAssembler::clrx( Register s1, int simm13a) { stx( G0, s1, simm13a); }
duke@435 763
duke@435 764 // returns if membar generates anything, obviously this code should mirror
duke@435 765 // membar below.
duke@435 766 inline bool MacroAssembler::membar_has_effect( Membar_mask_bits const7a ) {
duke@435 767 if( !os::is_MP() ) return false; // Not needed on single CPU
duke@435 768 if( VM_Version::v9_instructions_work() ) {
duke@435 769 const Membar_mask_bits effective_mask =
duke@435 770 Membar_mask_bits(const7a & ~(LoadLoad | LoadStore | StoreStore));
duke@435 771 return (effective_mask != 0);
duke@435 772 } else {
duke@435 773 return true;
duke@435 774 }
duke@435 775 }
duke@435 776
duke@435 777 inline void MacroAssembler::membar( Membar_mask_bits const7a ) {
duke@435 778 // Uniprocessors do not need memory barriers
duke@435 779 if (!os::is_MP()) return;
duke@435 780 // Weakened for current Sparcs and TSO. See the v9 manual, sections 8.4.3,
duke@435 781 // 8.4.4.3, a.31 and a.50.
duke@435 782 if( VM_Version::v9_instructions_work() ) {
duke@435 783 // Under TSO, setting bit 3, 2, or 0 is redundant, so the only value
duke@435 784 // of the mmask subfield of const7a that does anything that isn't done
duke@435 785 // implicitly is StoreLoad.
duke@435 786 const Membar_mask_bits effective_mask =
duke@435 787 Membar_mask_bits(const7a & ~(LoadLoad | LoadStore | StoreStore));
duke@435 788 if ( effective_mask != 0 ) {
duke@435 789 Assembler::membar( effective_mask );
duke@435 790 }
duke@435 791 } else {
duke@435 792 // stbar is the closest there is on v8. Equivalent to membar(StoreStore). We
duke@435 793 // do not issue the stbar because to my knowledge all v8 machines implement TSO,
duke@435 794 // which guarantees that all stores behave as if an stbar were issued just after
duke@435 795 // each one of them. On these machines, stbar ought to be a nop. There doesn't
duke@435 796 // appear to be an equivalent of membar(StoreLoad) on v8: TSO doesn't require it,
duke@435 797 // it can't be specified by stbar, nor have I come up with a way to simulate it.
duke@435 798 //
duke@435 799 // Addendum. Dave says that ldstub guarantees a write buffer flush to coherent
duke@435 800 // space. Put one here to be on the safe side.
duke@435 801 Assembler::ldstub(SP, 0, G0);
duke@435 802 }
duke@435 803 }

mercurial