PIPS
expression.c File Reference
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "linear.h"
#include "genC.h"
#include "misc.h"
#include "ri.h"
#include "ri-util.h"
#include "properties.h"
+ Include dependency graph for expression.c:

Go to the source code of this file.

Data Structures

struct  ctx_substitute
 

Macros

#define ALREADY_SEEN(node)   (hash_defined_p(seen, (char*)node))
 
#define SEEN(node)   (hash_put(seen, (char*) node, (char*) 1))
 
#define DV_CIRCLE   ",a(\"_GO\",\"circle\")"
 
#define DV_YELLOW   ",a(\"COLOR\",\"yellow\")"
 

Typedefs

typedef struct ctx_substitute ctx_substitute_t
 

Functions

static string actual_fortran_string_to_compare (string fs, int *plength)
 quite lazy... More...
 
int fortran_string_compare (string fs1, string fs2)
 compare pips fortran string constants from the fortran point of view. More...
 
tag suggest_basic_for_expression (expression e)
 a BASIC tag is returned for the expression this is a preliminary version. More...
 
expression expression_mult (expression ex)
 
expression entity_to_expression (entity e)
 if v is a constant, returns a constant call. More...
 
expression make_entity_expression (entity e, cons *inds)
 
expression reference_to_expression (reference r)
 
reference expression_to_reference (expression e)
 
reference add_subscript_to_reference (reference r, expression s)
 Add a last subscript expression s to a reference r. More...
 
void generic_reference_add_fixed_subscripts (reference r, type t, bool zero_p)
 Add a set of zero subscripts to a reference "r" by side effect. More...
 
void reference_add_zero_subscripts (reference r, type t)
 
void reference_add_zero_subscript (reference r)
 No check on reference r. More...
 
void reference_complete_with_zero_subscripts (reference r)
 Reference r to an array maybe partial, as is possible in C: with declaration "int a[10][10]", references "a", "a[i]" and "a[i][j]" are all legal. More...
 
void reference_add_unbounded_subscripts (reference r, type t)
 
expression call_to_expression (call c)
 Build an expression that call a function or procedure. More...
 
expression make_call_expression (entity e, list l)
 Build an expression that call an function entity with an argument list. More...
 
expression MakeNullaryCall (entity f)
 Creates a call expression to a function with zero arguments. More...
 
expression MakeUnaryCall (entity f, expression a)
 Creates a call expression to a function with one argument. More...
 
expression MakeBinaryCall (entity f, expression eg, expression ed)
 Creates a call expression to a function with 2 arguments. More...
 
expression MakeTernaryCall (entity f, expression e1, expression e2, expression e3)
 Creates a call expression to a function with 3 arguments. More...
 
expression make_assign_expression (expression lhs, expression rhs)
 Make an assign expression, since in C the assignment is a side effect operator. More...
 
expression make_subscript_expression (expression a, list sl)
 
bool expression_brace_p (expression e)
 predicates and short cut accessors on expressions More...
 
bool expression_call_p (expression e)
 
bool expression_address_of_p (expression e)
 
call expression_call (expression e)
 
bool expression_cast_p (expression e)
 
cast expression_cast (expression e)
 
bool expression_sizeofexpression_p (expression e)
 
sizeofexpression expression_sizeofexpression (expression e)
 
bool expression_application_p (expression e)
 Duplicate bool expression_subscript_p(expression e) { return(syntax_subscript_p(expression_syntax(e))); }. More...
 
application expression_application (expression e)
 
bool expression_field_p (expression e)
 The expression is of kind "s.a", where "s" is a struct and a "a" field. More...
 
bool field_expression_p (expression e)
 The expression is of kind "a", where "a" is a field of some struct "s". More...
 
bool expression_pointer_p (expression e)
 we get the type of the expression by calling expression_to_type() which allocates a new one. More...
 
bool array_argument_p (expression e)
 
bool expression_reference_p (expression e)
 Test if an expression is a reference. More...
 
entity expression_variable (expression e)
 
bool is_expression_reference_to_entity_p (expression e, entity v)
 Test if an expression is a reference to a given variable entity. More...
 
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. More...
 
bool expression_equal_in_list_p (expression e, list le)
 This function returns true, if there exists an expression equal in the list false, otherwise. More...
 
bool logical_operator_expression_p (expression e)
 C xor is missing. More...
 
bool relational_expression_p (expression e)
 
bool integer_expression_p (expression e)
 
bool logical_expression_p (expression e)
 
int trivial_expression_p (expression e)
 This function returns: More...
 
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". More...
 
bool expression_implied_do_p (e)
 
bool comma_expression_p (expression e)
 
bool expression_list_directed_p (e)
 
bool extended_integer_constant_expression_p (expression e)
 More extensive than next function. More...
 
bool extended_integer_constant_expression_p_to_int (expression e, int *result)
 
bool integer_constant_expression_p (expression e)
 positive integer constant expression: call to a positive constant or to a sum of positive integer constant expressions (much too restrictive, but enough for the source codes submitted to PIPS up to now). More...
 
bool signed_integer_constant_expression_p (expression e)
 
bool expression_with_constant_signed_integer_value_p (expression e)
 The expression may be complicated but all its leaves are constants or parameters. More...
 
bool assignment_expression_p (expression e)
 Test if an expression is an assignment operation. More...
 
bool add_expression_p (expression e)
 Test if an expression is an addition. More...
 
bool sub_expression_p (expression e)
 
bool substraction_expression_p (expression e)
 Test if an expression is an substraction. More...
 
bool modulo_expression_p (expression e)
 
bool divide_expression_p (expression e)
 
bool power_expression_p (expression e)
 
bool abs_expression_p (expression e)
 
bool unary_minus_expression_p (expression e)
 
bool iabs_expression_p (expression e)
 
bool dabs_expression_p (expression e)
 
bool cabs_expression_p (expression e)
 
bool min0_expression_p (expression e)
 
bool max0_expression_p (expression e)
 
bool user_function_call_p (expression e)
 
bool operator_expression_p (expression e, string op_name)
 
expression make_true_expression ()
 
expression make_false_expression ()
 
bool true_expression_p (expression e)
 
bool false_expression_p (expression e)
 
bool unbounded_dimension_p (dimension dim)
 bool unbounded_dimension_p(dim) input : a dimension of an array entity. More...
 
expression find_ith_argument (list args, int n)
 
expression find_ith_expression (list le, int r)
 find_ith_expression() is obsolet; use find_ith_argument() instead More...
 
expression int_to_expression (_int i)
 transform an int into an expression and generate the corresponding entity if necessary; it is not clear if strdup() is always/sometimes necessary and if a memory leak occurs; wait till syntax/expression.c is merged with ri-util/expression.c More...
 
expression make_zero_expression (void)
 Make a zero expression. More...
 
bool zero_expression_p (expression e)
 
expression float_to_expression (float c)
 
expression complex_to_expression (float re, float im)
 
expression bool_to_expression (bool b)
 
expression Value_to_expression (Value v)
 added interface for linear stuff. More...
 
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 encountered; array references are added before their index expressions are scanned; More...
 
list syntax_to_reference_list (syntax s, list lr)
 
bool expression_equal_p (expression e1, expression e2)
 Syntactic equality e1==e2. More...
 
bool expression_equal_or_opposite_p (expression e1, expression e2)
 e1==e2 or -e1==e2 or e1==-e2 syntactically More...
 
bool expression_opposite_p (expression e1, expression e2)
 e1+e2==0, i.e. More...
 
bool expression_lists_equal_p (list l1, list l2)
 
bool same_expression_p (expression e1, expression e2)
 this is slightly different from expression_equal_p, as it will return true for a+b vs b+a More...
 
bool sizeofexpression_equal_p (sizeofexpression s0, sizeofexpression s1)
 
bool cast_equal_p (cast c1, cast c2)
 
bool syntax_equal_p (syntax s1, syntax s2)
 
bool subscript_equal_p (subscript s1, subscript s2)
 
bool reference_equal_p (reference r1, reference r2)
 
bool range_equal_p (range r1, range r2)
 
bool call_equal_p (call c1, call c2)
 
int integer_constant_expression_value (expression e)
 
int signed_integer_constant_expression_value (expression e)
 
expression make_max_expression (expression e1, expression e2, enum language_utype lang)
 
expression make_min_expression (expression e1, expression e2, enum language_utype lang)
 
expression make_factor_expression (int coeff, entity vari)
 Some functions to generate expressions from vectors and constraint systems. More...
 
expression make_vecteur_expression (Pvecteur pv)
 make expression for vector (Pvecteur) More...
 
statement Pvecteur_to_assign_statement (entity var, Pvecteur v)
 generates var = linear expression from the Pvecteur. More...
 
expression make_constraint_expression (Pvecteur v, Variable index)
 Make an expression from a constraint v for a given index. More...
 
expression make_contrainte_expression (Pcontrainte pc, Variable index)
 A wrapper around make_constraint_expression() for compatibility. More...
 
expression Pvecteur_to_expression (Pvecteur vect)
 AP, sep 25th 95 : some usefull functions moved from static_controlize/utils.c. More...
 
reference expression_reference (expression e)
 Short cut, meaningful only if expression_reference_p(e) holds. More...
 
bool expression_subscript_p (expression e)
 
subscript expression_subscript (expression e)
 
bool expression_range_p (expression e)
 
range expression_range (expression e)
 
bool array_reference_p (reference r)
 predicates on references More...
 
bool references_do_not_conflict_p (reference r1, reference r2)
 If true is returned, the two references cannot conflict unless array bound declarations are violated. More...
 
expression expression_list_to_binary_operator_call (list l, entity op)
 
expression expression_list_to_conjonction (list l)
 
bool expression_intrinsic_operation_p (expression exp)
 bool expression_intrinsic_operation_p(expression exp): Returns true if "exp" is an expression with a call to an intrinsic operation. More...
 
bool call_constant_p (call c)
 bool call_constant_p(call c): Returns true if "c" is a call to a constant, that is, a constant number or a symbolic constant. More...
 
bool expression_equal_integer_p (expression exp, int i)
 ================================================================ More...
 
expression make_op_exp (char *op_name, expression exp1, expression exp2)
 ================================================================ More...
 
expression add_integer_to_expression (expression exp, int val)
 
expression make_lin_op_exp (entity op_ent, expression exp1, expression exp2)
 ================================================================ More...
 
int expression_to_int (expression exp)
 ================================================================ More...
 
float expression_to_float (expression exp)
 Same as above for floating point constants. More...
 
constant expression_constant (expression exp)
 This function returns a "constant" object if the expression is a constant such as 10, -11 or 2.345 or "foo". More...
 
bool expression_string_constant_p (expression exp)
 
char * expression_string_constant (expression exp)
 returns a newly allocated string! More...
 
bool expression_integer_constant_p (expression e)
 
bool expression_constant_p (expression exp)
 ================================================================ More...
 
bool extended_expression_constant_p (expression exp)
 Returns true if the value of the expression does not depend syntactically on the current store. More...
 
bool expression_is_C_rhs_p (expression exp)
 Not all expressions can be used as right-hand side (rhs) in C assignments. More...
 
bool expression_one_p (expression exp)
 
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 (void *) 0). More...
 
static bool davinci_dump_expression_rc (FILE *out, expression e, hash_table seen)
 
void davinci_dump_expression (FILE *out, expression e)
 dump expression e in file out as a davinci graph. More...
 
static bool expr_flt (expression e)
 
void davinci_dump_all_expressions (FILE *out, statement s)
 dump all expressions in s to out. More...
 
static void substitute_variable_in_reference (reference r, ctx_substitute_t *ctx)
 
static void substitute_entity_in_call (call c, ctx_substitute_t *ctx)
 
expression substitute_entity_variable_in_expression (entity old, entity new, expression e)
 (This function isn't use for the moment) This function replaces all the occurrences of an old entity in the expression exp by the new entity. More...
 
expression substitute_entity_in_expression (entity old, entity new, expression e)
 This function replaces all the occurences of an old entity in the expression exp by the new entity. More...
 
bool simplify_C_expression (expression e)
 Replace C operators "+C" and "-C" which can handle pointers by arithmetic operators "+" and "-" when it is safe to do so, i.e. More...
 
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 comparison operator used. More...
 
bool reference_with_constant_indices_p (reference r)
 
reference reference_with_store_independent_indices (reference r)
 Return by side effect a reference whose memory locations includes the memory locations of r in case the subcript expressions are changed by a store change. More...
 
bool reference_with_unbounded_indices_p (reference r)
 indices can be constant or unbounded: they are store independent. More...
 
bool reference_with_unbounded_subscript_p (reference r)
 See if the reference uses the unbounded function '*'. More...
 
bool store_independent_reference_p (reference r)
 Does this reference define the same set of memory locations regardless of the current (environment and) memory state? More...
 
entity expression_to_entity (expression e)
 just returns the entity of an expression, or entity_undefined More...
 
list expressions_to_entities (list expressions)
 map expression_to_entity on expressions More...
 
static bool _expression_similar_p (expression target, expression pattern, hash_table symbols)
 perform the real similarity comparaison between two expressions target is matched against pattern, and expression <> argument is stored in symbols More...
 
bool expression_similar_get_context_p (expression target, expression pattern, hash_table *symbol_table)
 similar to expression_similar_p but the hash_map containing the crossref value is retured for further use More...
 
bool expression_similar_p (expression target, expression pattern)
 compare if two expressions are similar that is can we exchange target and pattern by substituing variables examples: 1+2 ~ a+b a+b !~ a+2 1+b ~ 1+c More...
 
list make_list_of_constant (int val, int number)
 of expression More...
 
bool brace_expression_p (expression e)
 Return bool indicating if expression e is a brace expression. More...
 
static list do_brace_expression_to_statements (entity arr, expression e, list curr_indices)
 helper for brace_expression_to_statements More...
 
list brace_expression_to_statements (entity arr, expression e)
 converts a brace expression used to initialize an array (not a struct yet) into a statement sequence More...
 
static void do_brace_expression_to_updated_type (entity arr, expression e, list dl)
 helper for brace_expression_to_updated_type More...
 
void brace_expression_to_updated_type (entity arr, expression e)
 use a brace expression to update the type of array "arr" if the dimensions are implicit More...
 
bool reference_scalar_p (reference r)
 This function returns true if Reference r is scalar. More...
 
expression expressions_to_operation (const list l_exprs, entity op)
 take a list of expression and apply a binary operator between all of them and return it as an expression More...
 
void update_expression_syntax (expression e, syntax s)
 frees expression syntax of e and replace it by the new syntax s More...
 
void local_assign_expression (expression caller, expression field)
 replace expression caller by expression field , where field is contained by caller More...
 
expression syntax_to_expression (syntax s)
 generates an expression from a syntax More...
 
expression monome_to_expression (Pmonome pm)
 converts a monome to an expression More...
 
expression polynome_to_expression (Ppolynome pp)
 converts a polynomial to expression More...
 
Ppolynome expression_to_polynome (expression exp)
 =========================================================================== More...
 
bool simplify_expression (expression *pexp)
 use polynomials to simplify an expression in some cases this operation can change the basic of the expression. More...
 
static void do_simplify_expressions (call c)
 
void simplify_expressions (void *obj)
 
expression reference_offset (reference ref)
 computes the offset of a C reference with its origin More...
 
expression replace_expression_content (expression e1, expression e2)
 Use side effects to move the content of e2, s2 and n2, into e1; s1 and n1 are freed, as well as e2. More...
 
bool expression_minmax_p (expression e)
 
expression MakeSizeofExpression (expression e)
 
expression MakeSizeofType (type t)
 
expression MakeCastExpression (type t, expression e)
 
expression MakeCommaExpression (list l)
 
expression MakeBraceExpression (list l)
 
expression dereference_expression (expression e)
 generate a newly allocated expression for *(e) More...
 
expression make_address_of_expression (expression e)
 generate a newly allocated expression for &(e) More...
 
list subscript_expressions_to_constant_subscript_expressions (list sl)
 make a full copy of the subscript expression list, preserve constant subscripts, replace non-constant subscript by the star subscript expression. More...
 
expression pointer_reference_to_expression (reference r)
 Assume p is a pointer. More...
 
expression expression_to_dereferencing_expression (expression e)
 Reuse expression e to build expression *(e) without cheking the legality of the construct. More...
 
bool C_initialization_expression_p (expression e)
 
list struct_initialization_expression_to_expressions (expression e)
 Returns a list of expressions hidden by the brace function. More...
 
void free_expressions (list el)
 Free a list of expressions. More...
 
static void expr_rwt (expression e)
 hack: clean all normalize fields... More...
 
void clean_all_normalized (expression e)
 
expression subscript_value_stride (entity arr, list l_inds)
 
expression size_of_actual_array (entity actual_array, list l_actual_ref, int i)
 
expression make_ref_expr (entity ent, list args)
 
bool unbounded_entity_p (entity f)
 
bool unbounded_expression_p (expression e)
 
expression make_unbounded_expression ()
 
list make_unbounded_subscripts (int d)
 FI: this piece of code must have been duplicated somewhere else in an effect library. More...
 
bool user_call_p (call c)
 Test if a call is a user call. More...
 
void normalize_subscript_expression (expression e)
 Normalization of subscript in expressions. More...
 
void expression_normalize_subscripts (expression e)
 To be used for initialization expressions. More...
 
void statement_normalize_subscripts (statement s)
 To be used for module statements. More...
 

Variables

static FILE * out_flt = NULL
 

Macro Definition Documentation

◆ ALREADY_SEEN

#define ALREADY_SEEN (   node)    (hash_defined_p(seen, (char*)node))

Definition at line 2631 of file expression.c.

◆ DV_CIRCLE

#define DV_CIRCLE   ",a(\"_GO\",\"circle\")"

Definition at line 2634 of file expression.c.

◆ DV_YELLOW

#define DV_YELLOW   ",a(\"COLOR\",\"yellow\")"

Definition at line 2635 of file expression.c.

◆ SEEN

#define SEEN (   node)    (hash_put(seen, (char*) node, (char*) 1))

Definition at line 2632 of file expression.c.

Typedef Documentation

◆ ctx_substitute_t

Function Documentation

◆ _expression_similar_p()

static bool _expression_similar_p ( expression  target,
expression  pattern,
hash_table  symbols 
)
static

perform the real similarity comparaison between two expressions target is matched against pattern, and expression <> argument is stored in symbols

Parameters
targetcheked expression
patternpattern expression
symbolsmap storing entity <> expression tuple
Returns
true if similar

cast handler

we memorize reference from target and pattern in the symbol table similar to \1 in sed

scalar reference always matches. SG: in fact, you have to check for type compatibility too ... Allows to match malloc(a) with more complex expressions like malloc(1 + strlen("...")). Interferes incorrectly with commutativity.

recursively compare each arguments if call do not differ

could occur with va args

SG: will this be usefull ?

SG:not supported yet

could occur with va args

Definition at line 3180 of file expression.c.

3181 {
3182  bool similar=true;
3183  syntax starget = expression_syntax(target),
3184  spattern = expression_syntax(pattern);
3185 
3186  /* cast handler */
3187  if( syntax_cast_p( spattern ) )
3188  {
3189  pips_user_warning("cast ignored\n");
3190  return _expression_similar_p(target, cast_expression(syntax_cast(spattern)),symbols);
3191  }
3192  if( syntax_cast_p( starget ) )
3193  {
3194  pips_user_warning("cast ignored\n");
3195  return _expression_similar_p(cast_expression(syntax_cast(starget)), pattern,symbols);
3196  }
3197 
3198  switch(syntax_tag(spattern) )
3199  {
3200  /* we memorize reference from target and pattern in the symbol table
3201  * similar to \1 in sed
3202  */
3203  case is_syntax_reference:
3204  {
3205  reference r = syntax_reference(spattern);
3206  /* scalar reference always matches.
3207  * SG: in fact, you have to check for type compatibility too ...
3208  * Allows to match malloc(a) with more complex expressions like malloc(1 +
3209  * strlen("...")).
3210  * Interferes incorrectly with commutativity. */
3212  similar = false;
3213  else {
3214  basic bpattern = basic_of_expression(pattern),
3215  btarget = basic_of_expression(target);
3216  basic bmax = basic_maximum(bpattern,btarget);
3217  if(basic_overloaded_p(bmax) || basic_equal_p(bmax,bpattern)) {
3218  hash_put(symbols,entity_name(reference_variable(r)), target);
3219  }
3220  else
3221  similar = false;
3222  free_basic(bmax);
3223  free_basic(bpattern);
3224  free_basic(btarget);
3225  }
3226  } break;
3227  /* recursively compare each arguments if call do not differ */
3228  case is_syntax_call:
3229  if( syntax_call_p(starget) &&
3231  {
3232  call cpattern = syntax_call(spattern);
3233  call ctarget = syntax_call(starget);
3234  if(commutative_call_p(cpattern))
3235  {
3236  pips_assert("pips commutative call have only two arguments\n",gen_length(call_arguments(cpattern))==2);
3237  expression lhs_pattern = binary_call_lhs(cpattern),
3238  rhs_pattern = binary_call_rhs(cpattern),
3239  lhs_target = binary_call_lhs(ctarget),
3240  rhs_target = binary_call_rhs(ctarget);
3241  similar = (_expression_similar_p(lhs_target,lhs_pattern,symbols) && _expression_similar_p(rhs_target,rhs_pattern,symbols))
3242  ||
3243  (_expression_similar_p(lhs_target,rhs_pattern,symbols) && _expression_similar_p(rhs_target,lhs_pattern,symbols))
3244  ;
3245 
3246  }
3247  else
3248  {
3249  list iter = call_arguments(cpattern);
3250  FOREACH(EXPRESSION, etarget, call_arguments(ctarget) )
3251  {
3252  if( ENDP(iter) ) { similar = false; break; }/* could occur with va args */
3253  expression epattern = EXPRESSION(CAR(iter));
3254  similar&= _expression_similar_p(etarget,epattern,symbols);
3255  POP(iter);
3256  if(!similar)
3257  break;
3258  }
3259  }
3260  }
3261  else
3262  {
3263  similar =false;
3264  }
3265  break;
3266  /* SG: will this be usefull ?*/
3267  case is_syntax_range:
3268  similar = syntax_range_p(starget) &&
3269  _expression_similar_p(range_lower(syntax_range(starget)),range_lower(syntax_range(spattern)),symbols) &&
3270  _expression_similar_p(range_upper(syntax_range(starget)),range_upper(syntax_range(spattern)),symbols) &&
3272  break;
3273 
3274  /* SG:not supported yet */
3275  case is_syntax_cast:
3276  pips_user_warning("cast ignored\n");
3277  similar = _expression_similar_p(cast_expression(syntax_cast(starget)),pattern,symbols);
3278  break;
3279 
3281  if( syntax_sizeofexpression_p(starget) )
3282  {
3283  sizeofexpression seo_target = syntax_sizeofexpression(starget);
3284  sizeofexpression seo_pattern = syntax_sizeofexpression(spattern);
3285  if( sizeofexpression_type(seo_pattern) )
3286  similar = sizeofexpression_type_p(seo_target) &&
3287  type_equal_p( sizeofexpression_type(seo_target), sizeofexpression_type(seo_pattern) );
3288  else
3289  similar = _expression_similar_p(sizeofexpression_expression(seo_target),
3290  sizeofexpression_expression(seo_pattern),
3291  symbols );
3292  }
3293  else
3294  {
3295  similar =false;
3296  }
3297  break;
3298 
3299  case is_syntax_subscript:
3300  if( syntax_subscript_p(starget) )
3301  {
3302  subscript sub_target = syntax_subscript(starget),
3303  sub_pattern = syntax_subscript(spattern);
3304  similar&= _expression_similar_p( subscript_array(sub_target), subscript_array(sub_pattern),symbols );
3305 
3306  list iter = subscript_indices(sub_pattern);
3307  FOREACH(EXPRESSION, etarget, subscript_indices(sub_target) )
3308  {
3309  if( ENDP(iter) ) { similar = false; break; }/* could occur with va args */
3310  expression epattern = EXPRESSION(CAR(iter));
3311  similar&= _expression_similar_p(etarget,epattern,symbols);
3312  POP(iter);
3313  }
3314  }
3315  else
3316  similar =false;
3317  break;
3318  case is_syntax_application:
3319  pips_user_warning("application similarity not implemented yet\n");
3320  similar=false;
3321  break;
3322  case is_syntax_va_arg:
3323  pips_user_warning("va_arg similarity not implemented yet\n");
3324  similar=false;
3325  break;
3326  };
3327  return similar;
3328 }
void free_basic(basic p)
Definition: ri.c:107
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
size_t gen_length(const list l)
Definition: list.c:150
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
void hash_put(hash_table htp, const void *key, const void *val)
This functions stores a couple (key,val) in the hash table pointed to by htp.
Definition: hash.c:364
#define pips_user_warning
Definition: misc-local.h:146
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define binary_call_rhs(c)
#define expression_scalar_p(e)
#define binary_call_lhs(c)
bool commutative_call_p(call c)
Test if we are allowed to commute operations.
Definition: entity.c:2661
bool same_entity_p(entity e1, entity e2)
predicates on entities
Definition: entity.c:1321
static bool _expression_similar_p(expression target, expression pattern, hash_table symbols)
perform the real similarity comparaison between two expressions target is matched against pattern,...
Definition: expression.c:3180
basic basic_of_expression(expression)
basic basic_of_expression(expression exp): Makes a basic of the same basic as the expression "exp".
Definition: type.c:1383
bool type_equal_p(type, type)
Definition: type.c:547
bool basic_equal_p(basic, basic)
Definition: type.c:927
basic basic_maximum(basic, basic)
Definition: type.c:1816
#define syntax_reference(x)
Definition: ri.h:2730
#define syntax_tag(x)
Definition: ri.h:2727
#define call_function(x)
Definition: ri.h:709
#define reference_variable(x)
Definition: ri.h:2326
#define sizeofexpression_type(x)
Definition: ri.h:2406
#define range_upper(x)
Definition: ri.h:2290
#define syntax_call_p(x)
Definition: ri.h:2734
#define sizeofexpression_expression(x)
Definition: ri.h:2409
#define syntax_cast(x)
Definition: ri.h:2739
#define syntax_sizeofexpression_p(x)
Definition: ri.h:2740
#define syntax_range(x)
Definition: ri.h:2733
@ is_syntax_range
Definition: ri.h:2692
@ is_syntax_application
Definition: ri.h:2697
@ is_syntax_cast
Definition: ri.h:2694
@ is_syntax_call
Definition: ri.h:2693
@ is_syntax_va_arg
Definition: ri.h:2698
@ is_syntax_reference
Definition: ri.h:2691
@ is_syntax_sizeofexpression
Definition: ri.h:2695
@ is_syntax_subscript
Definition: ri.h:2696
#define range_increment(x)
Definition: ri.h:2292
#define basic_overloaded_p(x)
Definition: ri.h:623
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define cast_expression(x)
Definition: ri.h:747
#define subscript_indices(x)
Definition: ri.h:2563
#define entity_name(x)
Definition: ri.h:2790
#define syntax_sizeofexpression(x)
Definition: ri.h:2742
#define sizeofexpression_type_p(x)
Definition: ri.h:2404
#define syntax_call(x)
Definition: ri.h:2736
#define subscript_array(x)
Definition: ri.h:2561
#define range_lower(x)
Definition: ri.h:2288
#define syntax_subscript(x)
Definition: ri.h:2745
#define call_arguments(x)
Definition: ri.h:711
#define syntax_cast_p(x)
Definition: ri.h:2737
#define syntax_range_p(x)
Definition: ri.h:2731
#define expression_syntax(x)
Definition: ri.h:1247
#define syntax_subscript_p(x)
Definition: ri.h:2743
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References basic_equal_p(), basic_maximum(), basic_of_expression(), basic_overloaded_p, binary_call_lhs, binary_call_rhs, call_arguments, call_function, CAR, cast_expression, commutative_call_p(), ENDP, entity_name, EXPRESSION, expression_scalar_p, expression_syntax, FOREACH, free_basic(), gen_length(), hash_put(), is_syntax_application, is_syntax_call, is_syntax_cast, is_syntax_range, is_syntax_reference, is_syntax_sizeofexpression, is_syntax_subscript, is_syntax_va_arg, pips_assert, pips_user_warning, POP, range_increment, range_lower, range_upper, reference_variable, same_entity_p(), sizeofexpression_expression, sizeofexpression_type, sizeofexpression_type_p, subscript_array, subscript_indices, syntax_call, syntax_call_p, syntax_cast, syntax_cast_p, syntax_range, syntax_range_p, syntax_reference, syntax_sizeofexpression, syntax_sizeofexpression_p, syntax_subscript, syntax_subscript_p, syntax_tag, and type_equal_p().

Referenced by expression_similar_get_context_p(), and expression_similar_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ abs_expression_p()

bool abs_expression_p ( expression  e)

Definition at line 1024 of file expression.c.

1026 {
1028 }
#define ABS_OPERATOR_NAME
bool operator_expression_p(expression e, string op_name)
Definition: expression.c:1087

References ABS_OPERATOR_NAME, and operator_expression_p().

+ Here is the call graph for this function:

◆ actual_fortran_string_to_compare()

static string actual_fortran_string_to_compare ( string  fs,
int plength 
)
static

quite lazy...

skip TOP-LEVEL header

skip : header

skip surrounding quotes

skip trailing spaces (are these blanks?) if any.

Definition at line 54 of file expression.c.

55 {
56  string s = fs;
57  int len;
58 
59  /* skip TOP-LEVEL header */
60  if (strncmp(s, TOP_LEVEL_MODULE_NAME, strlen(TOP_LEVEL_MODULE_NAME))==0)
61  s += strlen(TOP_LEVEL_MODULE_NAME);
62 
63  /* skip : header */
64  if (strncmp(s, MODULE_SEP_STRING, strlen(MODULE_SEP_STRING))==0)
65  s += strlen(MODULE_SEP_STRING);
66 
67  len = strlen(s);
68 
69  /* skip surrounding quotes */
70  if (len>=2 &&
71  ((s[0]=='\'' && s[len-1]=='\'') || (s[0]=='"' && s[len-1]=='"')))
72  {
73  s++;
74  len -= 2;
75  }
76 
77  /* skip trailing *spaces* (are these blanks?) if any. */
78  while (len>0 && s[len-1]==' ')
79  len--;
80 
81  *plength = len;
82  return s;
83 }
#define TOP_LEVEL_MODULE_NAME
Module containing the global variables in Fortran and C.
Definition: naming-local.h:101
#define MODULE_SEP_STRING
Definition: naming-local.h:30

References MODULE_SEP_STRING, and TOP_LEVEL_MODULE_NAME.

Referenced by fortran_string_compare().

+ Here is the caller graph for this function:

◆ add_expression_p()

bool add_expression_p ( expression  e)

Test if an expression is an addition.

Definition at line 986 of file expression.c.

986  {
989  ;
990 }
#define PLUS_OPERATOR_NAME
#define PLUS_C_OPERATOR_NAME

References operator_expression_p(), PLUS_C_OPERATOR_NAME, and PLUS_OPERATOR_NAME.

Referenced by incrementation_expression_to_increment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add_integer_to_expression()

expression add_integer_to_expression ( expression  exp,
int  val 
)
Returns
a new expression that adds the an expression with an integer
Parameters
e,theexpression to add
n,theinteger to add
Parameters
expxp
valal

Definition at line 2132 of file expression.c.

2132  {
2134 }
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
Definition: expression.c:1188
expression make_op_exp(char *op_name, expression exp1, expression exp2)
================================================================
Definition: expression.c:2012
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207

References exp, int_to_expression(), make_op_exp(), and PLUS_OPERATOR_NAME.

Referenced by do_linearize_array_reference(), and region_to_minimal_dimensions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add_subscript_to_reference()

reference add_subscript_to_reference ( reference  r,
expression  s 
)

Add a last subscript expression s to a reference r.

The validity of the input reference is not checked. The validity of the output reference is not checked either.

Definition at line 224 of file expression.c.

225 {
227  CONS(EXPRESSION, s, NIL));
228  return r;
229 }
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#define reference_indices(x)
Definition: ri.h:2328

References CONS, EXPRESSION, gen_nconc(), NIL, and reference_indices.

Referenced by substitute_struct_stub_in_transformer(), transformer_apply_field_assignments_or_equalities(), and transformer_apply_unknown_field_assignments_or_equalities().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ array_argument_p()

bool array_argument_p ( expression  e)

Definition at line 513 of file expression.c.

514 {
515  if (expression_reference_p(e))
516  {
519  if (array_entity_p(ent)) return true;
520  }
521  return false;
522 }
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
bool array_entity_p(entity e)
Definition: entity.c:793
bool expression_reference_p(expression e)
Test if an expression is a reference.
Definition: expression.c:528
reference expression_reference(expression e)
Short cut, meaningful only if expression_reference_p(e) holds.
Definition: expression.c:1832

References array_entity_p(), expression_reference(), expression_reference_p(), ref, and reference_variable.

Referenced by interprocedural_abc_call(), xml_Argument(), xml_AssignArgument(), xml_Call(), and xml_Transposition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ array_reference_p()

bool array_reference_p ( reference  r)

predicates on references

two possible meanings:

  • the referenced variable is declared as an array
  • the reference is to an array element

This makes a difference in procedure calls and IO statements

The second interpretation is chosen.

Definition at line 1861 of file expression.c.

1862 {
1863  /* two possible meanings:
1864  * - the referenced variable is declared as an array
1865  * - the reference is to an array element
1866  *
1867  * This makes a difference in procedure calls and IO statements
1868  *
1869  * The second interpretation is chosen.
1870  */
1871 
1872  return reference_indices(r) != NIL;
1873 }

References NIL, and reference_indices.

Referenced by array_to_constant_paths(), bottom_up_abc_reference(), bottom_up_abc_reference_implied_do(), dmas_invert_p(), expression_in_array_subscript(), initial_code_abc_reference(), and top_down_abc_flt().

+ Here is the caller graph for this function:

◆ assignment_expression_p()

bool assignment_expression_p ( expression  e)

Test if an expression is an assignment operation.

Definition at line 979 of file expression.c.

979  {
981 }
#define ASSIGN_OPERATOR_NAME
Definition: ri-util-local.h:95

References ASSIGN_OPERATOR_NAME, and operator_expression_p().

Referenced by expression_verbose_reduction_p_and_return_increment(), and step_directive_basic_workchunk_index().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bool_to_expression()

expression bool_to_expression ( bool  b)

Definition at line 1238 of file expression.c.

1239 {
1240  return MakeNullaryCall
1242  is_basic_logical));
1243 }
entity MakeConstant(string name, tag bt)
Make a Fortran constant.
Definition: constant.c:351
#define FALSE_OPERATOR_NAME
#define TRUE_OPERATOR_NAME
expression MakeNullaryCall(entity f)
Creates a call expression to a function with zero arguments.
Definition: expression.c:331
@ is_basic_logical
Definition: ri.h:573

References FALSE_OPERATOR_NAME, is_basic_logical, MakeConstant(), MakeNullaryCall(), and TRUE_OPERATOR_NAME.

Referenced by generate_all_liveness_but(), generate_dynamic_liveness_for_primary(), generate_prelude(), generate_remapping_guard(), and set_live_status().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ brace_expression_p()

bool brace_expression_p ( expression  e)

Return bool indicating if expression e is a brace expression.

Definition at line 3384 of file expression.c.

3385 {
3386  if (expression_call_p(e))
3387  {
3390  return true;
3391  }
3392  return false;
3393 }
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
#define ENTITY_BRACE_INTRINSIC_P(e)
C initialization expression.
bool expression_call_p(expression e)
Definition: expression.c:415

References call_function, ENTITY_BRACE_INTRINSIC_P, expression_call_p(), expression_syntax, f(), and syntax_call.

Referenced by brace_expression_to_statements(), brace_expression_to_updated_type(), c_brace_expression_string(), do_brace_expression_to_statements(), expression_is_C_rhs_p(), freia_extract_kernel(), st_brace_expression_as_string(), st_declaration_init(), this_entity_cdeclaration(), words_assign_op(), and words_variable_or_function().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ brace_expression_to_statements()

list brace_expression_to_statements ( entity  arr,
expression  e 
)

converts a brace expression used to initialize an array (not a struct yet) into a statement sequence

Parameters
arrrr

Definition at line 3480 of file expression.c.

3480  {
3481  pips_assert("is a brace expression\n",brace_expression_p(e));
3482  //SG: needs work to support structures
3483  // pips_assert("is an array\n",array_entity_p(arr));
3484  list curr_index = NIL;
3485  list out = do_brace_expression_to_statements(arr,e,curr_index);
3486  return out;
3487 }
static FILE * out
Definition: alias_check.c:128
static list do_brace_expression_to_statements(entity arr, expression e, list curr_indices)
helper for brace_expression_to_statements
Definition: expression.c:3396
bool brace_expression_p(expression e)
Return bool indicating if expression e is a brace expression.
Definition: expression.c:3384

References brace_expression_p(), do_brace_expression_to_statements(), NIL, out, and pips_assert.

