25 #include "pips_config.h"
38 #include "resources.h"
64 bool strict_p =
false;
110 pips_debug(5,
"Loop counter is probably %s\n",
111 *is_upper_p ?
"increasing" :
"decreasing");
115 pips_debug(5,
"End: no final bound available\n");
143 bool * is_increasing_p,
159 * is_increasing_p =
true;
166 * is_increasing_p =
false;
182 if ( (entity_plus_update_p||entity_minus_update_p) ) {
189 int sign = entity_plus_update_p ? 1 : -1 ;
193 * is_increasing_p = entity_plus_update_p;
194 pips_debug(5,
"Found += with positive increment!\n");
197 * is_increasing_p = entity_minus_update_p;
198 pips_debug(5,
"Found += with negative increment!\n");
211 if(entity_minus_update_p) {
218 *is_increasing_p = (entity_plus_update_p && pos_p)
219 || (entity_minus_update_p && neg_p);
235 * pincrement = inc_v;
238 * is_increasing_p =
true;
239 pips_debug(5,
"Found \"i = i + v\" or \"i = v + i\" with positive increment!\n");
242 * is_increasing_p =
false;
243 pips_debug(5,
"Found \"i = i + v\" or \"i = v + i\" with negative increment!\n");
253 * is_increasing_p =
true;
257 * is_increasing_p =
false;
273 * pincrement = inc_v;
276 * is_increasing_p =
true;
277 pips_debug(5,
"Found \"i = i - v\" or \"i = v - i\" with positive increment!\n");
280 * is_increasing_p =
false;
281 pips_debug(5,
"Found \"i = i - v\" or \"i = v - i\" with negative increment!\n");
290 * pincrement = inc_v;
292 * is_increasing_p =
false;
296 * is_increasing_p =
true;
414 bool guess_p =
false;
419 bool write_found_p =
false;
423 write_found_p =
true;
424 else if(write_found_p) {
595 else if(rhs==seed ) {
627 cond_inter_incr_entities =
set_intersection(cond_inter_incr_entities,incr_entities,cond_entities);
637 bool is_upper_p,is_increasing_p;
642 bool upper_bound_entity_written=
false;
647 upper_bound_entity_written=
true;
652 if(!upper_bound_entity_written){
666 if(increment_expression!=incr){
677 if( lower_bound!=
init) {
685 if (!is_upper_p && is_increasing_p)
687 if (is_upper_p && !is_increasing_p)
692 lr =
make_range(lower_bound, upper_bound, increment);
696 lr =
make_range(lower_bound, upper_bound, increment);
730 set_free( cond_inter_incr_entities);
751 pips_debug(3,
"do-loop has been generated.\n");
790 debug_on(
"FOR_LOOP_TO_DO_LOOP_DEBUG_LEVEL");
1012 debug_on(
"FOR_LOOP_TO_WHILE_LOOP_DEBUG_LEVEL");
instruction make_instruction_loop(loop _field_)
void free_forloop(forloop p)
loop make_loop(entity a1, range a2, statement a3, entity a4, execution a5, list a6)
instruction make_instruction_expression(expression _field_)
expression copy_expression(expression p)
EXPRESSION.
void free_extensions(extensions p)
bool statement_consistent_p(statement p)
execution make_execution_sequential(void)
statement make_statement(entity a1, intptr_t a2, intptr_t a3, string a4, instruction a5, list a6, string a7, extensions a8, synchronization a9)
instruction make_instruction_sequence(sequence _field_)
instruction make_instruction_call(call _field_)
synchronization make_synchronization_none(void)
sequence make_sequence(list a)
extensions copy_extensions(extensions p)
EXTENSIONS.
range make_range(expression a1, expression a2, expression a3)
static statement module_statement
bool clean_up_sequences(statement s)
Recursively clean up the statement sequences by fusing them if possible and by removing useless one.
struct _newgen_struct_statement_ * statement
const char * module_name(const char *s)
Return the module part of an entity name.
void transform_a_for_loop_statement_into_a_while_loop(statement st)
Same as above, but with no calls to ancestors.
static bool guess_write_effect_on_entity_stmt_walker(statement st, guesser_param *p)
classical statement walker, gen_recurse does not dive into statement declarations
bool guess_late_read_effect_on_entity(expression init, entity loop_index)
Check comma expressions used for initialization.
static bool incrementation_expression_to_increment(expression incr, entity li, bool *is_increasing_p, expression *pincrement)
bool for_loop_to_do_loop(const string module_name)
For-loop to do-loop transformation phase.
static expression guess_loop_increment_walker(expression e, entity loop_index, statement body)
guess the increment of a loop the condition is: the increment must be a reference that is constant in...
void transform_a_for_loop_into_a_while_loop(forloop f)
Try to to transform the C-like for-loops into Fortran-like do-loops.
sequence for_to_while_loop_conversion(expression init, expression cond, expression incr, statement body, extensions exts)
Build a sequence with a while-loop from for-loop parameters.
sequence for_to_do_loop_conversion(forloop theloop, statement parent)
Try to convert a C-like for-loop into a Fortran-like do-loop.
static expression guess_loop_increment(expression incr, entity loop_index, statement body)
iterate over
static bool guess_write_effect_on_entity_walker(call c, guesser_param *p)
Try hard to guess wether the call.
bool for_loop_to_while_loop(const string module_name)
For-loop to while-loop transformation phase.
static expression guess_loop_lower_bound(expression init, entity loop_index)
iterate over the comma-separeted expression
void try_to_transform_a_for_loop_into_a_do_loop(forloop f)
Try to to transform the C-like for-loops into Fortran-like do-loops.
static bool condition_expression_to_final_bound(expression cond, entity li, bool *is_upper_p, expression *pub)
Some passes to transform for-loops into do-loops or while-loops that may be easier to analyze by PIPS...
static void remove_expression_from_comma_list(expression comma_list, expression seed)
given an expression
static bool guess_write_effect_on_entity(void *exp, entity loop_index)
call guess_write_effect_on_entity_walker on each call of
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
#define gen_recurse(start, domain_number, flt, rwt)
statement instruction_to_statement(instruction)
Build a statement from a give instruction.
statement make_statement_from_statement_varargs_list(statement,...)
Build a statement sequence from a statement NULL-terminated varargs list.
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.
entity set_current_module_entity(entity)
static.c
void gen_recurse_stop(void *obj)
Tells the recursion not to go in this object.
void gen_context_multi_recurse(void *o, void *context,...)
Multi-recursion with context function visitor.
gen_chunk * gen_get_recurse_ancestor(const void *)
Get the first ancestor object encountered during the recursion for the given object.
void gen_null2(__attribute__((unused)) void *u1, __attribute__((unused)) void *u2)
idem with 2 args, to please overpeaky compiler checks
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)
#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.
void gen_free_list(list l)
free the spine of the 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.
list gen_append(list l1, const list l2)
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.
statement make_whileloop_statement(expression, statement, int, bool)
Build a while loop statement.
statement make_expression_statement(expression)
Build a statement from a given expression.
void insert_statement(statement, statement, bool)
This is the normal entry point.
bool forloop_statement_p(statement)
void fix_sequence_statement_attributes(statement)
Since blocks are not represented in Fortran, they cannot carry a label.
bool expression_constant_p(expression)
HPFC module by Fabien COELHO.
#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 STATEMENT_ORDERING_UNDEFINED
mapping.h inclusion
string bool_to_string(bool)
set set_intersection(set, const set, const set)
#define SET_FOREACH(type_name, the_item, the_set)
enumerate set elements in their internal order.
set set_make(set_type)
Create an empty set of any type but hash_private.
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
#define ENTITY_PLUS_UPDATE_P(e)
#define ENTITY_MODULO_UPDATE_P(e)
#define ENTITY_NON_EQUAL_P(e)
#define ENTITY_BITWISE_AND_UPDATE_P(e)
#define ENTITY_ASSIGN_P(e)
#define ENTITY_MINUS_P(e)
#define ENTITY_COMMA_P(e)
#define ENTITY_LESS_THAN_P(e)
#define ENTITY_PRE_DECREMENT_P(e)
#define ENTITY_POST_DECREMENT_P(e)
#define ENTITY_POST_INCREMENT_P(e)
#define STATEMENT_NUMBER_UNDEFINED
default values
#define ENTITY_RIGHT_SHIFT_UPDATE_P(e)
#define ENTITY_PRE_INCREMENT_P(e)
#define ENTITY_BITWISE_OR_UPDATE_P(e)
#define ENTITY_PLUS_C_P(e)
#define ENTITY_GREATER_THAN_P(e)
#define ENTITY_MINUS_C_P(e)
#define UNARY_MINUS_OPERATOR_NAME
#define ENTITY_MULTIPLY_UPDATE_P(e)
#define ENTITY_DIVIDE_UPDATE_P(e)
#define ENTITY_BITWISE_XOR_UPDATE_P(e)
#define ENTITY_ADDRESS_OF_P(e)
#define ENTITY_LESS_OR_EQUAL_P(e)
#define empty_comments
Empty comments (i.e.
#define ENTITY_MINUS_UPDATE_P(e)
#define ENTITY_LEFT_SHIFT_UPDATE_P(e)
#define ENTITY_GREATER_OR_EQUAL_P(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 same_entity_p(entity e1, entity e2)
predicates on entities
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
entity entity_empty_label(void)
static int init
Maximal value set for Fortran 77.
set get_referenced_entities(void *elem)
retrieves the set of entities used in elem beware that this entities may be formal parameters,...
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
bool positive_expression_p(expression e)
Use constants and type information to decide if the value of sigma(e) is always positive,...
bool negative_expression_p(expression e)
Use constants and type information to decide if the value of sigma(e) is always negative,...
expression expression_verbose_reduction_p_and_return_increment(expression incr, bool filter(expression))
Test if an expression is a verbose reduction of the form : "i = i op v" or "i = v op i".
bool extended_integer_constant_expression_p(expression e)
More extensive than next function.
bool expression_call_p(expression e)
int expression_to_int(expression exp)
================================================================
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
call expression_call(expression e)
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
bool add_expression_p(expression e)
Test if an expression is an addition.
expression convert_bound_expression(expression e, bool upper_p, bool non_strict_p)
Replace a C expression used as FOR bound by a Fortran DO bound expression, taking into account the C ...
expression MakeUnaryCall(entity f, expression a)
Creates a call expression to a function with one argument.
bool expression_reference_p(expression e)
Test if an expression is a reference.
reference expression_reference(expression e)
Short cut, meaningful only if expression_reference_p(e) holds.
bool sub_expression_p(expression e)
list expression_to_reference_list(expression e, list lr)
conversion of an expression into a list of references; references are appended to list lr as they are...
bool is_expression_reference_to_entity_p(expression e, entity v)
Test if an expression is a reference to a given variable entity.
bool empty_extensions_p(extensions es)
extensions empty_extensions(void)
extension.c
bool scalar_integer_type_p(type)
#define forloop_domain
newgen_extensions_domain_defined
#define value_undefined_p(x)
#define normalized_undefined
#define syntax_reference_p(x)
#define REFERENCE(x)
REFERENCE.
#define syntax_reference(x)
#define forloop_initialization(x)
#define reference_variable(x)
#define forloop_increment(x)
#define statement_ordering(x)
#define statement_domain
newgen_sizeofexpression_domain_defined
#define call_domain
newgen_callees_domain_defined
#define EXPRESSION(x)
EXPRESSION.
#define statement_label(x)
#define expression_undefined
@ is_instruction_sequence
#define instruction_tag(x)
#define expression_normalized(x)
#define sequence_statements(x)
#define statement_extensions(x)
struct _newgen_struct_instruction_ * instruction
#define instruction_sequence(x)
#define instruction_forloop(x)
#define expression_undefined_p(x)
#define statement_declarations(x)
#define statement_instruction(x)
#define statement_comments(x)
#define statement_decls_text(x)
#define forloop_condition(x)
#define call_arguments(x)
#define sequence_undefined
#define statement_number(x)
#define expression_syntax(x)
#define sequence_undefined_p(x)
#define statement_undefined
#define STATEMENT(x)
STATEMENT.
#define entity_initial(x)
FI: I do not understand why the type is duplicated at the set level.
The structure used to build lists in NewGen.
parameter of effect guesser
bool written
wheter the entity seems written
entity target
entity to find effect on
#define exp
Avoid some warnings from "gcc -Wshadow".