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

Go to the source code of this file.

Functions

static normalized _NormalizeExpression (expression e)
 this function shouldn't be called. More...
 
normalized NormalizeExpression (expression e)
 normalize.c More...
 
normalized NormalizeSyntax (syntax s)
 
normalized NormalizeCast (cast c)
 
normalized NormalizeCall (call c)
 
normalized NormalizeConstant (constant c)
 
normalized NormalizeReference (reference r)
 
normalized NormalizeIntrinsic (entity e, list la)
 
normalized binary_to_normalized (list la, int op)
 
bool EvalNormalized (normalized n, int *pv)
 
void FreeNormalized (normalized n)
 
void free_expression_normalized (expression e)
 
void unnormalize_expression (void *st)
 void unnormalize_expression(expression exp): puts all the normalized field of expressions in "st" to undefined and does the unnormalization recursively More...
 
Pvecteur expression_to_affine (expression e)
 
static bool normalized_constant_p (normalized n, int *pv)
 
static normalized normalize_intrinsic (entity f, list la)
 
static normalized normalize_constant (constant c)
 
normalized normalize_reference (reference r)
 
static normalized normalize_call (call c)
 
static void norm_all_rewrite (expression e)
 Look for affine expressions and encode them as vectors when possible. More...
 
void normalize_all_expressions_of (void *obj)
 
static bool normalize_first_expressions_filter (expression e)
 
void normalize_first_expressions_of (void *obj)
 

Function Documentation

◆ _NormalizeExpression()

static normalized _NormalizeExpression ( expression  e)
static

this function shouldn't be called.

Use macro NORMALIZE_EXPRESSION(e) instead.

Definition at line 76 of file normalize.c.

77 {
79 }
normalized NormalizeSyntax(syntax s)
Definition: normalize.c:94
#define expression_syntax(x)
Definition: ri.h:1247

References expression_syntax, and NormalizeSyntax().

Referenced by binary_to_normalized(), expression_to_affine(), NormalizeExpression(), and NormalizeIntrinsic().

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

◆ binary_to_normalized()

normalized binary_to_normalized ( list  la,
int  op 
)

initialized to please gcc

FI: the C operator is different from the Fortran operator for non-positive arguments.

FI: the C operator is different from the Fortran operator for non-positive arguments.

Parameters
laa
opp

Definition at line 320 of file normalize.c.

321 {
322  normalized ng;
323  normalized nd;
324  normalized n;
325  int val1;
326  int val2;
327  int val = 0; /* initialized to please gcc */
328 
329  pips_assert("binary_to_normalize", gen_length(la) == 2);
330 
332  if (normalized_complex_p(ng))
333  return(ng);
334 
336  if (normalized_complex_p(nd)) {
337  FreeNormalized(ng);
338  return(nd);
339  }
340 
341  if (EvalNormalized(nd, &val2) && EvalNormalized(ng, &val1)) {
342  bool succeed = true;
343 
344  FreeNormalized(nd);
345  FreeNormalized(ng);
346  switch(op) {
347  case MINIMUM:
348  val = MIN(val1, val2);
349  break;
350  case MAXIMUM:
351  val = MAX(val1, val2);
352  break;
353  case MOD:
354  /* FI: the C operator is different from the Fortran operator
355  * for non-positive arguments.
356  */
357  if(val2==0) {
358  user_error("binary_to_normalize",
359  "0 divide in modulo evaluation\n");
360  }
361  else {
362  val = val1%val2;
363  }
364  break;
365  case SLASH:
366  /* FI: the C operator is different from the Fortran operator
367  * for non-positive arguments.
368  */
369  if(val2==0) {
370  user_error("binary_to_normalize",
371  "0 divide\n");
372  }
373  else {
374  val = val1/val2;
375  }
376  break;
377  case POWER:
378  if(val2<0) {
379  succeed = false;
380  }
381  else {
382  val = ipow(val1,val2);
383  }
384  break;
385  default:
386  pips_internal_error("Unknown binary operator %d", op);
387  }
388  if(succeed) {
390  vect_new(TCST, val));
391  }
392  else {
394  }
395  }
396  else {
397  FreeNormalized(ng);
398  FreeNormalized(nd);
400  }
401  return n;
402 }
normalized make_normalized(enum normalized_utype tag, void *val)
Definition: ri.c:1447
#define MIN(x, y)
minimum and maximum if they are defined somewhere else, they are very likely to be defined the same w...
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 CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define pips_internal_error
Definition: misc-local.h:149
#define user_error(fn,...)
Definition: misc-local.h:265
#define UU
Definition: newgen_types.h:98
#define POWER
Definition: operator.h:46
#define MAXIMUM
Definition: operator.h:50
#define MINIMUM
Definition: operator.h:49
#define MOD
Definition: operator.h:47
bool EvalNormalized(normalized n, int *pv)
Definition: normalize.c:404
static normalized _NormalizeExpression(expression e)
this function shouldn't be called.
Definition: normalize.c:76
void FreeNormalized(normalized n)
Definition: normalize.c:419
int ipow(int vg, int vd)
FI: such a function should exist in Linear/arithmetique.
Definition: eval.c:769
#define normalized_complex_p(x)
Definition: ri.h:1782
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
@ is_normalized_linear
Definition: ri.h:1760
@ is_normalized_complex
Definition: ri.h:1761
#define MAX(x, y)
Definition: string.c:110
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
Pvecteur vect_new(Variable var, Value coeff)
Pvecteur vect_new(Variable var,Value coeff): allocation d'un vecteur colineaire au vecteur de base va...
Definition: alloc.c:110
#define SLASH