Referenced by split_initializations_in_statement().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ brace_expression_to_updated_type()

void brace_expression_to_updated_type ( entity  arr,
expression  e 
)

use a brace expression to update the type of array "arr" if the dimensions are implicit

Parameters
arrrr

Definition at line 3517 of file expression.c.

3517  {
3518  pips_assert("is a brace expression\n",brace_expression_p(e));
3519  //SG: needs work to support structures
3520  //pips_assert("is an array\n",array_entity_p(arr));
3521  // type t = entity_basic_concrete_type(arr);
3522  type t = entity_type(arr);
3523  variable v = type_variable(t);
3524  list dl = variable_dimensions(v);
3526 }
static void do_brace_expression_to_updated_type(entity arr, expression e, list dl)
helper for brace_expression_to_updated_type
Definition: expression.c:3493
#define type_variable(x)
Definition: ri.h:2949
#define variable_dimensions(x)
Definition: ri.h:3122
#define entity_type(x)
Definition: ri.h:2792

References brace_expression_p(), do_brace_expression_to_updated_type(), entity_type, pips_assert, type_variable, and variable_dimensions.

Referenced by split_initializations_in_statement().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ C_initialization_expression_p()

bool C_initialization_expression_p ( expression  e)

Definition at line 4056 of file expression.c.

4057 {
4058  bool initialization_p = false;
4059  syntax s = expression_syntax(e);
4060  if(syntax_call_p(s)) {
4061  call c = syntax_call(s);
4062  entity f = call_function(c);
4064  initialization_p = true;
4065  }
4066  return initialization_p;
4067 }

References call_function, ENTITY_BRACE_INTRINSIC_P, expression_syntax, f(), syntax_call, and syntax_call_p.

Referenced by struct_assignment_to_points_to(), and struct_initialization_expression_to_expressions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cabs_expression_p()

bool cabs_expression_p ( expression  e)

Definition at line 1048 of file expression.c.

1050 {
1052 }
#define CABS_OPERATOR_NAME

References CABS_OPERATOR_NAME, and operator_expression_p().

+ Here is the call graph for this function:

◆ call_constant_p()

bool call_constant_p ( call  c)

bool call_constant_p(call c): Returns true if "c" is a call to a constant, that is, a constant number or a symbolic constant.

Definition at line 1965 of file expression.c.

1966 {
1968  return( (value_tag(cv) == is_value_constant) ||
1969  (value_tag(cv) == is_value_symbolic) );
1970 }
#define value_tag(x)
Definition: ri.h:3064
@ is_value_constant
Definition: ri.h:3033
@ is_value_symbolic
Definition: ri.h:3032
#define entity_initial(x)
Definition: ri.h:2796

References call_function, entity_initial, is_value_constant, is_value_symbolic, and value_tag.

Referenced by logical_expression_to_transformer().

+ Here is the caller graph for this function:

◆ call_equal_p()

bool call_equal_p ( call  c1,
call  c2 
)
Parameters
c11
c22

Definition at line 1529 of file expression.c.

1530 {
1531  entity f1 = call_function(c1);
1532  entity f2 = call_function(c2);
1533  list args1 = call_arguments(c1);
1534  list args2 = call_arguments(c2);
1535 
1536  if(f1 != f2)
1537  return false;
1538 
1539  return gen_equals(args1,args2,(gen_eq_func_t)expression_equal_p);
1540 
1541  return true;
1542 }
bool gen_equals(const list l0, const list l1, gen_eq_func_t equals)
compares two lists using the functor given in parameters returns true if for all n,...
Definition: list.c:192
bool(* gen_eq_func_t)(const void *, const void *)
Definition: newgen_types.h:115
int f2(int off1, int off2, int w, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:1
bool expression_equal_p(expression e1, expression e2)
Syntactic equality e1==e2.
Definition: expression.c:1347

References call_arguments, call_function, expression_equal_p(), f2(), and gen_equals().

Referenced by syntax_equal_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ call_to_expression()

expression call_to_expression ( call  c)

Build an expression that call a function or procedure.

Parameters
cis the call

Definition at line 309 of file expression.c.

310 {
313 }
expression make_expression(syntax a1, normalized a2)
Definition: ri.c:886
syntax make_syntax(enum syntax_utype tag, void *val)
Definition: ri.c:2491
#define normalized_undefined
Definition: ri.h:1745

References is_syntax_call, make_expression(), make_syntax(), and normalized_undefined.

Referenced by add_exec_mmcd(), atom_cse_expression(), bound_to_statement(), call_nary_rwt(), call_to_transformer(), compute_constant(), do_point_to(), entity_to_expression(), expressions_to_operation(), float_to_expression(), freia_cleanup_status(), generate_compact(), generate_fifo_stat(), generate_mmcd_stat_from_ref(), get_fifoExp_from_ref(), gfc2pips_code2instruction_(), hwac_replace_statement(), if_different_pe_and_not_twin(), inline_statement_crawler(), int_to_expression(), inv_call_flt(), make_call_expression(), make_lInitStats(), make_loadsave_statement(), make_loop_step_stat(), make_lSwitchStats(), make_mmcd_load_store_stat(), make_read_write_fifo_stat(), make_send_receive_conversion(), make_step_inc_statement(), make_toggle_inc_statement(), make_transStat(), make_vecteur_expression(), MakeCaseStatement(), MakeForloopWithIndexDeclaration(), mpic_make_mpi_comm_rank(), mpic_make_mpi_comm_size(), mpic_make_mpi_finalize(), mpic_make_mpi_init(), mpic_make_mpi_irecv(), mpic_make_mpi_isend(), mpic_make_mpi_recv(), mpic_make_mpi_send(), new_local_image_variable(), pragma_build_if_condition(), pragma_if_as_expr(), process_innerStat1_proc(), replace_instruction_similar_to_pattern(), sesamify(), split_update_call(), and words_brace_op().

+ Here is the call graph for this function:

◆ cast_equal_p()

bool cast_equal_p ( cast  c1,
cast  c2 
)
Parameters
c11
c22

Definition at line 1455 of file expression.c.

1456 {
1457  return
1458  type_equal_p(cast_type(c1), cast_type(c2)) &&
1460 }
#define cast_type(x)
Definition: ri.h:745

References cast_expression, cast_type, expression_equal_p(), and type_equal_p().

Referenced by syntax_equal_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clean_all_normalized()

◆ comma_expression_p()

bool comma_expression_p ( expression  e)

Definition at line 830 of file expression.c.

831 {
832  bool result = false;
833 
834  if (expression_call_p(e)) {
836  entity f = call_function(c);
837 
838  result = ENTITY_COMMA_P(f);
839  }
840 
841  return result;
842 }
#define ENTITY_COMMA_P(e)

References call_function, ENTITY_COMMA_P, expression_call_p(), expression_syntax, f(), and syntax_call.

Referenced by any_expression_to_transformer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ complex_to_expression()

expression complex_to_expression ( float  re,
float  im 
)
Parameters
ree
imm

Definition at line 1234 of file expression.c.

1235 {
1237 }
expression MakeComplexConstantExpression(expression r, expression i)
Definition: constant.c:397
expression float_to_expression(float c)
Definition: expression.c:1229

References float_to_expression(), and MakeComplexConstantExpression().

Referenced by make_0val_expression(), and make_1val_expression().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ convert_bound_expression()

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 comparison operator used.

Fi this test is too strong to preserve source code

The offset might not be plus or minus one, unless we know the index is an integer? Does it depend on the step value? More thought needed than available tonight (FI)

The offset might not be plus or minus one, unless we know the index is an integer? Does it depend on the step value? More thought needed than available tonight (FI)

May modify the source code a bit more than necessary, but avoids stupid expressions such as 64-1-1

This could be generalized to any affine expression. See for instance loop_bound02.c. But the source code is likely to be disturbed if the bound expression is regenerated from v after adding or subtracting 1 from its constant term.

Parameters
upper_ppper_p
non_strict_pon_strict_p

Definition at line 2968 of file expression.c.

2969 {
2971 
2972  if(non_strict_p) {
2973  b = copy_expression(e);
2974  }
2975  else {
2976  /* */
2977  intptr_t ib = 0;
2978  intptr_t nb = 0;
2979 
2980  /* Fi this test is too strong to preserve source code */
2981  if(false && expression_integer_value(e, &ib)) {
2982  /* The offset might not be plus or minus one, unless we know the
2983  index is an integer? Does it depend on the step value? More
2984  thought needed than available tonight (FI) */
2985  nb = upper_p? ib-1 : ib+1;
2986  b = int_to_expression(nb);
2987  }
2988  else if(expression_constant_p(e)) {
2989  /* The offset might not be plus or minus one, unless we know the
2990  index is an integer? Does it depend on the step value? More
2991  thought needed than available tonight (FI) */
2992  ib = expression_to_int(e);
2993  nb = upper_p? ib-1 : ib+1;
2994  b = int_to_expression(nb);
2995  }
2996  else if(NORMALIZE_EXPRESSION(e), expression_linear_p(e)) {
2997  /* May modify the source code a bit more than necessary, but
2998  avoids stupid expressions such as 64-1-1 */
3000  Pvecteur v = normalized_linear(n);
3001  /* This could be generalized to any affine expression. See for
3002  instance loop_bound02.c. But the source code is likely to be
3003  disturbed if the bound expression is regenerated from v after
3004  adding or subtracting 1 from its constant term. */
3005  if(vect_constant_p(v) || VECTEUR_NUL_P(v)) {
3006  Value c = vect_coeff(TCST, v);
3007  ib = (int) c;
3008  nb = upper_p? ib-1 : ib+1;
3009  b = int_to_expression(nb);
3010  }
3011  }
3012  if(expression_undefined_p(b)) {
3015 
3016  b = MakeBinaryCall(op, copy_expression(e), offset);
3017  }
3018  }
3019  return b;
3020 }
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
void const char const char const int
int Value
bool vect_constant_p(Pvecteur)
bool vect_constant_p(Pvecteur v): v contains only a constant term, may be zero
Definition: predicats.c:211
static Value offset
Definition: translation.c:283
#define MINUS_OPERATOR_NAME
#define NORMALIZE_EXPRESSION(e)
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
bool expression_linear_p(expression e)
returns if e is already normalized and linear.
Definition: eval.c:951
bool expression_integer_value(expression e, intptr_t *pval)
Definition: eval.c:792
bool expression_constant_p(expression exp)
================================================================
Definition: expression.c:2453
int expression_to_int(expression exp)
================================================================
Definition: expression.c:2205
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
Definition: expression.c:354
#define expression_undefined
Definition: ri.h:1223
#define expression_normalized(x)
Definition: ri.h:1249
#define expression_undefined_p(x)
Definition: ri.h:1224
#define normalized_linear(x)
Definition: ri.h:1781
#define intptr_t
Definition: stdint.in.h:294
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
#define VECTEUR_NUL_P(v)
Value vect_coeff(Variable var, Pvecteur vect)
Variable vect_coeff(Variable var, Pvecteur vect): coefficient de coordonnee var du vecteur vect —> So...
Definition: unaires.c:228

References copy_expression(), entity_intrinsic(), expression_constant_p(), expression_integer_value(), expression_linear_p(), expression_normalized, expression_to_int(), expression_undefined, expression_undefined_p, int, int_to_expression(), intptr_t, MakeBinaryCall(), MINUS_OPERATOR_NAME, NORMALIZE_EXPRESSION, normalized_linear, offset, PLUS_OPERATOR_NAME, TCST, vect_coeff(), vect_constant_p(), and VECTEUR_NUL_P.

Referenced by condition_expression_to_final_bound().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dabs_expression_p()

bool dabs_expression_p ( expression  e)

Definition at line 1042 of file expression.c.

1044 {
1046 }
#define DABS_OPERATOR_NAME

References DABS_OPERATOR_NAME, and operator_expression_p().

+ Here is the call graph for this function:

◆ davinci_dump_all_expressions()

void davinci_dump_all_expressions ( FILE *  out,
statement  s 
)

dump all expressions in s to out.

Parameters
outut

Definition at line 2728 of file expression.c.

2729 {
2730  out_flt = out;
2732  out_flt = NULL;
2733 }
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
static FILE * out_flt
Definition: expression.c:2719
static bool expr_flt(expression e)
Definition: expression.c:2720

References expr_flt(), expression_domain, gen_null(), gen_recurse, out, and out_flt.

Referenced by davinci_dump_expressions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ davinci_dump_expression()

void davinci_dump_expression ( FILE *  out,
expression  e 
)

dump expression e in file out as a davinci graph.

Parameters
outut

Definition at line 2710 of file expression.c.

2711 {
2713  fprintf(out, "[\n");
2715  fprintf(out, "]\n\n");
2717 }
static hash_table seen
static function to store whether a module has been seen during the recursive generation of the daVinc...
Definition: graph.c:85
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327
@ hash_pointer
Definition: newgen_hash.h:32
static bool davinci_dump_expression_rc(FILE *out, expression e, hash_table seen)
Definition: expression.c:2637
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...

References davinci_dump_expression_rc(), fprintf(), hash_pointer, hash_table_free(), hash_table_make(), out, and seen.

Referenced by expr_flt().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ davinci_dump_expression_rc()

static bool davinci_dump_expression_rc ( FILE *  out,
expression  e,
hash_table  seen 
)
static

daVinci node prolog.

node epilog

Definition at line 2637 of file expression.c.

2639 {
2640  syntax s;
2641  const char* name, *shape, *color;
2642  list sons = NIL;
2643  bool first = true, something = true;
2644 
2645  if (ALREADY_SEEN(e)) return false;
2646  SEEN(e);
2647 
2648  s = expression_syntax(e);
2649  switch (syntax_tag(s))
2650  {
2651  case is_syntax_call:
2652  {
2653  call c = syntax_call(s);
2654  name = entity_local_name(call_function(c));
2655  sons = call_arguments(c);
2656  shape = "";
2657  color = "";
2658  break;
2659  }
2660  case is_syntax_range:
2661  name = "::";
2662  shape = "";
2663  color = "";
2664  break;
2665  case is_syntax_cast: // ???
2666  name = "";
2667  shape = "";
2668  color = "";
2669  pips_user_warning("skipping cast\n");
2670  break;
2671  case is_syntax_reference:
2673  shape = DV_CIRCLE;
2674  color = DV_YELLOW;
2675  break;
2676  default:
2677  name = "";
2678  shape = "";
2679  color = "";
2680  pips_internal_error("unexpected syntax tag (%d)", syntax_tag(s));
2681  }
2682 
2683  /* daVinci node prolog. */
2684  fprintf(out, "l(\"%zx\",n(\"\",[a(\"OBJECT\",\"%s\")%s%s],[",
2685  (_uint) e, name, color, shape);
2686 
2687  MAP(EXPRESSION, son,
2688  {
2689  if (!first) fprintf(out, ",\n");
2690  else { fprintf(out, "\n"); first=false; }
2691  fprintf(out, " l(\"%zx->%zx\",e(\"\",[],r(\"%zx\")))",
2692  (_uint) e, (_uint) son, (_uint) son);
2693  },
2694  sons);
2695 
2696  /* node epilog */
2697  fprintf(out, "]))\n");
2698 
2699  MAP(EXPRESSION, son,
2700  {
2701  if (something) fprintf(out, ",");
2702  something = davinci_dump_expression_rc(out, son, seen);
2703  }, sons);
2704 
2705  return true;
2706 }
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
Definition: newgen_list.h:226
#define pips_internal_error
Definition: misc-local.h:149
uintptr_t _uint
Definition: newgen_types.h:54
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...
Definition: entity.c:453
#define ALREADY_SEEN(node)
Definition: expression.c:2631
#define DV_YELLOW
Definition: expression.c:2635
#define DV_CIRCLE
Definition: expression.c:2634
#define SEEN(node)
Definition: expression.c:2632

References ALREADY_SEEN, call_arguments, call_function, DV_CIRCLE, DV_YELLOW, entity_local_name(), EXPRESSION, expression_syntax, fprintf(), is_syntax_call, is_syntax_cast, is_syntax_range, is_syntax_reference, MAP, NIL, out, pips_internal_error, pips_user_warning, reference_variable, seen, SEEN, syntax_call, syntax_reference, and syntax_tag.

Referenced by davinci_dump_expression().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dereference_expression()

expression dereference_expression ( expression  e)

generate a newly allocated expression for *(e)

Definition at line 3934 of file expression.c.

3935 {
3936  if (expression_call_p(e))
3937  {
3938  call c = expression_call(e);
3939  if (ENTITY_ADDRESS_OF_P(call_function(c))) // e is "&x"
3940  {
3941  pips_assert("one arg to address operator (&)",
3942  gen_length(call_arguments(c))==1);
3943 
3944  // result is simply "x"
3946  }
3947  }
3948 
3949  // result is "*e"
3951  copy_expression(e));
3952 }
#define DEREFERENCING_OPERATOR_NAME
Definition: ri-util-local.h:93
#define ENTITY_ADDRESS_OF_P(e)
entity CreateIntrinsic(string name)
this function does not create an intrinsic function because they must all be created beforehand by th...
Definition: entity.c:1311
call expression_call(expression e)
Definition: expression.c:445
expression MakeUnaryCall(entity f, expression a)
Creates a call expression to a function with one argument.
Definition: expression.c:342

References call_arguments, call_function, CAR, copy_expression(), CreateIntrinsic(), DEREFERENCING_OPERATOR_NAME, ENTITY_ADDRESS_OF_P, EXPRESSION, expression_call(), expression_call_p(), gen_length(), MakeUnaryCall(), and pips_assert.

Referenced by switch_vertex_to_assign().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ divide_expression_p()

bool divide_expression_p ( expression  e)

Definition at line 1012 of file expression.c.

1014 {
1016 }
#define DIVIDE_OPERATOR_NAME

References DIVIDE_OPERATOR_NAME, and operator_expression_p().

+ Here is the call graph for this function:

◆ do_brace_expression_to_statements()

static list do_brace_expression_to_statements ( entity  arr,
expression  e,
list  curr_indices 
)
static

helper for brace_expression_to_statements

Definition at line 3396 of file expression.c.

3396  {
3397  int new_index = 0;
3398  list out = NIL;
3400  // FI: we need to know the type of arr[curr_indices] to determine
3401  // if it is a struct or an array
3402 
3403  // A reference r is built temporarily to call reference_to_type()
3404  reference r = make_reference(arr, curr_indices);
3405  // FI: I have no idea if t should be freed; no documentation for
3406  // reference_to_type()
3407  type t = reference_to_type(r);
3408  reference_indices(r) = NIL;
3409  free_reference(r);
3410 
3412  if(array_type_p(t)) {
3413  ee = int_to_expression(new_index);
3414  }
3415  else if(type_struct_variable_p(t)) {
3416  list fl = struct_type_to_fields(t);
3417  entity f = ENTITY(gen_nth(new_index, fl));
3418  ee = entity_to_expression(f);
3419  // The field will appear as an index, not as a field selector
3420  }
3421  else
3422  pips_internal_error("Unexpected type.\n");
3423 
3424  list ind = gen_append(gen_full_copy_list(curr_indices),
3425  make_expression_list(ee));
3426  if(brace_expression_p(arg)) {
3427  list out_bis = do_brace_expression_to_statements(arr, arg,ind);
3428  gen_full_free_list(ind);
3429  out = gen_append(out, out_bis);
3430  }
3431  else {
3432  reference r = make_reference(arr,NIL);
3434  // FI: the expression should be normalized and field subscripts
3435  // replaced by field accesses, with the field operator...
3436  FOREACH(expression, ie, ind) {
3437  if(expression_reference_p(ie)) {
3439  if(entity_field_p(i)) {
3440  // FI: this is not going to work for structs of arrays...
3441  // expression ne = make_op_exp(FIELD_OPERATOR_NAME, e, ie);
3442  // expression ne = make_op_exp(FIELD_OPERATOR_NAME, e, ie);
3444  expression ne = MakeBinaryCall(op, e, ie);
3445  e = ne;
3446  }
3447  else
3448  pips_internal_error("Unexpected entity.\n");
3449  }
3450  else {
3451  // list ind is memory leaked...
3452  if(expression_reference_p(e)) {
3454  CONS(expression, ie, NIL));
3455  }
3456  else {
3457  subscript s = make_subscript(e, CONS(expression, ie, NIL));
3458  syntax ss = make_syntax_subscript(s);
3460  //entity op = CreateIntrinsic(SUBSCRIPT_OPERATOR_NAME);
3461  //expression ne = MakeBinaryCall(op, e, ie);
3462  //e = ne;
3463  }
3464  }
3465  }
3466  gen_free_list(ind);
3469  )
3470  );
3471  }
3472  ++new_index;
3473  }
3474  return out;
3475 }
subscript make_subscript(expression a1, list a2)
Definition: ri.c:2327
void free_reference(reference p)
Definition: ri.c:2050
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
syntax make_syntax_subscript(subscript _field_)
Definition: ri.c:2509
void gen_full_free_list(list l)
Definition: genClib.c:1023
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
list gen_append(list l1, const list l2)
Definition: list.c:471
gen_chunk gen_nth(int n, const list l)
to be used as ENTITY(gen_nth(3, l))...
Definition: list.c:710
list gen_full_copy_list(list l)
Copy a list structure with element copy.
Definition: list.c:535
statement make_assign_statement(expression, expression)
Definition: statement.c:583
#define make_expression_list(stats...)
#define FIELD_OPERATOR_NAME
Definition: ri-util-local.h:91
#define make_statement_list(stats...)
easy list constructor
bool entity_field_p(entity e)
e is the field of a structure
Definition: entity.c:857
expression reference_to_expression(reference r)
Definition: expression.c:196
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
bool array_type_p(type)
Definition: type.c:2942
list struct_type_to_fields(type)
Definition: type.c:5798
type reference_to_type(reference)
Definition: type.c:2354
bool type_struct_variable_p(type)
Definition: type.c:3867
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755

References array_type_p(), brace_expression_p(), call_arguments, CONS, copy_expression(), CreateIntrinsic(), ENTITY, entity_field_p(), entity_to_expression(), EXPRESSION, expression_call(), expression_reference(), expression_reference_p(), expression_undefined, f(), FIELD_OPERATOR_NAME, FOREACH, free_reference(), gen_append(), gen_free_list(), gen_full_copy_list(), gen_full_free_list(), gen_nconc(), gen_nth(), int_to_expression(), make_assign_statement(), make_expression(), make_expression_list, make_reference(), make_statement_list, make_subscript(), make_syntax_subscript(), MakeBinaryCall(), NIL, normalized_undefined, out, pips_internal_error, reference_indices, reference_to_expression(), reference_to_type(), reference_variable, struct_type_to_fields(), and type_struct_variable_p().

Referenced by brace_expression_to_statements().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ do_brace_expression_to_updated_type()

static void do_brace_expression_to_updated_type ( entity  arr,
expression  e,
list  dl 
)
static

helper for brace_expression_to_updated_type

Side-effect on dl, the dimension list of e's type

Definition at line 3493 of file expression.c.

3496 {
3497  dimension d = DIMENSION(CAR(dl));
3498  expression u = dimension_upper(d);
3499  if(unbounded_expression_p(u)) {
3501  int nu = (int) gen_length(al) -1 ;
3502  expression nue = int_to_expression(nu);
3503  dimension_upper(d) = nue;
3504  free_expression(u);
3505  if(!ENDP(CDR(dl))) {
3506  // This is probably useless because only the first dimension can
3507  // be undefined
3508  expression se = EXPRESSION(CAR(al));
3510  }
3511  }
3512 }
void free_expression(expression p)
Definition: ri.c:853
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
bool unbounded_expression_p(expression e)
Definition: expression.c:4329
#define dimension_upper(x)
Definition: ri.h:982

References call_arguments, CAR, CDR, DIMENSION, dimension_upper, ENDP, EXPRESSION, expression_call(), free_expression(), gen_length(), int, int_to_expression(), and unbounded_expression_p().

Referenced by brace_expression_to_updated_type().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ do_simplify_expressions()

static void do_simplify_expressions ( call  c)
static

Definition at line 3794 of file expression.c.

3794  {
3795  for(list iter = call_arguments(c);!ENDP(iter);POP(iter)) {
3796  expression *pexp = (expression*)REFCAR(iter);
3797  simplify_expression(pexp);
3798  }
3799 }
#define REFCAR(pc)
Get the adress of the first element of a list.
Definition: newgen_list.h:119
bool simplify_expression(expression *pexp)
use polynomials to simplify an expression in some cases this operation can change the basic of the ex...
Definition: expression.c:3770

References call_arguments, ENDP, POP, REFCAR, and simplify_expression().

Referenced by simplify_expressions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ entity_to_expression()

expression entity_to_expression ( entity  e)

if v is a constant, returns a constant call.

if v is a variable, returns a reference to v.

should be a scalar variable!

Definition at line 165 of file expression.c.

166 {
167  if(entity_symbolic_p(e))
168  return call_to_expression(make_call(e, NIL));
169  else if (entity_constant_p(e))
170  return call_to_expression(make_call(e, NIL));
171  else /* should be a scalar variable! */
173 }
call make_call(entity a1, list a2)
Definition: ri.c:269
#define entity_symbolic_p(e)
#define entity_constant_p(e)
expression call_to_expression(call c)
Build an expression that call a function or procedure.
Definition: expression.c:309

References call_to_expression(), entity_constant_p, entity_symbolic_p, make_call(), make_reference(), NIL, and reference_to_expression().

Referenced by add_actual_return_code(), add_exec_mmcd(), add_index_out_effect_proc(), add_pragma_to_sequence(), adg_dataflowgraph_with_extremities(), adg_enrichir(), adg_rename_entities(), any_basic_update_operation_to_transformer(), any_update_to_transformer_list(), atom_cse_expression(), buffer_full_condition(), build_call_STEP_AllToAll(), build_call_STEP_init_regionArray(), build_call_STEP_set_recvregions(), build_call_STEP_set_sendregions(), c_convex_effects_on_actual_parameter_forward_translation(), C_MakeReturnStatement(), call_STEP_subroutine(), call_STEP_subroutine3(), comEngine_generate_procCode(), compile_master(), compile_one_reduction(), compile_reduction(), compute_HRE_memory_mapping(), compute_points_to_binded_set(), compute_region(), controlize_distribution(), ctx_generate_new_statement_cluster_dependant(), declaration_statement_to_points_to(), declaration_to_post_pv(), define_node_processor_id(), derived_formal_parameter_to_stub_points_to(), dimensions_to_dma(), distribute_code(), do_array_to_pointer_walk_expression(), do_atomize_call(), do_brace_expression_to_statements(), do_clone_statement(), do_gather_all_expressions(), do_group_constants_terapix(), do_loop_expansion(), do_loop_nest_unswitching(), do_loop_to_for_loop(), do_loop_to_while_loop(), do_loop_unroll_with_epilogue(), do_loop_unroll_with_prologue(), do_outliner_smart_replacment(), do_point_to(), do_scalar_renaming_in_successors(), do_solve_hardware_constraints_on_volume(), do_split_structure(), do_symbolic_tiling(), do_terapix_argument_handler(), entities_to_expressions(), entities_to_expressions2(), expression_multiply_sizeof_to_transformer(), find_or_create_allocatable_struct(), fix_loop_index_sign(), for_to_do_loop_conversion(), freia_add_image_arguments(), freia_copy_image(), full_loop_unroll(), fusion(), fusion_buffer(), gen_if_rank(), Generate_C_ReturnStatement(), generate_call_compute_loopslices(), generate_call_get_commsize(), generate_call_get_rank(), generate_call_get_rank_loopbounds(), generate_call_get_workchunk_loopbounds(), generate_call_set_regionarray(), generate_code_loop(), generate_exec_statement(), generate_fifo_stat(), generate_fifo_stat2(), generate_ind_fifo_stat2(), generate_load_statement(), generate_loop_workchunk(), generate_mmcd_stat_from_ref(), generate_optimized_code_for_loop_nest(), generate_parallel_body(), generate_return_code_checks(), generate_save_statement(), generate_subarray_shift(), get_allocatable_data_expr(), get_fifoExp_from_ref(), get_indExp_from_ref(), gfc2pips_int2expression(), gfc2pips_logical2expression(), gfc2pips_real2expression(), gfc2pips_symbol2data_instruction(), hpfc_add_n(), hpfc_broadcast_buffers(), hpfc_broadcast_if_necessary(), hpfc_buffer_reference(), hpfc_compute_lid(), hpfc_gen_n_vars_expr(), hpfc_generate_message(), hpfc_hmessage(), hpfc_initsend(), hpfc_lazy_buffer_packing(), hpfc_lazy_guard(), hpfc_message(), hpfc_translate_call_with_distributed_args(), if_different_pe_and_not_twin(), image_free(), initialize_scalar_variable(), inline_expression_call(), inline_return_crawler(), inline_split_declarations(), insert_check_alias_before_statement(), intrinsic_call_to_points_to(), isolate_patch_reference(), loop_bound_evaluation_to_transformer(), loop_flt(), loop_rewrite(), loop_strip_mine(), loopbounds_substitution(), make_array_communication_statement(), make_assignement_statement(), make_body_from_loop(), make_C_print_statement(), make_communication_statement(), make_condition_from_loop(), make_dma_transfert(), make_exec_mmcd(), make_expression_with_state_variable(), make_factor_expression(), make_fields_assignment_instruction(), make_guard_expression(), make_increment_statement(), make_init_newInd_stat(), make_initialization_from_loop(), make_lInitStats(), make_loop_nest_for_overlap(), make_loop_step_stat(), make_loopStat1(), make_lSwitchStats(), make_mmcd_load_store_stat(), make_mmcd_stats_from_ref(), make_read_loopbody(), make_scalar_communication_module(), make_scanning_over_tiles(), make_send_receive_conversion(), make_set_rc_statement(), make_shuffle_statement(), make_start_ru_module(), make_state_variable_assignement_statement(), make_step_inc_statement(), make_temporary_scalar_entity(), make_toggle_inc_statement(), make_toggle_init_statement(), make_toggle_mmcd(), make_transStat(), MakeAssignedGotoInst(), MakeAssignedOrComputedGotoInst(), MakeDoInst(), modulo_to_transformer(), monome_to_expression(), move_declaration_control_node_declarations_to_statement(), mpi_initialize(), mpic_make_mpi_comm_rank(), mpic_make_mpi_comm_size(), mpic_make_mpi_finalize(), mpic_make_mpi_init(), mpic_make_mpi_irecv(), mpic_make_mpi_isend(), mpic_make_mpi_recv(), mpic_make_mpi_send(), mppa_compile_dag(), mppa_helper_args_params(), mylid_ne_lid(), new_local_image_variable(), normalize_microcode(), outliner_extract_loop_bound(), outliner_parameters(), outliner_patch_parameters(), perform_array_element_substitutions_in_transformer(), pointer_values_remove_var(), process_innerStat1_proc(), process_opt_replace(), Pvecteur_to_assign_statement(), reference_add_field_dimension(), reference_to_points_to(), regenerate_toggles(), region_to_address(), regions_to_loops(), rename_statement_declarations(), replace_field_by_reference_walker(), replace_indices_region(), replace_indices_region_com(), sc_delimiter(), scalar_to_array(), scalopify(), sequence_to_post_pv(), sesamify(), set_aipo_call(), simd_atomize_this_expression(), simd_loop_unroll(), simple_reference_add_field_dimension(), simplify_subscript(), split_complex_expression(), split_initializations_in_statement(), st_generate_packing(), statement_compute_bounds(), step_symbolic_expression(), string_to_expression(), struct_initialization_to_points_to(), struct_variable_to_pointer_locations(), struct_variable_to_pointer_subscripts(), substitute_struct_stub_in_transformer(), systeme_to_loop_nest(), terapix_loop_handler(), transformer_apply_field_assignments_or_equalities(), transformer_apply_unknown_field_assignments_or_equalities(), translate_to_module_frame(), typedef_formal_parameter_to_stub_points_to(), unsugared_loop_header(), unsugared_loop_inc(), unsugared_loop_test(), update_indices_for_local_computation(), update_reflhs_with_rhs_to_transformer(), usual_loop_tiling(), and verify_scalar_variable().

+ Here is the call graph for this function:

◆ expr_flt()

static bool expr_flt ( expression  e)
static

Definition at line 2720 of file expression.c.

2721 {
2723  return false;
2724 }
void davinci_dump_expression(FILE *out, expression e)
dump expression e in file out as a davinci graph.
Definition: expression.c:2710

References davinci_dump_expression(), and out_flt.

Referenced by davinci_dump_all_expressions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expr_rwt()

static void expr_rwt ( expression  e)
static

hack: clean all normalize fields...

Definition at line 4093 of file expression.c.

4094 {
4096  {
4099  }
4100 }
void free_normalized(normalized p)
Definition: ri.c:1407
#define normalized_undefined_p(x)
Definition: ri.h:1746

References expression_normalized, free_normalized(), normalized_undefined, and normalized_undefined_p.

Referenced by clean_all_normalized().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_address_of_p()

bool expression_address_of_p ( expression  e)

Definition at line 420 of file expression.c.

421 {
422  bool address_p = false;
423  syntax s = expression_syntax(e);
424  if(syntax_call_p(s)) {
425  call c = syntax_call(s);
426  entity f = call_function(c);
428  address_p = true;
429  }
430  return address_p;
431 }

References call_function, ENTITY_ADDRESS_OF_P, expression_syntax, f(), syntax_call, and syntax_call_p.

Referenced by freia_reduction_variable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_application()

application expression_application ( expression  e)

Definition at line 485 of file expression.c.

486 {
488 }
#define syntax_application(x)
Definition: ri.h:2748

References expression_syntax, and syntax_application.

Referenced by expression_to_transformer().

+ Here is the caller graph for this function:

◆ expression_application_p()

bool expression_application_p ( expression  e)

Duplicate bool expression_subscript_p(expression e) { return(syntax_subscript_p(expression_syntax(e))); }.

subscript expression_subscript(expression e) { return(syntax_subscript(expression_syntax(e))); }

Definition at line 480 of file expression.c.

481 {
483 }
#define syntax_application_p(x)
Definition: ri.h:2746

References expression_syntax, and syntax_application_p.

Referenced by expression_to_transformer().

+ Here is the caller graph for this function:

◆ expression_brace_p()

bool expression_brace_p ( expression  e)

predicates and short cut accessors on expressions

Definition at line 407 of file expression.c.

407  {
408  if(expression_call_p(e)) {
409  call c = expression_call(e);
411  }
412  return false;
413 }

References call_function, ENTITY_BRACE_INTRINSIC_P, expression_call(), and expression_call_p().

Referenced by do_convert_this_array_to_pointer_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_call()

call expression_call ( expression  e)

Definition at line 445 of file expression.c.

446 {
447  return(syntax_call(expression_syntax(e)));
448 }

References expression_syntax, and syntax_call.

Referenced by address_of_scalar(), any_expression_to_transformer(), atomize_call(), atomize_call_filter(), atomize_call_statement(), atomize_this_expression(), cleanup_subscript_pre(), compact_phi_functions(), compute_points_to_binded_set(), copy_from_statement(), copy_to_statement(), dereference_expression(), distance_between_expression(), do_array_to_pointer_patch_call_expression(), do_brace_expression_to_statements(), do_brace_expression_to_updated_type(), do_expression_reduction(), do_group_constant_entity(), do_linearize_array_init(), do_linearize_array_manage_callers(), do_linearize_prepatch_subscript(), do_linearize_remove_dereferencment_walker(), do_loop_nest_unswitching(), do_reduction_detection(), do_reduction_propagation(), do_simplify_constant_address_expression(), do_split_structure(), do_split_structure_return_hook_walker(), expr_cse_flt(), expression_allocatable_data_access_p(), expression_brace_p(), expression_equal_or_opposite_p(), expression_field_p(), expression_minmax_p(), expression_opposite_p(), expression_string_constant(), expression_string_constant_p(), expression_to_transformer(), filter_variables_in_pragma_expr(), find_entities_to_wrap(), for_to_do_loop_conversion(), freia_alloc_stat_p(), freia_reduction_variable(), get_complement_expression(), guess_late_read_effect_on_entity(), guess_loop_increment(), guess_loop_increment_walker(), guess_loop_lower_bound(), initialization_list_to_statements(), make_address_of_expression(), make_loadsave_statement(), make_send_receive_conversion(), pragma_omp_merge_expr(), pragma_omp_p(), pragma_PRAGMA_DISTRIBUTED_p(), reference_filter(), remove_expression_from_comma_list(), remove_simple_scalar_pointers(), remove_unread_variable(), reorder_pointer_expression(), replace_entity_by_expression_expression_walker(), replace_instruction_similar_to_pattern(), rssp_ref(), simplify_complex_expression(), simplify_minmax_expression(), skip_field_and_cast_expression(), statement_has_omp_parallel_directive_p(), statement_phi_function_p(), statement_remove_omp_clauses(), terapix_loop_optimizer(), terapix_normalize_tests(), terapixify_loops(), two_addresses_code_generator(), two_addresses_code_generator_split_p(), user_function_call_to_transformer(), and zero_expression_p().

◆ expression_call_p()

