Output proper local lables (starting with .L/L) for the PIC base, switch tables and...
[libfirm] / ir / be / bessadestr.c
index db7ddc7..48a9bf1 100644 (file)
 #include "be_t.h"
 #include "beutil.h"
 #include "bechordal_t.h"
-#include "bearch_t.h"
+#include "bearch.h"
 #include "belive_t.h"
-#include "benode_t.h"
-#include "besched_t.h"
+#include "benode.h"
+#include "besched.h"
 #include "bestatevent.h"
-#include "beirg_t.h"
+#include "beirg.h"
 #include "beintlive_t.h"
 
 DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
@@ -53,7 +53,8 @@ DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
 #define get_reg(irn)         arch_get_irn_register(irn)
 #define set_reg(irn, reg)    arch_set_irn_register(irn, reg)
 
-static void clear_link(ir_node *irn, void *data) {
+static void clear_link(ir_node *irn, void *data)
+{
        (void) data;
        set_irn_link(irn, NULL);
 }
@@ -64,7 +65,8 @@ static void clear_link(ir_node *irn, void *data) {
  *  - have the current register class
  * The list is rooted at get_irn_link(BB).
  */
-static void collect_phis_walker(ir_node *irn, void *data) {
+static void collect_phis_walker(ir_node *irn, void *data)
+{
        be_chordal_env_t *env = data;
        if (is_Phi(irn) && chordal_has_class(env, irn)) {
                ir_node *bl = get_nodes_block(irn);
@@ -86,7 +88,8 @@ typedef struct {
        ir_node *proj; /**< The proj created for @p arg. */
 } perm_proj_t;
 
-static int cmp_perm_proj(const void *a, const void *b, size_t n) {
+static int cmp_perm_proj(const void *a, const void *b, size_t n)
+{
        const perm_proj_t *p = a;
        const perm_proj_t *q = b;
        (void) n;
@@ -102,11 +105,11 @@ typedef struct insert_all_perms_env_t {
 /**
  * Insert Perms in all predecessors of a block containing a phi
  */
-static void insert_all_perms_walker(ir_node *bl, void *data) {
+static void insert_all_perms_walker(ir_node *bl, void *data)
+{
        insert_all_perms_env_t *env = data;
        be_chordal_env_t *chordal_env = env->chordal_env;
        pmap *perm_map = env->perm_map;
-       ir_graph *irg = chordal_env->irg;
        be_lv_t *lv = chordal_env->birg->lv;
        int i, n;
 
@@ -148,7 +151,7 @@ static void insert_all_perms_walker(ir_node *bl, void *data) {
                         * create one. The only restriction is, that the phi argument
                         * may not be live in at the current block, since this argument
                         * interferes with the phi and must thus not be member of a
-                        * Perm. A copy will be inserted for this argument alter on.
+                        * Perm. A copy will be inserted for this argument later on.
                         */
                        if(!pp && !be_is_live_in(lv, bl, arg)) {
                                templ.pos = n_projs++;
@@ -166,7 +169,7 @@ static void insert_all_perms_walker(ir_node *bl, void *data) {
                        for(pp = set_first(arg_set); pp; pp = set_next(arg_set))
                                in[pp->pos] = pp->arg;
 
-                       perm = be_new_Perm(chordal_env->cls, irg, pred_bl, n_projs, in);
+                       perm = be_new_Perm(chordal_env->cls, pred_bl, n_projs, in);
                        be_stat_ev("phi_perm", n_projs);
 
                        insert_after = sched_skip(sched_last(pred_bl), 0, sched_skip_cf_predicator, NULL);
@@ -179,7 +182,7 @@ static void insert_all_perms_walker(ir_node *bl, void *data) {
                         */
                        insert_after = perm;
                        for(pp = set_first(arg_set); pp; pp = set_next(arg_set)) {
-                               ir_node *proj = new_r_Proj(irg, pred_bl, perm, get_irn_mode(pp->arg), pp->pos);
+                               ir_node *proj = new_r_Proj(pred_bl, perm, get_irn_mode(pp->arg), pp->pos);
                                pp->proj = proj;
                                assert(get_reg(pp->arg));
                                set_reg(proj, get_reg(pp->arg));
@@ -227,7 +230,8 @@ static void insert_all_perms_walker(ir_node *bl, void *data) {
  * Adjusts the register allocation for the (new) phi-operands
  * and insert duplicates iff necessary.
  */
-static void    set_regs_or_place_dupls_walker(ir_node *bl, void *data) {
+static void    set_regs_or_place_dupls_walker(ir_node *bl, void *data)
+{
        be_chordal_env_t *chordal_env = data;
        be_lv_t *lv = chordal_env->birg->lv;
        ir_node *phi;
@@ -259,7 +263,7 @@ static void set_regs_or_place_dupls_walker(ir_node *bl, void *data) {
 
                        DBG((dbg, LEVEL_1, "  for %+F(%s) -- %+F(%s)\n", phi, phi_reg->name, arg, arg_reg->name));
 
-                       if (values_interfere(chordal_env->birg, phi, arg)) {
+                       if (be_values_interfere(lv, phi, arg)) {
                                /*
                                        Insert a duplicate in arguments block,
                                        make it the new phi arg,
@@ -267,7 +271,7 @@ static void set_regs_or_place_dupls_walker(ir_node *bl, void *data) {
                                        insert it into schedule,
                                        pin it
                                */
-                               ir_node *dupl  = be_new_Copy(cls, chordal_env->irg, arg_block, arg);
+                               ir_node *dupl  = be_new_Copy(cls, arg_block, arg);
 
                                /* this is commented out because it will fail in case of unknown float */
 #if 0
@@ -336,8 +340,8 @@ static void set_regs_or_place_dupls_walker(ir_node *bl, void *data) {
                                        insert it into schedule,
                                        pin it
                                */
-                               ir_node *perm     = get_Proj_pred(arg);
-                               ir_node *dupl     = be_new_Copy(cls, chordal_env->irg, arg_block, arg);
+                               ir_node *perm = get_Proj_pred(arg);
+                               ir_node *dupl = be_new_Copy(cls, arg_block, arg);
                                ir_node *ins;
 
                                /* this is commented out because it will fail in case of unknown float */
@@ -376,7 +380,8 @@ static void set_regs_or_place_dupls_walker(ir_node *bl, void *data) {
        }
 }
 
-void be_ssa_destruction(be_chordal_env_t *chordal_env) {
+void be_ssa_destruction(be_chordal_env_t *chordal_env)
+{
        insert_all_perms_env_t insert_perms_env;
        pmap *perm_map = pmap_create();
        ir_graph *irg  = chordal_env->irg;
@@ -406,7 +411,7 @@ void be_ssa_destruction(be_chordal_env_t *chordal_env) {
        DBG((dbg, LEVEL_1, "Setting regs and placing dupls...\n"));
        irg_block_walk_graph(irg, set_regs_or_place_dupls_walker, NULL, chordal_env);
 
-       /* TODO: unfortunaltely updating doesn't work yet. */
+       /* TODO: unfortunately updating doesn't work yet. */
        be_liveness_invalidate(lv);
 
        if (chordal_env->opts->dump_flags & BE_CH_DUMP_SSADESTR)
@@ -415,7 +420,8 @@ void be_ssa_destruction(be_chordal_env_t *chordal_env) {
        pmap_destroy(perm_map);
 }
 
-static void ssa_destruction_check_walker(ir_node *bl, void *data) {
+static void ssa_destruction_check_walker(ir_node *bl, void *data)
+{
        ir_node *phi;
        int i, max;
        (void)data;
@@ -447,6 +453,7 @@ static void ssa_destruction_check_walker(ir_node *bl, void *data) {
        }
 }
 
-void be_ssa_destruction_check(be_chordal_env_t *chordal_env) {
+void be_ssa_destruction_check(be_chordal_env_t *chordal_env)
+{
        irg_block_walk_graph(chordal_env->irg, ssa_destruction_check_walker, NULL, NULL);
 }