References _NormalizeExpression(), CAR, CDR, EvalNormalized(), EXPRESSION, FreeNormalized(), gen_length(), ipow(), is_normalized_complex, is_normalized_linear, make_normalized(), MAX, MAXIMUM, MIN, MINIMUM, MOD, normalized_complex_p, pips_assert, pips_internal_error, POWER, SLASH, TCST, user_error, UU, and vect_new().

Referenced by NormalizeIntrinsic().

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

◆ EvalNormalized()

bool EvalNormalized ( normalized  n,
int pv 
)
Parameters
pvv

Definition at line 404 of file normalize.c.

407 {
408  if (normalized_linear_p(n)) {
410  if (vect_size(v) == 1 && var_of(v) == TCST) {
411  *pv = VALUE_TO_INT(val_of(v));
412  return(true);
413  }
414  }
415 
416  return(false);
417 }
#define VALUE_TO_INT(val)
int vect_size(Pvecteur v)
package vecteur - reductions
Definition: reductions.c:47
#define normalized_linear_p(x)
Definition: ri.h:1779
#define normalized_linear(x)
Definition: ri.h:1781
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
#define val_of(varval)
struct Svecteur * Pvecteur
#define var_of(varval)

References normalized_linear, normalized_linear_p, TCST, val_of, VALUE_TO_INT, var_of, and vect_size().

Referenced by binary_to_normalized(), loop_increment_value(), NormalizeIntrinsic(), and words_numerical_dimension().

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

◆ expression_to_affine()

Pvecteur expression_to_affine ( expression  e)

As long as VECTEUR_UNDEFINED is not different from VECTEUR_NUL this routine cannot be used safely; either 0 will be considered not linear or every non linear expression will be equal to 0

should it also perform the conversion from variable entities to new value entities?

Definition at line 461 of file normalize.c.

462 {
463  normalized n;
464  Pvecteur v;
465 
466  /* As long as VECTEUR_UNDEFINED is not different from VECTEUR_NUL
467  this routine cannot be used safely; either 0 will be considered
468  not linear or every non linear expression will be equal to 0 */
469 
470  /* should it also perform the conversion from variable entities
471  to new value entities? */
472 
474  n = _NormalizeExpression(e);
475  else
476  n = expression_normalized(e);
477 
478  if(normalized_linear_p(n))
480  else
481  v = VECTEUR_UNDEFINED;
482 
483  return v;
484 }
#define normalized_undefined
Definition: ri.h:1745
#define expression_normalized(x)
Definition: ri.h:1249
#define VECTEUR_UNDEFINED
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

References _NormalizeExpression(), expression_normalized, normalized_linear, normalized_linear_p, normalized_undefined, vect_dup(), and VECTEUR_UNDEFINED.