bool expression_call_p ( expression  e)

Definition at line 415 of file expression.c.

416 {
417  return(syntax_call_p(expression_syntax(e)));
418 }

References expression_syntax, and syntax_call_p.

Referenced by actual_label_replacement_p(), address_of_scalar(), alloc_instrumentation(), any_expression_to_transformer(), atomize_call(), atomize_call_filter(), atomize_call_statement(), atomize_this_expression(), brace_expression_p(), c_brace_expression_p(), change_basic_if_needed(), cleanup_subscript_pre(), comma_expression_p(), complex_constant_expression_p(), compute_points_to_binded_set(), condition_to_transformer(), controlize_statement(), copy_from_statement(), copy_to_statement(), dereference_expression(), do_array_to_pointer_patch_call_expression(), do_expression_reduction(), do_group_constant_entity(), do_linearize_array_init(), do_linearize_array_manage_callers(), do_linearize_prepatch_subscript(), do_linearize_remove_dereferencment_walker(), do_reduction_detection(), do_reduction_propagation(), do_simplify_constant_address_expression(), expr_flt(), expression_allocatable_data_access_p(), expression_brace_p(), expression_field_p(), expression_implied_do_p(), expression_list_directed_p(), expression_minmax_p(), expression_reference_number(), expression_string_constant_p(), expression_to_int(), expression_to_transformer(), expression_try_find_size(), find_entities_to_wrap(), find_implicit_goto(), find_target_position(), freia_alloc_stat_p(), get_complement_expression(), guess_late_read_effect_on_entity(), guess_loop_increment(), guess_loop_increment_walker(), guess_loop_lower_bound(), initialization_list_to_statements(), inline_expression(), interprocedural_abc_expression(), is_this_op(), logical_operator_expression_p(), make_address_of_expression(), MakeReturn(), number_of_initial_values(), number_of_operators_flt(), parser_macro_expansion(), pragma_omp_p(), pragma_PRAGMA_DISTRIBUTED_p(), process_static_initialization(), reference_filter(), regenerate_call(), relational_expression_p(), remove_expression_from_comma_list(), remove_unread_variable(), reorder_pointer_expression(), replace_entity_by_expression_expression_walker(), replace_subscript(), rssp_ref(), sentence_data_statement(), simplify_complex_expression(), SizeOfArray(), statement_has_omp_parallel_directive_p(), statement_phi_function_p(), statement_remove_omp_clauses(), store_initial_value(), switch_specific_cmplx(), switch_specific_dcmplx(), terapix_loop_optimizer(), terapix_normalize_tests(), terapixify_loops(), two_addresses_code_generator(), two_addresses_code_generator_split_p(), words_assign_op(), words_dimension(), words_infix_binary_op(), words_infix_nary_op(), words_regular_call(), words_subexpression(), and zero_expression_p().

◆ expression_cast()

cast expression_cast ( expression  e)

Definition at line 455 of file expression.c.

456 {
457  return(syntax_cast(expression_syntax(e)));
458 }

References expression_syntax, and syntax_cast.

Referenced by condition_to_transformer(), expression_null_p(), expression_to_transformer(), MakeCaseStatement(), and words_subexpression().

+ Here is the caller graph for this function:

◆ expression_cast_p()

bool expression_cast_p ( expression  e)

Definition at line 450 of file expression.c.

451 {
452  return(syntax_cast_p(expression_syntax(e)));
453 }

References expression_syntax, and syntax_cast_p.

Referenced by condition_to_transformer(), expression_null_p(), expression_to_transformer(), MakeCaseStatement(), and words_subexpression().

+ Here is the caller graph for this function:

◆ expression_constant()

constant expression_constant ( expression  exp)

This function returns a "constant" object if the expression is a constant such as 10, -11 or 2.345 or "foo".

Expressions such as "5+0" or "sizeof(int)" or "m", with m defined as "const int m = 2;" or "M" with M defined as PARAMETER do not qualify. However their value is constant, i.e. store independent, and can be evaluated using EvalExpression().

FI: difficult to make a decision here. We may have a constant expression that cannot be evaluated as a constant statically by PIPS. What is the semantics of expression_constant_p()?

&& get_bool_property("EVAL_SIZEOF")

Too bad we need a function located in eval.c ...

Might be a reference to a scalar constant.

Parameters
expxp

Definition at line 2347 of file expression.c.

2348 {
2350  if(syntax_call_p(s))
2351  {
2354  switch(value_tag(v))
2355  {
2356  case is_value_constant:
2357  return value_constant(v);
2358  case is_value_intrinsic: {
2359  entity op = call_function(c);
2362  }
2363  default:
2364  ;
2365  }
2366  }
2367  else if(false && syntax_sizeofexpression_p(s)) {
2369  /* FI: difficult to make a decision here. We may have a constant
2370  expression that cannot be evaluated as a constant statically by
2371  PIPS. What is the semantics of expression_constant_p()? */
2372  if(sizeofexpression_type_p(soe) /* && get_bool_property("EVAL_SIZEOF")*/ ) {
2373  /* Too bad we need a function located in eval.c ... */
2374  value v = EvalSizeofexpression(soe);
2375  if(value_constant_p(v)) { // Should always be true...
2376  constant c = value_constant(v);
2378  free_value(v);
2379  return c;
2380  }
2381  }
2382  }
2383  else if(false && syntax_reference_p(s)) {
2384  /* Might be a reference to a scalar constant. */
2385  reference r = syntax_reference(s);
2386  entity v = reference_variable(r);
2387  if(const_variable_p(v)) {
2388  value val = entity_initial(v);
2389  if(value_constant_p(val)) {
2391  return c;
2392  }
2393  }
2394  }
2395  return constant_undefined;
2396 }
constant copy_constant(constant p)
CONSTANT.
Definition: ri.c:359
void free_value(value p)
Definition: ri.c:2787
#define ENTITY_UNARY_MINUS_P(e)
#define ENTITY_UNARY_PLUS_P(e)
value EvalSizeofexpression(sizeofexpression soe)
Definition: eval.c:210
constant expression_constant(expression exp)
This function returns a "constant" object if the expression is a constant such as 10,...
Definition: expression.c:2347
bool const_variable_p(entity)
Definition: variable.c:1687
#define syntax_reference_p(x)
Definition: ri.h:2728
#define value_constant(x)
Definition: ri.h:3073
@ is_value_intrinsic
Definition: ri.h:3034
#define value_constant_p(x)
Definition: ri.h:3071
#define constant_undefined
Definition: ri.h:802

References binary_call_lhs, call_function, const_variable_p(), constant_undefined, copy_constant(), entity_initial, ENTITY_UNARY_MINUS_P, ENTITY_UNARY_PLUS_P, EvalSizeofexpression(), exp, expression_syntax, free_value(), is_value_constant, is_value_intrinsic, reference_variable, sizeofexpression_type_p, syntax_call, syntax_call_p, syntax_reference, syntax_reference_p, syntax_sizeofexpression, syntax_sizeofexpression_p, value_constant, value_constant_p, and value_tag.

Referenced by expression_constant_p(), and words_dimension().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_constant_p()

bool expression_constant_p ( expression  exp)

================================================================

Overlap Management Module for HPFC Fabien Coelho, August 1993.

HPFC module by Fabien COELHO.

bool expression_constant_p(expression exp) Returns true if "exp" is an (integer) constant value.

Note : A negativePositive constant can be represented with a call to the unary minus/plus intrinsic function upon a positive value.

See below extended_expression_constant_p() for a more general function.

Parameters
expxp

Definition at line 2453 of file expression.c.

2454 {
2456 }
#define constant_undefined_p(x)
Definition: ri.h:803

References constant_undefined_p, exp, and expression_constant().

Referenced by add_const_expr_p(), analyze_expression(), array_indices_check(), array_size_stride(), atom_cse_expression(), atomize_this_expression(), compute_final_index_value(), constant_step_loop_p(), constraints_to_loop_bound(), convert_bound_expression(), do_loop_expansion(), do_loop_expansion_init(), do_solve_hardware_constraints_on_volume(), effect_field_dimension_entity(), equal_must_vreference(), expression_equal_integer_p(), expression_null_p(), expression_plusplus(), expression_string_constant_p(), expression_to_float(), expression_to_int(), expression_to_polynome(), expression_try_find_size(), formal_variable_add_aliases(), freia_insert_added_stats(), have_null_value_in_pointer_expression_p(), incrementation_expression_to_increment(), inline_expression_call(), loop_annotate(), loop_normalize_of_loop(), make_loadsave_statement(), make_max_exp(), make_send_receive_conversion(), MakeCaseStatement(), MakeEquivAtom(), malloc_arg_to_type(), normalizable_loop_p(), opkill_may_vreference(), opkill_must_vreference(), overlap_redefine_expression(), plc_make_dim(), points_to_compare_cell(), points_to_compare_cells(), points_to_compare_location(), points_to_compare_ptr_cell(), process_true_call_stat(), rational_op_exp(), references_do_not_conflict_p(), replace_subscript(), simplify_C_expression(), size_of_actual_array(), size_of_dummy_array(), sp_feautrier_expression_p(), splc_feautrier_expression_p(), stmt_bdt_directions(), subscript_value(), subscript_value_stride(), terapixify_loops(), valuer(), and words_dimension().

+ Here is the call graph for this function:

◆ expression_equal_in_list_p()

bool expression_equal_in_list_p ( expression  e,
list  le 
)

This function returns true, if there exists an expression equal in the list false, otherwise.

Parameters
lee

Definition at line 566 of file expression.c.

567 {
568  MAP(EXPRESSION, f, if (expression_equal_p(e,f)) return true, le);
569  return false;
570 }

References EXPRESSION, expression_equal_p(), f(), and MAP.

Referenced by pragma_omp_merge_expr().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_equal_integer_p()

bool expression_equal_integer_p ( expression  exp,
int  i 
)

◆ expression_equal_or_opposite_p()

bool expression_equal_or_opposite_p ( expression  e1,
expression  e2 
)

e1==e2 or -e1==e2 or e1==-e2 syntactically

Parameters
e11
e22

Definition at line 1366 of file expression.c.

1367 {
1368  bool equal_or_opposite_p = false;
1369  if(expression_equal_p(e1,e2)) {
1370  equal_or_opposite_p = true;
1371  }
1373  call c1 = expression_call(e1);
1375  equal_or_opposite_p = expression_equal_p(e11, e2);
1376  }
1378  call c2 = expression_call(e2);
1380  equal_or_opposite_p = expression_equal_p(e1, e22);
1381  }
1382  return equal_or_opposite_p;
1383 }
#define unary_intrinsic_expression(name, e)
Building quickly bool expressions, FC.
#define UNARY_MINUS_OPERATOR_NAME

References call_arguments, CAR, EXPRESSION, expression_call(), expression_equal_p(), unary_intrinsic_expression, and UNARY_MINUS_OPERATOR_NAME.

+ Here is the call graph for this function:

◆ expression_equal_p()

bool expression_equal_p ( expression  e1,
expression  e2 
)

Syntactic equality e1==e2.

Add expression_undefined tests to avoid segmentation fault

let's assume that every expression has a correct syntax component

Parameters
e11
e22

Definition at line 1347 of file expression.c.

1348 {
1349  syntax s1, s2;
1350 
1351  /* Add expression_undefined tests to avoid segmentation fault */
1352 
1354  return true;
1356  return false;
1357 
1358  /* let's assume that every expression has a correct syntax component */
1359  s1 = expression_syntax(e1);
1360  s2 = expression_syntax(e2);
1361 
1362  return syntax_equal_p(s1, s2);
1363 }
bool syntax_equal_p(syntax s1, syntax s2)
Definition: expression.c:1462
s1
Definition: set.c:247

References expression_syntax, expression_undefined_p, s1, and syntax_equal_p().

Referenced by bitwise_xor_to_transformer(), bottom_up_abc_base_reference_implied_do(), call_equal_p(), cast_equal_p(), compact_phi_functions(), compatible_points_to_subscripts_p(), convex_cell_reference_preceding_p(), dimension_equal_p(), do_expressions_to_vector(), effect_comparable_p(), effect_may_union(), effect_must_union(), expr_rwt(), expression_eq_in_list_p(), expression_equal_in_list_p(), expression_equal_or_opposite_p(), expression_flt(), expression_lists_equal_p(), expression_opposite_p(), find_equal_expression_not_in_list(), forward_substitute_array_location_in_transformer(), generic_basic_equal_p(), integer_multiply_to_transformer(), lexpression_equal_p(), loop_rewrite(), lrange_larger_p(), make_permutations_indexes(), make_simd_statement(), opkill_may_vreference(), opkill_must_vreference(), partial_eval_plus_or_minus_operator(), points_to_reference_included_p(), range_equal_p(), reference_equal_p(), reference_to_points_to_translations(), references_must_conflict_p(), same_alignment_in_list_p(), same_alignment_p(), same_distribute_p(), same_distribution_p(), same_expression_p(), similarity(), simple_cell_reference_preceding_p(), simple_cells_inclusion_p(), simple_cells_intersection_p(), simple_pv_may_union(), simple_pv_must_union(), sizeofexpression_equal_p(), subscript_equal_p(), switch_vertex_to_assign(), terapix_loop_optimizer(), terapixify_loops(), two_addresses_code_generator(), and update_vector_to_expressions().

+ Here is the call graph for this function:

◆ expression_field_p()

bool expression_field_p ( expression  e)

The expression is of kind "s.a", where "s" is a struct and a "a" field.

Definition at line 491 of file expression.c.

492 {
493  return expression_call_p(e)
495 }
#define ENTITY_FIELD_P(e)
C data structure and pointer management.

References call_function, ENTITY_FIELD_P, expression_call(), and expression_call_p().

Referenced by adapt_reference_to_type(), distance_between_expression(), expression_reference_or_field_p(), make_loadsave_statement(), replace_subscript(), and skip_field_and_cast_expression().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_implied_do_p()

bool expression_implied_do_p ( )

Definition at line 817 of file expression.c.

819 {
820  if (expression_call_p(e)) {
822  entity e = call_function(c);
823 
824  return(strcmp(entity_local_name(e), IMPLIED_DO_NAME) == 0);
825  }
826 
827  return(false);
828 }
#define IMPLIED_DO_NAME
Definition: ri-util-local.h:75

References call_function, entity_local_name(), expression_call_p(), expression_syntax, IMPLIED_DO_NAME, and syntax_call.

Referenced by bottom_up_abc_expression(), bottom_up_abc_expression_implied_do(), comp_regions_of_implied_do(), comp_regions_of_iolist(), expression_in_array_subscript(), FortranExpressionList(), initial_code_abc_expression(), MakeFortranBinaryCall(), and MakeFortranUnaryCall().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_integer_constant_p()

bool expression_integer_constant_p ( expression  e)

I hope a short evaluation is made by the compiler

Definition at line 2417 of file expression.c.

2419 {
2420  syntax s = expression_syntax(e);
2422 
2423  if ((n!=normalized_undefined) && (normalized_linear_p(n)))
2424  {
2425  Pvecteur v = normalized_linear(n);
2426  int s = vect_size(v);
2427 
2428  if (s==0) return(true);
2429  if (s>1) return(false);
2430  return((s==1) && value_notzero_p(vect_coeff(TCST,v)));
2431  }
2432  else
2433  if (syntax_call_p(s))
2434  {
2435  call c = syntax_call(s);
2437 
2438  /* I hope a short evaluation is made by the compiler */
2439  return((value_constant_p(v)) && (constant_int_p(value_constant(v))));
2440  }
2441 
2442  return(false);
2443 }
#define value_notzero_p(val)
int vect_size(Pvecteur v)
package vecteur - reductions
Definition: reductions.c:47
#define normalized_linear_p(x)
Definition: ri.h:1779
#define constant_int_p(x)
Definition: ri.h:848

References call_function, constant_int_p, entity_initial, expression_normalized, expression_syntax, normalized_linear, normalized_linear_p, normalized_undefined, syntax_call, syntax_call_p, TCST, value_constant, value_constant_p, value_notzero_p, vect_coeff(), and vect_size().

Referenced by array_access_to_array_ranges(), do_solve_hardware_constraints_on_volume(), generate_optimized_code_for_loop_nest(), hpfc_decision(), loop_flt(), and points_to_reference_to_type().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_intrinsic_operation_p()

bool expression_intrinsic_operation_p ( expression  exp)

bool expression_intrinsic_operation_p(expression exp): Returns true if "exp" is an expression with a call to an intrinsic operation.

Parameters
expxp

Definition at line 1949 of file expression.c.

1950 {
1951  entity e;
1952  syntax syn = expression_syntax(exp);
1953 
1954  if (syntax_tag(syn) != is_syntax_call)
1955  return (false);
1956 
1957  e = call_function(syntax_call(syn));
1958 
1960 }

References call_function, entity_initial, exp, expression_syntax, is_syntax_call, is_value_intrinsic, syntax_call, syntax_tag, and value_tag.

Referenced by atomizer_of_test().

+ Here is the caller graph for this function:

◆ expression_is_C_rhs_p()

bool expression_is_C_rhs_p ( expression  exp)

Not all expressions can be used as right-hand side (rhs) in C assignments.

PIPS expressions used to encode initializations such as

"{ 1, 2, 3}"

in

"int k[] = { 1, 2, 3 };" cannot be used as rhs.

There are probably many more cases, especially with Fortran-specific expressions, e.g. IO expressions. But we do not have a way to know if an intrinsic is a Fortran or a C or a shared intrinsic. The information is not carried by PIPS internal representation and hence not initialized in bootstrap.

Note: this test is too restrictive as the condition depends on the type of the lhs. A struct can be assigned a brace expression. So a type argument should be passed to make such decisions.

"s = { 1, 2, 3};" is ok if s is a struct with three integer compatible fields.

Parameters
expxp

Definition at line 2582 of file expression.c.

2583 {
2584  bool is_rhs_p = false;
2585 
2586  is_rhs_p = !brace_expression_p(exp);
2587 
2588  return is_rhs_p;
2589 }

References brace_expression_p(), and exp.

Referenced by redeclaration_enter_statement(), and split_initializations_in_statement().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_list_directed_p()

bool expression_list_directed_p ( )

Definition at line 844 of file expression.c.

846 {
847  if (expression_call_p(e)) {
849  entity e = call_function(c);
850 
851  return(strcmp(entity_local_name(e), LIST_DIRECTED_FORMAT_NAME) == 0);
852  }
853 
854  return(false);
855 }
#define LIST_DIRECTED_FORMAT_NAME
Definition: naming-local.h:97

References call_function, entity_local_name(), expression_call_p(), expression_syntax, LIST_DIRECTED_FORMAT_NAME, and syntax_call.

+ Here is the call graph for this function:

◆ expression_list_to_binary_operator_call()

expression expression_list_to_binary_operator_call ( list  l,
entity  op 
)
Parameters
opp

Definition at line 1917 of file expression.c.

1918 {
1919  int
1920  len = gen_length(l);
1921  expression
1922  result = expression_undefined;
1923 
1924  pips_assert("list_to_binary_operator_call", len!=0);
1925 
1926  result = EXPRESSION(CAR(l));
1927 
1928  MAPL(ce,
1929  {
1930  result = MakeBinaryCall(op, EXPRESSION(CAR(ce)), result);
1931  },
1932  CDR(l));
1933 
1934  return(result);
1935 }
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
Definition: newgen_list.h:203

References CAR, CDR, EXPRESSION, expression_undefined, gen_length(), MakeBinaryCall(), MAPL, and pips_assert.

Referenced by compute_region(), expression_list_to_conjonction(), and top_down_abc_not_exact_case().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_list_to_conjonction()

expression expression_list_to_conjonction ( list  l)

Definition at line 1937 of file expression.c.

1938 {
1939  int len = gen_length(l);
1941  return(len==0?
1942  MakeNullaryCall(entity_intrinsic(".TRUE.")):
1944 }
#define AND_OPERATOR_NAME
FI: intrinsics are defined at a third place after bootstrap and effects! I guess the name should be d...
expression expression_list_to_binary_operator_call(list l, entity op)
Definition: expression.c:1917

References AND_OPERATOR_NAME, entity_intrinsic(), expression_list_to_binary_operator_call(), gen_length(), and MakeNullaryCall().

Referenced by alias_check_scalar_and_array_variables_in_caller(), alias_check_scalar_and_array_variables_in_module(), alias_check_two_array_variables_in_caller(), alias_check_two_array_variables_in_module(), alias_check_two_scalar_variables_in_caller(), alias_check_two_scalar_variables_in_module(), make_guard_expression(), and Psysteme_to_expression().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_lists_equal_p()

bool expression_lists_equal_p ( list  l1,
list  l2 
)
Parameters
l11
l22

Definition at line 1405 of file expression.c.

1406 {
1407  bool equal_p = true;
1408  list cl1 = l1, cl2 = l2;
1409  while(!ENDP(cl1) && !ENDP(cl2)) {
1410  expression e1 = EXPRESSION(CAR(cl1));
1411  expression e2 = EXPRESSION(CAR(cl2));
1412  if(!expression_equal_p(e1, e2)) {
1413  equal_p = false;
1414  break;
1415  }
1416  POP(cl1), POP(cl2);
1417  }
1418  if(equal_p)
1419  equal_p = ENDP(cl1) && ENDP(cl2);
1420  return equal_p;
1421 }

References CAR, ENDP, EXPRESSION, expression_equal_p(), and POP.

Referenced by reference_to_points_to_translations().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_minmax_p()

bool expression_minmax_p ( expression  e)
Returns
true if expression e is a min or a max

Definition at line 3882 of file expression.c.

3883 {
3884  if(expression_call_p(e))
3885  {
3887  return ENTITY_MIN_P(op) || ENTITY_MAX_P(op);
3888  }
3889  return false;
3890 }
#define ENTITY_MAX_P(e)
#define ENTITY_MIN_P(e)

References call_function, ENTITY_MAX_P, ENTITY_MIN_P, expression_call(), and expression_call_p().

Referenced by do_loop_nest_unswitching(), region_to_minimal_dimensions(), and simplify_minmax_expression().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_mult()

expression expression_mult ( expression  ex)
Parameters
exx

Definition at line 156 of file expression.c.

157 {
158  pips_internal_error("not implemented");
159  return ex;
160 }

References pips_internal_error.

◆ expression_normalize_subscripts()

void expression_normalize_subscripts ( expression  e)

To be used for initialization expressions.

Definition at line 4465 of file expression.c.

4466 {
4468 }
void normalize_subscript_expression(expression e)
Normalization of subscript in expressions.
Definition: expression.c:4407

References expression_domain, gen_recurse, gen_true(), and normalize_subscript_expression().

+ Here is the call graph for this function:

◆ expression_null_p()

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 (void *) 0).

Parameters
expxp

Definition at line 2611 of file expression.c.

2612 {
2613  bool null_p = false;
2614  if (expression_cast_p(exp))
2616  else if (expression_reference_p(exp))
2617  {
2619  }
2620  else
2621  {
2623  null_p = (expression_to_int(exp) == 0);
2624  }
2625  return null_p;
2626 }
#define same_string_p(s1, s2)
bool expression_cast_p(expression e)
Definition: expression.c:450
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...
Definition: expression.c:2611
cast expression_cast(expression e)
Definition: expression.c:455
entity expression_variable(expression e)
Definition: expression.c:532

References cast_expression, entity_local_name(), exp, expression_cast(), expression_cast_p(), expression_constant_p(), expression_reference_p(), expression_to_int(), expression_variable(), and same_string_p.

Referenced by equal_condition_to_points_to(), freeable_points_to_cells(), have_null_value_in_pointer_expression_p(), non_equal_condition_to_points_to(), and pointer_expression_to_transformer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_one_p()

bool expression_one_p ( expression  exp)
Parameters
expxp

Definition at line 2591 of file expression.c.

2592 {
2593  bool one_p = false;
2594 
2598 
2599  if(value_constant_p(v)) {
2600  constant c = value_constant(v);
2601  one_p = constant_int_p(c) && (constant_int(c)==1);
2602  }
2603  }
2604  return one_p;
2605 }
#define constant_int(x)
Definition: ri.h:850

References call_function, constant_int, constant_int_p, entity_initial, exp, expression_syntax, syntax_call, syntax_call_p, value_constant, and value_constant_p.

Referenced by ensure_comment_consistency().

+ Here is the caller graph for this function:

◆ expression_opposite_p()

bool expression_opposite_p ( expression  e1,
expression  e2 
)

e1+e2==0, i.e.

-e1==e2 or e1==-e2 syntactically

Parameters
e11
e22

Definition at line 1386 of file expression.c.

1387 {
1388  bool opposite_p = false;
1389 
1390  if(unary_minus_expression_p(e1)) {
1391  call c1 = expression_call(e1);
1393  opposite_p = expression_equal_p(e11, e2);
1394  }
1395  else if(unary_minus_expression_p(e2)) {
1396  call c2 = expression_call(e2);
1398  opposite_p = expression_equal_p(e1, e22);
1399  }
1400  return opposite_p;
1401 }
bool unary_minus_expression_p(expression e)
Definition: expression.c:1030

References call_arguments, CAR, EXPRESSION, expression_call(), expression_equal_p(), and unary_minus_expression_p().

Referenced by integer_multiply_to_transformer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_pointer_p()

bool expression_pointer_p ( expression  e)

we get the type of the expression by calling expression_to_type() which allocates a new one.

Then we call ultimate_type() to have the final type. Finally we test if it's a pointer by using pointer_type_p().

Definition at line 506 of file expression.c.

506  {
507  type et = expression_to_type(e);
508  type t = ultimate_type(et);
509  return pointer_type_p(t);
510 
511 }
type ultimate_type(type)
Definition: type.c:3466
type expression_to_type(expression)
For an array declared as int a[10][20], the type returned for a[i] is int [20].
Definition: type.c:2486
bool pointer_type_p(type)
Check for scalar pointers.
Definition: type.c:2993

References expression_to_type(), pointer_type_p(), and ultimate_type().

Referenced by atom_cse_expression(), cse_call_flt(), derived_formal_parameter_to_stub_points_to(), do_terapix_pointer_initialized_from_a_mask_p(), glc_call(), points_to_cells_pointer_arguments(), and typedef_formal_parameter_to_stub_points_to().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_range()

range expression_range ( expression  e)

Definition at line 1853 of file expression.c.

1854 {
1855  pips_assert("is a range", expression_range_p(e));
1856  return syntax_range(expression_syntax(e));
1857 }
bool expression_range_p(expression e)
Definition: expression.c:1848

References expression_range_p(), expression_syntax, pips_assert, and syntax_range.

+ Here is the call graph for this function:

◆ expression_range_p()

bool expression_range_p ( expression  e)

Definition at line 1848 of file expression.c.

1849 {
1850  return syntax_range_p(expression_syntax(e));
1851 }

References expression_syntax, and syntax_range_p.

Referenced by expression_range(), and generic_atomic_points_to_reference_p().

+ Here is the caller graph for this function:

◆ expression_reference()

reference expression_reference ( expression  e)

Short cut, meaningful only if expression_reference_p(e) holds.

Definition at line 1832 of file expression.c.

1833 {
1834  pips_assert("e is a reference\n",expression_reference_p(e));
1836 }

References expression_reference_p(), expression_syntax, pips_assert, and syntax_reference.

Referenced by add_aliases_for_current_call_site(), address_of_scalar(), array_argument_p(), array_elements_substitution_in_transformer(), array_must_fully_written_by_regions_p(), array_to_constant_paths(), assignment_to_points_to(), atomize_call(), c_convex_effects_on_actual_parameter_forward_translation(), call_count_flt(), call_flt(), call_rwt(), comEngine_replace_reference_in_stat_rwt(), compact_phi_functions(), complete_points_to_reference_with_fixed_subscripts(), compute_points_to_binded_set(), convert_pointer_to_array_aux(), da_process_list(), dereferencing_to_points_to(), distance_between_expression(), do_array_to_pointer_walk_call_and_patch(), do_array_to_pointer_walk_expression(), do_atomize_call(), do_brace_expression_to_statements(), do_expression_reduction(), do_grouping_filter_out_self(), do_grouping_replace_reference_by_expression_walker(), do_linearize_prepatch_subscript(), do_linearize_remove_dereferencment_walker(), do_reduction_atomization(), do_reduction_detection(), do_reduction_propagation(), do_split_structure_return_hook_walker(), do_terapix_pointer_initialized_from_a_mask_p(), entity_used_in_calls_walker(), expression_allocatable_data_access_p(), expression_equal_in_context_p(), expression_reference_number(), expression_to_transformer(), expression_try_find_string_size(), expression_verbose_reduction_p_and_return_increment(), extended_regions_must_convex_hull(), field_expression_p(), FindDefinitionsOf_rewrite(), flint_cons_actual_argument(), freia_shuffle_move_forward(), full_copy_p(), generate_deducables(), get_complement_expression(), get_dma_dimension(), get_sizeofexpression_for_region(), glc_call(), guess_loop_increment_walker(), guess_loop_lower_bound(), guess_write_effect_on_entity_walker(), interprocedural_abc_call(), invalidate_expressions_in_statement(), isolate_patch_reference(), list_of_same_or_equivalence_arguments(), loadstore_type_conversion_string(), make_loadsave_statement(), make_send_receive_conversion(), new_array_elements_backward_substitution_in_transformer(), new_array_elements_forward_substitution_in_transformer(), offset_in_caller(), outliner_patch_parameters(), partial_eval_update_operators(), perform_substitution_in_assign(), points_to_array_reference_p(), points_to_array_reference_to_type(), points_to_cells_pointer_arguments(), points_to_indices_to_subscript_indices(), points_to_indices_to_unbounded_indices(), process_static_initialization(), process_true_call_stat(), put_variables_in_ordered_lists(), recursive_store_independent_points_to_reference_p(), reference_argument_number(), reference_filter(), reference_to_field_disambiguator(), references_must_conflict_p(), region_to_address(), remove_unread_variable(), replace_entities_expression_walker(), replace_entity_by_expression_expression_walker(), replace_field_by_reference_walker(), rssp_ref(), sac_aligned_expression_p(), sac_expression_reduction_p(), safe_expression_to_transformer(), same_or_equivalence_argument_add_aliases(), same_section_common_variable_in_list_p(), same_section_formal_variable_in_list_p(), seq_rwt(), simd_trace_call(), simple_reference_to_convex_reference_conversion(), simplify_complex_expression(), split_complex_expression(), statement_insertion_fix_access_in_callers(), subscripted_field_list_to_type(), substitute_image_in_statement(), sww_seq_rwt(), terapix_loop_handler(), update_functional_type_with_actual_arguments(), variable_to_dimensions(), and verify_array_element().

+ Here is the call graph for this function:

◆ expression_reference_p()

bool expression_reference_p ( expression  e)

Test if an expression is a reference.

Definition at line 528 of file expression.c.

528  {
530 }

References expression_syntax, and syntax_reference_p.

Referenced by add_aliases_for_current_call_site(), address_of_scalar(), alloc_instrumentation(), array_argument_p(), array_elements_substitution_in_transformer(), array_indices_check(), array_must_fully_written_by_regions_p(), assign_operation_to_transformer(), assignment_to_points_to(), atomize_call(), atomize_call_statement(), atomize_condition(), c_convex_effects_on_actual_parameter_forward_translation(), call_count_flt(), call_flt(), cleanup_subscript(), comEngine_replace_reference_in_stat_rwt(), compact_phi_functions(), compute_points_to_binded_set(), constant_reference_to_normalized_constant_reference(), continue_propagation_p(), controlize_statement(), convert_pointer_to_array_aux(), cstr_args_check(), dereferencing_to_points_to(), distance_between_expression(), do_array_to_pointer_walk_call_and_patch(), do_array_to_pointer_walk_expression(), do_atomize_call(), do_brace_expression_to_statements(), do_expression_reduction(), do_grouping_filter_out_self(), do_grouping_replace_reference_by_expression_walker(), do_linearize_pointer_is_expression(), do_linearize_prepatch_subscript(), do_linearize_remove_dereferencment_walker(), do_reduction_atomization(), do_reduction_propagation(), do_split_structure_return_hook_walker(), do_terapix_loop_optimizer(), entity_used_in_calls_walker(), expr_flt(), expr_rwt(), expression_equal_in_context_p(), expression_null_p(), expression_number_for_index(), expression_reference(), expression_reference_number(), expression_reference_or_field_p(), expression_simple_nondist_p(), expression_to_transformer(), expression_try_find_size(), expression_verbose_reduction_p_and_return_increment(), extended_regions_must_convex_hull(), field_expression_p(), flint_cons_actual_argument(), freia_extract_kernel(), freia_shuffle_move_forward(), full_copy_p(), get_complement_expression(), get_dma_dimension(), get_sizeofexpression_for_region(), glc_call(), guess_loop_increment_walker(), guess_loop_lower_bound(), guess_write_effect_on_entity_walker(), hpfc_overlap_kill_unused_scalars_rewrite(), interprocedural_mapping(), intrinsic_call_to_points_to(), invalidate_expressions_in_statement(), is_expression_reference_to_entity_p(), isolate_patch_reference(), list_of_same_or_equivalence_arguments(), loadstore_type_conversion_string(), make_loadsave_statement(), new_array_elements_backward_substitution_in_transformer(), new_array_elements_forward_substitution_in_transformer(), outliner_patch_parameters(), parser_macro_expansion(), partial_eval_call(), partial_eval_update_operators(), points_to_cells_pointer_arguments(), points_to_indices_to_array_index_number(), points_to_indices_to_subscript_indices(), points_to_indices_to_unbounded_indices(), process_static_initialization(), process_true_call_stat(), proper_to_summary_simple_effect(), reference_argument_number(), reference_filter(), reference_to_field_disambiguator(), reference_to_type(), references_aligned_p(), references_must_conflict_p(), regenerate_call(), region_to_address(), remove_unread_variable(), replace_entities_expression_walker(), replace_entity_by_expression_expression_walker(), replace_field_by_reference_walker(), rssp_ref(), sac_aligned_expression_p(), sac_expression_reduction_p(), safe_expression_to_transformer(), same_section_common_variable_in_list_p(), same_section_formal_variable_in_list_p(), seq_rwt(), simple_reference_to_convex_reference_conversion(), simplify_complex_expression(), statement_insertion_fix_access_in_callers(), subarray_shift_assignment_p(), subscripted_field_list_to_type(), substitute_image_in_statement(), sww_seq_rwt(), terapix_loop_handler(), update_functional_type_with_actual_arguments(), update_operation_to_transformer(), variable_references_may_conflict_p(), and variable_to_dimensions().

◆ expression_similar_get_context_p()

bool expression_similar_get_context_p ( expression  target,
expression  pattern,
hash_table symbol_table 
)

similar to expression_similar_p but the hash_map containing the crossref value is retured for further use

Parameters
targetexpression to compare
patternexpression serving as pattern
symbol_tablepointer to unallocated hash_map, in the end it will contain a set of pair (original syntax reference name, substituted syntax element). Must be freed, but only if expressions are similar
Returns
true if expressions are similar
Parameters
targetarget
patternattern
symbol_tableymbol_table

Definition at line 3339 of file expression.c.

3340 {
3342  bool similar = _expression_similar_p(target,pattern,*symbol_table);
3343  if( !similar) hash_table_free(*symbol_table);
3344  return similar;
3345 }
@ hash_string
Definition: newgen_hash.h:32
#define HASH_DEFAULT_SIZE
Definition: newgen_hash.h:26
bool symbol_table(const char *)
To replace c_symbol_table() and fortran_symbol_table() because the information about the language is ...
Definition: symbol_table.c:673

References _expression_similar_p(), HASH_DEFAULT_SIZE, hash_string, hash_table_free(), hash_table_make(), and symbol_table().

Referenced by replace_expression_similar_to_pattern().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_similar_p()

bool expression_similar_p ( expression  target,
expression  pattern 
)

compare if two expressions are similar that is can we exchange target and pattern by substituing variables examples: 1+2 ~ a+b a+b !~ a+2 1+b ~ 1+c

Parameters
targetexpression that sould match with pattern
patternthe pattern to match
Returns
true if expressions are similar
Parameters
targetarget
patternattern

Definition at line 3360 of file expression.c.

3361 {
3363  bool similar = _expression_similar_p(target,pattern,symbol_table);
3365  return similar;
3366 }

References _expression_similar_p(), HASH_DEFAULT_SIZE, hash_pointer, hash_table_free(), hash_table_make(), and symbol_table().

+ Here is the call graph for this function:

◆ expression_sizeofexpression()

sizeofexpression expression_sizeofexpression ( expression  e)

Definition at line 465 of file expression.c.

466 {
468 }

References expression_syntax, and syntax_sizeofexpression.

Referenced by expression_to_transformer().

+ Here is the caller graph for this function:

◆ expression_sizeofexpression_p()

bool expression_sizeofexpression_p ( expression  e)

Definition at line 460 of file expression.c.

461 {
463 }

References expression_syntax, and syntax_sizeofexpression_p.

Referenced by expression_to_transformer().

+ Here is the caller graph for this function:

◆ expression_string_constant()

char* expression_string_constant ( expression  exp)

