diff --git a/Makefile b/Makefile index 88a942585f3f54e196db0ff74ab48f4f3320d8c3..1eab8e13727c0038641ee26273015fbf66e93aa6 100755 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ .PHONY: all -all: TEST1 TEST2 TEST3 TEST4 dot convert +#all: TEST1 TEST2 TEST3 TEST4 dot convert +all: TEST3 dot convert TEST1=./tests/simple_test1.c TEST2=./tests/simple_test2.c diff --git a/functions/frontier.c b/functions/frontier.c index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..c2b031815978921434d281977625cbb6175031a5 100644 --- a/functions/frontier.c +++ b/functions/frontier.c @@ -0,0 +1,105 @@ +#include "frontier.h" + +void bitmap_pdf(function * fun) +{ + printf("---------\n"); + printf("\n---PDF---\n"); + printf("---------\n"); + + bitmap_head *pfrontiers; + basic_block bb; + pfrontiers = XNEWVEC (bitmap_head, last_basic_block_for_fn (fun)); + + FOR_ALL_BB_FN (bb, cfun) + { + bitmap_initialize (&pfrontiers[bb->index], &bitmap_default_obstack); + } + + td5_q1_bitmap_post_dominance_frontiers (pfrontiers, fun); + + //FOR_ALL_BB_FN (bb, cfun) + //{ + // printf( "PDF Node %d: ", bb->index ) ; + // bitmap_print( stdout, &pfrontiers[bb->index], "", "\n" ) ; + //} +} +void bitmap_post_dominance_frontiers (bitmap_head *frontiers, function * fun) +{ + edge p; + edge_iterator ei; + basic_block b; + + FOR_EACH_BB_FN (b, fun) + { + + if (EDGE_COUNT (b->succs) >= 2) + { + FOR_EACH_EDGE (p, ei, b->succs) + { + basic_block runner = p->dest; + basic_block pdomsb; + + if (runner == EXIT_BLOCK_PTR_FOR_FN (fun)) + continue; + + pdomsb = get_immediate_dominator (CDI_POST_DOMINATORS, b); + while (runner != pdomsb) + { + if (!bitmap_set_bit (&frontiers[runner->index], b->index)) + break; + runner = get_immediate_dominator (CDI_POST_DOMINATORS, runner); + } + } + } + } +} +void +td5_q1_bitmap_post_dominance_frontiers (bitmap_head *frontiers, function * fun) +{ + edge p; + edge_iterator ei; + basic_block b; + + FOR_EACH_BB_FN (b, fun) + { + + if (EDGE_COUNT (b->succs) >= 2) +// if (EDGE_COUNT (b->preds) >= 2) + { + FOR_EACH_EDGE (p, ei, b->succs) +// FOR_EACH_EDGE (p, ei, b->preds) + { + basic_block runner = p->dest; +// basic_block runner = p->src; + basic_block pdomsb; + + if (runner == EXIT_BLOCK_PTR_FOR_FN (fun)) +// if (runner == ENTRY_BLOCK_PTR_FOR_FN (fun)) + continue; + + pdomsb = get_immediate_dominator (CDI_POST_DOMINATORS, b); +// pdomsb = get_immediate_dominator (CDI_DOMINATORS, b); + while (runner != pdomsb) + { + if (!bitmap_set_bit (&frontiers[runner->index], b->index)) + break; +/* + if (1 == bitmap_bit_p(&frontiers[runner->index], b->index)) + { + break; + } + else + { + bitmap_set_bit (&frontiers[runner->index], b->index); + cpt++; + printf("%d\n", cpt); + + } +*/ + runner = get_immediate_dominator (CDI_POST_DOMINATORS, runner); +// runner = get_immediate_dominator (CDI_DOMINATORS, runner); + } + } + } + } +} diff --git a/functions/frontier.h b/functions/frontier.h index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f3e73bf3811bff37a3374b18e1f52a63603a3450 100644 --- a/functions/frontier.h +++ b/functions/frontier.h @@ -0,0 +1,6 @@ +#ifndef __PDFDD__H +#define __PDFDD__H +void bitmap_pdf(function * fun); +void bitmap_post_dominance_frontiers (bitmap_head *frontiers, function * fun); +void td5_q1_bitmap_post_dominance_frontiers (bitmap_head *frontiers, function * fun); +#endif diff --git a/plugin.cpp b/plugin.cpp index a825ce1f2d55b2b8153714abbe4676220a668da5..b27aa81fbb34e0959eed58c295c779f1ce165012 100755 --- a/plugin.cpp +++ b/plugin.cpp @@ -24,6 +24,8 @@ #include "./functions/MPI_functions.c" #include "./functions/pragma.h" #include "./functions/pragma.c" +#include "./functions/frontier.h" +#include "./functions/frontier.c" int plugin_is_GPL_compatible; @@ -112,6 +114,7 @@ class split_count_pass : public gimple_opt_pass if ( !in_system_header_at( fun->function_start_locus ) ) cfgviz_dump( fun, function_name(fun), 1 ) ; + bitmap_pdf(fun); return 0; } };