Referenced by transformer_add_loop_index_incrementation().

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

◆ free_expression_normalized()

void free_expression_normalized ( expression  e)

Definition at line 432 of file normalize.c.

434 {
436 
438  FreeNormalized(n);
440  }
441 }

References expression_normalized, FreeNormalized(), and normalized_undefined.

Referenced by unnormalize_expression().

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

◆ FreeNormalized()

void FreeNormalized ( normalized  n)

FI: theoretically, free_normalized() performs the next three lines...

gen_free(n);

Definition at line 419 of file normalize.c.

421 {
422  /* FI: theoretically, free_normalized() performs the next three lines... */
423  if (normalized_linear_p(n)) {
425  normalized_linear_(n) = NULL;
426  }
427 
428  free_normalized(n);
429  /* gen_free(n); */
430 }
void free_normalized(normalized p)
Definition: ri.c:1407
#define normalized_linear_(x)
Definition: ri.h:1780
void vect_rm(Pvecteur v)
void vect_rm(Pvecteur v): desallocation des couples de v;
Definition: alloc.c:78

References free_normalized(), normalized_linear, normalized_linear_, normalized_linear_p, and vect_rm().

Referenced by binary_to_normalized(), free_expression_normalized(), and NormalizeIntrinsic().

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

◆ norm_all_rewrite()

static void norm_all_rewrite ( expression  e)
static

Look for affine expressions and encode them as vectors when possible.

Definition at line 635 of file normalize.c.

636 {
637  syntax s = expression_syntax(e);
638  tag t = syntax_tag(s);
639 
642 
643  switch(t) {
644  case is_syntax_range:
646  break;
647  case is_syntax_reference:
649  break;
650  case is_syntax_call:
651  n = normalize_call(syntax_call(s));
652  break;
653  case is_syntax_cast:
655  case is_syntax_subscript:
657  case is_syntax_va_arg:
659  break;
660  default:
662  pips_internal_error("undefined syntax tag (%d)", t);
663  }
664  expression_normalized(e) = n;
665  }
666 }
int tag
TAG.
Definition: newgen_types.h:92
static normalized normalize_call(call c)
Definition: normalize.c:604
normalized normalize_reference(reference r)
Definition: normalize.c:592
#define syntax_reference(x)
Definition: ri.h:2730
#define syntax_tag(x)
Definition: ri.h:2727
@ 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 syntax_call(x)
Definition: ri.h:2736
#define normalized_undefined_p(x)
Definition: ri.h:1746

References expression_normalized, expression_syntax, is_normalized_complex, 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, make_normalized(), normalize_call(), normalize_reference(), normalized_undefined, normalized_undefined_p, pips_internal_error, syntax_call, syntax_reference, syntax_tag, and UU.

Referenced by normalize_all_expressions_of().

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

◆ normalize_all_expressions_of()

void normalize_all_expressions_of ( void *  obj)
Parameters
objbj

Definition at line 668 of file normalize.c.

669 {
671  NULL);
672 }
void gen_multi_recurse(void *o,...)
Multi recursion visitor function.
Definition: genClib.c:3428
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
Definition: genClib.c:2780
static void norm_all_rewrite(expression e)
Look for affine expressions and encode them as vectors when possible.
Definition: normalize.c:635
#define expression_domain
newgen_execution_domain_defined
Definition: ri.h:154

References expression_domain, gen_multi_recurse(), gen_true(), and norm_all_rewrite().

Referenced by array_overflow(), atom_cse_expression(), atomize_this_expression(), call_rwt(), free_guards(), handle_align_and_realign_directive(), handle_distribute_and_redistribute_directive(), loop_flt(), normalize_wp65_code(), NormalizeCodeForHpfc(), and simd_atomize_this_expression().

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

◆ normalize_call()

static normalized normalize_call ( call  c)
static

Definition at line 604 of file normalize.c.

