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

Go to the source code of this file.

Functions

entity MakeParameter (entity e, expression x)
 lint More...
 
expression MakeImpliedDo (syntax v, range r, cons *l)
 expressions from input output lists might contain implied do loops. More...
 
expression loop_to_implieddo (loop)
 
static list make_arg_from_stmt (statement stmt, list args)
 this used to be a nested function, but compilation on macos dislikes nested functions ... More...
 
syntax MakeAtom (entity e, cons *indices, expression fc, expression lc, int HasParenthesis)
 MakeAtom: this function creates a syntax, ie. More...
 
consMakeIoList (cons *l)
 This function takes a list of io elements (i, j, t(i,j)), and returns the same list, with a cons cell pointing to a character constant expression 'IOLIST=' before each element of the original list. More...
 
list FortranExpressionList (list l)
 Make sure that no call to implied do is in l. More...
 
expression MakeFortranBinaryCall (entity op, expression e1, expression e2)
 
expression MakeFortranUnaryCall (entity op, expression e1)
 
syntax CheckLeftHandSide (syntax s)
 If a left hand side is a call, it should be a substring operator or a macro. More...
 
entity make_Fortran_constant_entity (string name, tag bt, size_t size)
 

Variables

char vcid_syntax_expression [] = "$Id: expression.c 23065 2016-03-02 09:05:50Z coelho $"
 expression.c More...
 

Function Documentation

◆ CheckLeftHandSide()

syntax CheckLeftHandSide ( syntax  s)

If a left hand side is a call, it should be a substring operator or a macro.

If it is a call to an intrinsic with no arguments, the intrinsic is in fact masqued by a local variable.

If s is not OK, it is freed and a new_s is allocated.

OK for substrings: They are processed later by MakeAssignInst()

Oupss... This must be a local variable

A call to an intrinsic cannot be a lhs: statement function? Let's hope it works...

Must be a macro...

Definition at line 542 of file expression.c.

