rename benode_t.h to benode.h, remove some unused code
[libfirm] / ir / be / mips / bearch_mips.c
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief   The main mips backend driver file.
23  * @author  Matthias Braun, Mehdi
24  * @version $Id$
25  */
26 #include "config.h"
27
28 #include "pseudo_irg.h"
29 #include "irgwalk.h"
30 #include "irprog.h"
31 #include "irprintf.h"
32 #include "ircons.h"
33 #include "irgmod.h"
34 #include "irgopt.h"
35 #include "irgwalk.h"
36 #include "iredges.h"
37 #include "irdump.h"
38 #include "irextbb.h"
39 #include "irtools.h"
40 #include "error.h"
41
42 #include "bitset.h"
43 #include "debug.h"
44
45 #include "../bearch.h"
46 #include "../benode.h"
47 #include "../belower.h"
48 #include "../besched.h"
49 #include "../beblocksched.h"
50 #include "../beirg.h"
51 #include "be.h"
52 #include "../beabi.h"
53 #include "../bemachine.h"
54 #include "../bemodule.h"
55 #include "../bespillslots.h"
56 #include "../beemitter.h"
57 #include "../begnuas.h"
58
59 #include "bearch_mips_t.h"
60
61 #include "mips_new_nodes.h"
62 #include "gen_mips_regalloc_if.h"
63 #include "mips_transform.h"
64 #include "mips_emitter.h"
65 #include "mips_map_regs.h"
66 #include "mips_util.h"
67 #include "mips_scheduler.h"
68
69 #define DEBUG_MODULE "firm.be.mips.isa"
70
71 /* TODO: ugly, but we need it to get access to the registers assigned to Phi nodes */
72 static set *cur_reg_set = NULL;
73
74 /**************************************************
75  *                         _ _              _  __
76  *                        | | |            (_)/ _|
77  *  _ __ ___  __ _    __ _| | | ___   ___   _| |_
78  * | '__/ _ \/ _` |  / _` | | |/ _ \ / __| | |  _|
79  * | | |  __/ (_| | | (_| | | | (_) | (__  | | |
80  * |_|  \___|\__, |  \__,_|_|_|\___/ \___| |_|_|
81  *            __/ |
82  *           |___/
83  **************************************************/
84
85 static arch_irn_class_t mips_classify(const ir_node *irn)
86 {
87         (void) irn;
88         return 0;
89 }
90
91 int mips_is_Load(const ir_node *node)
92 {
93         return is_mips_lw(node) || is_mips_lh(node) || is_mips_lhu(node) ||
94                 is_mips_lb(node) || is_mips_lbu(node);
95 }
96
97 int mips_is_Store(const ir_node *node)
98 {
99         return is_mips_sw(node) || is_mips_sh(node) || is_mips_sb(node);
100 }
101
102 static ir_entity *mips_get_frame_entity(const ir_node *node)
103 {
104         const mips_load_store_attr_t *attr;
105
106         if(!is_mips_irn(node))
107                 return NULL;
108         if(!mips_is_Load(node) && !mips_is_Store(node))
109                 return NULL;
110
111         attr = get_mips_load_store_attr_const(node);
112         return attr->stack_entity;
113 }
114
115 static void mips_set_frame_entity(ir_node *node, ir_entity *entity)
116 {
117         mips_load_store_attr_t *attr;
118
119         if(!is_mips_irn(node)) {
120                 panic("trying to set frame entity on non load/store node %+F", node);
121         }
122         if(!mips_is_Load(node) && !mips_is_Store(node)) {
123                 panic("trying to set frame entity on non load/store node %+F", node);
124         }
125
126         attr = get_irn_generic_attr(node);
127         attr->stack_entity = entity;
128 }
129
130 /**
131  * This function is called by the generic backend to correct offsets for
132  * nodes accessing the stack.
133  */
134 static void mips_set_frame_offset(ir_node *node, int offset)
135 {
136         mips_load_store_attr_t *attr;
137
138         if(!is_mips_irn(node)) {
139                 panic("trying to set frame offset on non load/store node %+F", node);
140         }
141         if(!mips_is_Load(node) && !mips_is_Store(node)) {
142                 panic("trying to set frame offset on non load/store node %+F", node);
143         }
144
145         attr = get_irn_generic_attr(node);
146         attr->offset += offset;
147
148         if(attr->offset < -32768 || attr->offset > 32767) {
149                 panic("Out of stack space! (mips supports only 16bit offsets)");
150         }
151 }
152
153 static int mips_get_sp_bias(const ir_node *irn)
154 {
155         (void) irn;
156         return 0;
157 }
158
159 /* fill register allocator interface */
160
161 static const arch_irn_ops_t mips_irn_ops = {
162         get_mips_in_req,
163         get_mips_out_req,
164         mips_classify,
165         mips_get_frame_entity,
166         mips_set_frame_entity,
167         mips_set_frame_offset,
168         mips_get_sp_bias,
169         NULL,    /* get_inverse             */
170         NULL,    /* get_op_estimated_cost   */
171         NULL,    /* possible_memory_operand */
172         NULL,    /* perform_memory_operand  */
173 };
174
175 /**************************************************
176  *                _                         _  __
177  *               | |                       (_)/ _|
178  *   ___ ___   __| | ___  __ _  ___ _ __    _| |_
179  *  / __/ _ \ / _` |/ _ \/ _` |/ _ \ '_ \  | |  _|
180  * | (_| (_) | (_| |  __/ (_| |  __/ | | | | | |
181  *  \___\___/ \__,_|\___|\__, |\___|_| |_| |_|_|
182  *                        __/ |
183  *                       |___/
184  **************************************************/
185
186 /**
187  * Transforms the standard firm graph into
188  * a mips firm graph
189  */
190 static void mips_prepare_graph(void *self) {
191         mips_code_gen_t *cg = self;
192
193         /* do local optimizations */
194         optimize_graph_df(cg->irg);
195
196         /* TODO: we often have dead code reachable through out-edges here. So for
197          * now we rebuild edges (as we need correct user count for code selection)
198          */
199 #if 1
200         edges_deactivate(cg->irg);
201         edges_activate(cg->irg);
202 #endif
203
204         // walk the graph and transform firm nodes into mips nodes where possible
205         mips_transform_graph(cg);
206         dump_ir_block_graph_sched(cg->irg, "-transformed");
207
208         /* do local optimizations (mainly CSE) */
209         optimize_graph_df(cg->irg);
210
211         /* do code placement, to optimize the position of constants */
212         place_code(cg->irg);
213
214         be_dump(cg->irg, "-place", dump_ir_block_graph_sched);
215 }
216
217 /**
218  * Called immediately before emit phase.
219  */
220 static void mips_finish_irg(void *self) {
221         mips_code_gen_t *cg = self;
222         ir_graph        *irg = cg->irg;
223
224         /* create block schedule, this also removes empty blocks which might
225          * produce critical edges */
226         cg->block_schedule = be_create_block_schedule(irg, cg->birg->exec_freq);
227
228         dump_ir_block_graph_sched(irg, "-mips-finished");
229 }
230
231
232 static void mips_before_ra(void *self)
233 {
234         (void) self;
235 }
236
237 static void mips_after_ra(void* self)
238 {
239         mips_code_gen_t *cg = self;
240         be_coalesce_spillslots(cg->birg);
241         irg_walk_blkwise_graph(cg->irg, NULL, mips_after_ra_walker, self);
242 }
243
244 /**
245  * Emits the code, closes the output file and frees
246  * the code generator interface.
247  */
248 static void mips_emit_and_done(void *self)
249 {
250         mips_code_gen_t *cg  = self;
251         ir_graph        *irg = cg->irg;
252         (void) self;
253
254         mips_gen_routine(cg, irg);
255
256         cur_reg_set = NULL;
257
258         /* de-allocate code generator */
259         del_set(cg->reg_set);
260         free(cg);
261 }
262
263 static void *mips_cg_init(be_irg_t *birg);
264
265 static const arch_code_generator_if_t mips_code_gen_if = {
266         mips_cg_init,
267         NULL,                /* get_pic_base */
268         NULL,                /* before abi introduce */
269         mips_prepare_graph,
270         NULL,                /* spill */
271         mips_before_ra,      /* before register allocation hook */
272         mips_after_ra,
273         mips_finish_irg,
274         mips_emit_and_done
275 };
276
277 /**
278  * Initializes the code generator.
279  */
280 static void *mips_cg_init(be_irg_t *birg)
281 {
282         const arch_env_t *arch_env = be_get_birg_arch_env(birg);
283         mips_isa_t       *isa      = (mips_isa_t *) arch_env;
284         mips_code_gen_t  *cg       = XMALLOCZ(mips_code_gen_t);
285
286         cg->impl     = &mips_code_gen_if;
287         cg->irg      = be_get_birg_irg(birg);
288         cg->reg_set  = new_set(mips_cmp_irn_reg_assoc, 1024);
289         cg->isa      = isa;
290         cg->birg     = birg;
291
292         cur_reg_set = cg->reg_set;
293
294         isa->cg = cg;
295
296         return (arch_code_generator_t *)cg;
297 }
298
299
300 /*****************************************************************
301  *  ____             _                  _   _____  _____
302  * |  _ \           | |                | | |_   _|/ ____|  /\
303  * | |_) | __ _  ___| | _____ _ __   __| |   | | | (___   /  \
304  * |  _ < / _` |/ __| |/ / _ \ '_ \ / _` |   | |  \___ \ / /\ \
305  * | |_) | (_| | (__|   <  __/ | | | (_| |  _| |_ ____) / ____ \
306  * |____/ \__,_|\___|_|\_\___|_| |_|\__,_| |_____|_____/_/    \_\
307  *
308  *****************************************************************/
309
310 static mips_isa_t mips_isa_template = {
311         {
312                 &mips_isa_if,
313                 &mips_gp_regs[REG_SP],
314                 &mips_gp_regs[REG_FP],
315                 &mips_reg_classes[CLASS_mips_gp],
316                 -1,             /* stack direction */
317                 2,      /* power of two stack alignment for calls, 2^2 == 4 */
318                 NULL,   /* main environment */
319                 7,      /* spill costs */
320                 5,      /* reload costs */
321         },
322         NULL,          /* cg */
323 };
324
325 /**
326  * Initializes the backend ISA and opens the output file.
327  */
328 static arch_env_t *mips_init(FILE *file_handle) {
329         static int inited = 0;
330         mips_isa_t *isa;
331
332         if(inited)
333                 return NULL;
334         inited = 1;
335
336         isa = XMALLOC(mips_isa_t);
337         memcpy(isa, &mips_isa_template, sizeof(isa[0]));
338
339         be_emit_init(file_handle);
340
341         mips_register_init();
342         mips_create_opcodes(&mips_irn_ops);
343         // mips_init_opcode_transforms();
344
345         /* we mark referenced global entities, so we can only emit those which
346          * are actually referenced. (Note: you mustn't use the type visited flag
347          * elsewhere in the backend)
348          */
349         inc_master_type_visited();
350
351         return &isa->arch_env;
352 }
353
354 /**
355  * Closes the output file and frees the ISA structure.
356  */
357 static void mips_done(void *self)
358 {
359         mips_isa_t *isa = self;
360
361         be_gas_emit_decls(isa->arch_env.main_env, 1);
362
363         be_emit_exit();
364         free(isa);
365 }
366
367 static unsigned mips_get_n_reg_class(const void *self)
368 {
369         (void) self;
370         return N_CLASSES;
371 }
372
373 static const arch_register_class_t *mips_get_reg_class(const void *self,
374                                                        unsigned i)
375 {
376         (void) self;
377         assert(i < N_CLASSES);
378         return &mips_reg_classes[i];
379 }
380
381
382
383 /**
384  * Get the register class which shall be used to store a value of a given mode.
385  * @param self The this pointer.
386  * @param mode The mode in question.
387  * @return A register class which can hold values of the given mode.
388  */
389 const arch_register_class_t *mips_get_reg_class_for_mode(const void *self,
390                                                          const ir_mode *mode)
391 {
392         (void) self;
393         (void) mode;
394         ASSERT_NO_FLOAT(mode);
395         return &mips_reg_classes[CLASS_mips_gp];
396 }
397
398 typedef struct {
399         be_abi_call_flags_bits_t flags;
400         const arch_env_t *arch_env;
401         ir_graph *irg;
402         // do special handling to support debuggers
403         int debug;
404 } mips_abi_env_t;
405
406 static void *mips_abi_init(const be_abi_call_t *call, const arch_env_t *arch_env, ir_graph *irg)
407 {
408         mips_abi_env_t *env    = XMALLOC(mips_abi_env_t);
409         be_abi_call_flags_t fl = be_abi_call_get_flags(call);
410         env->flags             = fl.bits;
411         env->irg               = irg;
412         env->arch_env          = arch_env;
413         env->debug             = 1;
414         return env;
415 }
416
417 static const arch_register_t *mips_abi_prologue(void *self, ir_node** mem, pmap *reg_map, int *stack_bias)
418 {
419         mips_abi_env_t *env = self;
420         ir_graph *irg = env->irg;
421         ir_node *block = get_irg_start_block(irg);
422         ir_node *sp = be_abi_reg_map_get(reg_map, &mips_gp_regs[REG_SP]);
423         ir_node *fp = be_abi_reg_map_get(reg_map, &mips_gp_regs[REG_FP]);
424         int initialstackframesize;
425
426         (void) stack_bias;
427
428         if (env->debug) {
429                 /*
430                  * The calling conventions wants a stack frame of at least 24bytes size with
431                  *   a0-a3 saved in offset 0-12
432                  *   fp saved in offset 16
433                  *   ra saved in offset 20
434                  */
435                 ir_node *mm[6];
436                 ir_node *sync, *reg, *store;
437                 initialstackframesize = 24;
438
439                 // - setup first part of stackframe
440                 sp = new_bd_mips_addu(NULL, block, sp,
441                                       mips_create_Immediate(initialstackframesize));
442                 arch_set_irn_register(sp, &mips_gp_regs[REG_SP]);
443                 panic("FIXME Use IncSP or set register requirement with ignore");
444
445                 /* TODO: where to get an edge with a0-a3
446                 int i;
447                 for(i = 0; i < 4; ++i) {
448                         ir_node *reg = be_abi_reg_map_get(reg_map, &mips_gp_regs[REG_A0 + i]);
449                         ir_node *store = new_bd_mips_store_r(dbg, block, *mem, sp, reg, mode_T);
450                         attr = get_mips_attr(store);
451                         attr->load_store_mode = mode_Iu;
452                         attr->tv = new_tarval_from_long(i * 4, mode_Is);
453
454                         mm[i] = new_r_Proj(irg, block, store, mode_M, pn_Store_M);
455                 }
456                 */
457
458                 reg = be_abi_reg_map_get(reg_map, &mips_gp_regs[REG_FP]);
459                 store = new_bd_mips_sw(NULL, block, sp, reg, *mem, NULL, 16);
460
461                 mm[4] = store;
462
463                 reg = be_abi_reg_map_get(reg_map, &mips_gp_regs[REG_RA]);
464                 store = new_bd_mips_sw(NULL, block, sp, reg, *mem, NULL, 20);
465
466                 mm[5] = store;
467
468                 /* Note: ideally we would route these mem edges directly towards the
469                  * epilogue, but this is currently not supported so we sync all mems
470                  * together */
471                 sync = new_r_Sync(block, 2, mm+4);
472                 *mem = sync;
473         } else {
474                 ir_node *reg, *store;
475                 initialstackframesize = 4;
476
477                 // save old framepointer
478                 sp = new_bd_mips_addu(NULL, block, sp,
479                                       mips_create_Immediate(-initialstackframesize));
480                 arch_set_irn_register(sp, &mips_gp_regs[REG_SP]);
481                 panic("FIXME Use IncSP or set register requirement with ignore");
482
483                 reg = be_abi_reg_map_get(reg_map, &mips_gp_regs[REG_FP]);
484                 store = new_bd_mips_sw(NULL, block, sp, reg, *mem, NULL, 0);
485
486                 *mem = store;
487         }
488
489         // setup framepointer
490         fp = new_bd_mips_addu(NULL, block, sp,
491                               mips_create_Immediate(-initialstackframesize));
492         arch_set_irn_register(fp, &mips_gp_regs[REG_FP]);
493         panic("FIXME Use IncSP or set register requirement with ignore");
494
495         be_abi_reg_map_set(reg_map, &mips_gp_regs[REG_FP], fp);
496         be_abi_reg_map_set(reg_map, &mips_gp_regs[REG_SP], sp);
497
498         return &mips_gp_regs[REG_SP];
499 }
500
501 static void mips_abi_epilogue(void *self, ir_node *block, ir_node **mem, pmap *reg_map)
502 {
503         mips_abi_env_t   *env = self;
504
505         ir_node *sp = be_abi_reg_map_get(reg_map, &mips_gp_regs[REG_SP]);
506         ir_node *fp = be_abi_reg_map_get(reg_map, &mips_gp_regs[REG_FP]);
507         ir_node *load;
508         int initial_frame_size = env->debug ? 24 : 4;
509         int fp_save_offset = env->debug ? 16 : 0;
510
511         // copy fp to sp
512         sp = new_bd_mips_or(NULL, block, fp, mips_create_zero());
513         arch_set_irn_register(sp, &mips_gp_regs[REG_SP]);
514         panic("FIXME Use be_Copy or set register requirement with ignore");
515
516         // 1. restore fp
517         load = new_bd_mips_lw(NULL, block, sp, *mem, NULL,
518                               fp_save_offset - initial_frame_size);
519         panic("FIXME register requirement with ignore");
520
521         fp = new_r_Proj(block, load, mode_Iu, pn_mips_lw_res);
522         *mem = new_r_Proj(block, load, mode_Iu, pn_mips_lw_M);
523         arch_set_irn_register(fp, &mips_gp_regs[REG_FP]);
524
525         be_abi_reg_map_set(reg_map, &mips_gp_regs[REG_FP], fp);
526         be_abi_reg_map_set(reg_map, &mips_gp_regs[REG_SP], sp);
527 }
528
529 /**
530  * Produces the type which sits between the stack args and the locals on the stack.
531  * it will contain the return address and space to store the old frame pointer.
532  * @return The Firm type modelling the ABI between type.
533  */
534 static ir_type *mips_abi_get_between_type(void *self) {
535         mips_abi_env_t *env = self;
536
537         static ir_type *debug_between_type = NULL;
538         static ir_type *opt_between_type = NULL;
539         static ir_entity *old_fp_ent    = NULL;
540
541         if(env->debug && debug_between_type == NULL) {
542                 ir_entity *a0_ent, *a1_ent, *a2_ent, *a3_ent;
543                 ir_entity *ret_addr_ent;
544                 ir_type *ret_addr_type = new_type_primitive(new_id_from_str("return_addr"), mode_P);
545                 ir_type *old_fp_type   = new_type_primitive(new_id_from_str("fp"), mode_P);
546                 ir_type *old_param_type = new_type_primitive(new_id_from_str("param"), mode_Iu);
547
548                 debug_between_type     = new_type_class(new_id_from_str("mips_between_type"));
549                 a0_ent                             = new_entity(debug_between_type, new_id_from_str("a0_ent"), old_param_type);
550                 a1_ent                             = new_entity(debug_between_type, new_id_from_str("a1_ent"), old_param_type);
551                 a2_ent                             = new_entity(debug_between_type, new_id_from_str("a2_ent"), old_param_type);
552                 a3_ent                             = new_entity(debug_between_type, new_id_from_str("a3_ent"), old_param_type);
553                 old_fp_ent             = new_entity(debug_between_type, new_id_from_str("old_fp"), old_fp_type);
554                 ret_addr_ent           = new_entity(debug_between_type, new_id_from_str("ret_addr"), ret_addr_type);
555
556                 set_entity_offset(a0_ent, 0);
557                 set_entity_offset(a1_ent, 4);
558                 set_entity_offset(a2_ent, 8);
559                 set_entity_offset(a3_ent, 12);
560                 set_entity_offset(old_fp_ent, 16);
561                 set_entity_offset(ret_addr_ent, 20);
562
563                 set_type_size_bytes(debug_between_type, 24);
564         } else if(!env->debug && opt_between_type == NULL) {
565                 ir_type *old_fp_type   = new_type_primitive(new_id_from_str("fp"), mode_P);
566                 ir_entity *old_fp_ent;
567
568                 opt_between_type       = new_type_class(new_id_from_str("mips_between_type"));
569                 old_fp_ent             = new_entity(opt_between_type, new_id_from_str("old_fp"), old_fp_type);
570                 set_entity_offset(old_fp_ent, 0);
571                 set_type_size_bytes(opt_between_type, 4);
572         }
573
574         return env->debug ? debug_between_type : opt_between_type;
575 }
576
577 static const be_abi_callbacks_t mips_abi_callbacks = {
578         mips_abi_init,
579         free,
580         mips_abi_get_between_type,
581         mips_abi_prologue,
582         mips_abi_epilogue,
583 };
584
585 /**
586  * Get the ABI restrictions for procedure calls.
587  * @param self        The this pointer.
588  * @param method_type The type of the method (procedure) in question.
589  * @param abi         The abi object to be modified
590  */
591 static void mips_get_call_abi(const void *self, ir_type *method_type,
592                               be_abi_call_t *abi)
593 {
594         ir_type  *tp;
595         ir_mode  *mode;
596         int       n = get_method_n_params(method_type);
597         int result_count;
598         int       i;
599         ir_mode **modes;
600         const arch_register_t *reg;
601         be_abi_call_flags_t call_flags;
602         (void) self;
603
604         memset(&call_flags, 0, sizeof(call_flags));
605         call_flags.bits.left_to_right         = 0;
606         call_flags.bits.store_args_sequential = 0;
607         call_flags.bits.try_omit_fp           = 1;
608         call_flags.bits.fp_free               = 0;
609         call_flags.bits.call_has_imm          = 1;
610
611         /* set stack parameter passing style */
612         be_abi_call_set_flags(abi, call_flags, &mips_abi_callbacks);
613
614         /* collect the mode for each type */
615         modes = ALLOCAN(ir_mode*, n);
616         for (i = 0; i < n; i++) {
617                 tp       = get_method_param_type(method_type, i);
618                 modes[i] = get_type_mode(tp);
619         }
620
621         // assigns parameters to registers or stack
622         for (i = 0; i < n; i++) {
623                 // first 4 params in $a0-$a3, the others on the stack
624                 if(i < 4) {
625                         reg = &mips_gp_regs[REG_A0 + i];
626                         be_abi_call_param_reg(abi, i, reg);
627                 } else {
628                         /* default: all parameters on stack */
629                         be_abi_call_param_stack(abi, i, modes[i], 4, 0, 0);
630                 }
631         }
632
633         /* set return register */
634         /* default: return value is in R0 (and maybe R1) */
635         result_count = get_method_n_ress(method_type);
636         assert(result_count <= 2 && "More than 2 result values not supported");
637         for(i = 0; i < result_count; ++i) {
638                 const arch_register_t* reg;
639                 tp   = get_method_res_type(method_type, i);
640                 mode = get_type_mode(tp);
641                 ASSERT_NO_FLOAT(mode);
642
643                 reg = &mips_gp_regs[REG_V0 + i];
644                 be_abi_call_res_reg(abi, i, reg);
645         }
646 }
647
648 /**
649  * Initializes the code generator interface.
650  */
651 static const arch_code_generator_if_t *mips_get_code_generator_if(void *self)
652 {
653         (void) self;
654         return &mips_code_gen_if;
655 }
656
657 /**
658  * Returns the necessary byte alignment for storing a register of given class.
659  */
660 static int mips_get_reg_class_alignment(const void *self,
661                                         const arch_register_class_t *cls)
662 {
663         ir_mode *mode = arch_register_class_mode(cls);
664         (void) self;
665         return get_mode_size_bytes(mode);
666 }
667
668 static const be_execution_unit_t ***mips_get_allowed_execution_units(
669                 const void *self, const ir_node *irn)
670 {
671         (void) self;
672         (void) irn;
673         /* TODO */
674         panic("Unimplemented mips_get_allowed_execution_units()");
675 }
676
677 static const be_machine_t *mips_get_machine(const void *self)
678 {
679         (void) self;
680         /* TODO */
681         panic("Unimplemented mips_get_machine()");
682 }
683
684 /**
685  * Return irp irgs in the desired order.
686  */
687 static ir_graph **mips_get_irg_list(const void *self, ir_graph ***irg_list)
688 {
689         (void) self;
690         (void) irg_list;
691         return NULL;
692 }
693
694 /**
695  * Returns the libFirm configuration parameter for this backend.
696  */
697 static const backend_params *mips_get_libfirm_params(void) {
698         static backend_params p = {
699                 1,     /* need dword lowering */
700                 0,     /* don't support inline assembler yet */
701                 NULL,  /* will be set later */
702                 NULL,  /* but yet no creator function */
703                 NULL,  /* context for create_intrinsic_fkt */
704                 NULL,  /* no if conversion settings */
705                 NULL,  /* float arithmetic mode (TODO) */
706                 0,     /* no trampoline support: size 0 */
707                 0,     /* no trampoline support: align 0 */
708                 NULL,  /* no trampoline support: no trampoline builder */
709                 4      /* alignment of stack parameter */
710         };
711
712         return &p;
713 }
714
715 static asm_constraint_flags_t mips_parse_asm_constraint(const void *self,
716                                                         const char **c)
717 {
718         (void) self;
719         (void) c;
720         return ASM_CONSTRAINT_FLAG_INVALID;
721 }
722
723 static int mips_is_valid_clobber(const void *self, const char *clobber)
724 {
725         (void) self;
726         (void) clobber;
727         return 0;
728 }
729
730 const arch_isa_if_t mips_isa_if = {
731         mips_init,
732         mips_done,
733         NULL,               /* handle intrinsics */
734         mips_get_n_reg_class,
735         mips_get_reg_class,
736         mips_get_reg_class_for_mode,
737         mips_get_call_abi,
738         mips_get_code_generator_if,
739         mips_get_list_sched_selector,
740         mips_get_ilp_sched_selector,
741         mips_get_reg_class_alignment,
742         mips_get_libfirm_params,
743         mips_get_allowed_execution_units,
744         mips_get_machine,
745         mips_get_irg_list,
746         NULL,                /* mark remat */
747         mips_parse_asm_constraint,
748         mips_is_valid_clobber
749 };
750
751 void be_init_arch_mips(void)
752 {
753         be_register_isa_if("mips", &mips_isa_if);
754 }
755
756 BE_REGISTER_MODULE_CONSTRUCTOR(be_init_arch_mips);