605 {
607  entity f = call_function(c);
608  value v = entity_initial(f);
609  tag t = value_tag(v);
610 
611  switch (t)
612  {
613  case is_value_intrinsic:
615  break;
616  case is_value_constant:
618  break;
619  case is_value_symbolic:
621  break;
622  case is_value_unknown:
623  case is_value_code:
625  break;
626  default:
627  pips_internal_error("unexpected value tag (%d)", t);
628  }
629 
630  return(n);
631 }
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
static normalized normalize_intrinsic(entity f, list la)
Definition: normalize.c:517
static normalized normalize_constant(constant c)
Definition: normalize.c:583
#define value_tag(x)
Definition: ri.h:3064
#define value_constant(x)
Definition: ri.h:3073
#define call_function(x)
Definition: ri.h:709
#define symbolic_constant(x)
Definition: ri.h:2599
@ is_value_intrinsic
Definition: ri.h:3034
@ is_value_unknown
Definition: ri.h:3035
@ is_value_constant
Definition: ri.h:3033
@ is_value_code
Definition: ri.h:3031
@ is_value_symbolic
Definition: ri.h:3032
#define value_symbolic(x)
Definition: ri.h:3070
#define call_arguments(x)
Definition: ri.h:711
#define entity_initial(x)
Definition: ri.h:2796

References call_arguments, call_function, entity_initial, f(), is_normalized_complex, is_value_code, is_value_constant, is_value_intrinsic, is_value_symbolic, is_value_unknown, make_normalized(), normalize_constant(), normalize_intrinsic(), normalized_undefined, pips_internal_error, symbolic_constant, UU, value_constant, value_symbolic, and value_tag.

Referenced by norm_all_rewrite().

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

◆ normalize_constant()

static normalized normalize_constant ( constant  c)
static

Definition at line 583 of file normalize.c.

584 {
585  return((constant_int_p(c)) ?
587  vect_new(TCST, constant_int(c))) :
589 }
#define constant_int(x)
Definition: ri.h:850
#define constant_int_p(x)
Definition: ri.h:848

References constant_int, constant_int_p, is_normalized_complex, is_normalized_linear, make_normalized(), TCST, UU, and vect_new().

Referenced by normalize_call().

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

◆ normalize_first_expressions_filter()

static bool normalize_first_expressions_filter ( expression  e)
static

the first expressions encountered are normalized

normalized

n = NORMALIZE_EXPRESSION(e);

ifdebug(8)

fprintf(stderr, "[NormExpr] result (%p)\n", n),

print_expression(e);

Definition at line 679 of file normalize.c.

680 {
682  {
683  // FI: to avoid cycles betwen librairies ri-util and prettyprint
684  /* normalized */
685  /* n = NORMALIZE_EXPRESSION(e); */
686  /* ifdebug(8) */
687  /* fprintf(stderr, "[NormExpr] result (%p)\n", n), */
688  /* print_expression(e); */
689  }
690 
691  return false;
692 }

References expression_normalized, and normalized_undefined_p.

Referenced by normalize_first_expressions_of().

+ Here is the caller graph for this function:

◆ normalize_first_expressions_of()

void normalize_first_expressions_of ( void *  obj)
Parameters
objbj

Definition at line 694 of file normalize.c.

695 {
696  gen_multi_recurse(obj,
699  gen_null,
700  NULL);
701 }
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
static bool normalize_first_expressions_filter(expression e)
Definition: normalize.c:679

References expression_domain, gen_multi_recurse(), gen_null(), and normalize_first_expressions_filter().

Referenced by normalize_align(), normalize_distribute(), and normalize_hpf_object().

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

◆ normalize_intrinsic()

static normalized normalize_intrinsic ( entity  f,
list  la 
)
static

else

else

else

else

else multiply (caution: vect_multiply does not allocate...)

else

Definition at line 517 of file normalize.c.

