27 #ifdef BUILDER_ARRAY_RESIZING_BOTTOM_UP
30 #include "pips_config.h"
70 static FILE * instrument_file;
72 #define PREFIX "$ARRAY_DECLARATION"
88 variable_is_param_common_p(
entity e)
114 for (pv = p_var; !
VECTEUR_NUL_P(pv) && divisible; pv=pv->succ) {
162 result = extract_constraint_on_var(p_var,var,v_phi,&ptmp);
183 pips_debug(8,
"The variable %s is a parameter and its value is %lld\n",
194 v_p_tmp->
succ = v_tmp;
207 else v_p_tmp->
succ = v_tmp;
243 Psysteme volatile ps_egal = SC_UNDEFINED;
244 Psysteme volatile ps_inf = SC_UNDEFINED;
245 Psysteme volatile ps_sup = SC_UNDEFINED;
251 Pvecteur p1, p2, p_egal, p_inf, p_sup,pvt,pv_1;
252 bool egal =
false, inf =
false, sup =
false;
283 p1 = vect_partial_eval(pv1);
284 p2 = vect_partial_eval(pv2);
328 egal = !SC_UNDEFINED_P(ps_egal) &&
330 inf = !SC_UNDEFINED_P(ps_inf) &&
332 sup = !SC_UNDEFINED_P(ps_sup) &&
339 if ( (egal && inf && !sup) || (egal && !inf && !sup) || (!egal && inf && !sup) ) {
343 if ( (egal && !inf && sup) || (egal && !inf && !sup) || (!egal && !inf && sup) ) {
353 if ( (egal && inf && !sup) || (egal && !inf && !sup) || (!egal && inf && !sup) ) {
357 if ( (egal && !inf && sup) || (egal && !inf && !sup) || (!egal && !inf && sup) ) {
394 (void)extract_constraint_on_var(p_var,var,v_phi,&ptmp);
397 p_max = sc_minmax_of_pvector(ps_prec, p_max, ptmp,
false);
399 p_min = sc_minmax_of_pvector(ps_prec, p_min, ptmp,
true);
430 if (variable_to_project_p(var, v)) {
431 if (SC_EMPTY_P(ps = sc_projection_pure(ps, v)))
438 if (SC_UNDEFINED_P(ps) || ( sc_nbre_inegalites(ps)==0 && sc_nbre_egalites(ps)==0))
444 (void)extract_constraint_from_equalitites(ps_e, var, &pe);
445 ok2 = extract_constraint_from_inequalities(ps_i, var, ps_prec, &pe,
min,
max);
448 pips_debug(8,
"The upper bound has been found\n");
450 pips_debug(8,
"The upper bound has not been found\n");
519 while (!
ENDP(l_regions))
533 l_regions =
CDR(l_regions);
559 string instrument_file_name =
strdup(
concatenate(dir_name,
"/BU_instrument.out", NULL));
562 instrument_file =
safe_fopen(instrument_file_name,
"a");
564 "/",base_name,NULL));
571 debug_on(
"ARRAY_RESIZING_BOTTOM_UP_DEBUG_LEVEL");
572 debug(1,
" Begin bottom up array resizing for %s\n", mod_name);
605 region reg = find_union_store_regions(l_regions,e);
606 new_array_declaration_from_region(reg,e,pre);
614 region reg = find_union_store_regions(l_regions,e);
615 new_array_declaration_from_region(reg,e,pre);
626 user_log(
"This option has not been implemented yet\n");
630 region reg = find_union_store_regions(l_regions,e);
631 new_array_declaration_from_region(reg,e,pre);
636 region reg = find_union_store_regions(l_regions,e);
637 new_array_declaration_from_region(reg,e,pre);
652 user_log(
"This option has not been implemented yet\n");
655 user_log(
"* Number of right array declarations replaced: %d *\n"
658 debug(1,
"End bottom up array resizing for %s\n", mod_name);
667 free(dir_name), dir_name = NULL;
668 free(instrument_file_name), instrument_file_name = NULL;
688 for (pv = p_var; !
VECTEUR_NUL_P(pv) && divisible; pv=pv->succ) {
730 result = extract_constraint_on_var_C(p_var,var,v_phi,&ptmp);
745 Psysteme volatile ps_egal = SC_UNDEFINED;
746 Psysteme volatile ps_inf = SC_UNDEFINED;
747 Psysteme volatile ps_sup = SC_UNDEFINED;
753 Pvecteur p1, p2, p_egal, p_inf, p_sup,pvt,pv_1;
754 bool egal =
false, inf =
false, sup =
false;
787 p1 = vect_partial_eval(pv1);
788 p2 = vect_partial_eval(pv2);
835 egal = !SC_UNDEFINED_P(ps_egal) &&
837 inf = !SC_UNDEFINED_P(ps_inf) &&
839 sup = !SC_UNDEFINED_P(ps_sup) &&
846 if ( (egal && inf && !sup) || (egal && !inf && !sup) || (!egal && inf && !sup) ) {
851 if ( (egal && !inf && sup) || (egal && !inf && !sup) || (!egal && !inf && sup) ) {
864 if ( (egal && inf && !sup) || (egal && !inf && !sup) || (!egal && inf && !sup) ) {
869 if ( (egal && !inf && sup) || (egal && !inf && !sup) || (!egal && !inf && sup) ) {
925 extract_ok = extract_constraint_on_var_C(p_var,var,v_phi,&ptmp);
930 p_max = sc_minmax_of_pvector_C(ps_prec, p_max, ptmp,
false);
938 p_min = sc_minmax_of_pvector_C(ps_prec, p_min, ptmp,
true);
1015 if (variable_to_project_p(var, v)) {
1016 if (SC_EMPTY_P(ps = sc_projection_pure(ps, v)))
1023 if (SC_UNDEFINED_P(ps) || ( sc_nbre_inegalites(ps)==0 && sc_nbre_egalites(ps)==0))
1034 ok_eg = extract_constraint_from_equalitites_C(ps_e, var, &pe);
1035 ok2 = extract_constraint_from_inequalities_C(ps_i, var, ps_prec, ok_eg, &pe,
min,
max);
1038 pips_debug(8,
"New bounds have been found\n");
1040 pips_debug(8,
"New bound have not been found\n");
1054 struct context_resizing
1064 static struct context_resizing * make_context_resizing (
entity e)
1066 struct context_resizing * result = NULL;
1067 result = (
struct context_resizing *)
alloc(
sizeof(
struct context_resizing));
1068 if (result == NULL) {
1072 result->l_shift =
NIL;
1073 result->need_shift_p =
false;
1077 static void free_context_resizing(
struct context_resizing * str)
1082 static list init_list_of_array_to_compute(
list l_decl)
1085 struct context_resizing * to_add = NULL;
1086 bool compute_assumed_only =
get_bool_property(
"ARRAY_RESIZING_ASSUMED_SIZE_ONLY");
1092 if (compute_argument) {
1094 pips_user_warning(
"It can impact the caller function with the modification of the structure\n");
1096 if (compute_assumed_only) {
1101 to_add = make_context_resizing(e);
1102 result =
gen_cons((
const struct context_resizing *) to_add, result);
1108 to_add = make_context_resizing(e);
1109 result =
gen_cons((
const struct context_resizing *) to_add, result);
1115 if (compute_assumed_only) {
1120 to_add = make_context_resizing(e);
1121 result =
gen_cons((
const struct context_resizing *) to_add, result);
1127 to_add = make_context_resizing(e);
1128 result =
gen_cons((
const struct context_resizing *) to_add, result);
1140 static void free_list_of_array_to_compute(
list * l_ctx) {
1141 list l_temp = *l_ctx;
1142 for(
struct context_resizing * elem; !
ENDP(l_temp) && (elem= ((
struct context_resizing *) (
CAR(l_temp).p)));
POP(l_temp)) {
1143 free_context_resizing(elem);
1147 static bool modify_array_declaration(
statement st,
list *ctx) {
1159 bool c_array_notation =
false;
1176 for(
struct context_resizing *compute_array; !
ENDP(l_temp) && (compute_array= ((
struct context_resizing *) (
CAR(l_temp).p)));
POP(l_temp)) {
1219 if (sc_min_max_of_variable_C(ps, (
Variable) phi, pre, &
min, &
max)) {
1228 pips_user_warning(
"don't success to compute new upper bound for dimension index %d\n", i);
1241 "No implementation for complex expression yet."
1242 "Done nothing for dimension index %d\n", i);
1250 pips_user_warning(
"don't success to compute new lower bound for dimension index %d\n", i);
1273 else if (!c_array_notation) {
1275 compute_array->l_shift =
CONS(
EXPRESSION, lower, compute_array->l_shift);
1276 compute_array->need_shift_p =
true;
1278 pips_debug(2,
"%s access need to be shift with -%s for dimension %d\n",
1283 "Warning :it's different from Fortran array notation.\n"
1284 "In C : a[start:nbr_element] \n");
1303 pips_debug(2,
"new upper bound: upper=%s, diff=%s\n",
1329 if (compute_array->need_shift_p) {
1330 compute_array->l_shift =
gen_nreverse(compute_array->l_shift);
1376 for(
struct context_resizing *compute_array; !
ENDP(l_temp) && (compute_array= ((
struct context_resizing *) (
CAR(l_temp).p)));
POP(l_temp)) {
1379 if (compute_array->need_shift_p) {
1380 list l_shift = compute_array->l_shift;
1383 int current_index = 1;
1411 l_indices =
CDR(l_indices);
1416 pips_debug(5,
"new reference of array access shifted:\n");
1434 bool good_result_p =
true;
1436 debug_on(
"ARRAY_RESIZING_BOTTOM_UP_DEBUG_LEVEL");
1460 list l_var = init_list_of_array_to_compute(l_decl);
1482 free_list_of_array_to_compute(&l_var);
1498 return (good_result_p);
int get_int_property(const string)
void user_log(const char *format,...)
bool statement_consistent_p(statement p)
void free_expression(expression p)
void free_syntax(syntax p)
struct _newgen_struct_entity_ * entity
static reference ref
Current stmt (an integer)
static statement module_statement
static entity current_mod
#define int_to_value(i)
end LINEAR_VALUE_IS_INT
#define value_uminus(val)
unary operators on values
#define value_direct_multiply(v1, v2)
#define value_zero_p(val)
#define value_plus(v1, v2)
binary operators on values
#define value_mod(v1, v2)
#define value_div(v1, v2)
#define PREFIX
This phase checks for out of bound error when passing arrays or array elements as arguments in proced...
char * alloc(int size)
ALLOC is an "iron-clad" version of malloc(3).
bool vecteur_nul_p(Pvecteur v)
#define CONTRAINTE_UNDEFINED_P(c)
#define CONTRAINTE_NULLE_P(c)
contrainte nulle (non contrainte 0 == 0 ou 0 <= 0)
#define contrainte_vecteur(c)
passage au champ vecteur d'une contrainte "a la Newgen"
#define CONTRAINTE_UNDEFINED
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
void inegalite_fprint(FILE *, Pcontrainte, char *(*)(Variable))
static bool parameter_p(entity e)
#define region_system(reg)
#define region_undefined_p(reg)
#define region
simulation of the type region
effect regions_must_convex_hull(region f1, region f2)
1- Union :
entity make_phi_entity(int)
effect region_dup(effect)
void reset_useful_variables_effects(void)
void set_rw_effects(statement_effects)
void set_useful_variables_effects(entity_effects)
effects load_useful_variables_effects(entity)
list load_rw_effects_list(statement)
void reset_rw_effects(void)
bool bound_useful_variables_effects_p(entity)
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
bool store_effect_p(effect)
#define effects_effects(x)
FILE * safe_fopen(const char *filename, const char *what)
int safe_fclose(FILE *stream, const char *filename)
char * pips_basename(char *fullpath, char *suffix)
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
static FILE * user_file
These functions implements the writing of objects.
void reset_current_module_entity(void)
Reset the current module entity.
void reset_current_module_statement(void)
Reset the current module statement.
statement set_current_module_statement(statement)
Set the current module statement.
statement get_current_module_statement(void)
Get the current module statement.
entity set_current_module_entity(entity)
static.c
entity get_current_module_entity(void)
Get the entity of the current module.
void gen_context_multi_recurse(void *o, void *context,...)
Multi-recursion with context function visitor.
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.
list gen_nreverse(list cp)
reverse a list in place
#define POP(l)
Modify a list pointer to point on the next element of the list.
#define NIL
The empty list (nil in Lisp)
size_t gen_length(const list l)
list gen_cons(const void *item, const list next)
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
#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.
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_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
bool declaration_statement_p(statement)
Had to be optimized according to Beatrice Creusillet.
language get_prettyprint_language()
please avoid using this function directly, use predicate instead (see below)
enum language_utype get_prettyprint_language_tag()
void vect_print(Pvecteur v, get_variable_name_t variable_name)
void vect_print(Pvecteur v, char * (*variable_name)()): impression d'un vecteur creux v sur stdout; l...
bool vect_equal(Pvecteur v1, Pvecteur v2)
bool vect_equal(Pvecteur v1, Pvecteur v2): test a egalite de deux vecteurs
string db_get_directory_name_for_module(const char *name)
returns the allocated and mkdir'ed directory for module name
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
#define pips_user_warning
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
#define pips_internal_error
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
string concatenate(const char *,...)
Return the concatenation of the given strings.
void free_expression_normalized(expression e)
#define WORKSPACE_SRC_SPACE
string db_get_current_workspace_directory(void)
void print_entity_variable(entity e)
print_entity_variable(e)
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 print_reference(reference r)
void print_statement(statement)
Print a statement on stderr.
bool same_entity_lname_p(entity, entity)
#define NORMALIZE_EXPRESSION(e)
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 same_entity_p(entity e1, entity e2)
predicates on entities
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 unnormalized_array_p(entity e)
expression Pvecteur_to_expression(Pvecteur vect)
AP, sep 25th 95 : some usefull functions moved from static_controlize/utils.c.
int expression_to_int(expression exp)
================================================================
expression make_unbounded_expression()
bool expression_null_p(expression exp)
returns true if the expression is equal to zero or NULL (even if there is a cast before such as in (v...
expression make_zero_expression(void)
Make a zero expression.
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
bool unbounded_expression_p(expression e)
dimension find_ith_dimension(list, int)
This function returns the ith dimension of a list of dimensions.
bool variable_in_common_p(entity)
true if v is in a common.
bool formal_parameter_p(entity)
#define type_functional_p(x)
#define value_undefined_p(x)
#define storage_formal_p(x)
#define normalized_linear_p(x)
#define reference_variable(x)
#define dimension_lower(x)
#define entity_storage(x)
#define statement_domain
newgen_sizeofexpression_domain_defined
#define code_declarations(x)
#define value_symbolic(x)
#define language_fortran95_p(x)
#define EXPRESSION(x)
EXPRESSION.
#define reference_domain
newgen_range_domain_defined
#define expression_undefined
#define value_symbolic_p(x)
#define transformer_relation(x)
#define dimension_upper(x)
#define reference_indices(x)
#define dimension_undefined
#define expression_undefined_p(x)
#define variable_dimensions(x)
#define statement_declarations(x)
#define normalized_linear(x)
#define expression_syntax(x)
#define language_fortran_p(x)
#define predicate_system(x)
#define symbolic_expression(x)
#define variable_basic(x)
#define entity_initial(x)
void sc_creer_base(Psysteme ps)
void sc_creer_base(Psysteme ps): initialisation des parametres dimension et base d'un systeme lineair...
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.
Psysteme sc_elim_redund(Psysteme ps)
Psysteme sc_elim_redund(Psysteme ps): elimination des contraintes lineaires redondantes dans le syste...
bool sc_rational_feasibility_ofl_ctrl(Psysteme sc, int ofl_ctrl, bool ofl_res)
Psysteme sc_inequality_add(Psysteme sc, Pcontrainte c)
Psysteme sc_equation_add(Psysteme sc, Pcontrainte c)
The basis of the constraint system is updated.
void sc_print(Psysteme ps, get_variable_name_t nom_var)
void sc_print()
Psysteme sc_free(Psysteme in_ps)
Psysteme sc_free( in_ps ) AL 30/05/94 Free of in_ps.
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
Psysteme sc_normalize(Psysteme ps)
Psysteme sc_normalize(Psysteme ps): normalisation d'un systeme d'equation et d'inequations lineaires ...
transformer load_statement_precondition(statement)
void reset_precondition_map(void)
void set_precondition_map(statement_mapping)
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 BASE_NULLE
MACROS SUR LES BASES.
#define OFL_CTRL
I do thing that overflows are managed in a very poor manner.
#define VECTEUR_UNDEFINED_P(v)
Pvecteur vect_dup(Pvecteur v_in)
Pvecteur vect_dup(Pvecteur v_in): duplication du vecteur v_in; allocation de et copie dans v_out;.
Pvecteur vect_new(Variable var, Value coeff)
Pvecteur vect_new(Variable var,Value coeff): allocation d'un vecteur colineaire au vecteur de base va...
void vect_rm(Pvecteur v)
void vect_rm(Pvecteur v): desallocation des couples de v;
Pvecteur vect_add(Pvecteur v1, Pvecteur v2)
package vecteur - operations binaires
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2)
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2): allocation d'un vecteur v dont la valeur est la di...
void vect_erase_var(Pvecteur *ppv, Variable v)
void vect_erase_var(Pvecteur * ppv, Variable v): projection du vecteur *ppv selon la direction v (i....
Value vect_coeff(Variable var, Pvecteur vect)
Variable vect_coeff(Variable var, Pvecteur vect): coefficient de coordonnee var du vecteur vect —> So...
void vect_chg_coeff(Pvecteur *ppv, Variable var, Value val)
void vect_chg_coeff(Pvecteur *ppv, Variable var, Value val): mise de la coordonnee var du vecteur *pp...