543 {
544  syntax new_s = syntax_undefined;
545 
546  if(syntax_reference_p(s)) {
548  type vt = entity_type(v);
549 
550  if(type_variable_p(vt))
551  new_s = s;
552  else
553  pips_user_error("Illegal assignment to variable %s with type %s\n",
555  }
556  else {
557  call c = syntax_call(s);
558  entity f = call_function(c);
559 
560  if(intrinsic_entity_p(f)) {
561  if(strcmp(entity_local_name(f), SUBSTRING_FUNCTION_NAME)==0) {
562  /* OK for substrings: They are processed later by MakeAssignInst() */
563  pips_debug(7, "Substring assignment detected\n");
564  new_s = s;
565  }
566  else if(ENDP(call_arguments(c))) {
567  /* Oupss... This must be a local variable */
569 
570  user_warning("CheckLeftHandSide",
571  "Name conflict between local variable %s and intrinsics %s\n",
573 
574  free_syntax(s);
577  }
578  else {
579  /* A call to an intrinsic cannot be a lhs: statement function?
580  Let's hope it works... */
581  user_warning("CheckLeftHandSide",
582  "Name conflict between statement function %s and intrinsics %s\n",
584  new_s = s;
585  }
586  }
587  else {
588  /* Must be a macro... */
589  pips_debug(2, "Statement function definition %s\n", entity_name(f));
590  new_s = s;
591  }
592  }
593 
594  return new_s;
595 }
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
void free_syntax(syntax p)
Definition: ri.c:2445
syntax make_syntax(enum syntax_utype tag, void *val)
Definition: ri.c:2491
const char * get_current_module_name(void)
Get the name of the current module.
Definition: static.c:121
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define user_warning(fn,...)
Definition: misc-local.h:262
#define pips_user_error
Definition: misc-local.h:147
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
void reify_ghost_variable_entity(entity e)
It is possible to change one's mind and effectively use an entity which was previously assumed useles...
Definition: procedure.c:284
#define SUBSTRING_FUNCTION_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 FindOrCreateEntity(const char *package, const char *local_name)
Problem: A functional global entity may be referenced without parenthesis or CALL keyword in a functi...
Definition: entity.c:1586
bool intrinsic_entity_p(entity e)
Definition: entity.c:1272
string type_to_string(const type)
type.c
Definition: type.c:51
#define syntax_reference_p(x)
Definition: ri.h:2728
#define syntax_reference(x)
Definition: ri.h:2730
#define call_function(x)
Definition: ri.h:709
#define reference_variable(x)
Definition: ri.h:2326
@ is_syntax_reference
Definition: ri.h:2691
#define entity_name(x)
Definition: ri.h:2790
#define syntax_call(x)
Definition: ri.h:2736
#define syntax_undefined
Definition: ri.h:2676
#define call_arguments(x)
Definition: ri.h:711
#define entity_type(x)
Definition: ri.h:2792
#define type_variable_p(x)
Definition: ri.h:2947

References call_arguments, call_function, ENDP, entity_local_name(), entity_name, entity_type, f(), FindOrCreateEntity(), free_syntax(), get_current_module_name(), intrinsic_entity_p(), is_syntax_reference, make_reference(), make_syntax(), NIL, pips_debug, pips_user_error, reference_variable, reify_ghost_variable_entity(), SUBSTRING_FUNCTION_NAME, syntax_call, syntax_reference, syntax_reference_p, syntax_undefined, type_to_string(), type_variable_p, and user_warning.

+ Here is the call graph for this function:

◆ FortranExpressionList()

list FortranExpressionList ( list  l)

Make sure that no call to implied do is in l.

Definition at line 492 of file expression.c.

493 {
494  MAP(EXPRESSION, e, {
496  ParserError("FortranExpressionList", "Unexpected implied DO\n");
497  }, l);
498  return l;
499 }
#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
bool expression_implied_do_p(e)
Definition: expression.c:817
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
bool ParserError(const char *f, const char *m)
Definition: parser.c:116

References EXPRESSION, expression_implied_do_p(), MAP, and ParserError().

+ Here is the call graph for this function:

◆ loop_to_implieddo()

expression loop_to_implieddo ( loop  l)

Fix last parameter

Definition at line 167 of file expression.c.

167  {
169  range r = loop_range(l);
170 
171 
172  /* Fix last parameter */
173  statement body = loop_body(l);
174  instruction ibody = statement_instruction(body);
175  list args = NIL;
176  if(instruction_sequence_p(ibody)) {
177  sequence seq = instruction_sequence(ibody);
179  args = make_arg_from_stmt(stmt, args);
180  }
181  args = gen_nreverse(args);
182  } else {
183  args = make_arg_from_stmt(body, args);
184  }
185  return MakeImpliedDo(index, r, args);
186 }
syntax make_syntax_reference(reference _field_)
Definition: ri.c:2494
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#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
#define loop_body(x)
Definition: ri.h:1644
#define instruction_sequence_p(x)
Definition: ri.h:1512
#define sequence_statements(x)
Definition: ri.h:2360
#define instruction_sequence(x)
Definition: ri.h:1514
#define statement_instruction(x)
Definition: ri.h:2458
#define loop_range(x)
Definition: ri.h:1642
#define loop_index(x)
Definition: ri.h:1640
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
Definition: statement.c:54
expression MakeImpliedDo(syntax v, range r, cons *l)
expressions from input output lists might contain implied do loops.
Definition: expression.c:115
static list make_arg_from_stmt(statement stmt, list args)
this used to be a nested function, but compilation on macos dislikes nested functions ....
Definition: expression.c:148

References FOREACH, gen_nreverse(), instruction_sequence, instruction_sequence_p, loop_body, loop_index, loop_range, make_arg_from_stmt(), make_reference(), make_syntax_reference(), MakeImpliedDo(), NIL, sequence_statements, and statement_instruction.

Referenced by gfc2pips_code2instruction_(), and make_arg_from_stmt().

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

◆ make_arg_from_stmt()

static list make_arg_from_stmt ( statement  stmt,
list  args 
)
static

this used to be a nested function, but compilation on macos dislikes nested functions ...

Definition at line 148 of file expression.c.

148  {
150  expression expr;
151  if ( instruction_expression_p(i) ) {
152  expr = instruction_expression(i);
153  } else if ( instruction_loop_p(i) ) {
154  expr = loop_to_implieddo( instruction_loop(i) );
155  } else {
156  pips_internal_error("We can't handle anything other than expression"
157  "and loop for loop-to-implieddo conversion.\n");
158  expr = expression_undefined;
159  }
160  args = CONS(EXPRESSION,expr, args );
161  return args;
162 }
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#define pips_internal_error
Definition: misc-local.h:149
#define instruction_loop_p(x)
Definition: ri.h:1518
#define instruction_loop(x)
Definition: ri.h:1520
#define expression_undefined
Definition: ri.h:1223
#define instruction_expression(x)
Definition: ri.h:1541
#define instruction_expression_p(x)
Definition: ri.h:1539
expression loop_to_implieddo(loop)
Definition: expression.c:167

References CONS, EXPRESSION, expression_undefined, instruction_expression, instruction_expression_p, instruction_loop, instruction_loop_p, loop_to_implieddo(), pips_internal_error, and statement_instruction.

Referenced by loop_to_implieddo().

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

◆ make_Fortran_constant_entity()

entity make_Fortran_constant_entity ( string  name,
tag  bt,
size_t  size 
)
Parameters
nameame
btt
sizeize

Definition at line 597 of file expression.c.

600 {
601  return make_C_or_Fortran_constant_entity(name, bt, size, true, ParserError);
602 }
entity make_C_or_Fortran_constant_entity(const char *name, tag bt, size_t size, bool is_fortran, bool(*error_manager)(const char *, const char *))
This function creates a constant.
Definition: constant.c:148

References make_C_or_Fortran_constant_entity(), and ParserError().

+ Here is the call graph for this function:

◆ MakeAtom()

syntax MakeAtom ( entity  e,
cons indices,
expression  fc,
expression  lc,
int  HasParenthesis 
)

MakeAtom: this function creates a syntax, ie.

a reference, a call or a range.

there are a few good cases: e is a variable and its dimensionality is equal to the number of expressions in indices, e is a function, e is a constant or a symbolic constant.

there are a few bad cases: e is a zero dimension variable and indices is not equal to NIL (see comments of MakeExternalFunction), e is not known and the list indices is not empty (it is a call to a user function), e is not known and the list indices is empty (it is an implicit declaration).

in this function, we first try to transform bad cases into good ones, and then to create a syntax.

e is a variable or a function.

indices is a list of expressions (arguments or indices).

fc and lc are substring bound expressions.

HasParenthesis is a bool that tells if the reference to e was done with () or not. this is mandatory to make the difference between a call to a function and a reference to a function.

  • MakeAtom in expression.c fixed to generate the proper message when the substring operator is used (Francois Irigoin, 6 June 1995). See lcart2.f in Validation.

checking errors ...

It can be a PARAMETER or a functional variable or...

Not enough information to decide to stop or not.

ParserError("MakeAtom", "unsupported use of a functional entity\n");

fixing bad cases

FI: to handle parameterless function calls like t= second() - 11 March 1993

if (indices == NULL) {

It has already been declared and should not be redeclared because it may be an entry formal parameter which is not declared in the current module. If e represents an entry formal parameter (although its top-level name is the current module), it does not belong to the declarations of the current module. Hence, it is hard to assert something here.

However, e has to be typed and valued.

e = MakeExternalFunction(e, type_undefined);

use expression list to compute argument types

FI: same as in previous paragraph

if (variable_dimensions(type_variable(te))==NULL && indices!=NULL) {

if (variable_dimensions(type_variable(te))==NULL && (indices!=NULL || HasParenthesis)) {

use expression list to compute argument types

FI: probleme here for character returning function! You have to know if you are dealing with a substring operator or a function call.

Fortunately, according to SUN f77 compiler, you are not allowed to take the substring of a function call!

In fact, only check compatability... if requested!

here, bad cases have been transformed into good ones.

substring

pips_assert("Substring can only be applied to a string", basic_string_p(bt));

Probably an extension we would have liked to have for the DREAM-UP project.

The upper bound may be unknown for formal parameters and for allocatable arrays and cannot be retrieved from the type declaration

ParserError("MakeAtom", "Substrings are not implemented\n");

e is either called or passed as argument to a function. It cannot be a PARAMETER or its value would be known.

e is either called or passed as argument to a function, or it is a PARAMETER, in which case, it must really be called.

Parameters
indicesndices
fcc
lcc
HasParenthesisasParenthesis

Definition at line 222 of file expression.c.

227 {
229  type te;
230 
231  te = entity_type(e);
232 
233  /* checking errors ... */
234  if (te != type_undefined) {
235  if (type_statement_p(te)) {
236  FatalError("MakeAtom", "label dans une expression\n");
237  }
238  else if (type_area_p(te)) {
239  FatalError("MakeAtom", "area dans une expression\n");
240  }
241  else if (type_void_p(te)) {
242  FatalError("MakeAtom", "void dans une expression\n");
243  }
244  else if (type_unknown_p(te)) {
245  FatalError("MakeAtom", "unknown dans une expression\n");
246  }
247  else if (type_functional_p(te)) {
248  if(!HasParenthesis) {
249  /* It can be a PARAMETER or a functional variable or... */
250  value iv = entity_initial(e);
251  if(!value_undefined_p(iv) && value_code_p(iv)) {
252  user_warning("MakeAtom", "reference to functional entity %s\n",
253  entity_name(e));
254  /* Not enough information to decide to stop or not. */
255  /* ParserError("MakeAtom",
256  "unsupported use of a functional entity\n"); */
257  }
258  }
259  }
260  }
261 
262  /* fixing bad cases */
263  if (te == type_undefined) {
264  /* FI: to handle parameterless function calls like t= second() - 11 March 1993 */
265  /* if (indices == NULL) { */
266  if (indices == NULL && !HasParenthesis) {
268  debug(2, "MakeAtom", "implicit declaration of scalar variable: %s\n",
269  entity_name(e));
272  }
273  else if(storage_formal_p(entity_storage(e))) {
274  pips_debug(2, "reference to a functional parameter: %s\n",
275  entity_name(e));
276  /* It has already been declared and should not be
277  redeclared because it may be an entry formal parameter
278  which is not declared in the current module. If e
279  represents an entry formal parameter (although its
280  top-level name is the current module), it does not
281  belong to the declarations of the current
282  module. Hence, it is hard to assert something here.
283 
284  However, e has to be typed and valued. */
285  if(type_undefined_p(entity_type(e))) {
286  entity_type(e) = ImplicitType(e);
287  }
290  }
291  }
292  else {
293  debug(2, "MakeAtom", "implicit type declaration of scalar variable: %s\n",
294  entity_name(e));
297  }
298  }
299  else {
300  type tr = ImplicitType(e);
301 
302  debug(2, "MakeAtom", "new user function: %s\n",
303  entity_name(e));
304  /* e = MakeExternalFunction(e, type_undefined); */
305  e = MakeExternalFunction(e, tr);
306 
307  /* use expression list to compute argument types */
309  }
310  }
311  else if (type_variable_p(te)) {
312  /* FI: same as in previous paragraph */
313  /* if (variable_dimensions(type_variable(te))==NULL && indices!=NULL) { */
314  /* if (variable_dimensions(type_variable(te))==NULL
315  && (indices!=NULL || HasParenthesis)) { */
316  if (variable_dimensions(type_variable(te))==NULL
317  && (indices!=NULL || HasParenthesis)) {
319  /*
320  if( !basic_string_p(variable_basic(type_variable(te)))
321  || (fc==expression_undefined && lc==expression_undefined)) */ {
323 
324  /* use expression list to compute argument types */
326 
327  /* FI: probleme here for character returning function! You have to know if
328  * you are dealing with a substring operator or a function call.
329  *
330  * Fortunately, according to SUN f77 compiler, you are not allowed to
331  * take the substring of a function call!
332  */
333  }
334  }
335  }
336  else if (type_functional_p(te) && HasParenthesis) {
337  /* In fact, only check compatability... if requested! */
339  }
340 
341  /* here, bad cases have been transformed into good ones. */
342  te = entity_type(e);
343 
344  if (type_variable_p(te)) {
345  if((gen_length(indices)==0) ||
346  (gen_length(indices)==
348  if (lc == expression_undefined && fc == expression_undefined) {
350  make_reference(e, indices));
351  }
352  else {
353  /* substring */
354  expression ref =
356  make_reference(e, indices)),
360  list lexpr = NIL;
363 
364  if(!basic_string_p(bt)) {
365  /* pips_assert("Substring can only be applied to a string",
366  basic_string_p(bt)); */
367  if(!get_bool_property("PARSER_ACCEPT_ARRAY_RANGE_EXTENSION"))
368  ParserError("MakeAtom",
369  "Substring operations can only be applied to "
370  "strings in Fortran 77\n");
371  else {
372  /* Probably an extension we would have liked to have
373  for the DREAM-UP project. */
374  pips_internal_error("Not implemented yet");
375  }
376  }
377 
378  if(fc == expression_undefined)
379  fce = int_to_expression(1);
380  else
381  fce = fc;
382 
383  if(lc == expression_undefined) {
384  /* The upper bound may be unknown for formal
385  parameters and for allocatable arrays and cannot be
386  retrieved from the type declaration */
387  value ub = basic_string(bt);
388 
389  if(value_unknown_p(ub)) {
391  }
392  else {
394  }
395  }
396  else
397  lce = lc;
398 
399  lexpr = CONS(EXPRESSION, ref,
400  CONS(EXPRESSION, fce,
401  CONS(EXPRESSION, lce, NIL)));
402  s = make_syntax(is_syntax_call, make_call(substr, lexpr));
403  /* ParserError("MakeAtom", "Substrings are not implemented\n"); */
404  }
405  }
406  else {
407  user_warning("MakeAtom",
408  "Too many or too few subscript expressions"
409  " for reference to %s\n",
410  entity_local_name(e));
411  ParserError("MakeAtom", "Illegal array reference\n");
412  }
413 
414  }
415  else if (type_functional_p(te)) {
417  /* e is either called or passed as argument to a function.
418  It cannot be a PARAMETER or its value would be known. */
419  if (indices == NIL && HasParenthesis == false) {
421  }
422  else {
425  }
426  }
427  else {
428  if (value_code_p(entity_initial(e))) {
430  }
431 
432  /* e is either called or passed as argument to a function, or
433  it is a PARAMETER, in which case, it must really be
434  called. */
435  if (indices == NIL && !HasParenthesis
438  }
439  else {
441  }
442  }
443  }
444  else {
445  ParserError("MakeAtom", "unexpected type\n");
446  }
447 
448  return(s);
449 }
call make_call(entity a1, list a2)
Definition: ri.c:269
value make_value_unknown(void)
Definition: ri.c:2847
expression make_expression(syntax a1, normalized a2)
Definition: ri.c:886
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
void DeclareVariable(entity e, type t, list d, storage s, value v)
void DeclareVariable(e, t, d, s, v): update entity e description as declaration statements are encoun...
Definition: declaration.c:670
type ImplicitType(entity e)
This function computes the Fortran implicit type of entity e.
Definition: declaration.c:1311
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
size_t gen_length(const list l)
Definition: list.c:150
static list indices
Definition: icm.c:204
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
entity MakeExternalFunction(entity e, type r)
Definition: procedure.c:2372
void update_called_modules(entity e)
Definition: procedure.c:308
#define UNBOUNDED_DIMENSION_NAME
Definition: ri-util-local.h:74
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
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
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 MakeNullaryCall(entity f)
Creates a call expression to a function with zero arguments.
Definition: expression.c:331
int basic_type_size(basic)
See also SizeOfElements()
Definition: type.c:1074
#define type_functional_p(x)
Definition: ri.h:2950
#define value_undefined_p(x)
Definition: ri.h:3017
#define value_undefined
Definition: ri.h:3016
#define value_code_p(x)
Definition: ri.h:3065
#define normalized_undefined
Definition: ri.h:1745
#define storage_formal_p(x)
Definition: ri.h:2522
#define type_unknown_p(x)
Definition: ri.h:2956
#define value_unknown_p(x)
Definition: ri.h:3077
#define type_variable(x)
Definition: ri.h:2949
#define entity_storage(x)
Definition: ri.h:2794
#define type_statement_p(x)
Definition: ri.h:2941
@ is_syntax_call
Definition: ri.h:2693
#define type_undefined_p(x)
Definition: ri.h:2884
#define value_symbolic_p(x)
Definition: ri.h:3068
#define type_void_p(x)
Definition: ri.h:2959
#define variable_dimensions(x)
Definition: ri.h:3122
#define type_undefined
Definition: ri.h:2883
#define type_area_p(x)
Definition: ri.h:2944
#define basic_string_p(x)
Definition: ri.h:629
#define storage_undefined_p(x)
Definition: ri.h:2477
#define variable_basic(x)
Definition: ri.h:3120
#define basic_string(x)
Definition: ri.h:631
#define storage_undefined
Definition: ri.h:2476
#define entity_initial(x)
Definition: ri.h:2796
#define FatalError(f, m)
Definition: syntax-local.h:56
void update_functional_type_with_actual_arguments(entity e, list l)
Definition: statement.c:971

References basic_string, basic_string_p, basic_type_size(), CONS, CreateIntrinsic(), debug(), DeclareVariable(), entity_initial, entity_intrinsic(), entity_local_name(), entity_name, entity_storage, entity_type, EXPRESSION, expression_undefined, FatalError, gen_length(), get_bool_property(), ImplicitType(), indices, int_to_expression(), is_syntax_call, is_syntax_reference, make_call(), make_expression(), make_reference(), make_syntax(), make_value_unknown(), MakeExternalFunction(), MakeNullaryCall(), NIL, normalized_undefined, ParserError(), pips_debug, pips_internal_error, ref, storage_formal_p, storage_undefined, storage_undefined_p, SUBSTRING_FUNCTION_NAME, syntax_undefined, type_area_p, type_functional_p, type_statement_p, type_undefined, type_undefined_p, type_unknown_p, type_variable, type_variable_p, type_void_p, UNBOUNDED_DIMENSION_NAME, update_called_modules(), update_functional_type_with_actual_arguments(), user_warning, value_code_p, value_symbolic_p, value_undefined, value_undefined_p, value_unknown_p, variable_basic, and variable_dimensions.

+ Here is the call graph for this function:

◆ MakeFortranBinaryCall()

expression MakeFortranBinaryCall ( entity  op,
expression  e1,
expression  e2 
)
Parameters
opp
e11
e22

Definition at line 502 of file expression.c.

506 {
508 
510  ParserError("MakeFortranBinaryCall", "Unexpected implied DO\n");
511  }
512 
513  e = MakeBinaryCall(op, e1, e2);
514 
515  return e;
516 }
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
Definition: expression.c:354

