fixed debug output of unary x87 nodes
[libfirm] / ir / be / ppc32 / bearch_ppc32.c
index 8799e40..455f371 100644 (file)
@@ -128,10 +128,10 @@ static const arch_register_req_t *ppc32_get_irn_reg_req(const void *self, arch_r
                        DB((mod, LEVEL_1, "returning standard reqs for %+F\n", irn));
 
                        if (mode_is_float(mode)) {
-                               memcpy(req, &(ppc32_default_req_ppc32_floating_point.req), sizeof(*req));
+                               memcpy(req, &(ppc32_default_req_ppc32_fp.req), sizeof(*req));
                        }
                        else if (mode_is_int(mode) || mode_is_reference(mode)) {
-                               memcpy(req, &(ppc32_default_req_ppc32_general_purpose.req), sizeof(*req));
+                               memcpy(req, &(ppc32_default_req_ppc32_gp.req), sizeof(*req));
                        }
                        else if (mode == mode_T || mode == mode_M) {
                                DBG((mod, LEVEL_1, "ignoring Phi node %+F\n", irn));
@@ -233,6 +233,12 @@ static entity *ppc32_get_frame_entity(const void *self, const ir_node *irn) {
        return get_ppc32_frame_entity(irn);
 }
 
+static void ppc32_set_frame_entity(const void *self, const ir_node *irn, entity *ent) {
+       if (! is_ppc32_irn(irn) || get_ppc32_type(irn) != ppc32_ac_FrameEntity)
+               return;
+       set_ppc32_frame_entity(irn, ent);
+}
+
 /**
  * This function is called by the generic backend to correct offsets for
  * nodes accessing the stack.
@@ -323,9 +329,9 @@ static const arch_register_t *ppc32_abi_prologue(void *self, ir_node **mem, pmap
        isleaf = flags.bits.irg_is_leaf;
 
        if(flags.bits.try_omit_fp)
-               return &ppc32_general_purpose_regs[REG_R1];
+               return &ppc32_gp_regs[REG_R1];
        else
-               return &ppc32_general_purpose_regs[REG_R31];
+               return &ppc32_gp_regs[REG_R31];
 }
 
 /**
@@ -359,7 +365,12 @@ static const arch_irn_ops_if_t ppc32_irn_ops_if = {
        ppc32_classify,
        ppc32_get_flags,
        ppc32_get_frame_entity,
-       ppc32_set_stack_bias
+       ppc32_set_frame_entity,
+       ppc32_set_stack_bias,
+       NULL,    /* get_inverse             */
+       NULL,    /* get_op_estimated_cost   */
+       NULL,    /* possible_memory_operand */
+       NULL,    /* perform_memory_operand  */
 };
 
 ppc32_irn_ops_t ppc32_irn_ops = {
@@ -433,7 +444,7 @@ static void ppc32_prepare_graph(void *self) {
 /**
  * Called immediatly before emit phase.
  */
-static void ppc32_finish_irg(ir_graph *irg, ppc32_code_gen_t *cg) {
+static void ppc32_finish_irg(void *self) {
        /* TODO: - fix offsets for nodes accessing stack
                         - ...
        */
@@ -469,15 +480,15 @@ static void ppc32_transform_spill(ir_node *node, void *env)
 
                const arch_register_class_t *regclass = arch_get_irn_reg_class(cgenv->arch_env, node, 1);
 
-               if (regclass == &ppc32_reg_classes[CLASS_ppc32_general_purpose])
+               if (regclass == &ppc32_reg_classes[CLASS_ppc32_gp])
                {
                        store = new_rd_ppc32_Stw(dbg, current_ir_graph, block,
-                               get_irn_n(node, 0), get_irn_n(node, 1), new_rd_NoMem(current_ir_graph), mode_T);
+                               get_irn_n(node, 0), get_irn_n(node, 1), new_rd_NoMem(current_ir_graph));
                }
-               else if (regclass == &ppc32_reg_classes[CLASS_ppc32_floating_point])
+               else if (regclass == &ppc32_reg_classes[CLASS_ppc32_fp])
                {
                        store = new_rd_ppc32_Stfd(dbg, current_ir_graph, block,
-                               get_irn_n(node, 0), get_irn_n(node, 1), new_rd_NoMem(current_ir_graph), mode_T);
+                               get_irn_n(node, 0), get_irn_n(node, 1), new_rd_NoMem(current_ir_graph));
                }
                else assert(0 && "Spill for register class not supported yet!");
 
@@ -505,15 +516,13 @@ static void ppc32_transform_spill(ir_node *node, void *env)
 
                const arch_register_class_t *regclass = arch_get_irn_reg_class(cgenv->arch_env, node, -1);
 
-               if (regclass == &ppc32_reg_classes[CLASS_ppc32_general_purpose])
+               if (regclass == &ppc32_reg_classes[CLASS_ppc32_gp])
                {
-                       load = new_rd_ppc32_Lwz(dbg, current_ir_graph, block,
-                               get_irn_n(node, 0), get_irn_n(node, 1), mode_T);
+                       load = new_rd_ppc32_Lwz(dbg, current_ir_graph, block,   get_irn_n(node, 0), get_irn_n(node, 1));
                }
-               else if (regclass == &ppc32_reg_classes[CLASS_ppc32_floating_point])
+               else if (regclass == &ppc32_reg_classes[CLASS_ppc32_fp])
                {
-                       load = new_rd_ppc32_Lfd(dbg, current_ir_graph, block,
-                               get_irn_n(node, 0), get_irn_n(node, 1), mode_T);
+                       load = new_rd_ppc32_Lfd(dbg, current_ir_graph, block,   get_irn_n(node, 0), get_irn_n(node, 1));
                }
                else assert(0 && "Reload for register class not supported yet!");
 
@@ -558,7 +567,6 @@ static void ppc32_emit_and_done(void *self) {
                cg->emit_decls = 0;
        }
 
-       ppc32_finish_irg(irg, cg);
        dump_ir_block_graph_sched(irg, "-ppc-finished");
        ppc32_gen_routine(out, irg, cg);
 
@@ -601,6 +609,7 @@ static const arch_code_generator_if_t ppc32_code_gen_if = {
        ppc32_before_sched,   /* before scheduling hook */
        ppc32_before_ra,      /* before register allocation hook */
        ppc32_after_ra,
+       ppc32_finish_irg,
        ppc32_emit_and_done
 };
 
@@ -661,8 +670,8 @@ static void *ppc32_cg_init(const be_irg_t *birg) {
 
 static ppc32_isa_t ppc32_isa_template = {
        &ppc32_isa_if,
-       &ppc32_general_purpose_regs[REG_R1],  // stack pointer
-       &ppc32_general_purpose_regs[REG_R31], // base pointer
+       &ppc32_gp_regs[REG_R1],  // stack pointer
+       &ppc32_gp_regs[REG_R31], // base pointer
        -1,                                   // stack is decreasing
        0,                                    // num codegens... ??
        NULL
@@ -721,9 +730,9 @@ static const arch_register_class_t *ppc32_get_reg_class(const void *self, int i)
  */
 const arch_register_class_t *ppc32_get_reg_class_for_mode(const void *self, const ir_mode *mode) {
        if (mode_is_float(mode))
-               return &ppc32_reg_classes[CLASS_ppc32_floating_point];
+               return &ppc32_reg_classes[CLASS_ppc32_fp];
        else
-               return &ppc32_reg_classes[CLASS_ppc32_general_purpose];
+               return &ppc32_reg_classes[CLASS_ppc32_gp];
 }
 
 
@@ -763,7 +772,7 @@ static void ppc32_get_call_abi(const void *self, ir_type *method_type, be_abi_ca
                                {
                                        if(get_mode_size_bits(mode) == 32) gpregi++, stackparamsize=4;
                                        else gpregi += 2, stackparamsize=8;                                                             // mode == irm_D
-                                       reg = &ppc32_floating_point_regs[fpregi++];
+                                       reg = &ppc32_fp_regs[fpregi++];
                                }
                                else
                                {
@@ -775,7 +784,7 @@ static void ppc32_get_call_abi(const void *self, ir_type *method_type, be_abi_ca
                        else
                        {
                                if(gpregi <= REG_R10)
-                                       reg = &ppc32_general_purpose_regs[gpregi++];
+                                       reg = &ppc32_gp_regs[gpregi++];
                                else
                                        reg = NULL;
                                stackparamsize=4;
@@ -804,7 +813,7 @@ static void ppc32_get_call_abi(const void *self, ir_type *method_type, be_abi_ca
                mode = get_type_mode(tp);
 
                be_abi_call_res_reg(abi, 0,
-                       mode_is_float(mode) ? &ppc32_floating_point_regs[REG_F1] : &ppc32_general_purpose_regs[REG_R3]);
+                       mode_is_float(mode) ? &ppc32_fp_regs[REG_F1] : &ppc32_gp_regs[REG_R3]);
        }
 }
 
@@ -850,6 +859,30 @@ static int ppc32_get_reg_class_alignment(const void *self, const arch_register_c
        return get_mode_size_bytes(mode);
 }
 
+/**
+ * Returns the libFirm configuration parameter for this backend.
+ */
+static const backend_params *ppc32_get_libfirm_params(void) {
+       static arch_dep_params_t ad = {
+               1,  /* allow subs */
+               0,      /* Muls are fast enough on ARM */
+               31, /* shift would be ok */
+               0,  /* SMUL is needed, only in Arch M*/
+               0,  /* UMUL is needed, only in Arch M */
+               32, /* SMUL & UMUL available for 32 bit */
+       };
+       static backend_params p = {
+               NULL,  /* no additional opcodes */
+               NULL,  /* will be set later */
+               1,     /* need dword lowering */
+               NULL,  /* but yet no creator function */
+               NULL,  /* context for create_intrinsic_fkt */
+       };
+
+       p.dep_param = &ad;
+       return &p;
+}
+
 #ifdef WITH_LIBCORE
 static void ppc32_register_options(lc_opt_entry_t *ent)
 {
@@ -867,6 +900,7 @@ const arch_isa_if_t ppc32_isa_if = {
        ppc32_get_code_generator_if,
        ppc32_get_list_sched_selector,
        ppc32_get_reg_class_alignment,
+       ppc32_get_libfirm_params,
 #ifdef WITH_LIBCORE
        ppc32_register_options
 #endif