From a81ce0e899bb843d65eaf2bef1a58be3d0ef2b0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9otime=20DONNENFELD?= <theotime.donnenfeld@ensiie.fr> Date: Sun, 21 Oct 2018 17:51:05 +0200 Subject: [PATCH] =?UTF-8?q?Tableau=20des=20fonctions=20a=20analyser=20bien?= =?UTF-8?q?=20r=C3=A9cup=C3=A9rer=20dans=20la=20gate,=20reste=20=C3=A0=20g?= =?UTF-8?q?=C3=A9rer=20le=20stockage=20de=20ce=20tableau=20et=20la=20compa?= =?UTF-8?q?raison=20pour=20chaque=20gate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/pragma.c | 27 ++++++++++++--------------- functions/pragma.h | 2 -- plugin.cpp | 7 +++++++ tests/pragma_test.c | 16 ++++++++-------- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/functions/pragma.c b/functions/pragma.c index 95085db..a98fc77 100644 --- a/functions/pragma.c +++ b/functions/pragma.c @@ -1,5 +1,8 @@ #include "pragma.h" +vec<const char*> pragma_func_names; +vec<const char*> pragma_func_names_temp; + static void my_pragma_action(cpp_reader *ARG_UNUSED(dummy)) { printf("****** Pragam detected: ******\n"); @@ -8,11 +11,11 @@ static void my_pragma_action(cpp_reader *ARG_UNUSED(dummy)) const char* elt; token = pragma_lex (&x); bool close_paren_needed_p = false; - bool correct_pragma_names = true; - bool is_in_array=false; + + if (cfun){ printf("!!Pragma placed inside function!!\n"); - correct_pragma_names = false; + return; } @@ -31,14 +34,8 @@ static void my_pragma_action(cpp_reader *ARG_UNUSED(dummy)) args = tree_cons (NULL_TREE, x, args); printf("Arg found : %s\n", IDENTIFIER_POINTER(x)); - is_in_array = false; - for (int ix = 0; pragma_func_names.iterate (ix, &elt); ix++){ - if(strcmp(elt,IDENTIFIER_POINTER(x))){ - is_in_array = true; - } - } - if(is_in_array) - pragma_func_names_temp.safe_push(IDENTIFIER_POINTER(x)); + + pragma_func_names_temp.safe_push(IDENTIFIER_POINTER(x)); token = pragma_lex (&x); //Cleans COMAS while (token == CPP_COMMA){ @@ -56,7 +53,7 @@ static void my_pragma_action(cpp_reader *ARG_UNUSED(dummy)) } else{ printf("Missing closed parenthesis\n"); - correct_pragma_names = false; + return; } } @@ -70,11 +67,11 @@ static void my_pragma_action(cpp_reader *ARG_UNUSED(dummy)) if (token != CPP_EOF) { printf("Error : arg read but EOL not reached"); - correct_pragma_names = false; + return; } - while(pragma_func_names_temp.length() != 0 && correct_pragma_names){ + while(pragma_func_names_temp.length() != 0){ pragma_func_names.safe_push(pragma_func_names_temp.pop()); } @@ -84,7 +81,7 @@ static void my_pragma_action(cpp_reader *ARG_UNUSED(dummy)) static void register_my_pragma(void *event_data, void *data) { - c_register_pragma ("instrumente", "function", my_pragma_action); + c_register_pragma ("ProjetCA", "mpicoll_check", my_pragma_action); } diff --git a/functions/pragma.h b/functions/pragma.h index 625efe5..5fdc160 100644 --- a/functions/pragma.h +++ b/functions/pragma.h @@ -1,8 +1,6 @@ #ifndef __PRAGMADD__H #define __PRAGMADD__H -vec<const char*> pragma_func_names; -vec<const char*> pragma_func_names_temp; static void register_my_pragma(void *event_data, void *data); static void my_pragma_action(cpp_reader *ARG_UNUSED(dummy)); diff --git a/plugin.cpp b/plugin.cpp index 566b6b3..ff70c35 100755 --- a/plugin.cpp +++ b/plugin.cpp @@ -121,6 +121,12 @@ class cleanup_pass : public gimple_opt_pass { printf("=> plugin: cleanup_pass... \n"); printf("=> plugin: gate... \n"); + printf("List of functions to be checked :\n"); + while(pragma_func_names.length() != 0){ + printf("- %s\n",pragma_func_names.pop()); + } + + return true; } @@ -131,6 +137,7 @@ class cleanup_pass : public gimple_opt_pass { printf("=> plugin: cleanup_pass... \n"); printf("=> plugin: execute...\n"); + printf("... in function %s\n\n", function_name(fun)); edit_all_aux_value(fun,(int*)NULL); return 0; diff --git a/tests/pragma_test.c b/tests/pragma_test.c index dbbfd9d..0589c90 100755 --- a/tests/pragma_test.c +++ b/tests/pragma_test.c @@ -5,17 +5,17 @@ #include <stdio.h> #include "pragma_test.h" -#pragma instrumente function mock1 -#pragma instrumente function mock2 -#pragma instrumente function mock3,mock5 -#pragma instrumente function (mock4,mock6) -#pragma instrumente function CANARD -#pragma instrumente function mock1 -#pragma instrumente function (coincoin +#pragma ProjetCA mpicoll_check mock1 +#pragma ProjetCA mpicoll_check mock2 +#pragma ProjetCA mpicoll_check mock3,mock5 +#pragma ProjetCA mpicoll_check (mock4,mock6) +#pragma ProjetCA mpicoll_check CANARD +#pragma ProjetCA mpicoll_check mock1 +#pragma ProjetCA mpicoll_check (coincoin void mock1() { printf("mock1\n"); - #pragma instrumente function MOCK1 + #pragma ProjetCA mpicoll_check MOCK1 } void mock2() { -- GitLab