References expression_implied_do_p(), expression_undefined, MakeBinaryCall(), and ParserError().

+ Here is the call graph for this function:

◆ MakeFortranUnaryCall()

expression MakeFortranUnaryCall ( entity  op,
expression  e1 
)
Parameters
opp
e11

Definition at line 519 of file expression.c.

522 {
524 
525  if(expression_implied_do_p(e1)) {
526  ParserError("MakeFortranUnaryCall", "Unexpected implied DO\n");
527  }
528 
529  e = MakeUnaryCall(op, e1);
530 
531  return e;
532 }
expression MakeUnaryCall(entity f, expression a)
Creates a call expression to a function with one argument.
Definition: expression.c:342

References expression_implied_do_p(), expression_undefined, MakeUnaryCall(), and ParserError().

Referenced by gfc2pips_expr2expression(), gfc2pips_int2expression(), and gfc2pips_real2expression().

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

◆ MakeImpliedDo()

expression MakeImpliedDo ( syntax  v,
range  r,
cons l 
)

expressions from input output lists might contain implied do loops.

with our internal representation, implied do loops are stored as calls to a special intrinsic function whose name is IMPLIED_DO_NAME and whose first argument is the range of the loop.

v is a reference to the do variable.

r is the range of the loop.

l is the list of expressions which are to be read or written according to this implied do loop.