returns a newly allocated string!

Parameters
expxp

Definition at line 2409 of file expression.c.

2409  {
2410  pips_assert("is a string constant", expression_string_constant_p(exp));
2411  call c = expression_call(exp);
2412  entity operator = call_function(c);
2413  const char * eun = entity_user_name(operator);
2414  return strndup(eun+1,strlen(eun)-2);
2415 }
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
Definition: entity.c:487
bool expression_string_constant_p(expression exp)
Definition: expression.c:2398
char * strndup(char const *s, size_t n)
A replacement function, for systems that lack strndup.
Definition: strndup.c:26

References call_function, entity_user_name(), exp, expression_call(), expression_string_constant_p(), pips_assert, and strndup().

Referenced by do_simplify_constant_address_expression().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_string_constant_p()

bool expression_string_constant_p ( expression  exp)
Parameters
expxp

Definition at line 2398 of file expression.c.

2398  {
2399  bool constant_p = false;
2401  call c = expression_call(exp);
2402  entity operator = call_function(c);
2404  }
2405  return constant_p;
2406 }
bool constant_string_entity_p(entity e)
Definition: constant.c:356
static bool constant_p(entity e)
This function return a bool indicating if related entity e represents a constant.

References call_function, constant_p(), constant_string_entity_p(), exp, expression_call(), expression_call_p(), and expression_constant_p().

Referenced by compute_points_to_binded_set(), do_simplify_constant_address_expression(), and expression_string_constant().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_subscript()

subscript expression_subscript ( expression  e)

Definition at line 1843 of file expression.c.

1844 {
1845  pips_assert("is a subscript\n",expression_subscript_p(e));
1847 }
bool expression_subscript_p(expression e)
Definition: expression.c:1838

References expression_subscript_p(), expression_syntax, pips_assert, and syntax_subscript.

Referenced by expression_to_transformer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_subscript_p()

bool expression_subscript_p ( expression  e)

Definition at line 1838 of file expression.c.

1838  {
1840 }

References expression_syntax, and syntax_subscript_p.

Referenced by expression_subscript(), and expression_to_transformer().

+ Here is the caller graph for this function:

◆ expression_to_dereferencing_expression()

expression expression_to_dereferencing_expression ( expression  e)

Reuse expression e to build expression *(e) without cheking the legality of the construct.

Definition at line 4051 of file expression.c.

4052 {
4054 }

References DEREFERENCING_OPERATOR_NAME, and unary_intrinsic_expression.

◆ expression_to_entity()

entity expression_to_entity ( expression  e)

just returns the entity of an expression, or entity_undefined

The entity returned is either the function called or the variable referenced

SG: moved here from hpfc Warning: This function certainly needs to be reviewed, maybe just testing the size of arguments (call), or the size of index (reference) may be sufficient as a first step. If their sizes are != 0, it may not return what we expect (for instance "-3" will return UNARY_MINUS_OPERATOR_NAME "--"). But expression_to_entity is called by many functions and I worry about the side effects on them.

Definition at line 3140 of file expression.c.

3141 {
3142  syntax s = expression_syntax(e);
3143 
3144  switch (syntax_tag(s))
3145  {
3146  case is_syntax_call:
3147  return call_function(syntax_call(s));
3148  case is_syntax_reference:
3150  case is_syntax_range:
3151  case is_syntax_cast:
3153  case is_syntax_subscript:
3154  case is_syntax_application:
3155  case is_syntax_va_arg:
3156  default:
3157  return entity_undefined;
3158  }
3159 }
#define entity_undefined
Definition: ri.h:2761

References call_function, entity_undefined, expression_syntax, is_syntax_application, is_syntax_call, is_syntax_cast, is_syntax_range, is_syntax_reference, is_syntax_sizeofexpression, is_syntax_subscript, is_syntax_va_arg, reference_variable, syntax_call, syntax_reference, and syntax_tag.

Referenced by address_of_entity_p(), continue_propagation_p(), copy_write_statement_with_cumulated_regions(), dagvtx_copy_list_dot(), do_check_isolate_statement_preconditions_on_call(), do_group_statement_constant(), do_isolate_statement_preconditions_satisified_p(), do_simdizer_init(), do_solve_hardware_constraints_on_nb_proc(), do_terapix_loop_optimizer(), effect_field_dimension_entity(), expressions_to_entities(), filter_variables_in_pragma_expr(), find_receiver_cluster(), fis_call_flt(), freia_cleanup_sequence_rec(), freia_extract_params(), freia_is_transpose_call(), gen_mpi_send_recv(), get_assigned_variable(), get_reference_assignments(), handle_align_and_realign_directive(), handle_prescriptive_directive(), hpf_compile_call(), hpfc_translate_call_with_distributed_args(), is_expression_in_list(), is_expression_omp_for_p(), is_expression_omp_if_p(), is_expression_omp_omp_p(), is_expression_omp_parallel_p(), is_expression_omp_private_p(), is_expression_omp_reduction_p(), lUpdateExpr_but_distributed(), make_loadsave_statement(), make_send_receive_conversion(), make_simd_statement(), mpi_recv_ctx(), mpi_send_ctx(), new_dynamic(), new_fake_function(), new_io_function(), new_processor(), new_pure_function(), new_system_with_only_live_variable(), new_template(), oi_call_rwt(), outliner_smart_references_computation(), partial_eval_binary_operator(), region_to_minimal_dimensions(), remove_from_effective_parameters(), step_directive_basic_workchunk_index(), terapix_loop_optimizer(), terapixify_loops(), test_rewrite(), and update_overlaps_in_caller().

◆ expression_to_float()

float expression_to_float ( expression  exp)

Same as above for floating point constants.

Its calls must be guarded by expression_constant_p()

Parameters
expxp

Definition at line 2305 of file expression.c.

2306 {
2307  float rv = 0;
2308 
2309  pips_debug( 7, "doing\n");
2310  if(expression_constant_p(exp)) {
2312  switch(value_tag(entity_initial(call_function(c)))) {
2313  case is_value_constant: {
2314  rv = atof(entity_user_name(call_function(c)));
2315  break;
2316  }
2317  case is_value_intrinsic: {
2318  entity op = call_function(c);
2319  if(ENTITY_UNARY_MINUS_P(op))
2320  rv = 0 - expression_to_float(binary_call_lhs(c));
2321  else if(ENTITY_UNARY_PLUS_P(op))
2323  else
2324  pips_internal_error("Unexpected intrinsic \"%s\"\n",
2325  entity_local_name(op));
2326  break;
2327  }
2328  default:
2329  pips_internal_error("expression is not a constant"
2330  " according to expression_constant_p()");
2331  }
2332  }
2333  else
2334  pips_internal_error("expression is not a constant"
2335  " according to expression_constant_p()");
2336  return(rv);
2337 }
float expression_to_float(expression exp)
Same as above for floating point constants.
Definition: expression.c:2305

References binary_call_lhs, call_function, entity_initial, entity_local_name(), ENTITY_UNARY_MINUS_P, ENTITY_UNARY_PLUS_P, entity_user_name(), exp, expression_constant_p(), expression_syntax, is_value_constant, is_value_intrinsic, pips_debug, pips_internal_error, syntax_call, and value_tag.

Referenced by do_solve_hardware_constraints_on_volume(), and expression_to_polynome().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_to_int()

int expression_to_int ( expression  exp)

================================================================

int expression_to_int(expression exp): returns the integer value of "exp" when "exp" is programming language constant or a Fortran symbolic constant.

Note: "exp" is supposed to contain an integer value which means that the function expression_constant_p() has returned true with "exp" as argument.

This implies that if "exp" is not a "value_constant", it must be a "value_intrinsic". In that case it is an unary minus operation upon an expression for which the function expression_constant_p() returns true (see its comment).

SG: improvement: the integer value of a extended_integer_constant_expression_p is computed too, for instance 0+5 or 6+3.

FI: I am not sure it is an improvement, at best it is an extension; it looks more like a change of semantics (see above comments and expression_constant_p()); other functions exist to evaluate a constant expression... The extension should be useless as this function should not be called unless guarded by a test with expression_constant_p()... The same is true for the extension related to symbolic constants.

For an extended static expression evaluation, see EvalExpression(). See also extended_expression_constant_p() for more comments about what is called a "constant" expression.

For a cleaner implementation of this function, as it was originally intended, see below expression_to_float().

use the normalize field first: this is Serge Guelton's improvement...

Not good for user source code preservation...

This is the initial code

pips_internal_error("expression %s is not an integer constant.\n",

expression_to_string(exp));

Could be improved checking dependent and not dependent types...

pips_internal_error("expression %s is not an integer constant\n",

expression_to_string(exp));

This is another useless extension

Is it an integer "parameter" in Fortran, that is symbolic constants?

Should this be generalized to C const qualified variables?

I have doubt about this piece of code since the call is supposedly guarded by expression_constant_p()

pips_internal_error("expression %s is not an integer constant\n",

expression_to_string(exp));

pips_internal_error("expression %s is not an integer constant"

" in the sense of expression_constant_p()\n",

expression_to_string(exp));

Parameters
expxp

Definition at line 2205 of file expression.c.

2206 {
2207  int rv = 0;
2208  pips_debug(7, "doing\n");
2209 
2210  /* use the normalize field first: this is Serge Guelton's improvement... */
2211  /* Not good for user source code preservation... */
2214  if(normalized_linear_p(n)) {
2215  Pvecteur pv = normalized_linear(n);
2216  if(vect_constant_p(pv))
2217  return (int)vect_coeff(TCST, pv);
2218  }
2219 
2220  /* This is the initial code */
2221  if(expression_constant_p(exp)) {
2223  if(syntax_call_p(s)) { // A nullary call is assumed
2224  call c = syntax_call(s);
2225  switch(value_tag(entity_initial(call_function(c)))) {
2226  case is_value_constant: {
2228  break;
2229  }
2230  case is_value_intrinsic: {
2231  entity op = call_function(c);
2232  if(ENTITY_UNARY_MINUS_P(op))
2233  rv = 0 - expression_to_int(binary_call_lhs(c));
2234  else if(ENTITY_UNARY_PLUS_P(op))
2236  else
2237  pips_internal_error("Unexpected intrinsic \"%s\"\n",
2238  entity_local_name(op));
2239  break;
2240  }
2241  default:
2242  /* pips_internal_error("expression %s is not an integer constant.\n", */
2243  /* expression_to_string(exp)); */
2244  pips_internal_error("expression is not an integer constant.\n");
2245  }
2246  }
2247  else if(false && syntax_sizeofexpression(s)) {
2249  // FI: do we want to guard this evaluation with EVAL_SIZEOF?
2250  // This should be part of eval.c
2251  value v = EvalSizeofexpression(soe);
2252  if(value_constant_p(v)) { // Should always be true... but for dependent types
2253  rv = constant_int(value_constant(v));
2254  }
2255  else {
2256  /* Could be improved checking dependent and not dependent types...*/
2257  // FI: to avoid cycles between librairies ri-util and prettyprint
2258  /* pips_internal_error("expression %s is not an integer constant\n", */
2259  /* expression_to_string(exp)); */
2260  pips_internal_error("expression is not an integer constant.\n");
2261  }
2262  free_value(v);
2263  }
2264  }
2265  /* This is another useless extension */
2266  else if(expression_call_p(exp)) {
2267  /* Is it an integer "parameter" in Fortran, that is symbolic constants?
2268  *
2269  * Should this be generalized to C const qualified variables?
2270  *
2271  * I have doubt about this piece of code since the call is
2272  * supposedly guarded by expression_constant_p()
2273  */
2275  value v = entity_initial(p);
2276 
2279  }
2280  else {
2281  // FI: to avoid cycles between librairies ri-util and prettyprint
2282  /* pips_internal_error("expression %s is not an integer constant\n", */
2283  /* expression_to_string(exp)); */
2284  pips_internal_error("expression is not an integer constant\n");
2285  }
2286  }
2287  else {
2288  // FI: to avoid cycles between librairies ri-util and prettyprint
2289  /* pips_internal_error("expression %s is not an integer constant" */
2290  /* " in the sense of expression_constant_p()\n", */
2291  /* expression_to_string(exp)); */
2292  pips_internal_error("expression is not an integer constant"
2293  " in the sense of expression_constant_p()\n");
2294  }
2295 
2296  return(rv);
2297 }
#define symbolic_constant(x)
Definition: ri.h:2599
#define value_symbolic(x)
Definition: ri.h:3070
#define value_symbolic_p(x)
Definition: ri.h:3068

References binary_call_lhs, call_function, constant_int, constant_int_p, entity_initial, entity_local_name(), ENTITY_UNARY_MINUS_P, ENTITY_UNARY_PLUS_P, EvalSizeofexpression(), exp, expression_call_p(), expression_constant_p(), expression_normalized, expression_syntax, free_value(), is_value_constant, is_value_intrinsic, NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, pips_debug, pips_internal_error, symbolic_constant, syntax_call, syntax_call_p, syntax_sizeofexpression, TCST, value_constant, value_constant_p, value_symbolic, value_symbolic_p, value_tag, vect_coeff(), and vect_constant_p().

Referenced by adg_get_conjonctions(), analyze_expression(), array_indices_check(), array_size_stride(), compute_final_index_value(), convert_bound_expression(), effect_field_dimension_entity(), equal_must_vreference(), expression_equal_integer_p(), expression_null_p(), expression_plusplus(), expression_try_find_size(), find_target_position(), formal_variable_add_aliases(), incrementation_expression_to_increment(), loop_annotate(), loop_normalize_of_loop(), make_max_exp(), make_send_receive_conversion(), MakeEquivAtom(), opkill_may_vreference(), opkill_must_vreference(), points_to_compare_cell(), points_to_compare_cells(), points_to_compare_location(), points_to_compare_ptr_cell(), rational_op_exp(), references_do_not_conflict_p(), sentence_data_statement(), size_of_actual_array(), size_of_dummy_array(), subscript_value(), subscript_value_stride(), system_new_var_subst(), valuer(), and words_dimension().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_to_polynome()

Ppolynome expression_to_polynome ( expression  exp)

===========================================================================

Ppolynome expression_to_polynome(expression exp): translates "exp" into a polynome. This transformation is feasible if "exp" contains only scalars and the four classical operations (+, -, *, /).

The translation is done straightforwardly and recursively.

it returns a POLYNOME_UNDEFINED if the conversion failed

This the resulting polynome

Two cases : _ a constant _ a "real" call, ie an intrinsic or external function

We should have a real null polynome : 0*TCST^1 AL, AC 04 11 93 else { Pmonome pm = (Pmonome) malloc(sizeof(Smonome)); monome_coeff(pm) = 0; monome_term(pm) = vect_new(TCST, 1); pp_new = monome_to_new_polynome(pm); }

The call must be one of the four classical operations: +, - (unary or binary), *, /

This call has one (unary minus) or two (binary plus, minus, multiply or divide) arguments, no less and no more.

arg1 + arg2

-arg2 + arg1

arg1 * arg2

arg1 / arg2

(ENTITY_UNARY_MINUS_P(op_ent)) : -arg1

Parameters
expxp

Definition at line 3650 of file expression.c.

3651 {
3652  Ppolynome pp_new=POLYNOME_UNDEFINED; /* This the resulting polynome */
3654 
3655  switch(syntax_tag(sy))
3656  {
3657  case is_syntax_reference:
3658  {
3659  reference r = syntax_reference(sy);
3660  entity en = reference_variable(r);
3661 
3663  pp_new = make_polynome(1.0, (Variable) en, (Value) 1);
3664  break;
3665  }
3666  case is_syntax_call:
3667  {
3668  /* Two cases : _ a constant
3669  * _ a "real" call, ie an intrinsic or external function
3670  */
3671  if (expression_constant_p(exp)) {
3672  float etof = expression_to_float(exp);
3673  pp_new = make_polynome( etof,
3675  /* We should have a real null polynome : 0*TCST^1 AL, AC 04 11 93
3676  *else {
3677  * Pmonome pm = (Pmonome) malloc(sizeof(Smonome));
3678  * monome_coeff(pm) = 0;
3679  * monome_term(pm) = vect_new(TCST, 1);
3680  * pp_new = monome_to_new_polynome(pm);
3681  *}
3682  */
3683  }
3684  else
3685  {
3686  int cl;
3687  expression arg1, arg2 = expression_undefined;
3688  entity op_ent = call_function(syntax_call(sy));
3689 
3690  /* The call must be one of the four classical operations:
3691  * +, - (unary or binary), *, /
3692  */
3693  if(ENTITY_FIVE_OPERATION_P(op_ent))
3694  {
3695  /* This call has one (unary minus) or two (binary plus, minus,
3696  * multiply or divide) arguments, no less and no more.
3697  */
3699  if( (cl != 2) && (cl != 1) )
3700  pips_internal_error("%s call with %d argument(s)",
3701  entity_local_name(op_ent), cl);
3702 
3703  arg1 = EXPRESSION(CAR(call_arguments(syntax_call(sy))));
3704  if(cl == 2)
3705  arg2 = EXPRESSION(CAR(CDR(call_arguments(syntax_call(sy)))));
3706 
3707  if (ENTITY_PLUS_P(op_ent)||ENTITY_PLUS_C_P(op_ent)) /* arg1 + arg2 */
3708  {
3709  pp_new = expression_to_polynome(arg1);
3710  if(!POLYNOME_UNDEFINED_P(pp_new))
3711  polynome_add(&pp_new, expression_to_polynome(arg2));
3712  }
3713  else if(ENTITY_MINUS_P(op_ent)||ENTITY_MINUS_C_P(op_ent)) /* -arg2 + arg1 */
3714  {
3715  pp_new = expression_to_polynome(arg2);
3716  if(!POLYNOME_UNDEFINED_P(pp_new)) {
3717  polynome_negate(&pp_new);
3718  Ppolynome parg1 = expression_to_polynome(arg1);
3719  if(!POLYNOME_UNDEFINED_P(parg1))
3720  polynome_add(&pp_new, parg1);
3721  else {
3722  polynome_rm(&pp_new);
3723  pp_new=POLYNOME_UNDEFINED;
3724  }
3725  }
3726  }
3727  else if(ENTITY_MULTIPLY_P(op_ent)) /* arg1 * arg2 */ {
3728  Ppolynome p1 = expression_to_polynome(arg1);
3729  if(!POLYNOME_UNDEFINED_P(p1)) {
3730  Ppolynome p2 = expression_to_polynome(arg2);
3731  if(!POLYNOME_UNDEFINED_P(p2)) {
3732  pp_new = polynome_mult(p1,p2);
3733  }
3734  }
3735  }
3736  else if(ENTITY_DIVIDE_P(op_ent)) /* arg1 / arg2 */ {
3737  Ppolynome p1 = expression_to_polynome(arg1);
3738  if(!POLYNOME_UNDEFINED_P(p1)) {
3739  Ppolynome p2 = expression_to_polynome(arg2);
3740  if(!POLYNOME_UNDEFINED_P(p2)) {
3741  pp_new = polynome_div(p1,p2);
3742  }
3743  }
3744  }
3745  else /* (ENTITY_UNARY_MINUS_P(op_ent)) : -arg1 */
3746  {
3747  pp_new = expression_to_polynome(arg1);
3748  if(!POLYNOME_UNDEFINED_P(pp_new)) {
3749  polynome_negate(&pp_new);
3750  }
3751  }
3752  }
3753  }
3754 
3755  break;
3756  }
3757  default :
3758  {
3759  pp_new=POLYNOME_UNDEFINED;
3760  }
3761  }
3762  return(pp_new);
3763 }
Ppolynome make_polynome(float coeff, Variable var, Value expo)
Ppolynome make_polynome(float coeff, Variable var, Value expo) PRIVATE allocates space for,...
Definition: pnome-alloc.c:100
void polynome_rm(Ppolynome *ppp)
void polynome_rm(Ppolynome* ppp) frees space occupied by polynomial *ppp returns *ppp pointing to POL...
Definition: pnome-alloc.c:170
Ppolynome polynome_div(Ppolynome pp1, Ppolynome pp2)
Ppolynome polynome_div(Ppolynome pp1, Ppolynome pp2) returns p = pp1 / pp2.
Definition: pnome-bin.c:381
Ppolynome polynome_mult(Ppolynome pp1, Ppolynome pp2)
Ppolynome polynome_mult(Ppolynome pp1, Ppolynome pp2) returns pp1 * pp2.
Definition: pnome-bin.c:287
void polynome_add(Ppolynome *ppp, Ppolynome pp2)
void polynome_add(Ppolynome* ppp, Ppolynome pp2) (*ppp) = (*ppp) + pp2.
Definition: pnome-bin.c:171
void polynome_negate(Ppolynome *ppp)
void polynome_negate(Ppolynome *ppp); changes sign of polynomial *ppp.
Definition: pnome-unaires.c:45
#define POLYNOME_UNDEFINED
#define POLYNOME_UNDEFINED_P(pp)
#define ENTITY_DIVIDE_P(e)
#define ENTITY_FIVE_OPERATION_P(e)
#define ENTITY_MINUS_P(e)
#define ENTITY_PLUS_P(e)
#define ENTITY_MULTIPLY_P(e)
#define ENTITY_PLUS_C_P(e)
#define ENTITY_MINUS_C_P(e)
bool entity_pointer_p(entity e)
Definition: entity.c:745
Ppolynome expression_to_polynome(expression exp)
===========================================================================
Definition: expression.c:3650
bool entity_scalar_p(entity)
The concrete type of e is a scalar type.
Definition: variable.c:1113
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Definition: vecteur-local.h:60

References call_arguments, call_function, CAR, CDR, ENDP, ENTITY_DIVIDE_P, ENTITY_FIVE_OPERATION_P, entity_local_name(), ENTITY_MINUS_C_P, ENTITY_MINUS_P, ENTITY_MULTIPLY_P, ENTITY_PLUS_C_P, ENTITY_PLUS_P, entity_pointer_p(), entity_scalar_p(), entity_undefined, exp, EXPRESSION, expression_constant_p(), expression_syntax, expression_to_float(), expression_undefined, gen_length(), is_syntax_call, is_syntax_reference, make_polynome(), pips_internal_error, polynome_add(), polynome_div(), polynome_mult(), polynome_negate(), polynome_rm(), POLYNOME_UNDEFINED, POLYNOME_UNDEFINED_P, reference_indices, reference_variable, syntax_call, syntax_reference, and syntax_tag.

Referenced by edge_cost_polynome(), include_trans_in_poly(), plc_make_distance(), search_scc_bdt(), simplify_expression(), and size_of_regions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_to_reference()

reference expression_to_reference ( expression  e)

Definition at line 212 of file expression.c.

213 {
214  syntax s = expression_syntax(e);
215  message_assert("reference", syntax_reference_p(s));
216  return syntax_reference(s);
217 }
#define message_assert(msg, ex)
Definition: newgen_assert.h:47

References expression_syntax, message_assert, syntax_reference, and syntax_reference_p.

Referenced by continue_propagation_p(), handle_align_and_realign_directive(), and handle_distribute_and_redistribute_directive().

+ Here is the caller graph for this function:

◆ expression_to_reference_list()

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 encountered; array references are added before their index expressions are scanned;

references to functions and constants (which are encoded as null-ary functions) are not recorded

Parameters
lrr

Definition at line 1263 of file expression.c.

1264 {
1265  syntax s = expression_syntax(e);
1266  lr = syntax_to_reference_list(s, lr);
1267  return lr;
1268 }
list syntax_to_reference_list(syntax s, list lr)
Definition: expression.c:1270

References expression_syntax, and syntax_to_reference_list().

Referenced by array_indice_in_list_p(), check_loop_distribution_feasability(), effect_interference(), effects_interfere_p(), guess_late_read_effect_on_entity(), loop_nest_to_local_variables(), self_initialization_p(), syntax_to_reference_list(), and verify_used_before_set_call().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_variable()

entity expression_variable ( expression  e)

Assume e is a reference expression: expression_reference_p(e)==true

Definition at line 532 of file expression.c.

533 {
534  /* Assume e is a reference expression:
535  expression_reference_p(e)==true */
537 }

References expression_syntax, reference_variable, and syntax_reference.

Referenced by expression_null_p(), find_entities_to_wrap(), freia_extract_kernel(), freia_reduction_variable(), maybe_unroll_while_rwt(), proper_to_summary_simple_effect(), seq_rwt(), and variable_references_may_conflict_p().

+ Here is the caller graph for this function:

◆ expression_verbose_reduction_p_and_return_increment()

expression expression_verbose_reduction_p_and_return_increment ( expression  incr,
bool   filterexpression 
)

Test if an expression is a verbose reduction of the form : "i = i op v" or "i = v op i".

Parameters
eis the expression to analyse
filteris a function that take an expression and return true iff expression is of the form "op(a,b,c...)". The filter may not be specific to binary operators, even if this function only deal with binary patterns. Use for example add_expression_p() to detect "i = i + v" or "i = v + i".
Returns
the v expression if e is of the requested form or expression_undefined if not

The expression is an assignment, it is a good start.

Only deal with simple references right now:

Operation found.

Only deal with binary operators

If arg1 is the same reference as lhs, we are in the "i = i op v" case:

If arg2 is the same reference as lhs, we are in the "i = v op i" case:

Definition at line 780 of file expression.c.

781  {
782  if (assignment_expression_p(incr)) {
783  /* The expression is an assignment, it is a good start. */
784  list assign_params = call_arguments(syntax_call(expression_syntax(incr)));
785  expression lhs = EXPRESSION(CAR(assign_params));
786 
787  /* Only deal with simple references right now: */
788  if (expression_reference_p(lhs)) {
789  expression rhs = EXPRESSION(CAR(CDR(assign_params)));
790  if (filter(rhs)) {
791  /* Operation found. */
793  /* Only deal with binary operators */
794  if (gen_length(op_params) == 2) {
795  expression arg1 = EXPRESSION(CAR(op_params));
796  expression arg2 = EXPRESSION(CAR(CDR(op_params)));
797  if (expression_reference_p(arg1)
799  expression_reference(arg1)))
800  /* If arg1 is the same reference as lhs,
801  we are in the "i = i op v" case: */
802  return arg2;
803  else if (expression_reference_p(arg2)
805  expression_reference(arg2)))
806  /* If arg2 is the same reference as lhs,
807  we are in the "i = v op i" case: */
808  return arg1;
809  }
810  }
811  }
812  }
813  return expression_undefined;
814 }
bool reference_equal_p(reference r1, reference r2)
Definition: expression.c:1500
bool assignment_expression_p(expression e)
Test if an expression is an assignment operation.
Definition: expression.c:979

References assignment_expression_p(), call_arguments, CAR, CDR, EXPRESSION, expression_reference(), expression_reference_p(), expression_syntax, expression_undefined, gen_length(), reference_equal_p(), and syntax_call.

Referenced by incrementation_expression_to_increment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_with_constant_signed_integer_value_p()

bool expression_with_constant_signed_integer_value_p ( expression  e)

The expression may be complicated but all its leaves are constants or parameters.

It evaluates to a signed integer constant. I am too lazy to fully implement it as I should and I only take care of affine expressions (Francois).

No vecteur_constant_p() in linear library?

Definition at line 960 of file expression.c.

962 {
964  bool constant_p = false;
965 
966  if(normalized_linear_p(ne)) {
967  Pvecteur ve = normalized_linear(ne);
968  /* No vecteur_constant_p() in linear library? */
970  || (term_cst(ve) && VECTEUR_UNDEFINED_P(vecteur_succ(ve)));
971  }
972 
973  return constant_p;
974 }
#define vecteur_succ(v)
#define term_cst(varval)
#define VECTEUR_UNDEFINED_P(v)

References constant_p(), NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, term_cst, VECTEUR_NUL_P, vecteur_succ, and VECTEUR_UNDEFINED_P.

Referenced by array_with_numerical_bounds_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expressions_to_entities()

list expressions_to_entities ( list  expressions)

map expression_to_entity on expressions

Parameters
expressionsxpressions

Definition at line 3161 of file expression.c.

3162 {
3163  list entities = NIL;
3164  FOREACH(EXPRESSION,exp,expressions)
3166  return gen_nreverse(entities);
3167 }
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
entity expression_to_entity(expression e)
just returns the entity of an expression, or entity_undefined
Definition: expression.c:3140

References CONS, ENTITY, exp, EXPRESSION, expression_to_entity(), FOREACH, gen_nreverse(), and NIL.

Referenced by do_array_expansion(), do_solve_hardware_constraints_on_nb_proc(), generate_full_copy(), handle_independent_directive(), handle_reduction_directive(), rectangularization_region(), and statement_insertion_fix_access().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expressions_to_operation()

expression expressions_to_operation ( const list  l_exprs,
entity  op 
)

take a list of expression and apply a binary operator between all of them and return it as an expression

Returns
the operations as an expression
Parameters
l_exprs,thelist of expressions to compute with the operator
op,thebinary operator to apply
Parameters
l_exprs_exprs
opp

Definition at line 3544 of file expression.c.

3544  {
3546  if ((l_exprs != NIL) && (op != entity_undefined)){
3547  list l_src = l_exprs;
3548  result = EXPRESSION (CAR (l_src));
3549  POP(l_src);
3550  FOREACH (EXPRESSION, ex, l_src) {
3551  list args = gen_expression_cons (result, NIL);
3552  args = gen_expression_cons (ex, args);
3553  call c = make_call (op, args);
3554  result = call_to_expression (c);
3555  }
3556  }
3557  return result;
3558 }
list gen_expression_cons(expression p, list l)
Definition: ri.c:866

References call_to_expression(), CAR, entity_undefined, EXPRESSION, expression_undefined, FOREACH, gen_expression_cons(), make_call(), NIL, and POP.

Referenced by add_loop_parallel_threshold(), make_send_receive_conversion(), and merge_conditions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extended_expression_constant_p()

bool extended_expression_constant_p ( expression  exp)

Returns true if the value of the expression does not depend syntactically on the current store.

Returns false when this has not been proved.

The only constant references in PIPS internal representation are references to functions and to declared constants.

Check that all arguments are constant

Certainly true for Fortran. Quid for C?

does not make much sense... for a function!

Let's be conservative

There might be another case of constant expressions: all that are casted to void... Usage?

This should be a constant, except for dependent types.

Parameters
expxp

Definition at line 2461 of file expression.c.

2462 {
2464  bool constant_p = false;
2465 
2466  switch(syntax_tag(s)) {
2467  case is_syntax_reference: {
2468  /* The only constant references in PIPS internal representation
2469  are references to functions and to declared constants. */
2470  reference r = syntax_reference(s);
2471  entity v = reference_variable(r);
2472  type t = ultimate_type(entity_type(v));
2473 
2475  break;
2476  }
2477  case is_syntax_range: {
2478  range r = syntax_range(s);
2479  expression lb = range_lower(r);
2480  expression ub = range_upper(r);
2481  expression inc = range_increment(r);
2482 
2486  break;
2487  }
2488  case is_syntax_call: {
2489  call c = syntax_call(s);
2490  entity f = call_function(c);
2491  value v = entity_initial(f);
2492  switch(value_tag(v)) {
2493  case is_value_constant:
2494  constant_p = true;
2495  break;
2496  case is_value_intrinsic: {
2497  /* Check that all arguments are constant */
2498  list args = call_arguments(c);
2499  constant_p = true;
2500  FOREACH(EXPRESSION, sub_exp, args) {
2502  }
2503  break;
2504  }
2505  case is_value_symbolic:
2506  /* Certainly true for Fortran. Quid for C? */
2507  constant_p = true;
2508  break;
2509  case is_value_expression: {
2510  /* does not make much sense... for a function! */
2511  expression sub_exp = value_expression(v);
2513  break;
2514  }
2515  case is_value_unknown:
2516  case is_value_code:
2517  default:
2518  /* Let's be conservative */
2519  constant_p = false;
2520  }
2521  break;
2522  }
2523  case is_syntax_cast: {
2524  /* There might be another case of constant expressions: all that
2525  are casted to void... Usage? */
2526  cast c = syntax_cast(s);
2527  expression sub_exp = cast_expression(c);
2529  break;
2530  }
2532  /* This should be a constant, except for dependent types. */
2534  type t = type_undefined;
2535  if(sizeofexpression_type_p(soe))
2536  t = copy_type(sizeofexpression_type(soe));
2537  else {
2539  t = expression_to_type(se);
2540  }
2541  // constant_p = !dependent_type_p(t);
2543  free_type(t);
2544  break;
2545  }
2546  case is_syntax_subscript:
2547  break;
2548  case is_syntax_application:
2549  break;
2550  case is_syntax_va_arg:
2551  break;
2552  default:
2553  pips_internal_error("Unexpected syntax tag %d", syntax_tag(s));
2554  }
2555  return constant_p;
2556 }
type copy_type(type p)
TYPE.
Definition: ri.c:2655
void free_type(type p)
Definition: ri.c:2658
bool extended_expression_constant_p(expression exp)
Returns true if the value of the expression does not depend syntactically on the current store.
Definition: expression.c:2461
bool variable_length_array_type_p(type)
Is this equivalent to dependent_type_p()?
Definition: type.c:2972
#define type_functional_p(x)
Definition: ri.h:2950
@ is_value_unknown
Definition: ri.h:3035
@ is_value_expression
Definition: ri.h:3036
@ is_value_code
Definition: ri.h:3031
#define type_undefined
Definition: ri.h:2883
#define value_expression(x)
Definition: ri.h:3082

References call_arguments, call_function, cast_expression, const_variable_p(), constant_p(), copy_type(), entity_initial, entity_type, exp, EXPRESSION, expression_syntax, expression_to_type(), f(), FOREACH, free_type(), is_syntax_application, is_syntax_call, is_syntax_cast, is_syntax_range, is_syntax_reference, is_syntax_sizeofexpression, is_syntax_subscript, is_syntax_va_arg, is_value_code, is_value_constant, is_value_expression, is_value_intrinsic, is_value_symbolic, is_value_unknown, pips_internal_error, range_increment, range_lower, range_upper, reference_variable, sizeofexpression_expression, sizeofexpression_type, sizeofexpression_type_p, syntax_call, syntax_cast, syntax_range, syntax_reference, syntax_sizeofexpression, syntax_tag, type_functional_p, type_undefined, ultimate_type(), value_expression, value_tag, and variable_length_array_type_p().

Referenced by dependent_type_p(), do_simdizer_init(), do_terapix_remove_divide(), redeclaration_enter_statement(), references_must_conflict_p(), and variable_length_array_type_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extended_integer_constant_expression_p()

bool extended_integer_constant_expression_p ( expression  e)

More extensive than next function.

Definition at line 858 of file expression.c.

859 {
860  value v = EvalExpression(e);
861  bool ice_p = false;
862 
863  if(value_constant_p(v)) {
864  constant c = value_constant(v);
865 
866  ice_p = constant_int_p(c);
867  }
868  free_value(v);
869  return ice_p;
870 }
value EvalExpression(expression e)
Evaluate statically an expression.
Definition: eval.c:108

References constant_int_p, EvalExpression(), free_value(), value_constant, and value_constant_p.

Referenced by constant_points_to_indices_p(), effect_to_store_independent(), incrementation_expression_to_increment(), opgen_may_vreference(), points_to_indices_to_subscript_indices(), proper_to_summary_simple_effect(), reference_to_points_to_translations(), reference_with_constant_indices_p(), reference_with_store_independent_indices(), reference_with_unbounded_indices_p(), and store_independent_points_to_indices_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extended_integer_constant_expression_p_to_int()

bool extended_integer_constant_expression_p_to_int ( expression  e,
int result 
)
Parameters
resultesult

Definition at line 874 of file expression.c.

875 {
876  value v = EvalExpression(e);
877  bool ice_p = false;
878 
879  if(value_constant_p(v)) {
880  constant c = value_constant(v);
881 
882  ice_p = constant_int_p(c);
883  if (ice_p) *result = constant_int(c);
884  }
885  free_value(v);
886  return ice_p;
887 }

References constant_int, constant_int_p, EvalExpression(), free_value(), value_constant, and value_constant_p.

Referenced by perform_array_element_substitutions_in_transformer(), range_contains_at_least_one_point_p(), and range_contains_nothing_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ false_expression_p()

bool false_expression_p ( expression  e)

Definition at line 1118 of file expression.c.

1119 {
1121 }

References FALSE_OPERATOR_NAME, and operator_expression_p().

+ Here is the call graph for this function:

◆ field_expression_p()

bool field_expression_p ( expression  e)

The expression is of kind "a", where "a" is a field of some struct "s".

Definition at line 498 of file expression.c.

499 {
500  return expression_reference_p(e)
502 }

References entity_field_p(), expression_reference(), expression_reference_p(), and reference_variable.

Referenced by complete_points_to_reference_with_fixed_subscripts(), opkill_may_vreference(), and reference_with_constant_indices_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ find_ith_argument()

expression find_ith_argument ( list  args,
int  n 
)

◆ find_ith_expression()

expression find_ith_expression ( list  le,
int  r 
)

find_ith_expression() is obsolet; use find_ith_argument() instead

the first element is one

two local variables, useless but for debugging

Parameters
lee

