27 #ifdef BUILDER_ARRAY_RESIZING_TOP_DOWN
30 #include "pips_config.h"
124 #define PREFIX1 "$ARRAY_DECLARATION"
125 #define PREFIX2 "$COMMON_DECLARATION"
126 #define PREFIX3 "$COMMON_DECLARATION_END"
127 #define NEW_DECLARATIONS ".new_declarations"
133 static list l_values_of_current_caller =
NIL;
138 static FILE * instrument_file;
139 static int number_of_unnormalized_arrays_without_caller = 0;
140 static int number_of_replaced_array_declarations = 0;
141 static int number_of_instrumented_array_declarations = 0;
142 static int number_of_array_size_assignments = 0;
144 static string file_name_caller= NULL;
148 static void display_array_resizing_top_down_statistics()
150 user_log(
"* Number of unnormalized arrays without caller: %d *\n",
151 number_of_unnormalized_arrays_without_caller);
152 user_log(
"* Number of right array declarations replaced: %d*\n",
153 number_of_replaced_array_declarations);
154 user_log(
"* Number of array declarations instrumented: %d *\n",
155 number_of_instrumented_array_declarations);
156 user_log(
"* Number of assignments added: %d *\n",
157 number_of_array_size_assignments);
158 user_log(
"\n Number of processed modules: %d \n"
162 static bool scalar_argument_p(
entity e)
269 bool in_callee =
false;
292 fprintf(stderr,
"\n Syntax reference: Common variable, add to list: \n");
315 " COMMON /",pips_common_name,
"/ ",pips_variable_name,
"\n",NULL));
322 fprintf(instrument_file,
"%s", new_decl);
323 fprintf(instrument_file,
"%s\n",PREFIX3);
325 free(new_decl), new_decl = NULL;
364 fprintf(stderr,
"\n Syntax reference : using precondition + association \n");
376 ps = sc_system_projection_along_variables(ps, pv_var);
378 if (ps != SC_UNDEFINED)
382 for (egal = ps->
egalites; egal != NULL; egal = egal1)
400 for (v = newv; (v !=NULL) && (check); v = v->
succ)
411 fprintf(stderr,
"\n Add new expression/reference to list by using prec+ asso : \n");
483 fprintf(stderr,
"\n Add numerical constant to list: \n");
495 ps = sc_system_projection_along_variables(ps, pv_var);
497 if (ps != SC_UNDEFINED)
504 fprintf(stderr,
"\n Call : using Precondition + Association to find formal parameter equal to %d \n", i);
507 for (egal = ps->
egalites; egal != NULL; egal = egal1)
511 for (v = vec; v !=NULL; v = v->
succ)
525 fprintf(stderr,
"\n Add new expression/constant to list by prec+asso: \n");
550 l1 = my_list_change(l1,fun);
559 list l3 = my_list_combination(l1,l2,fun);
603 fprintf(stderr,
"\n Syntax reference \n");
606 return translate_reference_to_callee_frame(e,
ref,
context);
613 fprintf(stderr,
"\n Syntax call \n");
616 return translate_call_to_callee_frame(ca,
context);
632 static expression size_of_unnormalized_dummy_array(
entity dummy_array,
int i)
638 for (j=i+1; j<= num_dim-1; j++)
659 fprintf(stderr,
"\n Size of unnormalized dummy array: \n");
667 static bool top_down_adn_call_flt(
call c)
680 list l_values_of_current_call_site =
NIL;
684 fprintf(stderr,
" \n Current statement : \n");
692 fprintf(stderr,
" \n The precondition before \n");
699 fprintf(stderr,
" \n The precondition after \n");
717 fprintf(stderr, "\n Number of same dimensions : %d \n",same_dim);
725 l_values_of_current_caller =
NIL;
732 if (scalar_argument_p(actual_array))
763 l_values_of_current_caller =
NIL;
770 fprintf(stderr,
"\n Size of actual array before translation : \n");
773 l_values_of_current_call_site = translate_to_callee_frame(actual_array_size,
context);
776 fprintf(stderr,
"\n Size of actual array after translation (list of possible values) : \n");
779 if (l_values_of_current_call_site !=
NIL)
782 expression dummy_array_size = size_of_unnormalized_dummy_array(current_dummy_array,same_dim);
787 l_values_of_current_call_site = my_list_division(l_values_of_current_call_site,
797 if (i_dummy == i_actual)
800 l_values_of_current_call_site = my_list_division(l_values_of_current_call_site,
805 l_values_of_current_call_site = my_list_multiplication(l_values_of_current_call_site,
808 l_values_of_current_call_site = my_list_division(l_values_of_current_call_site,
814 l_values_of_current_call_site = my_list_division(l_values_of_current_call_site,
819 l_values_of_current_caller = my_list_intersection(l_values_of_current_caller,
820 l_values_of_current_call_site);
823 fprintf(stderr,
"\n List of values of the current caller (after intersection): \n");
826 if (l_values_of_current_caller ==
NIL)
837 l_values_of_current_caller =
NIL;
844 static void instrument_call_rwt(
call c)
874 if (scalar_argument_p(actual_array))
909 if (i_dummy != i_actual)
920 fprintf(stderr,
"\n Size of actual array: \n");
930 fprintf(stderr,
"\n New statements: \n");
934 fprintf(instrument_file,
"%s\t%s\t%s\t(%d,%d)\n",
PREFIX2,file_name_caller,
937 fprintf(instrument_file,
"%s\n",PREFIX3);
938 number_of_array_size_assignments++;
949 static list top_down_adn_caller_array()
953 l_values_of_current_caller =
NIL;
954 make_current_statement_stack();
962 free_current_statement_stack();
965 fprintf(stderr,
"\n List of values of the current caller is :\n ");
968 return l_values_of_current_caller;
971 static void instrument_caller_array()
975 make_current_statement_stack();
982 free_current_statement_stack();
986 static void top_down_adn_callers_arrays(
list l_arrays,
list l_callers)
1002 while (!
ENDP(l_arrays))
1010 current_dummy_array =
ENTITY(
CAR(l_arrays));
1015 while (flag && !
ENDP(l))
1025 list l_values_of_one_caller = top_down_adn_caller_array();
1031 if (l_values_of_one_caller ==
NIL)
1037 fprintf(stderr,
"\n List of values (before intersection):\n ");
1040 l_values = my_list_intersection(l_values,l_values_of_one_caller);
1043 fprintf(stderr,
"\n List of values (after intersection):\n ");
1046 if (l_values ==
NIL)
1053 if (flag && (l_values!=
NIL))
1086 number_of_replaced_array_declarations++;
1108 " COMMON /",pips_common_name,
"/ ",pips_variable_name,
"\n",NULL));
1110 expression dummy_array_size = size_of_unnormalized_dummy_array(current_dummy_array,0);
1128 fprintf(instrument_file,
"%s", new_decl);
1129 fprintf(instrument_file,
"%s\n",PREFIX3);
1144 string base_name_caller =
pips_basename(user_file_caller, NULL);
1146 "/",base_name_caller,NULL));
1150 fprintf(instrument_file,
"%s", new_decl);
1151 fprintf(instrument_file,
"%s\n",PREFIX3);
1154 instrument_caller_array();
1156 free(file_name_caller), file_name_caller = NULL;
1161 number_of_instrumented_array_declarations++;
1162 free(new_decl), new_decl = NULL;
1169 l_arrays =
CDR(l_arrays);
1218 FILE * declaration_file;
1222 string declaration_file_name =
strdup(
concatenate(dir_name,
"/", new_declarations, NULL));
1223 string instrument_file_name =
strdup(
concatenate(dir_name,
"/TD_instrument.out", NULL));
1224 instrument_file =
safe_fopen(instrument_file_name,
"a");
1228 debug_on(
"ARRAY_RESIZING_TOP_DOWN_DEBUG_LEVEL");
1233 list l_callee_decl =
NIL, l_formal_unnorm_arrays =
NIL;
1278 user_log(
"\n This option has not been implemented yet");
1282 if (l_formal_unnorm_arrays !=
NIL)
1288 number_of_unnormalized_arrays_without_caller +=
1297 if (l_callers ==
NIL)
1300 number_of_unnormalized_arrays_without_caller +=
1305 fprintf(stderr,
" \n The formal unnormalized array list :");
1307 fprintf(stderr,
" \n The caller list : ");
1313 top_down_adn_callers_arrays(l_formal_unnorm_arrays,l_callers);
1318 display_array_resizing_top_down_statistics();
1319 declaration_file =
safe_fopen(declaration_file_name,
"w");
1320 fprintf(declaration_file,
"/* Top down array resizing for module %s. */\n",
module_name);
1321 safe_fclose(declaration_file, declaration_file_name);
1322 safe_fclose(instrument_file, instrument_file_name);
1323 free(dir_name), dir_name = NULL;
1324 free(declaration_file_name), declaration_file_name = NULL;
1325 free(instrument_file_name), instrument_file_name = NULL;
int get_int_property(const string)
void user_log(const char *format,...)
expression copy_expression(expression p)
EXPRESSION.
reference make_reference(entity a1, list a2)
static reference ref
Current stmt (an integer)
#define PREFIX1
TO AMELIORATE : for the moment, we only use trivial_expression_p to compare offsets + array sizes CAN...
static entity current_caller
static int number_of_processed_modules
static const char * caller_name
#define value_mone_p(val)
#define int_to_value(i)
end LINEAR_VALUE_IS_INT
#define value_eq(v1, v2)
bool operators on values
bool base_contains_variable_p(Pbase b, Variable v)
bool base_contains_variable_p(Pbase b, Variable v): returns true if variable v is one of b's elements...
transformer transformer_dup(transformer t_in)
transformer package - basic routines
transformer transformer_identity()
Allocate an identity transformer.
bool module_is_called_by_main_program_p(entity mod)
struct _newgen_struct_statement_ * statement
Pcontrainte contraintes_free(Pcontrainte pc)
Pcontrainte contraintes_free(Pcontrainte pc): desallocation de toutes les contraintes de la liste pc.
static entity current_callee
const char * module_name(const char *s)
Return the module part of an entity name.
FILE * safe_fopen(const char *filename, const char *what)
int safe_fclose(FILE *stream, const char *filename)
char * pips_basename(char *fullpath, char *suffix)
static FILE * user_file
These functions implements the writing of objects.
void reset_current_module_entity(void)
Reset the current module entity.
entity set_current_module_entity(entity)
static.c
void gen_multi_recurse(void *o,...)
Multi recursion visitor function.
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
#define ENDP(l)
Test if a list is empty.
#define NIL
The empty list (nil in Lisp)
list gen_copy_seq(list l)
Copy a list structure.
size_t gen_length(const list l)
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
#define CAR(pcons)
Get the value of the first element of a list.
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
#define CDR(pcons)
Get the list less its first element.
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
#define DB_PUT_FILE_RESOURCE
Put a file resource into the current workspace database.
statement make_assign_statement(expression, expression)
bool expression_constant_p(expression)
HPFC module by Fabien COELHO.
string db_build_file_resource_name(const char *rname, const char *oname, const char *suffix)
returns an allocated file name for a file resource.
string db_get_directory_name_for_module(const char *name)
returns the allocated and mkdir'ed directory for module name
#define pips_user_warning
#define pips_internal_error
string concatenate(const char *,...)
Return the concatenation of the given strings.
#define DEFINE_LOCAL_STACK(name, type)
#define WORKSPACE_SRC_SPACE
string db_get_current_workspace_directory(void)
void print_expressions(list le)
void print_expression(expression e)
no file descriptor is passed to make is easier to use in a debugging stage.
string expression_to_string(expression e)
void fprint_statement(FILE *, statement)
Print statement "s" on file descriptor "fd".
void print_statement(statement)
Print a statement on stderr.
#define MINUS_OPERATOR_NAME
#define PLUS_OPERATOR_NAME
#define ORDERING_NUMBER(o)
#define ORDERING_STATEMENT(o)
#define NORMALIZE_EXPRESSION(e)
#define binary_intrinsic_expression(name, e1, e2)
#define DIVIDE_OPERATOR_NAME
#define MULTIPLY_OPERATOR_NAME
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
bool assumed_size_array_p(entity e)
bool array_entity_p(entity e)
code entity_code(entity e)
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
bool entity_main_module_p(entity e)
bool unnormalized_array_p(entity e)
entity make_new_common(string name, entity mod)
This function creates a common for a given name in a given module.
const char * module_local_name(entity e)
Returns the module local user name.
void print_entities(list l)
entity make_new_integer_scalar_common_variable(string name, entity mod, entity com)
This function creates a common variable in a given common in a given module.
const char * entity_module_name(entity e)
See comments about module_name().
expression reference_to_expression(reference r)
expression Pvecteur_to_expression(Pvecteur vect)
AP, sep 25th 95 : some usefull functions moved from static_controlize/utils.c.
void clean_all_normalized(expression e)
bool same_expression_in_list_p(expression e, list le)
This function returns true, if there exists a same expression in the list false, otherwise.
int expression_to_int(expression exp)
================================================================
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
expression size_of_actual_array(entity actual_array, list l_actual_ref, int i)
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
expression find_ith_argument(list args, int n)
bool array_argument_p(expression e)
list make_list_of_constant(int val, int number)
of expression
expression MakeUnaryCall(entity f, expression a)
Creates a call expression to a function with one argument.
reference expression_reference(expression e)
Short cut, meaningful only if expression_reference_p(e) holds.
entity expression_to_entity(expression e)
just returns the entity of an expression, or entity_undefined
bool operator_expression_p(expression e, string op_name)
dimension find_ith_dimension(list, int)
This function returns the ith dimension of a list of dimensions.
bool variable_is_a_module_formal_parameter_p(entity, entity)
bool variable_in_common_p(entity)
true if v is in a common.
bool same_scalar_location_p(entity, entity)
FI: transferred from semantics (should be used for effect translation as well)
bool formal_parameter_p(entity)
_int SizeOfElements(basic)
This function returns the length in bytes of the Fortran or C type represented by a basic,...
struct _newgen_struct_callees_ * callees
#define value_constant(x)
#define syntax_reference(x)
#define normalized_linear_p(x)
#define callees_callees(x)
#define reference_variable(x)
#define symbolic_constant(x)
#define statement_ordering(x)
#define dimension_lower(x)
#define entity_storage(x)
#define statement_domain
newgen_sizeofexpression_domain_defined
#define code_declarations(x)
#define value_constant_p(x)
#define call_domain
newgen_callees_domain_defined
#define storage_formal(x)
#define value_symbolic(x)
#define EXPRESSION(x)
EXPRESSION.
#define constant_int_p(x)
#define expression_undefined
#define value_symbolic_p(x)
#define transformer_relation(x)
#define dimension_upper(x)
#define reference_indices(x)
#define constant_call_p(x)
#define constant_undefined_p(x)
#define expression_undefined_p(x)
#define variable_dimensions(x)
#define call_arguments(x)
#define normalized_linear(x)
#define expression_syntax(x)
#define predicate_system(x)
#define constant_undefined
#define variable_basic(x)
#define entity_initial(x)
void sc_rm(Psysteme ps)
void sc_rm(Psysteme ps): liberation de l'espace memoire occupe par le systeme de contraintes ps;
Psysteme sc_dup(Psysteme ps)
Psysteme sc_dup(Psysteme ps): should becomes a link.
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
void vect_chg_sgn(Pvecteur v)
void vect_chg_sgn(Pvecteur v): multiplie v par -1
bool statement_weakly_feasible_p(statement)
utils.c
transformer load_statement_precondition(statement)
void reset_precondition_map(void)
void set_precondition_map(statement_mapping)
static statement current_statement
struct Scontrainte * succ
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
The structure used to build lists in NewGen.
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.
#define VECTEUR_UNDEFINED
char *(* get_variable_name_t)(Variable)
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
#define VECTEUR_UNDEFINED_P(v)
void vect_rm(Pvecteur v)
void vect_rm(Pvecteur v): desallocation des couples de v;
void vect_add_elem(Pvecteur *pvect, Variable var, Value val)
void vect_add_elem(Pvecteur * pvect, Variable var, Value val): addition d'un vecteur colineaire au ve...
Pvecteur vect_del_var(Pvecteur v_in, Variable var)
Pvecteur vect_del_var(Pvecteur v_in, Variable var): allocation d'un nouveau vecteur egal a la project...
Value vect_coeff(Variable var, Pvecteur vect)
Variable vect_coeff(Variable var, Pvecteur vect): coefficient de coordonnee var du vecteur vect —> So...
bool vect_contains_variable_p(Pvecteur v, Variable var)
bool vect_contains_variable_p(Pvecteur v, Variable var) BA 19/05/94 input : a vector and a variable o...