2003-10-09 Dick Porter <dick@ximian.com>
[mono.git] / mono / mini / mini.h
1 #ifndef __MONO_MINI_H__
2 #define __MONO_MINI_H__
3
4 #include <glib.h>
5 #include <signal.h>
6 #include <mono/metadata/loader.h>
7 #include <mono/metadata/mempool.h>
8 #include <mono/utils/monobitset.h>
9 #include <mono/metadata/class.h>
10 #include <mono/metadata/object.h>
11 #include <mono/metadata/opcodes.h>
12 #include <mono/metadata/tabledefs.h>
13 #include <mono/metadata/profiler-private.h>
14
15 #include "mini-arch.h"
16 #include "regalloc.h"
17
18 #define MONO_USE_AOT_COMPILER
19
20 /* Version number of the AOT file format */
21 #define MONO_AOT_FILE_VERSION "6"
22
23 #if 1
24 #define mono_bitset_test_fast(set,n) (((guint32*)set)[2+(n)/32] & (1 << ((n) % 32)))
25 #else
26 #define mono_bitset_test_fast(set,n) mono_bitset_test(set,n)
27 #endif
28
29 #if 0
30 #define mono_bitset_foreach_bit(set,b,n) \
31         for (b = 0; b < n; b++)\
32                 if (mono_bitset_test_fast(set,b))
33 #define mono_bitset_foreach_bit_rev(set,b,n) \
34         for (b = n - 1; b >= 0; b--)\
35                 if (mono_bitset_test_fast(set,b))
36 #else
37 #define mono_bitset_foreach_bit(set,b,n) \
38         for (b = mono_bitset_find_first (set, -1); b < n && b >= 0; b = mono_bitset_find_first (set, b))
39 #define mono_bitset_foreach_bit_rev(set,b,n) \
40         for (b = mono_bitset_find_last (set, n - 1); b >= 0; b = b ? mono_bitset_find_last (set, b) : -1)
41  
42 #endif
43
44 /*
45  * Pull the list of opcodes
46  */
47 #define OPDEF(a,b,c,d,e,f,g,h,i,j) \
48         a = i,
49
50 enum {
51 #include "mono/cil/opcode.def"
52         CEE_LASTOP
53 };
54 #undef OPDEF
55
56 #define MONO_VARINFO(cfg,varnum) ((cfg)->vars [varnum])
57
58 #define MONO_INST_NEW(cfg,dest,op) do { \
59                 (dest) = mono_mempool_alloc0 ((cfg)->mempool, sizeof (MonoInst));       \
60                 (dest)->opcode = (op);  \
61         } while (0)
62
63 #define MONO_INST_NEW_CALL(cfg,dest,op) do {    \
64                 (dest) = mono_mempool_alloc0 ((cfg)->mempool, sizeof (MonoCallInst));   \
65                 (dest)->inst.opcode = (op);     \
66         } while (0)
67
68 #define MONO_ADD_INS(b,inst) do {       \
69                 if ((b)->last_ins) {    \
70                         (b)->last_ins->next = (inst);   \
71                         (b)->last_ins = (inst); \
72                 } else {        \
73                         (b)->code = (b)->last_ins = (inst);     \
74                 }       \
75         } while (0)
76
77 typedef struct MonoInst MonoInst;
78 typedef struct MonoCallInst MonoCallInst;
79 typedef struct MonoEdge MonoEdge;
80 typedef struct MonoMethodVar MonoMethodVar;
81 typedef struct MonoBasicBlock MonoBasicBlock;
82 typedef struct MonoLMF MonoLMF;
83 typedef struct MonoSpillInfo MonoSpillInfo;
84
85 extern guint32 mono_jit_tls_id;
86 extern gboolean mono_jit_trace_calls;
87 extern gboolean mono_break_on_exc;
88 extern int mono_exc_esp_offset;
89 extern gboolean mono_compile_aot;
90
91 struct MonoEdge {
92         MonoEdge *next;
93         MonoBasicBlock *bb;
94         /* add edge type? */
95 };
96
97 struct MonoSpillInfo {
98         MonoSpillInfo *next;
99         int offset;
100 };
101
102 /*
103  * The IR-level basic block.  
104  *
105  * A basic block can have multiple exits just fine, as long as the point of
106  * 'departure' is the last instruction in the basic block. Extended basic
107  * blocks, on the other hand, may have instructions that leave the block
108  * midstream. The important thing is that they cannot be _entered_
109  * midstream, ie, execution of a basic block (or extened bb) always start
110  * at the beginning of the block, never in the middle.
111  */
112 struct MonoBasicBlock {
113         MonoInst *last_ins;
114
115         /* Points to the start of the CIL code that initiated this BB */
116         unsigned char* cil_code;
117
118         /* Length of the CIL block */
119         gint32 cil_length;
120
121         /* The address of the generated code, used for fixups */
122         int native_offset;
123         int max_offset;
124         
125         gint32 dfn;
126
127         /* unique block number identification */
128         gint32 block_num;
129
130         /* Visited and reachable flags */
131         guint32 flags;
132
133         /* Basic blocks: incoming and outgoing counts and pointers */
134         gint16 out_count, in_count;
135         MonoBasicBlock **in_bb;
136         MonoBasicBlock **out_bb;
137
138         /* the next basic block in the order it appears in IL */
139         MonoBasicBlock *next_bb;
140
141         /*
142          * Before instruction selection it is the first tree in the
143          * forest and the first item in the list of trees. After
144          * instruction selection it is the first instruction and the
145          * first item in the list of instructions.
146          */
147         MonoInst *code;
148
149         /*
150          * SSA and loop based flags
151          */
152         MonoBitSet *dominators;
153         MonoBitSet *dfrontier;
154         MonoBasicBlock *idom;
155         GList *dominated;
156         /* fast dominator algorithm */
157         MonoBasicBlock *df_parent, *ancestor, *child, *label;
158         MonoEdge *bucket;
159         int size, sdom, idomn;
160         
161         /* loop nesting and recognition */
162         GList *loop_blocks;
163         gint8  nesting;
164
165         /* use for liveness analysis */
166         MonoBitSet *gen_set;
167         MonoBitSet *kill_set;
168         MonoBitSet *live_in_set;
169         MonoBitSet *live_out_set;
170
171         /* fields to deal with non-empty stack slots at bb boundary */
172         guint16 out_scount, in_scount;
173         MonoInst **out_stack;
174         MonoInst **in_stack;
175
176         /* we use that to prevent merging of bblock covered by different clauses*/
177         guint real_offset;
178         guint region;
179
180         /* The current symbolic register number, used in local register allocation. */
181         guint32 max_ireg, max_freg;
182 };
183
184 /* BBlock flags */
185 #define BB_VISITED 1
186 #define BB_REACHABLE 2
187
188 struct MonoInst {
189         union {
190                 union {
191                         MonoInst *src;
192                         MonoMethodVar *var;
193                         gssize const_val;
194                         gpointer p;
195                         MonoMethod *method;
196                         MonoMethodSignature *signature;
197                         MonoBasicBlock **many_blocks;
198                         MonoBasicBlock *target_block;
199                         MonoInst **args;
200                         MonoType *vtype;
201                         MonoClass *klass;
202                         int *phi_args;
203                 } op [2];
204                 gint64 i8const;
205                 double r8const;
206         } data;
207         guint16 opcode;
208         guint8  type; /* stack type */
209         guint   ssa_op : 3;
210         guint8  flags  : 5;
211         
212         /* used by the register allocator */
213         gint32 dreg, sreg1, sreg2, unused;
214         
215         MonoInst *next;
216         MonoClass *klass;
217         const unsigned char* cil_code; /* for debugging and bblock splitting */
218 };
219         
220 struct MonoCallInst {
221         MonoInst inst;
222         MonoMethodSignature *signature;
223         MonoMethod *method;
224         MonoInst **args;
225         MonoInst *out_args;
226         gconstpointer fptr;
227         guint stack_usage;
228         regmask_t used_iregs;
229         regmask_t used_fregs;
230 };
231
232 /* 
233  * flags for MonoInst
234  * Note: some of the values overlap, because they can't appear
235  * in the same MonoInst.
236  */
237 enum {
238         MONO_INST_HAS_METHOD = 1,
239         /* temp local created by a DUP: used only within a BB */
240         MONO_INST_IS_TEMP    = 1,
241         MONO_INST_INIT       = 1, /* in localloc */
242         MONO_INST_IS_DEAD    = 2,
243         MONO_INST_TAILCALL   = 4,
244         MONO_INST_VOLATILE   = 4,
245         MONO_INST_BRLABEL    = 4,
246         MONO_INST_NOTYPECHECK    = 4,
247         MONO_INST_UNALIGNED  = 8,
248         /* the address of the variable has been taken */
249         MONO_INST_INDIRECT   = 16,
250         MONO_INST_NORANGECHECK   = 16
251 };
252
253 #define inst_c0 data.op[0].const_val
254 #define inst_c1 data.op[1].const_val
255 #define inst_i0 data.op[0].src
256 #define inst_i1 data.op[1].src
257 #define inst_p0 data.op[0].p
258 #define inst_p1 data.op[1].p
259 #define inst_l  data.i8const
260 #define inst_r  data.r8const
261 #define inst_left  data.op[0].src
262 #define inst_right data.op[1].src
263
264 #define inst_newa_len   data.op[0].src
265 #define inst_newa_class data.op[1].klass
266
267 #define inst_switch data.op[0].switch_blocks
268 #define inst_var    data.op[0].var
269 #define inst_vtype  data.op[1].vtype
270 /* in branch instructions */
271 #define inst_many_bb   data.op[1].many_blocks
272 #define inst_target_bb data.op[0].target_block
273 #define inst_true_bb   data.op[1].many_blocks[0]
274 #define inst_false_bb  data.op[1].many_blocks[1]
275
276 #define inst_basereg sreg1
277 #define inst_indexreg sreg2
278 #define inst_destbasereg dreg
279 #define inst_offset data.op[0].const_val
280 #define inst_imm    data.op[1].const_val
281
282 #define inst_phi_args   data.op[1].phi_args
283
284 /* instruction description for use in regalloc/scheduling */
285 enum {
286         MONO_INST_DEST,
287         MONO_INST_SRC1,
288         MONO_INST_SRC2,
289         MONO_INST_FLAGS,
290         MONO_INST_CLOB,
291         MONO_INST_COST,
292         MONO_INST_DELAY,
293         MONO_INST_RES,
294         MONO_INST_LEN,
295         MONO_INST_MAX
296 };
297
298 typedef union {
299         struct {
300                 guint16 tid; /* tree number */
301                 guint16 bid; /* block number */
302         } pos ;
303         guint32 abs_pos; 
304 } MonoPosition;
305
306 typedef struct {
307         MonoPosition first_use, last_use;
308 } MonoLiveRange;
309
310 /*
311  * Additional information about a variable
312  */
313 struct MonoMethodVar {
314         guint           idx; /* inside cfg->varinfo, cfg->vars */
315         guint           last_name;
316         MonoBitSet     *dfrontier;
317         MonoLiveRange   range; /* generated by liveness analysis */
318         int             reg; /* != -1 if allocated into a register */
319         int             spill_costs;
320         MonoBitSet     *def_in; /* used by SSA */
321         MonoInst       *def;    /* used by SSA */
322         MonoBasicBlock *def_bb; /* used by SSA */
323         GList          *uses;   /* used by SSA */
324         char            cpstate;  /* used by SSA conditional  constant propagation */
325 };
326
327 typedef struct {
328         gpointer          end_of_stack;
329         MonoLMF          *lmf;
330         MonoLMF          *first_lmf;
331         void            (*abort_func) (MonoObject *object);
332 } MonoJitTlsData;
333
334 typedef enum {
335         MONO_PATCH_INFO_BB,
336         MONO_PATCH_INFO_ABS,
337         MONO_PATCH_INFO_LABEL,
338         MONO_PATCH_INFO_METHOD,
339         MONO_PATCH_INFO_METHOD_JUMP,
340         MONO_PATCH_INFO_METHOD_REL,
341         MONO_PATCH_INFO_METHODCONST,
342         MONO_PATCH_INFO_INTERNAL_METHOD,
343         MONO_PATCH_INFO_SWITCH,
344         MONO_PATCH_INFO_EXC,
345         MONO_PATCH_INFO_EXC_NAME,
346         MONO_PATCH_INFO_CLASS,
347         MONO_PATCH_INFO_IMAGE,
348         MONO_PATCH_INFO_FIELD,
349         MONO_PATCH_INFO_VTABLE,
350         MONO_PATCH_INFO_CLASS_INIT,
351         MONO_PATCH_INFO_SFLDA,
352         MONO_PATCH_INFO_LDSTR,
353         MONO_PATCH_INFO_LDTOKEN,
354         MONO_PATCH_INFO_TYPE_FROM_HANDLE,
355         MONO_PATCH_INFO_R4,
356         MONO_PATCH_INFO_R8,
357         MONO_PATCH_INFO_IP,
358         MONO_PATCH_INFO_IID,
359         MONO_PATCH_INFO_WRAPPER
360 } MonoJumpInfoType;
361
362 /*
363  * We need to store the image which the token refers to along with the token,
364  * since the image might not be the same as the image of the method which
365  * contains the relocation, because of inlining.
366  */
367 typedef struct MonoJumpInfoToken {
368         MonoImage *image;
369         guint32 token;
370 } MonoJumpInfoToken;
371
372 typedef struct MonoJumpInfo MonoJumpInfo;
373 struct MonoJumpInfo {
374         MonoJumpInfo *next;
375         union {
376                 int i;
377                 guint8 *p;
378                 MonoInst *label;
379         } ip;
380
381         MonoJumpInfoType type;
382         union {
383                 gconstpointer   target;
384                 int             offset;
385                 MonoBasicBlock *bb;
386                 MonoBasicBlock **table;
387                 MonoInst       *inst;
388                 MonoMethod     *method;
389                 MonoClass      *klass;
390                 MonoClassField *field;
391                 MonoImage      *image;
392                 MonoVTable     *vtable;
393                 const char     *name;
394                 MonoJumpInfoToken  *token;
395         } data;
396
397         int table_size; /* use by switch */
398 };
399
400 /* optimization flags: keep up to date with the name array in driver.c */
401 enum {
402         MONO_OPT_PEEPHOLE = 1 << 0,
403         MONO_OPT_BRANCH   = 1 << 1,
404         MONO_OPT_INLINE   = 1 << 2,
405         MONO_OPT_CFOLD    = 1 << 3,
406         MONO_OPT_CONSPROP = 1 << 4,
407         MONO_OPT_COPYPROP = 1 << 5,
408         MONO_OPT_DEADCE   = 1 << 6,
409         MONO_OPT_LINEARS  = 1 << 7,
410         MONO_OPT_CMOV     = 1 << 8,
411         MONO_OPT_SHARED   = 1 << 9,
412         MONO_OPT_SCHED    = 1 << 10,
413         MONO_OPT_INTRINS  = 1 << 11,
414         MONO_OPT_TAILC    = 1 << 12,
415         MONO_OPT_LOOP     = 1 << 13,
416         MONO_OPT_FCMOV    = 1 << 14,
417         MONO_OPT_LEAF     = 1 << 15,
418         MONO_OPT_AOT      = 1 << 16,
419         MONO_OPT_PRECOMP  = 1 << 17
420 };
421
422 #define MONO_REGION_FINALLY  16
423 #define MONO_REGION_CATCH    32
424 #define MONO_REGION_FAULT    64
425 #define MONO_REGION_FILTER  128
426
427 /*
428  * Control Flow Graph and compilation unit information
429  */
430 typedef struct {
431         MonoMethod      *method;
432         MonoMemPool     *mempool;
433         MonoInst       **varinfo;
434         MonoMethodVar  **vars;
435         MonoInst        *ret;
436         MonoBasicBlock  *bb_entry;
437         MonoBasicBlock  *bb_exit;
438         MonoBasicBlock  *bb_init;
439         MonoBasicBlock **bblocks;
440         GHashTable      *bb_hash;
441         MonoMemPool     *state_pool; /* used by instruction selection */
442         MonoBasicBlock  *cbb;        /* used by instruction selection */
443         MonoInst        *prev_ins;   /* in decompose */
444         MonoJumpInfo    *patch_info;
445         MonoJitInfo     *jit_info;
446         guint            num_bblocks;
447         guint            locals_start;
448         guint            num_varinfo; /* used items in varinfo */
449         guint            varinfo_count; /* total storage in varinfo */
450         gint             stack_offset;
451         MonoRegState    *rs;
452         MonoSpillInfo   *spill_info;
453         gint             spill_count;
454         // unsigned char   *cil_code;
455
456         MonoInst        *exvar; /* the exception object passed to catch/filter blocks */
457         MonoInst        *domainvar; /* a cache for the current domain */
458         /* A hashtable of region ID-> SP var mappings */
459     /* An SP var is a place to store the stack pointer (used by handlers) */
460         GHashTable      *spvars;
461
462         GList           *ldstr_list; /* used by AOT */
463         
464         MonoDomain      *domain;
465
466         unsigned char   *native_code;
467         guint            code_size;
468         guint            code_len;
469         guint            prolog_end;
470         guint            epilog_begin;
471         regmask_t        used_int_regs;
472         guint32          opt;
473         guint32          prof_options;
474         guint32          flags;
475         guint32          comp_done;
476         guint32          verbose_level;
477         guint32          stack_usage;
478         guint32          param_area;
479         guint32          frame_reg;
480         gint32           sig_cookie;
481         gboolean         disable_aot;
482         gboolean         disable_ssa;
483         gpointer         debug_info;
484         guint16          *intvars;
485         MonoProfileCoverageInfo *coverage_info;
486 #ifdef __ia64
487         guint8           ins, locals, outs; /* reg stack region sizes */
488 #endif /* __ia64 */
489 } MonoCompile;
490
491 typedef enum {
492         MONO_CFG_HAS_ALLOCA = 1 << 0,
493         MONO_CFG_HAS_CALLS  = 1 << 1
494 } MonoCompileFlags;
495
496 typedef struct {
497         gulong methods_compiled;
498         gulong methods_aot;
499         gulong methods_lookups;
500         gulong method_trampolines;
501         gulong allocate_var;
502         gulong analyze_stack_repeat;
503         gulong cil_code_size;
504         gulong native_code_size;
505         gulong code_reallocs;
506         gulong max_code_size_ratio;
507         gulong biggest_method_size;
508         gulong allocated_code_size;
509         gulong inlineable_methods;
510         gulong inlined_methods;
511         gulong basic_blocks;
512         gulong max_basic_blocks;
513         MonoMethod *max_ratio_method;
514         MonoMethod *biggest_method;
515         gboolean enabled;
516 } MonoJitStats;
517
518 extern MonoJitStats mono_jit_stats;
519
520 /* values for MonoInst.ssa_op */
521 enum {
522         MONO_SSA_NOP,
523         MONO_SSA_LOAD,
524         MONO_SSA_STORE,
525         MONO_SSA_MAYBE_LOAD,
526         MONO_SSA_MAYBE_STORE
527 };
528
529 #define OP_CEQ    (256+CEE_CEQ)
530 #define OP_CLT    (256+CEE_CLT)
531 #define OP_CLT_UN (256+CEE_CLT_UN)
532 #define OP_CGT    (256+CEE_CGT)
533 #define OP_CGT_UN (256+CEE_CGT_UN)
534 #define OP_LOCALLOC (256+CEE_LOCALLOC)
535
536 /* opcodes: value assigned after all the CIL opcodes */
537 #ifdef MINI_OP
538 #undef MINI_OP
539 #endif
540 #define MINI_OP(a,b) a,
541 enum {
542         OP_START = MONO_CEE_LAST,
543 #include "mini-ops.h"
544         OP_LAST
545 };
546 #undef MINI_OP
547
548 /* make this depend on 32bit platform (use OP_LADD otherwise) */
549 #define OP_PADD CEE_ADD
550 #define OP_PNEG CEE_NEG
551 #define OP_PCONV_TO_U2 CEE_CONV_U2
552 #define OP_PCONV_TO_OVF_I1_UN CEE_CONV_OVF_I1_UN
553 #define OP_PCONV_TO_OVF_I1 CEE_CONV_OVF_I1
554 #define OP_PCEQ CEE_CEQ
555
556 typedef enum {
557         STACK_INV,
558         STACK_I4,
559         STACK_I8,
560         STACK_PTR,
561         STACK_R8,
562         STACK_MP,
563         STACK_OBJ,
564         STACK_VTYPE,
565         STACK_MAX
566 } MonoStackType;
567
568 typedef struct {
569         union {
570                 double   r8;
571                 gint32   i4;
572                 gint64   i8;
573                 gpointer p;
574                 MonoClass *klass;
575         } data;
576         int type;
577 } StackSlot;
578
579 enum {
580         MONO_COMP_DOM = 1,
581         MONO_COMP_IDOM = 2,
582         MONO_COMP_DFRONTIER = 4,
583         MONO_COMP_DOM_REV = 8,
584         MONO_COMP_LIVENESS = 16,
585         MONO_COMP_SSA = 32,
586         MONO_COMP_SSA_DEF_USE = 64,
587         MONO_COMP_REACHABILITY = 128,
588         MONO_COMP_LOOPS = 256
589 };
590
591 typedef enum {
592         MONO_GRAPH_CFG = 1,
593         MONO_GRAPH_DTREE = 2,
594         MONO_GRAPH_CFG_CODE = 4,
595         MONO_GRAPH_CFG_SSA = 8,
596         MONO_GRAPH_CFG_OPTCODE = 16
597 } MonoGraphOptions;
598
599 typedef struct {
600         const char *name;
601         gconstpointer func;
602         gconstpointer wrapper;
603         MonoMethodSignature *sig;
604 } MonoJitICallInfo;
605
606 typedef void (*MonoInstFunc) (MonoInst *tree, gpointer data);
607
608 /* main function */
609 int         mono_main                      (int argc, char* argv[]);
610 void        mono_set_defaults              (int verbose_level, guint32 opts);
611 MonoDomain* mini_init                      (const char *filename);
612 void        mini_cleanup                   (MonoDomain *domain);
613
614 /* helper methods */
615 MonoJumpInfoToken * mono_jump_info_token_new (MonoMemPool *mp, MonoImage *image, guint32 token);
616 MonoInst* mono_find_spvar_for_region        (MonoCompile *cfg, int region);
617 void      mono_precompile_assemblies        (void);
618 int       mono_parse_default_optimizations  (const char* p);
619 void      mono_bblock_add_inst              (MonoBasicBlock *bb, MonoInst *inst);
620 void      mono_constant_fold                (MonoCompile *cfg);
621 void      mono_constant_fold_inst           (MonoInst *inst, gpointer data);
622 void      mono_cprop_local                  (MonoCompile *cfg, MonoBasicBlock *bb, MonoInst **acp, int acp_size);
623 MonoInst* mono_compile_create_var           (MonoCompile *cfg, MonoType *type, int opcode);
624 void      mono_blockset_print               (MonoCompile *cfg, MonoBitSet *set, const char *name, guint idom);
625 void      mono_print_tree                   (MonoInst *tree);
626 void      mono_print_tree_nl                (MonoInst *tree);
627 void      mono_print_code                   (MonoCompile *cfg);
628 int       mono_spillvar_offset              (MonoCompile *cfg, int spillvar);
629 void      mono_select_instructions          (MonoCompile *cfg);
630 const char* mono_inst_name                  (int op);
631 void      mono_inst_foreach                 (MonoInst *tree, MonoInstFunc func, gpointer data);
632 void      mono_disassemble_code             (guint8 *code, int size, char *id);
633 guint     mono_type_to_ldind                (MonoType *t);
634 guint     mono_type_to_stind                (MonoType *t);
635 void      mono_add_patch_info               (MonoCompile *cfg, int ip, MonoJumpInfoType type, gconstpointer target);
636 void      mono_remove_patch_info            (MonoCompile *cfg, int ip);
637 gpointer  mono_get_lmf_addr                 (void);
638 GList    *mono_varlist_insert_sorted        (MonoCompile *cfg, GList *list, MonoMethodVar *mv, gboolean sort_end);
639 void      mono_analyze_liveness             (MonoCompile *cfg);
640 void      mono_linear_scan                  (MonoCompile *cfg, GList *vars, GList *regs, regmask_t *used_mask);
641 void      mono_create_jump_table            (MonoCompile *cfg, MonoInst *label, MonoBasicBlock **bbs, int num_blocks);
642 int       mono_compile_assembly             (MonoAssembly *ass, guint32 opts);
643 MonoCompile *mini_method_compile            (MonoMethod *method, guint32 opts, MonoDomain *domain, int parts);
644 void      mono_destroy_compile              (MonoCompile *cfg);
645 void      mono_aot_init                     (void);
646 MonoJitInfo*  mono_aot_get_method           (MonoDomain *domain,
647                                                                                          MonoMethod *method);
648 gboolean  mono_method_blittable             (MonoMethod *method);
649 void      mono_register_opcode_emulation    (int opcode, const char* name, MonoMethodSignature *sig, gpointer func, gboolean no_throw);
650 void      mono_arch_register_lowlevel_calls (void);
651 void      mono_draw_graph                   (MonoCompile *cfg, MonoGraphOptions draw_options);
652 void      mono_add_varcopy_to_end           (MonoCompile *cfg, MonoBasicBlock *bb, int src, int dest);
653
654 int               mono_find_method_opcode      (MonoMethod *method);
655 MonoJitICallInfo *mono_find_jit_icall_by_name  (const char *name);
656 MonoJitICallInfo *mono_find_jit_icall_by_addr  (gconstpointer addr);
657 MonoJitICallInfo *mono_register_jit_icall      (gconstpointer func, const char *name, MonoMethodSignature *sig, gboolean is_save);
658 gconstpointer     mono_icall_get_wrapper       (MonoJitICallInfo* callinfo);
659
660 gpointer          mono_create_class_init_trampoline (MonoVTable *vtable);
661 MonoVTable*       mono_find_class_init_trampoline_by_addr (gconstpointer addr);
662
663 /* methods that must be provided by the arch-specific port */
664 void      mono_arch_cpu_init                    (void);
665 guint32   mono_arch_cpu_optimizazions           (guint32 *exclude_mask);
666 void      mono_arch_instrument_mem_needs        (MonoMethod *method, int *stack, int *code);
667 void     *mono_arch_instrument_prolog           (MonoCompile *cfg, void *func, void *p, gboolean enable_arguments);
668 void     *mono_arch_instrument_epilog           (MonoCompile *cfg, void *func, void *p, gboolean enable_arguments);
669 MonoCallInst *mono_arch_call_opcode             (MonoCompile *cfg, MonoBasicBlock* bb, MonoCallInst *call, int is_virtual);
670 void      mono_codegen                          (MonoCompile *cfg);
671 const char *mono_arch_regname                   (int reg);
672 gpointer  mono_arch_get_throw_exception         (void);
673 gpointer  mono_arch_get_throw_exception_by_name (void);
674 gpointer  mono_arch_create_jit_trampoline       (MonoMethod *method);
675 gpointer  mono_arch_create_jump_trampoline      (MonoMethod *method);
676 gpointer  mono_arch_create_class_init_trampoline(MonoVTable *vtable);
677 GList    *mono_arch_get_allocatable_int_vars    (MonoCompile *cfg);
678 GList    *mono_arch_get_global_int_regs         (MonoCompile *cfg);
679 void      mono_arch_patch_code                  (MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *ji);
680 void      mono_arch_flush_icache                (guint8 *code, gint size);
681 int       mono_arch_max_epilog_size             (MonoCompile *cfg);
682 guint8   *mono_arch_emit_prolog                 (MonoCompile *cfg);
683 void      mono_arch_emit_epilog                 (MonoCompile *cfg);
684 void      mono_arch_local_regalloc              (MonoCompile *cfg, MonoBasicBlock *bb);
685 void      mono_arch_output_basic_block          (MonoCompile *cfg, MonoBasicBlock *bb);
686 gboolean  mono_arch_has_unwind_info             (gconstpointer addr);
687 void      mono_arch_allocate_vars               (MonoCompile *m);
688 void      mono_jit_walk_stack                   (MonoStackWalk func, gpointer user_data);
689 MonoArray *ves_icall_get_trace                  (MonoException *exc, gint32 skip, MonoBoolean need_file_info);
690 MonoBoolean ves_icall_get_frame_info            (gint32 skip, MonoBoolean need_file_info, 
691                                                  MonoReflectionMethod **method, 
692                                                  gint32 *iloffset, gint32 *native_offset,
693                                                  MonoString **file, gint32 *line, gint32 *column);
694
695 /* Dominator/SSA methods */
696 void        mono_compile_dominator_info         (MonoCompile *cfg, int dom_flags);
697 void        mono_compute_natural_loops          (MonoCompile *cfg);
698 MonoBitSet* mono_compile_iterated_dfrontier     (MonoCompile *cfg, MonoBitSet *set);
699 void        mono_ssa_compute                    (MonoCompile *cfg);
700 void        mono_ssa_remove                     (MonoCompile *cfg);
701 void        mono_ssa_cprop                      (MonoCompile *cfg);
702 void        mono_ssa_deadce                     (MonoCompile *cfg);
703 void        mono_ssa_strength_reduction         (MonoCompile *cfg);
704
705 /* debugging support */
706 void      mono_debug_init_method                (MonoCompile *cfg, MonoBasicBlock *start_block,
707                                                  guint32 breakpoint_id);
708 void      mono_debug_open_method                (MonoCompile *cfg);
709 void      mono_debug_close_method               (MonoCompile *cfg);
710 void      mono_debug_open_block                 (MonoCompile *cfg, MonoBasicBlock *bb, guint32 address);
711 void      mono_debug_record_line_number         (MonoCompile *cfg, MonoInst *ins, guint32 address);
712
713 #endif /* __MONO_MINI_H__ */