520 {
521  bool minus;
522 
523  if (! top_level_entity_p(f))
525 
526  if (ENTITY_UNARY_MINUS_P(f))
527  {
528  Pvecteur tmp = VECTEUR_NUL;
530 
531  return(normalized_complex_p(n) ?
534  (vect_chg_sgn(tmp=vect_dup(normalized_linear(n))), tmp)));
535  }
536  /* else */
537  if ((minus=ENTITY_MINUS_P(f)) || (ENTITY_PLUS_P(f)))
538  {
539  normalized
542  Pvecteur (*operation)() = minus ? vect_substract : vect_add;
543 
545 
548  /* else */
550  operation(normalized_linear(n1),
551  normalized_linear(n2))));
552  }
553  /* else */
554  if (ENTITY_MULTIPLY_P(f))
555  {
556  normalized
559  bool b1, b2;
560  int i1, i2;
561  Pvecteur v;
562 
565  /* else */
566  b1 = normalized_constant_p(n1, &i1),
567  b2 = normalized_constant_p(n2, &i2);
568 
569  if (! (b1 || b2)) return(make_normalized(is_normalized_complex, UU));
570 
571  /* else multiply (caution: vect_multiply does not allocate...)
572  */
574 
576  vect_multiply(v, b1 ? i1 : i2)));
577  }
578  /* else */
580 }
#define assert(ex)
Definition: newgen_assert.h:41
static bool normalized_constant_p(normalized n, int *pv)
Definition: normalize.c:494
#define ENTITY_MINUS_P(e)
#define ENTITY_UNARY_MINUS_P(e)
#define ENTITY_PLUS_P(e)
#define ENTITY_MULTIPLY_P(e)
bool top_level_entity_p(entity e)
Check if the scope of entity e is global.
Definition: entity.c:1130
Value b2
Definition: sc_gram.c:105
Value b1
booleen indiquant quel membre est en cours d'analyse
Definition: sc_gram.c:105
void vect_chg_sgn(Pvecteur v)
void vect_chg_sgn(Pvecteur v): multiplie v par -1
Definition: scalaires.c:151
Pvecteur vect_multiply(Pvecteur v, Value x)
Pvecteur vect_multiply(Pvecteur v, Value x): multiplication du vecteur v par le scalaire x,...
Definition: scalaires.c:123
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.
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 assert, b1, b2, CAR, CDR, ENTITY_MINUS_P, ENTITY_MULTIPLY_P, ENTITY_PLUS_P, ENTITY_UNARY_MINUS_P, EXPRESSION, expression_normalized, f(), is_normalized_complex, is_normalized_linear, make_normalized(), normalized_complex_p, normalized_constant_p(), normalized_linear, normalized_undefined_p, top_level_entity_p(), UU, vect_add(), vect_chg_sgn(), vect_dup(), vect_multiply(), vect_substract(), and VECTEUR_NUL.

Referenced by normalize_call().

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

◆ normalize_reference()

normalized normalize_reference ( reference  r)

Definition at line 592 of file normalize.c.

