PIPS
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "ri-util.h"
#include "workspace-util.h"
#include "parser_private.h"
#include "properties.h"
#include "misc.h"
#include "syntax.h"
Go to the source code of this file.
Macros | |
#define | IS_UPPER(c) (isascii(c) && isupper(c)) |
Functions | |
int | SafeSizeOfArray (entity a) |
This function should not be used outside of the syntax library because it depends on ParserError(). More... | |
void | InitAreas () |
void | save_all_entities () |
functions for the SAVE declaration More... | |
void | SaveEntity (entity e) |
These two functions transform a dynamic variable into a static one. More... | |
void | MakeVariableStatic (entity v, bool force_it) |
void | ProcessSave (entity v) |
void | save_initialized_variable (entity v) |
void | SaveCommon (entity c) |
this function transforms a dynamic common into a static one. More... | |
void | PrintData (cons *ldvr, cons *ldvl) |
a debugging function, just in case ... More... | |
void | AnalyzeData (list ldvr, list ldvl) |
this function scans at the same time a list of datavar and a list of dataval. More... | |
void | MakeDataStatement (list ldr, list ldv) |
Receives as first input an implicit list of references, including implicit DO, and as second input an list of value using pseudo-intrinsic REPEAT_VALUE() to replicate values. More... | |
void | DeclarePointer (entity ptr, entity pointed_array, list decl_dims) |
static bool | same_basic_and_scalar_p (type t1, type t2) |
type_equal_p -> same_basic_and_scalar_p in latter... More... | |
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 encountered. More... | |
void | DeclareIntrinsic (entity e) |
Intrinsic e is used in the current module. More... | |
bool | fortran_relevant_area_entity_p (entity c) |
These tests are needed to check area consistency when dumping or printing a symbol table. More... | |
void | initialize_common_size_map () |
void | reset_common_size_map () |
void | reset_common_size_map_on_error () |
bool | common_to_defined_size_p (entity a) |
size_t | common_to_size (entity a) |
void | set_common_to_size (entity a, size_t size) |
void | update_common_to_size (entity a, size_t new_size) |
static entity | make_common_entity (entity c) |
updates the common entity if necessary with the common prefix More... | |
entity | MakeCommon (entity e) |
MakeCommon: This function creates a common block. More... | |
entity | NameToCommon (string n) |
void | AddVariableToCommon (entity c, entity v) |
This function adds a variable v to a common block c. More... | |
int | CurrentOffsetOfArea (entity a, entity v) |
void | update_common_sizes (void) |
void | InitImplicit () |
this function initializes the data structure used to compute implicit types More... | |
void | cr_implicit (tag t, int l, int lettre_d, int lettre_f) |
this function updates the data structure used to compute implicit types. More... | |
type | ImplicitType (entity e) |
This function computes the Fortran implicit type of entity e. More... | |
bool | implicit_type_p (entity e) |
This function checks that entity e has an undefined or an implicit type which can be superseded by another declaration. More... | |
void | retype_formal_parameters () |
If an IMPLICIT statement is encountered, it must be applied to the formal parameters, and, if the current module is a function, to the function result type and to the variable used internally when a value is assigned to the function (see MakeCurrentFunction) More... | |
type | MakeFortranType (tag t, value v) |
this function creates a type that represents a fortran type. More... | |
int | OffsetOfReference (reference r) |
This function computes the numerical offset of a variable element from the begining of the variable. More... | |
int | ValueOfIthLowerBound (entity e, int i) |
this function returns the size of the ith lower bound of a variable e. More... | |
int | SizeOfRange (range r) |
This function computes the size of a range, ie. More... | |
int | IsIntegerScalar (entity e) |
FI: should be moved in ri-util; this function returns true if e is a zero dimension variable of basic type integer. More... | |
void | update_user_common_layouts (entity m) |
Check... More... | |
bool | update_common_layout (entity m, entity c) |
(Re)compute offests of all variables allocated in common c from module m and update (if necessary) the size of common c for the whole program or set of modules in the current workspace. More... | |
entity | SafeFindOrCreateEntity (const char *package, const char *name) |
Problem: A functional global entity may be referenced without parenthesis or CALL keyword in a function or subroutine call as functional parameter. More... | |
void | add_entity_to_declarations (string name, string area_name, enum basic_utype tag, void *val) |
FI: I do not understand the naming here, or the parameter. More... | |
Variables | |
static hash_table | common_size_map = hash_table_undefined |
static tag | tag_implicit [26] |
local variables for implicit type implementation More... | |
static size_t | int_implicit [26] |
#define IS_UPPER | ( | c | ) | (isascii(c) && isupper(c)) |
Definition at line 76 of file declaration.c.
void add_entity_to_declarations | ( | string | name, |
string | area_name, | ||
enum basic_utype | tag, | ||
void * | val | ||
) |
FI: I do not understand the naming here, or the parameter.
The name of the new variable must be a global name, whereas the name of the area is a local name. And the area does not have to be the stack area...
Why is this variable called "stack area" when it can be any area?
name | ame |
area_name | rea_name |
val | al |
Definition at line 1969 of file declaration.c.
References AddEntityToDeclarations(), CurrentOffsetOfArea(), discard_module_declaration_text(), entity_initial, entity_storage, entity_type, FindEntity(), FindOrCreateTopLevelEntity(), get_current_module_entity(), make_basic(), make_ram(), make_storage_ram(), make_type_variable(), make_value_unknown(), make_variable(), module_local_name(), module_name(), and NIL.
This function adds a variable v to a common block c.
v's storage must be undefined.
c's size used to be indirectly updated by CurrentOffsetOfArea() but this is meaningless because v's type and dimensions are unknown. The layouts of commons are updated later by update_common_sizes() called from EndOfProcedure().
Definition at line 1108 of file declaration.c.
References area_layout, CONS, DeclareVariable(), ENTITY, entity_blockdata_p(), entity_initial, entity_local_name(), entity_name, entity_storage, entity_type, entity_undefined, FatalError, FindOrCreateEntity(), gen_nconc(), get_current_module_entity(), get_current_module_name(), ImplicitType(), intrinsic_entity_p(), is_storage_ram, line_b_I, line_e_I, make_ram(), make_storage(), module_local_name(), NIL, ParserError(), pips_user_warning, storage_rom_p, storage_tag, storage_undefined, type_area, type_undefined, type_undefined_p, user_warning, value_defined_p(), and value_undefined.
this function scans at the same time a list of datavar and a list of dataval.
it tries to match datavar to dataval and to compute initial values for zero dimension variable of basic type integer.
ldvr is a list of datavar.
ldvl is a list of dataval.
FI: this assertion must be usually wrong! pips_assert("AnalyseData", gen_length(ldvr) == gen_length(ldvl));
Variable is in static area or in a user declared common
Variable must be in a user declared common
Variable must be in static area
entity e initial field is set here with the data information.
if (entity_defined_p(e))
ldvr | dvr |
ldvl | dvl |
Definition at line 352 of file declaration.c.
References CAR, CDR, constant_call_p, constant_int_p, copy_constant(), DATAVAL, dataval_constant, dataval_nboccurrences, DATAVAR, datavar_nbelements, datavar_variable, dynamic_area_p(), entity_blockdata_p(), entity_initial, entity_local_name(), entity_name, entity_scalar_p(), entity_storage, entity_undefined_p, free_value(), gen_length(), get_bool_property(), get_current_module_entity(), is_storage_ram, is_value_constant, make_ram(), make_storage(), make_value(), module_local_name(), NIL, ParserError(), pips_assert, pips_debug, pips_user_warning, ram_section, SaveEntity(), static_area_p(), StaticArea, storage_ram, storage_ram_p, storage_tag, storage_undefined_p, UNKNOWN_RAM_OFFSET, user_warning, value_undefined_p, value_unknown_p, and Warning.
Definition at line 980 of file declaration.c.
References common_size_map, hash_get(), and HASH_UNDEFINED_VALUE.
Referenced by MakeCommon().
Definition at line 990 of file declaration.c.
References common_size_map, entity_name, hash_get(), HASH_UNDEFINED_VALUE, and pips_internal_error.
Referenced by ComputeAddresses(), CurrentOffsetOfArea(), fortran_relevant_area_entity_p(), update_common_layout(), and update_common_sizes().
this function updates the data structure used to compute implicit types.
the implicit type for the range of letters defined by lettre_d and lettre_f has tag t and length l. tag is_basic_string is temporarely forbidden.
lettre_d | ettre_d |
lettre_f | ettre_f |
Definition at line 1284 of file declaration.c.
References FatalError, int_implicit, IS_UPPER, and tag_implicit.
Referenced by InitImplicit().
the local areas are StaticArea, DynamicArea, HeapArea, StackArea
Definition at line 1195 of file declaration.c.
References area_layout, area_size, common_to_size(), CONS, ENTITY, entity_type, gen_nconc(), NIL, SafeSizeOfArray(), top_level_entity_p(), type_area, and update_common_to_size().
Referenced by add_entity_to_declarations(), and gfc2pips_code2instruction__TOP().
void DeclareIntrinsic | ( | entity | e | ) |
Intrinsic e is used in the current module.
Definition at line 918 of file declaration.c.
References AddEntityToDeclarations(), entity_undefined, get_current_module_entity(), intrinsic_entity_p(), and pips_assert.
It is assumed that decl_tableau can be ignored for EDF examples
A varying dimension is impossible in the dynamic area for address computation. A heap area must be added.
dims = decl_dims;
No specific type for SUN pointers
EDF code contains several declaration for a unique pointer
ptr | tr |
pointed_array | ointed_array |
decl_dims | ecl_dims |
Definition at line 546 of file declaration.c.
References basic_int_p, CONS, CreateIntrinsic(), DeclareVariable(), DIMENSION, ENDP, entity_local_name(), entity_type, get_bool_property(), get_current_module_entity(), HeapArea, implicit_type_p(), int_to_expression(), is_basic_int, is_storage_ram, line_b_I, line_e_I, list_undefined, make_dimension(), make_ram(), make_storage(), MakeBasic(), MakeNullaryCall(), MakeTypeVariable(), NIL, ParserError(), pips_user_warning, storage_undefined, type_undefined, type_undefined_p, type_variable, type_variable_p, UNBOUNDED_DIMENSION_NAME, UNKNOWN_RAM_OFFSET, value_undefined, and variable_basic.
void DeclareVariable(e, t, d, s, v): update entity e description as declaration statements are encountered.
Examples of sequences:
INTEGER*4 T DIMENSION T(10) SAVE T
or COMMON /TOTO/X,Y CHARACTER*30 X DIMENSION X(10)
or EXTERNAL F INTEGER F
The input code is assumed correct. As the standard states, IMPLICIT statements must occur before any declaration.
Parameters: e is an entity which should be either a variable or a funtion; it may already have a type et, of kind variable or functional; the type variable may have a dimension; variable or functional implicit types, as well as undefined type, can be superseded by the new type t; a NIL type dimension can be superseded by d; how should area entities be handled ??? t is a type of kind "variable" (functional types are not accepted; functional declaration are handled by ??? ) or undefined; it should have no dimensions; d is a (possibly) empty list of dimensions; the empty list is handled as the undefined list; each dimension is an expression s is the storage, possibly undefined; v is the initial value, possibly undefined
Most problems occur because of the great number of combinations between the entity type et (undefined, variable, functional) and the entity type dimension etd (NIL ot not) giving 7 cases on one hand, the type t and the dimensions d giving 4 cases on the other hand. That is 28 different behaviors.
No sharing is introduced between t and et. However d and s are directly used in e fields.
no new information: do nothing
update functional type
the old type should be gen_freed...
set dimension etd if NIL
set dimension etd if NIL
update type
I: to check update_common_layout
FI: it should be redefined and the offset be updated, maybe in check_common_area(); 1 Feb. 1994
Exception: since it is a synthetic variable, it is unlikely to be typed explicitly. But it can appear in later PIPS regenerated declarations. Unless there is a clash with a user variable.
No problem, but do not free t because this is performed in gram.y
free_type(t);
If the return variable is retyped, the function must be retyped
the pointed area has just been freed!
Meaningless warning when the result variable is declared the first time with the function itself user_warning("DeclareVariable", "Attempt to retype function %s with result of type " "%s with very same type %s\n", module_local_name(f), basic_to_string(old), basic_to_string(new));
Definition at line 670 of file declaration.c.
References AddEntityToDeclarations(), basic_to_string(), basic_type_size(), basic_undefined, copy_basic(), copy_type(), debug(), entity_initial, entity_local_name(), entity_name, entity_storage, entity_type, f(), formal_label_replacement_p(), fprint_functional(), fprintf(), free_type(), functional_result, get_current_module_entity(), ifdebug, implicit_type_p(), ImplicitType(), is_type_area, is_type_functional, is_type_variable, line_b_I, line_e_I, list_undefined, make_value_unknown(), MakeTypeVariable(), module_local_name(), NIL, ParserError(), pips_assert, pips_internal_error, pips_user_warning, same_basic_and_scalar_p(), storage_ram_p, storage_return_p, storage_undefined, storage_undefined_p, type_equal_p(), type_functional, type_functional_p, type_tag, type_undefined, type_undefined_p, type_variable, type_variable_p, user_warning, value_undefined, variable_basic, and variable_dimensions.
Referenced by AddVariableToCommon(), DeclarePointer(), MakeAssignedGotoInst(), MakeAtom(), MakeCurrentFunction(), and SaveEntity().
These tests are needed to check area consistency when dumping or printing a symbol table.
Definition at line 940 of file declaration.c.
References common_size_map, common_to_size(), hash_table_undefined, heap_area_p(), and stack_area_p().
This function checks that entity e has an undefined or an implicit type which can be superseded by another declaration.
The first letter of e's name is used to determine the implicit type. The implicit type of a functional entity is its result type.
ASSERT
to please gcc
Definition at line 1358 of file declaration.c.
References basic_complex, basic_float, basic_int, basic_logical, basic_string, basic_tag, constant_int, entity_local_name(), entity_name, entity_type, FatalError, functional_result, int, int_implicit, is_basic_complex, is_basic_float, is_basic_int, is_basic_logical, is_basic_overloaded, is_basic_string, IS_UPPER, pips_internal_error, tag_implicit, type_functional, type_functional_p, type_tag, type_undefined, type_variable, type_variable_p, value_constant, and variable_basic.
Referenced by DeclarePointer(), DeclareVariable(), retype_formal_parameters(), and TypeFunctionalEntity().
This function computes the Fortran implicit type of entity e.
The first letter of e's name is used.
It should be now called FortranImplicitType()
Definition at line 1311 of file declaration.c.
References entity_local_name(), FatalError, int, int_implicit, is_basic_complex, is_basic_float, is_basic_int, is_basic_logical, is_basic_overloaded, is_basic_string, is_constant_int, IS_UPPER, is_value_constant, make_basic(), make_constant(), make_value(), MakeTypeVariable(), NIL, pips_internal_error, tag_implicit, type_undefined, and value_undefined.
Referenced by AddVariableToCommon(), DeclareVariable(), MakeAtom(), MakeCurrentFunction(), MakeFormalParameter(), MakeParameter(), MakeResultType(), mpi_type_mpi_comm(), mpi_type_mpi_request(), mpi_type_mpi_status(), retype_formal_parameters(), TypeFunctionalEntity(), and UpdateFunctionalType().
void InitAreas | ( | void | ) |
Definition at line 100 of file declaration.c.
References ABSTRACT_LOCATION, AddEntityToDeclarations(), CurrentPackage, DYNAMIC_AREA_LOCAL_NAME, DynamicArea, ENTITY_DYNAMIC_AREA, ENTITY_HEAP_AREA, entity_initial, entity_kind, ENTITY_STACK_AREA, ENTITY_STATIC_AREA, entity_storage, entity_type, FindOrCreateEntity(), get_current_module_entity(), HEAP_AREA_LOCAL_NAME, HeapArea, is_type_area, make_area(), make_storage_rom(), make_type(), make_value_unknown(), NIL, set_common_to_size(), STACK_AREA_LOCAL_NAME, StackArea, STATIC_AREA_LOCAL_NAME, and StaticArea.
Referenced by gfc2pips_namespace(), and MakeCurrentFunction().
void initialize_common_size_map | ( | void | ) |
Definition at line 947 of file declaration.c.
References common_size_map, hash_pointer, hash_table_make(), hash_table_undefined, and pips_assert.
Referenced by gfc2pips_namespace(), and MakeCurrentFunction().
void InitImplicit | ( | void | ) |
this function initializes the data structure used to compute implicit types
Definition at line 1271 of file declaration.c.
References cr_implicit(), DefaultLengthOfBasic(), is_basic_float, and is_basic_int.
Referenced by BeginingOfProcedure().
FI: should be moved in ri-util; this function returns true if e is a zero dimension variable of basic type integer.
Definition at line 1647 of file declaration.c.
References basic_int_p, entity_type, NIL, type_variable, type_variable_p, variable_basic, and variable_dimensions.
updates the common entity if necessary with the common prefix
Definition at line 1018 of file declaration.c.
References AddEntityToDeclarations(), entity_common_p(), entity_initial, entity_storage, entity_type, get_current_module_entity(), is_storage_ram, is_type_area, make_area(), make_code(), make_language_fortran(), make_ram(), make_sequence(), make_storage(), make_type(), make_value_code(), NIL, StaticArea, string_undefined, and type_undefined_p.
Referenced by MakeCommon().
MakeCommon: This function creates a common block.
pips creates static common blocks. This is not true in the ANSI standard stricto sensu, but true in most implementations.
A common declaration can be made out of several common statements. MakeCommon() is called for each common statement, although it only is useful the first time.
common e may already exist because it was encountered in another module but not have been registered as known by the current module. It may also already exist because it was encountered in the same module, but AddEntityToDeclarations() does not duplicate declarations.
FI: for a while, common sizes were always reset to 0, even when several common statements were encountered in the same module for the same common. This did not matter because offsets in commons are recomputed once variable types and dimensions are all known.
Definition at line 1047 of file declaration.c.
References AddEntityToDeclarations(), common_to_defined_size_p(), get_current_module_entity(), make_common_entity(), and set_common_to_size().
Referenced by MakeEntryCommon(), and NameToCommon().
Receives as first input an implicit list of references, including implicit DO, and as second input an list of value using pseudo-intrinsic REPEAT_VALUE() to replicate values.
Generates a call statement to STATIC-INITIALIZATION(), with a call to DATA_LIST to prefix ldr (unlike IO list). Processes the information as AnalyzeData() used to do it. Add the new data call statement to the initializations field of the current module.
ldr | dr |
ldv | dv |
Definition at line 524 of file declaration.c.
References code_initializations, CONS, DATA_LIST_FUNCTION_NAME, entity_code(), entity_undefined, entity_undefined_p, EXPRESSION, expression_undefined, FindEntity(), gen_nconc(), get_current_module_entity(), iPrevComm, make_call_expression(), make_call_statement(), NIL, pips_assert, PrevComm, sequence_statements, STATEMENT, statement_undefined, STATIC_INITIALIZATION_NAME, strdup(), and TOP_LEVEL_MODULE_NAME.
this function creates a type that represents a fortran type.
its basic is an int (the length of the fortran type) except in case of strings where the type might be unknown, as in:
CHARACTER*(*) PF
t is a tag, eg: INTEGER, REAL, ...
v is a value that represents the length in bytes of the type.
Check compatibility between type and byte length
Accept INTEGER*1 for SIMD parallelizer and INTEGER*2 for legacy code and INTEGER*8 for 64 bit machines
Definition at line 1505 of file declaration.c.
References constant_int, DefaultLengthOfBasic(), get_bool_property(), is_basic_complex, is_basic_float, is_basic_int, is_basic_logical, is_basic_overloaded, is_basic_string, is_constant_int, is_value_constant, make_basic(), make_constant(), make_value(), MakeTypeVariable(), NIL, ok, ParserError(), value_constant, and value_undefined.
v may have become static because of a DATA statement (OK) or because of another SAVE (NOK)
Could be the stack or the heap area or any common
force_it | orce_it |
Definition at line 245 of file declaration.c.
References DynamicArea, entity_local_name(), entity_storage, module_local_name(), ParserError(), ram_section, SaveEntity(), StaticArea, storage_ram, storage_ram_p, storage_tag, storage_undefined, and user_warning.
Referenced by ProcessSave(), and save_initialized_variable().
Check for potential conflicts
Definition at line 1071 of file declaration.c.
References BLOCKDATA_PREFIX, COMMON_PREFIX, concatenate(), entity_undefined_p, FindEntity(), FindOrCreateEntity(), free(), MAIN_PREFIX, MakeCommon(), prefixes, strdup(), TOP_LEVEL_MODULE_NAME, and user_warning.
This function computes the numerical offset of a variable element from the begining of the variable.
The variable must have numerical bounds for this function to work. It core dumps for adjustable arrays such as formal parameters.
Use a trick to retrieve the size in bytes of one array element and use the size of the previous dimension
Definition at line 1565 of file declaration.c.
References CAR, CDR, EXPRESSION, ExpressionToInt(), reference_indices, reference_variable, SizeOfIthDimension(), and ValueOfIthLowerBound().
Referenced by MakeEquivAtom().
a debugging function, just in case ...
ldvr | dvr |
ldvl | dvl |
Definition at line 310 of file declaration.c.
References CAR, CDR, constant_int, constant_int_p, DATAVAL, dataval_constant, dataval_nboccurrences, DATAVAR, datavar_nbelements, datavar_variable, debug(), entity_name, and NIL.
void ProcessSave | ( | entity | v | ) |
Definition at line 282 of file declaration.c.
References MakeVariableStatic().
void reset_common_size_map | ( | void | ) |
Problems:
Definition at line 954 of file declaration.c.
References common_size_map, hash_table_free(), hash_table_undefined, and ParserError().
Referenced by EndOfProcedure(), and gfc2pips_namespace().
void reset_common_size_map_on_error | ( | void | ) |
Definition at line 972 of file declaration.c.
References common_size_map, hash_table_free(), and hash_table_undefined.
Referenced by ParserError().
void retype_formal_parameters | ( | void | ) |
If an IMPLICIT statement is encountered, it must be applied to the formal parameters, and, if the current module is a function, to the function result type and to the variable used internally when a value is assigned to the function (see MakeCurrentFunction)
If the current module is a function, its type should be updated.
The function signature is computed later by UpdateFunctionalType() called from EndOfProcedure: there should be no parameters in the type.
Update type of internal variable used to store the function result
nothing to be done: subroutine or main
Definition at line 1411 of file declaration.c.
References code_declarations, ENDP, ENTITY, entity_function_p(), entity_initial, entity_local_name(), entity_storage, entity_type, entity_undefined, FindEntity(), formal_parameter_p(), free_type(), functional_parameters, functional_result, get_current_module_entity(), implicit_type_p(), ImplicitType(), MAP, module_local_name(), pips_assert, pips_debug, pips_internal_error, pips_user_warning, storage_ram_p, storage_rom_p, storage_undefined_p, type_equal_p(), type_functional, type_functional_p, type_tag, type_undefined, type_variable_p, type_void_p, value_code, and variable_entity_p().
entity SafeFindOrCreateEntity | ( | const char * | package, |
const char * | name | ||
) |
Problem: A functional global entity may be referenced without parenthesis or CALL keyword in a function or subroutine call as functional parameter.
FindOrCreateEntity() will return a local variable which already is or will be in the ghost variable list. When ghost variables are eliminated the data structure using this local variable contain a pointer to nowhere.
However, SafeFindOrCreateEntity() does not solve this problem entirely. The call with a functional parameter may occur before a call to this functional parameter lets us find out it is indeed functional.
Morevover, SafeFindOrCreateEntity() does create new problem because intrinsic overloading is ignored. Fortran does not use reserved words and a local variable may have the same name as an intrinsics. The intrinsic entity returned by this function must later be converted into a local variable when it is found out that the user really wanted a local variable, for instance because it appears in a lhs. So intrinsics are not searched anymore.
This is yet another reason to split the building of the internal representation into three phases. The first phase should not assume any default type or storage. Then, type and storage are consolidated together and default type and storage are only used when no information is available. The last phase should be kind of a link edit. The references to really global variables and intrinsics have to be fixed by scanning the intermediate representation.
See also FindOrCreateEntity().
This is a request for a global variable
May be a local or a global entity
This is a request for a local or a global variable. If a local variable with name "name" exists, return it.
No such local variable yet.
Does a global variable with the same name exist and is it in the package's scope?
let s hope concatenate s buffer lasts long enough...
There is no such global variable. Let's make a new local variable
A global entity with the same local name exists.
There is such a global variable and it is in the proper scope
Here comes the mistake if the current_module_entity is not yet defined as is the case when formal parameters are parsed. Intrinsics may wrongly picked out. See capture01.f, variable DIM.
The global variable is not be in the scope.
A local variable must be created. It is later replaced by a global variable if necessary and becomes a ghost variable.
A local variable has been found
le is not a ghost variable
package | ackage |
name | le nom du package le nom de l'entite |
Definition at line 1891 of file declaration.c.
References code_declarations, concatenate(), entity_code(), entity_domain, entity_is_argument_p(), entity_undefined, entity_undefined_p, FindEntity(), full_name, gen_find_tabulated(), get_current_module_entity(), ghost_variable_entity_p(), intrinsic_entity_p(), make_entity, MODULE_SEP_STRING, package, pips_assert, storage_undefined, strdup(), TOP_LEVEL_MODULE_NAME, type_undefined, and value_undefined.
This function should not be used outside of the syntax library because it depends on ParserError().
cproto-generated files
See ri-util/size.c: array_size()
Definition at line 83 of file declaration.c.
References entity_name, ParserError(), pips_user_warning, and SizeOfArray().
Referenced by ComputeAddresses(), CurrentOffsetOfArea(), and update_common_layout().
type_equal_p -> same_basic_and_scalar_p in latter...
FC.
Definition at line 615 of file declaration.c.
References basic_equal_p(), NIL, type_variable, type_variable_p, variable_basic, variable_dimensions, and variable_undefined_p.
Referenced by DeclareVariable().
void save_all_entities | ( | void | ) |
functions for the SAVE declaration
FI: all variables previously allocated should be reallocated
FI: This is pretty crude... Let's hope it works
Definition at line 138 of file declaration.c.
References code_declarations, current_offset_of_area(), DynamicArea, ENTITY, entity_initial, entity_storage, entity_undefined, free_storage(), get_current_module_entity(), is_storage_ram, make_ram(), make_storage(), MAP, NIL, pips_assert, ram_section, StaticArea, storage_ram, storage_ram_p, storage_undefined, and value_code.
void save_initialized_variable | ( | entity | v | ) |
Definition at line 287 of file declaration.c.
References MakeVariableStatic().
void SaveCommon | ( | entity | c | ) |
this function transforms a dynamic common into a static one.
Definition at line 295 of file declaration.c.
References entity_type, pips_assert, type_area_p, and Warning.
void SaveEntity | ( | entity | e | ) |
These two functions transform a dynamic variable into a static one.
They are called to handle SAVE and DATA statements.
Because equivalence chains have not yet been processed, it is not possible to assign an offset or to chain the variable to the static area layout. These two updates are performed by ComputeAddresses() only called by EndOfProcedure() to make sure that all non-declared variables have been taken into account.
Let's hope functions and subroutines called are listed in the declaration list.
This cannot be done before the equivalences have been processed
Not much can be said. Maybe it is redundant, but...
Maybe the standard claims that you are not allowed to save a common variable?
The type and dimensions are still unknown
Definition at line 178 of file declaration.c.
References code_declarations, DeclareVariable(), DynamicArea, entity_initial, entity_is_argument_p(), entity_local_name(), entity_name, entity_storage, entity_type, entity_undefined_p, get_current_module_entity(), is_storage_ram, local_name_to_top_level_entity(), make_ram(), make_storage(), NIL, ParserError(), ram_offset, ram_section, StaticArea, storage_ram, storage_ram_p, storage_tag, storage_undefined, type_undefined, UNKNOWN_RAM_OFFSET, user_warning, value_code, and value_undefined.
Referenced by AnalyzeData(), fix_storage(), and MakeVariableStatic().
size | ize |
Definition at line 1004 of file declaration.c.
References common_size_map, and hash_put().
Referenced by gfc2pips_computeAdressesOfArea(), gfc2pips_namespace(), InitAreas(), and MakeCommon().
This function computes the size of a range, ie.
the number of iterations that would be done by a loop with this range.
See also range_count().
Definition at line 1619 of file declaration.c.
References ExpressionToInt(), FatalError, range_increment, range_lower, and range_upper.
(Re)compute offests of all variables allocated in common c from module m and update (if necessary) the size of common c for the whole program or set of modules in the current workspace.
As a consequence, warning messages unfortunately depend on the parsing order.
Offsets used to be computed a first time when the common declaration is encountered, but the variables may be typed or dimensionned later.
This function is correct only if no equivalenced variables have been added to the layout. It should not be used for the static and dynamic areas (see below).
It is assumed that:
the layout field does not seem to be filled in for STATIC and DYNAMIC
skip variables which do not belong to the module of interest
This should now always be the case. The offset within the common is no longer computed on the fly.
If c really is a common, check its size because it may have increased. Note that decreases are not taken into account although they might occur as well.
Too late, if the common only contains one element because the MAPL has not been entered at all if we are dealing wih te last parsed module... which is always the case up to now!
Variables declared in the static and dynamic areas were assigned offsets dynamically. The result may be ok.
Special case: only one element in the common for the current procedure (and the current procedure is last one declared - which is not so special)
If c really is a common, check its size because it may have increased. Note that decreases are not taken into account although they might occur as well.
Definition at line 1746 of file declaration.c.
References area_layout, bool_to_string(), CAR, common_to_size(), current, debug(), ENDP, ENTITY, entity_special_area_p(), entity_storage, entity_type, entity_undefined, ifdebug, list_undefined, module_local_name(), pips_assert, POP, print_arguments(), ram_offset, SafeSizeOfArray(), storage_ram, storage_ram_p, top_level_entity_p(), type_area, update_common_to_size(), and variable_in_module_p().
Referenced by update_user_common_layouts().
void update_common_sizes | ( | void | ) |
I'm afraid this warning might be printed because area_size is given a wrong value by CurrentOffsetOfArea().
Definition at line 1215 of file declaration.c.
References area_size, arguments_add_entity(), common_size_map, common_to_size(), CurrentPackage, debug(), ENTITY, entity_name, entity_type, FOREACH, gen_free_list(), HASH_MAP, HASH_UNDEFINED_VALUE, intptr_t, module_local_name(), NIL, pips_assert, pips_debug, sort_list_of_entities(), tc, type_area, and user_warning.
Referenced by EndOfProcedure().
new_size | ew_size |
Definition at line 1010 of file declaration.c.
References common_size_map, and hash_update().
Referenced by ComputeAddresses(), CurrentOffsetOfArea(), and update_common_layout().
void update_user_common_layouts | ( | entity | m | ) |
Check...
and fix, if needed!
Only user COMMONs are checked. The two implicit areas, DynamicArea and StaticArea, have not been initialized yet (see ComputeAddress() and the calls in EndOfProcedure()).
List of implicitly and explicitly declared variables, functions and areas
Structure of each area/common
User declarations of commons imply the offset and cannot conflict with equivalences, whereas static and dynamic variables must first comply with equivalences. Hence the layouts of user commons must be updated before equivalences are satisfied whereas layouts of the static and dynamic areas must be satisfied after the equiavelences have been processed.
Definition at line 1670 of file declaration.c.
References code_declarations, ENDP, ENTITY, entity_initial, entity_module_p(), entity_name, entity_special_area_p(), entity_type, fprintf(), gen_append(), gen_free_list(), ifdebug, MAP, module_local_name(), NIL, pips_assert, pips_debug, print_common_layout(), sort_list_of_entities(), type_area_p, update_common_layout(), and value_code.
Referenced by EndOfProcedure().
this function returns the size of the ith lower bound of a variable e.
Definition at line 1591 of file declaration.c.
References CAR, CDR, DIMENSION, dimension_lower, entity_type, ExpressionToInt(), ParserError(), pips_assert, type_variable, type_variable_p, and variable_dimensions.
Referenced by OffsetOfReference().
|
static |
Definition at line 935 of file declaration.c.
Referenced by common_to_defined_size_p(), common_to_size(), fortran_relevant_area_entity_p(), initialize_common_size_map(), reset_common_size_map(), reset_common_size_map_on_error(), set_common_to_size(), update_common_sizes(), and update_common_to_size().
|
static |
Definition at line 1265 of file declaration.c.
Referenced by cr_implicit(), implicit_type_p(), and ImplicitType().
|
static |
local variables for implicit type implementation
Definition at line 1264 of file declaration.c.
Referenced by cr_implicit(), implicit_type_p(), and ImplicitType().