Definition at line 1161 of file expression.c.

1162 {
1163  /* the first element is one */
1164  /* two local variables, useless but for debugging */
1165  list cle;
1166  int i;
1167 
1168  pips_assert("find_ith_expression", r > 0);
1169 
1170  for(i=r, cle=le ; i>1 && !ENDP(cle); i--, POP(cle))
1171  ;
1172 
1173  if(ENDP(cle))
1174  pips_internal_error("not enough elements in expresion list");
1175 
1176  return EXPRESSION(CAR(cle));
1177 }

References CAR, ENDP, EXPRESSION, pips_assert, pips_internal_error, and POP.

Referenced by set_dimensions_of_local_variable_family().

+ Here is the caller graph for this function:

◆ float_to_expression()

expression float_to_expression ( float  c)

Definition at line 1229 of file expression.c.

1230 {
1231  entity e = float_to_entity(c);
1232  return call_to_expression(make_call(e,NIL));
1233 }
entity float_to_entity(float c)
Definition: constant.c:430

References call_to_expression(), float_to_entity(), make_call(), and NIL.

Referenced by complex_to_expression(), make_0val_expression(), make_1val_expression(), monome_to_expression(), and set_the_i().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fortran_string_compare()

int fortran_string_compare ( string  fs1,
string  fs2 
)

compare pips fortran string constants from the fortran point of view.

expression.c

as of 3.1 and 6.3.5 of the Fortran 77 standard, the character order is not fully specified. It states:

  • A < B < C ... < Z
  • 0 < 1 < 2 ... < 9
  • blank < 0
  • blank < A
  • 9 < A OR Z < 0 since these rules are ascii compatible, we'll take ascii. in practice, this may be implementation dependent?
Parameters
fs1constant fortran string (entity name is fine)
fs2constant fortran string (entity name is fine)
Returns
-n 0 +n depending on < == >, n first differing char.

skip headers, trailers...

collating sequence comparison.

equal string header case.

Parameters
fs1s1
fs2s2

Definition at line 101 of file expression.c.

102 {
103  int l1, l2, i, c = 0;
104  string s1, s2;
105 
106  /* skip headers, trailers... */
108  s2 = actual_fortran_string_to_compare(fs2, &l2);
109 
110  /* collating sequence comparison. */
111  for (i=0; c==0 && i<l1 && i<l2; i++)
112  {
113  if (s1[i] < s2[i]) c = -i-1;
114  if (s1[i] > s2[i]) c = i+1;
115  }
116 
117  /* equal string header case. */
118  if (c==0 && l1!=l2)
119  c = (l1<l2)? -l1-1: l2+1;
120 
121  return c;
122 }
static string actual_fortran_string_to_compare(string fs, int *plength)
quite lazy...
Definition: expression.c:54

References actual_fortran_string_to_compare(), and s1.

Referenced by constant_constraint_check().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ free_expressions()

void free_expressions ( list  el)

Free a list of expressions.

Parameters
ell

Definition at line 4084 of file expression.c.

4085 {
4086  FOREACH(EXPRESSION,e, el)
4087  free_expression(e);
4088 }

References EXPRESSION, FOREACH, and free_expression().

Referenced by user_call_to_points_to_sinks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generic_reference_add_fixed_subscripts()

void generic_reference_add_fixed_subscripts ( reference  r,
type  t,
bool  zero_p 
)

Add a set of zero subscripts to a reference "r" by side effect.

Used when array names or partial array references have to to converted to the first array element.

Parameters
zero_pero_p

Definition at line 236 of file expression.c.

237 {
238  pips_assert("type is of kind variable", type_variable_p(t));
239  variable v = type_variable(t);
240  //list rsl = reference_indices(r);
241 
242  // FI: this assert makes sense within the ri-util framework but is
243  // too strong for the kind of references used in effects-util
244  // pips_assert("scalar type", ENDP(reference_indices(r)));
245 
246  list dl = variable_dimensions(v);
247  //
248  //pips_assert("Reference r is correct", gen_length(dl)>=gen_length(rsl));
249  //
250  //FOREACH(EXPRESSION, rs, rsl)
251  // POP(dl);
252  list sl = NIL; // subscript list
253  FOREACH(DIMENSION, d, dl) {
255  // reference_indices(r) = CONS(EXPRESSION, s, reference_indices(r));
256  sl = CONS(EXPRESSION, s, sl);
257  }
259 }
expression make_unbounded_expression()
Definition: expression.c:4339
#define type_variable_p(x)
Definition: ri.h:2947

References CONS, DIMENSION, EXPRESSION, FOREACH, gen_nconc(), int_to_expression(), make_unbounded_expression(), NIL, pips_assert, reference_indices, type_variable, type_variable_p, and variable_dimensions.

Referenced by reference_add_unbounded_subscripts(), and reference_add_zero_subscripts().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ iabs_expression_p()

bool iabs_expression_p ( expression  e)

Definition at line 1036 of file expression.c.

1038 {
1040 }
#define IABS_OPERATOR_NAME

References IABS_OPERATOR_NAME, and operator_expression_p().

+ Here is the call graph for this function:

◆ int_to_expression()

expression int_to_expression ( _int  i)

transform an int into an expression and generate the corresponding entity if necessary; it is not clear if strdup() is always/sometimes necessary and if a memory leak occurs; wait till syntax/expression.c is merged with ri-util/expression.c

Negative constants do not seem to be included in PIPS internal representation.

special hook for VALUE_MIN: the problem is that VALUE_MIN cannot be represented in the IR because -VALUE_MIN does not fit into and _int, so we replace it by VALUE_MIN -1, which is still big ...

Definition at line 1188 of file expression.c.

1189 {
1190  bool negative_p = i<0;
1191  /* special hook for VALUE_MIN:
1192  the problem is that VALUE_MIN cannot be represented in the IR because
1193  -VALUE_MIN does not fit into and _int, so we replace it by VALUE_MIN -1,
1194  which is still big ... */
1195  if(negative_p)
1196  while(i==-i) { // ie while we have an integer overflow
1197  ++i;
1198  }
1199  // it is unclear whether to call abs/labs/llabs...
1200  entity e = int_to_entity(negative_p? -i: i);
1202  if(negative_p)
1204  return exp;
1205 }
entity int_to_entity(_int c)
Definition: constant.c:453

References call_to_expression(), entity_intrinsic(), exp, int_to_entity(), make_call(), MakeUnaryCall(), NIL, and UNARY_MINUS_OPERATOR_NAME.

Referenced by abc_with_allocation_size(), add_initialization_expression(), add_integer_to_expression(), add_prettyprint_control_list_to_declaration_statement(), add_reduction(), ajoute_constante(), ajoute_new_var(), alias_check(), alias_check_array_and_scalar_variable_in_caller_flt(), alias_check_array_and_scalar_variable_in_module_flt(), alias_check_array_variable_in_caller_flt(), alias_check_array_variable_in_module_flt(), alias_check_scalar_and_array_variables_in_caller(), alias_check_scalar_and_array_variables_in_module(), analyze_expression(), any_basic_update_operation_to_transformer(), any_basic_update_to_transformer_list(), array_access_to_array_ranges(), array_as_template(), array_indices_check(), array_indices_communication(), array_ranges_to_template_ranges(), array_scalar_access_to_bank_communication(), array_scalar_access_to_compute_communication(), array_size_stride(), basic_update_reflhs_with_rhs_to_transformer(), bdt_save_int(), bdt_save_pred(), bottom_up_abc_expression_implied_do(), bound_generation(), bound_to_statement(), bounds_of_expression(), build_bdt_null(), build_call_STEP_init_regionArray(), build_first_comb(), build_flag_assign(), build_flag_test(), build_local_time_test(), build_third_comb(), c_convex_effects_on_actual_parameter_forward_translation(), c_dim_string(), C_loop_range(), c_text_entity(), call_nary_rwt(), check_loop_distribution_feasability(), code_generation(), comEngine_generate_procCode(), compile_master(), compile_one_reduction(), compile_reduction(), complementary_range(), complete_points_to_reference_with_fixed_subscripts(), complex_bound_generation(), compute_final_index_value(), compute_receive_content(), compute_receive_domain(), constant_image_p(), constant_reference_to_normalized_constant_reference(), constraints_to_loop_bound(), contraintes_to_expression(), convert_bound_expression(), create_counter(), create_externalized_function_common(), create_pointer_to_array_stub_points_to(), create_stub_points_to(), CreateLogicalUnits(), cstr_args_check(), ctx_generate_new_statement_cluster_dependant(), dag_normalize(), dag_simplify(), DeclarePointer(), define_node_processor_id(), dimension_to_range(), distance_between_entity(), distance_between_expression(), do_brace_expression_to_statements(), do_brace_expression_to_updated_type(), do_gather_all_expressions(), do_group_constants_terapix(), do_group_count_elements(), do_group_count_elements_reduce(), do_isolate_statement_preconditions_satisified_p(), do_linearize_array_reference(), do_linearize_prepatch(), do_linearize_prepatch_subscript(), do_linearize_prepatch_type(), do_linearize_type(), do_loop_expansion(), do_loop_expansion_init(), do_loop_unroll_with_epilogue(), do_loop_unroll_with_prologue(), do_simdizer_auto_tile_int_to_list(), do_solve_hardware_constraints_on_nb_proc(), do_solve_hardware_constraints_on_volume(), do_symbolic_tiling(), do_terapix_remove_divide(), dynamic_alias_check_flt(), ecrit_une_var(), ecrit_une_var_neg(), edge_cost_polynome(), effects_to_dma(), enclose_in_a_parallel_loop(), entity_ith_bounds(), expand_call(), expr_compute_local_index(), expression_plusplus(), expression_try_find_size(), expression_try_find_string_size(), extract_the_align(), fix_if_condition(), flow_sensitive_malloc_to_points_to_sinks(), free_guards(), full_loop_unroll(), fusion(), fusion_buffer(), gen_mpi_send_recv(), generate_call_get_workchunk_loopbounds(), generate_call_set_regionarray(), generate_code(), generate_compact(), generate_copy_loop_nest(), generate_fifo_stat(), generate_full_copy(), generate_ind_fifo_stat2(), generate_io_wp65_code(), generate_loop_workchunk(), generate_mmcd_stat_from_ref(), generate_monome(), generate_one_message(), generate_prelude(), generate_remapping_guard(), generate_stat_from_ref_list_proc(), generate_stat_from_ref_list_proc_list(), generate_subarray_shift(), GenerateReturn(), generic_effect_find_aliases_with_simple_pointer_values(), generic_reference_add_fixed_subscripts(), get_complement_expression(), get_fifo_from_ref(), get_indExp_from_ref(), get_sizeofexpression_for_region(), gfc2pips_array_ref2indices(), gfc2pips_code2instruction_(), gfc2pips_get_list_of_dimensions2(), gfc2pips_int2dimension(), gfc2pips_vars_(), heap_intrinsic_to_post_pv(), Hierarchical_tiling(), hpfc_add_2(), hpfc_add_n(), hpfc_broadcast_buffers(), hpfc_buffer_initialization(), hpfc_compute_lid(), hpfc_init_run_time_entities(), if_different_pe_and_not_twin(), impact_check(), incrementation_expression_to_increment(), initialization_list_to_statements(), InitializeEnumMemberValues(), inline_statement_crawler(), interprocedural_abc_arrays(), intrinsic_call_to_points_to(), live_mapping_expression(), loop_annotate(), loop_flt(), loop_nest_to_wp65_code(), loop_normalize_of_loop(), loop_strip_mine(), lower_bound_generation(), make_0val_expression(), make_1val_expression(), make_abc_count_statement(), make_array_bounds(), make_bound_expression(), make_bounds(), make_c_stop_statement(), make_condition_from_loop(), make_constraint_expression(), make_datum_movement(), make_emulated_shared_variable(), make_exec_mmcd(), make_exit_statement(), make_expression_with_state_variable(), make_factor_expression(), make_global_common_and_initialize(), make_guard_expression(), make_increment_instruction(), make_increment_statement(), make_init_newInd_stat(), make_lInitStats(), make_list_of_constant(), make_list_of_flags(), make_loadsave_statement(), make_loop_skeleton(), make_lSwitchStats(), make_max_exp(), make_maxval_expression(), make_minval_expression(), make_mmcd_load_store_stat(), make_movement_scalar_wp65(), make_movements_loop_body_wp65(), make_mypos_expression(), make_new_simd_vector_with_prefix(), make_op_exp(), make_rational_exp(), make_reduction_vector_entity(), make_reindex(), make_scanning_over_one_tile(), make_scanning_over_tiles(), make_send_receive_conversion(), make_set_rc_statement(), make_shuffle_statement(), make_special_value(), make_state_variable_assignement_statement(), make_step_inc_statement(), make_toggle_inc_statement(), make_toggle_init_statement(), make_toggle_mmcd(), make_transStat(), make_unbounded_dimensions(), make_vecteur_expression(), make_zero_expression(), MakeArithmIfInst(), MakeAssignedOrComputedGotoInst(), MakeAtom(), MakeDataValueSet(), MakeDimension(), MakeForloop(), MakeIoFileArray(), MakeIoInstA(), MakeWhileDoInst(), malloc_arg_to_type(), merge_lists(), module_initial_parameter_pv(), monome_to_expression(), mpic_make_args_mpi_send_or_receiv(), ndf_normalized_test(), new_local_image_variable(), NewDeclarationOfDistributedArray(), normalize_integer_constant_expression(), normalize_test_leaves(), NormalizeOneTemplateDistribution(), offset_array_reference(), offset_in_caller(), offset_of_struct(), offset_points_to_cell(), original_malloc_to_abstract_location(), outliner_extract_loop_bound(), outliner_patch_parameters(), outliner_smart_references_computation(), overlap_redefine_expression(), parallel_tiling(), perform_array_element_substitutions_in_transformer(), phi_free_contraints_to_expressions(), points_to_cell_types_compatibility(), points_to_cell_update_last_subscript(), polynome_to_expression(), pragma_build_if_condition(), predicate_to_expression(), prepare_array_bounds(), prgm_mapping(), promote_statement(), propagate_constant_image(), psystem_to_expression(), ram_variable_add_aliases(), range_to_expression(), rational_op_exp(), rational_sol_edit(), re_do_it(), reference_add_field_dimension(), reference_add_zero_subscript(), reference_complete_with_zero_subscripts(), reference_filter(), reference_offset(), reference_to_points_to_sinks(), reference_to_points_to_translations(), regenerate_expression(), region_to_address(), region_to_minimal_dimensions(), rename_reduction_ref_walker(), replace_reductions_in_statement(), safe_static_domain_bound(), same_or_equivalence_argument_add_aliases(), save_int(), save_pred(), sc_delimiter(), sc_opposite_exp_of_conjunction(), sesamify(), set_array_status_to_target(), set_dimensions_of_local_variable_family(), shape_one_message(), simdizer_auto_tile(), simplified_reference(), simplify_complex_entity(), simplify_complex_expression(), simplify_dimension(), simplify_relational_expression(), size_of_actual_array(), size_of_dummy_array(), size_of_regions(), SizeOfDimension(), SizeOfDimensions(), split_complex_expression(), sprintf_check_expression(), st_compute_current_computer(), st_compute_current_owners(), st_compute_neighbour(), statement_compute_bounds(), step_local_loopSlices(), step_local_regionArray(), step_parameter(), storage_ram_offset(), subscript_expressions_to_constant_subscript_expressions(), subscript_value(), subscript_value_stride(), substitute_and_create(), substitute_struct_stub_in_transformer(), systeme_to_loop_nest(), template_ranges_to_processors_ranges(), test_bound_generation(), Tiling2_buffer(), Tiling_buffer_allocation(), tiling_transformation(), top_down_abc_dimension(), type_to_array_type(), unary_into_binary_ref(), unary_intrinsic_call_to_points_to_sinks(), update_indices_for_local_computation(), update_operator_to_post_pv(), update_range(), upper_bound_generation(), usual_loop_tiling(), Value_to_expression(), variable_initial_expression(), variable_to_dimensions(), verify_array_element(), verify_array_variable(), verify_scalar_variable(), and words_dimension().

+ Here is the call graph for this function:

◆ integer_constant_expression_p()

bool integer_constant_expression_p ( expression  e)

positive integer constant expression: call to a positive constant or to a sum of positive integer constant expressions (much too restrictive, but enough for the source codes submitted to PIPS up to now).

Likely to fail and need further extension if subtraction and multiplication are used as probably allowed by C standard.

NormalizeExpression() could be used instead, as it is in fact to compute the value of the expression.

Use previous function instead of this one, and -1 will be a constant...

Definition at line 903 of file expression.c.

905 {
906  syntax s = expression_syntax(e);
907  bool ice = false;
908 
909  if(syntax_call_p(s)) {
910  call c = syntax_call(s);
911  entity cst = call_function(c);
912  list args = call_arguments(c);
913  int i;
914 
915  if(integer_constant_p(cst, &i)) {
916  ice = true;
917  }
918  else if(integer_symbolic_constant_p(cst, &i)) {
919  ice = true;
920  }
921  else if(ENTITY_PLUS_P(cst)||ENTITY_PLUS_C_P(cst)) {
922  expression e1 = EXPRESSION(CAR(args));
923  expression e2 = EXPRESSION(CAR(CDR(args)));
924 
926  }
927  }
928 
929  return ice;
930 }
bool integer_constant_p(entity ent, int *int_p)
Returns the double value associated to a PIPS constant.
Definition: constant.c:542
bool integer_symbolic_constant_p(entity ent, int *int_p)
(*int_p) gets integer constant if any
Definition: constant.c:556
bool integer_constant_expression_p(expression e)
positive integer constant expression: call to a positive constant or to a sum of positive integer con...
Definition: expression.c:903

References call_arguments, call_function, CAR, CDR, ENTITY_PLUS_C_P, ENTITY_PLUS_P, EXPRESSION, expression_syntax, integer_constant_p(), integer_symbolic_constant_p(), syntax_call, and syntax_call_p.

Referenced by full_define_p(), get_final_offset(), integer_constant_expression_value(), integer_divide_to_transformer(), integer_right_shift_to_transformer(), make_send_receive_conversion(), sentence_data_statement(), signed_integer_constant_expression_p(), and test_working_false().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ integer_constant_expression_value()

int integer_constant_expression_value ( expression  e)

Definition at line 1545 of file expression.c.

1546 {
1547  pips_assert("is constant", integer_constant_expression_p(e));
1549 }
int signed_integer_constant_expression_value(expression e)
Definition: expression.c:1551

References integer_constant_expression_p(), pips_assert, and signed_integer_constant_expression_value().

Referenced by c_text_related_entities(), full_define_p(), get_final_offset(), integer_divide_to_transformer(), and integer_right_shift_to_transformer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ integer_expression_p()

bool integer_expression_p ( expression  e)

Definition at line 601 of file expression.c.

602 {
603  basic b = basic_of_expression(e);
604  bool integer_p = basic_int_p(b);
605 
606  free_basic(b);
607  return integer_p;
608 }
#define basic_int_p(x)
Definition: ri.h:614

References basic_int_p, basic_of_expression(), and free_basic().

Referenced by fix_if_condition(), and points_to_cell_to_upper_bound_points_to_cells().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_expression_reference_to_entity_p()

bool is_expression_reference_to_entity_p ( expression  e,
entity  v 
)

Test if an expression is a reference to a given variable entity.

Definition at line 541 of file expression.c.

542 {
543  bool is_e_reference_to_v = false;
544 
545  if(expression_reference_p(e)) {
547 
548  is_e_reference_to_v = (reference_variable(r)==v);
549  }
550  return is_e_reference_to_v;
551 }

References expression_reference_p(), expression_syntax, reference_variable, and syntax_reference.

Referenced by incrementation_expression_to_increment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ local_assign_expression()

void local_assign_expression ( expression  caller,
expression  field 
)

replace expression caller by expression field , where field is contained by caller

Parameters
calleraller
fieldield

Definition at line 3571 of file expression.c.

3572 {
3573  syntax s = expression_syntax(field) ;
3575  free_syntax(expression_syntax(caller));
3576  expression_syntax(caller)=s;
3578 }
void free_syntax(syntax p)
Definition: ri.c:2445
#define syntax_undefined
Definition: ri.h:2676

References expression_normalized, expression_syntax, free_normalized(), free_syntax(), and syntax_undefined.

Referenced by simplify_minmax_expression().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ logical_expression_p()

bool logical_expression_p ( expression  e)

A logical expression is either one of the following:

  • a logical constant
  • the symbolic name of a logical constant
  • a logical variable name
  • a logical array element name
  • a logical function reference
  • a relational expression (.LT.,.LE.,.EQ.,.NE.,.GT.,.GE.)
  • is formed by combining together one or more of the above entities using parentheses and the logical operators .NOT.,.AND.,.OR.,.EQV.,.NEQV.

NN: In fact, I didn't use the PIPS function : basic_of_expression because of 2 reasons :

  • the function basic_of_intrinsic use the macro : ENTITY_LOGICAL_OPERATOR_P which is not like the Fortran Standard definition (the above comments)
  • the case where an expression is a range is not considered here for a logical expression

The case of symbolic name of a logical constant is not treated here

Definition at line 610 of file expression.c.

611 {
612  /* A logical expression is either one of the following:
613  * - a logical constant
614  * - the symbolic name of a logical constant
615  * - a logical variable name
616  * - a logical array element name
617  * - a logical function reference
618  * - a relational expression (.LT.,.LE.,.EQ.,.NE.,.GT.,.GE.)
619  * - is formed by combining together one or more of the above
620  * entities using parentheses and the logical operators
621  * .NOT.,.AND.,.OR.,.EQV.,.NEQV. */
622 
623  /* NN: In fact, I didn't use the PIPS function : basic_of_expression because of 2 reasons :
624  * - the function basic_of_intrinsic use the macro : ENTITY_LOGICAL_OPERATOR_P
625  * which is not like the Fortran Standard definition (the above comments)
626  * - the case where an expression is a range is not considered here for a
627  * logical expression */
628 
629  syntax s = expression_syntax(e);
630  basic b;
631  entity func;
632 
633  pips_debug(2, "\n");
634 
635  switch(syntax_tag(s)) {
636  case is_syntax_reference:
637  {
639  if (basic_logical_p(b))
640  return true;
641  return false;
642  }
643  case is_syntax_call:
644  {
649  return true;
652  if (basic_logical_p(b)) return true;
653 
654  /* The case of symbolic name of a logical constant is not treated here */
655 
656  return false;
657  }
658  case is_syntax_range:
659  return false;
660  default: pips_internal_error("Bad syntax tag");
661  return false;
662  }
663 
664  debug(2, "logical expression", " ends\n");
665 }
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
bool logical_operator_expression_p(expression e)
C xor is missing.
Definition: expression.c:573
bool relational_expression_p(expression e)
Definition: expression.c:587
#define functional_result(x)
Definition: ri.h:1444
#define type_functional(x)
Definition: ri.h:2952
#define variable_basic(x)
Definition: ri.h:3120
#define basic_logical_p(x)
Definition: ri.h:620

References basic_logical_p, call_function, debug(), entity_type, expression_syntax, FALSE_OPERATOR_NAME, functional_result, is_syntax_call, is_syntax_range, is_syntax_reference, logical_operator_expression_p(), operator_expression_p(), pips_debug, pips_internal_error, reference_variable, relational_expression_p(), syntax_call, syntax_reference, syntax_tag, TRUE_OPERATOR_NAME, type_functional, type_variable, and variable_basic.

Referenced by fix_if_condition(), and MakeWhileDoInst().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ logical_operator_expression_p()

bool logical_operator_expression_p ( expression  e)

C xor is missing.

Logical operators are : .NOT.,.AND.,.OR.,.EQV.,.NEQV.

Definition at line 573 of file expression.c.

574 {
575  /* Logical operators are : .NOT.,.AND.,.OR.,.EQV.,.NEQV.*/
576  if (expression_call_p(e))
577  {
579  if (ENTITY_AND_P(op) || ENTITY_OR_P(op) || ENTITY_NOT_P(op) ||
581  return true;
582  return false;
583  }
584  return false;
585 }
#define ENTITY_OR_P(e)
#define ENTITY_AND_P(e)
#define ENTITY_NOT_P(e)
#define ENTITY_NON_EQUIV_P(e)
#define ENTITY_EQUIV_P(e)

References call_function, ENTITY_AND_P, ENTITY_EQUIV_P, ENTITY_NON_EQUIV_P, ENTITY_NOT_P, ENTITY_OR_P, expression_call_p(), expression_syntax, and syntax_call.

Referenced by logical_expression_p(), number_of_operators_flt(), and simplify_boolean_expression_with_precondition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_address_of_expression()

expression make_address_of_expression ( expression  e)

generate a newly allocated expression for &(e)

Definition at line 3956 of file expression.c.

3957 {
3958  if (expression_call_p(e))
3959  {
3960  call c = expression_call(e);
3961  if (ENTITY_DEREFERENCING_P(call_function(c))) // e is "*x"
3962  {
3963  pips_assert("one arg to address operator (&)",
3964  gen_length(call_arguments(c))==1);
3965 
3966  // result is simply "x"
3968  }
3969  }
3970 
3971  // result is "*e"
3973  copy_expression(e));
3974 }
#define ENTITY_DEREFERENCING_P(e)
#define ADDRESS_OF_OPERATOR_NAME

References ADDRESS_OF_OPERATOR_NAME, call_arguments, call_function, CAR, copy_expression(), CreateIntrinsic(), ENTITY_DEREFERENCING_P, EXPRESSION, expression_call(), expression_call_p(), gen_length(), MakeUnaryCall(), and pips_assert.

Referenced by declaration_to_post_pv(), gen_mpi_send_recv(), make_send_receive_conversion(), mpi_initialize(), mpic_make_args_mpi_send_or_receiv(), mpic_make_mpi_comm_rank(), mpic_make_mpi_comm_size(), and mpic_make_mpi_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_assign_expression()

expression make_assign_expression ( expression  lhs,
expression  rhs 
)

Make an assign expression, since in C the assignment is a side effect operator.

Useful in for-loops.

Parameters
lhsmust be a reference
rhsis the expression to assign
Returns
the expression "lhs = rhs"

RK: this assert should be relaxed to deal with *p and so on. pips_assert("Need a reference as lhs", expression_reference_p(lhs));

Parameters
lhshs
rhshs

Definition at line 390 of file expression.c.

391  {
392  /* RK: this assert should be relaxed to deal with *p and so on.
393  pips_assert("Need a reference as lhs", expression_reference_p(lhs)); */
395 }

References ASSIGN_OPERATOR_NAME, CreateIntrinsic(), and MakeBinaryCall().

Referenced by do_loop_nest_unswitching(), and do_loop_to_for_loop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_call_expression()

expression make_call_expression ( entity  e,
list  l 
)

◆ make_constraint_expression()

expression make_constraint_expression ( Pvecteur  v,
Variable  index 
)

Make an expression from a constraint v for a given index.

For example: for a constraint of index I : aI + linear_expr(J,K,TCST) <=0

Returns
the new expression for I that is -expr_linear(J,K,TCST)/a

earch the couple (var,val) where var is equal to index and extract it

If the vector wihout the index is the vector null, we have simply index = 0:

If the coefficient for the index is positive, inverse all the vector since the index goes at the other side of "=":

If coeff is negative, correct the future division rounding (by -coeff) by adding (coeff - 1) to the vector first:

If the vector is simply coeff.index=c, directly generate and return c/coeff:

Generate an expression from the linear vector:

If coeff > 1, divide all the expression by coeff:

FI->YY: before generating a division, you should test if it could not be performed statically; you have to check if ex1 is not a constant expression, which is fairly easy since you still have its linear form, pv

build expressions for the lower and upper bounds

Parameters
indexndex

Definition at line 1748 of file expression.c.

1749 {
1750  Pvecteur pv;
1751  expression ex1, ex2, ex;
1752  entity div;
1753  Value coeff;
1754 
1755  /*search the couple (var,val) where var is equal to index and extract it */
1756  pv = vect_dup(v);
1757  coeff = vect_coeff(index, pv);
1758  vect_erase_var(&pv, index);
1759 
1760  if (VECTEUR_NUL_P(pv))
1761  /* If the vector wihout the index is the vector null, we have simply
1762  index = 0: */
1763  return int_to_expression(0);
1764 
1765  /* If the coefficient for the index is positive, inverse all the
1766  vector since the index goes at the other side of "=": */
1767  if (value_pos_p(coeff))
1768  vect_chg_sgn(pv);
1769  else {
1770  /* If coeff is negative, correct the future division rounding (by
1771  -coeff) by adding (coeff - 1) to the vector first: */
1772  value_absolute(coeff);
1773  vect_add_elem(&pv, TCST, value_minus(coeff, VALUE_ONE));
1774  }
1775 
1776  if(vect_size(pv) == 1 && vecteur_var(pv) == TCST) {
1777  /* If the vector is simply coeff.index=c, directly generate and
1778  return c/coeff: */
1779  vecteur_val(pv) = value_pdiv(vecteur_val(pv), coeff);
1780  return make_vecteur_expression(pv);
1781  }
1782 
1783  /* Generate an expression from the linear vector: */
1784  ex1 = make_vecteur_expression(pv);
1785 
1786  if (value_gt(coeff, VALUE_ONE)) {
1787  /* If coeff > 1, divide all the expression by coeff: */
1788  /* FI->YY: before generating a division, you should test if it could
1789  not be performed statically; you have to check if ex1 is not a
1790  constant expression, which is fairly easy since you still have
1791  its linear form, pv */
1792  /* build expressions for the lower and upper bounds */
1793  if( c_language_module_p(get_current_module_entity()) && !get_bool_property("PRETTYPRINT_DIV_INTRINSICS"))
1795  else // Fortran case and C intrinsics requested
1796  div = gen_find_tabulated("TOP-LEVEL:/",entity_domain);
1797  pips_assert("Division operator not found", div != entity_undefined);
1798 
1799  ex2 = int_to_expression(VALUE_TO_INT(coeff));
1801  make_call(div,
1802  CONS(EXPRESSION,ex1,
1803  CONS(EXPRESSION,
1804  ex2,NIL)))),
1806  return(ex);
1807  }
1808  else
1809  return(ex1);
1810 }
#define value_pos_p(val)
#define value_minus(v1, v2)
#define value_absolute(ref)
#define value_gt(v1, v2)
#define VALUE_TO_INT(val)
#define value_pdiv(v1, v2)
#define VALUE_ONE
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
#define PIPS_C_DIV_OPERATOR_NAME
expression make_vecteur_expression(Pvecteur pv)
make expression for vector (Pvecteur)
Definition: expression.c:1650
bool c_language_module_p(entity m)
Definition: module.c:447
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
void vect_chg_sgn(Pvecteur v)
void vect_chg_sgn(Pvecteur v): multiplie v par -1
Definition: scalaires.c:151
#define vecteur_val(v)
#define vecteur_var(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;.
Definition: alloc.c:51
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....
Definition: unaires.c:106
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...
Definition: unaires.c:72

References c_language_module_p(), CONS, entity_domain, entity_intrinsic(), entity_undefined, EXPRESSION, gen_find_tabulated(), get_bool_property(), get_current_module_entity(), int_to_expression(), is_syntax_call, make_call(), make_expression(), make_syntax(), make_vecteur_expression(), NIL, normalized_undefined, pips_assert, PIPS_C_DIV_OPERATOR_NAME, TCST, value_absolute, value_gt, value_minus, VALUE_ONE, value_pdiv, value_pos_p, VALUE_TO_INT, vect_add_elem(), vect_chg_sgn(), vect_coeff(), vect_dup(), vect_erase_var(), vect_size(), VECTEUR_NUL_P, vecteur_val, and vecteur_var.

Referenced by make_bound_expression(), and make_contrainte_expression().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_contrainte_expression()

expression make_contrainte_expression ( Pcontrainte  pc,
Variable  index 
)

A wrapper around make_constraint_expression() for compatibility.

Simply call the function on the vector in the constrain system:

Parameters
pcc
indexndex

Definition at line 1815 of file expression.c.

1815  {
1816  /* Simply call the function on the vector in the constrain system: */
1817  return make_constraint_expression(pc->vecteur, index);
1818 }
expression make_constraint_expression(Pvecteur v, Variable index)
Make an expression from a constraint v for a given index.
Definition: expression.c:1748
Pvecteur vecteur

References make_constraint_expression(), and Scontrainte::vecteur.

Referenced by free_guards().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_entity_expression()

expression make_entity_expression ( entity  e,
cons inds 
)
Parameters
indsnds

Definition at line 176 of file expression.c.

177 {
179  if( entity_constant_p(e) )
180  {
182  }
183  else
184  {
185  reference r = make_reference(e, inds);
186  s = make_syntax_reference(r);
187  }
188  return syntax_to_expression(s);
189 }
syntax make_syntax_call(call _field_)
Definition: ri.c:2500
syntax make_syntax_reference(reference _field_)
Definition: ri.c:2494
expression syntax_to_expression(syntax s)
generates an expression from a syntax
Definition: expression.c:3581

References entity_constant_p, make_call(), make_reference(), make_syntax_call(), make_syntax_reference(), NIL, syntax_to_expression(), and syntax_undefined.

Referenced by alloc_instrumentation(), assign_tmp_to_exp(), atomizer_of_external(), build_flag_assign(), build_flag_test(), build_global_time_test_with_exp(), build_local_time_test(), build_third_comb(), cstr_args_check(), distribute_code(), edge_cost_polynome(), expression_try_find_size(), find_tmp_of_exp(), gen_mpi_send_recv(), get_sp_of_call_p(), loop_header(), loop_inc(), loop_normalize_of_loop(), loop_test(), make_array_communication_statement(), make_com_loopbody(), make_communication_statement(), make_increment_instruction(), make_init_time(), make_loadsave_statement(), make_send_receive_conversion(), make_start_ru_module(), mpi_finalize(), mpi_initialize(), mpic_make_args_mpi_send_or_receiv(), mpic_make_mpi_comm_rank(), mpic_make_mpi_comm_size(), mpic_make_mpi_init(), put_source_ind(), sprintf_check_expression(), and task_time_polynome().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_factor_expression()

expression make_factor_expression ( int  coeff,
entity  vari 
)

Some functions to generate expressions from vectors and constraint systems.

expression make_factor_expression(int coeff, entity vari) make the expression "coeff*vari" where vari is an entity.

a constant only

Parameters
coeffoeff
variari

Definition at line 1631 of file expression.c.

1632 {
1633  expression e1, e2, e3;
1634 
1635  e1 = int_to_expression(coeff);
1636  if (vari==NULL)
1637  return(e1); /* a constant only */
1638  else {
1639  e2 = entity_to_expression(vari);
1640  if (coeff == 1) return(e2);
1641  else {
1643  return (e3);
1644  }
1645  }
1646 }
#define MULTIPLY_OPERATOR_NAME

References entity_intrinsic(), entity_to_expression(), int_to_expression(), MakeBinaryCall(), and MULTIPLY_OPERATOR_NAME.

Referenced by ecrit_une_var(), icm_loop_rwt(), and make_vecteur_expression().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_false_expression()

expression make_false_expression ( void  )

Definition at line 1108 of file expression.c.

1109 {
1111 }
expression make_call_expression(entity e, list l)
Build an expression that call an function entity with an argument list.
Definition: expression.c:321

References FALSE_OPERATOR_NAME, is_basic_logical, make_call_expression(), MakeConstant(), and NIL.

Referenced by simplify_boolean_expression_with_precondition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_lin_op_exp()

expression make_lin_op_exp ( entity  op_ent,
expression  exp1,
expression  exp2 
)

================================================================

expression make_lin_op_exp(entity op_ent, expression exp1 exp2): returns the expression resulting of the linear operation (ie. + or -) "op_ent" between two integer linear expressions "exp1" and "exp2".

This function uses the linear library for manipulating Pvecteurs. exp1 and exp2 are freed

Pvecteur_to_expression() is a function that rebuilds an expression from a Pvecteur.

Parameters
op_entp_ent
exp1xp1
exp2xp2

Definition at line 2147 of file expression.c.

2148 {
2149  Pvecteur V1, V2, newV = VECTEUR_NUL;
2150 
2151  debug( 7, "make_lin_op_exp", "doing\n");
2154  pips_internal_error( "expressions MUST be linear and normalized");
2155 
2158 
2159  if (ENTITY_PLUS_P(op_ent))
2160  newV = vect_add(V1, V2);
2161  else if (ENTITY_MINUS_P(op_ent))
2162  newV = vect_substract(V1, V2);
2163  else
2164  pips_internal_error("operation must be : + or -");
2165  free_expression(exp1);
2166  free_expression(exp2);
2167 
2168  return(Pvecteur_to_expression(newV));
2169 }
expression Pvecteur_to_expression(Pvecteur vect)
AP, sep 25th 95 : some usefull functions moved from static_controlize/utils.c.
Definition: expression.c:1825
#define normalized_complex_p(x)
Definition: ri.h:1782
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.
struct Svecteur * Pvecteur
Pvecteur vect_add(Pvecteur v1, Pvecteur v2)
package vecteur - operations binaires
Definition: binaires.c:53
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...
Definition: binaires.c:75

