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

Go to the source code of this file.

Functions

expression update_range (f, r, expression lw, expression up, expression in, bool left)
 Prettyprint one FORTRAN 90 loop as an array expression. More...
 

Function Documentation

◆ update_range()

expression update_range ( f  ,
,
expression  lw,
expression  up,
expression  in,
bool  left 
)

Prettyprint one FORTRAN 90 loop as an array expression.

Pierre Jouvelot

For one level only loop, with one assignment as body. Replaces occurences of the index variable by ranges in expressions. Ranges are prettyprinted as triplet when they occur as subscript expressions and as vectors with implicit DO otherwise. If the replacement cannot occur, for instance because subscript expressions are coupled, the loop is printed as a loop.

There are/were memory leaks here since a new expression is constructed. Entity f is supposed to be a binary operator, not always commutative but meaningful for a range and a scalar or for two ranges. Boolean argument left means that range r appears on the left of f, i.e. as first operator.

No sharing is created between the new expression e and arguments r, lw, up or in.

expression "in" must be integer constant 1

Definition at line 61 of file fortran90.c.

66 {
67  range new_r = copy_range(r);
68  intptr_t val = 0;
69  expression new_up = copy_expression(up);
70  expression new_lw = copy_expression(lw);
71  expression new_in = copy_expression(in);
73 
74  pips_assert("new_r is consistent before update", range_consistent_p(new_r));
75 
76  if(left) {
77  range_lower( new_r ) = MakeBinaryCall(f, range_lower(new_r), new_lw);
78  range_upper( new_r ) = MakeBinaryCall(f, range_upper(new_r), new_up);
79  }
80  else {
81  range_lower( new_r ) = MakeBinaryCall(f, new_lw, range_lower(new_r));
82  range_upper( new_r ) = MakeBinaryCall(f, new_up, range_upper(new_r));
83  }
84 
85  pips_assert("new_r is consistent", range_consistent_p(new_r));
86 
87  if( strcmp( entity_local_name( f ), MULTIPLY_OPERATOR_NAME ) == 0 ) {
88  /* expression "in" must be integer constant 1 */
89  pips_assert("This is a scalar value", lw==up);
91  range_increment( new_r ) =
92  MakeBinaryCall(f, new_in, copy_expression(range_lower(new_r))) ;
93  }
94 
95  if( !left && (strcmp( entity_local_name( f ), MINUS_OPERATOR_NAME ) == 0) ) {
97 
98  range_increment( new_r ) =
99  MakeUnaryCall(um, range_increment(new_r)) ;
100  }
101 
102  if(expression_integer_value(range_lower(new_r), &val)) {
104  range_lower(new_r) = int_to_expression(val);
105  }
106 
107  if(expression_integer_value(range_upper(new_r), &val)) {
109  range_upper(new_r) = int_to_expression(val);
110  }
111 
112  if(expression_integer_value(range_increment(new_r), &val)) {
114  range_increment(new_r) = int_to_expression(val);
115  }
116 
117  pips_assert("new_r is consistent after simplification", range_consistent_p(new_r));
118 
121 
122  return e;
123 }
range copy_range(range p)
RANGE.
Definition: ri.c:2005
expression make_expression(syntax a1, normalized a2)
Definition: ri.c:886
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
bool range_consistent_p(range p)
Definition: ri.c:2014
void free_expression(expression p)
Definition: ri.c:853
syntax make_syntax(enum syntax_utype tag, void *val)
Definition: ri.c:2491
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
#define MINUS_OPERATOR_NAME
#define UNARY_MINUS_OPERATOR_NAME
#define MULTIPLY_OPERATOR_NAME
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
bool expression_integer_value(expression e, intptr_t *pval)
Definition: eval.c:792
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
Definition: expression.c:354
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 MakeUnaryCall(entity f, expression a)
Creates a call expression to a function with one argument.
Definition: expression.c:342
#define normalized_undefined
Definition: ri.h:1745
#define range_upper(x)
Definition: ri.h:2290
@ is_syntax_range
Definition: ri.h:2692
#define range_increment(x)
Definition: ri.h:2292
#define expression_undefined
Definition: ri.h:1223
#define range_lower(x)
Definition: ri.h:2288
#define intptr_t
Definition: stdint.in.h:294

References copy_expression(), copy_range(), entity_intrinsic(), entity_local_name(), expression_integer_value(), expression_undefined, f(), free_expression(), int_to_expression(), intptr_t, is_syntax_range, make_expression(), make_syntax(), MakeBinaryCall(), MakeUnaryCall(), MINUS_OPERATOR_NAME, MULTIPLY_OPERATOR_NAME, normalized_undefined, pips_assert, range_consistent_p(), range_increment, range_lower, range_upper, and UNARY_MINUS_OPERATOR_NAME.

Referenced by expand_call().

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