the range is enclosed in an expression

Definition at line 115 of file expression.c.

119 {
120  call c;
121  expression er;
122 
123  if (!syntax_reference_p(v))
124  FatalError("MakeImpliedDo", "function call as DO variable\n");
125 
126  if (reference_indices(syntax_reference(v)) != NULL)
127  FatalError("MakeImpliedDo", "variable reference as DO variable\n");
128 
129  /* the range is enclosed in an expression */
132 
134  CONS(EXPRESSION, er, l));
135 
139 }
#define IMPLIED_DO_NAME
Definition: ri-util-local.h:75
@ is_syntax_range
Definition: ri.h:2692
#define reference_indices(x)
Definition: ri.h:2328

References CONS, CreateIntrinsic(), EXPRESSION, FatalError, IMPLIED_DO_NAME, is_syntax_call, is_syntax_range, make_call(), make_expression(), make_syntax(), normalized_undefined, reference_indices, syntax_reference, and syntax_reference_p.

Referenced by loop_to_implieddo().

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

◆ MakeIoList()

cons* MakeIoList ( cons l)

This function takes a list of io elements (i, j, t(i,j)), and returns the same list, with a cons cell pointing to a character constant expression 'IOLIST=' before each element of the original list.

(i , j , t(i,j)) becomes ('IOLIST=' , i , 'IOLIST=' , j , 'IOLIST=' , t(i,j))

