allow backend to do its own custom abi handling and disable the generic beabi.h/...
[libfirm] / ir / be / sparc / bearch_sparc.c
1 /*
2  * Copyright (C) 1995-2010 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 sparc backend driver file.
23  * @version  $Id$
24  */
25
26 #include "config.h"
27
28 #include "lc_opts.h"
29 #include "lc_opts_enum.h"
30
31 #include "pseudo_irg.h"
32 #include "irgwalk.h"
33 #include "irprog.h"
34 #include "irprintf.h"
35 #include "ircons.h"
36 #include "irgmod.h"
37 #include "irgopt.h"
38 #include "iroptimize.h"
39 #include "irtools.h"
40 #include "irdump.h"
41 #include "lowering.h"
42
43 #include "bitset.h"
44 #include "debug.h"
45 #include "array_t.h"
46 #include "error.h"
47
48 #include "../bearch.h"
49 #include "../benode.h"
50 #include "../belower.h"
51 #include "../besched.h"
52 #include "be.h"
53 #include "../beabi.h"
54 #include "../bemachine.h"
55 #include "../beilpsched.h"
56 #include "../bemodule.h"
57 #include "../beirg.h"
58 #include "../bespillslots.h"
59 #include "../begnuas.h"
60 #include "../belistsched.h"
61 #include "../beflags.h"
62
63 #include "bearch_sparc_t.h"
64 #include "bearch_sparc.h"
65
66 #include "sparc_new_nodes.h"
67 #include "gen_sparc_regalloc_if.h"
68 #include "sparc_transform.h"
69 #include "sparc_emitter.h"
70 #include "sparc_map_regs.h"
71
72 DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
73
74 static arch_irn_class_t sparc_classify(const ir_node *irn)
75 {
76         (void) irn;
77         return 0;
78 }
79
80 static ir_entity *sparc_get_frame_entity(const ir_node *irn)
81 {
82         const sparc_attr_t *attr = get_sparc_attr_const(irn);
83
84         if (is_sparc_FrameAddr(irn)) {
85                 const sparc_symconst_attr_t *attr = get_irn_generic_attr_const(irn);
86                 return attr->entity;
87         }
88
89         if (attr->is_load_store) {
90                 const sparc_load_store_attr_t *load_store_attr = get_sparc_load_store_attr_const(irn);
91                 if (load_store_attr->is_frame_entity) {
92                         return load_store_attr->entity;
93                 }
94         }
95
96         return NULL;
97 }
98
99 static void sparc_set_frame_entity(ir_node *node, ir_entity *ent)
100 {
101         (void) node;
102         (void) ent;
103         panic("sparc_set_frame_entity() called. This should not happen.");
104         /* TODO: set the ir_entity assigned to the frame */
105 }
106
107 /**
108  * This function is called by the generic backend to correct offsets for
109  * nodes accessing the stack.
110  */
111 static void sparc_set_frame_offset(ir_node *irn, int offset)
112 {
113         if (is_sparc_FrameAddr(irn)) {
114                 sparc_symconst_attr_t *attr = get_irn_generic_attr(irn);
115                 attr->fp_offset += offset;
116         } else {
117                 sparc_load_store_attr_t *attr = get_sparc_load_store_attr(irn);
118                 assert(attr->base.is_load_store);
119                 attr->offset += offset;
120         }
121 }
122
123 static int sparc_get_sp_bias(const ir_node *irn)
124 {
125         (void) irn;
126         return SPARC_MIN_STACKSIZE;
127 }
128
129 /* fill register allocator interface */
130
131 static const arch_irn_ops_t sparc_irn_ops = {
132         get_sparc_in_req,
133         sparc_classify,
134         sparc_get_frame_entity,
135         sparc_set_frame_entity,
136         sparc_set_frame_offset,
137         sparc_get_sp_bias,
138         NULL,    /* get_inverse             */
139         NULL,    /* get_op_estimated_cost   */
140         NULL,    /* possible_memory_operand */
141         NULL,    /* perform_memory_operand  */
142 };
143
144
145
146 /**
147  * Transforms the standard firm graph into
148  * a SPARC firm graph
149  */
150 static void sparc_prepare_graph(void *self)
151 {
152         sparc_code_gen_t *cg = self;
153
154         /* transform FIRM into SPARC asm nodes */
155         sparc_transform_graph(cg);
156
157         if (cg->dump)
158                 dump_ir_graph(cg->irg, "transformed");
159 }
160
161
162
163 static ir_node *sparc_flags_remat(ir_node *node, ir_node *after)
164 {
165         ir_node *block;
166         ir_node *copy;
167
168         if (is_Block(after)) {
169                 block = after;
170         } else {
171                 block = get_nodes_block(after);
172         }
173         copy = exact_copy(node);
174         set_nodes_block(copy, block);
175         sched_add_after(after, copy);
176         return copy;
177 }
178
179 static void sparc_before_ra(void *self)
180 {
181         sparc_code_gen_t *cg = self;
182         /* fixup flags register */
183         be_sched_fix_flags(cg->irg, &sparc_reg_classes[CLASS_sparc_flags], &sparc_flags_remat);
184 }
185
186 /**
187  * transform reload node => load
188  */
189 static void transform_Reload(ir_node *node)
190 {
191         ir_graph  *irg    = get_irn_irg(node);
192         ir_node   *block  = get_nodes_block(node);
193         dbg_info  *dbgi   = get_irn_dbg_info(node);
194         ir_node   *ptr    = get_irg_frame(irg);
195         ir_node   *mem    = get_irn_n(node, be_pos_Reload_mem);
196         ir_mode   *mode   = get_irn_mode(node);
197         ir_entity *entity = be_get_frame_entity(node);
198         const arch_register_t *reg;
199         ir_node   *proj;
200         ir_node   *load;
201
202         ir_node  *sched_point = sched_prev(node);
203
204         load = new_bd_sparc_Load(dbgi, block, ptr, mem, mode, entity, false, 0, true);
205         sched_add_after(sched_point, load);
206         sched_remove(node);
207
208         proj = new_rd_Proj(dbgi, load, mode, pn_sparc_Load_res);
209
210         reg = arch_get_irn_register(node);
211         arch_set_irn_register(proj, reg);
212
213         exchange(node, proj);
214 }
215
216 /**
217  * transform spill node => store
218  */
219 static void transform_Spill(ir_node *node)
220 {
221         ir_graph  *irg    = get_irn_irg(node);
222         ir_node   *block  = get_nodes_block(node);
223         dbg_info  *dbgi   = get_irn_dbg_info(node);
224         ir_node   *ptr    = get_irg_frame(irg);
225         ir_node   *mem    = new_NoMem();
226         ir_node   *val    = get_irn_n(node, be_pos_Spill_val);
227         ir_mode   *mode   = get_irn_mode(val);
228         ir_entity *entity = be_get_frame_entity(node);
229         ir_node   *sched_point;
230         ir_node   *store;
231
232         sched_point = sched_prev(node);
233         store = new_bd_sparc_Store(dbgi, block, ptr, val, mem, mode, entity, false, 0, true);
234         sched_remove(node);
235         sched_add_after(sched_point, store);
236
237         exchange(node, store);
238 }
239
240 /**
241  * walker to transform be_Spill and be_Reload nodes
242  */
243 static void sparc_after_ra_walker(ir_node *block, void *data)
244 {
245         ir_node *node, *prev;
246         (void) data;
247
248         for (node = sched_last(block); !sched_is_begin(node); node = prev) {
249                 prev = sched_prev(node);
250
251                 if (be_is_Reload(node)) {
252                         transform_Reload(node);
253                 } else if (be_is_Spill(node)) {
254                         transform_Spill(node);
255                 }
256         }
257 }
258
259
260 static void sparc_after_ra(void *self)
261 {
262         sparc_code_gen_t *cg = self;
263         be_coalesce_spillslots(cg->irg);
264
265         irg_block_walk_graph(cg->irg, NULL, sparc_after_ra_walker, NULL);
266 }
267
268
269
270 /**
271  * Emits the code, closes the output file and frees
272  * the code generator interface.
273  */
274 static void sparc_emit_and_done(void *self)
275 {
276         sparc_code_gen_t *cg = self;
277         ir_graph           *irg = cg->irg;
278
279         sparc_gen_routine(cg, irg);
280
281         /* de-allocate code generator */
282         free(cg);
283 }
284
285 static void *sparc_cg_init(ir_graph *irg);
286
287 static const arch_code_generator_if_t sparc_code_gen_if = {
288         sparc_cg_init,
289         NULL,                    /* get_pic_base hook */
290         NULL,                    /* before abi introduce hook */
291         sparc_prepare_graph,
292         NULL,                    /* spill hook */
293         sparc_before_ra,      /* before register allocation hook */
294         sparc_after_ra,       /* after register allocation hook */
295         NULL,
296         sparc_emit_and_done
297 };
298
299 /**
300  * Initializes the code generator.
301  */
302 static void *sparc_cg_init(ir_graph *irg)
303 {
304         static ir_type *int_tp = NULL;
305         sparc_isa_t      *isa = (sparc_isa_t *) be_get_irg_arch_env(irg);
306         sparc_code_gen_t *cg;
307
308         if (! int_tp) {
309                 /* create an integer type with machine size */
310                 int_tp = new_type_primitive(mode_Is);
311         }
312
313         cg                               = XMALLOC(sparc_code_gen_t);
314         cg->impl                                = &sparc_code_gen_if;
315         cg->irg                         = irg;
316         //cg->reg_set                           = new_set(arm_cmp_irn_reg_assoc, 1024);
317         cg->isa                         = isa;
318         //cg->int_tp                            = int_tp;
319         //cg->have_fp_insn      = 0;
320         //cg->unknown_gp                = NULL;
321         //cg->unknown_fpa               = NULL;
322         cg->dump                                = (be_get_irg_options(irg)->dump_flags & DUMP_BE) ? 1 : 0;
323
324         /* enter the current code generator */
325         isa->cg = cg;
326
327         return (arch_code_generator_t *)cg;
328 }
329
330
331
332 const arch_isa_if_t sparc_isa_if;
333 static sparc_isa_t sparc_isa_template = {
334         {
335                 &sparc_isa_if,             /* isa interface implementation */
336                 &sparc_gp_regs[REG_SP],  /* stack pointer register */
337                 &sparc_gp_regs[REG_FP],  /* base pointer register */
338                 &sparc_reg_classes[CLASS_sparc_gp],  /* link pointer register class */
339                 -1,                          /* stack direction */
340                 1,                           /* power of two stack alignment for calls, 2^2 == 4 */
341                 NULL,                        /* main environment */
342                 7,                           /* costs for a spill instruction */
343                 5,                           /* costs for a reload instruction */
344                 false,                       /* no custom abi handling */
345         },
346         NULL                                            /* current code generator */
347 };
348
349
350 static void sparc_handle_intrinsics(void)
351 {
352         ir_type *tp, *int_tp, *uint_tp;
353         i_record records[8];
354         int n_records = 0;
355
356         runtime_rt rt_iMod, rt_uMod;
357
358 #define ID(x) new_id_from_chars(x, sizeof(x)-1)
359
360         int_tp  = new_type_primitive(mode_Is);
361         uint_tp = new_type_primitive(mode_Iu);
362
363
364         /* SPARC has no signed mod instruction ... */
365         {
366                 i_instr_record *map_Mod = &records[n_records++].i_instr;
367
368                 tp = new_type_method(2, 1);
369                 set_method_param_type(tp, 0, int_tp);
370                 set_method_param_type(tp, 1, int_tp);
371                 set_method_res_type(tp, 0, int_tp);
372
373                 rt_iMod.ent             = new_entity(get_glob_type(), ID(".rem"), tp);
374                 set_entity_ld_ident(rt_iMod.ent, ID(".rem"));
375                 rt_iMod.mode            = mode_T;
376                 rt_iMod.res_mode        = mode_Is;
377                 rt_iMod.mem_proj_nr     = pn_Mod_M;
378                 rt_iMod.regular_proj_nr = pn_Mod_X_regular;
379                 rt_iMod.exc_proj_nr     = pn_Mod_X_except;
380                 rt_iMod.exc_mem_proj_nr = pn_Mod_M;
381                 rt_iMod.res_proj_nr     = pn_Mod_res;
382
383                 set_entity_visibility(rt_iMod.ent, ir_visibility_external);
384
385                 map_Mod->kind     = INTRINSIC_INSTR;
386                 map_Mod->op       = op_Mod;
387                 map_Mod->i_mapper = (i_mapper_func)i_mapper_RuntimeCall;
388                 map_Mod->ctx      = &rt_iMod;
389         }
390         /* ... nor an unsigned mod. */
391         {
392                 i_instr_record *map_Mod = &records[n_records++].i_instr;
393
394                 tp = new_type_method(2, 1);
395                 set_method_param_type(tp, 0, uint_tp);
396                 set_method_param_type(tp, 1, uint_tp);
397                 set_method_res_type(tp, 0, uint_tp);
398
399                 rt_uMod.ent             = new_entity(get_glob_type(), ID(".urem"), tp);
400                 set_entity_ld_ident(rt_uMod.ent, ID(".urem"));
401                 rt_uMod.mode            = mode_T;
402                 rt_uMod.res_mode        = mode_Iu;
403                 rt_uMod.mem_proj_nr     = pn_Mod_M;
404                 rt_uMod.regular_proj_nr = pn_Mod_X_regular;
405                 rt_uMod.exc_proj_nr     = pn_Mod_X_except;
406                 rt_uMod.exc_mem_proj_nr = pn_Mod_M;
407                 rt_uMod.res_proj_nr     = pn_Mod_res;
408
409                 set_entity_visibility(rt_uMod.ent, ir_visibility_external);
410
411                 map_Mod->kind     = INTRINSIC_INSTR;
412                 map_Mod->op       = op_Mod;
413                 map_Mod->i_mapper = (i_mapper_func)i_mapper_RuntimeCall;
414                 map_Mod->ctx      = &rt_uMod;
415         }
416
417         if (n_records > 0)
418                 lower_intrinsics(records, n_records, /*part_block_used=*/0);
419 }
420
421
422 /**
423  * Initializes the backend ISA
424  */
425 static arch_env_t *sparc_init(FILE *outfile)
426 {
427         static int run_once = 0;
428         sparc_isa_t *isa;
429
430         if (run_once)
431                 return NULL;
432         run_once = 1;
433
434         isa = XMALLOC(sparc_isa_t);
435         memcpy(isa, &sparc_isa_template, sizeof(*isa));
436
437         be_emit_init(outfile);
438
439         sparc_register_init();
440         sparc_create_opcodes(&sparc_irn_ops);
441         sparc_handle_intrinsics();
442
443         return &isa->arch_env;
444 }
445
446
447
448 /**
449  * Closes the output file and frees the ISA structure.
450  */
451 static void sparc_done(void *self)
452 {
453         sparc_isa_t *isa = self;
454
455         /* emit now all global declarations */
456         be_gas_emit_decls(isa->arch_env.main_env);
457
458         be_emit_exit();
459         free(self);
460 }
461
462
463 static unsigned sparc_get_n_reg_class(void)
464 {
465         return N_CLASSES;
466 }
467
468 static const arch_register_class_t *sparc_get_reg_class(unsigned i)
469 {
470         assert(i < N_CLASSES);
471         return &sparc_reg_classes[i];
472 }
473
474
475
476 /**
477  * Get the register class which shall be used to store a value of a given mode.
478  * @param self The this pointer.
479  * @param mode The mode in question.
480  * @return A register class which can hold values of the given mode.
481  */
482 static const arch_register_class_t *sparc_get_reg_class_for_mode(const ir_mode *mode)
483 {
484         if (mode_is_float(mode))
485                 return &sparc_reg_classes[CLASS_sparc_fp];
486         else
487                 return &sparc_reg_classes[CLASS_sparc_gp];
488 }
489
490
491
492 typedef struct {
493         be_abi_call_flags_bits_t flags;
494         const arch_env_t *arch_env;
495         ir_graph *irg;
496 } sparc_abi_env_t;
497
498 static void *sparc_abi_init(const be_abi_call_t *call, const arch_env_t *arch_env, ir_graph *irg)
499 {
500         sparc_abi_env_t *env = XMALLOC(sparc_abi_env_t);
501         be_abi_call_flags_t fl = be_abi_call_get_flags(call);
502         env->flags    = fl.bits;
503         env->irg      = irg;
504         env->arch_env = arch_env;
505         return env;
506 }
507
508 /**
509  * Get the between type for that call.
510  * @param self The callback object.
511  * @return The between type of for that call.
512  */
513 static ir_type *sparc_get_between_type(void *self)
514 {
515         static ir_type *between_type = NULL;
516         (void) self;
517
518         if (between_type == NULL) {
519                 between_type = new_type_class(new_id_from_str("sparc_between_type"));
520                 set_type_size_bytes(between_type, 0);
521         }
522
523         return between_type;
524 }
525
526
527 /**
528  * Build the prolog, return the BASE POINTER register
529  */
530 static const arch_register_t *sparc_abi_prologue(void *self, ir_node **mem,
531                                                     pmap *reg_map, int *stack_bias)
532 {
533         sparc_abi_env_t *env = self;
534         ir_node *block = get_irg_start_block(env->irg);
535         const arch_register_t *fp = &sparc_gp_regs[REG_FP];
536         const arch_register_t *sp = &sparc_gp_regs[REG_SP];
537
538         // sp
539         ir_node *sp_proj = be_abi_reg_map_get(reg_map, sp);
540
541
542         //ir_type *frame_type = get_irg_frame_type(env->irg);
543         //frame_alloc_area(frame_type, reserved_stack_size, 1, 1);
544
545         // alloc min required stack space
546         // TODO: the min stacksize depends on wether this is a leaf procedure or not
547         ir_node *save = new_bd_sparc_Save(NULL, block, sp_proj, *mem, SPARC_MIN_STACKSIZE);
548
549         (void) reg_map;
550         (void) mem;
551         (void) stack_bias;
552
553         *stack_bias -= SPARC_MIN_STACKSIZE;
554         sp_proj = new_r_Proj(save, sp->reg_class->mode, pn_sparc_Save_stack);
555         *mem    = new_r_Proj(save, mode_M, pn_sparc_Save_mem);
556
557         arch_set_irn_register(sp_proj, sp);
558         be_abi_reg_map_set(reg_map, sp, sp_proj);
559
560         // we always have a framepointer
561         return fp;
562 }
563
564 /* Build the epilog */
565 static void sparc_abi_epilogue(void *self, ir_node *bl, ir_node **mem,
566                                   pmap *reg_map)
567 {
568         (void) self;
569         (void) bl;
570         (void) mem;
571         (void) reg_map;
572 }
573
574 static const be_abi_callbacks_t sparc_abi_callbacks = {
575         sparc_abi_init,
576         free,
577         sparc_get_between_type,
578         sparc_abi_prologue,
579         sparc_abi_epilogue,
580 };
581
582 /**
583  * Get the ABI restrictions for procedure calls.
584  * @param self        The this pointer.
585  * @param method_type The type of the method (procedure) in question.
586  * @param abi         The abi object to be modified
587  */
588 static void sparc_get_call_abi(const void *self, ir_type *method_type,
589                                be_abi_call_t *abi)
590 {
591         ir_type  *tp;
592         ir_mode  *mode;
593         int       i, n = get_method_n_params(method_type);
594         be_abi_call_flags_t call_flags;
595         (void) self;
596
597         /* set abi flags for calls */
598         call_flags.bits.left_to_right         = 0;
599         call_flags.bits.store_args_sequential = 1;
600         /* */
601         call_flags.bits.try_omit_fp           = 0;
602         call_flags.bits.fp_free               = 0;
603         call_flags.bits.call_has_imm          = 1;
604
605         /* set stack parameter passing style */
606         be_abi_call_set_flags(abi, call_flags, &sparc_abi_callbacks);
607
608         for (i = 0; i < n; i++) {
609                 /* reg = get reg for param i;          */
610                 /* be_abi_call_param_reg(abi, i, reg); */
611
612                 /* pass outgoing params 0-5 via registers, remaining via stack */
613                 /* on sparc we need to set the ABI context since register names of parameters change to i0-i5 if we are the callee */
614                 if (i < 6) {
615                         be_abi_call_param_reg(abi, i, sparc_get_RegParamOut_reg(i), ABI_CONTEXT_CALLER);
616                         be_abi_call_param_reg(abi, i, sparc_get_RegParamIn_reg(i), ABI_CONTEXT_CALLEE);
617                 } else {
618                         tp   = get_method_param_type(method_type, i);
619                         mode = get_type_mode(tp);
620                         be_abi_call_param_stack(abi, i, mode, 4, 0, 0, ABI_CONTEXT_BOTH); /*< stack args have no special context >*/
621                 }
622         }
623
624         /* set return value register: return value is in i0 resp. f0 */
625         if (get_method_n_ress(method_type) > 0) {
626                 tp   = get_method_res_type(method_type, 0);
627                 mode = get_type_mode(tp);
628
629                 be_abi_call_res_reg(abi, 0,
630                         mode_is_float(mode) ? &sparc_fp_regs[REG_F0] : &sparc_gp_regs[REG_I0], ABI_CONTEXT_CALLEE); /*< return has no special context >*/
631
632                 be_abi_call_res_reg(abi, 0,
633                                         mode_is_float(mode) ? &sparc_fp_regs[REG_F0] : &sparc_gp_regs[REG_O0], ABI_CONTEXT_CALLER); /*< return has no special context >*/
634         }
635 }
636
637 static int sparc_to_appear_in_schedule(void *block_env, const ir_node *irn)
638 {
639         (void) block_env;
640
641         if (!is_sparc_irn(irn))
642                 return -1;
643
644         return 1;
645 }
646
647 /**
648  * Initializes the code generator interface.
649  */
650 static const arch_code_generator_if_t *sparc_get_code_generator_if(
651                 void *self)
652 {
653         (void) self;
654         return &sparc_code_gen_if;
655 }
656
657 list_sched_selector_t sparc_sched_selector;
658
659 /**
660  * Returns the reg_pressure scheduler with to_appear_in_schedule() overloaded
661  */
662 static const list_sched_selector_t *sparc_get_list_sched_selector(
663                 const void *self, list_sched_selector_t *selector)
664 {
665         (void) self;
666         (void) selector;
667
668         sparc_sched_selector = trivial_selector;
669         sparc_sched_selector.to_appear_in_schedule = sparc_to_appear_in_schedule;
670         return &sparc_sched_selector;
671 }
672
673 static const ilp_sched_selector_t *sparc_get_ilp_sched_selector(
674                 const void *self)
675 {
676         (void) self;
677         return NULL;
678 }
679
680 /**
681  * Returns the necessary byte alignment for storing a register of given class.
682  */
683 static int sparc_get_reg_class_alignment(const arch_register_class_t *cls)
684 {
685         ir_mode *mode = arch_register_class_mode(cls);
686         return get_mode_size_bytes(mode);
687 }
688
689 /**
690  * Returns the libFirm configuration parameter for this backend.
691  */
692 static const backend_params *sparc_get_backend_params(void)
693 {
694         static backend_params p = {
695                 0,     /* no dword lowering */
696                 0,     /* no inline assembly */
697                 NULL,  /* will be set later */
698                 NULL,  /* no creator function */
699                 NULL,  /* context for create_intrinsic_fkt */
700                 NULL,  /* parameter for if conversion */
701                 NULL,  /* float arithmetic mode */
702                 0,     /* no trampoline support: size 0 */
703                 0,     /* no trampoline support: align 0 */
704                 NULL,  /* no trampoline support: no trampoline builder */
705                 4      /* alignment of stack parameter: typically 4 (32bit) or 8 (64bit) */
706         };
707         return &p;
708 }
709
710 static const be_execution_unit_t ***sparc_get_allowed_execution_units(
711                 const ir_node *irn)
712 {
713         (void) irn;
714         /* TODO */
715         panic("sparc_get_allowed_execution_units not implemented yet");
716 }
717
718 static const be_machine_t *sparc_get_machine(const void *self)
719 {
720         (void) self;
721         /* TODO */
722         panic("sparc_get_machine not implemented yet");
723 }
724
725 static ir_graph **sparc_get_backend_irg_list(const void *self,
726                                                 ir_graph ***irgs)
727 {
728         (void) self;
729         (void) irgs;
730         return NULL;
731 }
732
733 static asm_constraint_flags_t sparc_parse_asm_constraint(const char **c)
734 {
735         (void) c;
736         return ASM_CONSTRAINT_FLAG_INVALID;
737 }
738
739 static int sparc_is_valid_clobber(const char *clobber)
740 {
741         (void) clobber;
742         return 0;
743 }
744
745 const arch_isa_if_t sparc_isa_if = {
746         sparc_init,
747         sparc_done,
748         NULL,                /* handle intrinsics */
749         sparc_get_n_reg_class,
750         sparc_get_reg_class,
751         sparc_get_reg_class_for_mode,
752         sparc_get_call_abi,
753         sparc_get_code_generator_if,
754         sparc_get_list_sched_selector,
755         sparc_get_ilp_sched_selector,
756         sparc_get_reg_class_alignment,
757     sparc_get_backend_params,
758         sparc_get_allowed_execution_units,
759         sparc_get_machine,
760         sparc_get_backend_irg_list,
761         NULL,                    /* mark remat */
762         sparc_parse_asm_constraint,
763         sparc_is_valid_clobber
764 };
765
766 BE_REGISTER_MODULE_CONSTRUCTOR(be_init_arch_sparc);
767 void be_init_arch_sparc(void)
768 {
769         be_register_isa_if("sparc", &sparc_isa_if);
770         FIRM_DBG_REGISTER(dbg, "firm.be.sparc.cg");
771         sparc_init_transform();
772         sparc_init_emitter();
773 }