1 #ifndef __MONO_MINI_S390X_H__
2 #define __MONO_MINI_S390X_H__
4 #include <mono/arch/s390x/s390x-codegen.h>
5 #include <mono/utils/mono-context.h>
8 #define MONO_ARCH_CPU_SPEC mono_s390x_cpu_desc
10 #define MONO_MAX_IREGS 16
11 #define MONO_MAX_FREGS 16
13 /*-------------------------------------------*/
14 /* Parameters used by the register allocator */
15 /*-------------------------------------------*/
18 gpointer previous_lmf
;
28 typedef struct MonoCompileArch
{
42 // #define MONO_ARCH_SIGSEGV_ON_ALTSTACK 1
43 #define MONO_ARCH_EMULATE_LCONV_TO_R8_UN 1
44 #define MONO_ARCH_NO_EMULATE_LONG_MUL_OPTS 1
45 #define MONO_ARCH_NO_EMULATE_LONG_SHIFT_OPS 1
46 #define MONO_ARCH_HAVE_IS_INT_OVERFLOW 1
47 #define MONO_ARCH_NEED_DIV_CHECK 1
48 #define MONO_ARCH_SIGNAL_STACK_SIZE 256*1024
49 #define MONO_ARCH_HAVE_DECOMPOSE_OPTS 1
50 #define MONO_ARCH_HAVE_TLS_GET 1
51 #define MONO_ARCH_ENABLE_MONO_LMF_VAR 1
52 #define MONO_ARCH_IMT_REG s390_r9
53 #define MONO_ARCH_VTABLE_REG S390_FIRST_ARG_REG
54 #define MONO_ARCH_RGCTX_REG MONO_ARCH_IMT_REG
55 #define MONO_ARCH_HAVE_SIGCTX_TO_MONOCTX 1
56 #define MONO_ARCH_SOFT_DEBUG_SUPPORTED 1
57 #define MONO_ARCH_HAVE_CONTEXT_SET_INT_REG 1
58 #define MONO_ARCH_USE_SIGACTION 1
59 #define MONO_ARCH_GC_MAPS_SUPPORTED 1
60 #define MONO_ARCH_GSHARED_SUPPORTED 1
61 #define MONO_ARCH_MONITOR_ENTER_ADJUSTMENT 1
62 #define MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD 1
63 #define MONO_ARCH_HAVE_INVALIDATE_METHOD 1
64 #define MONO_ARCH_HAVE_OP_GENERIC_CLASS_INIT 1
65 #define MONO_ARCH_HAVE_SETUP_ASYNC_CALLBACK 1
67 #define S390_STACK_ALIGNMENT 8
68 #define S390_FIRST_ARG_REG s390_r2
69 #define S390_LAST_ARG_REG s390_r6
70 #define S390_FIRST_FPARG_REG s390_f0
71 #define S390_LAST_FPARG_REG s390_f6
73 /*===============================================*/
74 /* Definitions used by mini-codegen.c */
75 /*===============================================*/
77 /*------------------------------------------------------*/
78 /* use s390_r2-s390_r6 as parm registers */
79 /* s390_r0, s390_r1, s390_r12, s390_r13 used internally */
80 /* s390_r8..s390_r11 are used for global regalloc */
81 /* s390_r15 is the stack pointer */
82 /*------------------------------------------------------*/
84 #define MONO_ARCH_CALLEE_REGS (0xfc)
86 #define MONO_ARCH_CALLEE_SAVED_REGS 0xff80
88 /*----------------------------------------*/
89 /* use s390_f1/s390_f3-s390_f15 as temps */
90 /*----------------------------------------*/
92 #define MONO_ARCH_CALLEE_FREGS (0xfffe)
94 #define MONO_ARCH_CALLEE_SAVED_FREGS 0
96 #define MONO_ARCH_USE_FPSTACK FALSE
97 #define MONO_ARCH_FPSTACK_SIZE 0
99 #define MONO_ARCH_INST_FIXED_REG(desc) ((desc == 'o') ? s390_r2 : \
100 ((desc == 'g') ? s390_f0 : \
101 ((desc == 'A') ? S390_FIRST_ARG_REG : -1)))
103 #define MONO_ARCH_INST_IS_FLOAT(desc) ((desc == 'f') || (desc == 'g'))
105 #define MONO_ARCH_INST_SREG2_MASK(ins) (0)
107 #define MONO_ARCH_INST_IS_REGPAIR(desc) (0)
108 #define MONO_ARCH_INST_REGPAIR_REG2(desc,hr) -1
110 #define MONO_ARCH_IS_GLOBAL_IREG(reg) 0
112 #define MONO_ARCH_FRAME_ALIGNMENT 8
113 #define MONO_ARCH_CODE_ALIGNMENT 32
115 /*-----------------------------------------------*/
116 /* SIMD Related Definitions */
117 /*-----------------------------------------------*/
119 #define MONO_MAX_XREGS 31
120 #define MONO_ARCH_CALLEE_XREGS 0x0
121 #define MONO_ARCH_CALLEE_SAVED_XREGS 0x0
123 /*-----------------------------------------------*/
124 /* Macros used to generate instructions */
125 /*-----------------------------------------------*/
126 #define S390_OFFSET(b, t) (guchar *) ((guint64) (b) - (guint64) (t))
127 #define S390_RELATIVE(b, t) (guchar *) ((((guint64) (b) - (guint64) (t))) / 2)
129 #define CODEPTR(c, o) (o) = (short *) ((guint64) c - 2)
130 #define PTRSLOT(c, o) *(o) = (short) ((guint64) c - (guint64) (o) + 2)/2
133 #define S390_ALIGN(v, a) (((a) > 0 ? (((v) + ((a) - 1)) & ~((a) - 1)) : (v)))
135 #define MONO_INIT_CONTEXT_FROM_FUNC(ctx,func) do { \
136 MonoS390StackFrame *sframe; \
137 __asm__ volatile("lgr %0,15" : "=r" (sframe)); \
138 MONO_CONTEXT_SET_BP ((ctx), sframe->prev); \
139 MONO_CONTEXT_SET_SP ((ctx), sframe->prev); \
140 MONO_CONTEXT_SET_IP ((ctx), func); \
143 #define MONO_ARCH_INIT_TOP_LMF_ENTRY(lmf) do { (lmf)->ebp = -1; } while (0)
145 /*------------------------------------------------------------------*/
147 /* Name - s390_patch_rel */
149 /* Function - Patch the code with a given offset. */
151 /*------------------------------------------------------------------*/
154 s390_patch_rel (guchar
*code
, guint64 target
)
156 guint32
*offset
= (guint32
*) code
;
159 *offset
= (guint32
) target
;
163 /*========================= End of Function ========================*/
165 /*------------------------------------------------------------------*/
167 /* Name - s390_patch_addr */
169 /* Function - Patch the code with a given address. */
171 /*------------------------------------------------------------------*/
174 s390_patch_addr (guchar
*code
, guint64 target
)
176 guint64
*offset
= (guint64
*) code
;
183 /*========================= End of Function ========================*/
185 /*------------------------------------------------------------------*/
187 /* Name - restoreLMF */
189 /* Function - Restore the LMF state prior to exiting a method. */
191 /*------------------------------------------------------------------*/
193 #define restoreLMF(code, frame_reg, stack_usage) do \
197 s390_lgr (code, s390_r13, frame_reg); \
199 lmfOffset = stack_usage - sizeof(MonoLMF); \
201 /*-------------------------------------------------*/ \
203 /*-------------------------------------------------*/ \
204 s390_aghi (code, s390_r13, lmfOffset); \
206 /*-------------------------------------------------*/ \
207 /* r6 = &jit_tls->lmf */ \
208 /*-------------------------------------------------*/ \
209 s390_lg (code, s390_r6, 0, s390_r13, \
210 G_STRUCT_OFFSET(MonoLMF, lmf_addr)); \
212 /*-------------------------------------------------*/ \
213 /* r0 = lmf.previous_lmf */ \
214 /*-------------------------------------------------*/ \
215 s390_lg (code, s390_r0, 0, s390_r13, \
216 G_STRUCT_OFFSET(MonoLMF, previous_lmf)); \
218 /*-------------------------------------------------*/ \
219 /* jit_tls->lmf = previous_lmf */ \
220 /*-------------------------------------------------*/ \
221 s390_lg (code, s390_r13, 0, s390_r6, 0); \
222 s390_stg (code, s390_r0, 0, s390_r6, 0); \
225 /*========================= End of Function ========================*/
227 #endif /* __MONO_MINI_S390X_H__ */