This IO list is later concatenated to the IO control list to form the argument of an IO function. The tagging is necessary because of this concatenation.

The IOLIST call used to be shared within one IO list. Since sharing is avoided in the PIPS internal representation, they are now duplicated.

to walk thru l

result list

Definition at line 468 of file expression.c.

470 {
471  cons *pc; /* to walk thru l */
472  cons *lr = NIL; /* result list */
473 
474  pc = l;
475  while (pc != NULL) {
477  cons *p = CONS(EXPRESSION, e, NIL);
478 
479  CDR(p) = pc;
480  pc = CDR(pc);
481  CDR(CDR(p)) = NIL;
482 
483  lr = gen_nconc(p, lr);
484  }
485 
486  return(lr);
487 }
expression MakeCharacterConstantExpression(string s)
END_EOLE.
Definition: constant.c:573
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
#define IO_LIST_STRING_NAME
Definition: ri-util-local.h:82

References CDR, CONS, EXPRESSION, gen_nconc(), IO_LIST_STRING_NAME, MakeCharacterConstantExpression(), and NIL.

+ Here is the call graph for this function:

◆ MakeParameter()

entity MakeParameter ( entity  e,
expression  x 
)

lint

this function creates a PARAMETER, ie a symbolic constant.

e is an entity.

x is an expression that represents the value of e.

