Tue, 24 Oct 2017 14:04:09 +0800
[Assembler] Complex address modes support for Assembler::lea(Register rt, Address src), Assembler::sd(Register rt, Address dst) and Assembler::sw(Register rt, Address dst)
1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2015, 2016, Loongson Technology. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
26 #ifndef CPU_MIPS_VM_MACROASSEMBLER_MIPS_HPP
27 #define CPU_MIPS_VM_MACROASSEMBLER_MIPS_HPP
29 #include "asm/assembler.hpp"
30 #include "utilities/macros.hpp"
31 #include "runtime/rtmLocking.hpp"
34 // MacroAssembler extends Assembler by frequently used macros.
35 //
36 // Instructions for which a 'better' code sequence exists depending
37 // on arguments should also go in here.
39 class MacroAssembler: public Assembler {
40 friend class LIR_Assembler;
41 friend class Runtime1; // as_Address()
43 protected:
45 Address as_Address(AddressLiteral adr);
46 Address as_Address(ArrayAddress adr);
48 // Support for VM calls
49 //
50 // This is the base routine called by the different versions of call_VM_leaf. The interpreter
51 // may customize this version by overriding it for its purposes (e.g., to save/restore
52 // additional registers when doing a VM call).
53 #ifdef CC_INTERP
54 // c++ interpreter never wants to use interp_masm version of call_VM
55 #define VIRTUAL
56 #else
57 #define VIRTUAL virtual
58 #endif
60 VIRTUAL void call_VM_leaf_base(
61 address entry_point, // the entry point
62 int number_of_arguments // the number of arguments to pop after the call
63 );
65 // This is the base routine called by the different versions of call_VM. The interpreter
66 // may customize this version by overriding it for its purposes (e.g., to save/restore
67 // additional registers when doing a VM call).
68 //
69 // If no java_thread register is specified (noreg) than rdi will be used instead. call_VM_base
70 // returns the register which contains the thread upon return. If a thread register has been
71 // specified, the return value will correspond to that register. If no last_java_sp is specified
72 // (noreg) than rsp will be used instead.
73 VIRTUAL void call_VM_base( // returns the register containing the thread upon return
74 Register oop_result, // where an oop-result ends up if any; use noreg otherwise
75 Register java_thread, // the thread if computed before ; use noreg otherwise
76 Register last_java_sp, // to set up last_Java_frame in stubs; use noreg otherwise
77 address entry_point, // the entry point
78 int number_of_arguments, // the number of arguments (w/o thread) to pop after the call
79 bool check_exceptions // whether to check for pending exceptions after return
80 );
82 // These routines should emit JVMTI PopFrame and ForceEarlyReturn handling code.
83 // The implementation is only non-empty for the InterpreterMacroAssembler,
84 // as only the interpreter handles PopFrame and ForceEarlyReturn requests.
85 virtual void check_and_handle_popframe(Register java_thread);
86 virtual void check_and_handle_earlyret(Register java_thread);
88 void call_VM_helper(Register oop_result, address entry_point, int number_of_arguments, bool check_exceptions = true);
90 // helpers for FPU flag access
91 // tmp is a temporary register, if none is available use noreg
93 public:
94 static intptr_t i[32];
95 static float f[32];
96 static void print(outputStream *s);
98 static int i_offset(unsigned int k);
99 static int f_offset(unsigned int k);
101 static void save_registers(MacroAssembler *masm);
102 static void restore_registers(MacroAssembler *masm);
104 MacroAssembler(CodeBuffer* code) : Assembler(code) {}
106 // Support for NULL-checks
107 //
108 // Generates code that causes a NULL OS exception if the content of reg is NULL.
109 // If the accessed location is M[reg + offset] and the offset is known, provide the
110 // offset. No explicit code generation is needed if the offset is within a certain
111 // range (0 <= offset <= page_size).
113 void null_check(Register reg, int offset = -1);
114 static bool needs_explicit_null_check(intptr_t offset);
116 // Required platform-specific helpers for Label::patch_instructions.
117 // They _shadow_ the declarations in AbstractAssembler, which are undefined.
118 void pd_patch_instruction(address branch, address target);
120 // Support for inc/dec with optimal instruction selection depending on value
121 void incrementl(Register reg, int value = 1);
122 void decrementl(Register reg, int value = 1);
125 // Alignment
126 void align(int modulus);
129 // Stack frame creation/removal
130 void enter();
131 void leave();
133 // Support for getting the JavaThread pointer (i.e.; a reference to thread-local information)
134 // The pointer will be loaded into the thread register.
135 void get_thread(Register thread);
138 // Support for VM calls
139 //
140 // It is imperative that all calls into the VM are handled via the call_VM macros.
141 // They make sure that the stack linkage is setup correctly. call_VM's correspond
142 // to ENTRY/ENTRY_X entry points while call_VM_leaf's correspond to LEAF entry points.
145 void call_VM(Register oop_result,
146 address entry_point,
147 bool check_exceptions = true);
148 void call_VM(Register oop_result,
149 address entry_point,
150 Register arg_1,
151 bool check_exceptions = true);
152 void call_VM(Register oop_result,
153 address entry_point,
154 Register arg_1, Register arg_2,
155 bool check_exceptions = true);
156 void call_VM(Register oop_result,
157 address entry_point,
158 Register arg_1, Register arg_2, Register arg_3,
159 bool check_exceptions = true);
161 // Overloadings with last_Java_sp
162 void call_VM(Register oop_result,
163 Register last_java_sp,
164 address entry_point,
165 int number_of_arguments = 0,
166 bool check_exceptions = true);
167 void call_VM(Register oop_result,
168 Register last_java_sp,
169 address entry_point,
170 Register arg_1, bool
171 check_exceptions = true);
172 void call_VM(Register oop_result,
173 Register last_java_sp,
174 address entry_point,
175 Register arg_1, Register arg_2,
176 bool check_exceptions = true);
177 void call_VM(Register oop_result,
178 Register last_java_sp,
179 address entry_point,
180 Register arg_1, Register arg_2, Register arg_3,
181 bool check_exceptions = true);
183 void get_vm_result (Register oop_result, Register thread);
184 void get_vm_result_2(Register metadata_result, Register thread);
185 void call_VM_leaf(address entry_point,
186 int number_of_arguments = 0);
187 void call_VM_leaf(address entry_point,
188 Register arg_1);
189 void call_VM_leaf(address entry_point,
190 Register arg_1, Register arg_2);
191 void call_VM_leaf(address entry_point,
192 Register arg_1, Register arg_2, Register arg_3);
194 // Super call_VM calls - correspond to MacroAssembler::call_VM(_leaf) calls
195 void super_call_VM_leaf(address entry_point);
196 void super_call_VM_leaf(address entry_point, Register arg_1);
197 void super_call_VM_leaf(address entry_point, Register arg_1, Register arg_2);
198 void super_call_VM_leaf(address entry_point, Register arg_1, Register arg_2, Register arg_3);
199 // last Java Frame (fills frame anchor)
200 void set_last_Java_frame(Register thread,
201 Register last_java_sp,
202 Register last_java_fp,
203 address last_java_pc);
205 // thread in the default location (r15_thread on 64bit)
206 void set_last_Java_frame(Register last_java_sp,
207 Register last_java_fp,
208 address last_java_pc);
210 void reset_last_Java_frame(Register thread, bool clear_fp, bool clear_pc);
212 // thread in the default location (r15_thread on 64bit)
213 void reset_last_Java_frame(bool clear_fp, bool clear_pc);
215 // Stores
216 void store_check(Register obj); // store check for obj - register is destroyed afterwards
217 void store_check(Register obj, Address dst); // same as above, dst is exact store location (reg. is destroyed)
219 #if INCLUDE_ALL_GCS
221 void g1_write_barrier_pre(Register obj,
222 Register pre_val,
223 Register thread,
224 Register tmp,
225 bool tosca_live,
226 bool expand_call);
228 void g1_write_barrier_post(Register store_addr,
229 Register new_val,
230 Register thread,
231 Register tmp,
232 Register tmp2);
234 #endif // INCLUDE_ALL_GCS
236 // split store_check(Register obj) to enhance instruction interleaving
237 void store_check_part_1(Register obj);
238 void store_check_part_2(Register obj);
240 // C 'boolean' to Java boolean: x == 0 ? 0 : 1
241 void c2bool(Register x);
242 //add for compressedoops
243 void load_klass(Register dst, Register src);
244 void store_klass(Register dst, Register src);
245 void load_prototype_header(Register dst, Register src);
247 #ifdef _LP64
248 void store_klass_gap(Register dst, Register src);
250 void load_heap_oop(Register dst, Address src);
251 void store_heap_oop(Address dst, Register src);
252 void store_heap_oop_null(Address dst);
253 void encode_heap_oop(Register r);
254 void encode_heap_oop(Register dst, Register src);
255 void decode_heap_oop(Register r);
256 void decode_heap_oop(Register dst, Register src);
257 void encode_heap_oop_not_null(Register r);
258 void decode_heap_oop_not_null(Register r);
259 void encode_heap_oop_not_null(Register dst, Register src);
260 void decode_heap_oop_not_null(Register dst, Register src);
262 void encode_klass_not_null(Register r);
263 void decode_klass_not_null(Register r);
264 void encode_klass_not_null(Register dst, Register src);
265 void decode_klass_not_null(Register dst, Register src);
267 // Returns the byte size of the instructions generated by decode_klass_not_null()
268 // when compressed klass pointers are being used.
269 static int instr_size_for_decode_klass_not_null();
271 // if heap base register is used - reinit it with the correct value
272 void reinit_heapbase();
274 DEBUG_ONLY(void verify_heapbase(const char* msg);)
276 void set_narrow_klass(Register dst, Klass* k);
277 void set_narrow_oop(Register dst, jobject obj);
279 #endif // _LP64
283 void int3();
284 // Sign extension
285 #ifdef _LP64
286 void sign_extend_short(Register reg) { /*dsll32(reg, reg, 16); dsra32(reg, reg, 16);*/ seh(reg, reg); }
287 void sign_extend_byte(Register reg) { /*dsll32(reg, reg, 24); dsra32(reg, reg, 24);*/ seb(reg, reg); }
288 #else
289 void sign_extend_short(Register reg) { /*sll(reg, reg, 16); sra(reg, reg, 16);*/ seh(reg, reg); }
290 void sign_extend_byte(Register reg) { /*sll(reg, reg, 24); sra(reg, reg, 24);*/ seb(reg, reg);}
291 #endif
292 void rem_s(FloatRegister fd, FloatRegister fs, FloatRegister ft, FloatRegister tmp);
293 void rem_d(FloatRegister fd, FloatRegister fs, FloatRegister ft, FloatRegister tmp);
295 // Inlined sin/cos generator for Java; must not use CPU instruction
296 // directly on Intel as it does not have high enough precision
297 // outside of the range [-pi/4, pi/4]. Extra argument indicate the
298 // number of FPU stack slots in use; all but the topmost will
299 // require saving if a slow case is necessary. Assumes argument is
300 // on FP TOS; result is on FP TOS. No cpu registers are changed by
301 // this code.
302 void trigfunc(char trig, int num_fpu_regs_in_use = 1);
303 // allocation
304 void eden_allocate(
305 Register obj, // result: pointer to object after successful allocation
306 Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise
307 int con_size_in_bytes, // object size in bytes if known at compile time
308 Register t1, // temp register
309 Register t2,
310 Label& slow_case // continuation point if fast allocation fails
311 );
312 void tlab_allocate(
313 Register obj, // result: pointer to object after successful allocation
314 Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise
315 int con_size_in_bytes, // object size in bytes if known at compile time
316 Register t1, // temp register
317 Register t2, // temp register
318 Label& slow_case // continuation point if fast allocation fails
319 );
320 void tlab_refill(Label& retry_tlab, Label& try_eden, Label& slow_case);
321 // interface method calling
322 void lookup_interface_method(Register recv_klass,
323 Register intf_klass,
324 RegisterOrConstant itable_index,
325 Register method_result,
326 Register scan_temp,
327 Label& no_such_interface);
329 // virtual method calling
330 void lookup_virtual_method(Register recv_klass,
331 RegisterOrConstant vtable_index,
332 Register method_result);
334 // Test sub_klass against super_klass, with fast and slow paths.
336 // The fast path produces a tri-state answer: yes / no / maybe-slow.
337 // One of the three labels can be NULL, meaning take the fall-through.
338 // If super_check_offset is -1, the value is loaded up from super_klass.
339 // No registers are killed, except temp_reg.
340 void check_klass_subtype_fast_path(Register sub_klass,
341 Register super_klass,
342 Register temp_reg,
343 Label* L_success,
344 Label* L_failure,
345 Label* L_slow_path,
346 RegisterOrConstant super_check_offset = RegisterOrConstant(-1));
348 // The rest of the type check; must be wired to a corresponding fast path.
349 // It does not repeat the fast path logic, so don't use it standalone.
350 // The temp_reg and temp2_reg can be noreg, if no temps are available.
351 // Updates the sub's secondary super cache as necessary.
352 // If set_cond_codes, condition codes will be Z on success, NZ on failure.
353 void check_klass_subtype_slow_path(Register sub_klass,
354 Register super_klass,
355 Register temp_reg,
356 Register temp2_reg,
357 Label* L_success,
358 Label* L_failure,
359 bool set_cond_codes = false);
361 // Simplified, combined version, good for typical uses.
362 // Falls through on failure.
363 void check_klass_subtype(Register sub_klass,
364 Register super_klass,
365 Register temp_reg,
366 Label& L_success);
369 // Debugging
371 // only if +VerifyOops
372 void verify_oop(Register reg, const char* s = "broken oop");
373 void verify_oop_addr(Address addr, const char * s = "broken oop addr");
374 void verify_oop_subroutine();
375 // TODO: verify method and klass metadata (compare against vptr?)
376 void _verify_method_ptr(Register reg, const char * msg, const char * file, int line) {}
377 void _verify_klass_ptr(Register reg, const char * msg, const char * file, int line){}
379 #define verify_method_ptr(reg) _verify_method_ptr(reg, "broken method " #reg, __FILE__, __LINE__)
380 #define verify_klass_ptr(reg) _verify_klass_ptr(reg, "broken klass " #reg, __FILE__, __LINE__)
382 // only if +VerifyFPU
383 void verify_FPU(int stack_depth, const char* s = "illegal FPU state");
385 // prints msg, dumps registers and stops execution
386 void stop(const char* msg);
388 // prints msg and continues
389 void warn(const char* msg);
391 static void debug(char* msg/*, RegistersForDebugging* regs*/);
392 static void debug32(int rdi, int rsi, int rbp, int rsp, int rbx, int rdx, int rcx, int rax, int eip, char* msg);
393 static void debug64(char* msg, int64_t pc, int64_t regs[]);
395 void print_reg(Register reg);
396 void print_reg(FloatRegister reg);
397 //void os_breakpoint();
399 void untested() { stop("untested"); }
401 void unimplemented(const char* what = "") { char* b = new char[1024]; jio_snprintf(b, sizeof(b), "unimplemented: %s", what); stop(b); }
403 void should_not_reach_here() { stop("should not reach here"); }
405 void print_CPU_state();
407 // Stack overflow checking
408 void bang_stack_with_offset(int offset) {
409 // stack grows down, caller passes positive offset
410 assert(offset > 0, "must bang with negative offset");
411 if (offset <= 32768) {
412 sw(A0, SP, -offset);
413 } else {
414 #ifdef _LP64
415 li(AT, offset);
416 dsub(AT, SP, AT);
417 #else
418 move(AT, offset);
419 sub(AT, SP, AT);
420 #endif
421 sw(A0, AT, 0);
422 }
423 }
425 // Writes to stack successive pages until offset reached to check for
426 // stack overflow + shadow pages. Also, clobbers tmp
427 void bang_stack_size(Register size, Register tmp);
429 virtual RegisterOrConstant delayed_value_impl(intptr_t* delayed_value_addr,
430 Register tmp,
431 int offset);
433 // Support for serializing memory accesses between threads
434 void serialize_memory(Register thread, Register tmp);
436 //void verify_tlab();
437 void verify_tlab(Register t1, Register t2);
439 // Biased locking support
440 // lock_reg and obj_reg must be loaded up with the appropriate values.
441 // swap_reg must be rax, and is killed.
442 // tmp_reg is optional. If it is supplied (i.e., != noreg) it will
443 // be killed; if not supplied, push/pop will be used internally to
444 // allocate a temporary (inefficient, avoid if possible).
445 // Optional slow case is for implementations (interpreter and C1) which branch to
446 // slow case directly. Leaves condition codes set for C2's Fast_Lock node.
447 // Returns offset of first potentially-faulting instruction for null
448 // check info (currently consumed only by C1). If
449 // swap_reg_contains_mark is true then returns -1 as it is assumed
450 // the calling code has already passed any potential faults.
451 int biased_locking_enter(Register lock_reg, Register obj_reg,
452 Register swap_reg, Register tmp_reg,
453 bool swap_reg_contains_mark,
454 Label& done, Label* slow_case = NULL,
455 BiasedLockingCounters* counters = NULL);
456 void biased_locking_exit (Register obj_reg, Register temp_reg, Label& done);
457 #ifdef COMPILER2
458 void fast_lock(Register obj, Register box, Register tmp, Register scr);
459 void fast_unlock(Register obj, Register box, Register tmp);
460 #endif
463 // Arithmetics
464 // Regular vs. d* versions
465 inline void addu_long(Register rd, Register rs, Register rt) {
466 #ifdef _LP64
467 daddu(rd, rs, rt);
468 #else
469 addu(rd, rs, rt);
470 #endif
471 }
472 inline void addu_long(Register rd, Register rs, long imm32_64) {
473 #ifdef _LP64
474 daddiu(rd, rs, imm32_64);
475 #else
476 addiu(rd, rs, imm32_64);
477 #endif
479 }
481 void round_to(Register reg, int modulus) {
482 assert_different_registers(reg, AT);
483 increment(reg, modulus - 1);
484 move(AT, - modulus);
485 andr(reg, reg, AT);
486 }
488 // the follow two might use AT register, be sure you have no meanful data in AT before you call them
489 void increment(Register reg, int imm);
490 void decrement(Register reg, int imm);
492 #ifdef _LP64
493 void shl(Register reg, int sa) { dsll(reg, reg, sa); }
494 void shr(Register reg, int sa) { dsrl(reg, reg, sa); }
495 void sar(Register reg, int sa) { dsra(reg, reg, sa); }
496 #else
497 void shl(Register reg, int sa) { sll(reg, reg, sa); }
498 void shr(Register reg, int sa) { srl(reg, reg, sa); }
499 void sar(Register reg, int sa) { sra(reg, reg, sa); }
500 #endif
501 // Helper functions for statistics gathering.
502 void atomic_inc32(address counter_addr, int inc, Register tmp_reg1, Register tmp_reg2);
504 // Calls
505 void call(address entry);
506 void call(address entry, relocInfo::relocType rtype);
507 void call(address entry, RelocationHolder& rh);
508 // Emit the CompiledIC call idiom
509 void ic_call(address entry);
511 // Jumps
512 void jmp(address entry);
513 void jmp(address entry, relocInfo::relocType rtype);
515 /* branches may exceed 16-bit offset */
516 void b_far(address entry);
517 void b_far(Label& L);
519 void bne_far (Register rs, Register rt, address entry);
520 void bne_far (Register rs, Register rt, Label& L);
522 void beq_far (Register rs, Register rt, address entry);
523 void beq_far (Register rs, Register rt, Label& L);
525 void patchable_call(address target);
526 void general_call(address target);
528 void patchable_jump(address target);
529 void general_jump(address target);
531 static int insts_for_patchable_call(address target);
532 static int insts_for_general_call(address target);
534 static int insts_for_patchable_jump(address target);
535 static int insts_for_general_jump(address target);
537 // Floating
538 // Data
540 // Argument ops
541 inline void store_int_argument(Register s, Argument &a) {
542 if(a.is_Register()) {
543 move(a.as_Register(), s);
544 } else {
545 sw(s, a.as_caller_address());
546 }
547 }
549 inline void store_long_argument(Register s, Argument &a) {
550 Argument a1 = a.successor();
551 if(a.is_Register() && a1.is_Register()) {
552 move(a.as_Register(), s);
553 move(a.as_Register(), s);
554 } else {
555 sd(s, a.as_caller_address());
556 }
557 }
559 inline void store_float_argument(FloatRegister s, Argument &a) {
560 if(a.is_Register()) {
561 mov_s(a.as_FloatRegister(), s);
562 } else {
563 swc1(s, a.as_caller_address());
564 }
565 }
566 inline void store_double_argument(FloatRegister s, Argument &a) {
567 if(a.is_Register()) {
568 mov_d(a.as_FloatRegister(), s);
569 } else {
570 sdc1(s, a.as_caller_address());
571 }
572 }
574 inline void store_ptr_argument(Register s, Argument &a) {
575 if(a.is_Register()) {
576 move(a.as_Register(), s);
577 } else {
578 st_ptr(s, a.as_caller_address());
579 }
580 }
582 // Load and store values by size and signed-ness
583 void load_sized_value(Register dst, Address src, size_t size_in_bytes, bool is_signed, Register dst2 = noreg);
584 void store_sized_value(Address dst, Register src, size_t size_in_bytes, Register src2 = noreg);
586 // ld_ptr will perform lw for 32 bit VMs and ld for 64 bit VMs
587 // st_ptr will perform sw for 32 bit VMs and sd for 64 bit VMs
588 inline void ld_ptr(Register rt, Address a){
589 #ifdef _LP64
590 ld(rt, a.base(), a.disp());
591 #else
592 lw(rt, a.base(), a.disp());
593 #endif
594 }
595 inline void ld_ptr(Register rt, Register base, int offset16){
596 #ifdef _LP64
597 ld(rt, base, offset16);
598 #else
599 lw(rt, base, offset16);
600 #endif
602 }
603 inline void st_ptr(Register rt, Address a){
604 #ifdef _LP64
605 sd(rt, a.base(), a.disp());
606 #else
607 sw(rt, a.base(), a.disp());
608 #endif
609 }
610 inline void st_ptr(Register rt, Register base, int offset16) {
611 #ifdef _LP64
612 sd(rt, base, offset16);
613 #else
614 sw(rt, base, offset16);
615 #endif
616 }
618 void ld_ptr(Register rt, Register offset, Register base);
619 void st_ptr(Register rt, Register offset, Register base);
621 // ld_long will perform lw for 32 bit VMs and ld for 64 bit VMs
622 // st_long will perform sw for 32 bit VMs and sd for 64 bit VMs
623 inline void ld_long(Register rt, Register base, int offset16);
624 inline void st_long(Register rt, Register base, int offset16);
625 inline void ld_long(Register rt, Address a);
626 inline void st_long(Register rt, Address a);
627 void ld_long(Register rt, Register offset, Register base);
628 void st_long(Register rt, Register offset, Register base);
630 // swap the two byte of the low 16-bit halfword
631 // this directive will use AT, be sure the high 16-bit of reg is zero
632 void hswap(Register reg);
633 void huswap(Register reg);
635 // convert big endian integer to little endian integer
636 void swap(Register reg);
638 // implement the x86 instruction semantic
639 // if c_reg == *dest then *dest <= x_reg
640 // else c_reg <= *dest
641 // the AT indicate if xchg occurred, 1 for xchged, else 0
642 void cmpxchg(Register x_reg, Address dest, Register c_reg);
643 #ifdef _LP64
644 void cmpxchg32(Register x_reg, Address dest, Register c_reg);
645 #endif
646 void cmpxchg8(Register x_regLo, Register x_regHi, Address dest, Register c_regLo, Register c_regHi);
648 //pop & push, added by aoqi
649 #ifdef _LP64
650 void extend_sign(Register rh, Register rl) { stop("extend_sign"); }
651 void neg(Register reg) { dsubu(reg, R0, reg); }
652 void push (Register reg) { sd (reg, SP, -8); daddi(SP, SP, -8); }
653 void push (FloatRegister reg) { sdc1(reg, SP, -8); daddi(SP, SP, -8); }
654 void pop (Register reg) { ld (reg, SP, 0); daddi(SP, SP, 8); }
655 void pop (FloatRegister reg) { ldc1(reg, SP, 0); daddi(SP, SP, 8); }
656 void pop () { daddi(SP, SP, 8); }
657 void pop2 () { daddi(SP, SP, 16); }
658 #else
659 void extend_sign(Register rh, Register rl) { sra(rh, rl, 31); }
660 void neg(Register reg) { subu(reg, R0, reg); }
661 void push (Register reg) { sw (reg, SP, -4); addi(SP, SP, -4); }
662 void push (FloatRegister reg) { swc1(reg, SP, -4); addi(SP, SP, -4); }
663 void pop (Register reg) { lw (reg, SP, 0); addi(SP, SP, 4); }
664 void pop (FloatRegister reg) { lwc1(reg, SP, 0); addi(SP, SP, 4); }
665 void pop () { addi(SP, SP, 4); }
666 void pop2 () { addi(SP, SP, 8); }
667 #endif
668 void push2(Register reg1, Register reg2);
669 void pop2 (Register reg1, Register reg2);
670 void dpush (Register reg) { sd (reg, SP, -8); daddi(SP, SP, -8); }
671 void dpop (Register reg) { ld (reg, SP, 0); daddi(SP, SP, 8); }
672 //we need 2 fun to save and resotre general register
673 void pushad();
674 void popad();
676 //move an 32-bit immediate to Register
677 void move(Register reg, int imm32) { li32(reg, imm32); }
678 void li (Register rd, long imm);
679 void li (Register rd, address addr) { li(rd, (long)addr); }
680 //replace move(Register reg, int imm)
681 void li32(Register rd, int imm32); // sign-extends to 64 bits on mips64
682 #ifdef _LP64
683 void set64(Register d, jlong value);
684 static int insts_for_set64(jlong value);
686 void patchable_set48(Register d, jlong value);
687 void patchable_set32(Register d, jlong value);
689 void patchable_call32(Register d, jlong value);
691 static int call_size(address target, bool far, bool patchable);
693 static bool reachable_from_cache(address target);
696 void dli(Register rd, long imm) { li(rd, imm); }
697 void li64(Register rd, long imm);
698 void li48(Register rd, long imm);
699 #endif
701 #ifdef _LP64
702 void move(Register rd, Register rs) { dadd(rd, rs, R0); }
703 void move_u32(Register rd, Register rs) { addu32(rd, rs, R0); }
704 #else
705 void move(Register rd, Register rs) { add(rd, rs, R0); }
706 #endif
707 void dmove(Register rd, Register rs) { dadd(rd, rs, R0); }
710 #ifndef PRODUCT
711 static void pd_print_patched_instruction(address branch) {
712 jint stub_inst = *(jint*) branch;
713 print_instruction(stub_inst);
714 ::tty->print("%s", " (unresolved)");
716 }
717 #endif
719 //FIXME
720 void empty_FPU_stack(){/*need implemented*/};
723 // method handles (JSR 292)
724 Address argument_address(RegisterOrConstant arg_slot, int extra_slot_offset = 0);
726 #undef VIRTUAL
728 };
730 /**
731 * class SkipIfEqual:
732 *
733 * Instantiating this class will result in assembly code being output that will
734 * jump around any code emitted between the creation of the instance and it's
735 * automatic destruction at the end of a scope block, depending on the value of
736 * the flag passed to the constructor, which will be checked at run-time.
737 */
738 class SkipIfEqual {
739 private:
740 MacroAssembler* _masm;
741 Label _label;
743 public:
744 SkipIfEqual(MacroAssembler*, const bool* flag_addr, bool value);
745 ~SkipIfEqual();
746 };
748 #ifdef ASSERT
749 inline bool AbstractAssembler::pd_check_instruction_mark() { return true; }
750 #endif
753 #endif // CPU_MIPS_VM_MACROASSEMBLER_MIPS_HPP