Skip to content
Extraits de code Groupes Projets
Valider 88f5135b rédigé par Thomas DILASSER's avatar Thomas DILASSER
Parcourir les fichiers

separated pass in order to to have a better view

split_count_pass : split bb blocs and write MPI_collectives.def code
cleanup_pass : clean bb->aux value for the rest of the compiler
parent e13cc588
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Pipeline #1130 annulé
......@@ -25,10 +25,11 @@
int plugin_is_GPL_compatible;
const pass_data my_pass_data =
// First pass data corresponding to
const pass_data split_count_pass_data =
{
GIMPLE_PASS, /* type */
"NEW_PASS", /* name */
"DDPASS1", /* name */
OPTGROUP_NONE, /* optinfo_flags */
TV_OPTIMIZE, /* tv_id */
0, /* properties_required */
......@@ -38,6 +39,18 @@ const pass_data my_pass_data =
0, /* todo_flags_finish */
};
const pass_data cleanup_pass_data =
{
GIMPLE_PASS, /* type */
"DDPASS2", /* name */
OPTGROUP_NONE, /* optinfo_flags */
TV_OPTIMIZE, /* tv_id */
0, /* properties_required */
0, /* properties_provided */
0, /* properties_destroyed */
0, /* todo_flags_start */
0, /* todo_flags_finish */
};
static void my_pragma_action(cpp_reader *ARG_UNUSED(dummy))
......@@ -53,17 +66,17 @@ static void register_my_pragma(void *event_data, void *data)
}
class my_pass : public gimple_opt_pass
class split_count_pass : public gimple_opt_pass
{
public:
my_pass (gcc::context *ctxt)
: gimple_opt_pass (my_pass_data, ctxt)
split_count_pass (gcc::context *ctxt)
: gimple_opt_pass (split_count_pass_data, ctxt)
{}
/* opt_pass methods: */
my_pass *clone ()
split_count_pass *clone ()
{
return new my_pass(g);
return new split_count_pass(g);
}
......@@ -71,6 +84,7 @@ class my_pass : public gimple_opt_pass
/* Gate function (shall we apply this pass?) */
bool gate (function * fun)
{
printf("=> plugin: split_count_pass... \n");
printf("=> plugin: gate... \n");
return true;
}
......@@ -80,13 +94,54 @@ class my_pass : public gimple_opt_pass
/* Execute function */
unsigned int execute (function *fun)
{
printf("=> plugin: split_count_pass... \n");
printf("=> plugin: execute...\n");
printf("... in function %s\n", function_name(fun));
edit_all_aux_value(fun,(int*)NULL);
printf("... in function %s\n\n", function_name(fun));
//counter in bb aux
mark_number_of_calls(fun);
//split bb where we find several MPI calls
split_mpi_block(fun);
//writing corresponding MPI Call in corresponding basic block
write_mpi_code(fun);
return 0;
}
};
class cleanup_pass : public gimple_opt_pass
{
public:
cleanup_pass (gcc::context *ctxt)
: gimple_opt_pass (cleanup_pass_data, ctxt)
{}
/* opt_pass methods: */
cleanup_pass *clone ()
{
return new cleanup_pass(g);
}
/* Gate function (shall we apply this pass?) */
bool gate (function * fun)
{
printf("=> plugin: cleanup_pass... \n");
printf("=> plugin: gate... \n");
return true;
}
/* Execute function */
unsigned int execute (function *fun)
{
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;
}
};
int plugin_init(struct plugin_name_args * plugin_info, struct plugin_gcc_version * version)
{
......@@ -97,14 +152,31 @@ int plugin_init(struct plugin_name_args * plugin_info, struct plugin_gcc_version
if(!plugin_default_version_check(version, &gcc_version)) return 1;
struct register_pass_info my_pass_info;
struct register_pass_info split_count_info;
struct register_pass_info cleanup_info;
split_count_pass first_pass(g);
split_count_info.pass = &first_pass;
split_count_info.reference_pass_name = "cfg";
split_count_info.ref_pass_instance_number = 0;
split_count_info.pos_op = PASS_POS_INSERT_AFTER;
//REGISTER PASS
register_callback(plugin_info->base_name,
PLUGIN_PASS_MANAGER_SETUP,
NULL,
&split_count_info);
my_pass p(g);
cleanup_pass second_pass(g);
my_pass_info.pass = &p;
my_pass_info.reference_pass_name = "cfg";
my_pass_info.ref_pass_instance_number = 0;
my_pass_info.pos_op = PASS_POS_INSERT_AFTER;
cleanup_info.pass = &second_pass;
cleanup_info.reference_pass_name = "DDPASS1";
cleanup_info.ref_pass_instance_number = 0;
cleanup_info.pos_op = PASS_POS_INSERT_AFTER;
......@@ -112,7 +184,7 @@ int plugin_init(struct plugin_name_args * plugin_info, struct plugin_gcc_version
register_callback(plugin_info->base_name,
PLUGIN_PASS_MANAGER_SETUP,
NULL,
&my_pass_info);
&cleanup_info);
// REGISTER PRAGMA
register_callback("plugin_name", PLUGIN_PRAGMAS, register_my_pragma, NULL );
......
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