Take the integer part of the floating point constant

Definition at line 52 of file expression.c.

53 {
54  type tp;
55 
56  tp = (entity_type(e) != type_undefined) ? entity_type(e) : ImplicitType(e);
60  }
61  else {
63  user_warning("MakeParameter", "Variable %s redefined as parameter\n",
65  ParserError("MakeParameter", "A variable cannot be redefined as a parameter\n");
66  }
67  else {
68  user_warning("MakeParameter", "Symbol %s redefined as parameter\n",
70  ParserError("MakeParameter", "A symbol cannot be redefined as a parameter\n");
71  }
72  }
75  symbolic s = value_symbolic(v);
78  entity_initial(e) = v;
79  else if(constant_float_p(c) && float_type_p(tp))
80  entity_initial(e) = v;
81  else if(constant_float_p(c) && scalar_integer_type_p(tp)) {
82  /* Take the integer part of the floating point constant */
83  double fval = constant_float(c);
84  long long int ival = (long long int) fval;
86  constant_int(c) = ival;
87  entity_initial(e) = v;
88  }
89  else
90  entity_initial(e) = v;
91  }
92  else {
93  user_warning("MakeParameter", "Initial value for variable %s redefined\n",
95  FatalError("MakeParameter", "An initial value cannot be redefined by parameter\n");
96  }
97 
98  return(e);
99 }
functional make_functional(list a1, type a2)
Definition: ri.c:1109
storage make_storage_rom(void)
Definition: ri.c:2285
type make_type(enum type_utype tag, void *val)
Definition: ri.c:2706
void const char const char const int
value MakeValueSymbolic(expression e)
this function creates a value for a symbolic constant.
Definition: constant.c:581
bool scalar_integer_type_p(type)
Definition: type.c:3276
bool float_type_p(type)
Definition: type.c:3263
#define constant_tag(x)
Definition: ri.h:847
#define constant_float_p(x)
Definition: ri.h:851
#define symbolic_constant(x)
Definition: ri.h:2599
#define constant_int(x)
Definition: ri.h:850
@ is_constant_int
Definition: ri.h:817
#define storage_ram_p(x)
Definition: ri.h:2519
#define value_symbolic(x)
Definition: ri.h:3070
#define constant_int_p(x)
Definition: ri.h:848
#define constant_float(x)
Definition: ri.h:853
@ is_type_functional
Definition: ri.h:2901
static char * x
Definition: split_file.c:159

References constant_float, constant_float_p, constant_int, constant_int_p, constant_tag, entity_initial, entity_local_name(), entity_storage, entity_type, FatalError, float_type_p(), ImplicitType(), int, is_constant_int, is_type_functional, make_functional(), make_storage_rom(), make_type(), MakeValueSymbolic(), NIL, ParserError(), scalar_integer_type_p(), storage_ram_p, storage_undefined_p, symbolic_constant, type_undefined, user_warning, value_symbolic, value_undefined_p, value_unknown_p, and x.

Referenced by step_parameter().

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

Variable Documentation

◆ vcid_syntax_expression

char vcid_syntax_expression[] = "$Id: expression.c 23065 2016-03-02 09:05:50Z coelho $"

expression.c

Definition at line 29 of file expression.c.