References debug(), ENTITY_MINUS_P, ENTITY_PLUS_P, expression_normalized, free_expression(), normalized_complex_p, normalized_linear, pips_internal_error, Pvecteur_to_expression(), vect_add(), vect_substract(), and VECTEUR_NUL.

Referenced by make_op_exp(), and rational_op_exp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_list_of_constant()

list make_list_of_constant ( int  val,
int  number 
)

of expression

the length of the created list

Parameters
valal
numberthe constant value

Definition at line 3369 of file expression.c.

3371 {
3372  list l=NIL;
3373 
3374  pips_assert("valid number", number>=0);
3375  for(; number; number--)
3376  l = CONS(EXPRESSION, int_to_expression(val), l);
3377 
3378  return l;
3379 }

References CONS, EXPRESSION, int_to_expression(), NIL, and pips_assert.

Referenced by hpfc_compute_lid(), st_compute_current_computer(), st_compute_current_owners(), and translate_to_module_frame().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_max_expression()

expression make_max_expression ( expression  e1,
expression  e2,
enum language_utype  lang 
)
Parameters
e11
e22
langang

Definition at line 1579 of file expression.c.

1580 {
1581  expression new_exp = expression_undefined;
1582  if (lang == is_language_c)
1583  {
1585  copy_expression(e1),
1586  copy_expression(e2));
1588  comp_exp,
1589  e2,
1590  e1);
1591  }
1592  else
1593  {
1595  e1,e2);
1596  }
1597  return new_exp;
1598 }
#define MAX_OPERATOR_NAME
#define CONDITIONAL_OPERATOR_NAME
#define C_LESS_THAN_OPERATOR_NAME
expression MakeTernaryCall(entity f, expression e1, expression e2, expression e3)
Creates a call expression to a function with 3 arguments.
Definition: expression.c:367
@ is_language_c
Definition: ri.h:1567

References C_LESS_THAN_OPERATOR_NAME, CONDITIONAL_OPERATOR_NAME, copy_expression(), entity_intrinsic(), expression_undefined, is_language_c, MakeBinaryCall(), MakeTernaryCall(), and MAX_OPERATOR_NAME.

Referenced by loop_annotate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_min_expression()

expression make_min_expression ( expression  e1,
expression  e2,
enum language_utype  lang 
)
Parameters
e11
e22
langang

Definition at line 1600 of file expression.c.

1601 {
1602  expression new_exp = expression_undefined;
1603  if (lang == is_language_c)
1604  {
1606  copy_expression(e1),
1607  copy_expression(e2));
1609  comp_exp,
1610  e1,
1611  e2);
1612  }
1613  else
1614  {
1616  e1,e2);
1617  }
1618  return new_exp;
1619 }
#define MIN_OPERATOR_NAME

References C_LESS_THAN_OPERATOR_NAME, CONDITIONAL_OPERATOR_NAME, copy_expression(), entity_intrinsic(), expression_undefined, is_language_c, MakeBinaryCall(), MakeTernaryCall(), and MIN_OPERATOR_NAME.

Referenced by loop_annotate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_op_exp()

expression make_op_exp ( char *  op_name,
expression  exp1,
expression  exp2 
)

================================================================

expression make_op_exp(char *op_name, expression exp1 exp2): Returns an expression containing the operation "op_name" between "exp1" and "exp2". "op_name" must be one of the four classic operations : +, -, * or /.

If both expressions are integer constant values and the operation result is an integer then the returned expression contained the calculated result.

Else, we treat five special cases : _ exp1 and exp2 are integer linear and op_name is + or -. This case is resolved by make_lin_op_exp(). _ exp1 = 0 _ exp1 = 1 _ exp2 = 0 _ exp2 = 1

Else, we create a new expression with a binary call.

Note: The function MakeBinaryCall() comes from Pips/.../syntax/expression.c The function int_to_expression() comes from ri-util.

Warning: using the same semantic as MakeBinaryCall, make_op_exp owns the pointer exp1 and exp2 after the call, beware of not sharing them !

pips_debug(5, "begin OP EXP : %s %s %s\n",

words_to_string(words_expression(exp1, NIL)),

op_name,

words_to_string(words_expression(exp2, NIL)));

ENTITY_DIVIDE_P(op_ent)

we compute here as FORTRAN would do

We need to know the integer linearity of both expressions.

dividing by one or minus one is similar to multiplying

ENTITY_MULTIPLY_P(op_ent) || ENTITY_DIVIDE_P(op_ent)

ENTITY_DIVIDE_P(op_ent)

pips_debug(5, "end OP EXP : %s\n",

words_to_string(words_expression(result_exp, NIL)));

Parameters
op_namep_name
exp1xp1
exp2xp2

Definition at line 2012 of file expression.c.

2013 {
2014  expression result_exp = expression_undefined;
2015  entity op_ent, unary_minus_ent;
2016 
2017  debug( 7, "make_op_exp", "doing\n");
2019  op_name), entity_domain);
2020  unary_minus_ent =
2023  entity_domain);
2024 
2025  // FI: to avoid cycle between the ri and prettyprint libraries
2026  /* pips_debug(5, "begin OP EXP : %s %s %s\n", */
2027  /* words_to_string(words_expression(exp1, NIL)), */
2028  /* op_name, */
2029  /* words_to_string(words_expression(exp2, NIL))); */
2030 
2031  if( ! ENTITY_FIVE_OPERATION_P(op_ent) )
2032  user_error("make_op_exp", "operation must be : +, -, *, MOD, or /");
2033 
2034  intptr_t val1, val2;
2035  if( expression_integer_value(exp1,&val1) && expression_integer_value(exp2,&val2) )
2036  {
2037 
2038  debug(6, "make_op_exp", "Constant expressions\n");
2039 
2040  if (ENTITY_PLUS_P(op_ent))
2041  result_exp = int_to_expression(val1 + val2);
2042  else if(ENTITY_MINUS_P(op_ent))
2043  result_exp = int_to_expression(val1 - val2);
2044  else if(ENTITY_MULTIPLY_P(op_ent))
2045  result_exp = int_to_expression(val1 * val2);
2046  else if(ENTITY_MODULO_P(op_ent))
2047  result_exp = int_to_expression(val1 % val2);
2048  else /* ENTITY_DIVIDE_P(op_ent) */
2049  /* we compute here as FORTRAN would do */
2050  result_exp = int_to_expression((int) (val1 / val2));
2051  free_expression(exp1);
2052  free_expression(exp2);
2053  }
2054  else
2055  {
2056  /* We need to know the integer linearity of both expressions. */
2057  normalized nor1 = NORMALIZE_EXPRESSION(exp1);
2058  normalized nor2 = NORMALIZE_EXPRESSION(exp2);
2059 
2060  /* dividing by one or minus one is similar to multiplying */
2061  _int val;
2062  if(( ENTITY_DIVIDE_P(op_ent) || ENTITY_MULTIPLY_P(op_ent))
2063  && expression_integer_value(exp2,&val)
2064  && ( val == -1) ) {
2065  free_expression(exp2);
2067  }
2068 
2069  if((normalized_linear_p(nor1) && normalized_linear_p(nor2) ) &&
2070  (ENTITY_PLUS_P(op_ent) || ENTITY_MINUS_P(op_ent) ) )
2071  {
2072  pips_debug(6, "Linear operation\n");
2073 
2074  result_exp = make_lin_op_exp(op_ent, copy_expression(exp1), copy_expression(exp2));
2075  }
2076  else if(expression_equal_integer_p(exp1, 0))
2077  {
2078  if (ENTITY_PLUS_P(op_ent)) {
2079  result_exp = exp2;
2080  free_expression(exp1);
2081  }
2082  else if(ENTITY_MINUS_P(op_ent)) {
2083  result_exp = MakeUnaryCall(unary_minus_ent, exp2);
2084  free_expression(exp1);
2085  }
2086  else /* ENTITY_MULTIPLY_P(op_ent) || ENTITY_DIVIDE_P(op_ent) */ {
2087  result_exp = int_to_expression(0);
2088  free_expression(exp1);free_expression(exp2);
2089  }
2090  }
2091  else if(expression_equal_integer_p(exp1, 1))
2092  {
2093  if(ENTITY_MULTIPLY_P(op_ent)) {
2094  result_exp = exp2;
2095  free_expression(exp1);
2096  }
2097  }
2098  else if(expression_equal_integer_p(exp2, 0))
2099  {
2100  free_expression(exp2);
2101  if (ENTITY_PLUS_P(op_ent) || ENTITY_MINUS_P(op_ent))
2102  result_exp = exp1;
2103  else if (ENTITY_MULTIPLY_P(op_ent)) {
2104  result_exp = int_to_expression(0);
2105  free_expression(exp1);
2106  }
2107  else /* ENTITY_DIVIDE_P(op_ent) */
2108  user_error("make_op_exp", "division by zero");
2109  }
2110  else if(expression_equal_integer_p(exp2, 1))
2111  {
2112  if(ENTITY_MULTIPLY_P(op_ent) || ENTITY_DIVIDE_P(op_ent)) {
2113  result_exp = exp1;
2114  free_expression(exp2);
2115  }
2116  }
2117  }
2118 
2119  if(result_exp == expression_undefined)
2120  result_exp = MakeBinaryCall(op_ent, exp1, exp2);
2121 
2122  // FI: to avoid cycle between the ri and prettyprint libraries
2123  /* pips_debug(5, "end OP EXP : %s\n", */
2124  /* words_to_string(words_expression(result_exp, NIL))); */
2125 
2126  return (result_exp);
2127 }
string make_entity_fullname(const char *module_name, const char *local_name)
END_EOLE.
Definition: entity_names.c:230
#define user_error(fn,...)
Definition: misc-local.h:265
intptr_t _int
_INT
Definition: newgen_types.h:53
#define ENTITY_MODULO_P(e)
expression make_lin_op_exp(entity op_ent, expression exp1, expression exp2)
================================================================
Definition: expression.c:2147
bool expression_equal_integer_p(expression exp, int i)
================================================================
Definition: expression.c:1977

References copy_expression(), debug(), ENTITY_DIVIDE_P, entity_domain, ENTITY_FIVE_OPERATION_P, ENTITY_MINUS_P, ENTITY_MODULO_P, ENTITY_MULTIPLY_P, ENTITY_PLUS_P, expression_equal_integer_p(), expression_integer_value(), expression_undefined, free_expression(), gen_find_tabulated(), int_to_expression(), intptr_t, make_entity_fullname(), make_lin_op_exp(), MakeBinaryCall(), MakeUnaryCall(), MINUS_OPERATOR_NAME, NORMALIZE_EXPRESSION, normalized_linear_p, pips_debug, TOP_LEVEL_MODULE_NAME, UNARY_MINUS_OPERATOR_NAME, and user_error.

Referenced by add_integer_to_expression(), ajoute_constante(), ajoute_new_var(), bdt_save_pred(), build_third_comb(), C_loop_range(), calloc_to_abstract_location(), compute_final_index_value(), contraintes_to_expression(), distance_between_entity(), distance_between_expression(), do_gather_all_expressions(), do_group_constants_terapix(), do_group_count_elements_reduce(), do_grouping_replace_reference_by_expression_walker(), do_linearize_array_reference(), do_linearize_type(), do_loop_expansion(), do_loop_expansion_init(), do_sizeofdimension_reduction(), do_solve_hardware_constraints_on_nb_proc(), do_symbolic_tiling(), do_terapix_warmup_patching(), ecrit_une_var(), ecrit_une_var_neg(), generate_call_get_workchunk_loopbounds(), heap_intrinsic_to_post_pv(), initialization_list_to_statements(), loop_annotate(), loop_normalize_of_loop(), loop_strip_mine(), malloc_arg_to_type(), monome_to_expression(), ndf_normalized_test(), normalize_test_leaves(), offset_of_struct(), partial_eval_min_or_max_operator(), polynome_to_expression(), put_source_ind(), range_to_expression(), rational_sol_edit(), reference_offset(), region_to_minimal_dimensions(), save_pred(), sc_opposite_exp_of_conjunction(), sesamify(), simplify_minmax_expression(), SizeOfDimension(), try_reorder_expression_call(), and whileloop_to_complexity().

+ Here is the call graph for this function:

◆ make_ref_expr()

expression make_ref_expr ( entity  ent,
list  args 
)
Parameters
entnt
argsrgs

Definition at line 4316 of file expression.c.

4317 {
4319  make_reference(ent, args)),
4321 }

References is_syntax_reference, make_expression(), make_reference(), make_syntax(), and normalized_undefined.

Referenced by do_loop_unroll_with_epilogue(), do_loop_unroll_with_prologue(), and full_loop_unroll().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_subscript_expression()

expression make_subscript_expression ( expression  a,
list  sl 
)
Parameters
sll

Definition at line 397 of file expression.c.

398 {
399  subscript i = make_subscript(a, sl);
402  return e;
403 }

References make_subscript(), make_syntax_subscript(), and syntax_to_expression().

+ Here is the call graph for this function:

◆ make_true_expression()

◆ make_unbounded_expression()

expression make_unbounded_expression ( void  )

Definition at line 4339 of file expression.c.

4340 {
4342 }
#define UNBOUNDED_DIMENSION_NAME
Definition: ri-util-local.h:74

References CreateIntrinsic(), MakeNullaryCall(), and UNBOUNDED_DIMENSION_NAME.

Referenced by array_formal_parameter_to_stub_points_to(), binary_arithmetic_operator_to_post_pv(), binary_intrinsic_call_to_points_to_sinks(), complete_points_to_reference_with_fixed_subscripts(), create_pointer_to_array_stub_points_to(), effect_interference(), effect_may_union(), effect_must_union(), effect_to_store_independent(), generic_reference_add_fixed_subscripts(), make_unbounded_dimensions(), make_unbounded_subscripts(), MakeDimension(), malloc_arg_to_type(), module_initial_parameter_pv(), offset_array_reference(), offset_points_to_cell(), points_to_cell_to_upper_bound_points_to_cells(), points_to_cell_types_compatibility(), points_to_cell_update_last_subscript(), points_to_indices_to_subscript_indices(), points_to_indices_to_unbounded_indices(), proper_to_summary_simple_effect(), reference_with_store_independent_indices(), simple_pv_may_union(), simple_pv_must_union(), simplified_reference(), struct_assignment_to_points_to(), struct_variable_to_pointer_locations(), struct_variable_to_pointer_subscripts(), subscript_expressions_to_constant_subscript_expressions(), type_to_array_type(), and update_operator_to_post_pv().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_unbounded_subscripts()

list make_unbounded_subscripts ( int  d)

FI: this piece of code must have been duplicated somewhere else in an effect library.

Definition at line 4346 of file expression.c.

4347 {
4348  list sl = NIL;
4349  int i;
4350 
4351  for(i=0; i<d; i++) {
4353  }
4354 
4355  return sl;
4356 }

References CONS, EXPRESSION, make_unbounded_expression(), and NIL.

Referenced by cells_to_read_or_write_effects().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_vecteur_expression()

expression make_vecteur_expression ( Pvecteur  pv)

make expression for vector (Pvecteur)

sort: to insure a deterministic generation of the expression. note: the initial system is NOT touched. ??? Sometimes the vectors are shared, so you cant modify them that easily. Many cores in Hpfc (deducables), Wp65, and so. ok, I'm responsible for some of them:-)

(c) FC 24/11/94 SG: added support for generation of C operator when needed

let us avoid -1*var, we prefer -var

choose among C or fortran operator depending on the entity type this limits the use of +C and -C to pointer arithmetic

Parameters
pvv

Definition at line 1650 of file expression.c.

1651 {
1652  /* sort: to insure a deterministic generation of the expression.
1653  * note: the initial system is *NOT* touched.
1654  * ??? Sometimes the vectors are shared, so you cant modify them
1655  * that easily. Many cores in Hpfc (deducables), Wp65, and so.
1656  * ok, I'm responsible for some of them:-)
1657  *
1658  * (c) FC 24/11/94
1659  * SG: added support for generation of C operator when needed
1660  */
1661  Pvecteur
1662  v_sorted = vect_sort(pv, compare_Pvecteur),
1663  v = v_sorted;
1664  expression factor1, factor2;
1665  entity op_add, op_sub,
1666  c_op_add, c_op_sub;
1667  int coef;
1668 
1673 
1674  if (VECTEUR_NUL_P(v))
1675  return int_to_expression(0);
1676 
1677  coef = VALUE_TO_INT(vecteur_val(v));
1678 
1679  entity var = (entity) vecteur_var(v);
1680  bool next_op_is_c = var !=TCST && entity_pointer_p(var);
1681  if (coef==-1) /* let us avoid -1*var, we prefer -var */
1682  {
1684  factor1 = make_factor_expression(1, (entity) vecteur_var(v));
1685  factor1 = call_to_expression
1686  (make_call(op_ums, CONS(EXPRESSION, factor1, NIL)));
1687  }
1688  else
1689  factor1 = make_factor_expression(coef, (entity) vecteur_var(v));
1690 
1691  for (v=v->succ; v!=NULL; v=v->succ)
1692  {
1693  var = (entity) vecteur_var(v);
1694  coef = VALUE_TO_INT(vecteur_val(v));
1695  pips_assert("some coefficient", coef!=0);
1696  factor2 = make_factor_expression(ABS(coef), var);
1697  /* choose among C or fortran operator depending on the entity type
1698  * this limits the use of +C and -C to pointer arithmetic
1699  */
1700  entity op =
1701  ( next_op_is_c ) ?
1702  ( coef> 0 ? c_op_add : c_op_sub ) :
1703  ( coef> 0 ? op_add : op_sub ) ;
1704  factor1 = MakeBinaryCall(op,factor1,factor2);
1705  next_op_is_c = var !=TCST && entity_pointer_p(var);
1706  }
1707 
1708  vect_rm(v_sorted);
1709 
1710  return factor1;
1711 }
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
#define ABS(x)
was: #define value_mult(v,w) value_direct_multiply(v,w) #define value_product(v,w) value_direct_produ...
int compare_Pvecteur(Pvecteur *pv1, Pvecteur *pv2)
comparison function for Pvecteur in pips, to be used by qsort.
Definition: constraint.c:50
#define MINUS_C_OPERATOR_NAME
expression make_factor_expression(int coeff, entity vari)
Some functions to generate expressions from vectors and constraint systems.
Definition: expression.c:1631
void vect_rm(Pvecteur v)
void vect_rm(Pvecteur v): desallocation des couples de v;
Definition: alloc.c:78
Pvecteur vect_sort(Pvecteur v, int *compare)
Pvecteur vect_sort(v, compare) Pvecteur v; int (*compare)();.
Definition: unaires.c:335

References ABS, call_to_expression(), compare_Pvecteur(), CONS, entity_intrinsic(), entity_pointer_p(), EXPRESSION, int_to_expression(), make_call(), make_factor_expression(), MakeBinaryCall(), MINUS_C_OPERATOR_NAME, MINUS_OPERATOR_NAME, NIL, pips_assert, PLUS_C_OPERATOR_NAME, PLUS_OPERATOR_NAME, TCST, UNARY_MINUS_OPERATOR_NAME, VALUE_TO_INT, vect_rm(), vect_sort(), VECTEUR_NUL_P, vecteur_val, and vecteur_var.

Referenced by array_indices_communication(), array_scalar_access_to_bank_communication(), build_esv_list(), build_third_comb(), complex_bound_generation(), constraints_to_loop_bound(), contraintes_to_expression(), eval_var(), expression_to_expression_newbase(), generate_subarray_shift(), get_exp_schedule(), lower_bound_generation(), make_array_bounds(), make_constraint_expression(), make_datum_movement(), make_movement_scalar_wp65(), make_movements_loop_body_wp65(), make_rational_exp(), negate_expression(), partial_eval_expression(), Pcontrainte_to_expression_list(), phi_free_contraints_to_expressions(), predicate_to_expression(), psystem_to_expression(), put_source_ind(), Pvecteur_to_assign_statement(), Pvecteur_to_expression(), reduce_loop_bound(), reference_conversion_computation(), test_bound_generation(), upper_bound_generation(), vect_to_string(), and vectors_to_expressions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_zero_expression()

expression make_zero_expression ( void  )

Make a zero expression.

It is useful compared to int_to_expression(0) because it is much easier to search in source text.

Definition at line 1212 of file expression.c.

1213 {
1214  return int_to_expression(0);
1215 }

References int_to_expression().

Referenced by array_formal_parameter_to_stub_points_to(), create_scalar_stub_sink_cell(), find_points_to_subscript_for_type(), generic_reference_to_transformer(), pointer_source_to_sinks(), and subscript_to_points_to_sinks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeBinaryCall()

expression MakeBinaryCall ( entity  f,
expression  eg,
expression  ed 
)

Creates a call expression to a function with 2 arguments.

Parameters
fis the function entity to call
egis the first argument expression given to the function to call
edis the second argument expression given to the function to call
Parameters
egg
edd

Definition at line 354 of file expression.c.

354  {
356  CONS(EXPRESSION, ed, NIL)));
357 }

References CONS, EXPRESSION, f(), make_call_expression(), and NIL.

Referenced by any_basic_update_operation_to_transformer(), any_basic_update_to_transformer_list(), any_update_to_transformer_list(), array_scalar_access_to_bank_communication(), basic_update_reflhs_with_rhs_to_transformer(), binary_arithmetic_operator_to_post_pv(), bound_to_statement(), buffer_full_condition(), c_dim_string(), c_reference(), call_rwt(), compile_master(), compute_final_index_value(), constraints_to_loop_bound(), convert_bound_expression(), ctx_generate_new_statement_cluster_dependant(), derived_formal_parameter_to_stub_points_to(), dimensions_to_dma(), do_array_to_pointer_walk_expression(), do_brace_expression_to_statements(), do_expression_reduction(), do_loop_expansion(), do_loop_to_for_loop(), do_loop_to_while_loop(), do_loop_unroll_with_epilogue(), do_loop_unroll_with_prologue(), do_reduction_atomization(), do_solve_hardware_constraints_on_nb_proc(), do_split_structure(), do_terapix_remove_divide(), do_terapix_warmup_patching(), expand_call(), expr_compute_local_index(), expression_list_to_binary_operator_call(), fix_if_condition(), gen_if_rank(), generate_monome(), get_allocatable_data_expr(), gfc2pips_buildCaseTest(), gfc2pips_code2instruction_(), gfc2pips_dumpSELECT(), gfc2pips_expr2expression(), gfc2pips_reduce_repeated_values(), gfc2pips_symbol2data_instruction(), guard_expanded_statement(), heap_intrinsic_to_post_pv(), hpfc_add_2(), hpfc_add_n(), loop_annotate(), loop_strip_mine(), make_assign_expression(), make_body_from_loop(), make_condition_from_loop(), make_expression_with_state_variable(), make_factor_expression(), make_fields_assignment_instruction(), make_increment_statement(), make_max_exp(), make_max_expression(), make_min_expression(), make_movements_loop_body_wp65(), make_op_exp(), make_scalar_communication_module(), make_scanning_over_tiles(), make_start_ru_module(), make_vecteur_expression(), MakeArithmIfInst(), MakeAssignedOrComputedGotoInst(), MakeComplexConstantExpression(), MakeDimension(), MakeFortranBinaryCall(), makeTransfertSizeExpression(), MakeWhileDoInst(), ndf_normalized_test(), normalize_test_leaves(), outliner_extract_loop_bound(), overlap_redefine_expression(), partial_eval_binary_operator_old(), partial_eval_mult_operator(), partial_eval_plus_or_minus_operator(), Pcontrainte_to_expression_list(), phi_free_contraints_to_expressions(), predicate_to_expression(), psystem_to_expression(), rational_op_exp(), regenerate_expression(), region_to_address(), region_to_minimal_dimensions(), sc_conditional(), sc_opposite_exp_of_conjunction(), sesamify(), simdizer_auto_tile(), simplify_complex_expression(), split_complex_expression(), split_update_call(), st_send_to_computer_if_necessary(), step_local_regionArray(), string_to_expression(), terapix_normalize_tests(), translate_to_module_frame(), typedef_formal_parameter_to_stub_points_to(), unsugared_loop_inc(), unsugared_loop_test(), update_indices_for_local_computation(), update_operation_to_transformer(), update_range(), update_reflhs_with_rhs_to_transformer(), update_test_condition(), and words_dimension().

+ Here is the call graph for this function:

◆ MakeBraceExpression()

expression MakeBraceExpression ( list  l)

Definition at line 3927 of file expression.c.

3928 {
3930 }
#define BRACE_INTRINSIC
Definition: ri-util-local.h:85

References BRACE_INTRINSIC, CreateIntrinsic(), and make_call_expression().

+ Here is the call graph for this function:

◆ MakeCastExpression()

expression MakeCastExpression ( type  t,
expression  e 
)

exp = (t) e

Definition at line 3911 of file expression.c.

3912 {
3913  syntax s = make_syntax_cast(make_cast(t,e));
3915  return exp; /* exp = (t) e */
3916 }
cast make_cast(type a1, expression a2)
Definition: ri.c:311
syntax make_syntax_cast(cast _field_)
Definition: ri.c:2503

References exp, make_cast(), make_expression(), make_syntax_cast(), and normalized_undefined.

Referenced by cast_STEP_ARG().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeCommaExpression()

expression MakeCommaExpression ( list  l)

Definition at line 3918 of file expression.c.

3919 {
3920  if (ENDP(l))
3921  return expression_undefined;
3922  if (gen_length(l)==1)
3923  return EXPRESSION(CAR(l));
3925 }
#define COMMA_OPERATOR_NAME

References CAR, COMMA_OPERATOR_NAME, CreateIntrinsic(), ENDP, EXPRESSION, expression_undefined, gen_length(), and make_call_expression().

Referenced by MakeArrayExpression(), and MakeWhileLoop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeNullaryCall()

expression MakeNullaryCall ( entity  f)

Creates a call expression to a function with zero arguments.

Parameters
fis the function entity to call

Definition at line 331 of file expression.c.

332 {
333  return make_call_expression(f, NIL);
334 }

References f(), make_call_expression(), and NIL.

Referenced by bool_to_expression(), DeclarePointer(), dims_array_init(), expression_list_to_conjonction(), gfc2pips_array_ref2indices(), gfc2pips_code2instruction_(), gfc2pips_expr2expression(), gfc2pips_exprIO2(), gfc2pips_exprIO3(), gfc2pips_get_list_of_dimensions2(), make_simple_Fortran_io_instruction(), make_unbounded_expression(), MakeAtom(), MakeCharacterConstantExpression(), and MakeSimpleIoInst1().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeSizeofExpression()

expression MakeSizeofExpression ( expression  e)

exp = sizeof(e)

Definition at line 3896 of file expression.c.

3897 {
3898 
3901  return exp; /* exp = sizeof(e)*/
3902 }
sizeofexpression make_sizeofexpression_expression(expression _field_)
Definition: ri.c:2180
syntax make_syntax_sizeofexpression(sizeofexpression _field_)
Definition: ri.c:2506

References exp, make_expression(), make_sizeofexpression_expression(), make_syntax_sizeofexpression(), and normalized_undefined.

Referenced by get_sizeofexpression_for_region().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeSizeofType()

expression MakeSizeofType ( type  t)

exp = sizeof(t)

Definition at line 3904 of file expression.c.

3905 {
3908  return exp; /* exp = sizeof(t) */
3909 }
sizeofexpression make_sizeofexpression_type(type _field_)
Definition: ri.c:2177

References exp, make_expression(), make_sizeofexpression_type(), make_syntax_sizeofexpression(), and normalized_undefined.

Referenced by get_sizeofexpression_for_region().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeTernaryCall()

expression MakeTernaryCall ( entity  f,
expression  e1,
expression  e2,
expression  e3 
)

Creates a call expression to a function with 3 arguments.

Parameters
fis the function entity to call
e1is the first argument expression given to the function to call
e2is the second argument expression given to the function to call
e3is the second argument expression given to the function to call
Parameters
e11
e22
e33

Definition at line 367 of file expression.c.

370  {
371  return make_call_expression(f,
372  CONS(EXPRESSION, e1,
373  CONS(EXPRESSION, e2,
374  CONS(EXPRESSION, e3,
375  NIL))));
376 }

References CONS, EXPRESSION, f(), make_call_expression(), and NIL.

Referenced by expr_compute_local_index(), make_max_expression(), make_min_expression(), and make_phi_assign_instruction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeUnaryCall()

expression MakeUnaryCall ( entity  f,
expression  a 
)

Creates a call expression to a function with one argument.

Parameters
fis the function entity to call
ais the argument expression given to the function to call

Definition at line 342 of file expression.c.

343 {
344  return make_call_expression(f, CONS(EXPRESSION, a, NIL));
345 }

References CONS, EXPRESSION, f(), make_call_expression(), and NIL.

Referenced by binary_arithmetic_operator_to_post_pv(), binary_intrinsic_call_to_points_to_sinks(), call_STEP_subroutine3(), compute_final_index_value(), dag_normalize(), dereference_expression(), dimensions_to_dma(), do_array_to_pointer_walk_expression(), do_linearize_array_manage_callers(), do_outliner_smart_replacment(), do_terapix_argument_handler(), ecrit_une_var_neg(), expr_compute_local_index(), generate_compact(), generate_monome(), get_expression_addr(), heap_intrinsic_to_post_pv(), if_conv_init_statement(), incrementation_expression_to_increment(), initialization_list_to_statements(), inline_expression_call(), int_to_expression(), intrinsic_call_to_points_to(), make_address_of_expression(), make_op_exp(), make_substitution(), MakeArithmIfInst(), MakeFortranUnaryCall(), normalize_microcode(), normalize_test_leaves(), outliner_patch_parameters(), outliner_smart_references_computation(), rational_op_exp(), recover_structured_while(), regenerate_expression(), region_to_address(), replace_reductions_in_statement(), scalopify(), simplify_complex_expression(), st_make_nice_test(), static_controlize_statement(), string_to_expression(), translate_to_module_frame(), and update_range().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ max0_expression_p()

bool max0_expression_p ( expression  e)

Definition at line 1061 of file expression.c.

1063 {
1066 }
#define MAX0_OPERATOR_NAME

References MAX0_OPERATOR_NAME, MAX_OPERATOR_NAME, and operator_expression_p().

+ Here is the call graph for this function:

◆ min0_expression_p()

bool min0_expression_p ( expression  e)

Definition at line 1054 of file expression.c.

1056 {
1059 }
#define MIN0_OPERATOR_NAME

References MIN0_OPERATOR_NAME, MIN_OPERATOR_NAME, and operator_expression_p().

+ Here is the call graph for this function:

◆ modulo_expression_p()

bool modulo_expression_p ( expression  e)

Definition at line 1006 of file expression.c.

1008 {
1010 }
#define MODULO_OPERATOR_NAME

References MODULO_OPERATOR_NAME, and operator_expression_p().

+ Here is the call graph for this function:

◆ monome_to_expression()

expression monome_to_expression ( Pmonome  pm)

converts a monome to an expression

Parameters
pmm

Definition at line 3589 of file expression.c.

3590 {
3591  if (MONOME_UNDEFINED_P(pm))
3592  return expression_undefined;
3593  else {
3594  expression coeff;
3595  float x= monome_coeff(pm);
3596  if(x == (int)x)
3597  coeff = (x==1.f)? expression_undefined:int_to_expression((int)x);
3598  else
3599  coeff = float_to_expression(x);
3601  for(Pvecteur v = monome_term(pm);!VECTEUR_NUL_P(v);v=vecteur_succ(v)) {
3602  Value exp = vecteur_val(v);
3603  Variable var = vecteur_var(v);
3604  expression tmp ;
3605  if(exp==0||var==TCST) tmp = int_to_expression(1);
3606  else {
3607  Value val = exp>0 ? exp: -exp;
3608  tmp = entity_to_expression((entity)var);
3609  while(--val)
3611  if(exp<0)
3613  }
3615  }
3616  return expression_undefined_p(coeff)?term:
3618  }
3619 }
static void term(Pproblem XX, int s, Value k, int x)
Definition: isolve.c:315
#define monome_term(pm)
#define MONOME_UNDEFINED_P(pm)
#define monome_coeff(pm)
Macros definitions.
static char * x
Definition: split_file.c:159

References DIVIDE_OPERATOR_NAME, entity_to_expression(), exp, expression_undefined, expression_undefined_p, float_to_expression(), int_to_expression(), make_op_exp(), monome_coeff, monome_term, MONOME_UNDEFINED_P, MULTIPLY_OPERATOR_NAME, TCST, term(), VECTEUR_NUL_P, vecteur_succ, vecteur_val, vecteur_var, and x.

Referenced by polynome_to_expression().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ normalize_subscript_expression()

void normalize_subscript_expression ( expression  e)

Normalization of subscript in expressions.

The C parser generates no more than one index in each subscript construct:

subscript = array:expression x indices:expression* ; syntax = reference + range + call + cast + sizeofexpression

  • subscript + application + va_arg:sizeofexpression* ; expression = syntax x normalized ;

If the array expression points to a multidimensional array, the indices list should be as long as possible, compatible with the array dimension.

               e (expression)
               |
               es (syntax)
               |
              esub (subscript)
              /  \
             /    \
             a    il -> -> (indices list)
             |        \
             as        \
             |          \
            asub         \
            /  \          \
           /    \          \
          sa    sil -> -> ->

The recursive normalization function works bottom up and, when facing the pattern above, concatenate the il index list (or a sublist) to the sil list. If the il list becomes empty, e is connected directly to as and the pieces of data structure es, esub and a are removed.

gen_recurse() is used to apply the transformation on the way up in expression trees. In the C parser, the transformation is applied to a module statement and to the initialization expressions present in the declarations.

Definition at line 4407 of file expression.c.

4408 {
4409  syntax es = expression_syntax(e);
4410  if(syntax_subscript_p(es)) {
4411  subscript esub = syntax_subscript(es);
4412  expression a = subscript_array(esub);
4413  syntax as = expression_syntax(a);
4414  if(syntax_subscript_p(as)) {
4415  subscript asub = syntax_subscript(as);
4416  // FI: bad, imported from effects-util :-( We could use
4417  // expression_to_type and then convert it into a concrete type
4418  //extern type points_to_expression_to_concrete_type(expression);
4419  // type t = points_to_expression_to_concrete_type(a);
4421  // This might be wrong: a is likely to be a pointer to a sub-array
4422  // or a pointer to a scalar for 1D array.
4423  if(pointer_type_p(t) || array_type_p(t)) { // FI: should always be true for a subscript?
4424  int nm = 0;
4425  if(pointer_type_p(t)) {
4426  type et = type_to_pointed_type(t);
4427  nm = (int) array_type_dimension(et) + 1;
4428  }
4429  else
4430  nm = (int) array_type_dimension(t);
4431  //list sil = subscript_indices(asub);
4432  // int nsi = (int) gen_length(sil);
4433  // FI: the efficient way would be to cut of the il list into two
4434  // parts and to use only one call to gen_nconc()
4435  list il = subscript_indices(esub);
4436  for(int i=0;i<nm && !ENDP(il); i++) {
4437  list ni = il; // new index/subscript
4438  POP(il);
4439  CDR(ni) = NIL;
4440  subscript_indices(asub) =
4441  gen_nconc(subscript_indices(asub), ni);
4442  }
4443  if(ENDP(il)) {
4444  // The top subscript can be removed
4445  expression_syntax(e) = as;
4447  subscript_indices(esub) = NIL;
4448  free_syntax(es);
4449  }
4450  else if(il!=subscript_indices(esub)) {
4451  // Update the new index list with the remaining indices
4452  subscript_indices(esub) = il;
4453  }
4454  else {
4455  // No restructuring
4456  ;
4457  }
4458  }
4459  free_type(t);
4460  }
4461  }
4462 }
type expression_to_concrete_type(expression)
A new type is allocated.
Definition: type.c:3751
type type_to_pointed_type(type)
returns t if t is not a pointer type, and the pointed type if t is a pointer type.
Definition: type.c:5265
unsigned int array_type_dimension(type)
Definition: type.c:2947

References array_type_dimension(), array_type_p(), CDR, ENDP, expression_syntax, expression_to_concrete_type(), free_syntax(), free_type(), gen_nconc(), int, NIL, pointer_type_p(), POP, subscript_array, subscript_indices, syntax_subscript, syntax_subscript_p, syntax_undefined, and type_to_pointed_type().

Referenced by expression_normalize_subscripts(), and statement_normalize_subscripts().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator_expression_p()

bool operator_expression_p ( expression  e,
string  op_name 
)
Parameters
op_namep_name

Definition at line 1087 of file expression.c.

1090 {
1091  syntax s = expression_syntax(e);
1092 
1093  if(syntax_call_p(s)) {
1094  call c = syntax_call(s);
1095  entity op = call_function(c);
1096 
1097  return strcmp(op_name, entity_local_name(op)) == 0;
1098  }
1099  else
1100  return false;
1101 }

References call_function, entity_local_name(), expression_syntax, syntax_call, and syntax_call_p.

