PIPS
|
#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"
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... | |
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. 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... | |
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.
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.
Make sure that no call to implied do is in l.
Definition at line 492 of file expression.c.
References EXPRESSION, expression_implied_do_p(), MAP, and ParserError().
expression loop_to_implieddo | ( | loop | l | ) |
Fix last parameter
Definition at line 167 of file expression.c.
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().
this used to be a nested function, but compilation on macos dislikes nested functions ...
Definition at line 148 of file expression.c.
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().
name | ame |
bt | t |
size | ize |
Definition at line 597 of file expression.c.
References make_C_or_Fortran_constant_entity(), and ParserError().
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.
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.
indices | ndices |
fc | c |
lc | c |
HasParenthesis | asParenthesis |
Definition at line 222 of file expression.c.
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.
expression MakeFortranBinaryCall | ( | entity | op, |
expression | e1, | ||
expression | e2 | ||
) |
op | p |
e1 | 1 |
e2 | 2 |
Definition at line 502 of file expression.c.
References expression_implied_do_p(), expression_undefined, MakeBinaryCall(), and ParserError().
expression MakeFortranUnaryCall | ( | entity | op, |
expression | e1 | ||
) |
op | p |
e1 | 1 |
Definition at line 519 of file expression.c.
References expression_implied_do_p(), expression_undefined, MakeUnaryCall(), and ParserError().
Referenced by gfc2pips_expr2expression(), gfc2pips_int2expression(), and gfc2pips_real2expression().
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.
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().
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.
References CDR, CONS, EXPRESSION, gen_nconc(), IO_LIST_STRING_NAME, MakeCharacterConstantExpression(), and NIL.
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.
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().
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.