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