From 6bf519d05209156dff586c59160ecba487d7f132 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Fri, 6 Nov 2009 12:57:06 +0000 Subject: [PATCH] cleanup beabi a bit and use module constructor/global debug context [r26721] --- ir/be/beabi.c | 42 +++++++++++++----------------------------- ir/be/bemodule.c | 7 +++++-- 2 files changed, 18 insertions(+), 31 deletions(-) diff --git a/ir/be/beabi.c b/ir/be/beabi.c index 9d4f3f9b2..7624f6f09 100644 --- a/ir/be/beabi.c +++ b/ir/be/beabi.c @@ -54,6 +54,9 @@ #include "besched.h" #include "beirg.h" #include "bessaconstr.h" +#include "bemodule.h" + +DEBUG_ONLY(static firm_dbg_module_t *dbg;) typedef struct _be_abi_call_arg_t { unsigned is_res : 1; /**< 1: the call argument is a return value. 0: it's a call parameter. */ @@ -109,8 +112,6 @@ struct _be_abi_irg_t { arch_register_req_t *sp_req; be_stack_layout_t frame; /**< The stack frame model. */ - - DEBUG_ONLY(firm_dbg_module_t *dbg;) /**< The debugging module. */ }; static heights_t *ir_heights; @@ -377,25 +378,6 @@ static be_stack_layout_t *stack_frame_init(be_stack_layout_t *frame, ir_type *ar return frame; } -#if 0 -/** Dumps the stack layout to file. */ -static void stack_layout_dump(FILE *file, be_stack_layout_t *frame) -{ - int i, j, n; - - ir_fprintf(file, "initial offset: %d\n", frame->initial_offset); - for (j = 0; j < N_FRAME_TYPES; ++j) { - ir_type *t = frame->order[j]; - - ir_fprintf(file, "type %d: %F size: %d\n", j, t, get_type_size_bytes(t)); - for (i = 0, n = get_compound_n_members(t); i < n; ++i) { - ir_entity *ent = get_compound_member(t, i); - ir_fprintf(file, "\t%F int ofs: %d glob ofs: %d\n", ent, get_entity_offset_bytes(ent), get_stack_entity_offset(frame, ent, 0)); - } - } -} -#endif - /** * Returns non-zero if the call argument at given position * is transfered on the stack. @@ -752,7 +734,7 @@ static ir_node *adjust_call(be_abi_irg_t *env, ir_node *irn, ir_node *curr_sp) */ be_node_set_reg_class_in(low_call, be_pos_Call_ptr, call->cls_addr); - DBG((env->dbg, LEVEL_3, "\tcreated backend call %+F\n", low_call)); + DBG((dbg, LEVEL_3, "\tcreated backend call %+F\n", low_call)); /* Set the register classes and constraints of the Call parameters. */ for (i = 0; i < n_reg_params; ++i) { @@ -1183,7 +1165,7 @@ static void process_ops_in_block(ir_node *bl, void *data) for (i = n - 1; i >= 0; --i) { ir_node *irn = nodes[i]; - DBG((env->dbg, LEVEL_3, "\tprocessing call %+F\n", irn)); + DBG((dbg, LEVEL_3, "\tprocessing call %+F\n", irn)); switch (get_irn_opcode(irn)) { case iro_Call: if (! be_omit_fp) { @@ -1629,7 +1611,6 @@ static void fix_address_of_parameter_access(be_abi_irg_t *env, ent_pos_pair *val ent_pos_pair *entry, *new_list; ir_type *frame_tp; int i, n = ARR_LEN(value_param_list); - DEBUG_ONLY(firm_dbg_module_t *dbg = env->dbg;) new_list = NULL; for (i = 0; i < n; ++i) { @@ -1855,8 +1836,6 @@ static void modify_irg(be_abi_irg_t *env) lower_frame_sels_env_t ctx; ir_entity **param_map; - DEBUG_ONLY(firm_dbg_module_t *dbg = env->dbg;) - DBG((dbg, LEVEL_1, "introducing abi on %+F\n", irg)); /* Must fetch memory here, otherwise the start Barrier gets the wrong @@ -2343,8 +2322,6 @@ be_abi_irg_t *be_abi_introduce(be_irg_t *birg) env->init_sp = dummy = new_r_Unknown(irg, env->arch_env->sp->reg_class->mode); restore_optimization_state(&state); - FIRM_DBG_REGISTER(env->dbg, "firm.be.abi"); - env->calls = NEW_ARR_F(ir_node*, 0); if (birg->main_env->options->pic) { @@ -2553,7 +2530,7 @@ static int process_stack_bias(be_abi_irg_t *env, ir_node *bl, int real_bias) int bias = omit_fp ? real_bias : 0; int offset = get_stack_entity_offset(&env->frame, ent, bias); arch_set_frame_offset(irn, offset); - DBG((env->dbg, LEVEL_2, "%F has offset %d (including bias %d)\n", + DBG((dbg, LEVEL_2, "%F has offset %d (including bias %d)\n", ent, offset, bias)); } @@ -2716,3 +2693,10 @@ int be_abi_omit_fp(const be_abi_irg_t *abi) { return abi->call->flags.bits.try_omit_fp; } + +void be_init_abi(void) +{ + FIRM_DBG_REGISTER(dbg, "firm.be.abi"); +} + +BE_REGISTER_MODULE_CONSTRUCTOR(be_init_abi); diff --git a/ir/be/bemodule.c b/ir/be/bemodule.c index e93deff5e..dc75c94d9 100644 --- a/ir/be/bemodule.c +++ b/ir/be/bemodule.c @@ -27,10 +27,12 @@ #include "config.h" #include +#include #include "bemodule_t.h" #include "xmalloc.h" +void be_init_abi(void); void be_init_sched(void); void be_init_blocksched(void); void be_init_spill(void); @@ -82,12 +84,13 @@ void be_quit_pbqp(void); */ void be_init_modules(void) { - static int run_once = 0; + static bool run_once = false; if (run_once) return; - run_once = 1; + run_once = true; + be_init_abi(); be_init_irgmod(); be_init_loopana(); be_init_live(); -- 2.20.1