fehler109
[libfirm] / ir / be / ppc32 / bearch_ppc32.c
index 1c68941..ea04f8a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
@@ -37,6 +37,7 @@
 
 #include "bitset.h"
 #include "debug.h"
+#include "error.h"
 
 #include "../bearch_t.h"                /* the general register allocator interface */
 #include "../benode_t.h"
@@ -264,8 +265,9 @@ typedef struct
  */
 static void *ppc32_abi_init(const be_abi_call_t *call, const arch_env_t *aenv, ir_graph *irg)
 {
-       (void) aenv;
        ppc32_abi_env *env = xmalloc(sizeof(ppc32_abi_env));
+       (void) aenv;
+
        env->call = call;
        env->irg = irg;
        return env;
@@ -505,7 +507,7 @@ static void ppc32_transform_spill(ir_node *node, void *env)
                        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));
                }
-               else assert(0 && "Spill for register class not supported yet!");
+               else panic("Spill for register class not supported yet!");
 
                set_ppc32_frame_entity(store, be_get_frame_entity(node));
 
@@ -539,7 +541,7 @@ static void ppc32_transform_spill(ir_node *node, void *env)
                {
                        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!");
+               else panic("Reload for register class not supported yet!");
 
                set_ppc32_frame_entity(load, be_get_frame_entity(node));
 
@@ -650,7 +652,6 @@ static ppc32_isa_t ppc32_isa_template = {
                7,                       /* spill costs */
                5,                       /* reload costs */
        },
-       NULL_EMITTER,           /* emitter environment */
        NULL                    /* symbol set */
 };
 
@@ -685,7 +686,7 @@ static void *ppc32_init(FILE *file_handle) {
        isa = xmalloc(sizeof(*isa));
        memcpy(isa, &ppc32_isa_template, sizeof(*isa));
 
-       be_emit_init_env(&isa->emit, file_handle);
+       be_emit_init(file_handle);
 
        ppc32_register_init();
        ppc32_create_opcodes();
@@ -712,8 +713,8 @@ static void ppc32_dump_indirect_symbols(ppc32_isa_t *isa) {
 
        foreach_pset(isa->symbol_set, ent) {
                const char *ld_name = get_entity_ld_name(ent);
-               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);
-               be_emit_write_line(&isa->emit);
+               be_emit_irprintf(".non_lazy_symbol_pointer\n%s:\n\t.indirect_symbol _%s\n\t.long 0\n\n", ld_name, ld_name);
+               be_emit_write_line();
        }
 }
 
@@ -723,11 +724,11 @@ static void ppc32_dump_indirect_symbols(ppc32_isa_t *isa) {
 static void ppc32_done(void *self) {
        ppc32_isa_t *isa = self;
 
-       be_gas_emit_decls(&isa->emit, isa->arch_isa.main_env, 1);
-       be_gas_emit_switch_section(&isa->emit, GAS_SECTION_DATA);
+       be_gas_emit_decls(isa->arch_isa.main_env, 1);
+       be_gas_emit_switch_section(GAS_SECTION_DATA);
        ppc32_dump_indirect_symbols(isa);
 
-       be_emit_destroy_env(&isa->emit);
+       be_emit_exit();
        del_pset(isa->symbol_set);
 
        free(self);
@@ -735,14 +736,15 @@ static void ppc32_done(void *self) {
 
 
 
-static int ppc32_get_n_reg_class(const void *self) {
+static unsigned ppc32_get_n_reg_class(const void *self) {
        (void) self;
        return N_CLASSES;
 }
 
-static const arch_register_class_t *ppc32_get_reg_class(const void *self, int i) {
+static const arch_register_class_t *ppc32_get_reg_class(const void *self,
+                                                        unsigned i) {
        (void) self;
-       assert(i >= 0 && i < N_CLASSES && "Invalid ppc register class requested.");
+       assert(i < N_CLASSES && "Invalid ppc register class requested.");
        return &ppc32_reg_classes[i];
 }
 
@@ -790,10 +792,9 @@ static void ppc32_get_call_abi(const void *self, ir_type *method_type, be_abi_ca
 
        for (i = 0; i < n; i++) {
                tp   = get_method_param_type(method_type, i);
+               mode = get_type_mode(tp);
                if(is_atomic_type(tp))
                {
-                       mode = get_type_mode(tp);
-
                        if(mode_is_float(mode))
                        {
                                if(fpregi <= REG_F13)
@@ -822,14 +823,14 @@ static void ppc32_get_call_abi(const void *self, ir_type *method_type, be_abi_ca
                                be_abi_call_param_reg(abi, i, reg);
                        else
                        {
-                               be_abi_call_param_stack(abi, i, 4, stackoffs-lastoffs, 0);
+                               be_abi_call_param_stack(abi, i, mode, 4, stackoffs - lastoffs, 0);
                                lastoffs = stackoffs+stackparamsize;
                        }
                        stackoffs += stackparamsize;
                }
                else
                {
-                       be_abi_call_param_stack(abi, i, 4, stackoffs-lastoffs, 0);
+                       be_abi_call_param_stack(abi, i, mode, 4, stackoffs - lastoffs, 0);
                        stackoffs += (get_type_size_bytes(tp)+3) & -4;
                        lastoffs = stackoffs;
                }
@@ -884,7 +885,7 @@ list_sched_selector_t ppc32_sched_selector;
 static const list_sched_selector_t *ppc32_get_list_sched_selector(const void *self, list_sched_selector_t *selector) {
        (void) self;
        (void) selector;
-       memcpy(&ppc32_sched_selector, trivial_selector, sizeof(list_sched_selector_t));
+       ppc32_sched_selector = trivial_selector;
        ppc32_sched_selector.to_appear_in_schedule = ppc32_to_appear_in_schedule;
        return &ppc32_sched_selector;
 }
@@ -898,8 +899,9 @@ static const ilp_sched_selector_t *ppc32_get_ilp_sched_selector(const void *self
  * Returns the necessary byte alignment for storing a register of given class.
  */
 static int ppc32_get_reg_class_alignment(const void *self, const arch_register_class_t *cls) {
-       (void) self;
        ir_mode *mode = arch_register_class_mode(cls);
+       (void) self;
+
        return get_mode_size_bytes(mode);
 }
 
@@ -931,14 +933,6 @@ static ir_graph **ppc32_get_irg_list(const void *self, ir_graph ***irg_list) {
  * 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 = {
                1,     /* need dword lowering */
                0,     /* don't support inlien assembler yet */
@@ -949,7 +943,6 @@ static const backend_params *ppc32_get_libfirm_params(void) {
                NULL,  /* no if conversion settings */
        };
 
-       p.dep_param = &ad;
        return &p;
 }