Skip to content
Extraits de code Groupes Projets
Valider 46c574b6 rédigé par Théotime DONNENFELD's avatar Théotime DONNENFELD
Parcourir les fichiers

Added first version of pragmas

parent 84fc6327
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Pipeline #1134 annulé
#include "pragma.h"
static void my_pragma_action(cpp_reader *ARG_UNUSED(dummy))
{
printf("****** Pragam detected: ******\n");
enum cpp_ttype token;
tree x;
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;
}
if (token == CPP_OPEN_PAREN){
close_paren_needed_p = true;
token = pragma_lex (&x);
}
if (token == CPP_NAME){
tree args = NULL_TREE;
do
{
if (TREE_STRING_LENGTH (x) > 0)
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));
token = pragma_lex (&x);
//Cleans COMAS
while (token == CPP_COMMA){
token = pragma_lex (&x);
}
}while (token == CPP_NAME);
if(close_paren_needed_p){
if (token == CPP_CLOSE_PAREN){
token = pragma_lex (&x);
}
else{
printf("Missing closed parenthesis\n");
correct_pragma_names = false;
return;
}
}
}
else{
printf("Invalid pragma - not starting with name or open parenthesis\n");
return;
}
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){
pragma_func_names.safe_push(pragma_func_names_temp.pop());
}
printf("\n\n");
}
static void register_my_pragma(void *event_data, void *data)
{
c_register_pragma ("instrumente", "function", my_pragma_action);
}
#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));
#endif
......@@ -22,6 +22,8 @@
#include "./functions/graph.c"
#include "./functions/MPI_functions.h"
#include "./functions/MPI_functions.c"
#include "./functions/pragma.h"
#include "./functions/pragma.c"
int plugin_is_GPL_compatible;
......@@ -53,19 +55,6 @@ const pass_data cleanup_pass_data =
};
static void my_pragma_action(cpp_reader *ARG_UNUSED(dummy))
{
printf("****** Pragma detected: ******\n");
printf("\n");
}
static void register_my_pragma(void *event_data, void *data)
{
c_register_pragma ("instrumente", "function", my_pragma_action);
}
class split_count_pass : public gimple_opt_pass
{
public:
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter