Remove address name SymConsts.
[libfirm] / ir / be / ppc32 / bearch_ppc32.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 ppc backend driver file.
23  * @author  Moritz Kroll, Jens Mueller
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 "irdump.h"
35
36 #include "bitset.h"
37 #include "debug.h"
38 #include "error.h"
39
40 #include "../bearch.h"
41 #include "../benode.h"
42 #include "../belower.h"
43 #include "../besched.h"
44 #include "be.h"
45 #include "../beabi.h"
46 #include "../bemachine.h"
47 #include "../bemodule.h"
48 #include "../bespillslots.h"
49 #include "../beblocksched.h"
50 #include "../beirg.h"
51 #include "../begnuas.h"
52 #include "../belistsched.h"
53
54 #include "pset.h"
55
56 #include "bearch_ppc32_t.h"
57
58 #include "ppc32_new_nodes.h"
59 #include "gen_ppc32_regalloc_if.h"
60 #include "ppc32_transform.h"
61 #include "ppc32_transform_conv.h"
62 #include "ppc32_emitter.h"
63 #include "ppc32_map_regs.h"
64
65 #define DEBUG_MODULE "firm.be.ppc.isa"
66
67 int isleaf;
68
69 /* TODO: ugly, but we need it to get access to the registers assigned to Phi nodes */
70 static set *cur_reg_set = NULL;
71
72 /**************************************************
73  *                         _ _              _  __
74  *                        | | |            (_)/ _|
75  *  _ __ ___  __ _    __ _| | | ___   ___   _| |_
76  * | '__/ _ \/ _` |  / _` | | |/ _ \ / __| | |  _|
77  * | | |  __/ (_| | | (_| | | | (_) | (__  | | |
78  * |_|  \___|\__, |  \__,_|_|_|\___/ \___| |_|_|
79  *            __/ |
80  *           |___/
81  **************************************************/
82
83 static arch_irn_class_t ppc32_classify(const ir_node *irn)
84 {
85         (void) irn;
86         return 0;
87 }
88
89 static ir_entity *ppc32_get_frame_entity(const ir_node *irn)
90 {
91         if (!is_ppc32_irn(irn)) return NULL;
92         if (get_ppc32_type(irn)!=ppc32_ac_FrameEntity) return NULL;
93         return get_ppc32_frame_entity(irn);
94 }
95
96 static void ppc32_set_frame_entity(ir_node *irn, ir_entity *ent)
97 {
98         if (! is_ppc32_irn(irn) || get_ppc32_type(irn) != ppc32_ac_FrameEntity)
99                 return;
100         set_ppc32_frame_entity(irn, ent);
101 }
102
103 /**
104  * This function is called by the generic backend to correct offsets for
105  * nodes accessing the stack.
106  */
107 static void ppc32_set_stack_bias(ir_node *irn, int bias)
108 {
109         set_ppc32_offset(irn, bias);
110 }
111
112 static int ppc32_get_sp_bias(const ir_node *irn)
113 {
114         (void) irn;
115         return 0;
116 }
117
118 typedef struct
119 {
120         const be_abi_call_t *call;
121         ir_graph *irg;
122 } ppc32_abi_env;
123
124 /**
125  * Initialize the callback object.
126  * @param call The call object.
127  * @param aenv The architecture environment.
128  * @param irg  The graph with the method.
129  * @return     Some pointer. This pointer is passed to all other callback functions as self object.
130  */
131 static void *ppc32_abi_init(const be_abi_call_t *call, const arch_env_t *aenv, ir_graph *irg)
132 {
133         ppc32_abi_env *env = XMALLOC(ppc32_abi_env);
134         (void) aenv;
135
136         env->call = call;
137         env->irg = irg;
138         return env;
139 }
140
141 /**
142  * Destroy the callback object.
143  * @param self The callback object.
144  */
145 static void ppc32_abi_done(void *self)
146 {
147         free(self);
148 }
149
150 /**
151  * Get the between type for that call.
152  * @param self The callback object.
153  * @return The between type of for that call.
154  */
155 static ir_type *ppc32_abi_get_between_type(void *self)
156 {
157         static ir_type *between_type = NULL;
158         static ir_entity *old_bp_ent = NULL;
159         (void) self;
160
161         if (!between_type) {
162                 ir_entity *ret_addr_ent;
163                 ir_type *ret_addr_type = new_type_primitive(mode_P);
164                 ir_type *old_bp_type   = new_type_primitive(mode_P);
165
166                 between_type           = new_type_class(new_id_from_str("ppc32_between_type"));
167                 old_bp_ent             = new_entity(between_type, new_id_from_str("old_bp"), old_bp_type);
168                 ret_addr_ent           = new_entity(between_type, new_id_from_str("old_bp"), ret_addr_type);
169
170                 set_entity_offset(old_bp_ent, 0);
171                 set_entity_offset(ret_addr_ent, get_type_size_bytes(old_bp_type));
172                 set_type_size_bytes(between_type, get_type_size_bytes(old_bp_type) + get_type_size_bytes(ret_addr_type));
173         }
174
175         return between_type;
176 }
177
178 /**
179  * Generate the prologue.
180  * @param self       The callback object.
181  * @param mem        A pointer to the mem node. Update this if you define new memory.
182  * @param reg_map    A mapping mapping all callee_save/ignore/parameter registers to their defining nodes.
183  * @param stack_bias Points to the current stack bias, can be modified if needed.
184  *
185  * @return        The register which shall be used as a stack frame base.
186  *
187  * All nodes which define registers in @p reg_map must keep @p reg_map current.
188  */
189 static const arch_register_t *ppc32_abi_prologue(void *self, ir_node **mem, pmap *reg_map, int *stack_bias)
190 {
191         ppc32_abi_env *env = (ppc32_abi_env *) self;
192         be_abi_call_flags_t flags = be_abi_call_get_flags(env->call);
193         (void) mem;
194         (void) reg_map;
195         (void) stack_bias;
196         isleaf = flags.bits.irg_is_leaf;
197
198         if (flags.bits.try_omit_fp)
199                 return &ppc32_gp_regs[REG_R1];
200         else
201                 return &ppc32_gp_regs[REG_R31];
202 }
203
204 /**
205  * Generate the epilogue.
206  * @param self    The callback object.
207  * @param mem     Memory one can attach to.
208  * @param reg_map A mapping mapping all callee_save/ignore/return registers to their defining nodes.
209  *
210  * All nodes which define registers in @p reg_map must keep @p reg_map current.
211  * Also, the @p mem variable must be updated, if memory producing nodes are inserted.
212  */
213 static void ppc32_abi_epilogue(void *self, ir_node *bl, ir_node **mem, pmap *reg_map)
214 {
215         (void) self;
216         (void) bl;
217         (void) mem;
218         (void) reg_map;
219 }
220
221 static const be_abi_callbacks_t ppc32_abi_callbacks = {
222         ppc32_abi_init,
223         ppc32_abi_done,
224         ppc32_abi_get_between_type,
225         ppc32_abi_prologue,
226         ppc32_abi_epilogue,
227 };
228
229 /* fill register allocator interface */
230
231 static const arch_irn_ops_t ppc32_irn_ops = {
232         get_ppc32_in_req,
233         ppc32_classify,
234         ppc32_get_frame_entity,
235         ppc32_set_frame_entity,
236         ppc32_set_stack_bias,
237         ppc32_get_sp_bias,
238         NULL,    /* get_inverse             */
239         NULL,    /* get_op_estimated_cost   */
240         NULL,    /* possible_memory_operand */
241         NULL,    /* perform_memory_operand  */
242 };
243
244 /**************************************************
245  *                _                         _  __
246  *               | |                       (_)/ _|
247  *   ___ ___   __| | ___  __ _  ___ _ __    _| |_
248  *  / __/ _ \ / _` |/ _ \/ _` |/ _ \ '_ \  | |  _|
249  * | (_| (_) | (_| |  __/ (_| |  __/ | | | | | |
250  *  \___\___/ \__,_|\___|\__, |\___|_| |_| |_|_|
251  *                        __/ |
252  *                       |___/
253  **************************************************/
254
255 static void ppc32_before_abi(void *self)
256 {
257         ppc32_code_gen_t *cg = self;
258         ir_type *frame_type = get_irg_frame_type(cg->irg);
259
260         frame_alloc_area(frame_type, 24, 4, 1);
261
262         ppc32_init_conv_walk();
263         irg_walk_blkwise_graph(cg->irg, NULL, ppc32_conv_walk, cg);
264
265         if (cg->area_size) {
266                 if (cg->area_size < 32) cg->area_size = 32;
267                 cg->area = frame_alloc_area(get_irg_frame_type(cg->irg), cg->area_size+24, 16, 1);
268         }
269 }
270
271 static void ppc32_search_start_successor(ir_node *block, void *env)
272 {
273         ppc32_code_gen_t *cg = env;
274         int n = get_Block_n_cfgpreds(block);
275         ir_node *startblock = get_irg_start_block(cg->irg);
276         if (block == startblock) return;
277
278         for (n--; n >= 0; n--) {
279                 ir_node *predblock = get_irn_n(get_Block_cfgpred(block, n), -1);
280                 if (predblock == startblock)
281                 {
282                         cg->start_succ_block = block;
283                         return;
284                 }
285         }
286 }
287
288 /**
289  * Transforms the standard firm graph into
290  * a ppc firm graph
291  */
292 static void ppc32_prepare_graph(void *self)
293 {
294         ppc32_code_gen_t *cg = self;
295
296         irg_block_walk_graph(cg->irg, NULL, ppc32_search_start_successor, cg);
297         irg_walk_blkwise_graph(cg->irg, NULL, ppc32_pretransform_walk, cg);
298         be_dump(cg->irg, "-pretransformed", dump_ir_block_graph);
299
300         ppc32_register_transformers();
301         irg_walk_blkwise_graph(cg->irg, NULL, ppc32_transform_node, cg);
302         be_dump(cg->irg, "-transformed", dump_ir_block_graph);
303         irg_walk_blkwise_graph(cg->irg, NULL, ppc32_transform_const, cg);
304 }
305
306
307
308 /**
309  * Called immediatly before emit phase.
310  */
311 static void ppc32_finish_irg(void *self)
312 {
313         (void) self;
314         /* TODO: - fix offsets for nodes accessing stack
315                          - ...
316         */
317 }
318
319
320 /**
321  * Called before the register allocator.
322  * Calculate a block schedule here. We need it for the x87
323  * simulator and the emitter.
324  */
325 static void ppc32_before_ra(void *self)
326 {
327         ppc32_code_gen_t *cg = self;
328         cg->blk_sched = be_create_block_schedule(cg->irg, cg->birg->exec_freq);
329 }
330
331 static void ppc32_transform_spill(ir_node *node, void *env)
332 {
333         (void)env;
334
335         if (be_is_Spill(node))
336         {
337                 ir_node  *store, *proj;
338                 dbg_info *dbg   = get_irn_dbg_info(node);
339                 ir_node  *block = get_nodes_block(node);
340
341                 const arch_register_class_t *regclass = arch_get_irn_reg_class(node, 1);
342
343                 if (regclass == &ppc32_reg_classes[CLASS_ppc32_gp])
344                 {
345                         store = new_bd_ppc32_Stw(dbg, block,
346                                 get_irn_n(node, 0), get_irn_n(node, 1), new_NoMem());
347                 }
348                 else if (regclass == &ppc32_reg_classes[CLASS_ppc32_fp])
349                 {
350                         store = new_bd_ppc32_Stfd(dbg, block,
351                                 get_irn_n(node, 0), get_irn_n(node, 1), new_NoMem());
352                 }
353                 else panic("Spill for register class not supported yet!");
354
355                 set_ppc32_frame_entity(store, be_get_frame_entity(node));
356
357                 proj = new_rd_Proj(dbg, block, store, mode_M, pn_Store_M);
358
359                 if (sched_is_scheduled(node)) {
360                         sched_add_after(sched_prev(node), store);
361                         sched_add_after(store, proj);
362
363                         sched_remove(node);
364                 }
365
366                 exchange(node, proj);
367         }
368
369         if (be_is_Reload(node))
370         {
371                 ir_node *load, *proj;
372                 const arch_register_t *reg;
373                 dbg_info *dbg   = get_irn_dbg_info(node);
374                 ir_node  *block = get_nodes_block(node);
375                 ir_mode  *mode  = get_irn_mode(node);
376
377                 const arch_register_class_t *regclass = arch_get_irn_reg_class_out(node);
378
379                 if (regclass == &ppc32_reg_classes[CLASS_ppc32_gp])
380                 {
381                         load = new_bd_ppc32_Lwz(dbg, block,     get_irn_n(node, 0), get_irn_n(node, 1));
382                 }
383                 else if (regclass == &ppc32_reg_classes[CLASS_ppc32_fp])
384                 {
385                         load = new_bd_ppc32_Lfd(dbg, block,     get_irn_n(node, 0), get_irn_n(node, 1));
386                 }
387                 else panic("Reload for register class not supported yet!");
388
389                 set_ppc32_frame_entity(load, be_get_frame_entity(node));
390
391                 proj = new_rd_Proj(dbg, block, load, mode, pn_Load_res);
392
393                 if (sched_is_scheduled(node)) {
394                         sched_add_after(sched_prev(node), load);
395                         sched_add_after(load, proj);
396
397                         sched_remove(node);
398                 }
399
400                 /* copy the register from the old node to the new Load */
401                 reg = arch_get_irn_register(node);
402                 arch_set_irn_register(load, reg);
403
404                 exchange(node, proj);
405         }
406 }
407
408 /**
409  * Some stuff to do immediately after register allocation
410  */
411 static void ppc32_after_ra(void *self)
412 {
413         ppc32_code_gen_t *cg = self;
414         be_coalesce_spillslots(cg->birg);
415         irg_walk_blkwise_graph(cg->irg, NULL, ppc32_transform_spill, NULL);
416 }
417
418 /**
419  * Emits the code, closes the output file and frees
420  * the code generator interface.
421  */
422 static void ppc32_emit_and_done(void *self)
423 {
424         ppc32_code_gen_t *cg = self;
425         ir_graph         *irg = cg->irg;
426
427         dump_ir_block_graph_sched(irg, "-ppc-finished");
428         ppc32_gen_routine(cg, irg);
429
430         cur_reg_set = NULL;
431
432         /* de-allocate code generator */
433         del_set(cg->reg_set);
434         free(self);
435 }
436
437 int is_direct_entity(ir_entity *ent);
438
439 static void *ppc32_cg_init(be_irg_t *birg);
440
441 static const arch_code_generator_if_t ppc32_code_gen_if = {
442         ppc32_cg_init,
443         NULL,                 /* get_pic_base */
444         ppc32_before_abi,
445         ppc32_prepare_graph,
446         NULL,                 /* spill */
447         ppc32_before_ra,      /* before register allocation hook */
448         ppc32_after_ra,
449         ppc32_finish_irg,
450         ppc32_emit_and_done
451 };
452
453 /**
454  * Initializes the code generator.
455  */
456 static void *ppc32_cg_init(be_irg_t *birg)
457 {
458         ppc32_isa_t      *isa = (ppc32_isa_t *)birg->main_env->arch_env;
459         ppc32_code_gen_t *cg  = XMALLOC(ppc32_code_gen_t);
460
461         cg->impl      = &ppc32_code_gen_if;
462         cg->irg       = birg->irg;
463         cg->reg_set   = new_set(ppc32_cmp_irn_reg_assoc, 1024);
464         cg->isa       = isa;
465         cg->birg      = birg;
466         cg->area_size = 0;
467         cg->area      = NULL;
468         cg->start_succ_block = NULL;
469         cg->blk_sched = NULL;
470         FIRM_DBG_REGISTER(cg->mod, "firm.be.ppc.cg");
471
472         cur_reg_set = cg->reg_set;
473
474         return (arch_code_generator_t *)cg;
475 }
476
477
478
479 /*****************************************************************
480  *  ____             _                  _   _____  _____
481  * |  _ \           | |                | | |_   _|/ ____|  /\
482  * | |_) | __ _  ___| | _____ _ __   __| |   | | | (___   /  \
483  * |  _ < / _` |/ __| |/ / _ \ '_ \ / _` |   | |  \___ \ / /\ \
484  * | |_) | (_| | (__|   <  __/ | | | (_| |  _| |_ ____) / ____ \
485  * |____/ \__,_|\___|_|\_\___|_| |_|\__,_| |_____|_____/_/    \_\
486  *
487  *****************************************************************/
488
489 static ppc32_isa_t ppc32_isa_template = {
490         {
491                 &ppc32_isa_if,           /* isa interface */
492                 &ppc32_gp_regs[REG_R1],  /* stack pointer */
493                 &ppc32_gp_regs[REG_R31], /* base pointer */
494                 &ppc32_reg_classes[CLASS_ppc32_gp],  /* static link pointer class */
495                 -1,                      /* stack is decreasing */
496                 2,                       /* power of two stack alignment for calls, 2^2 == 4 */
497                 NULL,                    /* main environment */
498                 7,                       /* spill costs */
499                 5,                       /* reload costs */
500         },
501         NULL                    /* symbol set */
502 };
503
504 /**
505  * Collects all SymConsts which need to be accessed "indirectly"
506  *
507  * @param node    the firm node
508  * @param env     the symbol set
509  */
510 static void ppc32_collect_symconsts_walk(ir_node *node, void *env)
511 {
512         pset *symbol_set = env;
513
514         if (is_SymConst(node)) {
515                 ir_entity *ent = get_SymConst_entity(node);
516                 pset_insert_ptr(symbol_set, ent);
517         }
518 }
519
520 /**
521  * Initializes the backend ISA and opens the output file.
522  */
523 static arch_env_t *ppc32_init(FILE *file_handle)
524 {
525         static int inited = 0;
526         ppc32_isa_t *isa;
527         int i;
528
529         if (inited)
530                 return NULL;
531
532         isa = XMALLOC(ppc32_isa_t);
533         memcpy(isa, &ppc32_isa_template, sizeof(*isa));
534
535         be_emit_init(file_handle);
536
537         ppc32_register_init();
538         ppc32_create_opcodes(&ppc32_irn_ops);
539
540         inited = 1;
541
542         isa->symbol_set = pset_new_ptr(8);
543         for (i = 0; i < get_irp_n_irgs(); ++i) {
544                 ir_graph *irg = get_irp_irg(i);
545                 irg_walk_blkwise_graph(irg, NULL, ppc32_collect_symconsts_walk, isa->symbol_set);
546         }
547
548         /* we mark referenced global entities, so we can only emit those which
549          * are actually referenced. (Note: you mustn't use the type visited flag
550          * elsewhere in the backend)
551          */
552         inc_master_type_visited();
553
554         return &isa->arch_env;
555 }
556
557 static void ppc32_dump_indirect_symbols(ppc32_isa_t *isa)
558 {
559         ir_entity *ent;
560
561         foreach_pset(isa->symbol_set, ent) {
562                 const char *ld_name = get_entity_ld_name(ent);
563                 be_emit_irprintf(".non_lazy_symbol_pointer\n%s:\n\t.indirect_symbol _%s\n\t.long 0\n\n", ld_name, ld_name);
564                 be_emit_write_line();
565         }
566 }
567
568 /**
569  * Closes the output file and frees the ISA structure.
570  */
571 static void ppc32_done(void *self)
572 {
573         ppc32_isa_t *isa = self;
574
575         be_gas_emit_decls(isa->arch_env.main_env);
576         be_gas_emit_switch_section(GAS_SECTION_DATA);
577         ppc32_dump_indirect_symbols(isa);
578
579         be_emit_exit();
580         del_pset(isa->symbol_set);
581
582         free(self);
583 }
584
585
586
587 static unsigned ppc32_get_n_reg_class(void)
588 {
589         return N_CLASSES;
590 }
591
592 static const arch_register_class_t *ppc32_get_reg_class(unsigned i)
593 {
594         assert(i < N_CLASSES && "Invalid ppc register class requested.");
595         return &ppc32_reg_classes[i];
596 }
597
598
599
600 /**
601  * Get the register class which shall be used to store a value of a given mode.
602  * @param self The this pointer.
603  * @param mode The mode in question.
604  * @return A register class which can hold values of the given mode.
605  */
606 const arch_register_class_t *ppc32_get_reg_class_for_mode(const ir_mode *mode)
607 {
608         if (mode_is_float(mode))
609                 return &ppc32_reg_classes[CLASS_ppc32_fp];
610         else
611                 return &ppc32_reg_classes[CLASS_ppc32_gp];
612 }
613
614
615 /**
616  * Get the ABI restrictions for procedure calls.
617  * @param self        The this pointer.
618  * @param method_type The type of the method (procedure) in question.
619  * @param abi         The abi object to be modified
620  */
621 static void ppc32_get_call_abi(const void *self, ir_type *method_type, be_abi_call_t *abi)
622 {
623         ir_type  *tp;
624         ir_mode  *mode;
625         int       i, n = get_method_n_params(method_type);
626         int               stackoffs = 0, lastoffs = 0, stackparamsize;
627
628         int               gpregi = REG_R3;
629         int               fpregi = REG_F1;
630
631         const arch_register_t *reg;
632         be_abi_call_flags_t call_flags = { { 0, 0, 1, 0, 0, 0, 1 } };
633
634         (void) self;
635         call_flags.bits.call_has_imm = 1;
636
637         /* set stack parameter passing style */
638         be_abi_call_set_flags(abi, call_flags, &ppc32_abi_callbacks);
639
640         for (i = 0; i < n; i++) {
641                 tp   = get_method_param_type(method_type, i);
642                 mode = get_type_mode(tp);
643                 if (is_atomic_type(tp))
644                 {
645                         if (mode_is_float(mode))
646                         {
647                                 if (fpregi <= REG_F13)
648                                 {
649                                         if (get_mode_size_bits(mode) == 32) gpregi++, stackparamsize=4;
650                                         else gpregi += 2, stackparamsize=8;                                                             // mode == irm_D
651                                         reg = &ppc32_fp_regs[fpregi++];
652                                 }
653                                 else
654                                 {
655                                         if (get_mode_size_bits(mode) == 32) stackparamsize=4;
656                                         else stackparamsize=8;                                                          // mode == irm_D
657                                         reg = NULL;
658                                 }
659                         }
660                         else
661                         {
662                                 if (gpregi <= REG_R10)
663                                         reg = &ppc32_gp_regs[gpregi++];
664                                 else
665                                         reg = NULL;
666                                 stackparamsize=4;
667                         }
668
669                         if (reg)
670                                 be_abi_call_param_reg(abi, i, reg);
671                         else
672                         {
673                                 be_abi_call_param_stack(abi, i, mode, 4, stackoffs - lastoffs, 0);
674                                 lastoffs = stackoffs+stackparamsize;
675                         }
676                         stackoffs += stackparamsize;
677                 }
678                 else
679                 {
680                         be_abi_call_param_stack(abi, i, mode, 4, stackoffs - lastoffs, 0);
681                         stackoffs += (get_type_size_bytes(tp)+3) & -4;
682                         lastoffs = stackoffs;
683                 }
684         }
685
686         /* explain where result can be found if any */
687         if (get_method_n_ress(method_type) > 0) {
688                 tp   = get_method_res_type(method_type, 0);
689                 mode = get_type_mode(tp);
690
691                 be_abi_call_res_reg(abi, 0,
692                         mode_is_float(mode) ? &ppc32_fp_regs[REG_F1] : &ppc32_gp_regs[REG_R3]);
693         }
694 }
695
696 int ppc32_to_appear_in_schedule(void *block_env, const ir_node *irn)
697 {
698         (void) block_env;
699         if (!is_ppc32_irn(irn))
700                 return -1;
701
702         return 1;
703 }
704
705 /**
706  * Initializes the code generator interface.
707  */
708 static const arch_code_generator_if_t *ppc32_get_code_generator_if(void *self)
709 {
710         (void) self;
711         return &ppc32_code_gen_if;
712 }
713
714 list_sched_selector_t ppc32_sched_selector;
715
716 /**
717  * Returns the reg_pressure scheduler with to_appear_in_schedule() overloaded
718  */
719 static const list_sched_selector_t *ppc32_get_list_sched_selector(const void *self, list_sched_selector_t *selector)
720 {
721         (void) self;
722         (void) selector;
723         ppc32_sched_selector = trivial_selector;
724         ppc32_sched_selector.to_appear_in_schedule = ppc32_to_appear_in_schedule;
725         return &ppc32_sched_selector;
726 }
727
728 static const ilp_sched_selector_t *ppc32_get_ilp_sched_selector(const void *self)
729 {
730         (void) self;
731         return NULL;
732 }
733
734 /**
735  * Returns the necessary byte alignment for storing a register of given class.
736  */
737 static int ppc32_get_reg_class_alignment(const arch_register_class_t *cls)
738 {
739         ir_mode *mode = arch_register_class_mode(cls);
740         return get_mode_size_bytes(mode);
741 }
742
743 static const be_execution_unit_t ***ppc32_get_allowed_execution_units(const ir_node *irn)
744 {
745         (void) irn;
746         /* TODO */
747         panic("Unimplemented ppc32_get_allowed_execution_units()");
748         return NULL;
749 }
750
751 static const be_machine_t *ppc32_get_machine(const void *self)
752 {
753         (void) self;
754         /* TODO */
755         panic("Unimplemented ppc32_get_machine()");
756         return NULL;
757 }
758
759 /**
760  * Return irp irgs in the desired order.
761  */
762 static ir_graph **ppc32_get_irg_list(const void *self, ir_graph ***irg_list)
763 {
764         (void) self;
765         (void) irg_list;
766         return NULL;
767 }
768
769 /**
770  * Returns the libFirm configuration parameter for this backend.
771  */
772 static const backend_params *ppc32_get_libfirm_params(void)
773 {
774         static backend_params p = {
775                 1,     /* need dword lowering */
776                 0,     /* don't support inline assembler yet */
777                 NULL,  /* will be set later */
778                 NULL,  /* but yet no creator function */
779                 NULL,  /* context for create_intrinsic_fkt */
780                 NULL,  /* no if conversion settings */
781                 NULL,  /* no float arithmetic mode (TODO) */
782                 0,     /* no trampoline support: size 0 */
783                 0,     /* no trampoline support: align 0 */
784                 NULL,  /* no trampoline support: no trampoline builder */
785                 4      /* alignment of stack parameter */
786         };
787
788         return &p;
789 }
790
791 static asm_constraint_flags_t ppc32_parse_asm_constraint(const char **c)
792 {
793         /* no asm support yet */
794         (void) c;
795         return ASM_CONSTRAINT_FLAG_INVALID;
796 }
797
798 static int ppc32_is_valid_clobber(const char *clobber)
799 {
800         /* no asm support yet */
801         (void) clobber;
802         return 0;
803 }
804
805 const arch_isa_if_t ppc32_isa_if = {
806         ppc32_init,
807         ppc32_done,
808         NULL,             /* handle intrinsics */
809         ppc32_get_n_reg_class,
810         ppc32_get_reg_class,
811         ppc32_get_reg_class_for_mode,
812         ppc32_get_call_abi,
813         ppc32_get_code_generator_if,
814         ppc32_get_list_sched_selector,
815         ppc32_get_ilp_sched_selector,
816         ppc32_get_reg_class_alignment,
817         ppc32_get_libfirm_params,
818         ppc32_get_allowed_execution_units,
819         ppc32_get_machine,
820         ppc32_get_irg_list,
821         NULL,                 /* mark remat */
822         ppc32_parse_asm_constraint,
823         ppc32_is_valid_clobber
824 };
825
826 void be_init_arch_ppc32(void)
827 {
828         be_register_isa_if("ppc32", &ppc32_isa_if);
829 }
830
831 BE_REGISTER_MODULE_CONSTRUCTOR(be_init_arch_ppc32);