Transition s390/mips/ia64 to use mono_arch_find_jit_info_ext.
[mono.git] / mono / mini / mini-ia64.h
1 #ifndef __MONO_MINI_IA64_H__
2 #define __MONO_MINI_IA64_H__
3
4 #include <glib.h>
5
6 #include <mono/arch/ia64/ia64-codegen.h>
7
8 #define MONO_ARCH_CPU_SPEC ia64_desc
9
10 /* FIXME: regset -> 128 bits ! */
11
12 #define MONO_MAX_IREGS 128
13 #define MONO_MAX_FREGS 128
14
15 /* Parameters used by the register allocator */
16
17 /* r8..r11, r14..r29 */
18 #define MONO_ARCH_CALLEE_REGS ((regmask_t)(0xf00UL) | (regmask_t)(0x3fffc000UL))
19
20 /* f6..f15, f34..f127 */
21 /* FIXME: Use the upper 64 bits as well */
22 #define MONO_ARCH_CALLEE_FREGS ((regmask_t)(0xfffffffc00000000UL) | ((regmask_t)(0x3ffUL) << 6))
23
24 #define MONO_ARCH_CALLEE_SAVED_REGS ~(MONO_ARCH_CALLEE_REGS)
25
26 #define MONO_ARCH_CALLEE_SAVED_FREGS 0
27
28 #define MONO_ARCH_USE_FPSTACK FALSE
29 #define MONO_ARCH_FPSTACK_SIZE 0
30
31 #define MONO_ARCH_INST_FIXED_REG(desc) ((desc == 'r') ? IA64_R8 : ((desc == 'g') ? 8 : -1))
32 #define MONO_ARCH_INST_IS_FLOAT(desc) ((desc == 'f') || (desc == 'g'))
33 #define MONO_ARCH_INST_SREG2_MASK(ins) (0)
34 #define MONO_ARCH_INST_IS_REGPAIR(desc) FALSE
35 #define MONO_ARCH_INST_REGPAIR_REG2(desc,hreg1) (-1)
36
37 #define MONO_ARCH_IS_GLOBAL_IREG(reg) (is_hard_ireg (reg) && ((reg) >= cfg->arch.reg_local0) && ((reg) < cfg->arch.reg_out0))
38
39 #define MONO_ARCH_FRAME_ALIGNMENT 16
40
41 #define MONO_ARCH_CODE_ALIGNMENT 16
42
43 #define MONO_ARCH_RETREG1 IA64_R8
44 #define MONO_ARCH_FRETREG1 8
45
46 #define MONO_ARCH_SIGNAL_STACK_SIZE SIGSTKSZ
47
48 struct MonoLMF {
49         guint64    ebp;
50 };
51
52 typedef struct MonoContext {
53         unw_cursor_t cursor;
54         /* Whenever the ip in 'cursor' points to the ip where the exception happened */
55         /* This is true for the initial context for exceptions thrown from signal handlers */
56         gboolean precise_ip;
57 } MonoContext;
58
59 typedef struct MonoCompileArch {
60         gint32 stack_alloc_size;
61         gint32 lmf_offset;
62         gint32 localloc_offset;
63         gint32 n_out_regs;
64         gint32 reg_in0;
65         gint32 reg_local0;
66         gint32 reg_out0;
67         gint32 reg_saved_ar_pfs;
68         gint32 reg_saved_b0;
69         gint32 reg_saved_sp;
70         gint32 reg_fp;
71         gint32 reg_saved_return_val;
72         guint32 prolog_end_offset, epilog_begin_offset, epilog_end_offset;
73         void *ret_var_addr_local;
74         unw_dyn_region_info_t *r_pro, *r_epilog;
75         void *last_bb;
76         Ia64CodegenState code;
77         gboolean omit_fp;
78         GHashTable *branch_targets;
79 } MonoCompileArch;
80
81 static inline unw_word_t
82 mono_ia64_context_get_ip (MonoContext *ctx)
83 {
84         unw_word_t ip;
85         int err;
86
87         err = unw_get_reg (&ctx->cursor, UNW_IA64_IP, &ip);
88         g_assert (err == 0);
89
90         if (ctx->precise_ip) {
91                 return ip;
92         } else {
93                 /* Subtrack 1 so ip points into the actual instruction */
94                 return ip - 1;
95         }
96 }
97
98 static inline unw_word_t
99 mono_ia64_context_get_sp (MonoContext *ctx)
100 {
101         unw_word_t sp;
102         int err;
103
104         err = unw_get_reg (&ctx->cursor, UNW_IA64_SP, &sp);
105         g_assert (err == 0);
106
107         return sp;
108 }
109
110 static inline unw_word_t
111 mono_ia64_context_get_fp (MonoContext *ctx)
112 {
113         unw_cursor_t new_cursor;
114         unw_word_t fp;
115         int err;
116
117         {
118                 unw_word_t ip, sp;
119
120                 err = unw_get_reg (&ctx->cursor, UNW_IA64_SP, &sp);
121                 g_assert (err == 0);
122
123                 err = unw_get_reg (&ctx->cursor, UNW_IA64_IP, &ip);
124                 g_assert (err == 0);
125         }
126
127         /* fp is the SP of the parent frame */
128         new_cursor = ctx->cursor;
129
130         err = unw_step (&new_cursor);
131         g_assert (err >= 0);
132
133         err = unw_get_reg (&new_cursor, UNW_IA64_SP, &fp);
134         g_assert (err == 0);
135
136         return fp;
137 }
138
139 #define MONO_CONTEXT_SET_IP(ctx,eip) do { int err = unw_set_reg (&(ctx)->cursor, UNW_IA64_IP, (unw_word_t)(eip)); g_assert (err == 0); } while (0)
140 #define MONO_CONTEXT_SET_BP(ctx,ebp) do { } while (0)
141 #define MONO_CONTEXT_SET_SP(ctx,esp) do { int err = unw_set_reg (&(ctx)->cursor, UNW_IA64_SP, (unw_word_t)(esp)); g_assert (err == 0); } while (0)
142
143 #define MONO_CONTEXT_GET_IP(ctx) ((gpointer)(mono_ia64_context_get_ip ((ctx))))
144 #define MONO_CONTEXT_GET_BP(ctx) ((gpointer)(mono_ia64_context_get_fp ((ctx))))
145 #define MONO_CONTEXT_GET_SP(ctx) ((gpointer)(mono_ia64_context_get_sp ((ctx))))
146
147 #define MONO_INIT_CONTEXT_FROM_FUNC(ctx,start_func) do {        \
148     MONO_INIT_CONTEXT_FROM_CURRENT (ctx); \
149 } while (0)
150
151 #define MONO_INIT_CONTEXT_FROM_CURRENT(ctx) do { \
152         int res; \
153         res = unw_getcontext (&unw_ctx); \
154         g_assert (res == 0); \
155         res = unw_init_local (&(ctx)->cursor, &unw_ctx); \
156         g_assert (res == 0); \
157 } while (0)
158
159 /* This is ia64 only */
160 #define MONO_CONTEXT_SET_FUNC(ctx, func) MONO_CONTEXT_SET_IP ((ctx), ((gpointer*)(func))[0])
161
162 #define MONO_ARCH_CONTEXT_DEF unw_context_t unw_ctx;
163
164 #define MONO_ARCH_USE_SIGACTION 1
165
166 #ifdef HAVE_WORKING_SIGALTSTACK
167 /*#define MONO_ARCH_SIGSEGV_ON_ALTSTACK*/
168 #endif
169
170 unw_dyn_region_info_t* mono_ia64_create_unwind_region (Ia64CodegenState *code);
171
172 #define MONO_ARCH_NO_EMULATE_LONG_SHIFT_OPS 1
173 #define MONO_ARCH_NO_EMULATE_MUL_IMM 1
174 #define MONO_ARCH_NO_EMULATE_MUL     1
175
176 #define MONO_ARCH_EMULATE_CONV_R8_UN     1
177 #define MONO_ARCH_EMULATE_LCONV_TO_R8_UN 1
178 #define MONO_ARCH_EMULATE_FREM           1
179 #define MONO_ARCH_EMULATE_MUL_DIV        1
180 #define MONO_ARCH_EMULATE_LONG_MUL_OPTS  1
181 #define MONO_ARCH_NEED_DIV_CHECK         1
182
183 #define MONO_ARCH_HAVE_IS_INT_OVERFLOW 1
184
185 #define MONO_ARCH_HAVE_INVALIDATE_METHOD 1
186 #define MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE 1
187 #define MONO_ARCH_HAVE_SAVE_UNWIND_INFO 1
188 #define MONO_ARCH_HAVE_ATOMIC_EXCHANGE 1
189 #define MONO_ARCH_HAVE_IMT 1
190 #define MONO_ARCH_HAVE_GENERALIZED_IMT_THUNK 1
191 #define MONO_ARCH_THIS_AS_FIRST_ARG 1
192 #define MONO_ARCH_HAVE_FIND_JIT_INFO_EXT 1
193
194 #endif /* __MONO_MINI_IA64_H__ */