removed dangerous get_nodes_block()
[libfirm] / ir / be / ia32 / bearch_ia32.c
index d4276b9..e4ac9d1 100644 (file)
@@ -1504,6 +1504,7 @@ static ia32_isa_t ia32_isa_template = {
        { NULL, },                      /* emitter environment */
        NULL,                    /* 16bit register names */
        NULL,                    /* 8bit register names */
+       NULL,                    /* 8bit register names high */
        NULL,                    /* types */
        NULL,                    /* tv_ents */
        (0                 |
@@ -1558,14 +1559,16 @@ static void *ia32_init(FILE *file_handle) {
        }
 
        be_emit_init_env(&isa->emit, file_handle);
-       isa->regs_16bit = pmap_create();
-       isa->regs_8bit  = pmap_create();
-       isa->types      = pmap_create();
-       isa->tv_ent     = pmap_create();
-       isa->cpu        = ia32_init_machine_description();
+       isa->regs_16bit     = pmap_create();
+       isa->regs_8bit      = pmap_create();
+       isa->regs_8bit_high = pmap_create();
+       isa->types          = pmap_create();
+       isa->tv_ent         = pmap_create();
+       isa->cpu            = ia32_init_machine_description();
 
        ia32_build_16bit_reg_map(isa->regs_16bit);
        ia32_build_8bit_reg_map(isa->regs_8bit);
+       ia32_build_8bit_reg_map_high(isa->regs_8bit_high);
 
 #ifndef NDEBUG
        isa->name_obst = xmalloc(sizeof(*isa->name_obst));
@@ -1601,6 +1604,7 @@ static void ia32_done(void *self) {
 
        pmap_destroy(isa->regs_16bit);
        pmap_destroy(isa->regs_8bit);
+       pmap_destroy(isa->regs_8bit_high);
        pmap_destroy(isa->tv_ent);
        pmap_destroy(isa->types);
 
@@ -1662,11 +1666,7 @@ static void ia32_get_call_abi(const void *self, ir_type *method_type, be_abi_cal
        ir_mode  *mode;
        unsigned  cc        = get_method_calling_convention(method_type);
        int       n         = get_method_n_params(method_type);
-       int       biggest_n = -1;
-       int       stack_idx = 0;
-       int       i, ignore_1, ignore_2;
-       ir_mode **modes;
-       const arch_register_t *reg;
+       int       i;
        be_abi_call_flags_t call_flags = be_abi_call_get_flags(abi);
 
        unsigned use_push = !IS_P6_ARCH(isa->opt_arch);
@@ -1678,40 +1678,24 @@ static void ia32_get_call_abi(const void *self, ir_type *method_type, be_abi_cal
        call_flags.bits.fp_free               = 0;  /* the frame pointer is fixed in IA32 */
        call_flags.bits.call_has_imm          = 1;  /* IA32 calls can have immediate address */
 
-       /* set stack parameter passing style */
+       /* set parameter passing style */
        be_abi_call_set_flags(abi, call_flags, &ia32_abi_callbacks);
 
-       /* collect the mode for each type */
-       modes = alloca(n * sizeof(modes[0]));
-
        for (i = 0; i < n; i++) {
-               tp       = get_method_param_type(method_type, i);
-               modes[i] = get_type_mode(tp);
-       }
+               const ir_mode         *mode;
+               const arch_register_t *reg;
 
-       /* set register parameters  */
-       if (cc & cc_reg_param) {
-               /* determine the number of parameters passed via registers */
-               biggest_n = ia32_get_n_regparam_class(n, modes, &ignore_1, &ignore_2);
+               tp   = get_method_param_type(method_type, i);
+               mode = get_type_mode(tp);
+               reg  = ia32_get_RegParam_reg(isa->cg, cc, i, mode);
 
-               /* loop over all parameters and set the register requirements */
-               for (i = 0; i <= biggest_n; i++) {
-                       reg = ia32_get_RegParam_reg(n, modes, i, cc);
-                       assert(reg && "kaputt");
+               if(reg != NULL) {
                        be_abi_call_param_reg(abi, i, reg);
+               } else {
+                       be_abi_call_param_stack(abi, i, 4, 0, 0);
                }
-
-               stack_idx = i;
-       }
-
-
-       /* set stack parameters */
-       for (i = stack_idx; i < n; i++) {
-               /* parameters on the stack are 32 bit aligned */
-               be_abi_call_param_stack(abi, i, 4, 0, 0);
        }
 
-
        /* set return registers */
        n = get_method_n_ress(method_type);
 
@@ -1760,8 +1744,6 @@ const arch_irn_handler_t *ia32_get_irn_handler(const void *self) {
 
 int ia32_to_appear_in_schedule(void *block_env, const ir_node *irn) {
        if(!is_ia32_irn(irn)) {
-               if (is_ASM(irn))
-                       return 1;
                return -1;
        }
 
@@ -1925,14 +1907,6 @@ static int ia32_is_psi_allowed(ir_node *sel, ir_node *phi_list, int i, int j)
        return 1;
 }
 
-/**
- * Called by the frontend to encode a register name into a backend specific way
- */
-static unsigned ia32_register_from_name(const char *regname) {
-       /* NYI */
-       return 0;
-}
-
 static ia32_intrinsic_env_t intrinsic_env = {
        NULL,    /**< the irg, these entities belong to */
        NULL,    /**< entity for first div operand (move into FPU) */
@@ -1961,12 +1935,12 @@ static const backend_params *ia32_get_libfirm_params(void) {
        static backend_params p = {
                1,     /* need dword lowering */
                1,     /* support inline assembly */
+               1,     /* prefer fastcall calling convention */
                NULL,  /* no additional opcodes */
                NULL,  /* will be set later */
                ia32_create_intrinsic_fkt,
                &intrinsic_env,  /* context for ia32_create_intrinsic_fkt */
                NULL,  /* will be set later */
-               ia32_register_from_name, /* register names */
        };
 
        p.dep_param    = &ad;