1 #ifndef __MONO_MINI_SPARC_H__
2 #define __MONO_MINI_SPARC_H__
4 #include <mono/arch/sparc/sparc-codegen.h>
8 #define MONO_ARCH_CPU_SPEC sparc_desc
10 #define MONO_MAX_IREGS 32
11 #define MONO_MAX_FREGS 32
13 /* Parameters used by the register allocator */
16 * Use %o0..%o5 as local registers, plus %l7 since we need an extra register for
17 * holding the sreg1 in call instructions.
19 #define MONO_ARCH_CALLEE_REGS ((1 << sparc_o0) | (1 << sparc_o1) | (1 << sparc_o2) | (1 << sparc_o3) | (1 << sparc_o4) | (1 << sparc_o5) | (1 << sparc_l7))
21 #define MONO_ARCH_CALLEE_SAVED_REGS ((~MONO_ARCH_CALLEE_REGS) & ~(1 << sparc_g1))
24 /* Use %d34..%d62 as the double precision floating point local registers */
25 /* %d32 has the same encoding as %f1, so %d36%d38 == 0b1010 == 0xa */
26 #define MONO_ARCH_CALLEE_FREGS (0xaaaaaaa8)
28 /* Use %f2..%f30 as the double precision floating point local registers */
29 #define MONO_ARCH_CALLEE_FREGS (0x55555554)
32 #define MONO_ARCH_CALLEE_SAVED_FREGS 0
34 #define MONO_ARCH_USE_FPSTACK FALSE
35 #define MONO_ARCH_FPSTACK_SIZE 0
37 #define MONO_ARCH_INST_FIXED_REG(desc) ((desc == 'o') ? sparc_o0 : -1)
39 #define MONO_ARCH_INST_FIXED_REG(desc) ((desc == 'o') ? sparc_o0 : ((desc == 'l') ? sparc_o1 : -1))
41 #define MONO_ARCH_INST_SREG2_MASK(ins) (0)
44 #define MONO_ARCH_INST_IS_REGPAIR(desc) FALSE
45 #define MONO_ARCH_INST_REGPAIR_REG2(desc,hreg1) (-1)
47 #define MONO_ARCH_INST_IS_REGPAIR(desc) ((desc == 'l') || (desc == 'L'))
48 #define MONO_ARCH_INST_REGPAIR_REG2(desc,hreg1) (((desc == 'l') ? sparc_o0 : (desc == 'L' ? (hreg1 + 1) : -1)))
51 #if SIZEOF_VOID_P == 8
52 #define MONO_ARCH_FRAME_ALIGNMENT 16
54 #define MONO_ARCH_FRAME_ALIGNMENT 8
57 #define MONO_ARCH_CODE_ALIGNMENT 32
59 #define MONO_ARCH_RETREG1 sparc_i0
62 #define MONO_SPARC_STACK_BIAS 2047
64 #define MONO_SPARC_STACK_BIAS 0
68 gpointer previous_lmf
;
76 typedef struct MonoContext
{
82 typedef struct MonoCompileArch
{
84 gint32 localloc_offset
;
85 void *float_spill_slot
;
88 #define MONO_CONTEXT_SET_IP(ctx,eip) do { (ctx)->ip = (gpointer)(eip); } while (0);
89 #define MONO_CONTEXT_SET_BP(ctx,ebp) do { (ctx)->fp = (gpointer*)(ebp); } while (0);
90 #define MONO_CONTEXT_SET_SP(ctx,esp) do { (ctx)->sp = (gpointer*)(esp); } while (0);
92 #define MONO_CONTEXT_GET_IP(ctx) ((gpointer)((ctx)->ip))
93 #define MONO_CONTEXT_GET_BP(ctx) ((gpointer)((ctx)->fp))
94 #define MONO_CONTEXT_GET_SP(ctx) ((gpointer)((ctx)->sp))
96 #define MONO_INIT_CONTEXT_FROM_FUNC(ctx,start_func) do { \
97 mono_arch_flush_register_windows (); \
98 MONO_CONTEXT_SET_IP ((ctx), (start_func)); \
99 MONO_CONTEXT_SET_BP ((ctx), __builtin_frame_address (0)); \
100 MONO_CONTEXT_SET_SP ((ctx), __builtin_frame_address (0)); \
105 * Can't use sigaction on sparc/linux, since it doesn't support SA_SIGINFO. Instead, we
106 * have to use the obsolete sigcontext parameter:
107 * http://www.ussg.iu.edu/hypermail/linux/kernel/0110.3/1531.html.
109 #define MONO_ARCH_USE_SIGACTION 1
112 #ifdef HAVE_WORKING_SIGALTSTACK
113 /*#define MONO_ARCH_SIGSEGV_ON_ALTSTACK*/
116 #define MONO_ARCH_EMULATE_FCONV_TO_I8 1
117 #define MONO_ARCH_EMULATE_LCONV_TO_R8 1
118 #define MONO_ARCH_EMULATE_LCONV_TO_R4 1
119 #define MONO_ARCH_EMULATE_CONV_R8_UN 1
120 #define MONO_ARCH_EMULATE_LCONV_TO_R8_UN 1
121 #define MONO_ARCH_EMULATE_FREM 1
122 #define MONO_ARCH_NEED_DIV_CHECK 1
123 #define MONO_ARCH_HAVE_THROW_CORLIB_EXCEPTION 1
124 #define MONO_ARCH_HAVE_IMT 1
125 #define MONO_ARCH_IMT_REG sparc_g1
126 #define MONO_ARCH_HAVE_DECOMPOSE_LONG_OPTS 1
129 #define MONO_ARCH_NO_EMULATE_LONG_SHIFT_OPS
133 /* assume Sun compiler if not GCC */
134 static void * __builtin_return_address(int depth
)
138 asm("be retAddr_End");
140 asm("retAddr_Start:");
141 asm("sub %i0, 1, %i0");
143 asm("bne retAddr_Start");
145 asm("ldx [%l0+2159], %l0");
147 asm("ldx [%l0+2167], %i0");
149 asm("ld [%l0+56], %l0");
151 asm("ld [%l0+60], %i0");
155 static void * __builtin_frame_address(int depth
)
159 asm("be frameAddr_End");
161 asm("frameAddr_Start:");
162 asm("sub %i0, 1, %i0");
164 asm("bne frameAddr_Start");
166 asm("ldx [%l0+2159], %l0");
167 asm("frameAddr_End:");
168 asm("ldx [%l0+2159], %i0");
170 asm("ld [%l0+56], %l0");
171 asm("frameAddr_End:");
172 asm("ld [%l0+56], %i0");
177 gboolean
mono_sparc_is_virtual_call (guint32
*code
);
179 gpointer
* mono_sparc_get_vcall_slot_addr (guint32
*code
, mgreg_t
*regs
);
181 void mono_sparc_flushw (void);
183 gboolean
mono_sparc_is_v9 (void);
185 gboolean
mono_sparc_is_sparc64 (void);
189 guint32
* mono_sparc_emit_save_lmf (guint32
* code
, guint32 lmf_offset
);
191 guint32
* mono_sparc_emit_restore_lmf (guint32
*code
, guint32 lmf_offset
);
193 #endif /* __MONO_MINI_SPARC_H__ */