593 {
594  entity var = reference_variable(r);
595 
596  pips_assert("The entity var is a variable", entity_variable_p(var));
597 
598  return(entity_integer_scalar_p(var) ?
601 }
#define entity_variable_p(e)
An entity_variable_p(e) may hide a typedef and hence a functional type.
bool entity_integer_scalar_p(entity)
for variables (like I), not constants (like 1)! use integer_constant_p() for constants
Definition: variable.c:1130
#define reference_variable(x)
Definition: ri.h:2326
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 entity_integer_scalar_p(), entity_variable_p, is_normalized_complex, is_normalized_linear, make_normalized(), pips_assert, reference_variable, UU, and vect_new().

Referenced by norm_all_rewrite(), and reference_to_expression().

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

◆ NormalizeCall()

normalized NormalizeCall ( call  c)

Definition at line 145 of file normalize.c.

146 {
148  entity f = call_function(c);
149  value v = entity_initial(f);
150 
151  switch (value_tag(v)) {
152  case is_value_intrinsic:
154  break;
155  case is_value_constant:
157  break;
158  case is_value_symbolic:
159  if(get_bool_property("EVAL_SYMBOLIC_CONSTANT"))
161  else
163  break;
164  case is_value_unknown:
165  case is_value_code:
167  break;
168  default:
169  pips_internal_error("case default");
170  }
171 
172  return(n);
173 }
normalized make_normalized_linear(Pvecteur _field_)
Definition: ri.c:1450
#define VALUE_ONE
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
normalized NormalizeIntrinsic(entity e, list la)
Definition: normalize.c:221
normalized NormalizeConstant(constant c)
Definition: normalize.c:175

References call_arguments, call_function, entity_initial, f(), get_bool_property(), is_normalized_complex, is_value_code, is_value_constant, is_value_intrinsic, is_value_symbolic, is_value_unknown, make_normalized(), make_normalized_linear(), NormalizeConstant(), normalized_undefined, NormalizeIntrinsic(), pips_internal_error, symbolic_constant, UU, value_constant, VALUE_ONE, value_symbolic, value_tag, and vect_new().

Referenced by NormalizeSyntax().

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

◆ NormalizeCast()

normalized NormalizeCast ( cast  c)

Definition at line 130 of file normalize.c.

131 {
133  type ct = cast_type(c);
134  expression cexp = cast_expression(c);
135  type cexpt = expression_to_type(cexp);
136 
137  if (type_equal_p(ct, cexpt))
138  n = NormalizeExpression(cexp);
139  else
141  free_type(cexpt);
142  return(n);
143 }
void free_type(type p)
Definition: ri.c:2658
normalized make_normalized_complex(void)
Definition: ri.c:1453
normalized NormalizeExpression(expression e)
normalize.c
Definition: normalize.c:81
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 type_equal_p(type, type)
Definition: type.c:547
#define cast_expression(x)
Definition: ri.h:747
#define cast_type(x)
Definition: ri.h:745

References cast_expression, cast_type, expression_to_type(), free_type(), make_normalized_complex(), normalized_undefined, NormalizeExpression(), and type_equal_p().

Referenced by NormalizeSyntax().

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

◆ NormalizeConstant()

normalized NormalizeConstant ( constant  c)

Definition at line 175 of file normalize.c.

176 {
177  return((constant_int_p(c)) ?
180 }

References constant_int, constant_int_p, make_normalized_complex(), make_normalized_linear(), TCST, and vect_new().

Referenced by NormalizeCall().

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

◆ normalized_constant_p()

static bool normalized_constant_p ( normalized  n,
int pv 
)
static

New Stuff to normalize all expressions - bottom-up

FC 09/06/94

Definition at line 494 of file normalize.c.

495 {
496  if (normalized_linear_p(n))
497  {
499  int length = vect_size(v);
500 
501  if (length==0)
502  {
503  *pv=0;
504  return true;
505  }
506  else if (length==1 && var_of(v)==TCST)
507  {
508  *pv=VALUE_TO_INT(val_of(v));
509  return true;
510  }
511  }
512 
513  return false;
514 }

References normalized_linear, normalized_linear_p, TCST, val_of, VALUE_TO_INT, var_of, and vect_size().

Referenced by normalize_intrinsic().

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

◆ NormalizeExpression()

normalized NormalizeExpression ( expression  e)

normalize.c

Definition at line 81 of file normalize.c.

82 {
83  normalized n;
84 
86  user_warning("NormalizeExpression",
87  "expression is already normalized\n");
88 
89  n = _NormalizeExpression(e);
90  // expression_normalized(e) = n;
91  return(n);
92 }
#define user_warning(fn,...)
Definition: misc-local.h:262

References _NormalizeExpression(), expression_normalized, normalized_undefined, and user_warning.

Referenced by force_renormalize(), NormalizeCast(), xml_Connection(), and xml_ConstOffset().

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

◆ NormalizeIntrinsic()

normalized NormalizeIntrinsic ( entity  e,
list  la 
)

There is no point in normalizing ng since this cannot be expressed by a normalized expression

Parameters
laa

Definition at line 221 of file normalize.c.

222 {
223  normalized n;
224 
225  if (! top_level_entity_p(e))
227 
228  if (ENTITY_UNARY_MINUS_P(e)) {
230 
231  if (normalized_complex_p(n))
232  return(n);
233 
235  }
236  else if (ENTITY_MINUS_P(e) || ENTITY_MINUS_C_P(e) || ENTITY_PLUS_P(e) || ENTITY_PLUS_C_P(e)) {
237  normalized ng, nd;
238 
240  if (normalized_complex_p(ng))
241  return(ng);
242 
244  if (normalized_complex_p(nd)) {
245  FreeNormalized(ng);
246  return(nd);
247  }
248 
249  n = (ENTITY_PLUS_P(e) || ENTITY_PLUS_C_P(e)) ?
252  normalized_linear(nd))) :
255  normalized_linear(nd)));
256 
257  FreeNormalized(ng);
258  FreeNormalized(nd);
259  }
260  else if (ENTITY_MINUS_UPDATE_P(e) || ENTITY_PLUS_UPDATE_P(e)) {
261  /* There is no point in normalizing ng since this cannot be
262  expressed by a normalized expression */
263  //normalized nd;
264 
265  (void) _NormalizeExpression(EXPRESSION(CAR(CDR(la))));
266  return make_normalized_complex();
267  }
268  else if (ENTITY_MULTIPLY_P(e)) {
269  normalized ng, nd;
270  int val;
271 
273  if (normalized_complex_p(ng))
274  return(ng);
275 
277  if (normalized_complex_p(nd)) {
278  FreeNormalized(ng);
279  return(nd);
280  }
281 
282  if (EvalNormalized(nd, &val)) {
283  FreeNormalized(nd);
284  normalized_linear(n = ng) =
286  }
287  else if (EvalNormalized(ng, &val)) {
288  FreeNormalized(ng);
289  normalized_linear(n = nd) =
291  }
292  else {
293  FreeNormalized(ng);
294  FreeNormalized(nd);
296  }
297  }
298  else if((ENTITY_MIN_P(e) || ENTITY_MIN0_P(e)) && gen_length(la) == 2) {
299  n = binary_to_normalized(la, MINIMUM);
300  }
301  else if((ENTITY_MAX_P(e) || ENTITY_MAX0_P(e)) && gen_length(la) == 2) {
302  n = binary_to_normalized(la, MAXIMUM);
303  }
304  else if(ENTITY_MODULO_P(e)) {
305  n = binary_to_normalized(la, MOD);
306  }
307  else if(ENTITY_DIVIDE_P(e)) {
308  n = binary_to_normalized(la, SLASH);
309  }
310  else if(ENTITY_POWER_P(e)) {
311  n = binary_to_normalized(la, POWER);
312  }
313  else {
315  }
316 
317  return(n);
318 }
normalized binary_to_normalized(list la, int op)
Definition: normalize.c:320
#define ENTITY_PLUS_UPDATE_P(e)
#define ENTITY_DIVIDE_P(e)
#define ENTITY_POWER_P(e)
#define ENTITY_MAX0_P(e)
#define ENTITY_PLUS_C_P(e)
#define ENTITY_MAX_P(e)
#define ENTITY_MINUS_C_P(e)
#define ENTITY_MIN0_P(e)
#define ENTITY_MIN_P(e)
#define ENTITY_MINUS_UPDATE_P(e)
#define ENTITY_MODULO_P(e)

