c9a6c1a09a0e558abd9095fec1f0fe4ba01d9664
[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         cg->constants = pmap_create();
306
307         /* enter the current code generator */
308         isa->cg = cg;
309
310         return (arch_code_generator_t*) cg;
311 }
312
313 const arch_isa_if_t sparc_isa_if;
314 static sparc_isa_t sparc_isa_template = {
315         {
316                 &sparc_isa_if,           /* isa interface implementation */
317                 &sparc_gp_regs[REG_SP],  /* stack pointer register */
318                 &sparc_gp_regs[REG_FP],  /* base pointer register */
319                 &sparc_reg_classes[CLASS_sparc_gp],  /* link pointer register class */
320                 -1,                          /* stack direction */
321                 3,                           /* power of two stack alignment for calls, 2^2 == 4 */
322                 NULL,                        /* main environment */
323                 7,                           /* costs for a spill instruction */
324                 5,                           /* costs for a reload instruction */
325                 false,                       /* no custom abi handling */
326         },
327         NULL                                            /* current code generator */
328 };
329
330
331 static void sparc_handle_intrinsics(void)
332 {
333         ir_type *tp, *int_tp, *uint_tp;
334         i_record records[8];
335         int n_records = 0;
336
337         runtime_rt rt_iMod, rt_uMod;
338
339 #define ID(x) new_id_from_chars(x, sizeof(x)-1)
340
341         int_tp  = new_type_primitive(mode_Is);
342         uint_tp = new_type_primitive(mode_Iu);
343
344
345         /* SPARC has no signed mod instruction ... */
346         {
347                 i_instr_record *map_Mod = &records[n_records++].i_instr;
348
349                 tp = new_type_method(2, 1);
350                 set_method_param_type(tp, 0, int_tp);
351                 set_method_param_type(tp, 1, int_tp);
352                 set_method_res_type(tp, 0, int_tp);
353
354                 rt_iMod.ent             = new_entity(get_glob_type(), ID(".rem"), tp);
355                 set_entity_ld_ident(rt_iMod.ent, ID(".rem"));
356                 rt_iMod.mode            = mode_T;
357                 rt_iMod.res_mode        = mode_Is;
358                 rt_iMod.mem_proj_nr     = pn_Mod_M;
359                 rt_iMod.regular_proj_nr = pn_Mod_X_regular;
360                 rt_iMod.exc_proj_nr     = pn_Mod_X_except;
361                 rt_iMod.exc_mem_proj_nr = pn_Mod_M;
362                 rt_iMod.res_proj_nr     = pn_Mod_res;
363
364                 set_entity_visibility(rt_iMod.ent, ir_visibility_external);
365
366                 map_Mod->kind     = INTRINSIC_INSTR;
367                 map_Mod->op       = op_Mod;
368                 map_Mod->i_mapper = (i_mapper_func)i_mapper_RuntimeCall;
369                 map_Mod->ctx      = &rt_iMod;
370         }
371         /* ... nor an unsigned mod. */
372         {
373                 i_instr_record *map_Mod = &records[n_records++].i_instr;
374
375                 tp = new_type_method(2, 1);
376                 set_method_param_type(tp, 0, uint_tp);
377                 set_method_param_type(tp, 1, uint_tp);
378                 set_method_res_type(tp, 0, uint_tp);
379
380                 rt_uMod.ent             = new_entity(get_glob_type(), ID(".urem"), tp);
381                 set_entity_ld_ident(rt_uMod.ent, ID(".urem"));
382                 rt_uMod.mode            = mode_T;
383                 rt_uMod.res_mode        = mode_Iu;
384                 rt_uMod.mem_proj_nr     = pn_Mod_M;
385                 rt_uMod.regular_proj_nr = pn_Mod_X_regular;
386                 rt_uMod.exc_proj_nr     = pn_Mod_X_except;
387                 rt_uMod.exc_mem_proj_nr = pn_Mod_M;
388                 rt_uMod.res_proj_nr     = pn_Mod_res;
389
390                 set_entity_visibility(rt_uMod.ent, ir_visibility_external);
391
392                 map_Mod->kind     = INTRINSIC_INSTR;
393                 map_Mod->op       = op_Mod;
394                 map_Mod->i_mapper = (i_mapper_func)i_mapper_RuntimeCall;
395                 map_Mod->ctx      = &rt_uMod;
396         }
397
398         if (n_records > 0)
399                 lower_intrinsics(records, n_records, /*part_block_used=*/0);
400 }
401
402
403 /**
404  * Initializes the backend ISA
405  */
406 static arch_env_t *sparc_init(FILE *outfile)
407 {
408         static int run_once = 0;
409         sparc_isa_t *isa;
410
411         if (run_once)
412                 return NULL;
413         run_once = 1;
414
415         isa = XMALLOC(sparc_isa_t);
416         memcpy(isa, &sparc_isa_template, sizeof(*isa));
417
418         be_emit_init(outfile);
419
420         sparc_register_init();
421         sparc_create_opcodes(&sparc_irn_ops);
422         sparc_handle_intrinsics();
423
424         return &isa->base;
425 }
426
427
428
429 /**
430  * Closes the output file and frees the ISA structure.
431  */
432 static void sparc_done(void *self)
433 {
434         sparc_isa_t *isa = self;
435
436         /* emit now all global declarations */
437         be_gas_emit_decls(isa->base.main_env);
438
439         be_emit_exit();
440         free(self);
441 }
442
443
444 static unsigned sparc_get_n_reg_class(void)
445 {
446         return N_CLASSES;
447 }
448
449 static const arch_register_class_t *sparc_get_reg_class(unsigned i)
450 {
451         assert(i < N_CLASSES);
452         return &sparc_reg_classes[i];
453 }
454
455
456
457 /**
458  * Get the register class which shall be used to store a value of a given mode.
459  * @param self The this pointer.
460  * @param mode The mode in question.
461  * @return A register class which can hold values of the given mode.
462  */
463 static const arch_register_class_t *sparc_get_reg_class_for_mode(const ir_mode *mode)
464 {
465         if (mode_is_float(mode))
466                 return &sparc_reg_classes[CLASS_sparc_fp];
467         else
468                 return &sparc_reg_classes[CLASS_sparc_gp];
469 }
470
471
472
473 typedef struct {
474         be_abi_call_flags_bits_t flags;
475         ir_graph                *irg;
476 } sparc_abi_env_t;
477
478 static void *sparc_abi_init(const be_abi_call_t *call, ir_graph *irg)
479 {
480         sparc_abi_env_t *env = XMALLOC(sparc_abi_env_t);
481         be_abi_call_flags_t fl = be_abi_call_get_flags(call);
482         env->flags    = fl.bits;
483         env->irg      = irg;
484         return env;
485 }
486
487 /**
488  * Get the between type for that call.
489  * @param self The callback object.
490  * @return The between type of for that call.
491  */
492 static ir_type *sparc_get_between_type(void *self)
493 {
494         static ir_type *between_type = NULL;
495         (void) self;
496
497         if (between_type == NULL) {
498                 between_type = new_type_class(new_id_from_str("sparc_between_type"));
499                 set_type_size_bytes(between_type, SPARC_MIN_STACKSIZE);
500         }
501
502         return between_type;
503 }
504
505
506 /**
507  * Build the prolog, return the BASE POINTER register
508  */
509 static const arch_register_t *sparc_abi_prologue(void *self, ir_node **mem,
510                                                  pmap *reg_map, int *stack_bias)
511 {
512         sparc_abi_env_t *env = self;
513         ir_node *block = get_irg_start_block(env->irg);
514         const arch_register_t *fp = &sparc_gp_regs[REG_FP];
515         const arch_register_t *sp = &sparc_gp_regs[REG_SP];
516
517         // sp
518         ir_node *sp_proj = be_abi_reg_map_get(reg_map, sp);
519
520
521         //ir_type *frame_type = get_irg_frame_type(env->irg);
522         //frame_alloc_area(frame_type, reserved_stack_size, 1, 1);
523
524         // alloc min required stack space
525         // TODO: the min stacksize depends on wether this is a leaf procedure or not
526         ir_node *save = new_bd_sparc_Save(NULL, block, sp_proj, *mem, SPARC_MIN_STACKSIZE);
527
528         (void) reg_map;
529         (void) mem;
530         (void) stack_bias;
531
532         sp_proj = new_r_Proj(save, sp->reg_class->mode, pn_sparc_Save_stack);
533         *mem    = new_r_Proj(save, mode_M, pn_sparc_Save_mem);
534
535         arch_set_irn_register(sp_proj, sp);
536         be_abi_reg_map_set(reg_map, sp, sp_proj);
537
538         // we always have a framepointer
539         return fp;
540 }
541
542 /* Build the epilog */
543 static void sparc_abi_epilogue(void *self, ir_node *bl, ir_node **mem,
544                                pmap *reg_map)
545 {
546         (void) self;
547         (void) bl;
548         (void) mem;
549         (void) reg_map;
550 }
551
552 static const be_abi_callbacks_t sparc_abi_callbacks = {
553         sparc_abi_init,
554         free,
555         sparc_get_between_type,
556         sparc_abi_prologue,
557         sparc_abi_epilogue,
558 };
559
560 static const arch_register_t *gp_param_out_regs[] = {
561         &sparc_gp_regs[REG_O0],
562         &sparc_gp_regs[REG_O1],
563         &sparc_gp_regs[REG_O2],
564         &sparc_gp_regs[REG_O3],
565         &sparc_gp_regs[REG_O4],
566         &sparc_gp_regs[REG_O5],
567 };
568
569 static const arch_register_t *gp_param_in_regs[] = {
570         &sparc_gp_regs[REG_I0],
571         &sparc_gp_regs[REG_I1],
572         &sparc_gp_regs[REG_I2],
573         &sparc_gp_regs[REG_I3],
574         &sparc_gp_regs[REG_I4],
575         &sparc_gp_regs[REG_I5],
576 };
577
578 /**
579  * get register for outgoing parameters 1-6
580  */
581 static const arch_register_t *sparc_get_RegParamOut_reg(int n)
582 {
583         assert(n < 6 && n >=0 && "trying to get (out) register for param >= 6");
584         return gp_param_out_regs[n];
585 }
586
587 /**
588  * get register for incoming parameters 1-6
589  */
590 static const arch_register_t *sparc_get_RegParamIn_reg(int n)
591 {
592         assert(n < 6 && n >=0 && "trying to get (in) register for param >= 6");
593         return gp_param_in_regs[n];
594 }
595
596 /**
597  * Get the ABI restrictions for procedure calls.
598  * @param self        The this pointer.
599  * @param method_type The type of the method (procedure) in question.
600  * @param abi         The abi object to be modified
601  */
602 static void sparc_get_call_abi(const void *self, ir_type *method_type,
603                                be_abi_call_t *abi)
604 {
605         ir_type  *tp;
606         ir_mode  *mode;
607         int       i, n = get_method_n_params(method_type);
608         be_abi_call_flags_t call_flags;
609         (void) self;
610
611         /* set abi flags for calls */
612         call_flags.bits.left_to_right         = 0;
613         call_flags.bits.store_args_sequential = 1;
614         call_flags.bits.try_omit_fp           = 0;
615         call_flags.bits.fp_free               = 0;
616         call_flags.bits.call_has_imm          = 1;
617
618         /* set stack parameter passing style */
619         be_abi_call_set_flags(abi, call_flags, &sparc_abi_callbacks);
620
621         for (i = 0; i < n; i++) {
622                 ir_type *type = get_method_param_type(method_type, i);
623                 ir_mode *mode = get_type_mode(type);
624
625                 if (mode_is_float(mode) || i >= 6) {
626                         unsigned align = get_type_size_bytes(type);
627                         be_abi_call_param_stack(abi, i, mode, align, 0, 0,
628                                                 ABI_CONTEXT_BOTH);
629                         continue;
630                 }
631
632                 /* pass integer params 0-5 via registers.
633                  * On sparc we need to set the ABI context since register names of
634                  * parameters change to i0-i5 if we are the callee */
635                 be_abi_call_param_reg(abi, i, sparc_get_RegParamOut_reg(i),
636                                       ABI_CONTEXT_CALLER);
637                 be_abi_call_param_reg(abi, i, sparc_get_RegParamIn_reg(i),
638                                       ABI_CONTEXT_CALLEE);
639         }
640
641         n = get_method_n_ress(method_type);
642         /* more than 1 result not supported */
643         assert(n <= 1);
644         for (i = 0; i < n; ++i) {
645                 tp   = get_method_res_type(method_type, i);
646                 mode = get_type_mode(tp);
647
648                 /* set return value register: return value is in i0 resp. f0 */
649                 if (mode_is_float(mode)) {
650                         be_abi_call_res_reg(abi, i, &sparc_fp_regs[REG_F0],
651                                             ABI_CONTEXT_BOTH);
652                 } else {
653                         be_abi_call_res_reg(abi, i, &sparc_gp_regs[REG_I0],
654                                             ABI_CONTEXT_CALLEE);
655                         be_abi_call_res_reg(abi, i, &sparc_gp_regs[REG_O0],
656                                             ABI_CONTEXT_CALLER);
657                 }
658         }
659 }
660
661 static int sparc_to_appear_in_schedule(void *block_env, const ir_node *irn)
662 {
663         (void) block_env;
664
665         if (!is_sparc_irn(irn))
666                 return -1;
667
668         return 1;
669 }
670
671 /**
672  * Initializes the code generator interface.
673  */
674 static const arch_code_generator_if_t *sparc_get_code_generator_if(
675                 void *self)
676 {
677         (void) self;
678         return &sparc_code_gen_if;
679 }
680
681 list_sched_selector_t sparc_sched_selector;
682
683 /**
684  * Returns the reg_pressure scheduler with to_appear_in_schedule() overloaded
685  */
686 static const list_sched_selector_t *sparc_get_list_sched_selector(
687                 const void *self, list_sched_selector_t *selector)
688 {
689         (void) self;
690         (void) selector;
691
692         sparc_sched_selector = trivial_selector;
693         sparc_sched_selector.to_appear_in_schedule = sparc_to_appear_in_schedule;
694         return &sparc_sched_selector;
695 }
696
697 static const ilp_sched_selector_t *sparc_get_ilp_sched_selector(
698                 const void *self)
699 {
700         (void) self;
701         return NULL;
702 }
703
704 /**
705  * Returns the necessary byte alignment for storing a register of given class.
706  */
707 static int sparc_get_reg_class_alignment(const arch_register_class_t *cls)
708 {
709         ir_mode *mode = arch_register_class_mode(cls);
710         return get_mode_size_bytes(mode);
711 }
712
713 /**
714  * Returns the libFirm configuration parameter for this backend.
715  */
716 static const backend_params *sparc_get_backend_params(void)
717 {
718         static backend_params p = {
719                 0,     /* no dword lowering */
720                 0,     /* no inline assembly */
721                 NULL,  /* will be set later */
722                 NULL,  /* no creator function */
723                 NULL,  /* context for create_intrinsic_fkt */
724                 NULL,  /* parameter for if conversion */
725                 NULL,  /* float arithmetic mode */
726                 0,     /* no trampoline support: size 0 */
727                 0,     /* no trampoline support: align 0 */
728                 NULL,  /* no trampoline support: no trampoline builder */
729                 4      /* alignment of stack parameter: typically 4 (32bit) or 8 (64bit) */
730         };
731         return &p;
732 }
733
734 static const be_execution_unit_t ***sparc_get_allowed_execution_units(
735                 const ir_node *irn)
736 {
737         (void) irn;
738         /* TODO */
739         panic("sparc_get_allowed_execution_units not implemented yet");
740 }
741
742 static const be_machine_t *sparc_get_machine(const void *self)
743 {
744         (void) self;
745         /* TODO */
746         panic("sparc_get_machine not implemented yet");
747 }
748
749 static ir_graph **sparc_get_backend_irg_list(const void *self,
750                                              ir_graph ***irgs)
751 {
752         (void) self;
753         (void) irgs;
754         return NULL;
755 }
756
757 static asm_constraint_flags_t sparc_parse_asm_constraint(const char **c)
758 {
759         (void) c;
760         return ASM_CONSTRAINT_FLAG_INVALID;
761 }
762
763 static int sparc_is_valid_clobber(const char *clobber)
764 {
765         (void) clobber;
766         return 0;
767 }
768
769 const arch_isa_if_t sparc_isa_if = {
770         sparc_init,
771         sparc_done,
772         NULL,                /* handle intrinsics */
773         sparc_get_n_reg_class,
774         sparc_get_reg_class,
775         sparc_get_reg_class_for_mode,
776         sparc_get_call_abi,
777         sparc_get_code_generator_if,
778         sparc_get_list_sched_selector,
779         sparc_get_ilp_sched_selector,
780         sparc_get_reg_class_alignment,
781         sparc_get_backend_params,
782         sparc_get_allowed_execution_units,
783         sparc_get_machine,
784         sparc_get_backend_irg_list,
785         NULL,                    /* mark remat */
786         sparc_parse_asm_constraint,
787         sparc_is_valid_clobber
788 };
789
790 BE_REGISTER_MODULE_CONSTRUCTOR(be_init_arch_sparc);
791 void be_init_arch_sparc(void)
792 {
793         be_register_isa_if("sparc", &sparc_isa_if);
794         FIRM_DBG_REGISTER(dbg, "firm.be.sparc.cg");
795         sparc_init_transform();
796         sparc_init_emitter();
797 }