PIPS
|
#include <stdio.h>
#include <ctype.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "resources.h"
#include "misc.h"
#include "ri-util.h"
#include "prettyprint.h"
#include "syntheses.h"
#include "effects-util.h"
#include "pipsdbm.h"
#include "text-util.h"
#include "properties.h"
#include "dg.h"
#include "transformer.h"
#include "graph.h"
#include "ray_dte.h"
#include "sommet.h"
#include "sg.h"
#include "polyedre.h"
#include "semantics.h"
#include "control.h"
#include "callgraph.h"
#include "preprocessor.h"
#include "pipsmake.h"
#include "phrase_tools.h"
#include "effects-generic.h"
#include "effects-simple.h"
#include "effects-convex.h"
#include "phrase_distribution.h"
Go to the source code of this file.
Typedefs | |
typedef dg_arc_label | arc_label |
typedef dg_vertex_label | vertex_label |
Functions | |
static entity | create_module_with_statement (statement stat, string new_module_name, list l_params, list l_priv) |
Dynamically build a new module with specified statement. More... | |
string | get_function_name_by_searching_tag (statement stat, const char *tag) |
Return the identified function name of the externalized portion of code by searching comment matching tag. More... | |
static void | remove_begin_tag (statement stat, string function_name) |
Remove begin tag for statement stat and function function_name. More... | |
static void | remove_end_tag (statement stat, string function_name) |
Remove end tag for statement stat and function function_name. More... | |
static statement | isolate_code_portion (statement begin_tag_statement, statement end_tag_statement, statement sequence_statement) |
At this point, we have a sequence statement sequence_statement which contains a statement with a begin tag and a statement with a end tag. More... | |
list | identify_analyzed_statements_to_distribute (statement stat) |
This function return a list of statements that were previously marked for externalization during phase PHRASE_DISTRIBUTOR_INIT. More... | |
static list | identify_statements_to_distribute (statement module_stat) |
This function return a list of statements that are marked for externalization. More... | |
static void | distribute_code (string function_name, statement externalized_code, statement module_stat, list l_params, list l_priv) |
This function is called after identification and isolation of a portion of code to externalize. More... | |
static void | distribute (statement module_stat, entity module) |
Main function for PHRASE_DISTRIBUTION: phrase distribution for main module module, with root statement stat. More... | |
static void | prepare_distribute (statement module_stat) |
Main function for PHRASE_DISTRIBUTION_INIT: phrase distribution for module module_stat. More... | |
static string | get_externalized_function_param_name (entity variable, int param_nb) |
static string | get_externalized_function_private_param_name (entity variable) |
static entity | create_parameter_variable_for_new_module (entity a_variable, string new_name, string new_module_name, entity module, int param_nb) |
Creates a variable declared as a parameter in specified module. More... | |
entity | create_private_variable_for_new_module (entity a_variable, const char *new_name, const char *new_module_name, entity module) |
Creates a private variable in specified module. More... | |
void | add_parameter_variable_to_module (reference ref, entity module, statement stat, string new_module_name, int param_nb) |
Declare in the newly created module a new variable (which will be a parameter of the module), and replace all occurences to the old variable by the new created. More... | |
void | add_private_variable_to_module (reference ref, entity module, statement stat, string new_module_name) |
Declare in the newly created module a new variable (which will be a private to the module), and replace all occurences to the old variable by the new created. More... | |
bool | phrase_distributor_init (const char *module_name) |
bool | phrase_distributor (const char *module_name) |
Variables | |
static entity | dynamic_area = entity_undefined |
typedef dg_arc_label arc_label |
Definition at line 50 of file phrase_distributor.c.
typedef dg_vertex_label vertex_label |
Definition at line 51 of file phrase_distributor.c.
void add_parameter_variable_to_module | ( | reference | ref, |
entity | module, | ||
statement | stat, | ||
string | new_module_name, | ||
int | param_nb | ||
) |
Declare in the newly created module a new variable (which will be a parameter of the module), and replace all occurences to the old variable by the new created.
Assert that entity represent a value code
Get the variable name
trdup("")
ref | ef |
module | odule |
stat | tat |
new_module_name | Statement of the new module |
param_nb | aram_nb |
Definition at line 633 of file phrase_distributor.c.
References code_declarations, CONS, create_parameter_variable_for_new_module(), ENTITY, entity_initial, entity_local_name(), entity_module_p(), entity_type, functional_parameters, get_externalized_function_param_name(), make_dummy_identifier(), make_mode_reference(), make_parameter(), module, module_declarations(), new_variable, PARAMETER, pips_assert, pips_debug, ref, reference_variable, replace_reference(), type_functional, value_code, and variable_name().
Referenced by create_module_with_statement().
void add_private_variable_to_module | ( | reference | ref, |
entity | module, | ||
statement | stat, | ||
string | new_module_name | ||
) |
Declare in the newly created module a new variable (which will be a private to the module), and replace all occurences to the old variable by the new created.
Assert that entity represent a value code
Get the variable name
Creates the variable
ref | ef |
module | odule |
stat | tat |
new_module_name | Statement of the new module |
Definition at line 683 of file phrase_distributor.c.
References code_declarations, CONS, create_private_variable_for_new_module(), ENTITY, entity_initial, entity_local_name(), entity_module_p(), get_externalized_function_private_param_name(), module, module_declarations(), new_variable, pips_assert, pips_debug, ref, reference_variable, replace_reference(), value_code, and variable_name().
Referenced by create_module_with_statement().
|
static |
Dynamically build a new module with specified statement.
After creation, return it.
Deal with private variables
Definition at line 720 of file phrase_distributor.c.
References add_new_module_from_text(), add_parameter_variable_to_module(), add_private_variable_to_module(), compilation_unit_of_module(), FOREACH, fortran_module_p(), free_text(), gen_length(), get_current_module_entity(), get_current_module_name(), ifdebug, make_empty_subroutine(), make_language_unknown(), pips_debug, print_statement(), ref, REFERENCE, references_for_regions(), and text_named_module().
Referenced by distribute_code().
|
static |
Creates a variable declared as a parameter in specified module.
This entity does not exist, we can safely create it
Definition at line 551 of file phrase_distributor.c.
References a_variable, concatenate(), copy_type(), copy_value(), entity_domain, entity_initial, entity_type, entity_undefined, gen_find_tabulated(), make_entity, make_formal(), make_storage_formal(), module, MODULE_SEP_STRING, new_variable, pips_internal_error, and strdup().
Referenced by add_parameter_variable_to_module().
entity create_private_variable_for_new_module | ( | entity | a_variable, |
const char * | new_name, | ||
const char * | new_module_name, | ||
entity | module | ||
) |
Creates a private variable in specified module.
This entity does not exist, we can safely create it
a_variable | _variable |
new_name | ew_name |
new_module_name | ew_module_name |
module | odule |
Definition at line 586 of file phrase_distributor.c.
References a_variable, add_variable_to_area(), base, basic_tag, concatenate(), copy_type(), copy_value(), DYNAMIC_AREA_LOCAL_NAME, entity_domain, entity_global_name(), entity_initial, entity_storage, entity_type, entity_undefined, FindEntity(), gen_find_tabulated(), is_basic_overloaded, is_storage_ram, make_entity, make_ram(), make_storage(), module, MODULE_SEP_STRING, new_variable, NIL, pips_debug, pips_internal_error, storage_undefined, strdup(), type_variable, and variable_basic.
Referenced by add_private_variable_to_module().
|
static |
Main function for PHRASE_DISTRIBUTION: phrase distribution for main module module, with root statement stat.
Definition at line 478 of file phrase_distributor.c.
References compute_distribution_context(), distribute_code(), hash_get(), HASH_MAP, hash_table_free(), identify_analyzed_statements_to_distribute(), and module.
Referenced by phrase_distributor().
|
static |
This function is called after identification and isolation of a portion of code to externalize.
Externalization of specified code is done here.
Definition at line 398 of file phrase_distributor.c.
References asprintf, concatenate(), CONS, create_module_with_statement(), entity_empty_label(), entity_to_expression(), EXPRESSION, EXTERNALIZED_CODE_PRAGMA_CALL, gen_consistent_p(), ifdebug, is_instruction_call, make_call(), make_instruction(), make_statement(), make_synchronization_none(), MAP, NIL, pips_assert, pips_debug, print_statement(), ref, REFERENCE, reference_variable, references_for_regions(), replace_in_sequence_statement_with(), statement_consistent_p(), statement_extensions, statement_number, and statement_ordering.
Referenced by distribute().
Definition at line 526 of file phrase_distributor.c.
References asprintf, buffer, entity_local_name(), and EXTERNALIZED_FUNCTION_PARAM_NAME.
Referenced by add_parameter_variable_to_module().
Definition at line 539 of file phrase_distributor.c.
References asprintf, buffer, entity_local_name(), and EXTERNALIZED_FUNCTION_PRIVATE_PARAM_NAME.
Referenced by add_private_variable_to_module().
Return the identified function name of the externalized portion of code by searching comment matching tag.
stat | tat |
tag | ag |
Definition at line 82 of file phrase_distributor.c.
References gen_nth(), ifdebug, instruction_sequence, instruction_tag, is_instruction_sequence, malloc(), pips_debug, print_statement(), sequence_statements, STATEMENT, statement_comments, statement_instruction, statement_with_empty_comment_p(), and strdup().
Referenced by get_externalizable_function_name(), and get_externalized_function_name().
This function return a list of statements that were previously marked for externalization during phase PHRASE_DISTRIBUTOR_INIT.
We identify all the statement containing an analyzed tag
stat | tat |
Definition at line 288 of file phrase_distributor.c.
References EXTERNALIZED_CODE_PRAGMA_ANALYZED, and get_statements_with_comments_containing().
Referenced by comEngine_distribute(), and distribute().
This function return a list of statements that are marked for externalization.
A well-formed externalizable code must be one or more continuous statements defined in a sequence statement framed with comments containing tags EXTERNALIZED_CODE_PRAGMA_BEGIN and EXTERNALIZED_CODE_PRAGMA_END
We identify all the statement containing a begin tag
We restructure the code to avoid imbricated sequences only if some portions are found (to allow more than one INIT)
We identify again (after code restructuration) all the statement containing a begin tag
We check that all those statements are contained in a sequence
Definition at line 304 of file phrase_distributor.c.
References asprintf, CONS, EXTERNALIZED_CODE_PRAGMA_BEGIN, EXTERNALIZED_CODE_PRAGMA_END, FOREACH, gen_length(), gen_nth(), get_externalizable_function_name(), get_statements_with_comments_containing(), ifdebug, isolate_code_portion(), MAP, NIL, pips_debug, pips_user_warning, print_statement(), sequence_statement_containing(), simple_restructure_statement(), STATEMENT, and statement_is_contained_in_a_sequence_p().
Referenced by prepare_distribute().
|
static |
At this point, we have a sequence statement sequence_statement which contains a statement with a begin tag and a statement with a end tag.
The goal is to transform this statement in a sequence statement with a single statement, which is the embedded statement that will be distributed. This function returns this isolated statement
First, count the number of statements to isolate in a single statement
Insert an analyzed tag
Build new isolated sequence statement
Build new sequence containing isolated sequence statement
Rebuild the sequence in the GOOD order
Nothing to do, the code is already isolated !
Definition at line 161 of file phrase_distributor.c.
References asprintf, concatenate(), CONS, empty_comments, entity_empty_label(), EXTERNALIZED_CODE_PRAGMA_ANALYZED, gen_nreverse(), get_externalizable_function_name(), ifdebug, insert_comments_to_statement(), instruction_sequence, instruction_tag, is_instruction_sequence, make_instruction(), make_sequence(), make_statement(), make_synchronization_none(), MAP, NIL, pips_assert, pips_debug, pips_user_warning, print_statement(), remove_begin_tag(), remove_end_tag(), sequence_statements, STATEMENT, statement_extensions, statement_instruction, statement_number, and statement_ordering.
Referenced by identify_statements_to_distribute().
bool phrase_distributor | ( | const char * | module_name | ) |
set and get the current properties concerning regions
get the resources
sets dynamic_area
Get the READ, WRITE, IN and OUT regions of the module
Now do the job
Reorder the module, because new statements have been added
update/release resources
module_name | odule_name |
Definition at line 816 of file phrase_distributor.c.
References compute_callees(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, distribute(), dynamic_area, DYNAMIC_AREA_LOCAL_NAME, entity_undefined, entity_undefined_p, FindOrCreateEntity(), free_value_mappings(), gen_consistent_p(), get_regions_properties(), module, module_local_name(), module_name(), module_name_to_entity(), module_reorder(), module_to_value_mappings(), pips_assert, pips_debug, reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), reset_in_effects(), reset_out_effects(), reset_proper_rw_effects(), reset_rw_effects(), set_bool_property(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_in_effects(), set_out_effects(), set_proper_rw_effects(), set_rw_effects(), and statement_consistent_p().
bool phrase_distributor_init | ( | const char * | module_name | ) |
get the resources
Now do the job
Reorder the module, because new statements have been added
update/release resources
module_name | odule_name |
Definition at line 768 of file phrase_distributor.c.
References compute_callees(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, gen_consistent_p(), module_name(), module_name_to_entity(), module_reorder(), pips_assert, pips_debug, prepare_distribute(), reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), and statement_consistent_p().
|
static |
Main function for PHRASE_DISTRIBUTION_INIT: phrase distribution for module module_stat.
Definition at line 518 of file phrase_distributor.c.
References identify_statements_to_distribute().
Referenced by phrase_distributor_init().
Remove begin tag for statement stat and function function_name.
Definition at line 127 of file phrase_distributor.c.
References asprintf, clean_statement_from_tags(), EXTERNALIZED_CODE_PRAGMA_BEGIN, ifdebug, pips_debug, and print_statement().
Referenced by isolate_code_portion().
Remove end tag for statement stat and function function_name.
Definition at line 141 of file phrase_distributor.c.
References asprintf, clean_statement_from_tags(), EXTERNALIZED_CODE_PRAGMA_END, ifdebug, pips_debug, and print_statement().
Referenced by isolate_code_portion().
|
static |
Definition at line 814 of file phrase_distributor.c.
Referenced by GenericAddLocalEntityToDeclarations(), make_new_entity(), make_nlc_entity(), make_nsp_entity(), make_nub_entity(), phrase_comEngine_distributor(), phrase_distributor(), replace_indices_region(), and replace_indices_region_com().