2 * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
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.
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.
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
22 * @brief The main ppc backend driver file.
23 * @author Moritz Kroll, Jens Mueller
30 #include "pseudo_irg.h"
41 #include "../bearch_t.h" /* the general register allocator interface */
42 #include "../benode_t.h"
43 #include "../belower.h"
44 #include "../besched_t.h"
47 #include "../bemachine.h"
48 #include "../bemodule.h"
49 #include "../bespillslots.h"
50 #include "../beblocksched.h"
51 #include "../beirg_t.h"
52 #include "../begnuas.h"
56 #include "bearch_ppc32_t.h"
58 #include "ppc32_new_nodes.h" /* ppc nodes interface */
59 #include "gen_ppc32_regalloc_if.h" /* the generated interface (register type and class defenitions) */
60 #include "ppc32_transform.h"
61 #include "ppc32_transform_conv.h"
62 #include "ppc32_emitter.h"
63 #include "ppc32_map_regs.h"
65 #define DEBUG_MODULE "firm.be.ppc.isa"
69 /* TODO: ugly, but we need it to get access to the registers assigned to Phi nodes */
70 static set *cur_reg_set = NULL;
72 /**************************************************
75 * _ __ ___ __ _ __ _| | | ___ ___ _| |_
76 * | '__/ _ \/ _` | / _` | | |/ _ \ / __| | | _|
77 * | | | __/ (_| | | (_| | | | (_) | (__ | | |
78 * |_| \___|\__, | \__,_|_|_|\___/ \___| |_|_|
81 **************************************************/
84 * Return register requirements for a ppc node.
85 * If the node returns a tuple (mode_T) then the proj's
86 * will be asked for this information.
89 arch_register_req_t *ppc32_get_irn_reg_req(const void *self,
90 const ir_node *irn, int pos) {
91 long node_pos = pos == -1 ? 0 : pos;
92 ir_mode *mode = get_irn_mode(irn);
93 FIRM_DBG_REGISTER(firm_dbg_module_t *mod, DEBUG_MODULE);
96 if (is_Block(irn) || mode == mode_X || mode == mode_M) {
97 DBG((mod, LEVEL_1, "ignoring block, mode_X or mode_M node %+F\n", irn));
98 return arch_no_register_req;
101 if (mode == mode_T && pos < 0) {
102 DBG((mod, LEVEL_1, "ignoring request for OUT requirements at %+F", irn));
103 return arch_no_register_req;
106 DBG((mod, LEVEL_1, "get requirements at pos %d for %+F ... ", pos, irn));
109 /* in case of a proj, we need to get the correct OUT slot */
110 /* of the node corresponding to the proj number */
112 node_pos = ppc32_translate_proj_pos(irn);
117 irn = skip_Proj_const(irn);
119 DB((mod, LEVEL_1, "skipping Proj, going to %+F at pos %d ... ", irn, node_pos));
122 /* get requirements for our own nodes */
123 if (is_ppc32_irn(irn)) {
124 const arch_register_req_t *req;
126 req = get_ppc32_in_req(irn, pos);
128 req = get_ppc32_out_req(irn, node_pos);
131 DB((mod, LEVEL_1, "returning reqs for %+F at pos %d\n", irn, pos));
135 /* unknowns should be transformed by now */
136 assert(!is_Unknown(irn));
138 DB((mod, LEVEL_1, "returning NULL for %+F (node not supported)\n", irn));
139 return arch_no_register_req;
142 static void ppc32_set_irn_reg(const void *self, ir_node *irn, const arch_register_t *reg) {
148 if (get_irn_mode(irn) == mode_X) {
152 pos = ppc32_translate_proj_pos(irn);
153 irn = skip_Proj(irn);
156 if (is_ppc32_irn(irn)) {
157 const arch_register_t **slots;
159 slots = get_ppc32_slots(irn);
163 /* here we set the registers for the Phi nodes */
164 ppc32_set_firm_reg(irn, reg, cur_reg_set);
168 static const arch_register_t *ppc32_get_irn_reg(const void *self, const ir_node *irn) {
170 const arch_register_t *reg = NULL;
175 if (get_irn_mode(irn) == mode_X) {
179 pos = ppc32_translate_proj_pos(irn);
180 irn = skip_Proj_const(irn);
183 if (is_ppc32_irn(irn)) {
184 const arch_register_t **slots;
185 slots = get_ppc32_slots(irn);
189 reg = ppc32_get_firm_reg(irn, cur_reg_set);
195 static arch_irn_class_t ppc32_classify(const void *self, const ir_node *irn) {
197 irn = skip_Proj_const(irn);
200 return arch_irn_class_branch;
202 else if (is_ppc32_irn(irn)) {
203 return arch_irn_class_normal;
209 static arch_irn_flags_t ppc32_get_flags(const void *self, const ir_node *irn) {
211 irn = skip_Proj_const(irn);
213 if (is_ppc32_irn(irn)) {
214 return get_ppc32_flags(irn);
216 else if (is_Unknown(irn)) {
217 return arch_irn_flags_ignore;
223 static ir_entity *ppc32_get_frame_entity(const void *self, const ir_node *irn) {
225 if(!is_ppc32_irn(irn)) return NULL;
226 if(get_ppc32_type(irn)!=ppc32_ac_FrameEntity) return NULL;
227 return get_ppc32_frame_entity(irn);
230 static void ppc32_set_frame_entity(const void *self, ir_node *irn, ir_entity *ent) {
232 if (! is_ppc32_irn(irn) || get_ppc32_type(irn) != ppc32_ac_FrameEntity)
234 set_ppc32_frame_entity(irn, ent);
238 * This function is called by the generic backend to correct offsets for
239 * nodes accessing the stack.
241 static void ppc32_set_stack_bias(const void *self, ir_node *irn, int bias) {
243 set_ppc32_offset(irn, bias);
246 static int ppc32_get_sp_bias(const void *self, const ir_node *irn) {
254 const be_abi_call_t *call;
259 * Initialize the callback object.
260 * @param call The call object.
261 * @param aenv The architecture environment.
262 * @param irg The graph with the method.
263 * @return Some pointer. This pointer is passed to all other callback functions as self object.
265 static void *ppc32_abi_init(const be_abi_call_t *call, const arch_env_t *aenv, ir_graph *irg)
267 ppc32_abi_env *env = xmalloc(sizeof(ppc32_abi_env));
276 * Destroy the callback object.
277 * @param self The callback object.
279 static void ppc32_abi_done(void *self)
285 * Get the between type for that call.
286 * @param self The callback object.
287 * @return The between type of for that call.
289 static ir_type *ppc32_abi_get_between_type(void *self)
291 static ir_type *between_type = NULL;
292 static ir_entity *old_bp_ent = NULL;
296 ir_entity *ret_addr_ent;
297 ir_type *ret_addr_type = new_type_primitive(new_id_from_str("return_addr"), mode_P);
298 ir_type *old_bp_type = new_type_primitive(new_id_from_str("bp"), mode_P);
300 between_type = new_type_class(new_id_from_str("ppc32_between_type"));
301 old_bp_ent = new_entity(between_type, new_id_from_str("old_bp"), old_bp_type);
302 ret_addr_ent = new_entity(between_type, new_id_from_str("old_bp"), ret_addr_type);
304 set_entity_offset(old_bp_ent, 0);
305 set_entity_offset(ret_addr_ent, get_type_size_bytes(old_bp_type));
306 set_type_size_bytes(between_type, get_type_size_bytes(old_bp_type) + get_type_size_bytes(ret_addr_type));
313 * Put all registers which are saved by the prologue/epilogue in a set.
314 * @param self The callback object.
317 static void ppc32_abi_regs_saved_by_me(void *self, pset *regs)
324 * Generate the prologue.
325 * @param self The callback object.
326 * @param mem A pointer to the mem node. Update this if you define new memory.
327 * @param reg_map A mapping mapping all callee_save/ignore/parameter registers to their defining nodes.
328 * @return The register which shall be used as a stack frame base.
330 * All nodes which define registers in @p reg_map must keep @p reg_map current.
332 static const arch_register_t *ppc32_abi_prologue(void *self, ir_node **mem, pmap *reg_map)
334 ppc32_abi_env *env = (ppc32_abi_env *) self;
335 be_abi_call_flags_t flags = be_abi_call_get_flags(env->call);
338 isleaf = flags.bits.irg_is_leaf;
340 if(flags.bits.try_omit_fp)
341 return &ppc32_gp_regs[REG_R1];
343 return &ppc32_gp_regs[REG_R31];
347 * Generate the epilogue.
348 * @param self The callback object.
349 * @param mem Memory one can attach to.
350 * @param reg_map A mapping mapping all callee_save/ignore/return registers to their defining nodes.
352 * All nodes which define registers in @p reg_map must keep @p reg_map current.
353 * Also, the @p mem variable must be updated, if memory producing nodes are inserted.
355 static void ppc32_abi_epilogue(void *self, ir_node *bl, ir_node **mem, pmap *reg_map)
363 static const be_abi_callbacks_t ppc32_abi_callbacks = {
366 ppc32_abi_get_between_type,
367 ppc32_abi_regs_saved_by_me,
372 /* fill register allocator interface */
374 static const arch_irn_ops_if_t ppc32_irn_ops_if = {
375 ppc32_get_irn_reg_req,
380 ppc32_get_frame_entity,
381 ppc32_set_frame_entity,
382 ppc32_set_stack_bias,
384 NULL, /* get_inverse */
385 NULL, /* get_op_estimated_cost */
386 NULL, /* possible_memory_operand */
387 NULL, /* perform_memory_operand */
390 ppc32_irn_ops_t ppc32_irn_ops = {
397 /**************************************************
400 * ___ ___ __| | ___ __ _ ___ _ __ _| |_
401 * / __/ _ \ / _` |/ _ \/ _` |/ _ \ '_ \ | | _|
402 * | (_| (_) | (_| | __/ (_| | __/ | | | | | |
403 * \___\___/ \__,_|\___|\__, |\___|_| |_| |_|_|
406 **************************************************/
408 static void ppc32_before_abi(void *self) {
409 ppc32_code_gen_t *cg = self;
410 ir_type *frame_type = get_irg_frame_type(cg->irg);
412 frame_alloc_area(frame_type, 24, 4, 1);
414 ppc32_init_conv_walk();
415 irg_walk_blkwise_graph(cg->irg, NULL, ppc32_conv_walk, cg);
418 if(cg->area_size < 32) cg->area_size = 32;
419 cg->area = frame_alloc_area(get_irg_frame_type(cg->irg), cg->area_size+24, 16, 1);
423 static void ppc32_search_start_successor(ir_node *block, void *env) {
424 ppc32_code_gen_t *cg = env;
425 int n = get_Block_n_cfgpreds(block);
426 ir_node *startblock = get_irg_start_block(cg->irg);
427 if(block == startblock) return;
429 for (n--; n >= 0; n--) {
430 ir_node *predblock = get_irn_n(get_Block_cfgpred(block, n), -1);
431 if(predblock == startblock)
433 cg->start_succ_block = block;
440 * Transforms the standard firm graph into
443 static void ppc32_prepare_graph(void *self) {
444 ppc32_code_gen_t *cg = self;
446 irg_block_walk_graph(cg->irg, NULL, ppc32_search_start_successor, cg);
447 irg_walk_blkwise_graph(cg->irg, NULL, ppc32_pretransform_walk, cg);
448 be_dump(cg->irg, "-pretransformed", dump_ir_block_graph);
450 ppc32_register_transformers();
451 irg_walk_blkwise_graph(cg->irg, NULL, ppc32_transform_node, cg);
452 be_dump(cg->irg, "-transformed", dump_ir_block_graph);
453 irg_walk_blkwise_graph(cg->irg, NULL, ppc32_transform_const, cg);
459 * Called immediatly before emit phase.
461 static void ppc32_finish_irg(void *self) {
463 /* TODO: - fix offsets for nodes accessing stack
470 * These are some hooks which must be filled but are probably not needed.
472 static void ppc32_before_sched(void *self) {
474 /* Some stuff you need to do after scheduling but before register allocation */
478 * Called before the register allocator.
479 * Calculate a block schedule here. We need it for the x87
480 * simulator and the emitter.
482 static void ppc32_before_ra(void *self) {
483 ppc32_code_gen_t *cg = self;
484 cg->blk_sched = be_create_block_schedule(cg->irg, cg->birg->exec_freq);
487 static void ppc32_transform_spill(ir_node *node, void *env)
489 ppc32_code_gen_t *cgenv = (ppc32_code_gen_t *)env;
491 if(be_is_Spill(node))
493 ir_node *store, *proj;
494 dbg_info *dbg = get_irn_dbg_info(node);
495 ir_node *block = get_nodes_block(node);
497 const arch_register_class_t *regclass = arch_get_irn_reg_class(cgenv->arch_env, node, 1);
499 if (regclass == &ppc32_reg_classes[CLASS_ppc32_gp])
501 store = new_rd_ppc32_Stw(dbg, current_ir_graph, block,
502 get_irn_n(node, 0), get_irn_n(node, 1), new_rd_NoMem(current_ir_graph));
504 else if (regclass == &ppc32_reg_classes[CLASS_ppc32_fp])
506 store = new_rd_ppc32_Stfd(dbg, current_ir_graph, block,
507 get_irn_n(node, 0), get_irn_n(node, 1), new_rd_NoMem(current_ir_graph));
509 else assert(0 && "Spill for register class not supported yet!");
511 set_ppc32_frame_entity(store, be_get_frame_entity(node));
513 proj = new_rd_Proj(dbg, current_ir_graph, block, store, mode_M, pn_Store_M);
515 if (sched_is_scheduled(node)) {
516 sched_add_after(sched_prev(node), store);
517 sched_add_after(store, proj);
522 exchange(node, proj);
525 if(be_is_Reload(node))
527 ir_node *load, *proj;
528 const arch_register_t *reg;
529 dbg_info *dbg = get_irn_dbg_info(node);
530 ir_node *block = get_nodes_block(node);
531 ir_mode *mode = get_irn_mode(node);
533 const arch_register_class_t *regclass = arch_get_irn_reg_class(cgenv->arch_env, node, -1);
535 if (regclass == &ppc32_reg_classes[CLASS_ppc32_gp])
537 load = new_rd_ppc32_Lwz(dbg, current_ir_graph, block, get_irn_n(node, 0), get_irn_n(node, 1));
539 else if (regclass == &ppc32_reg_classes[CLASS_ppc32_fp])
541 load = new_rd_ppc32_Lfd(dbg, current_ir_graph, block, get_irn_n(node, 0), get_irn_n(node, 1));
543 else assert(0 && "Reload for register class not supported yet!");
545 set_ppc32_frame_entity(load, be_get_frame_entity(node));
547 proj = new_rd_Proj(dbg, current_ir_graph, block, load, mode, pn_Load_res);
549 if (sched_is_scheduled(node)) {
550 sched_add_after(sched_prev(node), load);
551 sched_add_after(load, proj);
556 /* copy the register from the old node to the new Load */
557 reg = arch_get_irn_register(cgenv->arch_env, node);
558 arch_set_irn_register(cgenv->arch_env, load, reg);
560 exchange(node, proj);
565 * Some stuff to do immediately after register allocation
567 static void ppc32_after_ra(void *self) {
568 ppc32_code_gen_t *cg = self;
569 be_coalesce_spillslots(cg->birg);
570 irg_walk_blkwise_graph(cg->irg, NULL, ppc32_transform_spill, cg);
574 * Emits the code, closes the output file and frees
575 * the code generator interface.
577 static void ppc32_emit_and_done(void *self) {
578 ppc32_code_gen_t *cg = self;
579 ir_graph *irg = cg->irg;
581 dump_ir_block_graph_sched(irg, "-ppc-finished");
582 ppc32_gen_routine(cg, irg);
586 /* de-allocate code generator */
587 del_set(cg->reg_set);
591 int is_direct_entity(ir_entity *ent);
593 static void *ppc32_cg_init(be_irg_t *birg);
595 static const arch_code_generator_if_t ppc32_code_gen_if = {
600 ppc32_before_sched, /* before scheduling hook */
601 ppc32_before_ra, /* before register allocation hook */
608 * Initializes the code generator.
610 static void *ppc32_cg_init(be_irg_t *birg) {
611 ppc32_isa_t *isa = (ppc32_isa_t *)birg->main_env->arch_env->isa;
612 ppc32_code_gen_t *cg = xmalloc(sizeof(*cg));
614 cg->impl = &ppc32_code_gen_if;
616 cg->reg_set = new_set(ppc32_cmp_irn_reg_assoc, 1024);
617 cg->arch_env = birg->main_env->arch_env;
622 cg->start_succ_block = NULL;
623 cg->blk_sched = NULL;
624 FIRM_DBG_REGISTER(cg->mod, "firm.be.ppc.cg");
626 cur_reg_set = cg->reg_set;
627 ppc32_irn_ops.cg = cg;
629 return (arch_code_generator_t *)cg;
634 /*****************************************************************
635 * ____ _ _ _____ _____
636 * | _ \ | | | | |_ _|/ ____| /\
637 * | |_) | __ _ ___| | _____ _ __ __| | | | | (___ / \
638 * | _ < / _` |/ __| |/ / _ \ '_ \ / _` | | | \___ \ / /\ \
639 * | |_) | (_| | (__| < __/ | | | (_| | _| |_ ____) / ____ \
640 * |____/ \__,_|\___|_|\_\___|_| |_|\__,_| |_____|_____/_/ \_\
642 *****************************************************************/
644 static ppc32_isa_t ppc32_isa_template = {
646 &ppc32_isa_if, /* isa interface */
647 &ppc32_gp_regs[REG_R1], /* stack pointer */
648 &ppc32_gp_regs[REG_R31], /* base pointer */
649 -1, /* stack is decreasing */
650 NULL, /* main environment */
652 5, /* reload costs */
654 NULL_EMITTER, /* emitter environment */
655 NULL /* symbol set */
659 * Collects all SymConsts which need to be accessed "indirectly"
661 * @param node the firm node
662 * @param env the symbol set
664 static void ppc32_collect_symconsts_walk(ir_node *node, void *env) {
665 pset *symbol_set = env;
667 if (is_SymConst(node)) {
668 ir_entity *ent = get_SymConst_entity(node);
669 set_entity_backend_marked(ent, 1);
670 if (! is_direct_entity(ent))
671 pset_insert_ptr(symbol_set, ent);
676 * Initializes the backend ISA and opens the output file.
678 static void *ppc32_init(FILE *file_handle) {
679 static int inited = 0;
686 isa = xmalloc(sizeof(*isa));
687 memcpy(isa, &ppc32_isa_template, sizeof(*isa));
689 be_emit_init_env(&isa->emit, file_handle);
691 ppc32_register_init();
692 ppc32_create_opcodes();
696 isa->symbol_set = pset_new_ptr(8);
697 for (i = 0; i < get_irp_n_irgs(); ++i) {
698 ir_graph *irg = get_irp_irg(i);
699 irg_walk_blkwise_graph(irg, NULL, ppc32_collect_symconsts_walk, isa->symbol_set);
702 /* we mark referenced global entities, so we can only emit those which
703 * are actually referenced. (Note: you mustn't use the type visited flag
704 * elsewhere in the backend)
706 inc_master_type_visited();
711 static void ppc32_dump_indirect_symbols(ppc32_isa_t *isa) {
714 foreach_pset(isa->symbol_set, ent) {
715 const char *ld_name = get_entity_ld_name(ent);
716 be_emit_irprintf(&isa->emit, ".non_lazy_symbol_pointer\n%s:\n\t.indirect_symbol _%s\n\t.long 0\n\n", ld_name, ld_name);
717 be_emit_write_line(&isa->emit);
722 * Closes the output file and frees the ISA structure.
724 static void ppc32_done(void *self) {
725 ppc32_isa_t *isa = self;
727 be_gas_emit_decls(&isa->emit, isa->arch_isa.main_env, 1);
728 be_gas_emit_switch_section(&isa->emit, GAS_SECTION_DATA);
729 ppc32_dump_indirect_symbols(isa);
731 be_emit_destroy_env(&isa->emit);
732 del_pset(isa->symbol_set);
739 static int ppc32_get_n_reg_class(const void *self) {
744 static const arch_register_class_t *ppc32_get_reg_class(const void *self, int i) {
746 assert(i >= 0 && i < N_CLASSES && "Invalid ppc register class requested.");
747 return &ppc32_reg_classes[i];
753 * Get the register class which shall be used to store a value of a given mode.
754 * @param self The this pointer.
755 * @param mode The mode in question.
756 * @return A register class which can hold values of the given mode.
758 const arch_register_class_t *ppc32_get_reg_class_for_mode(const void *self, const ir_mode *mode) {
760 if (mode_is_float(mode))
761 return &ppc32_reg_classes[CLASS_ppc32_fp];
763 return &ppc32_reg_classes[CLASS_ppc32_gp];
768 * Get the ABI restrictions for procedure calls.
769 * @param self The this pointer.
770 * @param method_type The type of the method (procedure) in question.
771 * @param abi The abi object to be modified
773 static void ppc32_get_call_abi(const void *self, ir_type *method_type, be_abi_call_t *abi) {
776 int i, n = get_method_n_params(method_type);
777 int stackoffs = 0, lastoffs = 0, stackparamsize;
782 const arch_register_t *reg;
783 be_abi_call_flags_t call_flags = { { 0, 0, 1, 0, 0, 0, 1 } };
786 if(get_type_visibility(method_type)!=visibility_external_allocated)
787 call_flags.bits.call_has_imm = 1;
789 /* set stack parameter passing style */
790 be_abi_call_set_flags(abi, call_flags, &ppc32_abi_callbacks);
792 for (i = 0; i < n; i++) {
793 tp = get_method_param_type(method_type, i);
794 if(is_atomic_type(tp))
796 mode = get_type_mode(tp);
798 if(mode_is_float(mode))
800 if(fpregi <= REG_F13)
802 if(get_mode_size_bits(mode) == 32) gpregi++, stackparamsize=4;
803 else gpregi += 2, stackparamsize=8; // mode == irm_D
804 reg = &ppc32_fp_regs[fpregi++];
808 if(get_mode_size_bits(mode) == 32) stackparamsize=4;
809 else stackparamsize=8; // mode == irm_D
815 if(gpregi <= REG_R10)
816 reg = &ppc32_gp_regs[gpregi++];
823 be_abi_call_param_reg(abi, i, reg);
826 be_abi_call_param_stack(abi, i, 4, stackoffs-lastoffs, 0);
827 lastoffs = stackoffs+stackparamsize;
829 stackoffs += stackparamsize;
833 be_abi_call_param_stack(abi, i, 4, stackoffs-lastoffs, 0);
834 stackoffs += (get_type_size_bytes(tp)+3) & -4;
835 lastoffs = stackoffs;
839 /* explain where result can be found if any */
840 if (get_method_n_ress(method_type) > 0) {
841 tp = get_method_res_type(method_type, 0);
842 mode = get_type_mode(tp);
844 be_abi_call_res_reg(abi, 0,
845 mode_is_float(mode) ? &ppc32_fp_regs[REG_F1] : &ppc32_gp_regs[REG_R3]);
849 static const void *ppc32_get_irn_ops(const arch_irn_handler_t *self, const ir_node *irn) {
852 return &ppc32_irn_ops;
855 const arch_irn_handler_t ppc32_irn_handler = {
859 const arch_irn_handler_t *ppc32_get_irn_handler(const void *self) {
861 return &ppc32_irn_handler;
864 int ppc32_to_appear_in_schedule(void *block_env, const ir_node *irn) {
866 if(!is_ppc32_irn(irn))
873 * Initializes the code generator interface.
875 static const arch_code_generator_if_t *ppc32_get_code_generator_if(void *self) {
877 return &ppc32_code_gen_if;
880 list_sched_selector_t ppc32_sched_selector;
883 * Returns the reg_pressure scheduler with to_appear_in_schedule() overloaded
885 static const list_sched_selector_t *ppc32_get_list_sched_selector(const void *self, list_sched_selector_t *selector) {
888 memcpy(&ppc32_sched_selector, trivial_selector, sizeof(list_sched_selector_t));
889 ppc32_sched_selector.to_appear_in_schedule = ppc32_to_appear_in_schedule;
890 return &ppc32_sched_selector;
893 static const ilp_sched_selector_t *ppc32_get_ilp_sched_selector(const void *self) {
899 * Returns the necessary byte alignment for storing a register of given class.
901 static int ppc32_get_reg_class_alignment(const void *self, const arch_register_class_t *cls) {
902 ir_mode *mode = arch_register_class_mode(cls);
905 return get_mode_size_bytes(mode);
908 static const be_execution_unit_t ***ppc32_get_allowed_execution_units(const void *self, const ir_node *irn) {
916 static const be_machine_t *ppc32_get_machine(const void *self) {
924 * Return irp irgs in the desired order.
926 static ir_graph **ppc32_get_irg_list(const void *self, ir_graph ***irg_list) {
933 * Returns the libFirm configuration parameter for this backend.
935 static const backend_params *ppc32_get_libfirm_params(void) {
936 static arch_dep_params_t ad = {
938 0, /* Muls are fast enough on ARM */
939 31, /* shift would be ok */
940 0, /* SMUL is needed, only in Arch M*/
941 0, /* UMUL is needed, only in Arch M */
942 32, /* SMUL & UMUL available for 32 bit */
944 static backend_params p = {
945 1, /* need dword lowering */
946 0, /* don't support inlien assembler yet */
947 NULL, /* no additional opcodes */
948 NULL, /* will be set later */
949 NULL, /* but yet no creator function */
950 NULL, /* context for create_intrinsic_fkt */
951 NULL, /* no if conversion settings */
958 const arch_isa_if_t ppc32_isa_if = {
961 ppc32_get_n_reg_class,
963 ppc32_get_reg_class_for_mode,
965 ppc32_get_irn_handler,
966 ppc32_get_code_generator_if,
967 ppc32_get_list_sched_selector,
968 ppc32_get_ilp_sched_selector,
969 ppc32_get_reg_class_alignment,
970 ppc32_get_libfirm_params,
971 ppc32_get_allowed_execution_units,
976 void be_init_arch_ppc32(void)
978 be_register_isa_if("ppc32", &ppc32_isa_if);
981 BE_REGISTER_MODULE_CONSTRUCTOR(be_init_arch_ppc32);