From a40bcb492210445ed81c83177c31182abeeb8987 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 12 Dec 2016 23:45:52 +0100 Subject: [PATCH] Rename the locals SSA pass to be more clearly named. --- .../mcg/{pass_ssa.c => pass_locals_ssa.c} | 54 +++---------------- 1 file changed, 7 insertions(+), 47 deletions(-) rename mach/proto/mcg/{pass_ssa.c => pass_locals_ssa.c} (76%) diff --git a/mach/proto/mcg/pass_ssa.c b/mach/proto/mcg/pass_locals_ssa.c similarity index 76% rename from mach/proto/mcg/pass_ssa.c rename to mach/proto/mcg/pass_locals_ssa.c index e0f835f17..4570521e9 100644 --- a/mach/proto/mcg/pass_ssa.c +++ b/mach/proto/mcg/pass_locals_ssa.c @@ -1,50 +1,11 @@ #include "mcg.h" -static PMAPOF(struct basicblock, struct basicblock) dominancefrontiers; - static struct local* current_local; static ARRAYOF(struct basicblock) defining; static ARRAYOF(struct basicblock) needsphis; static ARRAYOF(struct ir) definitions; static ARRAYOF(struct basicblock) rewritten; -static void calculate_dominance_frontier_graph(void) -{ - /* This is the algorithm described here: - * - * Cooper, Keith D., Timothy J. Harvey, and Ken Kennedy. - * "A simple, fast dominance algorithm." - * Software Practice & Experience 4.1-10 (2001): 1-8. - * - * https://www.cs.rice.edu/~keith/EMBED/dom.pdf - */ - - int i, j; - - dominancefrontiers.count = 0; - - for (i=0; iprevs.count >= 2) - { - for (j=0; jprevs.count; j++) - { - struct basicblock* runner = b->prevs.item[j]; - while (runner != dominator) - { - tracef('S', "S: %s is in %s's dominance frontier\n", - b->name, runner->name); - pmap_add(&dominancefrontiers, runner, b); - runner = pmap_findleft(&dominance.graph, runner); - } - } - } - } - -} - static bool is_local(struct ir* ir) { return ((ir->opcode == IR_LOAD) && @@ -153,9 +114,9 @@ static void ssa_convert(void) ); ir->root = ir; - ir->left->root = ir; - ir->right->root = ir; - ir->right->left->root = ir; + ir->bb = cfg.entry; + ir->left->root = ir->right->root = ir->right->left->root = ir; + ir->left->bb = ir->right->bb = ir->right->left->bb = cfg.entry; array_insert(&cfg.entry->irs, ir, 0); } @@ -186,11 +147,11 @@ static void ssa_convert(void) { struct basicblock* bb = defining.item[i]; tracef('S', "S: local %d in defined in block %s\n", current_local->offset, bb->name); - for (j=0; joffset, dominates->name); @@ -205,6 +166,7 @@ static void ssa_convert(void) struct basicblock* bb = needsphis.item[i]; struct ir* ir = new_ir0(IR_PHI, current_local->size); ir->root = ir; + ir->bb = bb; array_insert(&bb->irs, ir, 0); } @@ -219,8 +181,6 @@ void pass_convert_locals_to_ssa(void) { int i; - calculate_dominance_frontier_graph(); - for (i=0; ilocals.count; i++) { current_local = current_proc->locals.item[i].right; -- 2.34.1