Referenced by abs_expression_p(), add_expression_p(), assignment_expression_p(), cabs_expression_p(), dabs_expression_p(), divide_expression_p(), false_expression_p(), iabs_expression_p(), logical_expression_p(), max0_expression_p(), min0_expression_p(), modulo_expression_p(), power_expression_p(), sub_expression_p(), substraction_expression_p(), true_expression_p(), and unary_minus_expression_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pointer_reference_to_expression()

expression pointer_reference_to_expression ( reference  r)

Assume p is a pointer.

Compute expression "*(p+i)" from reference r = "p[i]".

rsl is fully copied into two sub-lists: the effective array indices and then the pointer indices.

We build a proper reference to an element of p

We build the equivalent pointer arithmetic expression

Definition at line 4004 of file expression.c.

4005 {
4006  entity p = reference_variable(r);
4008  list rsl = reference_indices(r);
4009  int p_d = variable_dimension_number(type_variable(t)); // pointer dimension
4010  int r_d = (int) gen_length(rsl); // reference dimension
4011 
4012  pips_assert("The reference dimension is strictly greater than "
4013  "the array of pointers dimension", r_d>p_d);
4014 
4015  /* rsl is fully copied into two sub-lists: the effective array
4016  indices and then the pointer indices. */
4017  list esl = NIL;
4018  list psl = NIL;
4019  list crsl = rsl;
4020  int i;
4021  for(i = 0; i<r_d; i++) {
4022  expression se = EXPRESSION(CAR(crsl));
4023  i<p_d? (esl = CONS(EXPRESSION, copy_expression(se), esl))
4024  : (psl = CONS(EXPRESSION, copy_expression(se), psl));
4025  POP(crsl);
4026  }
4027  esl = gen_nreverse(esl), psl = gen_nreverse(psl);
4028 
4029  pips_assert("The pointer index list is not empty", !ENDP(psl));
4030 
4031  /* We build a proper reference to an element of p */
4032  reference nr = make_reference(p, esl);
4034 
4035  /* We build the equivalent pointer arithmetic expression */
4036  expression pae = nre;
4037  // FI: would be better to compute the two operators before entering the loop
4038  // entity plus = ;
4039  // entity indirection = ;
4040  FOREACH(EXPRESSION, pse, psl) {
4043  }
4044 
4045  return pae;
4046 }
#define binary_intrinsic_expression(name, e1, e2)
int variable_dimension_number(variable)
Definition: type.c:5632
type entity_basic_concrete_type(entity)
retrieves or computes and then returns the basic concrete type of an entity
Definition: type.c:3677

References binary_intrinsic_expression, CAR, CONS, copy_expression(), DEREFERENCING_OPERATOR_NAME, ENDP, entity_basic_concrete_type(), EXPRESSION, FOREACH, gen_length(), gen_nreverse(), int, make_reference(), NIL, pips_assert, PLUS_C_OPERATOR_NAME, POP, reference_indices, reference_to_expression(), reference_variable, type_variable, unary_intrinsic_expression, and variable_dimension_number().

Referenced by pointer_reference_dereferencing_to_points_to(), and pointer_reference_to_points_to_sinks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ polynome_to_expression()

expression polynome_to_expression ( Ppolynome  pp)

converts a polynomial to expression

Parameters
ppp

Definition at line 3622 of file expression.c.

3623 {
3625 
3626  if (POLYNOME_UNDEFINED_P(pp))
3628  else if (POLYNOME_NUL_P(pp))
3629  r = int_to_expression(0);
3630  else {
3631  while (!POLYNOME_NUL_P(pp)) {
3633  if(expression_undefined_p(r)) r=s;
3634  else
3636  pp = polynome_succ(pp);
3637  }
3638  }
3639  return r;
3640 }
#define polynome_monome(pp)
#define POLYNOME_NUL_P(pp)
#define polynome_succ(pp)
expression monome_to_expression(Pmonome pm)
converts a monome to an expression
Definition: expression.c:3589

References expression_undefined, expression_undefined_p, int_to_expression(), make_op_exp(), monome_to_expression(), PLUS_OPERATOR_NAME, polynome_monome, POLYNOME_NUL_P, polynome_succ, and POLYNOME_UNDEFINED_P.

Referenced by do_group_statement_constant(), do_solve_hardware_constraints_on_volume(), edge_cost_polynome(), and simplify_expression().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ power_expression_p()

bool power_expression_p ( expression  e)

Definition at line 1018 of file expression.c.

1020 {
1022 }
#define POWER_OPERATOR_NAME

References operator_expression_p(), and POWER_OPERATOR_NAME.

+ Here is the call graph for this function:

◆ Pvecteur_to_assign_statement()

statement Pvecteur_to_assign_statement ( entity  var,
Pvecteur  v 
)

generates var = linear expression from the Pvecteur.

var is removed if necessary.

??? should manage an (positive remainder) integer divide ? Have a look to make_constraint_expression instead?

Parameters
varar

Definition at line 1720 of file expression.c.

1722 {
1723  statement result;
1724  Pvecteur vcopy;
1725  Value coef;
1726 
1727  coef = vect_coeff((Variable) var, v);
1729 
1730  vcopy = vect_dup(v);
1731 
1732  if (value_notzero_p(coef)) vect_erase_var(&vcopy, (Variable) var);
1733  if (value_one_p(coef)) vect_chg_sgn(vcopy);
1734 
1736  make_vecteur_expression(vcopy));
1737  vect_rm(vcopy);
1738 
1739  return result;
1740 }
#define value_le(v1, v2)
#define value_one_p(val)
#define value_abs(val)
#define assert(ex)
Definition: newgen_assert.h:41

References assert, entity_to_expression(), make_assign_statement(), make_vecteur_expression(), value_abs, value_le, value_notzero_p, VALUE_ONE, value_one_p, vect_chg_sgn(), vect_coeff(), vect_dup(), vect_erase_var(), and vect_rm().

Referenced by generate_deducables(), and hpfc_compute_lid().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Pvecteur_to_expression()

expression Pvecteur_to_expression ( Pvecteur  vect)

AP, sep 25th 95 : some usefull functions moved from static_controlize/utils.c.

rather use make_vecteur_expression which was already there

Parameters
vectect

Definition at line 1825 of file expression.c.

1826 {
1827  return make_vecteur_expression(vect);
1828 }

References make_vecteur_expression().

Referenced by analyze_expression(), build_first_comb(), build_third_comb(), do_gather_all_expressions_perms(), do_terapix_warmup_patching(), free_guards(), fusion(), fusion_buffer(), Hierarchical_tiling(), include_trans_on_LC_in_ref(), make_lin_op_exp(), make_reindex(), outliner_smart_references_computation(), prgm_mapping(), reconfig_expression(), simplify_dimension(), simplify_relational_expression(), Tiling2_buffer(), Tiling_buffer_allocation(), and translate_to_module_frame().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ range_equal_p()

bool range_equal_p ( range  r1,
range  r2 
)
Parameters
r11
r22

Definition at line 1522 of file expression.c.

1523 {
1524  return expression_equal_p(range_lower(r1), range_lower(r2))
1527 }

References expression_equal_p(), range_increment, range_lower, and range_upper.

Referenced by free_guards(), and syntax_equal_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reference_add_unbounded_subscripts()

void reference_add_unbounded_subscripts ( reference  r,
type  t 
)

Definition at line 300 of file expression.c.

301 {
303 }
void generic_reference_add_fixed_subscripts(reference r, type t, bool zero_p)
Add a set of zero subscripts to a reference "r" by side effect.
Definition: expression.c:236

References generic_reference_add_fixed_subscripts().

Referenced by points_to_cell_add_fixed_subscripts().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reference_add_zero_subscript()

void reference_add_zero_subscript ( reference  r)

No check on reference r.

This may generate an illegal reference if not called properly

Definition at line 267 of file expression.c.

268 {
271  CONS(EXPRESSION, z, NIL));
272 }

References CONS, EXPRESSION, gen_nconc(), int_to_expression(), NIL, and reference_indices.

Referenced by points_to_cell_add_zero_subscript().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reference_add_zero_subscripts()

void reference_add_zero_subscripts ( reference  r,
type  t 
)

Definition at line 261 of file expression.c.

262 {
264 }

References generic_reference_add_fixed_subscripts().

Referenced by anywhere_source_to_sinks(), points_to_cell_add_fixed_subscripts(), points_to_cell_types_compatibility(), reference_add_field_dimension(), and struct_assignment_to_points_to().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reference_complete_with_zero_subscripts()

void reference_complete_with_zero_subscripts ( reference  r)

Reference r to an array maybe partial, as is possible in C: with declaration "int a[10][10]", references "a", "a[i]" and "a[i][j]" are all legal.

The subscript list of reference r is completed with 0 subscript to reference an array element.

Definition at line 278 of file expression.c.

279 {
280  list rsl = reference_indices(r);
281  entity e = reference_variable(r);
283  pips_assert("t is a type of kind variable", type_variable_p(t));
284  variable v = type_variable(t);
285  list dl = variable_dimensions(v);
286 
287  if(gen_length(dl)>gen_length(rsl)) {
288  FOREACH(EXPRESSION, rs, rsl)
289  POP(dl);
290  list sl = NIL; // subscript list
291  FOREACH(DIMENSION, d, dl) {
292  // expression s = zero_p? int_to_expression(0) : make_unbounded_expression();
294  sl = CONS(EXPRESSION, s, sl);
295  }
297  }
298 }

References CONS, DIMENSION, entity_basic_concrete_type(), EXPRESSION, FOREACH, gen_length(), gen_nconc(), int_to_expression(), NIL, pips_assert, POP, reference_indices, reference_variable, type_variable, type_variable_p, and variable_dimensions.

Referenced by points_to_cell_complete_with_zero_subscripts().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reference_equal_p()

bool reference_equal_p ( reference  r1,
reference  r2 
)
Parameters
r11
r22

Definition at line 1500 of file expression.c.

1501 {
1502  entity v1 = reference_variable(r1);
1503  entity v2 = reference_variable(r2);
1504 
1505  list dims1 = reference_indices(r1);
1506  list dims2 = reference_indices(r2);
1507 
1508  if(v1 != v2) {
1509  if(entity_field_p(v1) && entity_field_p(v2)) {
1510  // FI: because of separate compilation, the same field is
1511  // represented by different entities
1512  return same_field_entity_p(v1, v2);
1513  }
1514  else
1515  return false;
1516  }
1517 
1518  return gen_equals(dims1,dims2,(gen_eq_func_t)expression_equal_p);
1519 }
bool same_field_entity_p(const entity f1, const entity f2)
Definition: entity.c:1019

References entity_field_p(), expression_equal_p(), gen_equals(), reference_indices, reference_variable, and same_field_entity_p().

Referenced by adg_write_reference_list(), attach_ref_to_stat(), build_successors_with_rhs(), call_flt(), cell_equal_p(), check_alias_args(), check_for_conflict(), checkReplaceReference(), comEngine_replace_reference_in_stat_rwt(), compact_phi_functions(), count_dataflows_on_ref(), create_realFifo_proc(), da_process_list(), daExpressionReplaceReference(), dataflows_on_ref(), dataflows_on_reference(), dmas_invert_p(), do_expression_reduction(), do_reduction_atomization(), do_reduction_detection(), do_reduction_propagation(), effect_sup_difference(), expression_verbose_reduction_p_and_return_increment(), find_or_create_fifo_from_ref(), fsr_reference_flt(), generate_fifo_stats(), generate_fifo_stats2(), generate_scalar_variables(), generate_scalar_variables_from_list(), get_fifoExp_from_ref(), get_HRE_buff_ent_from_ref(), get_indExp_from_ref(), in_effect_list_p(), merge_two_reductions(), opkill_may_reference(), opkill_must_reference(), perform_substitution_in_expression(), points_to_cell_equal_p(), potential_reduction_substitution_valid_p(), process_ref_lists(), reduction_in_statement_walker(), ref_subs_in_exp(), reference_conflicting_p(), reference_conflicting_test_and_update(), reference_dependence_variable_check_and_add(), reference_in_list_p(), reference_list_update(), rename_reduction_ref_walker(), same_reduction_p(), similarity(), stats_has_rw_conf_p(), and syntax_equal_p().

+ Here is the call graph for this function:

◆ reference_offset()

expression reference_offset ( reference  ref)

computes the offset of a C reference with its origin

iterate on the dimensions & indices to create the index expression

there may be more dimensions than indices

there may be more indices than dimensions

Parameters
refef

Definition at line 3807 of file expression.c.

3808 {
3809  if(ENDP(reference_indices(ref))) return int_to_expression(0);
3810  else {
3811  expression address_computation = copy_expression(EXPRESSION(CAR(reference_indices(ref))));
3812 
3813  /* iterate on the dimensions & indices to create the index expression */
3816  POP(indices);
3817  if(!ENDP(dims)) POP(dims); // the first dimension is unused
3818  FOREACH(DIMENSION,dim,dims)
3819  {
3822  make_op_exp(
3826  ),
3827  int_to_expression(1));
3828 
3829  if( !ENDP(indices) ) { /* there may be more dimensions than indices */
3830  expression index_expression = EXPRESSION(CAR(indices));
3831  address_computation = make_op_exp(
3833  copy_expression(index_expression),
3834  make_op_exp(
3836  dimension_size,address_computation
3837  )
3838  );
3839  POP(indices);
3840  }
3841  else {
3842  address_computation = make_op_exp(
3844  dimension_size,address_computation
3845  );
3846  }
3847  }
3848 
3849  /* there may be more indices than dimensions */
3851  {
3852  address_computation = make_op_exp(
3854  address_computation,copy_expression(e)
3855  );
3856  }
3857  return address_computation ;
3858  }
3859 }
static list indices
Definition: icm.c:204
int dimension_size(dimension)
this function computes the size of a dimension.
Definition: size.c:491
#define dimension_lower(x)
Definition: ri.h:980

References CAR, copy_expression(), DIMENSION, dimension_lower, dimension_size(), dimension_upper, ENDP, entity_type, EXPRESSION, FOREACH, indices, int_to_expression(), make_op_exp(), MINUS_OPERATOR_NAME, MULTIPLY_OPERATOR_NAME, PLUS_OPERATOR_NAME, POP, ref, reference_indices, reference_variable, type_variable, ultimate_type(), and variable_dimensions.

Referenced by do_group_constants_terapix(), do_grouping_replace_reference_by_expression_walker(), and sreference_offset().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reference_scalar_p()

bool reference_scalar_p ( reference  r)

This function returns true if Reference r is scalar.

Definition at line 3530 of file expression.c.

3531 {
3532  entity v = reference_variable(r);
3533  assert(!reference_undefined_p(r) && r!=NULL && v!=NULL);
3534  return (reference_indices(r) == NIL && entity_scalar_p(v));
3535 }
#define reference_undefined_p(x)
Definition: ri.h:2303

References assert, entity_scalar_p(), NIL, reference_indices, reference_undefined_p, and reference_variable.

Referenced by call_instruction_to_communications(), do_reduction_propagation(), first_reference_certainly_includes_second_reference_p(), guess_potential_reduction(), loop_nest_movement_generation(), loop_nest_to_wp65_code(), partial_eval_update_operators(), and references_must_conflict_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reference_to_expression()

expression reference_to_expression ( reference  r)

Definition at line 196 of file expression.c.

197 {
198  expression e;
200 
202 
203  return e;
204 }
normalized normalize_reference(reference r)
Definition: normalize.c:592

References is_syntax_reference, make_expression(), make_syntax(), and normalize_reference().

Referenced by alias_check_array_and_scalar_variable_in_caller_flt(), alias_check_array_variable_in_caller_flt(), bound_to_statement(), conflict_is_a_real_conflict_p(), define_node_processor_id(), do_brace_expression_to_statements(), do_expression_reduction(), do_group_constants_terapix(), do_reduction_atomization(), do_reduction_propagation(), entity_to_expression(), expand_points_to_domain(), generate_c1_alpha(), generate_compact(), generate_copy_loop_nest(), generate_full_copy(), generate_get_value_locally(), generate_mmcd_stat_from_ref(), generate_parallel_body(), generate_prelude(), generate_remapping_guard(), generate_update_values_on_computer_and_nodes(), hpfc_buffer_reference(), hpfc_generate_message(), initialization_list_to_statements(), initialize_array_variable(), live_mapping_expression(), loop_annotate(), make_abc_count_statement(), make_check_io_statement(), make_com_loopbody(), make_lInitStats(), make_list_of_flags(), make_loadsave_statement(), make_lSwitchStats(), make_mypos_expression(), make_phi_assign_instruction(), make_read_loopbody(), make_reference_expression(), make_statement_copy_i(), make_write_loopbody(), MakeArrayExpression(), outliner_smart_references_computation(), pointer_reference_to_expression(), pointer_subscript_to_expression(), process_true_call_stat(), reference_to_address_entity(), replace_array_ref_with_fifos(), replace_array_ref_with_fifos2(), replace_reductions_in_statement(), set_array_status_to_target(), split_complex_expression(), st_call_send_or_receive(), st_compute_current_computer(), st_compute_current_owners(), st_compute_ith_local_index(), struct_assignment_to_points_to(), struct_initialization_to_points_to(), Tiling_buffer_allocation(), translate_to_module_frame(), and verify_array_variable().

+ Here is the call graph for this function:

◆ reference_with_constant_indices_p()

bool reference_with_constant_indices_p ( reference  r)

Definition at line 3022 of file expression.c.

3023 {
3024  list sel = reference_indices(r);
3025  bool constant_p = true;
3026 
3027  FOREACH(EXPRESSION, se, sel) {
3029  && !field_expression_p(se) ) { // for points-to references
3030  constant_p = false;
3031  break;
3032  }
3033  }
3034  return constant_p;
3035 }
bool extended_integer_constant_expression_p(expression e)
More extensive than next function.
Definition: expression.c:858
bool field_expression_p(expression e)
The expression is of kind "a", where "a" is a field of some struct "s".
Definition: expression.c:498

References constant_p(), EXPRESSION, extended_integer_constant_expression_p(), field_expression_p(), FOREACH, and reference_indices.

Referenced by store_independent_effect_p(), and store_independent_reference_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reference_with_store_independent_indices()

reference reference_with_store_independent_indices ( reference  r)

Return by side effect a reference whose memory locations includes the memory locations of r in case the subcript expressions are changed by a store change.

Constant subscript expressions are preserved.

Store varying subscript expressions are replaced by unbounded expressions.

Definition at line 3045 of file expression.c.

3046 {
3047  list sel = reference_indices(r);
3048  list sec = list_undefined;
3049 
3050  for(sec = sel; !ENDP(sec); POP(sec)) {
3051  expression se = EXPRESSION(CAR(sec));
3052 
3054  free_expression(se);
3056  }
3057  }
3058 
3059  return r;
3060 }
#define list_undefined
Undefined list definition :-)
Definition: newgen_list.h:69
#define EXPRESSION_(x)
Definition: ri.h:1220

References CAR, ENDP, EXPRESSION, EXPRESSION_, extended_integer_constant_expression_p(), free_expression(), list_undefined, make_unbounded_expression(), POP, and reference_indices.

Referenced by effect_to_non_pointer_store_independent_effect(), and reference_to_points_to_sinks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reference_with_unbounded_indices_p()

bool reference_with_unbounded_indices_p ( reference  r)

indices can be constant or unbounded: they are store independent.

See next function, reference_with_unbounded_subscript_p()

Definition at line 3066 of file expression.c.

3067 {
3068  list sel = reference_indices(r);
3069  bool unbounded_p = true;
3070 
3071  FOREACH(EXPRESSION, se, sel) {
3073  && !unbounded_expression_p(se)) {
3074  unbounded_p = false;
3075  break;
3076  }
3077  }
3078  return unbounded_p;
3079 }

References EXPRESSION, extended_integer_constant_expression_p(), FOREACH, reference_indices, and unbounded_expression_p().

+ Here is the call graph for this function:

◆ reference_with_unbounded_subscript_p()

bool reference_with_unbounded_subscript_p ( reference  r)

See if the reference uses the unbounded function '*'.

See previous function, reference_with_unbounded_indices_p()

Definition at line 3085 of file expression.c.

3086 {
3087  list sel = reference_indices(r);
3088  bool unbounded_p = false;
3089 
3090  FOREACH(EXPRESSION, se, sel) {
3091  if(unbounded_expression_p(se)) {
3092  unbounded_p = true;
3093  break;
3094  }
3095  }
3096  return unbounded_p;
3097 }

References EXPRESSION, FOREACH, reference_indices, and unbounded_expression_p().

Referenced by generic_apply_effect_to_transformer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ references_do_not_conflict_p()

bool references_do_not_conflict_p ( reference  r1,
reference  r2 
)

If true is returned, the two references cannot conflict unless array bound declarations are violated.

If false is returned, the two references may conflict.

true is returned if the two references are array references and if the two references entities are equal and if at least one dimension can be used to desambiguate the two references using constant subscript expressions. This test is store independent and certainly does not replace a dependence test. It may beused to compute ude-def chains.

If needed, an extra effort could be made for aliased arrays.

FI: OK, it would be better to use their normalized forms

Parameters
r11
r22

Definition at line 1888 of file expression.c.

1889 {
1890  bool do_not_conflict = false;
1891  entity v1 = reference_variable(r1);
1892  entity v2 = reference_variable(r2);
1893 
1894  if(v1==v2) {
1895  list s1 = reference_indices(r1);
1896  list s2 = reference_indices(r2);
1897  if(!ENDP(s1) && gen_length(s1)==gen_length(s2)) {
1898  list cs1, cs2;
1899  for(cs1=s1, cs2=s2; !ENDP(cs1) && !do_not_conflict; POP(cs1), POP(cs2)) {
1900  expression sub1 = EXPRESSION(CAR(cs1));
1901  expression sub2 = EXPRESSION(CAR(cs2));
1902  if(expression_constant_p(sub1) && expression_constant_p(sub2)) {
1903  /* FI: OK, it would be better to use their normalized forms */
1904  do_not_conflict = (expression_to_int(sub1)!=expression_to_int(sub2));
1905  }
1906  }
1907  }
1908  }
1909 
1910  return do_not_conflict;
1911 }

References CAR, ENDP, EXPRESSION, expression_constant_p(), expression_to_int(), gen_length(), POP, reference_indices, reference_variable, and s1.

+ Here is the call graph for this function:

◆ relational_expression_p()

bool relational_expression_p ( expression  e)

A relational expression is a call whose function is either one of the following : .LT.,.LE.,.EQ.,.NE.,.GT.,.GE.

Definition at line 587 of file expression.c.

588 {
589  /* A relational expression is a call whose function is either one of the following :
590  * .LT.,.LE.,.EQ.,.NE.,.GT.,.GE. */
591  if (expression_call_p(e))
592  {
595  return true;
596  return false;
597  }
598  return false;
599 }
#define ENTITY_RELATIONAL_OPERATOR_P(e)

References call_function, ENTITY_RELATIONAL_OPERATOR_P, expression_call_p(), expression_syntax, and syntax_call.

Referenced by logical_expression_p(), simplify_relational_expression(), and trivial_expression_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ replace_expression_content()

expression replace_expression_content ( expression  e1,
expression  e2 
)

Use side effects to move the content of e2, s2 and n2, into e1; s1 and n1 are freed, as well as e2.

This is useful if you need to keep the handle on e1. e1 is returned, although it is redundant.

Parameters
e11
e22

Definition at line 3864 of file expression.c.

3865 {
3866  syntax s1 = expression_syntax(e1);
3868  syntax s2 = expression_syntax(e2);
3870 
3871  expression_syntax(e1) = s2;
3872  expression_normalized(e1) = n2;
3875  free_syntax(s1);
3876  free_normalized(n1);
3877  free_expression(e2);
3878 
3879  return e1;
3880 }

References expression_normalized, expression_syntax, free_expression(), free_normalized(), free_syntax(), normalized_undefined, s1, and syntax_undefined.

Referenced by simplify_boolean_expression_with_precondition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ same_expression_in_list_p()

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.

Parameters
lee

Definition at line 557 of file expression.c.

558 {
559  MAP(EXPRESSION, f, if (same_expression_p(e,f)) return true, le);
560  return false;
561 }
bool same_expression_p(expression e1, expression e2)
this is slightly different from expression_equal_p, as it will return true for a+b vs b+a
Definition: expression.c:1426

References EXPRESSION, f(), MAP, and same_expression_p().

Referenced by add_array_dimension_bound_test(), add_array_test(), expression_in_array_subscript(), top_down_abc_array(), and top_down_abc_call().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ same_expression_p()

bool same_expression_p ( expression  e1,
expression  e2 
)

this is slightly different from expression_equal_p, as it will return true for a+b vs b+a

lazy normalization.

Parameters
e11
e22

Definition at line 1426 of file expression.c.

1427 {
1428 
1429  /* lazy normalization.
1430  */
1433 
1434  normalized n1, n2;
1435  n1 = expression_normalized(e1);
1436  n2 = expression_normalized(e2);
1437 
1438 
1439 
1442  else
1443  return expression_equal_p(e1, e2);
1444 }
bool vect_equal(Pvecteur v1, Pvecteur v2)
bool vect_equal(Pvecteur v1, Pvecteur v2): test a egalite de deux vecteurs
Definition: reductions.c:278

References expression_equal_p(), expression_normalized, NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, and vect_equal().

Referenced by alias_check_array_and_scalar_variable_in_caller_flt(), alias_check_array_and_scalar_variable_in_module_flt(), alias_check_array_variable_in_caller_flt(), alias_check_array_variable_in_module_flt(), alias_check_scalar_and_array_variables_in_caller(), alias_check_scalar_and_array_variables_in_module(), bottom_up_abc_expression_implied_do(), check_loop_distribution_feasability(), compact_phi_functions(), expression_equal_in_context_p(), expression_in_array_subscript(), full_define_p(), interprocedural_abc_arrays(), make_loadsave_statement(), outliner_smart_references_computation(), prune_singleton(), same_dimension_p(), same_expression_in_list_p(), size_of_actual_array(), subscript_value(), subscript_value_stride(), substitute_expression_walker(), and try_reorder_expression_call().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ signed_integer_constant_expression_p()

bool signed_integer_constant_expression_p ( expression  e)

Definition at line 932 of file expression.c.

933 {
935  syntax s = expression_syntax(e);
936 
937  if(syntax_call_p(s)) {
938  call c = syntax_call(s);
939  entity um = call_function(c);
940 
943  entity_domain)) {
944  expression e2 = binary_call_lhs(c);
945 
947  }
948  }
949  return false;
950  }
951  else {
952  return true;
953  }
954 }

References binary_call_lhs, call_function, entity_domain, expression_syntax, gen_find_tabulated(), integer_constant_expression_p(), make_entity_fullname(), syntax_call, syntax_call_p, TOP_LEVEL_MODULE_NAME, and UNARY_MINUS_OPERATOR_NAME.

Referenced by signed_integer_constant_expression_value().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ signed_integer_constant_expression_value()

int signed_integer_constant_expression_value ( expression  e)

could be coded by geting directly the value of the constant entity...

also available as integer_constant_p() which has two arguments

Definition at line 1551 of file expression.c.

1552 {
1553  /* could be coded by geting directly the value of the constant entity... */
1554  /* also available as integer_constant_p() which has *two* arguments */
1555 
1557  int val = 0;
1558 
1559  pips_assert("is signed constant", signed_integer_constant_expression_p(e));
1560 
1561  n = NORMALIZE_EXPRESSION(e);
1562  if(normalized_linear_p(n)) {
1564 
1565  if(vect_constant_p(v)) {
1566  Value x = vect_coeff(TCST, v);
1567  val = VALUE_TO_INT(x);
1568  }
1569  else
1570  pips_internal_error("non constant expression");
1571  }
1572  else
1573  pips_internal_error("non affine expression");
1574 
1575  return val;
1576 }
bool signed_integer_constant_expression_p(expression e)
Definition: expression.c:932

References NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, normalized_undefined, pips_assert, pips_internal_error, signed_integer_constant_expression_p(), TCST, VALUE_TO_INT, vect_coeff(), vect_constant_p(), and x.

Referenced by integer_constant_expression_value().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ simplify_C_expression()

bool simplify_C_expression ( expression  e)

Replace C operators "+C" and "-C" which can handle pointers by arithmetic operators "+" and "-" when it is safe to do so, i.e.

when no pointer arithmetic is involved.

FI: Also, it might be useful to normalize the expression in order not to leave an undefined field in it. But this is a recursive function and probably not the right place to cope with this.

FI: see C_syntax/block_scope12.c. The source code line number where the problem occurs cannot be given because we are not in the c_syntax library.

FI: What if not? core dump?

The variable type can hide a functional type via a typedef

Might be wrong, but necessary

Should not occur in old C code

Should not occur in old C code

FI: The index expressions should be simplified too...

What is the type of the constant?

Should not occur in C, before C99

Check "+C" and "-C"

Try to simplify the arguments, do not hope much from the result type because of overloading.

a void expression such as (void) 0 results in an undefined basic. And so may do a condition c? (void *) 0 : (void *) 0.

FI: I guess, typedef equivalent to those could also be declared substituable

Should not occur in C

e must be a void expression, i.e. an expression returning no value

for gcc

Definition at line 2814 of file expression.c.

2815 {
2816  syntax s = expression_syntax(e);
2817  bool can_be_substituted_p = false;
2818 
2819  pips_debug(9, "Begin\n");
2820 
2821  switch(syntax_tag(s)) {
2822  case is_syntax_reference:
2823  {
2825  type rt = entity_type(re);
2826 
2827  if(type_undefined_p(rt)) {
2828  /* FI: see C_syntax/block_scope12.c. The source code line
2829  number where the problem occurs cannot be given because we
2830  are not in the c_syntax library. */
2831  pips_user_warning("Variable \"%s\" is probably used before it is defined\n",
2832  entity_user_name(re));
2833  can_be_substituted_p = false;
2834  }
2835  else {
2836  basic bt = basic_undefined;
2837 
2838  if(type_variable_p(rt)) { /* FI: What if not? core dump? */
2839  /* The variable type can hide a functional type via a
2840  typedef */
2841  type urt = ultimate_type(rt);
2842  if(type_variable_p(urt)) {
2843  bt = variable_basic(type_variable(urt));
2844 
2845  can_be_substituted_p =
2846  basic_int_p(bt)
2847  || basic_float_p(bt)
2848  || basic_overloaded_p(bt) /* Might be wrong, but necessary */
2849  || basic_complex_p(bt) /* Should not occur in old C code */
2850  || basic_logical_p(bt); /* Should not occur in old C code */
2851 
2852  pips_debug(9, "Variable %s is an arithmetic variable: %s\n",
2853  entity_local_name(re), bool_to_string(can_be_substituted_p));
2854  }
2855  }
2856  }
2857  break; /* FI: The index expressions should be simplified too... */
2858  }
2859  case is_syntax_call:
2860  {
2861  call c = syntax_call(s);
2862 
2863  if(expression_constant_p(e)) {
2864  /* What is the type of the constant? */
2865  entity cste = call_function(c);
2867 
2868  can_be_substituted_p =
2869  basic_int_p(rb)
2870  || basic_float_p(rb)
2871  || basic_complex_p(rb); /* Should not occur in C, before C99 */
2872  }
2873  else if(gen_length(call_arguments(c))==2) {
2874  /* Check "+C" and "-C" */
2875  expression e1 = binary_call_lhs(c);
2876  expression e2 = binary_call_rhs(c);
2877  bool can_be_substituted_p1 = simplify_C_expression(e1);
2878  bool can_be_substituted_p2 = simplify_C_expression(e2);
2879  can_be_substituted_p = can_be_substituted_p1 && can_be_substituted_p2;
2880  if(can_be_substituted_p) {
2881  entity op = call_function(c);
2882  if(ENTITY_PLUS_C_P(op)) {
2884  }
2885  else if(ENTITY_MINUS_C_P(op)) {
2887  }
2888  }
2889  }
2890  else {
2891  /* Try to simplify the arguments, do not hope much from the result
2892  type because of overloading. */
2893  type ft = call_to_functional_type(c, true);
2895  entity f = call_function(c);
2896 
2897  //pips_assert("The function type is functional", type_functional_p(entity_type(f)));
2898 
2899  FOREACH(EXPRESSION, se, call_arguments(c)) {
2900  (void) simplify_C_expression(se);
2901  }
2902 
2904  can_be_substituted_p = false;
2905  }
2906  else if(type_variable_p(rt)) {
2908 
2909  if(basic_overloaded_p(rb)) {
2910  /* a void expression such as (void) 0 results in an
2911  * undefined basic. And so may do a condition c? (void *)
2912  * 0 : (void *) 0.
2913  */
2914  rb = basic_of_expression(e);
2915  }
2916  else
2917  rb = copy_basic(rb);
2918 
2919  if(!basic_undefined_p(rb)) {
2920  /* FI: I guess, typedef equivalent to those could also be declared substituable */
2921  can_be_substituted_p =
2922  basic_int_p(rb)
2923  || basic_float_p(rb)
2924  || basic_complex_p(rb); /* Should not occur in C */
2925  free_basic(rb);
2926  }
2927  else {
2928  /* e must be a void expression, i.e. an expression returning no value */
2929  can_be_substituted_p = false;
2930  }
2931  }
2932  else {
2933  can_be_substituted_p = false;
2934  }
2935  }
2936  break;
2937  }
2938  case is_syntax_range:
2939  {
2940  range r = syntax_range(s);
2941  expression le = range_lower(r);
2942  expression ue = range_upper(r);
2943  expression ince = range_increment(r);
2944  (void) simplify_C_expression(le);
2945  (void) simplify_C_expression(ue);
2946  (void) simplify_C_expression(ince);
2947  can_be_substituted_p = false;
2948  break;
2949  }
2950  case is_syntax_cast:
2952  case is_syntax_subscript:
2953  case is_syntax_application:
2954  case is_syntax_va_arg:
2955  can_be_substituted_p = false;
2956  break;
2957  default: pips_internal_error("Bad syntax tag");
2958  can_be_substituted_p = false; /* for gcc */
2959  }
2960 
2961  pips_debug(9, "End: %s\n", bool_to_string(can_be_substituted_p));
2962  return can_be_substituted_p;
2963 }
basic copy_basic(basic p)
BASIC.
Definition: ri.c:104
string bool_to_string(bool)
Definition: string.c:243
#define ENTITY_CONDITIONAL_P(e)
bool simplify_C_expression(expression e)
Replace C operators "+C" and "-C" which can handle pointers by arithmetic operators "+" and "-" when ...
Definition: expression.c:2814
type call_to_functional_type(call, bool)
The function called can have a functional type, or a typedef type or a pointer type to a functional t...
Definition: type.c:3824
#define basic_complex_p(x)
Definition: ri.h:626
#define basic_undefined_p(x)
Definition: ri.h:557
#define type_undefined_p(x)
Definition: ri.h:2884
#define basic_undefined
Definition: ri.h:556
#define basic_float_p(x)
Definition: ri.h:617

References basic_complex_p, basic_float_p, basic_int_p, basic_logical_p, basic_of_expression(), basic_overloaded_p, basic_undefined, basic_undefined_p, binary_call_lhs, binary_call_rhs, bool_to_string(), call_arguments, call_function, call_to_functional_type(), copy_basic(), ENTITY_COMMA_P, ENTITY_CONDITIONAL_P, entity_intrinsic(), entity_local_name(), ENTITY_MINUS_C_P, ENTITY_PLUS_C_P, entity_type, entity_user_name(), EXPRESSION, expression_constant_p(), expression_syntax, f(), FOREACH, free_basic(), functional_result, gen_length(), is_syntax_application, is_syntax_call, is_syntax_cast, is_syntax_range, is_syntax_reference, is_syntax_sizeofexpression, is_syntax_subscript, is_syntax_va_arg, MINUS_OPERATOR_NAME, pips_debug, pips_internal_error, pips_user_warning, PLUS_OPERATOR_NAME, range_increment, range_lower, range_upper, reference_variable, syntax_call, syntax_range, syntax_reference, syntax_tag, type_functional, type_undefined_p, type_variable, type_variable_p, ultimate_type(), and variable_basic.

Referenced by MakeForloop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ simplify_expression()

bool simplify_expression ( expression pexp)

use polynomials to simplify an expression in some cases this operation can change the basic of the expression.

E.g. n/4 -> .25 * n In that case we just undo the simplification

Parameters
pexpexp

Definition at line 3770 of file expression.c.

3770  {
3771  expression exp = *pexp;
3772  bool result =false;
3773  if(!expression_undefined_p(exp)) {
3774  basic oldb = basic_of_expression(exp);
3776  if((result=!POLYNOME_UNDEFINED_P(pu))) {
3778  basic nbasic = basic_of_expression(pue);
3779  if(basic_equal_p(oldb,nbasic)) {
3781  *pexp=pue;
3782  }
3783  else {
3784  free_expression(pue);
3785  }
3786  free_basic(nbasic);
3787  polynome_rm(&pu);
3788  }
3789  free_basic(oldb);
3790  }
3791  return result;
3792 }
expression polynome_to_expression(Ppolynome pp)
converts a polynomial to expression
Definition: expression.c:3622