References _NormalizeExpression(), binary_to_normalized(), CAR, CDR, ENTITY_DIVIDE_P, ENTITY_MAX0_P, ENTITY_MAX_P, ENTITY_MIN0_P, ENTITY_MIN_P, ENTITY_MINUS_C_P, ENTITY_MINUS_P, ENTITY_MINUS_UPDATE_P, ENTITY_MODULO_P, ENTITY_MULTIPLY_P, ENTITY_PLUS_C_P, ENTITY_PLUS_P, ENTITY_PLUS_UPDATE_P, ENTITY_POWER_P, ENTITY_UNARY_MINUS_P, EvalNormalized(), EXPRESSION, FreeNormalized(), gen_length(), is_normalized_complex, is_normalized_linear, make_normalized(), make_normalized_complex(), MAXIMUM, MINIMUM, MOD, normalized_complex_p, normalized_linear, POWER, SLASH, top_level_entity_p(), UU, vect_add(), vect_chg_sgn(), vect_multiply(), and vect_substract().

Referenced by NormalizeCall().

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

◆ NormalizeReference()

normalized NormalizeReference ( reference  r)

SG is there any good reason to exclude pointer arithmetic ?

Definition at line 182 of file normalize.c.

183 {
185  entity e = reference_variable(r);
186  type t = entity_type(e);
187 
188  pips_assert("constant term ore is an entity",
190 
191  if (!type_variable_p(t)) {
192  if(type_functional_p(t)) {
193  // FI: we might not want to keep the warning for C code...
194  pips_user_warning("Reference to function \"%s\" cannot be normalized.\n"
195  "Is it an undeclared variable?\n",
196  entity_user_name(e));
198  }
199  else {
200  pips_user_warning("Reference to entity \"%s\" cannot be normalized because of its type tag %d\n",
201  entity_name(e), type_tag(t));
202  pips_user_error("Referenced entity should be a variable!\n");
203  }
204  }
205  else {
206  Variable v = (Variable) e;
207  Value val = VALUE_ONE;
208 
209  /* SG is there any good reason to exclude pointer arithmetic ?*/
210  n = (entity_integer_scalar_p(e) ||
212  ( entity_pointer_p(e) && ENDP(reference_indices(r))) ) ?
214  vect_new(v, val)) :
216  }
217 
218  return n;
219 }
int Value
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define pips_user_warning
Definition: misc-local.h:146
#define pips_user_error
Definition: misc-local.h:147
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 entity_enum_variable_p(entity e)
Definition: entity.c:992
bool entity_pointer_p(entity e)
Definition: entity.c:745
#define type_functional_p(x)
Definition: ri.h:2950
#define type_tag(x)
Definition: ri.h:2940
#define entity_name(x)
Definition: ri.h:2790
#define reference_indices(x)
Definition: ri.h:2328
#define entity_type(x)
Definition: ri.h:2792
#define entity_domain_number(x)
Definition: ri.h:2788
#define type_variable_p(x)
Definition: ri.h:2947
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410

