Remove the unused macro constant SNPRINTF_BUF_LEN.
[libfirm] / ir / be / ia32 / bearch_ia32.c
index 8e16494..b815291 100644 (file)
@@ -38,7 +38,6 @@
 #include "irflag.h"
 #include "irgmod.h"
 #include "irgopt.h"
-#include "irbitset.h"
 #include "irgopt.h"
 #include "irdump.h"
 #include "pdeq.h"
@@ -63,7 +62,6 @@
 #include "be.h"
 #include "be_t.h"
 #include "beirgmod.h"
-#include "be_dbgout.h"
 #include "beblocksched.h"
 #include "bespillutil.h"
 #include "bespillslots.h"
@@ -191,14 +189,6 @@ static ir_node *ia32_get_admissible_noreg(ir_node *irn, int pos)
        }
 }
 
-/**
- * The IA32 ABI callback object.
- */
-typedef struct {
-       be_abi_call_flags_bits_t flags;  /**< The call flags. */
-       ir_graph *irg;                   /**< The associated graph. */
-} ia32_abi_env_t;
-
 static ir_entity *ia32_get_frame_entity(const ir_node *irn)
 {
        return is_ia32_irn(irn) ? get_ia32_frame_ent(irn) : NULL;
@@ -254,7 +244,7 @@ static int ia32_get_sp_bias(const ir_node *node)
 static void ia32_build_between_type(void)
 {
 #define IDENT(s) new_id_from_chars(s, sizeof(s)-1)
-       if (! between_type) {
+       if (between_type == NULL) {
                ir_type *old_bp_type   = new_type_primitive(mode_Iu);
                ir_type *ret_addr_type = new_type_primitive(mode_Iu);
 
@@ -1311,7 +1301,7 @@ static void introduce_prolog_epilog(ir_graph *irg)
  * virtual with real x87 instructions, creating a block schedule and peephole
  * optimisations.
  */
-static void ia32_finish(ir_graph *irg)
+static void ia32_finish_graph(ir_graph *irg)
 {
        ia32_irg_data_t   *irg_data     = ia32_get_irg_data(irg);
        be_stack_layout_t *stack_layout = be_get_irg_stack_layout(irg);
@@ -1411,8 +1401,8 @@ static void set_tarval_output_modes(void)
 {
        size_t i;
 
-       for (i = get_irp_n_modes(); i > 0;) {
-               ir_mode *mode = get_irp_mode(--i);
+       for (i = ir_get_n_modes(); i > 0;) {
+               ir_mode *mode = ir_get_mode(--i);
 
                if (mode_is_int(mode))
                        set_tarval_mode_output_option(mode, &mo_integer);
@@ -1728,19 +1718,15 @@ static backend_params ia32_backend_params = {
  */
 static void ia32_init(void)
 {
-       ir_mode    *mode_long_long;
-       ir_mode    *mode_unsigned_long_long;
-       ir_type    *type_long_long;
-       ir_type    *type_unsigned_long_long;
+       ir_mode *mode_long_long;
+       ir_mode *mode_unsigned_long_long;
+       ir_type *type_long_long;
+       ir_type *type_unsigned_long_long;
 
        ia32_setup_cg_config();
 
        init_asm_constraints();
 
-       set_tarval_output_modes();
-       ia32_register_init();
-       ia32_create_opcodes(&ia32_irn_ops);
-
        ia32_mode_fpcw = new_int_mode("Fpcw", irma_twos_complement, 16, 0, 0);
 
        /* note mantissa is 64bit but with explicitely encoded 1 so the really
@@ -1766,6 +1752,20 @@ static void ia32_init(void)
                ia32_backend_params.mode_float_arithmetic = ia32_mode_E;
                ia32_backend_params.type_long_double      = ia32_type_E;
        }
+
+       ia32_register_init();
+       obstack_init(&opcodes_obst);
+       ia32_create_opcodes(&ia32_irn_ops);
+}
+
+static void ia32_finish(void)
+{
+       if (between_type != NULL) {
+               free_type(between_type);
+               between_type = NULL;
+       }
+       ia32_free_opcodes();
+       obstack_free(&opcodes_obst, NULL);
 }
 
 /**
@@ -1797,6 +1797,8 @@ static arch_env_t *ia32_begin_codegeneration(const be_main_env_t *env)
 {
        ia32_isa_t *isa = XMALLOC(ia32_isa_t);
 
+       set_tarval_output_modes();
+
        *isa        = ia32_isa_template;
        isa->tv_ent = pmap_create();
 
@@ -1918,10 +1920,8 @@ static void ia32_get_call_abi(ir_type *method_type, be_abi_call_t *abi)
        be_abi_call_flags_t call_flags = be_abi_call_get_flags(abi);
 
        /* set abi flags for calls */
-       call_flags.bits.store_args_sequential = 0;
        /* call_flags.bits.try_omit_fp                 not changed: can handle both settings */
-       call_flags.bits.fp_free               = 0;  /* the frame pointer is fixed in IA32 */
-       call_flags.bits.call_has_imm          = 0;  /* No call immediate, we handle this by ourselves */
+       call_flags.bits.call_has_imm = false;  /* No call immediate, we handle this by ourselves */
 
        /* set parameter passing style */
        be_abi_call_set_flags(abi, call_flags, &ia32_abi_callbacks);
@@ -2042,8 +2042,6 @@ static void ia32_lower_for_target(void)
                &intrinsic_env,
        };
 
-       ia32_create_opcodes(&ia32_irn_ops);
-
        /* lower compound param handling
         * Note: we lower compound arguments ourself, since on ia32 we don't
         * have hidden parameters but know where to find the structs on the stack.
@@ -2163,6 +2161,7 @@ static const lc_opt_table_entry_t ia32_options[] = {
 
 const arch_isa_if_t ia32_isa_if = {
        ia32_init,
+       ia32_finish,
        ia32_get_libfirm_params,
        ia32_lower_for_target,
        ia32_parse_asm_constraint,
@@ -2182,7 +2181,7 @@ const arch_isa_if_t ia32_isa_if = {
        ia32_before_abi,     /* before abi introduce hook */
        ia32_prepare_graph,
        ia32_before_ra,      /* before register allocation hook */
-       ia32_finish,         /* called before codegen */
+       ia32_finish_graph,   /* called before codegen */
        ia32_emit,           /* emit && done */
 };