References basic_equal_p(), basic_of_expression(), exp, expression_to_polynome(), expression_undefined_p, free_basic(), free_expression(), polynome_rm(), polynome_to_expression(), and POLYNOME_UNDEFINED_P.

Referenced by distance_between_expression(), do_simplify_expressions(), loop_annotate(), and simd_loop_unroll().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ simplify_expressions()

void simplify_expressions ( void *  obj)
Parameters
objbj

Definition at line 3801 of file expression.c.

3801  {
3803 }
static void do_simplify_expressions(call c)
Definition: expression.c:3794
#define call_domain
newgen_callees_domain_defined
Definition: ri.h:58

References call_domain, do_simplify_expressions(), gen_recurse, and gen_true().

Referenced by optimize_expressions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ size_of_actual_array()

expression size_of_actual_array ( entity  actual_array,
list  l_actual_ref,
int  i 
)

ifdebug(3)

{

fprintf(stderr, "\n Size of actual array without subscript value \n");

print_expression(e);

}

ifdebug(4)

{

fprintf(stderr, "\n j = %d \n",j);

fprintf(stderr, "\n prod : \n");

print_expression(prod);

fprintf(stderr, "\n sum =: \n");

print_expression(sum);

}

ifdebug(2)

{

fprintf(stderr, "\n Size of actual array - subscript value : \n");

print_expression(e);

}

ifdebug(2)

{

fprintf(stderr, "\n Size of actual array:\n");

print_expression(e);

}

Parameters
actual_arrayctual_array
l_actual_ref_actual_ref

Definition at line 4197 of file expression.c.

4199 {
4201  variable actual_var = type_variable(entity_type(actual_array));
4202  list l_actual_dims = variable_dimensions(actual_var);
4203  int num_dim = gen_length(l_actual_dims), j;
4204  for (j=i+1; j<= num_dim; j++)
4205  {
4206  dimension dim_j = find_ith_dimension(l_actual_dims,j);
4207  expression lower_j = dimension_lower(dim_j);
4208  expression upper_j = dimension_upper(dim_j);
4209  expression size_j;
4210  if (expression_constant_p(lower_j) && (expression_to_int(lower_j)==1))
4211  size_j = copy_expression(upper_j);
4212  else
4213  {
4214  size_j = binary_intrinsic_expression(MINUS_OPERATOR_NAME,upper_j,lower_j);
4216  copy_expression(size_j),int_to_expression(1));
4217  }
4218  if (expression_undefined_p(e))
4219  e = copy_expression(size_j);
4220  else
4222  }
4223  // FI: to avoid cycles between librairies ri-util and prettyprint
4224  /* ifdebug(3) */
4225  /* { */
4226  /* fprintf(stderr, "\n Size of actual array without subscript value \n"); */
4227  /* print_expression(e); */
4228  /* } */
4229  if (l_actual_ref!=NIL)
4230  {
4231  // the actual argument is an array element name,
4232  // we have to compute the subscript value also
4234  ifdebug(3)
4235  fprintf(stderr, "\n actual argument is an array element name:");
4236  for (j=i+1; j<= num_dim; j++)
4237  {
4238  dimension dim_j = find_ith_dimension(l_actual_dims,j);
4239  expression lower_j = dimension_lower(dim_j);
4240  expression sub_j = find_ith_argument(l_actual_ref,j);
4241  expression upper_j = dimension_upper(dim_j);
4242  expression size_j,sub_low_j,elem_j;
4243  if ( expression_constant_p(lower_j) && (expression_to_int(lower_j)==1))
4244  size_j = copy_expression(upper_j);
4245  else
4246  {
4247  size_j = binary_intrinsic_expression(
4248  MINUS_OPERATOR_NAME, upper_j, lower_j);
4249  size_j = binary_intrinsic_expression(
4251  }
4252  // CAUTION : heuristic
4253  // We can distinguish or not the special case: lower_bound = subscript,
4254  // 1. If not, we do not lose information such as in SPEC95/applu.f :
4255  // real u(5,33,33,33)
4256  // call exact(i,j,1,u(1,i,j,1))
4257  // => size = 5.33.33.33 -((i-1)5 +(j-1)5.33 +(k-1)5.33.33),
4258  // not 5.33.33.33 -((i-1)5 +(j-1)5.33) (as k=1)
4259  // subroutine exact(i,j,k,u000ijk)
4260  // We will have more combinations, but more chance to translate
4261  // the size of actual array to the callee's frame
4262  // 2. If yes, there are so much combinations =>
4263  // it takes long time to compute, such as in SPEC95/turb3d.f
4264  // CONCLUSION : for time efficiency, we distinguish this case
4265  if (!same_expression_p(sub_j,lower_j))
4266  {
4268  sub_j,lower_j);
4269  if (expression_undefined_p(prod))
4270  elem_j = copy_expression(sub_low_j);
4271  else
4273  sub_low_j,prod);
4275  sum = copy_expression(elem_j);
4276  else
4278  sum, elem_j);
4279  }
4280  if (expression_undefined_p(prod))
4281  prod = copy_expression(size_j);
4282  else
4284  prod,size_j);
4285  // FI: to avoid cycles between librairies ri-util and prettyprint
4286  /* ifdebug(4) */
4287  /* { */
4288  /* fprintf(stderr, "\n j = %d \n",j); */
4289  /* fprintf(stderr, "\n prod : \n"); */
4290  /* print_expression(prod); */
4291  /* fprintf(stderr, "\n sum =: \n"); */
4292  /* print_expression(sum); */
4293  /* } */
4294  }
4296  {
4298  copy_expression(e),sum);
4299  // FI: to avoid cycles between librairies ri-util and prettyprint
4300  /* ifdebug(2) */
4301  /* { */
4302  /* fprintf(stderr, "\n Size of actual array - subscript value : \n"); */
4303  /* print_expression(e); */
4304  /* } */
4305  }
4306  }
4307  // FI: to avoid cycles between librairies ri-util and prettyprint
4308  /* ifdebug(2) */
4309  /* { */
4310  /* fprintf(stderr, "\n Size of actual array:\n"); */
4311  /* print_expression(e); */
4312  /* } */
4313  return e;
4314 }
expression find_ith_argument(list args, int n)
Definition: expression.c:1147
dimension find_ith_dimension(list, int)
This function returns the ith dimension of a list of dimensions.
Definition: type.c:5621
#define ifdebug(n)
Definition: sg.c:47
static entity array
t_real sum(int n1, int n2, int n3, t_real u[n1][n2][n3])
Definition: stencil.c:57
Polymorphic argument.
Definition: printf-args.h:92

References binary_intrinsic_expression, copy_expression(), dimension_lower, dimension_upper, entity_type, expression_constant_p(), expression_to_int(), expression_undefined, expression_undefined_p, find_ith_argument(), find_ith_dimension(), fprintf(), gen_length(), ifdebug, int_to_expression(), MINUS_OPERATOR_NAME, MULTIPLY_OPERATOR_NAME, NIL, PLUS_OPERATOR_NAME, same_expression_p(), sum(), type_variable, and variable_dimensions.

Referenced by interprocedural_abc_arrays().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sizeofexpression_equal_p()

bool sizeofexpression_equal_p ( sizeofexpression  s0,
sizeofexpression  s1 
)
Parameters
s00
s11

Definition at line 1446 of file expression.c.

1447 {
1452  return false;
1453 }
#define sizeofexpression_expression_p(x)
Definition: ri.h:2407

References expression_equal_p(), s1, sizeofexpression_expression, sizeofexpression_expression_p, sizeofexpression_type, sizeofexpression_type_p, and type_equal_p().

Referenced by syntax_equal_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ statement_normalize_subscripts()

void statement_normalize_subscripts ( statement  s)

To be used for module statements.

Definition at line 4471 of file expression.c.

References expression_domain, gen_recurse, gen_true(), and normalize_subscript_expression().

Referenced by actual_c_parser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ store_independent_reference_p()

bool store_independent_reference_p ( reference  r)

Does this reference define the same set of memory locations regardless of the current (environment and) memory state?

This function copes with standard references, extended to pointer references such as p[i], not with general points-to references, which are extended to cope with structs and implicit dereferencing. Points-to references are/should be handled in effects-util, not in ri-util.

Definition at line 3108 of file expression.c.

3109 {
3110  bool independent_p = true;
3111  //list ind = reference_indices(r);
3112  entity v = reference_variable(r);
3113  type t = ultimate_type(entity_type(v));
3114 
3115  if(pointer_type_p(t)) {
3116  independent_p = false;
3117  }
3118  else {
3119  independent_p = reference_with_constant_indices_p(r);
3120  }
3121 
3122  return independent_p;
3123 }
bool reference_with_constant_indices_p(reference r)
Definition: expression.c:3022

References entity_type, pointer_type_p(), reference_variable, reference_with_constant_indices_p(), and ultimate_type().

Referenced by basic_update_reflhs_with_rhs_to_transformer(), generic_reference_to_transformer(), opkill_may_reference(), and opkill_must_reference().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ struct_initialization_expression_to_expressions()

list struct_initialization_expression_to_expressions ( expression  e)

Returns a list of expressions hidden by the brace function.

First cut: FI not too sure about recursive calls to the brace function.

Definition at line 4073 of file expression.c.

4074 {
4075  pips_assert("rhs is a C initialization expression",
4077  syntax s = expression_syntax(e);
4078  call c = syntax_call(s);
4079  list el = call_arguments(c);
4080  return el;
4081 }
bool C_initialization_expression_p(expression e)
Definition: expression.c:4056

References C_initialization_expression_p(), call_arguments, expression_syntax, pips_assert, and syntax_call.

Referenced by struct_initialization_to_points_to().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sub_expression_p()

bool sub_expression_p ( expression  e)

Definition at line 991 of file expression.c.

991  {
994  ;
995 }

References MINUS_C_OPERATOR_NAME, MINUS_OPERATOR_NAME, and operator_expression_p().

Referenced by incrementation_expression_to_increment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ subscript_equal_p()

bool subscript_equal_p ( subscript  s1,
subscript  s2 
)
Parameters
s11
s22

Definition at line 1495 of file expression.c.

References expression_equal_p(), gen_equals(), s1, subscript_array, and subscript_indices.

Referenced by syntax_equal_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ subscript_expressions_to_constant_subscript_expressions()

list subscript_expressions_to_constant_subscript_expressions ( list  sl)

make a full copy of the subscript expression list, preserve constant subscripts, replace non-constant subscript by the star subscript expression.

Parameters
sll

Definition at line 3981 of file expression.c.

3982 {
3983  list nsl = NIL;
3984 
3985  FOREACH(EXPRESSION, s, sl){
3987  value v = EvalExpression(s);
3989  int i = constant_int(value_constant(v));
3990  ni = int_to_expression(i);
3991  }
3992  else {
3994  }
3995  nsl = CONS(EXPRESSION, ni, nsl);
3996  }
3997  nsl = gen_nreverse(nsl);
3998  return nsl;
3999 }

References CONS, constant_int, constant_int_p, EvalExpression(), EXPRESSION, expression_undefined, FOREACH, gen_nreverse(), int_to_expression(), make_unbounded_expression(), NIL, value_constant, and value_constant_p.

Referenced by reference_dereferencing_to_points_to(), and subscript_to_points_to_sinks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ subscript_value_stride()

expression subscript_value_stride ( entity  arr,
list  l_inds 
)

ifdebug(4)

{

pips_debug(4,"\nStride of subscript value:");

print_expression(retour);

}

Parameters
arrrr
l_inds_inds

Definition at line 4127 of file expression.c.

4128 {
4129  expression retour = int_to_expression(0);
4130  if (!ENDP(l_inds))
4131  {
4132  variable var = type_variable(entity_type(arr));
4134  list l_dims = variable_dimensions(var);
4135  int num_dim = gen_length(l_inds),i;
4138  for (i=1; i<= num_dim; i++)
4139  {
4140  dimension dim_i = find_ith_dimension(l_dims,i);
4141  expression lower_i = dimension_lower(dim_i);
4142  expression sub_i = find_ith_argument(l_inds,i);
4143  expression upper_i = dimension_upper(dim_i);
4144  expression size_i;
4145  if ( expression_constant_p(lower_i) && (expression_to_int(lower_i)==1))
4146  size_i = copy_expression(upper_i);
4147  else
4148  {
4149  size_i = binary_intrinsic_expression(
4150  MINUS_OPERATOR_NAME, upper_i, lower_i);
4151  size_i = binary_intrinsic_expression(
4153  }
4154  if (!same_expression_p(sub_i,lower_i))
4155  {
4156  expression sub_low_i =
4158  expression elem_i;
4159  if (expression_undefined_p(prod))
4160  elem_i = copy_expression(sub_low_i);
4161  else
4163  sub_low_i,prod);
4164  if (expression_equal_integer_p(retour,0))
4165  retour = copy_expression(elem_i);
4166  else
4168  retour, elem_i);
4169  }
4170  if (expression_undefined_p(prod))
4171  prod = copy_expression(size_i);
4172  else
4174  prod,size_i);
4175  }
4176  if (!expression_equal_integer_p(retour,0))
4177  retour = binary_intrinsic_expression(
4178  MULTIPLY_OPERATOR_NAME, copy_expression(retour), e_size);
4179  }
4180  // FI: to avoid cycles between librairies ri-util and prettyprint
4181  /* ifdebug(4) */
4182  /* { */
4183  /* pips_debug(4,"\nStride of subscript value:"); */
4184  /* print_expression(retour); */
4185  /* } */
4186  return retour;
4187 }
_int SizeOfElements(basic)
This function returns the length in bytes of the Fortran or C type represented by a basic,...
Definition: size.c:297

References binary_intrinsic_expression, copy_expression(), dimension_lower, dimension_upper, ENDP, entity_type, expression_constant_p(), expression_equal_integer_p(), expression_to_int(), expression_undefined, expression_undefined_p, find_ith_argument(), find_ith_dimension(), gen_length(), int_to_expression(), MINUS_OPERATOR_NAME, MULTIPLY_OPERATOR_NAME, PLUS_OPERATOR_NAME, same_expression_p(), SizeOfElements(), type_variable, variable_basic, and variable_dimensions.

Referenced by add_aliases_for_current_call_site(), alias_check_array_and_scalar_variable_in_caller_flt(), alias_check_array_and_scalar_variable_in_module_flt(), alias_check_array_variable_in_caller_flt(), alias_check_array_variable_in_module_flt(), dynamic_alias_check_flt(), offset_in_caller(), and same_or_equivalence_argument_add_aliases().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ substitute_entity_in_call()

static void substitute_entity_in_call ( call  c,
ctx_substitute_t ctx 
)
static

Definition at line 2750 of file expression.c.

2750  {
2751  entity old = ctx->old;
2752  entity new = ctx->new;
2753 
2754  if (same_entity_p(call_function(c),old)) {
2755  call_function(c) = new;
2756  }
2757 }

References call_function, ctx_substitute::new, ctx_substitute::old, and same_entity_p().

Referenced by substitute_entity_in_expression().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ substitute_entity_in_expression()

expression substitute_entity_in_expression ( entity  old,
entity  new,
expression  e 
)

This function replaces all the occurences of an old entity in the expression exp by the new entity.

It returns the expression modified. I think we can write this function by using gen_context_multi_recurse ... * To do .... NN gen_context_multi_recurse done in r22231 Modify the entry expression e by side effect

Parameters
oldentity to replace
newentity that will replace old
eexpression in will the entity old will be replaced
Returns
e expression modified by side effect
Parameters
oldld
newew

Definition at line 2792 of file expression.c.

2793 {
2794  ctx_substitute_t ctx;
2795  ctx.old = old;
2796  ctx.new = new;
2797 
2799  e, &ctx,
2802  NULL);
2803  return e;
2804 }
void gen_context_multi_recurse(void *o, void *context,...)
Multi-recursion with context function visitor.
Definition: genClib.c:3373
static void substitute_variable_in_reference(reference r, ctx_substitute_t *ctx)
Definition: expression.c:2741
static void substitute_entity_in_call(call c, ctx_substitute_t *ctx)
Definition: expression.c:2750
#define reference_domain
newgen_range_domain_defined
Definition: ri.h:338

References call_domain, gen_context_multi_recurse(), gen_true(), ctx_substitute::new, ctx_substitute::old, reference_domain, substitute_entity_in_call(), and substitute_variable_in_reference().

+ Here is the call graph for this function:

◆ substitute_entity_variable_in_expression()

expression substitute_entity_variable_in_expression ( entity  old,
entity  new,
expression  e 
)

(This function isn't use for the moment) This function replaces all the occurrences of an old entity in the expression exp by the new entity.

It returns the expression modified. It replaces only entity when it's an variable. So a recurse can be made on reference to replace the entity. (to not consider only variable entity have to make a special case for call, call_function) Modify the entry expression e by side effect

Parameters
oldentity to replace
newentity that will replace old
eexpression in will the entity old will be replaced
Returns
e expression modified by side effect
Parameters
oldld
newew

Definition at line 2772 of file expression.c.

2773 {
2774  ctx_substitute_t ctx;
2775  ctx.old = old;
2776  ctx.new = new;
2777 
2779  return e;
2780 }
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
Definition: genC.h:285
bool gen_true2(__attribute__((unused)) gen_chunk *u1, __attribute__((unused)) void *u2)
Definition: genClib.c:2785

References gen_context_recurse, gen_true2(), ctx_substitute::new, ctx_substitute::old, reference_domain, and substitute_variable_in_reference().

+ Here is the call graph for this function:

◆ substitute_variable_in_reference()

static void substitute_variable_in_reference ( reference  r,
ctx_substitute_t ctx 
)
static

Definition at line 2741 of file expression.c.

2741  {
2742  entity old = ctx->old;
2743  entity new = ctx->new;
2744 
2745  if (same_entity_p(reference_variable(r), old)) {
2746  reference_variable(r) = new;
2747  }
2748 }

References ctx_substitute::new, ctx_substitute::old, reference_variable, and same_entity_p().

Referenced by substitute_entity_in_expression(), and substitute_entity_variable_in_expression().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ substraction_expression_p()

bool substraction_expression_p ( expression  e)

Test if an expression is an substraction.

Definition at line 1000 of file expression.c.

1000  {
1003 }

References MINUS_C_OPERATOR_NAME, MINUS_OPERATOR_NAME, and operator_expression_p().

+ Here is the call graph for this function:

◆ suggest_basic_for_expression()

tag suggest_basic_for_expression ( expression  e)

a BASIC tag is returned for the expression this is a preliminary version.

should be improved. was in HPFC.

must be a call

else some clever analysis could be done

Definition at line 130 of file expression.c.

131 {
132  tag result = basic_tag(expression_basic(e));
133 
134  if (result==is_basic_overloaded)
135  {
136  syntax s = expression_syntax(e);
137 
138  /* must be a call
139  */
140  assert(syntax_call_p(s));
141 
143  result = is_basic_logical;
144  else
145  {
146  /* else some clever analysis could be done
147  */
148  pips_user_warning("an overloaded is turned into an int...\n");
149  result = is_basic_int;
150  }
151  }
152 
153  return result;
154 }
int tag
TAG.
Definition: newgen_types.h:92
basic expression_basic(expression)
Definition: type.c:1115
@ is_basic_overloaded
Definition: ri.h:574
@ is_basic_int
Definition: ri.h:571
#define basic_tag(x)
Definition: ri.h:613

References assert, basic_tag, call_function, ENTITY_RELATIONAL_OPERATOR_P, expression_basic(), expression_syntax, is_basic_int, is_basic_logical, is_basic_overloaded, pips_user_warning, syntax_call, and syntax_call_p.

+ Here is the call graph for this function:

◆ syntax_equal_p()

bool syntax_equal_p ( syntax  s1,
syntax  s2 
)
Parameters
s11
s22

Definition at line 1462 of file expression.c.

1463 {
1464  tag t1 = syntax_tag(s1);
1465  tag t2 = syntax_tag(s2);
1466 
1467  if(t1!=t2)
1468  return false;
1469 
1470  switch(t1) {
1471  case is_syntax_reference:
1473  case is_syntax_range:
1474  return range_equal_p(syntax_range(s1), syntax_range(s2));
1475  case is_syntax_call:
1476  return call_equal_p(syntax_call(s1), syntax_call(s2));
1477  case is_syntax_cast:
1478  return cast_equal_p(syntax_cast(s1), syntax_cast(s2));
1481  case is_syntax_subscript:
1483  case is_syntax_application:
1484  case is_syntax_va_arg:
1485  pips_internal_error("Not implemented for syntax tag %d\n", t1);
1486  default:
1487  return false;
1488  break;
1489  }
1490 
1491  pips_internal_error("illegal. syntax tag %d", t1);
1492  return false;
1493 }
bool call_equal_p(call c1, call c2)
Definition: expression.c:1529
bool subscript_equal_p(subscript s1, subscript s2)
Definition: expression.c:1495
bool sizeofexpression_equal_p(sizeofexpression s0, sizeofexpression s1)
Definition: expression.c:1446
bool cast_equal_p(cast c1, cast c2)
Definition: expression.c:1455
bool range_equal_p(range r1, range r2)
Definition: expression.c:1522

References call_equal_p(), cast_equal_p(), is_syntax_application, is_syntax_call, is_syntax_cast, is_syntax_range, is_syntax_reference, is_syntax_sizeofexpression, is_syntax_subscript, is_syntax_va_arg, pips_internal_error, range_equal_p(), reference_equal_p(), s1, sizeofexpression_equal_p(), subscript_equal_p(), syntax_call, syntax_cast, syntax_range, syntax_reference, syntax_sizeofexpression, syntax_subscript, and syntax_tag.

Referenced by expression_equal_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ syntax_to_expression()

expression syntax_to_expression ( syntax  s)

generates an expression from a syntax

Definition at line 3581 of file expression.c.

3581  {
3582  return make_expression(
3583  s,
3585  );
3586 }

References make_expression(), and normalized_undefined.

Referenced by initialization_list_to_statements(), isolate_patch_reference(), make_entity_expression(), and make_subscript_expression().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ syntax_to_reference_list()

list syntax_to_reference_list ( syntax  s,
list  lr 
)
Parameters
lrr

Definition at line 1270 of file expression.c.

1271 {
1272  switch(syntax_tag(s)) {
1273  case is_syntax_reference:
1274  lr = gen_nconc(lr, CONS(REFERENCE, syntax_reference(s), NIL));
1275  MAPL(ce, {
1276  expression e = EXPRESSION(CAR(ce));
1277  lr = expression_to_reference_list(e, lr);
1278  },
1280  break;
1281  case is_syntax_range:
1285  lr);
1286  break;
1287  case is_syntax_call:
1288  MAPL(ce, {
1289  expression e = EXPRESSION(CAR(ce));
1290  lr = expression_to_reference_list(e, lr);
1291  },
1293  break;
1294  case is_syntax_cast: {
1295  cast c = syntax_cast(s);
1296  expression e = cast_expression(c);
1297  lr = expression_to_reference_list(e, lr);
1298  break;
1299  }
1304  lr = expression_to_reference_list(e, lr);
1305  }
1306  break;
1307  }
1308  case is_syntax_subscript: {
1309  subscript sub = syntax_subscript(s);
1310  expression e = subscript_array(sub);
1311  list il = subscript_indices(sub);
1312  lr = expression_to_reference_list(e, lr);
1313  FOREACH(EXPRESSION, i,il) {
1314  lr = expression_to_reference_list(i, lr);
1315  }
1316  break;
1317  }
1318  case is_syntax_application: {
1321  list al = application_arguments(app);
1322  lr = expression_to_reference_list(f, lr);
1323  FOREACH(EXPRESSION, a,al) {
1324  lr = expression_to_reference_list(a, lr);
1325  }
1326  break;
1327  }
1328  case is_syntax_va_arg: {
1329  list two = syntax_va_arg(s);
1330  FOREACH(SIZEOFEXPRESSION, soe, two) {
1333  lr = expression_to_reference_list(e, lr);
1334  }
1335  }
1336  break;
1337  }
1338  default:
1339  pips_internal_error("illegal tag %d",
1340  syntax_tag(s));
1341 
1342  }
1343  return lr;
1344 }
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...
Definition: expression.c:1263
#define REFERENCE(x)
REFERENCE.
Definition: ri.h:2296
#define SIZEOFEXPRESSION(x)
SIZEOFEXPRESSION.
Definition: ri.h:2364
#define syntax_va_arg(x)
Definition: ri.h:2751
#define application_arguments(x)
Definition: ri.h:510
#define application_function(x)
Definition: ri.h:508

References application_arguments, application_function, call_arguments, CAR, cast_expression, CONS, EXPRESSION, expression_to_reference_list(), f(), FOREACH, gen_nconc(), is_syntax_application, is_syntax_call, is_syntax_cast, is_syntax_range, is_syntax_reference, is_syntax_sizeofexpression, is_syntax_subscript, is_syntax_va_arg, MAPL, NIL, pips_internal_error, range_increment, range_lower, range_upper, REFERENCE, reference_indices, SIZEOFEXPRESSION, sizeofexpression_expression, sizeofexpression_expression_p, subscript_array, subscript_indices, syntax_application, syntax_call, syntax_cast, syntax_range, syntax_reference, syntax_sizeofexpression, syntax_subscript, syntax_tag, and syntax_va_arg.

Referenced by expression_to_reference_list().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ trivial_expression_p()

int trivial_expression_p ( expression  e)

This function returns:

1, if e is a relational expression that is always true

-1, if e is a relational expression that is always false

0, otherwise.

It should be called trivial_condition_p().

If e is a relational expression

ifdebug(3) {

fprintf(stderr, "Normalizes of expression:");

print_expression(e);

print_normalized(n1);

print_normalized(n2);

}

The test if an expression is trivial (always true or false) or not depends on the operator of the expression : (op= {<=,<,>=,>,==,!=}) so we have to treat each different case

Expression : v != 0

Expression : v == 0

Expression : v >= 0

Expression : v <= 0

Expression : v < 0

Expression : v > 0

Definition at line 679 of file expression.c.

680 {
682  {
683  /* If e is a relational expression*/
685  expression e1 = EXPRESSION(CAR(args));
686  expression e2 = EXPRESSION(CAR(CDR(args)));
687  normalized n1,n2;
688  entity op;
689  if (expression_undefined_p(e1) ||expression_undefined_p(e2) ) return 0;
690  n1 = NORMALIZE_EXPRESSION(e1);
691  n2 = NORMALIZE_EXPRESSION(e2);
693 
694  // FI: no cycle between the ri-util and prettyprint libraries
695  /* ifdebug(3) { */
696  /* fprintf(stderr, "Normalizes of expression:"); */
697  /* print_expression(e); */
698  /* print_normalized(n1); */
699  /* print_normalized(n2); */
700  /* } */
701 
703  {
704  Pvecteur v1 = normalized_linear(n1);
705  Pvecteur v2 = normalized_linear(n2);
706  Pvecteur v = vect_substract(v1,v2);
707 
708  /* The test if an expression is trivial (always true or false) or not
709  * depends on the operator of the expression :
710  * (op= {<=,<,>=,>,==,!=}) so we have to treat each different case */
711 
712  if (vect_constant_p(v))
713  {
714  if (ENTITY_NON_EQUAL_P(op))
715  {
716  /* Expression : v != 0 */
717  if (VECTEUR_NUL_P(v)) return -1;
718  if (value_zero_p(val_of(v))) return -1;
719  if (value_notzero_p(val_of(v))) return 1;
720  }
721  if (ENTITY_EQUAL_P(op))
722  {
723  /* Expression : v == 0 */
724  if (VECTEUR_NUL_P(v)) return 1;
725  if (value_zero_p(val_of(v))) return 1;
726  if (value_notzero_p(val_of(v))) return -1;
727  }
729  {
730  /* Expression : v >= 0 */
731  if (VECTEUR_NUL_P(v)) return 1;
732  if (value_posz_p(val_of(v))) return 1;
733  if (value_neg_p(val_of(v))) return -1;
734  }
735  if (ENTITY_LESS_OR_EQUAL_P(op))
736  {
737  /* Expression : v <= 0 */
738  if (VECTEUR_NUL_P(v)) return 1;
739  if (value_negz_p(val_of(v))) return 1;
740  if (value_pos_p(val_of(v))) return -1;
741  }
742  if (ENTITY_LESS_THAN_P(op))
743  {
744  /* Expression : v < 0 */
745  if (VECTEUR_NUL_P(v)) return -1;
746  if (value_neg_p(val_of(v))) return 1;
747  if (value_posz_p(val_of(v))) return -1;
748  }
749  if (ENTITY_GREATER_THAN_P(op))
750  {
751  /* Expression : v > 0 */
752  if (VECTEUR_NUL_P(v)) return -1;
753  if (value_pos_p(val_of(v))) return 1;
754  if (value_negz_p(val_of(v))) return -1;
755  }
756  }
757  return 0;
758  }
759  return 0;
760  }
761  return 0;
762 }
#define value_negz_p(val)
#define value_zero_p(val)
#define value_neg_p(val)
#define value_posz_p(val)
#define ENTITY_NON_EQUAL_P(e)
#define ENTITY_EQUAL_P(e)
#define ENTITY_LESS_THAN_P(e)
#define ENTITY_GREATER_THAN_P(e)
#define ENTITY_LESS_OR_EQUAL_P(e)
#define ENTITY_GREATER_OR_EQUAL_P(e)
#define val_of(varval)

References call_arguments, call_function, CAR, CDR, ENTITY_EQUAL_P, ENTITY_GREATER_OR_EQUAL_P, ENTITY_GREATER_THAN_P, ENTITY_LESS_OR_EQUAL_P, ENTITY_LESS_THAN_P, ENTITY_NON_EQUAL_P, EXPRESSION, expression_syntax, expression_undefined_p, NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, relational_expression_p(), syntax_call, val_of, value_neg_p, value_negz_p, value_notzero_p, value_pos_p, value_posz_p, value_zero_p, vect_constant_p(), vect_substract(), and VECTEUR_NUL_P.

Referenced by abc_with_allocation_size(), alias_check_array_and_scalar_variable_in_caller_flt(), alias_check_array_and_scalar_variable_in_module_flt(), alias_check_array_variable_in_caller_flt(), alias_check_array_variable_in_module_flt(), alias_check_scalar_and_array_variables_in_caller(), alias_check_scalar_and_array_variables_in_module(), alias_check_two_array_variables_in_caller(), alias_check_two_array_variables_in_module(), alias_check_two_scalar_variables_in_caller(), alias_check_two_scalar_variables_in_module(), bottom_up_abc_base_reference_implied_do(), bottom_up_abc_reference(), impact_check_two_scalar_variables_in_path(), and top_down_abc_call().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ true_expression_p()

◆ unary_minus_expression_p()

bool unary_minus_expression_p ( expression  e)

Definition at line 1030 of file expression.c.

1032 {
1034 }

References operator_expression_p(), and UNARY_MINUS_OPERATOR_NAME.

Referenced by expression_opposite_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unbounded_dimension_p()

bool unbounded_dimension_p ( dimension  dim)

bool unbounded_dimension_p(dim) input : a dimension of an array entity.

output : true if the last dimension is unbounded (*), false otherwise. modifies : nothing comment :

Parameters
dimim

Definition at line 1130 of file expression.c.

1132 {
1133  syntax dim_synt = expression_syntax(dimension_upper(dim));
1134  bool res = false;
1135 
1136  if (syntax_call_p(dim_synt)) {
1137  const char* dim_nom = entity_local_name(call_function(syntax_call(dim_synt)));
1138 
1140  res = true;
1141  }
1142 
1143  return(res);
1144 }

References call_function, dimension_upper, entity_local_name(), expression_syntax, same_string_p, syntax_call, syntax_call_p, and UNBOUNDED_DIMENSION_NAME.

Referenced by array_bounded_p(), assumed_size_array_p(), bottom_up_abc_base_reference_implied_do(), bottom_up_abc_reference(), build_call_STEP_init_regionArray(), C_pointer_type_p(), C_type_to_pointed_type(), entity_unbounded_p(), subscript_to_points_to_sinks(), top_down_abc_call(), top_down_abc_dimension(), and words_dimension().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unbounded_entity_p()

bool unbounded_entity_p ( entity  f)

Definition at line 4323 of file expression.c.

4324 {
4325  const char* n = entity_local_name(f);
4327 }

References entity_local_name(), f(), same_string_p, and UNBOUNDED_DIMENSION_NAME.

Referenced by store_independent_points_to_indices_p(), and unbounded_expression_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unbounded_expression_p()

bool unbounded_expression_p ( expression  e)

Definition at line 4329 of file expression.c.

4330 {
4331  syntax s = expression_syntax(e);
4332  if (syntax_call_p(s)) {
4334  return unbounded_entity_p(f);
4335  }
4336  return false;
4337 }
bool unbounded_entity_p(entity f)
Definition: expression.c:4323

References call_function, expression_syntax, f(), syntax_call, syntax_call_p, and unbounded_entity_p().

Referenced by any_expression_to_transformer(), array_references_may_conflict_p(), cell_is_xxx_p(), cell_reference_compare(), compatible_points_to_subscripts_p(), constant_reference_to_normalized_constant_reference(), do_brace_expression_to_updated_type(), effect_to_store_independent(), equal_must_vreference(), exact_points_to_subscript_list_p(), expression_to_points_to_sinks_with_offset(), flow_sensitive_malloc_to_points_to_sinks(), generic_atomic_points_to_reference_p(), malloc_arg_to_type(), module_initial_parameter_pv(), old_effects_conflict_p(), opkill_may_vreference(), opkill_must_vreference(), points_to_indices_to_subscript_indices(), points_to_indices_to_unbounded_indices(), points_to_reference_included_p(), points_to_subscripts_to_number_of_unbounded_dimensions(), proper_to_summary_simple_effect(), reference_to_points_to_translations(), reference_unbounded_indices_p(), reference_with_unbounded_indices_p(), reference_with_unbounded_subscript_p(), refine_points_to_cell_subscripts(), simple_cell_reference_preceding_p(), simple_cells_inclusion_p(), simple_cells_intersection_p(), unique_location_cell_p(), variable_references_may_conflict_p(), words_range(), and words_subscript_range().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update_expression_syntax()

void update_expression_syntax ( expression  e,
syntax  s 
)

◆ user_call_p()

bool user_call_p ( call  c)

Test if a call is a user call.

Definition at line 4361 of file expression.c.

4361  {
4362  entity f = call_function(c);
4363  value v = entity_initial(f);
4364  return value_code_p(v);
4365 }
#define value_code_p(x)
Definition: ri.h:3065

References call_function, entity_initial, f(), and value_code_p.

Referenced by copy_from_call(), copy_to_call(), costly_task(), look_for_user_call(), pragma_scop(), and statement_contains_user_call_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ user_function_call_p()

bool user_function_call_p ( expression  e)

Definition at line 1068 of file expression.c.

1070 {
1071  syntax s = expression_syntax(e);
1072  bool user_function_call_p = false;
1073 
1074  if(syntax_call_p(s)) {
1075  call c = syntax_call(s);
1076  entity f = call_function(c);
1077  value v = entity_initial(f);
1079  }
1080  else {
1081  user_function_call_p = false;
1082  }
1083 
1084  return user_function_call_p;
1085 }
bool user_function_call_p(expression e)
Definition: expression.c:1068

References call_function, entity_initial, expression_syntax, f(), syntax_call, syntax_call_p, and value_code_p.

+ Here is the call graph for this function:

◆ Value_to_expression()

expression Value_to_expression ( Value  v)

added interface for linear stuff.

it is not ok if Value is not an int, but if Value is changed sometime, I guess code that use this function will not need any change. FC.

Definition at line 1251 of file expression.c.

1252 {
1253  return(int_to_expression(VALUE_TO_INT(v)));
1254 }

References int_to_expression(), and VALUE_TO_INT.

Referenced by array_access_to_array_ranges(), constraints_to_loop_bound(), do_solve_hardware_constraints_on_nb_proc(), extract_the_align(), fusion(), fusion_buffer(), generate_one_message(), Hierarchical_tiling(), hpfc_broadcast_buffers(), make_rational_exp(), Tiling2_buffer(), Tiling_buffer_allocation(), and update_indices_for_local_computation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ zero_expression_p()

bool zero_expression_p ( expression  e)

Definition at line 1217 of file expression.c.

1218 {
1219  bool zero_p = false;
1220  if(expression_call_p(e)) {
1221  call c = expression_call(e);
1222  entity f = call_function(c);
1223  if(f==int_to_entity(0))
1224  zero_p = true;
1225  }
1226  return zero_p;
1227 }

References call_function, expression_call(), expression_call_p(), f(), and int_to_entity().

Referenced by binary_intrinsic_call_to_points_to_sinks(), make_send_receive_conversion(), offset_points_to_cell(), points_to_translation_of_formal_parameters(), and reference_to_points_to_translations().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ out_flt

FILE* out_flt = NULL
static

Definition at line 2719 of file expression.c.

Referenced by davinci_dump_all_expressions(), and expr_flt().