References ENDP, entity_domain, entity_domain_number, entity_enum_variable_p(), entity_integer_scalar_p(), entity_name, entity_pointer_p(), entity_type, entity_user_name(), is_normalized_complex, is_normalized_linear, make_normalized(), normalized_undefined, pips_assert, pips_user_error, pips_user_warning, reference_indices, reference_variable, type_functional_p, type_tag, type_variable_p, UU, VALUE_ONE, and vect_new().

Referenced by NormalizeSyntax().

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

◆ NormalizeSyntax()

normalized NormalizeSyntax ( syntax  s)

Definition at line 94 of file normalize.c.

95 {
97 
98  switch (syntax_tag(s)) {
101  break;
102  case is_syntax_range:
104  break;
105  case is_syntax_call:
106  n = NormalizeCall((syntax_call(s)));
107  break;
108  case is_syntax_cast:
109  n = NormalizeCast(syntax_cast(s));
110  break;
113  break;
114  case is_syntax_subscript:
116  break;
119  break;
120  case is_syntax_va_arg:
122  break;
123  default:
124  pips_internal_error("cas default");
125  }
126 
127  return(n);
128 }
normalized NormalizeCall(call c)
Definition: normalize.c:145
normalized NormalizeReference(reference r)
Definition: normalize.c:182
normalized NormalizeCast(cast c)
Definition: normalize.c:130
#define syntax_cast(x)
Definition: ri.h:2739

References 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, make_normalized_complex(), NormalizeCall(), NormalizeCast(), normalized_undefined, NormalizeReference(), pips_internal_error, syntax_call, syntax_cast, syntax_reference, and syntax_tag.

Referenced by _NormalizeExpression(), and array_indices_communication().

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

◆ unnormalize_expression()

void unnormalize_expression ( void *  st)

void unnormalize_expression(expression exp): puts all the normalized field of expressions in "st" to undefined and does the unnormalization recursively

This is very useful when you combine expressions. It prohibits unnormalized expressions with normalized sub-expressions.

FI: any chunk* can be passed; this function could be applied to an expression

Parameters
stt

Definition at line 452 of file normalize.c.

453 {
456  gen_true,
458  NULL);
459 }
void free_expression_normalized(expression e)
Definition: normalize.c:432

References expression_domain, free_expression_normalized(), gen_multi_recurse(), and gen_true().

Referenced by analyze_expression(), do_gather_all_expressions_perms(), do_outliner_smart_replacment(), do_scalar_renaming(), get_exp_schedule(), get_m_coef(), inline_expression_call(), my_adg_expressions_to_predicate(), nlc_linear_expression_p(), optimize_expressions(), partial_eval_expression(), perform_substitution(), rational_op_exp(), redundant_load_store_elimination(), rename_reference(), replace_entities_expression_walker(), sp_linear_expression_p(), splc_linear_expression_p(), try_reorder_expression_call(), and update_expression_syntax().

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