PIPS
gfc2pips.c File Reference
#include "gfc2pips-private.h"
#include "c_parser_private.h"
#include "misc.h"
#include "text-util.h"
#include "ri-util.h"
#include <stdio.h>
#include <string.h>
+ Include dependency graph for gfc2pips.c:

Go to the source code of this file.

Typedefs

typedef loop pips_loop
 

Functions

char * strdup (const char *)
 EXPR_STRUCTURE, EXPR_SUBSTRING, EXPR_NULL, EXPR_ARRAY are not dumped. More...
 
void gfc2pips_namespace (gfc_namespace *ns)
 Entry point for gfc2pips translation This will be called each time the parser encounter subroutine, function, or program. More...
 
gfc2pips_main_entity_type get_symbol_token (gfc_symbol *root_sym)
 
list gfc2pips_parameters (gfc_namespace *ns, gfc2pips_main_entity_type bloc_token)
 
list gfc2pips_args (gfc_namespace *ns)
 Retrieve the list of names of every argument of the function, if any. More...
 
void gfc2pips_generate_parameters_list (list parameters)
 replace a list of entities by a list of parameters to those entities More...
 
 __attribute__ ((warn_unused_result))
 Look for a specific symbol in a tree Check current entry first, then recurse left then right. More...
 
list gfc2pips_vars (gfc_namespace *ns)
 Extract every and each variable from a namespace. More...
 
list gfc2pips_vars_ (gfc_namespace *ns, list variables_p)
 Convert the list of gfc symbols into a list of pips entities with storage, type, everything. More...
 
void gfc2pips_getTypesDeclared (gfc_namespace *ns)
 
list gfc2pips_get_extern_entities (gfc_namespace *ns)
 build a list of externals entities More...
 
list gfc2pips_get_data_vars (gfc_namespace *ns)
 return a list of elements needing a DATA statement More...
 
list gfc2pips_get_save (gfc_namespace *ns)
 return a list of SAVE elements More...
 
list gfc2pips_get_list_of_dimensions (gfc_symtree *st)
 build a list - if any - of dimension elements from the gfc_symtree given More...
 
list gfc2pips_get_list_of_dimensions2 (gfc_symbol *s)
 build a list - if any - of dimension elements from the gfc_symbol given More...
 
list getSymbolBy (gfc_namespace *ns, gfc_symtree *st, bool(*func)(gfc_namespace *, gfc_symtree *))
 Look for a set of symbols filtered by a predicate function. More...
 
bool gfc2pips_test_variable (gfc_namespace __attribute__((__unused__)) *ns, gfc_symtree *st)
 get variables who are not implicit or are needed to be declared for data statements hence variable that should be explicit in PIPS More...
 
bool gfc2pips_test_variable2 (gfc_namespace __attribute__((__unused__)) *ns, gfc_symtree *st)
 
bool gfc2pips_test_derived (gfc_namespace __attribute__((__unused__)) *ns, gfc_symtree *st)
 
bool gfc2pips_test_extern (gfc_namespace __attribute__((__unused__)) *ns, gfc_symtree *st)
 test if it is an external function More...
 
bool gfc2pips_test_subroutine (gfc_namespace __attribute__((__unused__)) *ns, gfc_symtree *st)
 
bool gfc2pips_test_allocatable (gfc_namespace __attribute__((__unused__)) *ns, gfc_symtree *st)
 test if it is a allocatable entity More...
 
bool gfc2pips_test_arg (gfc_namespace __attribute__((__unused__)) *ns, gfc_symtree *st)
 test if it is a dummy parameter (formal parameter) More...
 
bool gfc2pips_test_data (gfc_namespace __attribute__((__unused__)) *ns, gfc_symtree *st)
 test if there is a value to stock More...
 
bool gfc2pips_test_save (gfc_namespace __attribute__((__unused__)) *ns, gfc_symtree *st)
 test if there is a SAVE to do More...
 
bool gfc2pips_get_commons (gfc_namespace __attribute__((__unused__)) *ns, gfc_symtree __attribute__((__unused__)) *st)
 test function to know if it is a common, always true because the tree is completely separated therefore the function using it only create a list More...
 
bool gfc2pips_get_incommon (gfc_namespace __attribute__((__unused__)) *ns, gfc_symtree __attribute__((__unused__)) *st)
 
bool gfc2pips_test_dimensions (gfc_namespace __attribute__((__unused__)) *ns, gfc_symtree *st)
 
entity gfc2pips_check_entity_doesnt_exists (char *s)
 
entity gfc2pips_check_entity_program_exists (char *s)
 
entity gfc2pips_check_entity_module_exists (char *s)
 
entity gfc2pips_check_entity_block_data_exists (char *s)
 
entity gfc2pips_check_entity_exists (const char *s)
 
entity gfc2pips_symbol2entity (gfc_symbol *s)
 translate a gfc symbol to a PIPS entity, check if it is a function, program, subroutine or else More...
 
entity gfc2pips_symbol2top_entity (gfc_symbol *s)
 translate a gfc symbol to a top-level entity More...
 
entity gfc2pips_char2entity (char *package, char *s)
 a little bit more elaborated FindOrCreateEntity More...
 
char * gfc2pips_get_safe_name (const char *str)
 gfc replace some functions by an homemade one, we check and return a copy of the original one if it is the case More...
 
dimension gfc2pips_int2dimension (int n)
 create a <dimension> from the integer value given More...
 
expression gfc2pips_int2expression (int n)
 translate a int to an expression More...
 
expression gfc2pips_real2expression (double r)
 translate a real to an expression More...
 
expression gfc2pips_logical2expression (bool b)
 translate a bool to an expression More...
 
entity gfc2pips_int_const2entity (int n)
 translate an integer to a PIPS constant, assume n is positive (or it will not be handled properly) More...
 
entity gfc2pips_int2label (int n)
 dump an integer to a PIPS label entity More...
 
entity gfc2pips_real2entity (double r)
 dump reals to PIPS entities More...
 
entity gfc2pips_logical2entity (bool b)
 translate a boolean to a PIPS/fortran entity More...
 
char * gfc2pips_gfc_char_t2string (gfc_char_t *c, int length)
 translate a string from a table of integers in gfc to one of chars in PIPS, escape all ' in the string More...
 
char * gfc2pips_gfc_char_t2string_ (gfc_char_t *c, int nb)
 translate a string from a table of integers in gfc to one of chars in PIPS, escape all ' in the string More...
 
char * gfc2pips_gfc_char_t2string2 (gfc_char_t *c)
 translate the <nb> first elements of from a wide integer representation to a char representation More...
 
basic gfc2pips_getbasic (gfc_symbol *s)
 
type gfc2pips_symbol2type (gfc_symbol *s)
 try to create the PIPS type that would be associated by the PIPS default parser More...
 
type gfc2pips_symbol2specialType (gfc_symbol *s)
 
int gfc2pips_symbol2size (gfc_symbol *s)
 return the size of an elementary element: REAL*16 A CHARACTER*17 B More...
 
int gfc2pips_symbol2sizeArray (gfc_symbol *s)
 calculate the total size of the array whatever the bounds are: A(-5,5) More...
 
list gfc2pips_array_ref2indices (gfc_array_ref *ar)
 convert a list of indices from gfc to PIPS, assume there is no range (dump only the min range element) More...
 
instruction gfc2pips_code2instruction__TOP (gfc_namespace *ns, gfc_code *c)
 Declaration of instructions. More...
 
instruction gfc2pips_code2instruction (gfc_code *c, bool force_sequence)
 Build an instruction sequence. More...
 
instruction gfc2pips_code2instruction_ (gfc_code *c)
 this function create an atomic statement, no block of data More...
 
expression gfc2pips_buildCaseTest (gfc_expr *test, gfc_case *cp)
 
list gfc2pips_dumpSELECT (gfc_code *c)
 
instruction gfc2pips_symbol2data_instruction (gfc_symbol *sym)
 build a DATA statement, filling blanks with zeroes. More...
 
expression gfc2pips_make_zero_for_symbol (gfc_symbol *sym)
 
list gfc2pips_reduce_repeated_values (list l)
 look for repeated values (integers or real) in the list (list for DATA instructions) and transform them in a FORTRAN repeat syntax More...
 
entity gfc2pips_code2get_label (gfc_code *c)
 
entity gfc2pips_code2get_label2 (gfc_code *c)
 
entity gfc2pips_code2get_label3 (gfc_code *c)
 
entity gfc2pips_code2get_label4 (gfc_code *c)
 
expression gfc2pips_expr2expression (gfc_expr *expr)
 
int gfc2pips_expr2int (gfc_expr *expr)
 
bool gfc2pips_exprIsVariable (gfc_expr *expr)
 
entity gfc2pips_expr2entity (gfc_expr *expr)
 create an entity based on an expression, assume it is used only for incremented variables in loops More...
 
list gfc2pips_arglist2arglist (gfc_actual_arglist *act)
 
list gfc2pips_exprIO (char *s, gfc_expr *e, list l)
 
list gfc2pips_exprIO2 (char *s, int e, list l)
 
list gfc2pips_exprIO3 (char *s, string e, list l)
 
void gfc2pips_computeAdresses (void)
 compute addresses of the stack, heap, dynamic and static areas More...
 
void gfc2pips_computeAdressesStatic (void)
 compute the addresses of the entities declared in StaticArea More...
 
void gfc2pips_computeAdressesDynamic (void)
 compute the addresses of the entities declared in DynamicArea More...
 
void gfc2pips_computeAdressesHeap (void)
 compute the addresses of the entities declared in StaticArea More...
 
int gfc2pips_computeAdressesOfArea (entity _area)
 compute the addresses of the entities declared in the given entity More...
 
void gfc2pips_computeEquiv (gfc_equiv *eq)
 
void gfc2pips_shiftAdressesOfArea (entity _area, int old_offset, int size, int max_offset, int shift)
 

Variables

gfc_option_t gfc_option
 Cmd line options. More...
 
statement gfc_function_body
 
const char * CurrentPackage
 the name of the current package, i.e. More...
 
int global_current_offset = 0
 
list gfc2pips_format = NULL
 
list gfc2pips_format2 = NULL
 
static int gfc2pips_last_created_label = 95000
 
static int gfc2pips_last_created_label_step = 2
 
entity gfc2pips_main_entity = entity_undefined
 
bool gfc2pips_last_statement_is_loop = false
 

Typedef Documentation

◆ pips_loop

typedef loop pips_loop

Definition at line 90 of file gfc2pips.c.

Function Documentation

◆ __attribute__()

__attribute__ ( (warn_unused_result)  )

Look for a specific symbol in a tree Check current entry first, then recurse left then right.

Parameters
name: the string containing the target symbol name
st: the current element of the tree beeing processed
Returns
: the tree element if found, else NULL

Definition at line 920 of file gfc2pips.c.

921  {
922  gfc_symtree *return_value = NULL;
923  if(!name)
924  return NULL;
925 
926  if(!st)
927  return NULL;
928  if(!st->n.sym)
929  return NULL;
930  if(!st->name)
931  return NULL;
932 
933  //much much more information, BUT useless (cause recursive)
934  gfc2pips_debug(10, "Looking for the symtree called: %s(%zu) %s(%zu)\n",
935  name, strlen(name), st->name, strlen(st->name) );
936 
937  // FIXME : case insentitive ????
938  if(strcmp_(st->name, name) == 0) {
939  //much much more information, BUT useless (cause recursive)
940  gfc2pips_debug(9, "symbol %s founded\n",name);
941  return st;
942  }
943  return_value = gfc2pips_getSymtreeByName(name, st->left);
944 
945  if(return_value == NULL) {
946  return_value = gfc2pips_getSymtreeByName(name, st->right);
947  }
948  return return_value;
949 }
int strcmp_(__const char *__s1, __const char *__s2)
compare the strings in upper case mode
gfc_symtree * gfc2pips_getSymtreeByName(const char *name, gfc_symtree *st)
#define gfc2pips_debug

References gfc2pips_debug, gfc2pips_getSymtreeByName(), and strcmp_().

+ Here is the call graph for this function:

◆ get_symbol_token()

gfc2pips_main_entity_type get_symbol_token ( gfc_symbol *  root_sym)

Definition at line 772 of file gfc2pips.c.

772  {
773  gfc2pips_main_entity_type bloc_token;
774  if(root_sym->attr.is_main_program) {
775  bloc_token = MET_PROG;
776  } else if(root_sym->attr.subroutine) {
777  bloc_token = MET_SUB;
778  } else if(root_sym->attr.function) {
779  bloc_token = MET_FUNC;
780  } else if(root_sym->attr.flavor == FL_BLOCK_DATA) {
781  bloc_token = MET_BLOCK;
782  } else if(root_sym->attr.flavor == FL_MODULE) {
783  bloc_token = MET_MODULE;
784  } else {
785  if(root_sym->attr.procedure) {
786  fprintf(stderr, "procedure\n");
787  }
788  pips_user_error("Unknown token !");
789  }
790  return bloc_token;
791 }
gfc2pips_main_entity_type
@ MET_PROG
@ MET_FUNC
@ MET_MODULE
@ MET_SUB
@ MET_BLOCK
#define pips_user_error
Definition: misc-local.h:147
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...

References fprintf(), MET_BLOCK, MET_FUNC, MET_MODULE, MET_PROG, MET_SUB, and pips_user_error.

Referenced by gfc2pips_namespace().

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

◆ getSymbolBy()

list getSymbolBy ( gfc_namespace *  ns,
gfc_symtree *  st,
bool(*)(gfc_namespace *, gfc_symtree *)  func 
)

Look for a set of symbols filtered by a predicate function.

Definition at line 1344 of file gfc2pips.c.

1346  {
1347  list args_list = NULL;
1348 
1349  if(!ns)
1350  return NULL;
1351  if(!st)
1352  return NULL;
1353  if(!func)
1354  return NULL;
1355 
1356  if(func(ns, st)) {
1357  args_list = gen_cons(st, args_list);
1358  }
1359  args_list = gen_nconc(args_list, getSymbolBy(ns, st->left, func));
1360  args_list = gen_nconc(args_list, getSymbolBy(ns, st->right, func));
1361 
1362  return args_list;
1363 }
list getSymbolBy(gfc_namespace *ns, gfc_symtree *st, bool(*func)(gfc_namespace *, gfc_symtree *))
Look for a set of symbols filtered by a predicate function.
Definition: gfc2pips.c:1344
list gen_cons(const void *item, const list next)
Definition: list.c:888
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References gen_cons(), gen_nconc(), and getSymbolBy().

Referenced by getSymbolBy(), gfc2pips_get_data_vars(), gfc2pips_get_extern_entities(), gfc2pips_get_save(), gfc2pips_getTypesDeclared(), gfc2pips_namespace(), and gfc2pips_vars().

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

◆ gfc2pips_arglist2arglist()

list gfc2pips_arglist2arglist ( gfc_actual_arglist *  act)

Definition at line 4287 of file gfc2pips.c.

4287  {
4288  list list_of_arguments = NULL, list_of_arguments_p = NULL;
4289  while(act) {
4290  expression ex = gfc2pips_expr2expression(act->expr);
4291 
4292  if(ex != expression_undefined) {
4293 
4294  if(list_of_arguments_p) {
4295  CDR( list_of_arguments_p) = CONS( EXPRESSION, ex, NIL );
4296  list_of_arguments_p = CDR( list_of_arguments_p );
4297  } else {
4298  list_of_arguments_p = CONS( EXPRESSION, ex, NIL );
4299  }
4300  }
4301  if(list_of_arguments == NULL)
4302  list_of_arguments = list_of_arguments_p;
4303 
4304  act = act->next;
4305  }
4306  return list_of_arguments;
4307 }
expression gfc2pips_expr2expression(gfc_expr *expr)
Definition: gfc2pips.c:3837
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define expression_undefined
Definition: ri.h:1223

References CDR, CONS, EXPRESSION, expression_undefined, gfc2pips_expr2expression(), and NIL.

Referenced by gfc2pips_code2instruction_().

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

◆ gfc2pips_args()

list gfc2pips_args ( gfc_namespace *  ns)

Retrieve the list of names of every argument of the function, if any.

Since alternate returns are obsoletes in F90 we do not dump them, still there is a start of dump (but crash if some properties are not activated)

Definition at line 847 of file gfc2pips.c.

847  {
848  gfc_symtree * current = NULL;
849  gfc_formal_arglist *formal;
850  list args_list = NULL, args_list_p = NULL;
853 
854  if(ns && ns->proc_name) {
855 
856  current = gfc2pips_getSymtreeByName(ns->proc_name->name, ns->sym_root);
857  if(current && current->n.sym) {
858  if(current->n.sym->formal) {
859  //we have a pb with alternate returns
860  formal = current->n.sym->formal;
861  if(formal) {
862  if(formal->sym) {
863  gfc_symtree* sym = gfc2pips_getSymtreeByName(formal->sym->name,
864  ns->sym_root);
865  e = gfc2pips_symbol2entity(sym->n.sym);
866  } else {
867  //alternate returns are obsolete in F90 (and since we only want it)
868  return NULL;
869  }
870  args_list = args_list_p = CONS( ENTITY, e, NULL );
871 
872  formal = formal->next;
873  while(formal) {
874  gfc2pips_debug(9,"alt return %s\n", formal->sym?"no":"yes");
875  if(formal->sym) {
876  gfc_symtree* sym = gfc2pips_getSymtreeByName(formal->sym->name,
877  ns->sym_root);
878  e = gfc2pips_symbol2entity(sym->n.sym);
879  CDR( args_list) = CONS( ENTITY, e, NULL );
880  args_list = CDR( args_list );
881  } else {
882  return args_list_p;
883  }
884  formal = formal->next;
885  }
886  }
887  }
888  }
889  }
890  return args_list_p;
891 }
entity gfc2pips_symbol2entity(gfc_symbol *s)
translate a gfc symbol to a PIPS entity, check if it is a function, program, subroutine or else
Definition: gfc2pips.c:1582
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define entity_undefined
Definition: ri.h:2761
struct _newgen_struct_formal_ * formal
Definition: ri.h:191
static size_t current
Definition: string.c:115
void set_current_number_of_alternate_returns()
Definition: return.c:187

References CDR, CONS, current, ENTITY, entity_undefined, gfc2pips_debug, gfc2pips_getSymtreeByName(), gfc2pips_symbol2entity(), and set_current_number_of_alternate_returns().

Referenced by f95split(), and gfc2pips_parameters().

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

◆ gfc2pips_array_ref2indices()

list gfc2pips_array_ref2indices ( gfc_array_ref *  ar)

convert a list of indices from gfc to PIPS, assume there is no range (dump only the min range element)

Parameters
arthe struct with indices only for AR_ARRAY references

There are two types of array sections: either the elements are identified by an integer array ('vector'), or by an index range. In the former case we only have to get the start expression which contains the vector, in the latter case we have to print any of lower and upper bound and the stride, if they're present.

Get lower bound

Get upper bound

Definition at line 2032 of file gfc2pips.c.

2032  {
2033  int i;
2034  list indices = NULL;
2035 
2036  switch(ar->type) {
2037  case AR_FULL:
2038  break;
2039  case AR_SECTION:
2040  for (i = 0; i < ar->dimen; i++) {
2041  /* There are two types of array sections: either the
2042  elements are identified by an integer array ('vector'),
2043  or by an index range. In the former case we only have to
2044  get the start expression which contains the vector, in
2045  the latter case we have to print any of lower and upper
2046  bound and the stride, if they're present. */
2047 
2048  if(ar->dimen_type[i] == DIMEN_RANGE) {
2049  expression start, end, stride;
2050 
2051  /* Get lower bound */
2052  if(ar->start[i]) {
2053  start = gfc2pips_expr2expression(ar->start[i]);
2054  } else {
2056  }
2057 
2058  /* Get upper bound */
2059  if(ar->end[i]) {
2060  end = gfc2pips_expr2expression(ar->end[i]);
2061  } else {
2063  }
2064 
2065  if(ar->stride[i]) {
2066  stride = gfc2pips_expr2expression(ar->stride[i]);
2067  } else {
2068  stride = int_to_expression(1);
2069  }
2070 
2071  range r = make_range(start, end, stride);
2074  indices = CONS( EXPRESSION,indice,indices);
2075  } else {
2076  indices = CONS( EXPRESSION,
2077  gfc2pips_expr2expression( ar->start[i] ),
2078  indices);
2079  }
2080 
2081  }
2083  break;
2084 
2085  case AR_ELEMENT:
2086  for (i = 0; i < ar->dimen; i++) {
2087  if(ar->start[i]) {
2088  indices = CONS( EXPRESSION,
2089  gfc2pips_expr2expression( ar->start[i] ),
2090  indices);
2091  }
2092  }
2094  break;
2095 
2096  case AR_UNKNOWN:
2097  pips_user_warning("Ref unknown ?");
2098  break;
2099 
2100  default:
2101  pips_internal_error ("Unknown array reference");
2102  }
2103  gfc2pips_debug(9,"%zu indice(s)\n", gen_length(indices) );
2104  return indices;
2105 }
expression make_expression(syntax a1, normalized a2)
Definition: ri.c:886
syntax make_syntax(enum syntax_utype tag, void *val)
Definition: ri.c:2491
range make_range(expression a1, expression a2, expression a3)
Definition: ri.c:2041
static char start[1024]
The name of the variable from which to start counting domain numbers.
Definition: genLisp.c:55
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
size_t gen_length(const list l)
Definition: list.c:150
char end
Definition: gtk_status.c:82
static list indices
Definition: icm.c:204
#define pips_user_warning
Definition: misc-local.h:146
#define pips_internal_error
Definition: misc-local.h:149
#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
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
#define normalized_undefined
Definition: ri.h:1745
@ is_syntax_range
Definition: ri.h:2692

References CONS, CreateIntrinsic(), end, EXPRESSION, gen_length(), gen_nreverse(), gfc2pips_debug, gfc2pips_expr2expression(), indices, int_to_expression(), is_syntax_range, make_expression(), make_range(), make_syntax(), MakeNullaryCall(), normalized_undefined, pips_internal_error, pips_user_warning, start, and UNBOUNDED_DIMENSION_NAME.

Referenced by gfc2pips_expr2expression().

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

◆ gfc2pips_buildCaseTest()

expression gfc2pips_buildCaseTest ( gfc_expr *  test,
gfc_case *  cp 
)

Definition at line 3364 of file gfc2pips.c.

3364  {
3365  expression range_expr = expression_undefined;
3366  expression tested_variable = gfc2pips_expr2expression(test);
3367  pips_assert("CASE expr require at least an high OR a low bound !",
3368  cp->low||cp->high);
3369  if(cp->low == cp->high) {
3370  // Exact bound
3372  tested_variable,
3374  } else {
3375  expression low = NULL, high = NULL;
3376  if(cp->low) {
3378  tested_variable,
3380  }
3381  if(cp->high) {
3383  tested_variable,
3384  gfc2pips_expr2expression(cp->high));
3385  }
3386 
3387  if(low && !high) {
3388  range_expr = low;
3389  } else if(!low && high) {
3390  range_expr = high;
3391  } else {
3392  range_expr
3394  }
3395  }
3396  return range_expr;
3397 }
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define EQUAL_OPERATOR_NAME
#define AND_OPERATOR_NAME
FI: intrinsics are defined at a third place after bootstrap and effects! I guess the name should be d...
#define GREATER_OR_EQUAL_OPERATOR_NAME
#define LESS_OR_EQUAL_OPERATOR_NAME
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
Definition: expression.c:354
Pvecteur cp
pointeur sur l'egalite ou l'inegalite courante
Definition: sc_read.c:87

References AND_OPERATOR_NAME, cp, CreateIntrinsic(), EQUAL_OPERATOR_NAME, expression_undefined, gfc2pips_expr2expression(), GREATER_OR_EQUAL_OPERATOR_NAME, LESS_OR_EQUAL_OPERATOR_NAME, MakeBinaryCall(), and pips_assert.

Referenced by gfc2pips_dumpSELECT().

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

◆ gfc2pips_char2entity()

entity gfc2pips_char2entity ( char *  package,
char *  s 
)

a little bit more elaborated FindOrCreateEntity

Definition at line 1705 of file gfc2pips.c.

1705  {
1706  s = gfc2pips_get_safe_name(s);
1710  if(entity_type(e) == type_undefined)
1712  free(s);
1713  return e;
1714 }
value make_value_unknown(void)
Definition: ri.c:2847
type make_type_unknown(void)
Definition: ri.c:2724
static char * package
The package name in which functions will be defined.
Definition: genLisp.c:59
void free(void *)
char * str2upper(char s[])
put the given char table to upper case
Definition: gfc2pips-util.c:83
char * gfc2pips_get_safe_name(const char *str)
gfc replace some functions by an homemade one, we check and return a copy of the original one if it i...
Definition: gfc2pips.c:1720
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
#define value_undefined
Definition: ri.h:3016
#define type_undefined
Definition: ri.h:2883
#define entity_type(x)
Definition: ri.h:2792
#define entity_initial(x)
Definition: ri.h:2796

References entity_initial, entity_type, FindOrCreateEntity(), free(), gfc2pips_get_safe_name(), make_type_unknown(), make_value_unknown(), package, str2upper(), type_undefined, and value_undefined.

+ Here is the call graph for this function:

◆ gfc2pips_check_entity_block_data_exists()

entity gfc2pips_check_entity_block_data_exists ( char *  s)

Definition at line 1558 of file gfc2pips.c.

1558  {
1559  string full_name;
1563  str2upper(strdup(s)),
1564  NULL);
1566 }
char * strdup(const char *)
EXPR_STRUCTURE, EXPR_SUBSTRING, EXPR_NULL, EXPR_ARRAY are not dumped.
#define full_name(dir, name)
Definition: compile.c:414
#define TOP_LEVEL_MODULE_NAME
Module containing the global variables in Fortran and C.
Definition: naming-local.h:101
#define BLOCKDATA_PREFIX
Definition: naming-local.h:35
#define MODULE_SEP_STRING
Definition: naming-local.h:30
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410

References BLOCKDATA_PREFIX, concatenate(), entity_domain, full_name, gen_find_tabulated(), MODULE_SEP_STRING, str2upper(), strdup(), and TOP_LEVEL_MODULE_NAME.

Referenced by gfc2pips_symbol2entity().

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

◆ gfc2pips_check_entity_doesnt_exists()

entity gfc2pips_check_entity_doesnt_exists ( char *  s)

Definition at line 1497 of file gfc2pips.c.

1497  {
1499  string full_name;
1500  //main program
1503  MAIN_PREFIX,
1504  str2upper(strdup(s)),
1505  NULL);
1507 
1508  //module
1509  if(e == entity_undefined) {
1512  str2upper(strdup(s)),
1513  NULL);
1515  }
1516 
1517  //simple entity
1518  if(e == entity_undefined) {
1521  str2upper(strdup(s)),
1522  NULL);
1524  }
1525  return e;
1526 }
const char * CurrentPackage
the name of the current package, i.e.
Definition: gfc2pips.c:96
#define MAIN_PREFIX
Definition: naming-local.h:32

References concatenate(), CurrentPackage, entity_domain, entity_undefined, full_name, gen_find_tabulated(), MAIN_PREFIX, MODULE_SEP_STRING, str2upper(), strdup(), and TOP_LEVEL_MODULE_NAME.

Referenced by gfc2pips_symbol2top_entity().

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

◆ gfc2pips_check_entity_exists()

entity gfc2pips_check_entity_exists ( const char *  s)

Definition at line 1567 of file gfc2pips.c.

1567  {
1568  string full_name;
1569  //simple entity
1572  str2upper(strdup(s)),
1573  NULL);
1575 }

References concatenate(), CurrentPackage, entity_domain, full_name, gen_find_tabulated(), MODULE_SEP_STRING, str2upper(), and strdup().

Referenced by gfc2pips_computeEquiv().

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

◆ gfc2pips_check_entity_module_exists()

entity gfc2pips_check_entity_module_exists ( char *  s)

Definition at line 1537 of file gfc2pips.c.

1537  {
1538  string full_name;
1539  //module
1542  str2upper(strdup(s)),
1543  NULL);
1544 
1546 
1547  ifdebug(5) {
1548  if(e==entity_undefined) {
1549  pips_debug(5,"'%s' doesn't exist.\n",full_name);
1550  } else {
1551  pips_debug(5,"'%s' found.\n",full_name);
1552  }
1553  }
1554 
1555  return e;
1556 }
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define ifdebug(n)
Definition: sg.c:47

References concatenate(), entity_domain, entity_undefined, full_name, gen_find_tabulated(), ifdebug, MODULE_SEP_STRING, pips_debug, str2upper(), strdup(), and TOP_LEVEL_MODULE_NAME.

Referenced by gfc2pips_symbol2entity().

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

◆ gfc2pips_check_entity_program_exists()

entity gfc2pips_check_entity_program_exists ( char *  s)

Definition at line 1527 of file gfc2pips.c.

1527  {
1528  string full_name;
1529  //main program
1532  MAIN_PREFIX,
1533  str2upper(strdup(s)),
1534  NULL);
1536 }

References concatenate(), entity_domain, full_name, gen_find_tabulated(), MAIN_PREFIX, MODULE_SEP_STRING, str2upper(), strdup(), and TOP_LEVEL_MODULE_NAME.

Referenced by gfc2pips_symbol2entity().

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

◆ gfc2pips_code2get_label()

entity gfc2pips_code2get_label ( gfc_code *  c)

Definition at line 3756 of file gfc2pips.c.

3756  {
3757  if(!c) {
3758  return entity_empty_label();
3759  }
3760 
3761  gfc2pips_debug(9,
3762  "test label: %lu %lu %lu %lu\t"
3763  "next %lu block %lu %lu\n",
3764  (_int)(c->label?c->label->value:0),
3765  (_int)(c->label2?c->label2->value:0),
3766  (_int)(c->label3?c->label3->value:0),
3767  (_int)(c->here?c->here->value:0),
3768  (_int)c->next,
3769  (_int)c->block,
3770  (_int)c->expr
3771  );
3772  if(c->here) {
3773  return gfc2pips_int2label(c->here->value);
3774  }
3775  return entity_empty_label();
3776 }
entity gfc2pips_int2label(int n)
dump an integer to a PIPS label entity
Definition: gfc2pips.c:1785
intptr_t _int
_INT
Definition: newgen_types.h:53
entity entity_empty_label(void)
Definition: entity.c:1105

References entity_empty_label(), gfc2pips_debug, and gfc2pips_int2label().

Referenced by gfc2pips_code2instruction(), gfc2pips_code2instruction_(), gfc2pips_code2instruction__TOP(), and gfc2pips_dumpSELECT().

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

◆ gfc2pips_code2get_label2()

entity gfc2pips_code2get_label2 ( gfc_code *  c)

Definition at line 3778 of file gfc2pips.c.

3778  {
3779  if(!c)
3780  return entity_empty_label();
3781  gfc2pips_debug(9,
3782  "test label2: %lu %lu %lu %lu\t"
3783  "next %lu block %lu %lu\n",
3784  (_int)(c->label?c->label->value:0),
3785  (_int)(c->label2?c->label2->value:0),
3786  (_int)(c->label3?c->label3->value:0),
3787  (_int)(c->here?c->here->value:0),
3788  (_int)c->next,
3789  (_int)c->block,
3790  (_int)c->expr
3791  );
3792  if(c->label)
3793  return gfc2pips_int2label(c->label->value);
3794  return entity_empty_label();
3795 }

References entity_empty_label(), gfc2pips_debug, and gfc2pips_int2label().

Referenced by gfc2pips_code2instruction_().

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

◆ gfc2pips_code2get_label3()

entity gfc2pips_code2get_label3 ( gfc_code *  c)

Definition at line 3796 of file gfc2pips.c.

3796  {
3797  if(!c)
3798  return entity_empty_label();
3799  gfc2pips_debug(9,
3800  "test label2: %lu %lu %lu %lu\t"
3801  "next %lu block %lu %lu\n",
3802  (_int)(c->label?c->label->value:0),
3803  (_int)(c->label2?c->label2->value:0),
3804  (_int)(c->label3?c->label3->value:0),
3805  (_int)(c->here?c->here->value:0),
3806  (_int)c->next,
3807  (_int)c->block,
3808  (_int)c->expr
3809  );
3810  if(c->label)
3811  return gfc2pips_int2label(c->label2->value);
3812  return entity_empty_label();
3813 }

References entity_empty_label(), gfc2pips_debug, and gfc2pips_int2label().

Referenced by gfc2pips_code2instruction_().

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

◆ gfc2pips_code2get_label4()

entity gfc2pips_code2get_label4 ( gfc_code *  c)

Definition at line 3814 of file gfc2pips.c.

3814  {
3815  if(!c)
3816  return entity_empty_label();
3817  gfc2pips_debug(9,
3818  "test label2: %lu %lu %lu %lu\t"
3819  "next %lu block %lu %lu\n",
3820  (_int)(c->label?c->label->value:0),
3821  (_int)(c->label2?c->label2->value:0),
3822  (_int)(c->label3?c->label3->value:0),
3823  (_int)(c->here?c->here->value:0),
3824  (_int)c->next,
3825  (_int)c->block,
3826  (_int)c->expr
3827  );
3828  if(c->label)
3829  return gfc2pips_int2label(c->label3->value);
3830  return entity_empty_label();
3831 }

References entity_empty_label(), gfc2pips_debug, and gfc2pips_int2label().

Referenced by gfc2pips_code2instruction_().

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

◆ gfc2pips_code2instruction()

instruction gfc2pips_code2instruction ( gfc_code *  c,
bool  force_sequence 
)

Build an instruction sequence.

same as {func}__TOP but without the declarations

Parameters
nsthe top-level entity from gfc. We need it to retrieve some more informations
cthe struct containing information about the instruction

Definition at line 2368 of file gfc2pips.c.

2368  {
2369  list list_of_statements;
2371  force_sequence = true;
2372  if(!c) {
2373  if(force_sequence) {
2374  //fprintf(stderr,"WE HAVE GOT A PROBLEM, SEQUENCE WITHOUT ANYTHING IN IT !\nSegfault soon ...\n");
2377  NIL ));
2378  } else {
2379  //fprintf(stderr,"Undefined code\n");
2380  return make_instruction_block(NULL);
2381  }
2382  }
2383  //No block, only one instruction
2384  //if(!c->next && !force_sequence )return gfc2pips_code2instruction_(c);
2385 
2386  //create a sequence and put everything into it ? is it right ?
2387  list_of_statements = NULL;
2388 
2389  //entity l = gfc2pips_code2get_label(c);
2390  do {
2391  if(c && c->op == EXEC_SELECT) {
2392  list_of_statements
2393  = gen_nconc(list_of_statements, gfc2pips_dumpSELECT(c));
2394  c = c->next;
2395  if(list_of_statements)
2396  break;
2397  } else {
2399  if(i != instruction_undefined) {
2400  string comments = gfc2pips_get_comment_of_code(c);//fprintf(stderr,"comment founded")
2401  list_of_statements = CONS( STATEMENT,
2405  comments,
2406  //empty_comments,
2407  i,
2408  NIL,
2409  NULL,
2410  empty_extensions( ),
2412  list_of_statements );
2413  }
2414  }
2415  c = c->next;
2416  } while(i == instruction_undefined && c);
2417 
2418  //statement_label((statement)list_of_statements->car.e) = gfc2pips_code2get_label(c);
2419 
2420  for (; c; c = c->next) {
2422  //l = gfc2pips_code2get_label(c);
2423  //on lie l'instruction suivante à la courante
2424  //fprintf(stderr,"Dump the following instructions\n");
2425  //CONS(STATEMENT,instruction_to_statement(gfc2pips_code2instruction_(c)),list_of_statements);
2426  int curr_label_num = gfc2pips_last_created_label;
2427  if(c && c->op == EXEC_SELECT) {
2428  list_of_statements
2429  = gen_nconc(list_of_statements, gfc2pips_dumpSELECT(c));
2430  } else {
2432  //si derniÚre boucle == c alors on doit ajouter un statement continue sur le label <curr_label_num>
2433  if(i != instruction_undefined) {
2434  string comments = gfc2pips_get_comment_of_code(c);//fprintf(stderr,"comment founded")
2438  comments,
2439  //empty_comments,
2440  i,
2441  NULL,
2442  NULL,
2443  empty_extensions(),
2445  if(s != statement_undefined) {
2446  list_of_statements = gen_nconc(list_of_statements, CONS( STATEMENT,
2447  s,
2448  NIL ));
2449  }
2450  //TODO: if it is a loop and there is an EXIT statement
2451  if(gfc2pips_get_last_loop() == c) {
2452  s = make_continue_statement(gfc2pips_int2label(curr_label_num - 1));
2453  list_of_statements = gen_nconc(list_of_statements, CONS( STATEMENT,
2454  s,
2455  NIL ));
2456  }
2457  }
2458  }
2459  /*
2460  * if we have got a label like a
2461  * ----------------------
2462  * do LABEL while (expr)
2463  * statement
2464  * LABEL continue
2465  * ----------------------
2466  * we do need to make a continue statement BUT this will crash the program in some cases
2467  * PARSED_PRINTED_FILE is okay, but not PRINTED_FILE so we have to find out why
2468  */
2469  }
2470  return make_instruction_block(list_of_statements);
2471 }
statement make_statement(entity a1, intptr_t a2, intptr_t a3, string a4, instruction a5, list a6, string a7, extensions a8, synchronization a9)
Definition: ri.c:2222
synchronization make_synchronization_none(void)
Definition: ri.c:2424
string gfc2pips_get_comment_of_code(gfc_code *c)
gfc_code * gfc2pips_get_last_loop(void)
list gfc2pips_dumpSELECT(gfc_code *c)
Definition: gfc2pips.c:3399
entity gfc2pips_code2get_label(gfc_code *c)
Definition: gfc2pips.c:3756
static int gfc2pips_last_created_label
Definition: gfc2pips.c:104
instruction gfc2pips_code2instruction_(gfc_code *c)
this function create an atomic statement, no block of data
Definition: gfc2pips.c:2479
statement instruction_to_statement(instruction)
Build a statement from a give instruction.
Definition: statement.c:597
instruction make_instruction_block(list statements)
Build an instruction block from a list of statements.
Definition: instruction.c:106
statement make_continue_statement(entity)
Definition: statement.c:953
#define STATEMENT_ORDERING_UNDEFINED
mapping.h inclusion
Definition: newgen-local.h:35
#define STATEMENT_NUMBER_UNDEFINED
default values
extensions empty_extensions(void)
extension.c
Definition: extension.c:43
#define instruction_undefined
Definition: ri.h:1454
#define statement_undefined
Definition: ri.h:2419
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413

References CONS, empty_extensions(), gen_nconc(), gfc2pips_code2get_label(), gfc2pips_code2instruction_(), gfc2pips_dumpSELECT(), gfc2pips_get_comment_of_code(), gfc2pips_get_last_loop(), gfc2pips_int2label(), gfc2pips_last_created_label, instruction_to_statement(), instruction_undefined, make_continue_statement(), make_instruction_block(), make_statement(), make_synchronization_none(), NIL, STATEMENT, STATEMENT_NUMBER_UNDEFINED, STATEMENT_ORDERING_UNDEFINED, and statement_undefined.

Referenced by gfc2pips_code2instruction_(), and gfc2pips_dumpSELECT().

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

◆ gfc2pips_code2instruction_()

instruction gfc2pips_code2instruction_ ( gfc_code *  c)

this function create an atomic statement, no block of data

Parameters
cthe instruction to translate from gfc
Returns
the statement equivalent in PIPS never call this function except in gfc2pips_code2instruction or in recursive mode

an instruction without anything => continue statement

Beware, left hand side of assignment cannot be a TOP-LEVEL entity If it is an assignment to a function, some complications are to be expected

Get the symbol that represent the function called

Convert symbol in a pips entity

Get the arglist for the call

Fix the storage

Fix the initial value (intrinsic only)

Fix the type of the function

invent list of parameters

need to translate list_of_arguments in sthg

make the call now

add to callees

Function (or subroutine) call of a procedure pointer component or type-bound procedure

WTF ? Same destination whatever the result of the test is ? let's put a goto !

WTF ?

No test in an if ? we are at the last ELSE statement for an ELSE IF

Let's produce an IF statement

Recursive call

Handle else

this is an ELSE IF

Recursive call

No condition therefore we are in the last ELSE statement

Recursive call

recursive call, get loop body

keep trace of enclosing loops

Get body (recursive call)

some problem inducted by the prettyprinter output become : DEALLOCATE(variable, STAT=, I) (note STAT= without nothing else)

Create the entity that will be "called", READ or WRITE only

lci will be set in reverse order, so we have to put data first

Get the datas in reverse order

Separator is IO_LIST

It is a reference to a FORMAT we do have a label somewhere with a format

delete supplementary quotes

UNIT is not a constant, we have to print it

We have to print UNIT= ; it's not implicit

Definition at line 2479 of file gfc2pips.c.

2479  {
2480  instruction return_instruction = instruction_undefined;
2481 
2482  //do we have a label ?
2483  //if(c->here){}
2484 
2485  gfc2pips_debug(8,"Start\n");
2486  switch(c->op) {
2487  /* an instruction without anything => continue statement*/
2488  case EXEC_NOP:
2489  case EXEC_CONTINUE:
2490  gfc2pips_debug(5, "Translation of CONTINUE\n");
2491 
2492  return_instruction = make_continue_instruction();
2493  break;
2494  case EXEC_INIT_ASSIGN:
2495  case EXEC_ASSIGN: {
2496  /* Beware, left hand side of assignment cannot be a TOP-LEVEL entity
2497  * If it is an assignment to a function, some complications are to be
2498  * expected
2499  */
2500  expression left_hand_side = gfc2pips_expr2expression(c->expr);
2501  expression right_hand_side = gfc2pips_expr2expression(c->expr2);
2502  return_instruction = make_assign_instruction(left_hand_side,
2503  right_hand_side);
2504  break;
2505  }
2506  case EXEC_POINTER_ASSIGN: {
2507  gfc2pips_debug(5, "Translation of assign POINTER ASSIGN\n");
2508 
2509  list list_of_arguments = CONS( EXPRESSION,
2510  gfc2pips_expr2expression( c->expr2 ),
2511  NIL );
2512 
2514  call call_ = make_call(e, list_of_arguments);
2517  return_instruction
2519  break;
2520  }
2521  case EXEC_GOTO: {
2522  gfc2pips_debug(5, "Translation of GOTO\n");
2524  return_instruction = make_instruction_goto(make_continue_statement(lbl));
2525  break;
2526  }
2527  case EXEC_CALL:
2528  case EXEC_ASSIGN_CALL: {
2529  gfc2pips_debug(5,"Translation of %s\n",
2530  c->op==EXEC_CALL?"CALL":"ASSIGN_CALL");
2531 
2532  gfc_symbol* symbol = NULL;
2533 
2534  /* Get the symbol that represent the function called */
2535  if(c->resolved_sym) {
2536  symbol = c->resolved_sym;
2537  } else if(c->symtree) {
2538  symbol = c->symtree->n.sym;
2539  } else {
2540  pips_user_error( "We do not have a symbol to call!!\n" );
2541  }
2542 
2543  /* Convert symbol in a pips entity */
2544  entity called_function = gfc2pips_symbol2entity(symbol);
2545 
2546  /* Get the arglist for the call */
2547  list list_of_arguments = gfc2pips_arglist2arglist(c->ext.actual);
2548 
2549  /* Fix the storage */
2550  if(entity_storage(called_function) == storage_undefined) {
2551  gfc2pips_debug(1,"Storage rom !! %s\n",entity_name(called_function));
2552  entity_storage(called_function) = make_storage_rom();
2553  }
2554 
2555  /* Fix the initial value (intrinsic only) */
2556  if(entity_initial(called_function) == value_undefined) {
2557  entity_initial(called_function) = make_value(is_value_intrinsic,
2558  called_function);
2559  pips_user_warning("Here we make an intrinsic since we "
2560  "didn't resolve symbol : %s\n",
2561  gfc2pips_get_safe_name( symbol->name ));
2562  }
2563 
2564  /* Fix the type of the function */
2565  if(entity_type(called_function) == type_undefined) {
2566  gfc2pips_debug(2,"Type is undefined %s\n",entity_name(called_function));
2567  /* invent list of parameters */
2568  list param_of_call = gen_copy_seq(list_of_arguments);
2569  list param_of_call_p = param_of_call;
2570  /* need to translate list_of_arguments in sthg */
2571  while(param_of_call_p) {
2572  entity _new =
2573  (entity)gen_copy_tree((gen_chunk *)param_of_call_p->car.e);
2574  entity_name(_new) = "toto"; // hum....
2575  gfc2pips_debug(2,
2576  "%s - %s",
2577  entity_name((entity)param_of_call_p->car.e),
2578  entity_name(_new) );
2579  param_of_call_p->car.e = _new;
2580  POP( param_of_call_p );
2581  }
2582 
2583  pips_user_warning("Type is undefined for function '%s',"
2584  " thus we make it 'overloaded'\n",
2585  gfc2pips_get_safe_name( symbol->name ));
2586 
2587  entity_type(called_function)
2589  }
2590 
2591  /* make the call now */
2592  call call_ = make_call(called_function, list_of_arguments);
2593 
2594  /* add to callees */
2595  gfc2pips_add_to_callees(called_function);
2596 
2597  return_instruction = make_instruction_call(call_);
2598  break;
2599  }
2600  case EXEC_COMPCALL: {
2601  /* Function (or subroutine) call of a procedure pointer component or
2602  * type-bound procedure
2603  */
2604  gfc2pips_debug(5, "Translation of COMPCALL\n");
2605  break;
2606  }
2607  case EXEC_RETURN: {
2608  //we shouldn't even dump that for main entities
2609  gfc2pips_debug(5, "Translation of RETURN\n");
2611 
2612  if(c->expr) {
2613  expression args = gfc2pips_expr2expression(c->expr);
2614  return_instruction = MakeUnaryCallInst(e, args);
2615  } else {
2616  return_instruction = MakeNullaryCallInst(e);
2617  }
2618  break;
2619  }
2620  case EXEC_PAUSE: {
2621  gfc2pips_debug(5, "Translation of PAUSE\n");
2623 
2624  list args = NULL;
2625  if(c->expr) {
2626  expression args = gfc2pips_expr2expression(c->expr);
2627  return_instruction = MakeUnaryCallInst(e, args);
2628  } else {
2629  return_instruction = MakeNullaryCallInst(e);
2630  }
2631  break;
2632  }
2633  case EXEC_STOP: {
2634  gfc2pips_debug(5, "Translation of STOP\n");
2636 
2637  if(c->expr) {
2638  expression args = gfc2pips_expr2expression(c->expr);
2639  return_instruction = MakeUnaryCallInst(e, args);
2640  } else {
2641  return_instruction = MakeNullaryCallInst(e);
2642  }
2643  break;
2644  }
2645  case EXEC_ARITHMETIC_IF: {
2646  gfc2pips_debug(5, "Translation of ARITHMETIC IF\n");
2647  expression e = gfc2pips_expr2expression(c->expr);
2649  e,
2650  int_to_expression(0));
2652  e,
2653  int_to_expression(0));
2654  expression e3 =
2656  e,
2657  int_to_expression(0));
2658  /*
2659  * we handle the labels doubled because it will never be checked
2660  * afterwards to combine/fuse
2661  */
2662  if(c->label->value == c->label2->value) {
2663  if(c->label->value == c->label3->value) {
2664  /* WTF ? Same destination whatever the result of the test is ?
2665  * let's put a goto !
2666  */
2668  statement continue_stmt = make_continue_statement(lbl);
2669  return_instruction = make_instruction_goto(continue_stmt);
2670  } else {
2671  //.LE. / .GT.
2672  statement
2673  s2 =
2675  statement
2676  s3 =
2678  return_instruction = make_instruction_test(make_test(e3, s2, s3));
2679  }
2680  } else if(c->label2->value == c->label3->value) {
2681  //.LT. / .GE.
2682  statement
2683  s2 =
2685  statement
2686  s3 =
2688  return_instruction = make_instruction_test(make_test(e1, s2, s3));
2689  } else {
2690  statement
2691  s1 =
2693  statement
2694  s2 =
2696  statement
2697  s3 =
2699  statement s =
2701  s2,
2702  s3)));
2703  return_instruction = make_instruction_test(make_test(e1, s1, s));
2704  }
2705  break;
2706  }
2707 
2708  case EXEC_IF: {
2709  gfc2pips_debug(5, "Translation of IF\n");
2710  /*
2711  * IF - ELSE IF - ELSE IF - .... - ELSE
2712  * is handled with a chain list.
2713  * next is the current "IF" (or ELSEIF or ELSE) and
2714  * block is the next test (if any)
2715  *
2716  * We handled this chain list recursively
2717  *
2718  */
2719  gfc_code* d = c->block;
2720  if(!d) {
2721  /* WTF ? */
2722  return_instruction = make_instruction_block(NULL);
2723  } else if(!d->expr) {
2724  /* No test in an if ? we are at the last ELSE statement for an ELSE IF
2725  */
2726  if(d->next) {
2727  return_instruction = gfc2pips_code2instruction(d->next, true);
2728  } else {
2729  return_instruction = make_instruction_block(NULL);
2730  }
2731  } else if(!d->next) {
2732  return_instruction = make_instruction_block(NULL);
2733  } else {
2734  /* Let's produce an IF statement */
2735 
2736  expression e = gfc2pips_expr2expression(d->expr);
2738  statement s_else = statement_undefined;
2739 
2740  /* Recursive call */
2741  instruction s_if_i = gfc2pips_code2instruction(d->next, false);
2742 
2743  message_assert( "Can't produce if instruction !\n",
2744  s_if_i != instruction_undefined );
2745 
2746  s_if = instruction_to_statement(s_if_i);
2747  statement_label(s_if) = gfc2pips_code2get_label(d->next);
2748 
2749  /* Handle else */
2750  if(d->block) {
2752  if(d->block->expr) { /* this is an ELSE IF */
2753  /* Recursive call */
2754  s_else_i = gfc2pips_code2instruction_(d);
2755  } else {/* No condition therefore we are in the last ELSE statement */
2756  /* Recursive call */
2757  s_else_i = gfc2pips_code2instruction(d->block->next, false);
2758  }
2759  message_assert( "s_else_i is defined\n", s_else_i !=instruction_undefined );
2760  s_else = instruction_to_statement(s_else_i);
2761  statement_label(s_else) = gfc2pips_code2get_label(d->block->next);
2762  } else {
2763  s_else = make_empty_block_statement();
2764  }
2765 
2766  return_instruction = test_to_instruction(make_test(e, s_if, s_else));
2767 
2768  }
2769  break;
2770  }
2771  case EXEC_DO: {
2772  gfc2pips_debug(5, "Translation of DO\n");
2773  // /* keep trace of enclosing loops *
2774  gfc2pips_push_loop(c);
2775 
2776  /* recursive call, get loop body */
2777  instruction do_i = gfc2pips_code2instruction(c->block->next, true);
2778  message_assert( "first instruction defined", do_i
2781 
2782  /*
2783  * it would be perfect if we knew there is a EXIT or a CYCLE in the loop,
2784  * do not add if already one (then how to stock the label ?)
2785  * add to s a continue statement at the end to make
2786  * cycle/continue statements
2787  */
2788  /*
2789  list list_of_instructions =
2790  sequence_statements(instruction_sequence(statement_instruction(s)));
2791  entity lbl = gfc2pips_int2label( gfc2pips_last_created_label );
2792  list_of_instructions = gen_nconc(list_of_instructions,
2793  CONS(STATEMENT,
2794  make_continue_statement( lbl ),
2795  NULL)
2796  );
2797  gfc2pips_last_created_label -= gfc2pips_last_created_label_step;
2798  sequence_statements(instruction_sequence(statement_instruction(s)))
2799  = list_of_instructions;
2800  */
2801 
2802  range r = make_range(gfc2pips_expr2expression(c->ext.iterator->start),
2803  gfc2pips_expr2expression(c->ext.iterator->end),
2804  gfc2pips_expr2expression(c->ext.iterator->step));//lower, upper, increment
2805 
2806  entity loop_index = gfc2pips_expr2entity(c->ext.iterator->var);
2807 
2808  // Fixme : what about parallel loop ? Check gfc...
2810  r,
2811  s,
2814  NULL);
2816  return_instruction = make_instruction_loop(w);
2817 
2818  break;
2819  }
2820  case EXEC_DO_WHILE: {
2821  gfc2pips_debug(5, "Translation of DO WHILE\n");
2822  /* keep trace of enclosing loops */
2823  gfc2pips_push_loop(c);
2824 
2825  /* Get body (recursive call) */
2826  instruction do_i = gfc2pips_code2instruction(c->block->next, true);
2827  message_assert( "first instruction defined",
2828  do_i!=instruction_undefined );
2830 
2831  /*
2832  * it would be perfect if we knew there is a EXIT or a CYCLE in the loop,
2833  * do not add if already one (then how to stock the label ?)
2834  * add to s a continue statement at the end to make
2835  * cycle/continue statements
2836  */
2837  /*
2838  list list_of_instructions =
2839  sequence_statements(instruction_sequence(statement_instruction(s)));
2840  entity lbl = gfc2pips_int2label( gfc2pips_last_created_label );
2841  list_of_instructions = gen_nconc(list_of_instructions,
2842  CONS(STATEMENT,
2843  make_continue_statement( lbl ),
2844  NULL)
2845  );
2846  gfc2pips_last_created_label -= gfc2pips_last_created_label_step;
2847  sequence_statements(instruction_sequence(statement_instruction(s)))
2848  = list_of_instructions;
2849  */
2850 
2851  statement_label(s) = gfc2pips_code2get_label(c->block->next);
2853  s,
2857  return_instruction = make_instruction_whileloop(w);
2858  break;
2859  }
2860  case EXEC_CYCLE: {
2861  gfc2pips_debug(5, "Translation of CYCLE\n");
2862  gfc_code* loop_c = gfc2pips_get_last_loop();
2863  entity label = entity_undefined;
2865  return_instruction
2867  break;
2868  }
2869  case EXEC_EXIT: { // FIXME : is the following really an exit ?
2870  gfc2pips_debug(5, "Translation of EXIT\n");
2871  gfc_code* loop_c = gfc2pips_get_last_loop();
2872  entity label = entity_undefined;
2874  return_instruction
2876  break;
2877  }
2878  case EXEC_ALLOCATE:
2879  case EXEC_DEALLOCATE: {
2880  gfc2pips_debug(5, "Translation of %s\n",
2881  c->op==EXEC_ALLOCATE?"ALLOCATE":"DEALLOCATE");
2882  list lci = NULL;
2883  gfc_alloc *a;
2884 
2885  entity e =
2886  CreateIntrinsic(c->op == EXEC_ALLOCATE ? ALLOCATE_FUNCTION_NAME
2888 
2889  /* some problem inducted by the prettyprinter output become :
2890  * DEALLOCATE(variable, STAT=, I)
2891  * (note STAT= without nothing else)
2892  */
2893  if(c->expr) {
2894  gfc2pips_debug(5,"Handling STAT=\n");
2895  lci = gfc2pips_exprIO("STAT=", c->expr, NULL);
2896  }
2897  for (a = c->ext.alloc_list; a; a = a->next) {
2898  lci = CONS( EXPRESSION, gfc2pips_expr2expression( a->expr ), lci );
2899  }
2900  return_instruction = make_instruction_call(make_call(e, gen_nconc(lci,
2901  NULL)));
2902  break;
2903  }
2904  case EXEC_OPEN: {
2905  gfc2pips_debug(5, "Translation of OPEN\n");
2906 
2908 
2909  list lci = NULL;
2910  gfc_open * o = c->ext.open;
2911 
2912  //We have to build the list in the opposite order it should be displayed
2913 
2914  if(o->err)
2915  lci = gfc2pips_exprIO2("ERR=", o->err->value, lci);
2916  if(o->asynchronous)
2917  lci = gfc2pips_exprIO("ASYNCHRONOUS=", o->asynchronous, lci);
2918  if(o->convert)
2919  lci = gfc2pips_exprIO("CONVERT=", o->convert, lci);
2920  if(o->sign)
2921  lci = gfc2pips_exprIO("SIGN=", o->sign, lci);
2922  if(o->round)
2923  lci = gfc2pips_exprIO("ROUND=", o->round, lci);
2924  if(o->encoding)
2925  lci = gfc2pips_exprIO("ENCODING=", o->encoding, lci);
2926  if(o->decimal)
2927  lci = gfc2pips_exprIO("DECIMAL=", o->decimal, lci);
2928  if(o->pad)
2929  lci = gfc2pips_exprIO("PAD=", o->pad, lci);
2930  if(o->delim)
2931  lci = gfc2pips_exprIO("DELIM=", o->delim, lci);
2932  if(o->action)
2933  lci = gfc2pips_exprIO("ACTION=", o->action, lci);
2934  if(o->position)
2935  lci = gfc2pips_exprIO("POSITION=", o->position, lci);
2936  if(o->blank)
2937  lci = gfc2pips_exprIO("BLANK=", o->blank, lci);
2938  if(o->recl)
2939  lci = gfc2pips_exprIO("RECL=", o->recl, lci);
2940  if(o->form)
2941  lci = gfc2pips_exprIO("FORM=", o->form, lci);
2942  if(o->access)
2943  lci = gfc2pips_exprIO("ACCESS=", o->access, lci);
2944  if(o->status)
2945  lci = gfc2pips_exprIO("STATUS=", o->status, lci);
2946  if(o->file)
2947  lci = gfc2pips_exprIO("FILE=", o->file, lci);
2948  if(o->iostat)
2949  lci = gfc2pips_exprIO("IOSTAT=", o->iostat, lci);
2950  if(o->iomsg)
2951  lci = gfc2pips_exprIO("IOMSG=", o->iomsg, lci);
2952  if(o->unit)
2953  lci = gfc2pips_exprIO("UNIT=", o->unit, lci);
2954 
2955  return_instruction = make_instruction_call(make_call(e, gen_nconc(lci,
2956  NULL)));
2957 
2958  break;
2959  }
2960  case EXEC_CLOSE: {
2961  gfc2pips_debug(5, "Translation of CLOSE\n");
2962 
2964 
2965  list lci = NULL;
2966  gfc_close * o = c->ext.close;
2967 
2968  if(o->err)
2969  lci = gfc2pips_exprIO2("ERR=", o->err->value, lci);
2970  if(o->status)
2971  lci = gfc2pips_exprIO("STATUS=", o->status, lci);
2972  if(o->iostat)
2973  lci = gfc2pips_exprIO("IOSTAT=", o->iostat, lci);
2974  if(o->iomsg)
2975  lci = gfc2pips_exprIO("IOMSG=", o->iomsg, lci);
2976  if(o->unit)
2977  lci = gfc2pips_exprIO("UNIT=", o->unit, lci);
2978  return_instruction = make_instruction_call(make_call(e, gen_nconc(lci,
2979  NULL)));
2980  break;
2981  }
2982  case EXEC_BACKSPACE:
2983  case EXEC_ENDFILE:
2984  case EXEC_REWIND:
2985  case EXEC_FLUSH: {
2986  const char* str;
2987  if(c->op == EXEC_BACKSPACE)
2989  else if(c->op == EXEC_ENDFILE)
2990  str = ENDFILE_FUNCTION_NAME;
2991  else if(c->op == EXEC_REWIND)
2992  str = REWIND_FUNCTION_NAME;
2993  else if(c->op == EXEC_FLUSH)
2994  str = "flush"; // FIXME, not implemented
2995  else
2996  pips_user_error( "Your computer is mad\n" );//no other possibility
2997 
2998  entity e = CreateIntrinsic((string)str);
2999 
3000  gfc_filepos *fp;
3001  fp = c->ext.filepos;
3002 
3003  list lci = NULL;
3004  if(fp->err)
3005  lci = gfc2pips_exprIO2("ERR=", fp->err->value, lci);
3006  if(fp->iostat)
3007  lci = gfc2pips_exprIO("UNIT=", fp->iostat, lci);
3008  if(fp->iomsg)
3009  lci = gfc2pips_exprIO("UNIT=", fp->iomsg, lci);
3010  if(fp->unit)
3011  lci = gfc2pips_exprIO("UNIT=", fp->unit, lci);
3012  return_instruction = make_instruction_call(make_call(e, gen_nconc(lci,
3013  NULL)));
3014  break;
3015  }
3016  case EXEC_INQUIRE: {
3017  gfc2pips_debug(5, "Translation of INQUIRE\n");
3018 
3020 
3021  list lci = NULL;
3022  gfc_inquire *i = c->ext.inquire;
3023 
3024  if(i->err)
3025  lci = gfc2pips_exprIO2("ERR=", i->err->value, lci);
3026  if(i->id)
3027  lci = gfc2pips_exprIO("ID=", i->id, lci);
3028  if(i->size)
3029  lci = gfc2pips_exprIO("SIZE=", i->size, lci);
3030  if(i->sign)
3031  lci = gfc2pips_exprIO("SIGN=", i->sign, lci);
3032  if(i->round)
3033  lci = gfc2pips_exprIO("ROUND=", i->round, lci);
3034  if(i->pending)
3035  lci = gfc2pips_exprIO("PENDING=", i->pending, lci);
3036  if(i->encoding)
3037  lci = gfc2pips_exprIO("ENCODING=", i->encoding, lci);
3038  if(i->decimal)
3039  lci = gfc2pips_exprIO("DECIMAL=", i->decimal, lci);
3040  if(i->asynchronous)
3041  lci = gfc2pips_exprIO("ASYNCHRONOUS=", i->asynchronous, lci);
3042  if(i->convert)
3043  lci = gfc2pips_exprIO("CONVERT=", i->convert, lci);
3044  if(i->pad)
3045  lci = gfc2pips_exprIO("PAD=", i->pad, lci);
3046  if(i->delim)
3047  lci = gfc2pips_exprIO("DELIM=", i->delim, lci);
3048  if(i->readwrite)
3049  lci = gfc2pips_exprIO("READWRITE=", i->readwrite, lci);
3050  if(i->write)
3051  lci = gfc2pips_exprIO("WRITE=", i->write, lci);
3052  if(i->read)
3053  lci = gfc2pips_exprIO("READ=", i->read, lci);
3054  if(i->action)
3055  lci = gfc2pips_exprIO("ACTION=", i->action, lci);
3056  if(i->position)
3057  lci = gfc2pips_exprIO("POSITION=", i->position, lci);
3058  if(i->blank)
3059  lci = gfc2pips_exprIO("BLANK=", i->blank, lci);
3060  if(i->nextrec)
3061  lci = gfc2pips_exprIO("NEXTREC=", i->nextrec, lci);
3062  if(i->recl)
3063  lci = gfc2pips_exprIO("RECL=", i->recl, lci);
3064  if(i->unformatted)
3065  lci = gfc2pips_exprIO("UNFORMATTED=", i->unformatted, lci);
3066  if(i->formatted)
3067  lci = gfc2pips_exprIO("FORMATTED=", i->formatted, lci);
3068  if(i->form)
3069  lci = gfc2pips_exprIO("FORM=", i->form, lci);
3070  if(i->direct)
3071  lci = gfc2pips_exprIO("DIRECT=", i->direct, lci);
3072  if(i->sequential)
3073  lci = gfc2pips_exprIO("SEQUENTIAL=", i->sequential, lci);
3074  if(i->access)
3075  lci = gfc2pips_exprIO("ACCESS=", i->access, lci);
3076  if(i->name)
3077  lci = gfc2pips_exprIO("NAME=", i->name, lci);
3078  if(i->named)
3079  lci = gfc2pips_exprIO("NAMED=", i->named, lci);
3080  if(i->number)
3081  lci = gfc2pips_exprIO("NUMBER=", i->number, lci);
3082  if(i->opened)
3083  lci = gfc2pips_exprIO("OPENED=", i->opened, lci);
3084  if(i->exist)
3085  lci = gfc2pips_exprIO("EXIST=", i->exist, lci);
3086  if(i->iostat)
3087  lci = gfc2pips_exprIO("IOSTAT=", i->iostat, lci);
3088  if(i->iomsg)
3089  lci = gfc2pips_exprIO("IOMSG=", i->iomsg, lci);
3090  if(i->file)
3091  lci = gfc2pips_exprIO("FILE=", i->file, lci);
3092  if(i->unit)
3093  lci = gfc2pips_exprIO("UNIT=", i->unit, lci);
3094  return_instruction = make_instruction_call(make_call(e, gen_nconc(lci,
3095  NULL)));
3096  break;
3097  }
3098  case EXEC_READ:
3099  case EXEC_WRITE: {
3100  gfc2pips_debug(5, "Translation of %s\n",c->op==EXEC_WRITE?"PRINT":"READ");
3101  //yeah ! we've got an intrinsic
3102  gfc_code *d = c;
3103  gfc_dt *dt = d->ext.dt;
3104 
3105  pips_assert("dt can't be NULL",dt!=NULL);
3106 
3107  /* Create the entity that will be "called", READ or WRITE only */
3109  if(c->op == EXEC_WRITE) {
3110  //print or write ? print is only a particular case of write
3112  } else {
3114  }
3115 
3118  list lci = NULL;
3119 
3120  /* lci will be set in reverse order, so we have to put data first */
3121 
3122  /* Get the datas in reverse order */
3123  list datas = NIL;
3124  for (c = c->block->next; c; c = c->next) {
3125  datas = gen_cons(c, datas);
3126  }
3127  FOREACH( CHUNKP, _c, datas) {
3128  gfc_code *c = (gfc_code *)_c;
3129  if(c->expr) {
3130  lci = CONS(EXPRESSION,gfc2pips_expr2expression(c->expr),lci);
3131  } else {
3133  if(instruction_loop_p(i)) {
3134  /*
3135  * We have to convert manually a loop to a call to a DO-IMPLIED
3136  */
3137  loop l = instruction_loop(i);
3138  lci = CONS(EXPRESSION,loop_to_implieddo(l),lci);
3139  } else if(instruction_call_p(i)) {
3141  } else {
3142  if(c->op != EXEC_DT_END) {
3143  pips_user_warning("We don't know how to handle op : %d\n", c->op);
3144  }
3145  continue;
3146  }
3147  }
3148  /* Separator is IO_LIST */
3149  lci = CONS( EXPRESSION,
3150  MakeCharacterConstantExpression( "IOLIST=" ),
3151  lci);
3152  }
3153 
3154  if(dt->format_expr) { //if no format ; it is standard
3155  fmt = gfc2pips_expr2expression(dt->format_expr);
3156  } else if(dt->format_label && dt->format_label->value != -1) {
3157  if(dt->format_label->format) {
3158 
3159  if(dt->format_label->value) {
3160  /* It is a reference to a FORMAT
3161  * we do have a label somewhere with a format
3162  */
3163  fmt = gfc2pips_int2expression(dt->format_label->value);
3164 
3165  /*
3166  * we check if we have already the label or not
3167  * the label is associated to a FORMAT =>
3168  * we check if we already have this format
3169  */
3170  if(gen_find_eq((void *)(_int)dt->format_label->value,
3172  /*
3173  * we have to push the current FORMAT in a list, we will dump it at
3174  * the very, very TOP. we need to change the expression, a FORMAT
3175  * statement doesn't have quotes around it
3176  */
3177  expression fmt_expr =
3178  gfc2pips_expr2expression(dt->format_label->format);
3179  /* delete supplementary quotes */
3180  char *str = entity_name(
3182  int curr_char_indice = 0, curr_char_indice_cible = 0,
3183  length_curr_format = strlen(str);
3184  for (; curr_char_indice_cible < length_curr_format - 1; curr_char_indice++, curr_char_indice_cible++) {
3185  if(str[curr_char_indice_cible] == '\'')
3186  curr_char_indice_cible++;
3187  str[curr_char_indice] = str[curr_char_indice_cible];
3188  }
3189  str[curr_char_indice] = '\0';
3190 
3193  = gen_cons((void *)(_int)dt->format_label->value,
3195  }
3196  } else {
3197  // The format is given as an argument !
3198  fmt = gfc2pips_expr2expression(dt->format_label->format);
3199  //delete supplementary quotes
3200  char * str =
3202  int curr_char_indice = 0, curr_char_indice_cible = 0,
3203  length_curr_format = strlen(str);
3204  for (; curr_char_indice_cible < length_curr_format - 1; curr_char_indice++, curr_char_indice_cible++) {
3205  if(str[curr_char_indice_cible] == '\'')
3206  curr_char_indice_cible++;
3207  str[curr_char_indice] = str[curr_char_indice_cible];
3208  }
3209  str[curr_char_indice] = '\0';
3210  }
3211  } else {
3212  //error or warning: we have bad code
3213  pips_user_error( "gfc2pips_code2instruction, No format for label\n" );
3214  }
3215  }
3216 
3217  /*
3218  * Handling of UNIT=
3219  */
3220  if(dt->io_unit) {
3221  bool has_to_generate_unit = FALSE; // Flag
3222 
3223  if(dt->io_unit->expr_type != EXPR_CONSTANT) {
3224  /* UNIT is not a constant, we have to print it */
3225  has_to_generate_unit = TRUE;
3226  } else if(d->op == EXEC_READ && mpz_get_si(dt->io_unit->value.integer)
3227  != 5 || d->op == EXEC_WRITE
3228  && mpz_get_si(dt->io_unit->value.integer) != 6) {
3229  /*
3230  * if the canal is 6, it is standard for write
3231  * if the canal is 5, it is standard for read
3232  */
3233  has_to_generate_unit = TRUE;
3234  }
3235 
3236  /* We have to print UNIT= ; it's not implicit */
3237  if(has_to_generate_unit) {
3238  std = gfc2pips_expr2expression(dt->io_unit);
3239  }
3240  }
3241 
3242  if(dt->err)
3243  lci = gfc2pips_exprIO2("ERR=", dt->err->value, lci);
3244  if(dt->end)
3245  lci = gfc2pips_exprIO2("END=", dt->end->value, lci);
3246  if(dt->eor)
3247  lci = gfc2pips_exprIO2("EOR=", dt->end->value, lci);
3248 
3249  if(dt->sign)
3250  lci = gfc2pips_exprIO("SIGN=", dt->sign, lci);
3251  if(dt->round)
3252  lci = gfc2pips_exprIO("ROUND=", dt->round, lci);
3253  if(dt->pad)
3254  lci = gfc2pips_exprIO("PAD=", dt->pad, lci);
3255  if(dt->delim)
3256  lci = gfc2pips_exprIO("DELIM=", dt->delim, lci);
3257  if(dt->decimal)
3258  lci = gfc2pips_exprIO("DECIMAL=", dt->decimal, lci);
3259  if(dt->blank)
3260  lci = gfc2pips_exprIO("BLANK=", dt->blank, lci);
3261  if(dt->asynchronous)
3262  lci = gfc2pips_exprIO("ASYNCHRONOUS=", dt->asynchronous, lci);
3263  if(dt->pos)
3264  lci = gfc2pips_exprIO("POS=", dt->pos, lci);
3265  if(dt->id)
3266  lci = gfc2pips_exprIO("ID=", dt->id, lci);
3267  if(dt->advance)
3268  lci = gfc2pips_exprIO("ADVANCE=", dt->advance, lci);
3269  if(dt->rec)
3270  lci = gfc2pips_exprIO("REC=", dt->rec, lci);
3271  if(dt->size)
3272  lci = gfc2pips_exprIO("SIZE=", dt->size, lci);
3273  if(dt->iostat)
3274  lci = gfc2pips_exprIO("IOSTAT=", dt->iostat, lci);
3275  if(dt->iomsg)
3276  lci = gfc2pips_exprIO("IOMSG=", dt->iomsg, lci);
3277 
3278  if(dt->namelist)
3279  lci = gfc2pips_exprIO3("NML=", (string)dt->namelist->name, lci);
3280 
3281  if(fmt == expression_undefined && !dt->rec && !dt->namelist) {
3283  }
3284 
3285  if(fmt != expression_undefined) {
3286  // fmt = MakeNullaryCall( CreateIntrinsic( LIST_DIRECTED_FORMAT_NAME ) );
3288  lci = CONS( EXPRESSION, format, CONS( EXPRESSION, fmt, lci ) );
3289 
3290  }
3291 
3292  if(std == expression_undefined) {
3294  }
3296  lci = CONS( EXPRESSION, unite, CONS( EXPRESSION, std, lci ) );
3297 
3298  ifdebug(8) {
3299  gfc2pips_debug(8,"List of arg : \n");
3300  FOREACH(expression, e, lci)
3301  {
3302  print_expression(e);
3303  }
3304  }
3305 
3306  return_instruction = make_instruction_call(make_call(e, lci));
3307 
3308  }
3309  break;
3310  case EXEC_TRANSFER: {
3311  // FIXME, chained transfert ? c->block->next not null ?
3312  expression transfered = gfc2pips_expr2expression(c->expr);
3313  return_instruction = make_instruction_expression(transfered);
3314  break;
3315  }
3316  case EXEC_DT_END:
3317  /*
3318  * This is normal end of recursion when handling data parameter for
3319  * READ and WRITE statement. We have handle the data previously in
3320  * EXEC_TRANSFER.
3321  */
3322  break;
3323 
3324  case EXEC_OMP_ATOMIC:
3325  case EXEC_OMP_BARRIER:
3326  case EXEC_OMP_CRITICAL:
3327  case EXEC_OMP_FLUSH:
3328  case EXEC_OMP_DO:
3329  case EXEC_OMP_MASTER:
3330  case EXEC_OMP_ORDERED:
3331  case EXEC_OMP_PARALLEL:
3332  case EXEC_OMP_PARALLEL_DO:
3333  case EXEC_OMP_PARALLEL_SECTIONS:
3334  case EXEC_OMP_PARALLEL_WORKSHARE:
3335  case EXEC_OMP_SECTIONS:
3336  case EXEC_OMP_SINGLE:
3337  case EXEC_OMP_TASK:
3338  case EXEC_OMP_TASKWAIT:
3339  case EXEC_OMP_WORKSHARE:
3340  pips_user_warning("OpenMP is not supported !!\n");
3341  break;
3342  case EXEC_ENTRY:
3343  pips_user_warning( "Don't know What to do with entry ! (%s)\n",
3344  c->ext.entry->sym->name );
3345  break;
3346  case EXEC_LABEL_ASSIGN:
3347  pips_user_warning( "Don't know What to do with Label-assign ! (%d)\n",
3348  c->label->value);
3349  break;
3350  case EXEC_IOLENGTH:
3351  pips_user_warning( "Don't know What to do with IOLENGTH !\n");
3352  break;
3353  default:
3354  pips_user_warning( "not yet dumpable %d\n", (int) c->op );
3355  }
3356 
3357  if(return_instruction == instruction_undefined) {
3358  return_instruction = make_instruction_block(NULL);
3359  }
3360 
3361  return return_instruction;
3362 }
instruction make_instruction_loop(loop _field_)
Definition: ri.c:1175
functional make_functional(list a1, type a2)
Definition: ri.c:1109
evaluation make_evaluation_before(void)
Definition: ri.c:786
call make_call(entity a1, list a2)
Definition: ri.c:269
syntax make_syntax_call(call _field_)
Definition: ri.c:2500
whileloop make_whileloop(expression a1, statement a2, entity a3, evaluation a4)
Definition: ri.c:2937
loop make_loop(entity a1, range a2, statement a3, entity a4, execution a5, list a6)
Definition: ri.c:1301
storage make_storage_rom(void)
Definition: ri.c:2285
instruction make_instruction_expression(expression _field_)
Definition: ri.c:1196
type make_type_functional(functional _field_)
Definition: ri.c:2718
value make_value(enum value_utype tag, void *val)
Definition: ri.c:2832
test make_test(expression a1, statement a2, statement a3)
Definition: ri.c:2607
execution make_execution_sequential(void)
Definition: ri.c:841
instruction make_instruction_test(test _field_)
Definition: ri.c:1172
instruction make_instruction_call(call _field_)
Definition: ri.c:1184
instruction make_instruction_whileloop(whileloop _field_)
Definition: ri.c:1178
instruction make_instruction_goto(statement _field_)
Definition: ri.c:1181
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
expression MakeCharacterConstantExpression(string s)
END_EOLE.
Definition: constant.c:573
#define gen_chunk_undefined
Definition: genC.h:74
#define CHUNKP(x)
Definition: genC.h:92
gen_chunk * gen_copy_tree(gen_chunk *obj)
Definition: genClib.c:1429
void gfc2pips_add_to_callees(entity e)
Add an entity to the list of callees.
Definition: gfc2pips-util.c:67
void gfc2pips_push_loop(gfc_code *c)
void gfc2pips_pop_loop(void)
list gfc2pips_format
Definition: gfc2pips.c:100
list gfc2pips_exprIO(char *s, gfc_expr *e, list l)
Definition: gfc2pips.c:4309
list gfc2pips_exprIO3(char *s, string e, list l)
Definition: gfc2pips.c:4319
list gfc2pips_format2
Definition: gfc2pips.c:101
instruction gfc2pips_code2instruction(gfc_code *c, bool force_sequence)
Build an instruction sequence.
Definition: gfc2pips.c:2368
list gfc2pips_exprIO2(char *s, int e, list l)
Definition: gfc2pips.c:4314
entity gfc2pips_code2get_label4(gfc_code *c)
Definition: gfc2pips.c:3814
list gfc2pips_arglist2arglist(gfc_actual_arglist *act)
Definition: gfc2pips.c:4287
expression gfc2pips_int2expression(int n)
translate a int to an expression
Definition: gfc2pips.c:1745
entity gfc2pips_code2get_label2(gfc_code *c)
Definition: gfc2pips.c:3778
entity gfc2pips_expr2entity(gfc_expr *expr)
create an entity based on an expression, assume it is used only for incremented variables in loops
Definition: gfc2pips.c:4249
entity gfc2pips_code2get_label3(gfc_code *c)
Definition: gfc2pips.c:3796
statement make_empty_block_statement(void)
Build an empty statement (block/sequence)
Definition: statement.c:625
instruction make_continue_instruction()
Creates a CONTINUE instruction, that is the FORTRAN nop, the ";" in C or the "pass" in Python for exa...
Definition: instruction.c:79
instruction make_assign_instruction(expression l, expression r)
Definition: instruction.c:87
instruction MakeUnaryCallInst(entity f, expression e)
Creates a call instruction to a function with one argument.
Definition: instruction.c:70
instruction MakeNullaryCallInst(entity f)
Creates a call instruction to a function with no argument.
Definition: instruction.c:60
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
#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
void * gen_find_eq(const void *item, const list seq)
Definition: list.c:422
static void symbol(Pproblem XX, int v)
N note: if use janus.c then not static DN.
Definition: isolve.c:113
#define LIST_DIRECTED_FORMAT_NAME
Definition: naming-local.h:97
#define message_assert(msg, ex)
Definition: newgen_assert.h:47
void print_expression(expression e)
no file descriptor is passed to make is easier to use in a debugging stage.
Definition: expression.c:58
#define READ_FUNCTION_NAME
#define ENDFILE_FUNCTION_NAME
#define LESS_THAN_OPERATOR_NAME
#define RETURN_FUNCTION_NAME
#define BACKSPACE_FUNCTION_NAME
#define REWIND_FUNCTION_NAME
#define OPEN_FUNCTION_NAME
#define ALLOCATE_FUNCTION_NAME
F95.
#define ADDRESS_OF_OPERATOR_NAME
#define WRITE_FUNCTION_NAME
#define CLOSE_FUNCTION_NAME
#define STOP_FUNCTION_NAME
#define test_to_instruction
#define PAUSE_FUNCTION_NAME
#define DEALLOCATE_FUNCTION_NAME
#define INQUIRE_FUNCTION_NAME
expression call_to_expression(call c)
Build an expression that call a function or procedure.
Definition: expression.c:309
type MakeOverloadedResult(void)
this function creates a default fortran operator result, i.e.
Definition: type.c:261
#define instruction_loop_p(x)
Definition: ri.h:1518
#define call_function(x)
Definition: ri.h:709
#define instruction_loop(x)
Definition: ri.h:1520
#define entity_storage(x)
Definition: ri.h:2794
@ is_value_intrinsic
Definition: ri.h:3034
#define statement_label(x)
Definition: ri.h:2450
#define entity_name(x)
Definition: ri.h:2790
#define syntax_call(x)
Definition: ri.h:2736
#define instruction_call_p(x)
Definition: ri.h:1527
#define instruction_call(x)
Definition: ri.h:1529
#define expression_syntax(x)
Definition: ri.h:1247
#define loop_index(x)
Definition: ri.h:1640
#define storage_undefined
Definition: ri.h:2476
s1
Definition: set.c:247
gen_chunk car
The data payload of a list element.
Definition: newgen_list.h:42
expression loop_to_implieddo(loop)
Definition: expression.c:167
A gen_chunk is used to store every object.
Definition: genC.h:58
void * e
For externals (foreign objects)
Definition: genC.h:65

References ADDRESS_OF_OPERATOR_NAME, ALLOCATE_FUNCTION_NAME, BACKSPACE_FUNCTION_NAME, call_function, call_to_expression(), cons::car, CHUNKP, CLOSE_FUNCTION_NAME, CONS, CreateIntrinsic(), DEALLOCATE_FUNCTION_NAME, gen_chunk::e, ENDFILE_FUNCTION_NAME, entity_initial, entity_name, entity_storage, entity_type, entity_undefined, EQUAL_OPERATOR_NAME, EXPRESSION, expression_syntax, expression_undefined, FOREACH, gen_chunk_undefined, gen_cons(), gen_copy_seq(), gen_copy_tree(), gen_find_eq(), gen_nconc(), gfc2pips_add_to_callees(), gfc2pips_arglist2arglist(), gfc2pips_code2get_label(), gfc2pips_code2get_label2(), gfc2pips_code2get_label3(), gfc2pips_code2get_label4(), gfc2pips_code2instruction(), gfc2pips_code2instruction_(), gfc2pips_debug, gfc2pips_expr2entity(), gfc2pips_expr2expression(), gfc2pips_exprIO(), gfc2pips_exprIO2(), gfc2pips_exprIO3(), gfc2pips_format, gfc2pips_format2, gfc2pips_get_last_loop(), gfc2pips_get_safe_name(), gfc2pips_int2expression(), gfc2pips_int2label(), gfc2pips_last_created_label, gfc2pips_pop_loop(), gfc2pips_push_loop(), gfc2pips_symbol2entity(), ifdebug, INQUIRE_FUNCTION_NAME, instruction_call, instruction_call_p, instruction_loop, instruction_loop_p, instruction_to_statement(), instruction_undefined, int_to_expression(), is_value_intrinsic, LESS_OR_EQUAL_OPERATOR_NAME, LESS_THAN_OPERATOR_NAME, LIST_DIRECTED_FORMAT_NAME, loop_index, loop_to_implieddo(), make_assign_instruction(), make_call(), make_continue_instruction(), make_continue_statement(), make_empty_block_statement(), make_evaluation_before(), make_execution_sequential(), make_expression(), make_functional(), make_instruction_block(), make_instruction_call(), make_instruction_expression(), make_instruction_goto(), make_instruction_loop(), make_instruction_test(), make_instruction_whileloop(), make_loop(), make_range(), make_storage_rom(), make_syntax_call(), make_test(), make_type_functional(), make_value(), make_whileloop(), MakeBinaryCall(), MakeCharacterConstantExpression(), MakeNullaryCall(), MakeNullaryCallInst(), MakeOverloadedResult(), MakeUnaryCallInst(), message_assert, NIL, normalized_undefined, OPEN_FUNCTION_NAME, PAUSE_FUNCTION_NAME, pips_assert, pips_user_error, pips_user_warning, POP, print_expression(), READ_FUNCTION_NAME, RETURN_FUNCTION_NAME, REWIND_FUNCTION_NAME, s1, statement_label, statement_undefined, STOP_FUNCTION_NAME, storage_undefined, symbol(), syntax_call, test_to_instruction, type_undefined, value_undefined, and WRITE_FUNCTION_NAME.

Referenced by gfc2pips_code2instruction(), gfc2pips_code2instruction_(), and gfc2pips_code2instruction__TOP().

+ Here is the caller graph for this function:

◆ gfc2pips_code2instruction__TOP()

instruction gfc2pips_code2instruction__TOP ( gfc_namespace *  ns,
gfc_code *  c 
)

Declaration of instructions.

We need to differentiate the instructions at the very top of the module from those in other blocks because of the declarations of DATA, SAVE, or simply any variable

Parameters
nsthe top-level entity from gfc. We need it to retrieve some more informations
cthe struct containing information about the instruction

fc_equiv * eq, *eq2; for (eq = ns->equiv; eq; eq = eq->next){ show_indent (); fputs ("Equivalence: ", dumpfile);

gfc2pips_handleEquiv(eq); eq2 = eq; while (eq2){ fprintf(stderr,"eq: %d %s %d ",eq2->expr, eq2->module, eq2->used); show_expr (eq2->expr); eq2 = eq2->eq; if(eq2)fputs (", ", stderr); else fputs ("\n", stderr); } }

unlike the classical method, we don't know if we have had a first statement (data inst)

fprintf( stderr, "list of formats: %p %zu\n", gfc2pips_format, gen_length( gfc2pips_format ) );

Definition at line 2119 of file gfc2pips.c.

2119  {
2120  list list_of_data_symbol, list_of_data_symbol_p;
2121  list_of_data_symbol_p = list_of_data_symbol = gfc2pips_get_data_vars(ns);
2122 
2123  //create a sequence and put everything into it ? is it right ?
2124  list list_of_statements, list_of_statements_p;
2125  list_of_statements_p = list_of_statements = NULL;
2126 
2128 
2129  //dump DATA
2130  //create a list of statements and dump them in one go
2131  //test for each if there is an explicit save statement
2132  //fprintf(stderr,"nb of data statements: %d\n",gen_length(list_of_data_symbol_p));
2133  while(list_of_data_symbol_p) {
2134 
2135  //if there are parts in the DATA statement, we have got a pb !
2137  ins
2138  = gfc2pips_symbol2data_instruction(((gfc_symtree*)list_of_data_symbol_p->car.e)->n.sym);
2139  //fprintf(stderr,"Got a data !\n");
2140  //PIPS doesn't tolerate comments here
2141  //we should shift endlessly the comments number to the first "real" statement
2142  //string comments = gfc2pips_get_comment_of_code(c);
2143  //fprintf(stderr,"comment founded")
2144 
2145  message_assert( "error in data instruction", ins != instruction_undefined );
2149  //comments,
2151  ins,
2152  NULL,
2153  NULL,
2154  empty_extensions(),
2155  make_synchronization_none()), NULL );
2159 
2160  POP( list_of_data_symbol_p );
2161  }
2162 
2163  //dump equivalence statements
2164  //int OffsetOfReference(reference r)
2165  //int CurrentOffsetOfArea(entity a, entity v)
2166 
2167  /*gfc_equiv * eq, *eq2;
2168  for (eq = ns->equiv; eq; eq = eq->next){
2169  //show_indent ();
2170  //fputs ("Equivalence: ", dumpfile);
2171 
2172  //gfc2pips_handleEquiv(eq);
2173  eq2 = eq;
2174  while (eq2){
2175  fprintf(stderr,"eq: %d %s %d ",eq2->expr, eq2->module, eq2->used);
2176  //show_expr (eq2->expr);
2177  eq2 = eq2->eq;
2178  if(eq2)fputs (", ", stderr);
2179  else fputs ("\n", stderr);
2180  }
2181  }*/
2182  //StoreEquivChain(<atom>)
2183 
2184 
2185  list list_of_save = gfc2pips_get_save(ns);
2186  //save_all_entities();//Syntax !!!
2187  gfc2pips_debug(3,"%zu SAVE founded\n",gen_length(list_of_save));
2188  while(list_of_save) {
2189  static int offset_area = 0;
2190  //we should know the current offset of every and each memory area or are equivalence not yet dumped ?
2191  // ProcessSave(<entity>); <=> MakeVariableStatic(<entity>,true)
2192  // => balance le storage dans RAM, ram_section(r) = StaticArea
2193  //fprintf(stderr,"%d\n",list_of_save->car.e);
2194  gfc2pips_debug(4,"entity to SAVE %s\n",((gfc_symtree*)list_of_save->car.e)->n.sym->name);
2195  entity curr_save =
2196  gfc2pips_symbol2entity(((gfc_symtree*)list_of_save->car.e)->n.sym);
2197  gfc2pips_debug(9,"Size of %s %d\n",STATIC_AREA_LOCAL_NAME, CurrentOffsetOfArea(StaticArea ,curr_save));//Syntax !
2198  //entity_type(curr_save) = make_type_area(<area>);
2199  //entity g = local_name_to_top_level_entity(entity_local_name(curr_save));
2200  if(entity_storage(curr_save) == storage_undefined) {
2201  //int offset_area = CurrentOffsetOfArea(StaticArea,curr_save);
2202  entity_storage(curr_save)
2204  StaticArea,
2206  NIL));
2209  =CONS(entity,curr_save,layout);
2210  //AddVariableToCommon(StaticArea,curr_save);
2211  //SaveEntity(curr_save);
2212  //offset_area = CurrentOffsetOfArea(StaticArea,curr_save);
2213  //set_common_to_size(StaticArea,offset_area);
2214  } else if(storage_ram_p(entity_storage(curr_save))
2215  && ram_section(storage_ram(entity_storage(curr_save))) == DynamicArea) {
2216  //int offset_area = CurrentOffsetOfArea(StaticArea,curr_save);
2219  //ram_offset(storage_ram(entity_storage(curr_save))) = UNKNOWN_RAM_OFFSET;
2220  //AddVariableToCommon(StaticArea,curr_save);
2221  //SaveEntity(curr_save);
2222  //offset_area = CurrentOffsetOfArea(StaticArea,curr_save);
2223  //set_common_to_size(StaticArea,offset_area);
2224  } else if(storage_ram_p(entity_storage(curr_save))
2225  && ram_section(storage_ram(entity_storage(curr_save))) == StaticArea) {
2226  //int offset_area = CurrentOffsetOfArea(StackArea,curr_save);
2227  //set_common_to_size(StaticArea,offset_area);
2228  gfc2pips_debug(9,"Entity %s already in the Static area\n",entity_name(curr_save));
2229  } else {
2230  pips_user_warning( "Static entity(%s) not in the correct memory Area: %s\n",
2231  entity_name(curr_save),
2233  : "?" );
2234  }
2235  POP( list_of_save );
2236  }
2237  if(!c) {
2238  //fprintf(stderr,"WE HAVE GOT A PROBLEM, SEQUENCE WITHOUT ANYTHING IN IT !\nSegfault soon ...\n");
2241  NIL ));
2242  }
2243 
2244  //dump other
2245  //we know we have at least one instruction, otherwise we would have
2246  //returned an empty list of statements
2247  while(i == instruction_undefined && c->op != EXEC_SELECT) {
2249  if(i != instruction_undefined) {
2250  //string comments = gfc2pips_get_comment_of_code(c);
2251  //fprintf(stderr,"comment founded")
2255  //comments,
2257  i,
2258  NULL,
2259  NULL,
2260  empty_extensions(),
2262  /* unlike the classical method, we don't know if we have had
2263  * a first statement (data inst)
2264  */
2265  list_of_statements = gen_nconc(list_of_statements, CONS( STATEMENT,
2266  s,
2267  NIL ));
2268  }
2269  c = c->next;
2270  }
2271 
2272  //compter le nombre de statements décalés
2273  unsigned long first_comment_num = gfc2pips_get_num_of_gfc_code(c);
2274  unsigned long last_code_num = gen_length(gfc2pips_list_of_declared_code);
2275  unsigned long curr_comment_num = first_comment_num;
2276  //for( ; curr_comment_num<first_comment_num ; curr_comment_num++ )
2277  // gfc2pips_replace_comments_num( curr_comment_num, first_comment_num );
2278  for (; curr_comment_num <= last_code_num; curr_comment_num++)
2279  gfc2pips_replace_comments_num(curr_comment_num, curr_comment_num + 1
2280  - first_comment_num);
2281 
2283  /*
2284  unsigned long first_comment_num = gfc2pips_get_num_of_gfc_code(c);
2285  unsigned long curr_comment_num=0;
2286  for( ; curr_comment_num<first_comment_num ; curr_comment_num++ ){
2287  gfc2pips_replace_comments_num( curr_comment_num, first_comment_num );
2288  }
2289  gfc2pips_assign_gfc_code_to_num_comments(c,first_comment_num );
2290  */
2291 
2292  for (; c; c = c->next) {
2294  if(c && c->op == EXEC_SELECT) {
2295  list_of_statements
2296  = gen_nconc(list_of_statements, gfc2pips_dumpSELECT(c));
2297  } else {
2299  if(i != instruction_undefined) {
2300  string comments = gfc2pips_get_comment_of_code(c);//fprintf(stderr,"comment founded")
2301  s
2306  comments,
2307  //empty_comments,
2308  i,
2309  NULL,
2310  NULL,
2311  empty_extensions(),
2313  list_of_statements = gen_nconc(list_of_statements, CONS( STATEMENT,
2314  s,
2315  NIL ));
2316 
2317  }
2318  }
2319  }
2320 
2321  //FORMAT
2322  //we have the informations only at the end, (<=>now)
2323  list gfc2pips_format_p = gfc2pips_format;
2324  list gfc2pips_format2_p = gfc2pips_format2;
2325  /* fprintf( stderr,
2326  "list of formats: %p %zu\n",
2327  gfc2pips_format,
2328  gen_length( gfc2pips_format ) );*/
2329  list list_of_statements_format = NULL;
2330  while(gfc2pips_format_p) {
2331  i
2332  = MakeZeroOrOneArgCallInst("FORMAT",
2333  (expression)gfc2pips_format_p->car.e);
2334  statement s =
2335  make_statement(gfc2pips_int2label((_int)gfc2pips_format2_p->car.e),
2338  //comments,
2340  i,
2341  NULL,
2342  NULL,
2343  empty_extensions(),
2345  //unlike the classical method, we don't know if we have had a first statement (data inst)
2346  list_of_statements_format = gen_nconc(list_of_statements_format,
2347  CONS( STATEMENT, s, NIL ));
2348  POP( gfc2pips_format_p );
2349  POP( gfc2pips_format2_p );
2350  }
2351  list_of_statements = gen_nconc(list_of_statements_format, list_of_statements);
2352 
2353  if(list_of_statements) {
2354  return make_instruction_block(list_of_statements);//make a sequence <=> make_instruction_sequence(make_sequence(list_of_statements));
2355  } else {
2356  fprintf(stderr, "Warning ! no instruction dumped => very bad\n");
2359  NIL ));
2360  }
2361 }
ram make_ram(entity a1, entity a2, intptr_t a3, list a4)
Definition: ri.c:1999
storage make_storage_ram(ram _field_)
Definition: ri.c:2279
entity DynamicArea
These global variables are declared in ri-util/util.c.
Definition: area.c:57
entity StaticArea
Definition: area.c:58
int CurrentOffsetOfArea(entity a, entity v)
Definition: declaration.c:1195
unsigned long gfc2pips_get_num_of_gfc_code(gfc_code *c)
void gfc2pips_replace_comments_num(unsigned long old, unsigned long new)
void gfc2pips_assign_gfc_code_to_num_comments(gfc_code *c, unsigned long num)
list gfc2pips_list_of_declared_code
Definition: gfc2pips-util.c:41
list gfc2pips_get_data_vars(gfc_namespace *ns)
return a list of elements needing a DATA statement
Definition: gfc2pips.c:1244
list gfc2pips_get_save(gfc_namespace *ns)
return a list of SAVE elements
Definition: gfc2pips.c:1250
instruction gfc2pips_symbol2data_instruction(gfc_symbol *sym)
build a DATA statement, filling blanks with zeroes.
Definition: gfc2pips.c:3501
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
#define STATIC_AREA_LOCAL_NAME
Definition: naming-local.h:70
#define UNKNOWN_RAM_OFFSET
#define empty_comments
Empty comments (i.e.
code entity_code(entity e)
Definition: entity.c:1098
#define instruction_sequence_p(x)
Definition: ri.h:1512
#define storage_ram_p(x)
Definition: ri.h:2519
#define ram_section(x)
Definition: ri.h:2249
#define area_layout(x)
Definition: ri.h:546
#define code_initializations(x)
Definition: ri.h:788
#define sequence_statements(x)
Definition: ri.h:2360
#define type_area(x)
Definition: ri.h:2946
#define storage_ram(x)
Definition: ri.h:2521
#define ram_offset(x)
Definition: ri.h:2251
instruction MakeZeroOrOneArgCallInst(char *s, expression e)
this function creates a simple Fortran statement such as RETURN, CONTINUE, ...
Definition: statement.c:669

References area_layout, cons::car, code_initializations, CONS, CurrentOffsetOfArea(), DynamicArea, gen_chunk::e, empty_comments, empty_extensions(), entity_code(), entity_empty_label(), entity_name, entity_storage, entity_type, fprintf(), gen_length(), gen_nconc(), get_current_module_entity(), gfc2pips_assign_gfc_code_to_num_comments(), gfc2pips_code2get_label(), gfc2pips_code2instruction_(), gfc2pips_debug, gfc2pips_dumpSELECT(), gfc2pips_format, gfc2pips_format2, gfc2pips_get_comment_of_code(), gfc2pips_get_data_vars(), gfc2pips_get_num_of_gfc_code(), gfc2pips_get_save(), gfc2pips_int2label(), gfc2pips_list_of_declared_code, gfc2pips_replace_comments_num(), gfc2pips_symbol2data_instruction(), gfc2pips_symbol2entity(), instruction_sequence_p, instruction_to_statement(), instruction_undefined, make_instruction_block(), make_ram(), make_statement(), make_storage_ram(), make_synchronization_none(), MakeZeroOrOneArgCallInst(), message_assert, NIL, pips_user_warning, POP, ram_offset, ram_section, sequence_statements, STATEMENT, STATEMENT_NUMBER_UNDEFINED, STATEMENT_ORDERING_UNDEFINED, statement_undefined, STATIC_AREA_LOCAL_NAME, StaticArea, storage_ram, storage_ram_p, storage_undefined, type_area, and UNKNOWN_RAM_OFFSET.

Referenced by gfc2pips_namespace().

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

◆ gfc2pips_computeAdresses()

void gfc2pips_computeAdresses ( void  )

compute addresses of the stack, heap, dynamic and static areas

Definition at line 4332 of file gfc2pips.c.

4332  {
4333  //check les déclarations, si UNBOUNDED_DIMENSION_NAME dans la liste des dimensions => direction *STACK*
4337 }
void gfc2pips_computeAdressesDynamic(void)
compute the addresses of the entities declared in DynamicArea
Definition: gfc2pips.c:4347
void gfc2pips_computeAdressesStatic(void)
compute the addresses of the entities declared in StaticArea
Definition: gfc2pips.c:4341
void gfc2pips_computeAdressesHeap(void)
compute the addresses of the entities declared in StaticArea
Definition: gfc2pips.c:4353

References gfc2pips_computeAdressesDynamic(), gfc2pips_computeAdressesHeap(), and gfc2pips_computeAdressesStatic().

Referenced by gfc2pips_namespace().

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

◆ gfc2pips_computeAdressesDynamic()

void gfc2pips_computeAdressesDynamic ( void  )

compute the addresses of the entities declared in DynamicArea

Definition at line 4347 of file gfc2pips.c.

4347  {
4349 }
int gfc2pips_computeAdressesOfArea(entity _area)
compute the addresses of the entities declared in the given entity
Definition: gfc2pips.c:4360

References DynamicArea, and gfc2pips_computeAdressesOfArea().

Referenced by gfc2pips_computeAdresses().

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

◆ gfc2pips_computeAdressesHeap()

void gfc2pips_computeAdressesHeap ( void  )

compute the addresses of the entities declared in StaticArea

Definition at line 4353 of file gfc2pips.c.

4353  {
4355 }
entity HeapArea
Definition: area.c:59

References gfc2pips_computeAdressesOfArea(), and HeapArea.

Referenced by gfc2pips_computeAdresses().

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

◆ gfc2pips_computeAdressesOfArea()

int gfc2pips_computeAdressesOfArea ( entity  _area)

compute the addresses of the entities declared in the given entity

Definition at line 4360 of file gfc2pips.c.

4360  {
4361  //compute each and every addresses of the entities in this area. Doesn't handle equivalences.
4362  if(!_area || _area == entity_undefined || entity_type(_area)
4363  == type_undefined || !type_area_p(entity_type(_area))) {
4364  pips_user_warning( "Impossible to compute the given object as an area\n" );
4365  return 0;
4366  }
4367  int offset = 0;
4369  list pcv = gen_copy_seq(_pcv);
4370  gfc2pips_debug(9,"Start \t\t%s %zu element(s) to check\n",entity_local_name(_area),gen_length(pcv));
4371  for (pcv = gen_nreverse(pcv); pcv != NIL; pcv = CDR( pcv )) {
4372  entity e = ENTITY(CAR(pcv));//ifdebug(1)fprintf(stderr,"%s\n",entity_local_name(e));
4375  && ram_section(storage_ram(entity_storage(e))) == _area) {
4376  //we need to skip the variables in commons and commons
4377  gfc2pips_debug(9,"Compute address of %s - offset: %d\n",entity_name(e), offset);
4378 
4380  if(type_tag(entity_type(e)) != is_type_variable || (section != StackArea
4381  && section != StaticArea && section != DynamicArea && section
4382  != HeapArea)) {
4383  pips_user_warning( "We don't know how to do that - skip %s\n",
4384  entity_local_name( e ) );
4385  //size = gfc2pips_computeAdressesOfArea(e);
4386  } else {
4388 
4389  area ca = type_area(entity_type(_area));
4390  area_layout(ca) = gen_nconc(area_layout(ca), CONS( ENTITY, e, NIL ));
4391 
4392  int size;
4393  SizeOfArray(e, &size);
4394  offset += size;
4395  }
4396  }
4397  }
4398 
4399  set_common_to_size(_area, offset);
4400  gfc2pips_debug( 9, "next offset: %d\t\tEnd %s\n", offset, entity_local_name(_area) );
4401  return offset;
4402 }
entity StackArea
Definition: area.c:60
void set_common_to_size(entity a, size_t size)
Definition: declaration.c:1004
static Value offset
Definition: translation.c:283
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
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
code EntityCode(entity e)
this function checks that e has an initial value code.
Definition: entity.c:301
bool SizeOfArray(entity, int *)
This function computes the total size of a variable in bytes, ie.
Definition: size.c:87
#define type_tag(x)
Definition: ri.h:2940
#define code_declarations(x)
Definition: ri.h:784
#define type_area_p(x)
Definition: ri.h:2944
@ is_type_variable
Definition: ri.h:2900

References area_layout, CAR, CDR, code_declarations, CONS, DynamicArea, ENTITY, entity_local_name(), entity_name, entity_storage, entity_type, entity_undefined, EntityCode(), gen_copy_seq(), gen_length(), gen_nconc(), gen_nreverse(), get_current_module_entity(), gfc2pips_debug, HeapArea, is_type_variable, NIL, offset, pips_user_warning, ram_offset, ram_section, set_common_to_size(), SizeOfArray(), StackArea, StaticArea, storage_ram, storage_ram_p, storage_undefined, type_area, type_area_p, type_tag, and type_undefined.

Referenced by gfc2pips_computeAdressesDynamic(), gfc2pips_computeAdressesHeap(), and gfc2pips_computeAdressesStatic().

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

◆ gfc2pips_computeAdressesStatic()

void gfc2pips_computeAdressesStatic ( void  )

compute the addresses of the entities declared in StaticArea

Definition at line 4341 of file gfc2pips.c.

4341  {
4343 }

References gfc2pips_computeAdressesOfArea(), and StaticArea.

Referenced by gfc2pips_computeAdresses().

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

◆ gfc2pips_computeEquiv()

void gfc2pips_computeEquiv ( gfc_equiv *  eq)

FIXME StackArea and HeapArea are entity, not storage... (Mehdi) message_assert("Storage is not STACK\n", entity_storage(e) != StackArea ); message_assert("Storage is not HEAP\n", entity_storage(e) != HeapArea );

Definition at line 4404 of file gfc2pips.c.

4404  {
4405  //equivalences are not correctly implemented in PIPS: they work on entities instead of expressions
4406  //there is no point in creating something wrong
4407  /*
4408  * example:
4409  * EQUIVALENCE (a,c(1)), (b,c(2))
4410  *
4411  * |-----a-----|
4412  * |-----b-----|
4413  * |--c(1)--|--c(2)--|--c(3)--|
4414  * |-------------c------------|-----d-----|
4415  *
4416  * It is impossible to represent with only entities !!!
4417  */
4418 
4419  //ComputeEquivalences();//syntax/equivalence.c
4420  //offset = calculate_offset(eq->expr); enlever le static du fichier
4421 
4422 
4423  for (; eq; eq = eq->next) {
4424  gfc_equiv * save = eq;
4425  gfc_equiv *eq_;
4426  gfc2pips_debug(9,"sequence of equivalences\n");
4427  entity storage_area = entity_undefined;
4428  entity not_moved_entity = entity_undefined;
4429  int offset = 0;
4430  int size = -1;
4431  int not_moved_entity_size;
4432  for (eq_ = eq; eq_; eq_ = eq_->eq) {
4433  //check in same memory storage, not formal, not *STACK* ('cause size unknown)
4434  //take minimum offset
4435  //calculate the difference in offset to the next variable
4436  //set the offset to the variable with the greatest offset
4437  //add if necessary the difference of offset to all variable with an offset greater than the current one (and not equiv too ? or else need to proceed in order of offset ...)
4438  // ?? gfc2pips_expr2int(eq->expr); ??
4439 
4440  message_assert( "expression to compute in equivalence\n", eq_->expr );
4441  gfc2pips_debug(9,"equivalence of %s\n",eq_->expr->symtree->name);
4442 
4443  //we have to absolutely know if it is an element in an array or a single variable
4444  entity e = gfc2pips_check_entity_exists(eq->expr->symtree->name);//this doesn't give an accurate idea for the offset, just an idea about the storage
4445  message_assert( "entity has been founded\n", e != entity_undefined );
4446  if(size == -1)
4447  not_moved_entity = e;
4448 
4449  message_assert( "Storage is defined\n", entity_storage(e)
4450  != storage_undefined );
4451  /* FIXME StackArea and HeapArea are entity, not storage... (Mehdi)
4452  message_assert("Storage is not STACK\n", entity_storage(e) != StackArea );
4453  message_assert("Storage is not HEAP\n", entity_storage(e) != HeapArea );
4454  */
4455  message_assert( "Storage is RAM\n", storage_ram_p(entity_storage(e)) );
4456 
4457  if(!storage_area)
4458  storage_area = ram_section(storage_ram(entity_storage(e)));
4459  message_assert( "Entities are in the same area\n",
4461  == storage_area );
4462 
4463  storage_area = ram_section(storage_ram(entity_storage(e)));
4464 
4465  //expression ex = gfc2pips_expr2expression(eq_->expr);
4466  //fprintf(stderr,"toto %x\n",ex);
4467 
4468  //int offset_of_expression = gfc2pips_offset_of_expression(eq_->expr);
4469  //relative offset from the beginning of the variable (null if simple variable or first value of array)
4470 
4471  // FIXME calculate_offset is static in trans-common.c... (Mehdi)
4472  //int offset_of_expression = calculate_offset( eq_->expr );//gcc/fortran/trans-common.c
4473  int offset_of_expression = 0;
4474 
4475  //int offset_of_expression = ram_offset(storage_ram(entity_storage(e)));
4476  offset_of_expression += ram_offset(storage_ram(entity_storage(e)));
4477 
4478  if(size != -1) {
4479  //gfc2pips_shiftAdressesOfArea( storage_area, not_moved_entity, e, eq_->expr );
4480  } else {
4481  size = 0;
4482  }
4483  }
4484  }
4485 }
entity gfc2pips_check_entity_exists(const char *s)
Definition: gfc2pips.c:1567
float_t save[SIZE][SIZE]
Definition: jacobi.c:9
Pcontrainte eq
element du vecteur colonne du systeme donne par l'analyse
Definition: sc_gram.c:108

References entity_storage, entity_undefined, eq, gfc2pips_check_entity_exists(), gfc2pips_debug, message_assert, offset, ram_offset, ram_section, save, storage_ram, storage_ram_p, and storage_undefined.

+ Here is the call graph for this function:

◆ gfc2pips_dumpSELECT()

list gfc2pips_dumpSELECT ( gfc_code *  c)

ist_of_statements = CONS(STATEMENT, instruction_to_statement( make_assign_instruction( gfc2pips_expr2expression(c->expr), gfc2pips_expr2expression(c->expr2) ) ), NULL );

Definition at line 3399 of file gfc2pips.c.

3399  {
3400  list list_of_statements = NULL;
3401  gfc_case * cp;
3402  gfc_code *d = c->block;
3403  gfc2pips_debug(5,"dump of SELECT\n");
3404 
3405  if(c->here) {
3406  list_of_statements
3413  NULL ) ),
3414  NULL,
3415  NULL,
3416  empty_extensions( ),
3418  NULL ),
3419  list_of_statements);
3420  }
3421 
3422  /*list_of_statements = CONS(STATEMENT,
3423  instruction_to_statement(
3424  make_assign_instruction(
3425  gfc2pips_expr2expression(c->expr),
3426  gfc2pips_expr2expression(c->expr2)
3427  )
3428  ),
3429  NULL
3430  );*/
3431 
3432  statement selectcase = NULL, current_case = NULL, default_stmt = NULL;
3433  for (; d; d = d->block) {
3434  gfc2pips_debug(5,"dump of SELECT CASE\n");
3435  //create a function with low/high returning a test in one go
3436  expression test_expr = expression_undefined;
3437  for (cp = d->ext.case_list; cp; cp = cp->next) {
3438  if(!cp->low && !cp->high) {
3439  // Default test case ... or error if test_expr != expression_undefined ?
3440  pips_assert("We should have default case, but it doesn't seem to be"
3441  "the case, aborting.\n",test_expr == expression_undefined);
3442  break;
3443  }
3444  if(test_expr == expression_undefined) {
3445  test_expr = gfc2pips_buildCaseTest(c->expr, cp);
3446  } else {
3448  test_expr,
3449  gfc2pips_buildCaseTest(c->expr, cp));
3450  }
3451  }
3452 
3453  instruction s_if = gfc2pips_code2instruction(d->next, false);
3454  if(s_if != instruction_undefined) {
3455  statement casetest;
3456  if(test_expr == expression_undefined) {
3457  // Default case
3458  default_stmt = instruction_to_statement(s_if);
3459  } else {
3463  if(current_case != NULL) {
3464  free_statement(test_false(statement_test(current_case)));
3465  test_false(statement_test(current_case)) = casetest;
3466  }
3467  current_case = casetest;
3468  if(!selectcase) {
3469  selectcase = casetest;
3470  }
3471  }
3472 
3473  } else {
3474  pips_user_error( "in SELECT : CASE block is empty ?\n" );
3475  }
3476  }
3477  if(default_stmt) {
3478  if(current_case) {
3479  free_statement(test_false(statement_test(current_case)));
3480  test_false(statement_test(current_case)) = default_stmt;
3481  } else {
3482  selectcase = default_stmt;
3483  }
3484  }
3485 
3486  if(selectcase != NULL) {
3487  list_of_statements = gen_nconc(list_of_statements, CONS( STATEMENT,
3488  selectcase,
3489  NULL ));
3490  }
3491  return list_of_statements;
3492 }
void free_statement(statement p)
Definition: ri.c:2189
expression gfc2pips_buildCaseTest(gfc_expr *test, gfc_case *cp)
Definition: gfc2pips.c:3364
test statement_test(statement)
Get the test of a statement.
Definition: statement.c:1348
#define CONTINUE_FUNCTION_NAME
#define OR_OPERATOR_NAME
#define test_false(x)
Definition: ri.h:2837

References CONS, CONTINUE_FUNCTION_NAME, cp, CreateIntrinsic(), empty_comments, empty_extensions(), expression_undefined, free_statement(), gen_nconc(), gfc2pips_buildCaseTest(), gfc2pips_code2get_label(), gfc2pips_code2instruction(), gfc2pips_debug, instruction_to_statement(), instruction_undefined, make_call(), make_empty_block_statement(), make_instruction_call(), make_statement(), make_synchronization_none(), make_test(), MakeBinaryCall(), OR_OPERATOR_NAME, pips_assert, pips_user_error, STATEMENT, STATEMENT_NUMBER_UNDEFINED, STATEMENT_ORDERING_UNDEFINED, statement_test(), test_false, and test_to_instruction.

Referenced by gfc2pips_code2instruction(), and gfc2pips_code2instruction__TOP().

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

◆ gfc2pips_expr2entity()

entity gfc2pips_expr2entity ( gfc_expr *  expr)

create an entity based on an expression, assume it is used only for incremented variables in loops

Definition at line 4249 of file gfc2pips.c.

4249  {
4250  message_assert( "No expression to dump.", expr );
4251 
4252  if(expr->expr_type == EXPR_VARIABLE) {
4253  message_assert( "No symtree in the expression.", expr->symtree );
4254  message_assert( "No symbol in the expression.", expr->symtree->n.sym );
4255  message_assert( "No name in the expression.", expr->symtree->n.sym->name );
4256  entity
4257  e =
4259  str2upper(gfc2pips_get_safe_name(expr->symtree->n.sym->name)));
4260  entity_type(e) = gfc2pips_symbol2type(expr->symtree->n.sym);
4262  int dynamicOffset = area_size(type_area(entity_type(DynamicArea)));
4264  DynamicArea,
4266  NIL));
4269  return e;
4270  }
4271 
4272  if(expr->expr_type == EXPR_CONSTANT) {
4273  if(expr->ts.type == BT_INTEGER) {
4274  return gfc2pips_int_const2entity(mpz_get_ui(expr->value.integer));
4275  }
4276  if(expr->ts.type == BT_LOGICAL) {
4277  return gfc2pips_logical2entity(expr->value.logical);
4278  }
4279  if(expr->ts.type == BT_REAL) {
4280  return gfc2pips_real2entity(mpfr_get_d(expr->value.real, GFC_RND_MODE));
4281  }
4282  }
4283 
4284  message_assert( "No entity to extract from this expression", 0 );
4285 }
type gfc2pips_symbol2type(gfc_symbol *s)
try to create the PIPS type that would be associated by the PIPS default parser
Definition: gfc2pips.c:1966
entity gfc2pips_real2entity(double r)
dump reals to PIPS entities
Definition: gfc2pips.c:1801
entity gfc2pips_int_const2entity(int n)
translate an integer to a PIPS constant, assume n is positive (or it will not be handled properly)
Definition: gfc2pips.c:1776
int global_current_offset
Definition: gfc2pips.c:98
entity gfc2pips_logical2entity(bool b)
translate a boolean to a PIPS/fortran entity
Definition: gfc2pips.c:1820
#define area_size(x)
Definition: ri.h:544

References area_size, CurrentPackage, DynamicArea, entity_initial, entity_storage, entity_type, FindOrCreateEntity(), get_current_module_entity(), gfc2pips_get_safe_name(), gfc2pips_int_const2entity(), gfc2pips_logical2entity(), gfc2pips_real2entity(), gfc2pips_symbol2type(), global_current_offset, make_ram(), make_storage_ram(), make_value_unknown(), message_assert, NIL, str2upper(), and type_area.

Referenced by gfc2pips_code2instruction_().

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

◆ gfc2pips_expr2expression()

expression gfc2pips_expr2expression ( gfc_expr *  expr)

This is the expression that will be returned

Get 1st arg with a recursive call

Assertion

Unary call

Recursive call, get second expression member

Assertion

Entity corresponding to the Gfortran variable

Args list is in use for array reference

It an array !

This is the full list for the call, we put element beginning with the latest

Firstly, the upper bound

We have an upper bound

Now the lower bound

And the string

substring operator

finally the call is created

Allocatable array array encapsulated in a structure, we have to produce a subscript

we have to use gmp/mpfr function to get the value

Recursive call on implicit cast argument

FIXME : should we really modify GFC IR ????

Definition at line 3837 of file gfc2pips.c.

3837  {
3838  message_assert( "Expr can't be null !\n", expr );
3839  /*
3840  * In GFC
3841  * p->value.op.op is the expression operator
3842  * p->value.op.op1 is the first argument
3843  * p->value.op.op2 is the second one
3844  */
3845 
3846  /* This is the expression that will be returned */
3847  expression returned_expr = expression_undefined;
3848  switch(expr->expr_type) {
3849  case EXPR_OP: {
3850  gfc2pips_debug(5, "Op : this is an (intrinsic) call)\n");
3851  const char *c = NULL;
3852  switch(expr->value.op.op) {
3853  // FIXME Replace all by PIPS #define like MULTIPLY_OPERATOR_NAME
3854  case INTRINSIC_UPLUS:
3855  case INTRINSIC_PLUS:
3856  c = "+";
3857  break;
3858  case INTRINSIC_UMINUS:
3859  case INTRINSIC_MINUS:
3860  c = "-";
3861  break;
3862  case INTRINSIC_TIMES:
3863  c = "*";
3864  break;
3865  case INTRINSIC_DIVIDE:
3866  c = "/";
3867  break;
3868  case INTRINSIC_POWER:
3869  c = "**";
3870  break;
3871  case INTRINSIC_CONCAT:
3872  c = "//";
3873  break;
3874  case INTRINSIC_AND:
3875  c = ".AND.";
3876  break;
3877  case INTRINSIC_OR:
3878  c = ".OR.";
3879  break;
3880  case INTRINSIC_EQV:
3881  c = ".EQV.";
3882  break;
3883  case INTRINSIC_NEQV:
3884  c = ".NEQV.";
3885  break;
3886 
3887  case INTRINSIC_EQ:
3888  case INTRINSIC_EQ_OS:
3889  c = ".EQ.";
3890  break;
3891  case INTRINSIC_NE:
3892  case INTRINSIC_NE_OS:
3893  c = ".NE.";
3894  break;
3895  case INTRINSIC_GT:
3896  case INTRINSIC_GT_OS:
3897  c = ".GT.";
3898  break;
3899  case INTRINSIC_GE:
3900  case INTRINSIC_GE_OS:
3901  c = ".GE.";
3902  break;
3903  case INTRINSIC_LT:
3904  case INTRINSIC_LT_OS:
3905  c = ".LT.";
3906  break;
3907  case INTRINSIC_LE:
3908  case INTRINSIC_LE_OS:
3909  c = ".LE.";
3910  break;
3911 
3912  case INTRINSIC_NOT:
3913  c = ".NOT.";
3914  break;
3915 
3916  case INTRINSIC_PARENTHESES:
3917  returned_expr = gfc2pips_expr2expression(expr->value.op.op1);
3918  break;
3919  default:
3920  pips_user_warning( "intrinsic not yet recognized: %d\n",
3921  (int) expr->value.op.op );
3922  break;
3923  }
3924 
3925  if(c) {
3926  gfc2pips_debug(6, "intrinsic recognized: %s\n",c);
3927  /* Get 1st arg with a recursive call */
3928  expression e1 = gfc2pips_expr2expression(expr->value.op.op1);
3929 
3930  /* Assertion */
3931  if(!e1 || e1 == expression_undefined) {
3932  pips_user_error( "intrinsic( (string)%s ) : 1st arg "
3933  "is null or undefined\n", c);
3934  }
3935  if(expr->value.op.op2 == NULL) {
3936  /* Unary call */
3937  switch(expr->value.op.op) {
3938  case INTRINSIC_UMINUS:
3939  returned_expr
3941  e1);
3942  break;
3943  case INTRINSIC_UPLUS:
3944  returned_expr = e1;
3945  break;
3946  case INTRINSIC_NOT:
3947  returned_expr
3949  break;
3950  default:
3951  pips_user_error( "No second expression member for intrinsic %s\n",
3952  c );
3953  }
3954  } else {
3955  /* Recursive call, get second expression member */
3956  expression e2 = gfc2pips_expr2expression(expr->value.op.op2);
3957 
3958  /* Assertion */
3959  if(!e2 || e2 == expression_undefined) {
3960  pips_user_error( "intrinsic( (string)%s ) : 2nd arg is null or undefined\n", c);
3961  }
3962  returned_expr = MakeBinaryCall(CreateIntrinsic((string)c), e1, e2);
3963  }
3964  }
3965  break;
3966  }
3967  case EXPR_VARIABLE: {
3968  gfc2pips_debug(5, "Variable\n");
3969 
3970  /* Entity corresponding to the Gfortran variable */
3971  entity ent_ref = gfc2pips_symbol2entity(expr->symtree->n.sym);
3972 
3973  /* Args list is in use for array reference */
3974  list args_list = NULL;
3976 
3977  if(strcmp(CurrentPackage, entity_name(ent_ref)) == 0) {
3978  gfc2pips_debug(9,"Variable %s is put in return storage\n",entity_name(ent_ref));
3979  entity_storage(ent_ref) = make_storage_return(ent_ref);
3980  entity_type(ent_ref)
3982  } else if(entity_storage(ent_ref) == storage_undefined) {
3983  gfc2pips_debug(1,"Undefined storage ! Let's put in RAM !! %s\n",
3984  entity_name(ent_ref));
3985 
3986  int dynamicOffset = area_size(type_area(entity_type(DynamicArea)));
3987  entity_storage(ent_ref)
3989  DynamicArea,
3990  dynamicOffset,
3991  NIL));
3993  += area_size(type_area(entity_type(ent_ref)));
3996  = gen_nconc(layout, CONS(entity,ent_ref,NULL));
3997 
3998  }
3999 
4000  if(expr->ref) {
4001  gfc_ref *r = expr->ref;
4002  /*
4003  * We have an array reference, get the indices !
4004  *
4005  * I'm not sure a loop is useful here...
4006  */
4007  while(r) {
4008  switch(r->type) {
4009  case REF_ARRAY: {
4010  /* It an array ! */
4011  gfc2pips_debug(9,"ref array : %s\n",entity_name(ent_ref));
4012  args_list = gfc2pips_array_ref2indices(&r->u.ar);
4013  break;
4014  }
4015  case REF_SUBSTRING: {
4016  gfc2pips_debug(9,"ref substring\n");
4017  expression ref =
4019  NULL)),
4021 
4022  /* This is the full list for the call,
4023  * we put element beginning with the latest
4024  */
4025  list lexpr;
4026 
4027  /* Firstly, the upper bound */
4028  expression upper;
4029  if(r->u.ss.end) {
4030  /* We have an upper bound */
4031  upper = gfc2pips_expr2expression(r->u.ss.end);
4032  } else {
4033  upper
4035  }
4036  lexpr = CONS( EXPRESSION,upper ,NULL );
4037 
4038  /* Now the lower bound */
4039  lexpr
4040  = CONS( EXPRESSION,gfc2pips_expr2expression( r->u.ss.start ),
4041  lexpr
4042  );
4043 
4044  /* And the string */
4045  lexpr = CONS( EXPRESSION,ref,lexpr);
4046 
4047  /* substring operator */
4049 
4050  /* finally the call is created */
4051  s = make_syntax_call(make_call(substr, lexpr));
4052  break;
4053  }
4054  default: {
4055  pips_user_warning("Unable to understand the ref %d\n",
4056  (int)r->type);
4057  break;
4058  }
4059  }
4060  r = r->next;
4061  }
4062  }
4063 
4064  if(syntax_undefined_p(s)) {
4065  /*
4066  * It doesn't seem to be a substring, it an array or a scalar
4067  */
4068  if(entity_allocatable_p(ent_ref)) {
4069  /* Allocatable array array encapsulated in a structure, we have
4070  * to produce a subscript
4071  */
4072  expression allocatable_data = get_allocatable_data_expr(ent_ref);
4073  subscript sub = make_subscript(allocatable_data, args_list);
4074  s = make_syntax_subscript(sub);
4075  } else {
4076  s = make_syntax_reference(make_reference(ent_ref, args_list));
4077  }
4078  }
4079  returned_expr = make_expression(s, normalized_undefined);
4080  break;
4081  }
4082  case EXPR_CONSTANT: {
4083  gfc2pips_debug(5, "Constant expression : %lu %lu\n",(_int)expr,
4084  (_int)expr->ts.type);
4085  switch(expr->ts.type) {
4086  case BT_INTEGER:
4087  returned_expr = gfc2pips_int2expression(gfc2pips_expr2int(expr));
4088  break;
4089  case BT_LOGICAL:
4090  returned_expr = gfc2pips_logical2expression(expr->value.logical);
4091  break;
4092  case BT_REAL: {
4093  /* we have to use gmp/mpfr function to get the value */
4094  double value = mpfr_get_d(expr->value.real, GFC_RND_MODE);
4095  returned_expr = gfc2pips_real2expression(value);
4096  break;
4097  }
4098  case BT_CHARACTER: {
4099  char *char_expr =
4100  gfc2pips_gfc_char_t2string(expr->value.character.string,
4101  expr->value.character.length);
4102  returned_expr = MakeCharacterConstantExpression(char_expr);
4103  }
4104  break;
4105  case BT_COMPLEX: {
4106  expression real, image;
4107  real = gfc2pips_real2expression(mpfr_get_d(expr->value.complex.r,
4108  GFC_RND_MODE));
4109  image = gfc2pips_real2expression(mpfr_get_d(expr->value.complex.i,
4110  GFC_RND_MODE));
4111  returned_expr = MakeComplexConstantExpression(real, image);
4112  break;
4113  }
4114  case BT_HOLLERITH:
4115  pips_user_error( "Hollerith not implemented\n");
4116  break;
4117  default:
4118  pips_user_warning( "type not implemented %d\n", (int) expr->ts.type );
4119  break;
4120 
4121  }
4122  break;
4123  }
4124  case EXPR_FUNCTION: {
4125  gfc2pips_debug(5, "func\n");
4126 
4127  /*
4128  * beware the automatic conversion here, some conversion functions may be
4129  * automatically called here, and we do not want them in the code
4130  * these implicit "cast" have a "__convert_" prefix (gfc internal)
4131  */
4132  if(strncmp(expr->symtree->n.sym->name, "__convert_", strlen("__convert_"))
4133  == 0) {
4134  /* Recursive call on implicit cast argument */
4135  gfc_expr *arg = expr->value.function.actual->expr;
4136  if(arg) {
4137  returned_expr = gfc2pips_expr2expression(arg);
4138  } else {
4139  pips_user_error( "expression null while trying to handle %s\n",
4140  expr->value.function.name );
4141  }
4142  } else {
4143  /*
4144  * functions whose name begin with __ should be used by gfc only
4145  * therefore we put the old name back
4146  */
4147  pips_debug(5,"Func name : %s\n",expr->value.function.name);
4148  if(strncmp(expr->value.function.name, "__", strlen("__")) == 0
4149  || strncmp(expr->value.function.name,
4150  "_gfortran_",
4151  strlen("_gfortran_")) == 0) {
4152  /* FIXME : should we really modify GFC IR ???? */
4153  expr->value.function.name = expr->symtree->n.sym->name;
4154  }
4155 
4156  /*
4157  * actual is the list of actual argument
4158  */
4159  list list_of_arguments = NULL, list_of_arguments_p = NULL;
4160  gfc_actual_arglist *act = expr->value.function.actual;
4161 
4162  if(act) {
4163  do {
4164  /*
4165  * gfc add default parameters for some FORTRAN functions, but it is
4166  * NULL in this case (could break ?)
4167  */
4168  if(act->expr) {
4169  expression ex = gfc2pips_expr2expression(act->expr);
4170  if(ex != expression_undefined) {
4171  if(list_of_arguments_p) {
4172  CDR( list_of_arguments_p) = CONS( EXPRESSION, ex, NIL );
4173  list_of_arguments_p = CDR( list_of_arguments_p );
4174  } else {
4175  list_of_arguments_p = CONS( EXPRESSION, ex, NIL );
4176  }
4177  if(list_of_arguments == NULL) {
4178  list_of_arguments = list_of_arguments_p;
4179  }
4180  }
4181  } else {
4182  break;
4183  }
4184 
4185  } while((act = act->next) != NULL);
4186  }
4187 
4188  string func_name = gfc2pips_get_safe_name(expr->value.function.name);
4189  func_name = str2upper(func_name);
4191 
4192  /*
4193  * This is impossible !
4194  * We must have found functions when converting symbol table
4195  * The only possibility here is a missing intrinsic in PIPS
4196  */
4197  if(entity_initial(e) == value_undefined) {
4198  pips_user_warning("(%d) Entity not declared : '%s' is it a missing"
4199  "intrinsic ??\n",
4200  __LINE__,entity_name( e ) );
4202  }
4203  call call_ = make_call(e, list_of_arguments);
4204 
4205  returned_expr = make_expression(make_syntax_call(call_),
4207  }
4208  break;
4209  }
4210  case EXPR_STRUCTURE:
4211  pips_user_error( "gfc2pips_expr2expression: dump of EXPR_STRUCTURE not "
4212  "yet implemented\n" );
4213  case EXPR_SUBSTRING:
4214  pips_user_error( "gfc2pips_expr2expression: dump of EXPR_SUBSTRING not "
4215  "yet implemented\n" );
4216  case EXPR_NULL:
4217  pips_user_error( "gfc2pips_expr2expression: dump of EXPR_NULL not yet "
4218  "implemented\n" );
4219  case EXPR_ARRAY:
4220  pips_user_error( "gfc2pips_expr2expression: dump of EXPR_ARRAY not yet "
4221  "implemented\n" );
4222  default:
4223  pips_user_error( "gfc2pips_expr2expression: dump not yet implemented, "
4224  "type of gfc_expr not recognized %d\n",
4225  (int) expr->expr_type );
4226  break;
4227  }
4228  return returned_expr;
4229 }
subscript make_subscript(expression a1, list a2)
Definition: ri.c:2327
type copy_type(type p)
TYPE.
Definition: ri.c:2655
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
storage make_storage_return(entity _field_)
Definition: ri.c:2276
syntax make_syntax_subscript(subscript _field_)
Definition: ri.c:2509
syntax make_syntax_reference(reference _field_)
Definition: ri.c:2494
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
expression MakeComplexConstantExpression(expression r, expression i)
Definition: constant.c:397
expression gfc2pips_logical2expression(bool b)
translate a bool to an expression
Definition: gfc2pips.c:1768
expression gfc2pips_real2expression(double r)
translate a real to an expression
Definition: gfc2pips.c:1757
list gfc2pips_array_ref2indices(gfc_array_ref *ar)
convert a list of indices from gfc to PIPS, assume there is no range (dump only the min range element...
Definition: gfc2pips.c:2032
char * gfc2pips_gfc_char_t2string(gfc_char_t *c, int length)
translate a string from a table of integers in gfc to one of chars in PIPS, escape all ' in the strin...
Definition: gfc2pips.c:1832
entity gfc2pips_main_entity
Definition: gfc2pips.c:107
int gfc2pips_expr2int(gfc_expr *expr)
Definition: gfc2pips.c:4238
#define SUBSTRING_FUNCTION_NAME
#define UNARY_MINUS_OPERATOR_NAME
#define NOT_OPERATOR_NAME
expression get_allocatable_data_expr(entity e)
This function produce an expression that is an access to the array inside the allocatable structure.
Definition: allocatable.c:141
bool entity_allocatable_p(entity e)
Check if an entity is an allocatable.
Definition: allocatable.c:72
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
#define functional_result(x)
Definition: ri.h:1444
#define type_functional(x)
Definition: ri.h:2952
#define syntax_undefined_p(x)
Definition: ri.h:2677
#define syntax_undefined
Definition: ri.h:2676
code taken from http://fast-edge.googlecode.com and adapted to c99
Definition: erode_dilate.c:33
expression MakeFortranUnaryCall(entity op, expression e1)
Definition: expression.c:519

References area_layout, area_size, CDR, CONS, copy_type(), CreateIntrinsic(), CurrentPackage, DynamicArea, entity_allocatable_p(), entity_initial, entity_intrinsic(), entity_name, entity_storage, entity_type, EXPRESSION, expression_undefined, FindOrCreateEntity(), functional_result, gen_nconc(), get_allocatable_data_expr(), get_current_module_entity(), gfc2pips_array_ref2indices(), gfc2pips_debug, gfc2pips_expr2expression(), gfc2pips_expr2int(), gfc2pips_get_safe_name(), gfc2pips_gfc_char_t2string(), gfc2pips_int2expression(), gfc2pips_logical2expression(), gfc2pips_main_entity, gfc2pips_real2expression(), gfc2pips_symbol2entity(), is_value_intrinsic, make_call(), make_expression(), make_ram(), make_reference(), make_storage_ram(), make_storage_return(), make_subscript(), make_syntax_call(), make_syntax_reference(), make_syntax_subscript(), make_value(), MakeBinaryCall(), MakeCharacterConstantExpression(), MakeComplexConstantExpression(), MakeFortranUnaryCall(), MakeNullaryCall(), message_assert, NIL, normalized_undefined, NOT_OPERATOR_NAME, pips_debug, pips_user_error, pips_user_warning, ref, storage_undefined, str2upper(), SUBSTRING_FUNCTION_NAME, syntax_undefined, syntax_undefined_p, TOP_LEVEL_MODULE_NAME, type_area, type_functional, UNARY_MINUS_OPERATOR_NAME, UNBOUNDED_DIMENSION_NAME, and value_undefined.

Referenced by gfc2pips_arglist2arglist(), gfc2pips_array_ref2indices(), gfc2pips_buildCaseTest(), gfc2pips_code2instruction_(), gfc2pips_expr2expression(), gfc2pips_exprIO(), gfc2pips_get_list_of_dimensions2(), gfc2pips_symbol2data_instruction(), and gfc2pips_vars_().

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

◆ gfc2pips_expr2int()

int gfc2pips_expr2int ( gfc_expr *  expr)

Definition at line 4238 of file gfc2pips.c.

4238  {
4239  return mpz_get_si(expr->value.integer);
4240 }

Referenced by gfc2pips_expr2expression(), and gfc2pips_symbol2sizeArray().

+ Here is the caller graph for this function:

◆ gfc2pips_exprIO()

list gfc2pips_exprIO ( char *  s,
gfc_expr *  e,
list  l 
)

Definition at line 4309 of file gfc2pips.c.

4309  {
4310  return CONS( EXPRESSION,
4313 }

References CONS, EXPRESSION, gfc2pips_expr2expression(), and MakeCharacterConstantExpression().

Referenced by gfc2pips_code2instruction_().

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

◆ gfc2pips_exprIO2()

list gfc2pips_exprIO2 ( char *  s,
int  e,
list  l 
)

Definition at line 4314 of file gfc2pips.c.

4314  {
4315  return CONS( EXPRESSION,
4318 }

References CONS, EXPRESSION, gfc2pips_int2label(), MakeCharacterConstantExpression(), and MakeNullaryCall().

Referenced by gfc2pips_code2instruction_().

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

◆ gfc2pips_exprIO3()

list gfc2pips_exprIO3 ( char *  s,
string  e,
list  l 
)

Definition at line 4319 of file gfc2pips.c.

4319  {
4320  return CONS( EXPRESSION,
4322  CONS( EXPRESSION,
4324  gfc2pips_get_safe_name( e ) ) ),
4325  l ) );
4326 }

References CONS, CurrentPackage, EXPRESSION, FindOrCreateEntity(), gfc2pips_get_safe_name(), MakeCharacterConstantExpression(), and MakeNullaryCall().

Referenced by gfc2pips_code2instruction_().

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

◆ gfc2pips_exprIsVariable()

bool gfc2pips_exprIsVariable ( gfc_expr *  expr)

Definition at line 4242 of file gfc2pips.c.

4242  {
4243  return expr && expr->expr_type == EXPR_VARIABLE;
4244 }

◆ gfc2pips_generate_parameters_list()

void gfc2pips_generate_parameters_list ( list  parameters)

replace a list of entities by a list of parameters to those entities

Definition at line 896 of file gfc2pips.c.

896  {
897  int formal_offset = 1;
898  while(parameters) {
899  entity ent = parameters->car.e;
900  gfc2pips_debug(8, "parameter founded: %s\n\t\tindice %d\n", entity_local_name(ent), formal_offset );
902  formal_offset));
903  //entity_initial(ent) = make_value_unknown();
904  type formal_param_type = entity_type(ent);//is the format ok ?
905  parameters->car.e = make_parameter(formal_param_type,
907  make_dummy_identifier(ent));
908  formal_offset++;
909  POP( parameters );
910  }
911 }
dummy make_dummy_identifier(entity _field_)
Definition: ri.c:620
parameter make_parameter(type a1, mode a2, dummy a3)
Definition: ri.c:1495
mode make_mode_reference(void)
Definition: ri.c:1356
storage make_storage_formal(formal _field_)
Definition: ri.c:2282
formal make_formal(entity a1, intptr_t a2)
Definition: ri.c:1067
#define formal_offset(x)
Definition: ri.h:1408

References cons::car, gen_chunk::e, entity_local_name(), entity_storage, entity_type, formal_offset, gfc2pips_debug, gfc2pips_main_entity, make_dummy_identifier(), make_formal(), make_mode_reference(), make_parameter(), make_storage_formal(), and POP.

Referenced by gfc2pips_parameters().

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

◆ gfc2pips_get_commons()

bool gfc2pips_get_commons ( gfc_namespace __attribute__((__unused__)) *  ns,
gfc_symtree __attribute__((__unused__)) *  st 
)

test function to know if it is a common, always true because the tree is completely separated therefore the function using it only create a list

Definition at line 1477 of file gfc2pips.c.

1478  {
1479  return true;
1480 }

Referenced by gfc2pips_namespace().

+ Here is the caller graph for this function:

◆ gfc2pips_get_data_vars()

list gfc2pips_get_data_vars ( gfc_namespace *  ns)

return a list of elements needing a DATA statement

Definition at line 1244 of file gfc2pips.c.

1244  {
1245  return getSymbolBy(ns, ns->sym_root, gfc2pips_test_data);
1246 }
bool gfc2pips_test_data(gfc_namespace __attribute__((__unused__)) *ns, gfc_symtree *st)
test if there is a value to stock
Definition: gfc2pips.c:1457

References getSymbolBy(), and gfc2pips_test_data().

Referenced by gfc2pips_code2instruction__TOP().

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

◆ gfc2pips_get_extern_entities()

list gfc2pips_get_extern_entities ( gfc_namespace *  ns)

build a list of externals entities

Definition at line 1219 of file gfc2pips.c.

1219  {
1220  list list_of_extern, list_of_extern_p;
1221  list_of_extern_p = list_of_extern = getSymbolBy(ns,
1222  ns->sym_root,
1224  while(list_of_extern_p) {
1225  gfc_symtree* curr = list_of_extern_p->car.e;
1226  entity e = gfc2pips_symbol2entity(curr->n.sym);
1227 
1228  // FIXME, is there other extern that calls ???
1230 
1231  if(entity_storage(e) == storage_undefined) {
1232  gfc2pips_debug(2,"Storage rom !! %s %d\n",entity_name(e),__LINE__);
1234  }
1235 
1236  list_of_extern_p->car.e = e;
1237  POP( list_of_extern_p );
1238  }
1239  return list_of_extern;
1240 }
bool gfc2pips_test_extern(gfc_namespace __attribute__((__unused__)) *ns, gfc_symtree *st)
test if it is an external function
Definition: gfc2pips.c:1419

References cons::car, gen_chunk::e, entity_name, entity_storage, getSymbolBy(), gfc2pips_add_to_callees(), gfc2pips_debug, gfc2pips_symbol2entity(), gfc2pips_test_extern(), make_storage_rom(), POP, and storage_undefined.

Referenced by gfc2pips_namespace().

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

◆ gfc2pips_get_incommon()

bool gfc2pips_get_incommon ( gfc_namespace __attribute__((__unused__)) *  ns,
gfc_symtree __attribute__((__unused__)) *  st 
)

Definition at line 1481 of file gfc2pips.c.

1482  {
1483  if(!st || !st->n.sym)
1484  return false;
1485  return st->n.sym->attr.in_common;
1486 }

Referenced by gfc2pips_namespace().

+ Here is the caller graph for this function:

◆ gfc2pips_get_list_of_dimensions()

list gfc2pips_get_list_of_dimensions ( gfc_symtree *  st)

build a list - if any - of dimension elements from the gfc_symtree given

Definition at line 1257 of file gfc2pips.c.

1257  {
1258  if(st) {
1259  return gfc2pips_get_list_of_dimensions2(st->n.sym);
1260  } else {
1261  return NULL;
1262  }
1263 }
list gfc2pips_get_list_of_dimensions2(gfc_symbol *s)
build a list - if any - of dimension elements from the gfc_symbol given
Definition: gfc2pips.c:1267

References gfc2pips_get_list_of_dimensions2().

+ Here is the call graph for this function:

◆ gfc2pips_get_list_of_dimensions2()

list gfc2pips_get_list_of_dimensions2 ( gfc_symbol *  s)

build a list - if any - of dimension elements from the gfc_symbol given

Definition at line 1267 of file gfc2pips.c.

1267  {
1268  list list_of_dimensions = NULL;
1269  int i = 0, j = 0;
1270 
1271  pips_assert("Allocatable should have been handled before !",
1272  !s->attr.allocatable);
1273 
1274  if(s && s->attr.dimension) {
1275  gfc_array_spec *as = s->as;
1276  const char *c;
1277  gfc2pips_debug(4, "%s is an array\n",s->name);
1278  if(as != NULL && as->rank != 0) {
1279  //according to the type of array we create different types of dimensions parameters
1280  switch(as->type) {
1281  case AS_EXPLICIT:
1282  c = strdup("AS_EXPLICIT");
1283  //create the list of dimensions
1284  i = as->rank - 1;
1285  do {
1286  //check lower ou upper n'est pas une variable dont la valeur est inconnue
1287  list_of_dimensions
1289  gfc2pips_expr2expression(as->upper[i]),
1290  NIL),
1291  list_of_dimensions);
1292  } while(--i >= j);
1293  break;
1294  case AS_DEFERRED://beware allocatable !!!
1295  c = strdup("AS_DEFERRED");
1296  i = as->rank - 1;
1297  do {
1298  list_of_dimensions
1301  NIL),
1302  list_of_dimensions);
1303  } while(--i >= j);
1304  break;
1305  //AS_ASSUMED_... means information come from a dummy argument and the property is inherited from the call
1306  case AS_ASSUMED_SIZE://means only the last set of dimensions is unknown
1307  j = 1;
1308  c = strdup("AS_ASSUMED_SIZE");
1309  //create the list of dimensions
1310  i = as->rank - 1;
1311  while(i > j) {
1312  //check lower ou upper n'est pas une variable dont la valeur est inconnue
1313  list_of_dimensions
1315  gfc2pips_expr2expression(as->upper[i]),
1316  NIL),
1317  list_of_dimensions);
1318  i--;
1319  }
1320 
1321  list_of_dimensions
1324  NIL),
1325  list_of_dimensions);
1326  break;
1327  case AS_ASSUMED_SHAPE:
1328  c = strdup("AS_ASSUMED_SHAPE");
1329  break;
1330  default:
1331  gfc_internal_error("show_array_spec(): Unhandled array shape "
1332  "type.");
1333  }
1334  }
1335  gfc2pips_debug(4, "%zu dimensions detected for %s\n",gen_length(list_of_dimensions),s->name);
1336  }
1337 
1338  return list_of_dimensions;
1339 }
dimension make_dimension(expression a1, expression a2, list a3)
Definition: ri.c:565

References CreateIntrinsic(), gen_cons(), gen_length(), gfc2pips_debug, gfc2pips_expr2expression(), int_to_expression(), make_dimension(), MakeNullaryCall(), NIL, pips_assert, strdup(), and UNBOUNDED_DIMENSION_NAME.

Referenced by gfc2pips_get_list_of_dimensions(), and gfc2pips_symbol2type().

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

◆ gfc2pips_get_safe_name()

char* gfc2pips_get_safe_name ( const char *  str)

gfc replace some functions by an homemade one, we check and return a copy of the original one if it is the case

Definition at line 1720 of file gfc2pips.c.

1720  {
1721  if(strncmp_("_gfortran_exit_", str, strlen("_gfortran_exit_")) == 0) {
1722  return strdup("exit");
1723  } else if(strncmp_("_gfortran_float", str, strlen("_gfortran_float")) == 0) {
1724  return strdup("FLOAT");
1725  } else {
1726  return strdup(str);
1727  }
1728 }
int strncmp_(__const char *__s1, __const char *__s2, size_t __n)
compare the strings in upper case mode

References strdup(), and strncmp_().

Referenced by gfc2pips_char2entity(), gfc2pips_code2instruction_(), gfc2pips_expr2entity(), gfc2pips_expr2expression(), gfc2pips_exprIO3(), gfc2pips_getbasic(), gfc2pips_symbol2entity(), gfc2pips_symbol2top_entity(), and gfc2pips_vars_().

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

◆ gfc2pips_get_save()

list gfc2pips_get_save ( gfc_namespace *  ns)

return a list of SAVE elements

Definition at line 1250 of file gfc2pips.c.

1250  {
1251  return getSymbolBy(ns, ns->sym_root, gfc2pips_test_save);
1252 }
bool gfc2pips_test_save(gfc_namespace __attribute__((__unused__)) *ns, gfc_symtree *st)
test if there is a SAVE to do
Definition: gfc2pips.c:1467

References getSymbolBy(), and gfc2pips_test_save().

Referenced by gfc2pips_code2instruction__TOP().

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

◆ gfc2pips_getbasic()

basic gfc2pips_getbasic ( gfc_symbol *  s)

Allocatable handling : we convert it to a structure

Definition at line 1909 of file gfc2pips.c.

1909  {
1910  basic b = basic_undefined;
1911  if(s->attr.pointer) {
1913  } else {
1914  int size = gfc2pips_symbol2size(s);
1915  switch(s->ts.type) {
1916  case BT_INTEGER:
1917  b = make_basic_int(size);
1918  break;
1919  case BT_REAL:
1920  b = make_basic_float(size);
1921  break;
1922  case BT_COMPLEX:
1923  b = make_basic_complex(2 * size);
1924  break;
1925  case BT_LOGICAL:
1926  b = make_basic_logical(size);
1927  break;
1928  case BT_CHARACTER:
1930  break;
1931  case BT_UNKNOWN:
1932  gfc2pips_debug( 5, "Type unknown\n" );
1933  b = basic_undefined;
1934  break;
1935  case BT_DERIVED:
1936  pips_user_error( "User-def types are not implemented yet\n" );
1937  b = basic_undefined;
1938  break;
1939  case BT_PROCEDURE:
1940  case BT_HOLLERITH:
1941  case BT_VOID:
1942  default:
1943  pips_user_error( "An error occurred in the type to type translation: impossible to translate the symbol.\n" );
1944  b = basic_undefined;
1945  //return make_type_unknown();
1946  }
1947  }
1948 
1949  if(s->attr.allocatable) {
1950  /* Allocatable handling : we convert it to a structure */
1951  char* name = str2upper(gfc2pips_get_safe_name(s->name));
1952  entity e = find_or_create_allocatable_struct(b, name, s->as->rank);
1953  b = make_basic_derived(e);
1954  }
1955 
1956  if(b != basic_undefined)
1957  gfc2pips_debug(5, "Basic type is : %d\n",basic_tag(b));
1958  else
1959  gfc2pips_debug(5, "Basic type is undefined\n");
1960  return b;
1961 }
basic make_basic_complex(intptr_t _field_)
Definition: ri.c:170
basic make_basic_derived(entity _field_)
Definition: ri.c:182
value make_value_constant(constant _field_)
Definition: ri.c:2841
basic make_basic_int(intptr_t _field_)
Definition: ri.c:158
basic make_basic_pointer(type _field_)
Definition: ri.c:179
constant make_constant_int(intptr_t _field_)
Definition: ri.c:409
basic make_basic_float(intptr_t _field_)
Definition: ri.c:161
basic make_basic_logical(intptr_t _field_)
Definition: ri.c:164
basic make_basic_string(value _field_)
Definition: ri.c:173
int gfc2pips_symbol2size(gfc_symbol *s)
return the size of an elementary element: REAL*16 A CHARACTER*17 B
Definition: gfc2pips.c:1990
entity find_or_create_allocatable_struct(basic b, string name, int ndim)
This function try to find the allocatable structure corresponding to the number of dimensions request...
Definition: allocatable.c:97
#define basic_tag(x)
Definition: ri.h:613
#define basic_undefined
Definition: ri.h:556

References basic_tag, basic_undefined, find_or_create_allocatable_struct(), gfc2pips_debug, gfc2pips_get_safe_name(), gfc2pips_symbol2size(), make_basic_complex(), make_basic_derived(), make_basic_float(), make_basic_int(), make_basic_logical(), make_basic_pointer(), make_basic_string(), make_constant_int(), make_value_constant(), pips_user_error, str2upper(), and type_undefined.

Referenced by gfc2pips_symbol2entity(), and gfc2pips_symbol2type().

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

◆ gfc2pips_getTypesDeclared()

void gfc2pips_getTypesDeclared ( gfc_namespace *  ns)

ecl_spec_list TK_SEMICOLON struct_decl_list { c_parser_context ycontext = stack_head(ContextStack); c_parser_context ycontext = GetContext(); Create the struct member entity with unique name, the name of the struct/union is added to the member name prefix * string istr = i2a(derived_counter++); string s = strdup(concatenate("PIPS_MEMBER_",istr,NULL)); string derived = code_decls_text((code) stack_head(StructNameStack)); entity ent = CreateEntityFromLocalNameAndPrefix(s,strdup(concatenate(derived, MEMBER_SEP_STRING,NULL)), is_external); gfc2pips_debug(5,"Current derived name: %s\n",derived); gfc2pips_debug(5,"Member name: %s\n",entity_name(ent)); entity_storage(ent) = make_storage_rom(); entity_type(ent) = c_parser_context_type(ycontext); free(s);

Temporally put the list of struct/union entities defined in $1 to initial value of ent. FI: where is it retrieved? in TakeDerivedEntities()? * entity_initial(ent) = (value) $1;

$$ = CONS(ENTITY,ent,$3);

stack_pop(ContextStack); PopContext(); }

how_typespec (&c->ts); if(c->attr.pointer) fputs(" POINTER", dumpfile); if(c->attr.dimension) fputs(" DIMENSION", dumpfile); fputc(' ', dumpfile); show_array_spec(c->as); if(c->attr.access) fprintf(dumpfile, " %s", gfc_code2string(access_types, c->attr.access) ); fputc (')', dumpfile); if (c->next != NULL) fputc (' ', dumpfile);

cope

nt = MakeDerivedEntity( current_symtree->n.sym->name, list_of_components, current_symtree->n.sym->attr.external, is_type_struct );

ariable v = make_variable(make_basic_derived(ent),NIL,NIL); list le = TakeDerivedEntities(list_of_components); variables = gen_cons( gen_nconc(le,CONS(ENTITY,ent,NIL)), variables );

get the list of entities in the struct entity ent = CreateEntityFromLocalNameAndPrefix( s->ts.derived->name, STRUCT_PREFIX, s->attr.external ); entity_type(ent) = make_type_struct( members ); return MakeTypeVariable( make_basic_derived(ent), NULL );

Definition at line 1119 of file gfc2pips.c.

1119  {
1120  if(ns) {
1121  list variables_p = gen_nreverse(getSymbolBy(ns,
1122  ns->sym_root,
1124 
1125  while(variables_p) {
1126  type Type = type_undefined;
1127  //create entities here
1128  gfc_symtree *current_symtree = (gfc_symtree*)variables_p->car.e;
1129 
1130  list list_of_components = NULL;
1131 
1132  list members = NULL;
1133  gfc_component *c;
1134  gfc2pips_debug(9,"start list of elements in the structure %s\n",current_symtree->name);
1135  for (c = current_symtree->n.sym->components; c; c = c->next) {
1136  /*decl_spec_list TK_SEMICOLON struct_decl_list
1137  {
1138  //c_parser_context ycontext = stack_head(ContextStack);
1139  c_parser_context ycontext = GetContext();
1140  * Create the struct member entity with unique name, the name of the
1141  * struct/union is added to the member name prefix *
1142  string istr = i2a(derived_counter++);
1143  string s = strdup(concatenate("PIPS_MEMBER_",istr,NULL));
1144  string derived = code_decls_text((code) stack_head(StructNameStack));
1145  entity ent = CreateEntityFromLocalNameAndPrefix(s,strdup(concatenate(derived,
1146  MEMBER_SEP_STRING,NULL)),
1147  is_external);
1148  gfc2pips_debug(5,"Current derived name: %s\n",derived);
1149  gfc2pips_debug(5,"Member name: %s\n",entity_name(ent));
1150  entity_storage(ent) = make_storage_rom();
1151  entity_type(ent) = c_parser_context_type(ycontext);
1152  free(s);
1153 
1154  * Temporally put the list of struct/union entities defined in $1 to
1155  * initial value of ent. FI: where is it retrieved? in TakeDerivedEntities()? *
1156  entity_initial(ent) = (value) $1;
1157 
1158  $$ = CONS(ENTITY,ent,$3);
1159 
1160  //stack_pop(ContextStack);
1161  PopContext();
1162  }*/
1163 
1164  fprintf(stdout, "%s\n", c->name);
1165  /*show_typespec (&c->ts);
1166  if(c->attr.pointer) fputs(" POINTER", dumpfile);
1167  if(c->attr.dimension) fputs(" DIMENSION", dumpfile);
1168  fputc(' ', dumpfile);
1169  show_array_spec(c->as);
1170  if(c->attr.access) fprintf(dumpfile, " %s", gfc_code2string(access_types, c->attr.access) );
1171  fputc (')', dumpfile);
1172  if (c->next != NULL) fputc (' ', dumpfile);*/
1173  }
1174  entity ent;
1175  if(current_symtree->n.sym->attr.external) {
1176  char * local_name;
1177  asprintf(&local_name,STRUCT_PREFIX "%s",current_symtree->name);
1179  free(local_name);
1180  } else {
1181  char * local_name;
1182  asprintf(&local_name,STRUCT_PREFIX "%s"/*scope*/,current_symtree->name);
1184  free(local_name);
1185  /*ent = MakeDerivedEntity(
1186  current_symtree->n.sym->name,
1187  list_of_components,
1188  current_symtree->n.sym->attr.external,
1189  is_type_struct
1190  );*/
1191  //entity_basic(ent) = make_basic_typedef(ent);
1192  entity_type(ent) = make_type_struct(members);
1193  }
1194 
1195  /*variable v = make_variable(make_basic_derived(ent),NIL,NIL);
1196  list le = TakeDerivedEntities(list_of_components);
1197  variables = gen_cons( gen_nconc(le,CONS(ENTITY,ent,NIL)), variables );
1198 
1199  //get the list of entities in the struct
1200  entity ent = CreateEntityFromLocalNameAndPrefix(
1201  s->ts.derived->name,
1202  STRUCT_PREFIX,
1203  s->attr.external
1204  );
1205  entity_type(ent) = make_type_struct( members );
1206  return MakeTypeVariable(
1207  make_basic_derived(ent),
1208  NULL
1209  );*/
1210 
1211  POP( variables_p );
1212  }
1213  }
1214 }
type make_type_struct(list _field_)
Definition: ri.c:2730
const char * local_name(const char *s)
Does not take care of block scopes and returns a pointer.
Definition: entity_names.c:221
bool gfc2pips_test_derived(gfc_namespace __attribute__((__unused__)) *ns, gfc_symtree *st)
Definition: gfc2pips.c:1407
#define asprintf
Definition: misc-local.h:225
#define STRUCT_PREFIX
Definition: naming-local.h:56

References asprintf, cons::car, CurrentPackage, gen_chunk::e, entity_type, FindOrCreateEntity(), fprintf(), free(), gen_nreverse(), getSymbolBy(), gfc2pips_debug, gfc2pips_test_derived(), local_name(), make_type_struct(), POP, STRUCT_PREFIX, and type_undefined.

Referenced by gfc2pips_namespace().

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

◆ gfc2pips_gfc_char_t2string()

char* gfc2pips_gfc_char_t2string ( gfc_char_t *  c,
int  length 
)

translate a string from a table of integers in gfc to one of chars in PIPS, escape all ' in the string

Parameters
cthe table of integers in gfc
nbthe size of the table

The function only calculate the number of ' to escape and give the information to gfc2pips_gfc_char_t2string_ TODO: optimize to know if we should put " or ' quotes

Definition at line 1832 of file gfc2pips.c.

1832  {
1833  if(length) {
1834  gfc_char_t *p = c;
1835  while(*p) {
1836  if(*p == '\'')
1837  length++;
1838  p++;
1839  }
1840  return gfc2pips_gfc_char_t2string_(c, length);
1841  } else {
1842  return strdup("");
1843  }
1844 }
char * gfc2pips_gfc_char_t2string_(gfc_char_t *c, int nb)
translate a string from a table of integers in gfc to one of chars in PIPS, escape all ' in the strin...
Definition: gfc2pips.c:1853

References gfc2pips_gfc_char_t2string_(), and strdup().

Referenced by gfc2pips_expr2expression().

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

◆ gfc2pips_gfc_char_t2string2()

char* gfc2pips_gfc_char_t2string2 ( gfc_char_t *  c)

translate the <nb> first elements of from a wide integer representation to a char representation

Parameters
cthe gfc integer table

Definition at line 1875 of file gfc2pips.c.

1875  {
1876  gfc_char_t *p = c;
1877  char *s = NULL;
1878  int nb, i;
1879  //fprintf(stderr,"try gfc2pips_gfc_char_t2string2");
1880 
1881  nb = 0;
1882  while(p && *p && nb < 132) {
1883  nb++;
1884  p++;
1885  }
1886  p = c;
1887  //fprintf(stderr,"continue gfc2pips_gfc_char_t2string2 %d\n",nb);
1888 
1889  if(nb) {
1890 
1891  s = malloc(sizeof(char) * (nb + 1));
1892  i = 0;
1893  while(i < nb && *p) {
1894  //fprintf(stderr,"i:%d *p:(%d=%c)\n",i,*p,*p);
1895  s[i++] = *p;
1896  p++;
1897  }
1898  s[i] = '\0';
1899  //fprintf(stderr,"end gfc2pips_gfc_char_t2string2");
1900  return s;
1901  } else {
1902  return NULL;
1903  }
1904 }
void * malloc(YYSIZE_T)

References malloc().

Referenced by gfc2pips_push_comment().

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

◆ gfc2pips_gfc_char_t2string_()

char* gfc2pips_gfc_char_t2string_ ( gfc_char_t *  c,
int  nb 
)

translate a string from a table of integers in gfc to one of chars in PIPS, escape all ' in the string

Parameters
cthe table of integers in gfc
nbthe size of the table

Stupidly add ' before ' and add ' at the beginning and the end of the string

Definition at line 1853 of file gfc2pips.c.

1853  {
1854  char *s = malloc(sizeof(char) * (nb + 1 + 2));
1855  gfc_char_t *p = c;
1856  int i = 1;
1857  s[0] = '\'';
1858  while(i <= nb) {
1859  if(*p == '\'') {
1860  s[i++] = '\'';
1861  }
1862  s[i++] = *p;
1863  p++;
1864 
1865  }
1866  s[i++] = '\'';
1867  s[i] = '\0';
1868  return s;
1869 }

References malloc().

Referenced by gfc2pips_gfc_char_t2string().

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

◆ gfc2pips_int2dimension()

dimension gfc2pips_int2dimension ( int  n)

create a <dimension> from the integer value given

Definition at line 1736 of file gfc2pips.c.

1736  {
1739  NIL);
1740 }

References gfc2pips_int2expression(), int_to_expression(), make_dimension(), and NIL.

+ Here is the call graph for this function:

◆ gfc2pips_int2expression()

expression gfc2pips_int2expression ( int  n)

translate a int to an expression

Definition at line 1745 of file gfc2pips.c.

1745  {
1746  //return int_expr(n);
1747  if(n < 0) {
1750  } else {
1752  }
1753 }
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165

References CreateIntrinsic(), entity_to_expression(), gfc2pips_int_const2entity(), and MakeFortranUnaryCall().

Referenced by gfc2pips_code2instruction_(), gfc2pips_expr2expression(), gfc2pips_int2dimension(), gfc2pips_make_zero_for_symbol(), gfc2pips_reduce_repeated_values(), and gfc2pips_symbol2data_instruction().

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

◆ gfc2pips_int2label()

entity gfc2pips_int2label ( int  n)

dump an integer to a PIPS label entity

Parameters
nthe value of the integer

Definition at line 1785 of file gfc2pips.c.

1785  {
1786  //return make_loop_label(n,concatenate(TOP_LEVEL_MODULE_NAME,MODULE_SEP_STRING,LABEL_PREFIX,NULL));
1787  char str[60];
1788  sprintf(str, LABEL_PREFIX "%d", n);//fprintf(stderr,"new label: %s %s %s %s %d\n",str,TOP_LEVEL_MODULE_NAME,MODULE_SEP_STRING,LABEL_PREFIX,n);
1789  return make_label(CurrentPackage,str);
1790 }
#define LABEL_PREFIX
Definition: naming-local.h:31
entity make_label(const char *module_name, const char *local_name)
Definition: entity.c:308

References CurrentPackage, LABEL_PREFIX, and make_label().

Referenced by gfc2pips_code2get_label(), gfc2pips_code2get_label2(), gfc2pips_code2get_label3(), gfc2pips_code2get_label4(), gfc2pips_code2instruction(), gfc2pips_code2instruction_(), gfc2pips_code2instruction__TOP(), and gfc2pips_exprIO2().

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

◆ gfc2pips_int_const2entity()

entity gfc2pips_int_const2entity ( int  n)

translate an integer to a PIPS constant, assume n is positive (or it will not be handled properly)

Definition at line 1776 of file gfc2pips.c.

1776  {
1777  char str[30];
1778  sprintf(str, "%d", n);
1779  return MakeConstant(str, is_basic_int);
1780 }
entity MakeConstant(string name, tag bt)
Make a Fortran constant.
Definition: constant.c:351
@ is_basic_int
Definition: ri.h:571

References is_basic_int, and MakeConstant().

Referenced by gfc2pips_expr2entity(), and gfc2pips_int2expression().

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

◆ gfc2pips_logical2entity()

entity gfc2pips_logical2entity ( bool  b)

translate a boolean to a PIPS/fortran entity

Definition at line 1820 of file gfc2pips.c.

1820  {
1821  return MakeConstant(b ? ".TRUE." : ".FALSE.", is_basic_logical);
1822 }
@ is_basic_logical
Definition: ri.h:573

References is_basic_logical, and MakeConstant().

Referenced by gfc2pips_expr2entity(), and gfc2pips_logical2expression().

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

◆ gfc2pips_logical2expression()

expression gfc2pips_logical2expression ( bool  b)

translate a bool to an expression

Definition at line 1768 of file gfc2pips.c.

1768  {
1769  //return int_expr(b!=false);
1771 }

References entity_to_expression(), and gfc2pips_logical2entity().

Referenced by gfc2pips_expr2expression().

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

◆ gfc2pips_make_zero_for_symbol()

expression gfc2pips_make_zero_for_symbol ( gfc_symbol *  sym)

Definition at line 3646 of file gfc2pips.c.

3646  {
3647  int size_of_unit = gfc2pips_symbol2size(sym);
3648  if(sym->ts.type == BT_CHARACTER)
3649  size_of_unit = 1;
3650  if(sym->ts.type == BT_COMPLEX) {
3653  } else if(sym->ts.type == BT_REAL) {
3654  return gfc2pips_real2expression(0.);
3655  } else {
3656  return gfc2pips_int2expression(0);
3657  }
3658 }

References gfc2pips_int2expression(), gfc2pips_real2expression(), gfc2pips_symbol2size(), and MakeComplexConstantExpression().

Referenced by gfc2pips_symbol2data_instruction().

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

◆ gfc2pips_namespace()

void gfc2pips_namespace ( gfc_namespace *  ns)

Entry point for gfc2pips translation This will be called each time the parser encounter subroutine, function, or program.

Debug level

pips main initialization

No common has yet been declared

Generic PIPS areas are created for memory allocation.

declare variables

Filter variables so that we keep only local variable

Get declarations

Add variables to declaration

Fix Storage for declarations

loop over the orphan list and remove current element from it

Create an entity for current element

omplete_list_of_entities_p = complete_list_of_entities; while( complete_list_of_entities_p ){ entity ent = complete_list_of_entities_p->car.e; if( ent ){ gfc2pips_debug(9,"Look for %s %zu\n", entity_local_name(ent), gen_length(complete_list_of_entities_p) ); POP(complete_list_of_entities_p); gfc_symtree* sort_entities = gfc2pips_getSymtreeByName(entity_local_name(ent),ns->sym_root); if( sort_entities && sort_entities->n.sym && ( sort_entities->n.sym->attr.in_common || sort_entities->n.sym->attr.implicit_type ) ){ gen_remove( &complete_list_of_entities , ent ); gfc2pips_debug(9,"Remove %s from list of entities, element\n",entity_local_name(ent)); } }else{ POP(complete_list_of_entities_p); } }

fc2pips_comments com; gfc_code *current_code_linked_to_comments=NULL; fprintf(stderr,"gfc2pips_comments_stack: %d\n",gfc2pips_comments_stack); if( com=gfc2pips_pop_comment() ){ while(1){ fprintf(stderr,"comment: %d ",com); if(com){ fprintf(stderr,"linked %s\n",com->done?"yes":"no"); current_code_linked_to_comments = com->num; do{ fprintf(stderr,"\t %d > %s\n", com->num, com->s ); com=gfc2pips_pop_comment(); }while( com && current_code_linked_to_comments == com->num );

}else{ break; } fprintf(stderr,"\n"); } fprintf(stderr,"\n"); }

fprintf(stderr,"gfc2pips_list_of_declared_code: %d\n",gfc2pips_list_of_declared_code); while( gfc2pips_list_of_declared_code ){ if(gfc2pips_list_of_declared_code->car.e){ fprintf(stderr,"gfc_code: %d %d %d %d %d\n", gfc2pips_list_of_declared_code->car.e, ((gfc_code*)gfc2pips_list_of_declared_code->car.e)->loc.nextc, ((gfc_code*)gfc2pips_list_of_declared_code->car.e)->loc.nextc, ((gfc_code*)gfc2pips_list_of_declared_code->car.e)->loc.lb->line, ((gfc_code*)gfc2pips_list_of_declared_code->car.e)->loc.lb->location ); fprintf(stderr,"%s\n", gfc2pips_gfc_char_t2string2( ((gfc_code*)gfc2pips_list_of_declared_code->car.e)->loc.nextc ) ); fprintf(stderr,"\n"); } POP(gfc2pips_list_of_declared_code); } fprintf(stderr,"\n");

Definition at line 114 of file gfc2pips.c.

114  {
115  gfc_symbol * root_sym;
116  gfc_formal_arglist *formal;
117 
120 
121  /* Debug level */
122  debug_on("GFC2PIPS_DEBUG_LEVEL");
123 
124  gfc2pips_debug(2, "Starting gfc2pips dumping\n");
125  message_assert( "No namespace to dump.", ns );
126  message_assert( "No symtree root.", ns->sym_root );
127  message_assert( "No symbol for the root.", ns->sym_root->n.sym );
128 
129  /* pips main initialization */
130  pips_init();
131 
132  // useful ? I don't think so... (Mehdi)
134 
135  { // Get symbol for current procedure (function, subroutine, whatever...)
136  gfc_symtree * current_proc;
137  current_proc = gfc2pips_getSymtreeByName(ns->proc_name->name, ns->sym_root);
138  message_assert( "No current symtree to match the name of the namespace",
139  current_proc != NULL );
140  root_sym = current_proc->n.sym;
141  }
142 
143  /*
144  * No callees at that time !
145  */
146  gfc_module_callees = NULL;
147 
148  /*
149  * Get the block_token (what we are working on)
150  * and the the return type if it's a function
151  */
152  gfc2pips_main_entity_type bloc_token = get_symbol_token(root_sym);
153 
154  /*
155  * Name for entity in PIPS corresponding to current procedure in GFC
156  */
158 
161 
162  gfc2pips_debug(2, "Currently parsing : %s\n", full_name);
163  gfc2pips_debug(2, "CurrentPackage : %s\n", CurrentPackage);
164  /*
165  * PIPS STUFF Initialization
166  */
167 
168  // It's safer to declare the current module in PIPS (ri-util)
170 
171  /* No common has yet been declared */
173 
174  /* Generic PIPS areas are created for memory allocation. */
175  InitAreas();
176 
177  /* declare variables */
178  list variables_p, variables;
179  variables_p = variables = gfc2pips_vars(ns);
180  gfc2pips_debug(2, "%zu variable(s) founded\n",gen_length(variables));
181 
182  /* Filter variables so that we keep only local variable */
183  variables = NIL;
184  FOREACH(entity,e,variables_p) {
185  storage s = entity_storage(e);
186  if(storage_ram_p(s)) {
189  }
190  }
191  }
192 
193  /*
194  * Get USE statements
195  */
196  list use_entities = get_use_entities_list(ns); // List of entities
197 
198  /* Get declarations */
200  /* Add variables to declaration */
201  decls = gen_nconc(use_entities, gen_nconc(decls, variables));
203  /* Fix Storage for declarations */
204  FOREACH( entity, e, decls ) {
205  // Fixme insecure
206  if(entity_variable_p(e)) {
209  const char* name = module_local_name(gfc2pips_main_entity);
210  if(ram_section(r) == entity_undefined) {
213  ram_section(r) = da;
214  }
215  }
216 
217  }
218 
219  gfc2pips_debug(2, "gfc2pips_main_entity %s %p %s\n",
222  CurrentPackage );
223  message_assert( "Main entity not created !", gfc2pips_main_entity
224  !=entity_undefined );
225 
226  // Storage is always ROM for main entity
228 
229  gfc2pips_debug(2, "main entity object initialized\n");
230 
231  /*
232  * we have taken the entities,
233  * we need to build user-defined elements
234  */
236 
237  /*
238  * Parameters (if applicable)
239  */
240  list parameters_name = gfc2pips_parameters(ns, bloc_token);
241 
242  if(bloc_token == MET_FUNC || bloc_token == MET_SUB) {
243  UpdateFunctionalType(gfc2pips_main_entity, parameters_name);
244  }
245 
246  int stack_offset = 0;
247 
248  // declare commons
249  list commons, commons_p, unnamed_commons, unnamed_commons_p, common_entities;
250  commons = commons_p = getSymbolBy(ns, ns->common_root, gfc2pips_get_commons);
251  unnamed_commons = unnamed_commons_p = getSymbolBy(ns,
252  ns->sym_root,
254 
255  common_entities = NULL; // NULL != list_undefined !!!
256 
257 
258  /*
259  * FIXME : outline all the following common stuff
260  */
261  gfc2pips_debug(2, "%zu explicit common(s) founded\n",gen_length(commons));
262 
263  /*
264  * We create an entity for each common, and we remove elements
265  * inside commons from orphan list
266  * We also accumulate the size of each element to compute the
267  * total size of the common
268  */
269  for (; commons_p; POP( commons_p )) {
270  gfc_symtree *st = (gfc_symtree*)commons_p->car.e;
271  gfc2pips_debug(3, "common founded: /%s/\n",st->name);
272 
273  // Check if the common exist first
274  char * upper;
275  string common_global_name = concatenate(TOP_LEVEL_MODULE_NAME,
278  upper=strupper(strdup(st->name),st->name),
279  NULL);
280  entity com = gen_find_tabulated(common_global_name, entity_domain);
281  if(com == entity_undefined) {
282  com = make_new_common(upper,
285  }
286 
287  //we need in the final state a list of entities
288  commons_p->car.e = com;
289 
290  gfc_symbol *s = st->n.common->head;
291  int offset_common = stack_offset;
292  /*
293  * We loop over elements inside the common :
294  * - first we remove them from the list of orphan common elements
295  * - secondly we create an entity for each element
296  */
297  for (; s; s = s->common_next) {
298  unnamed_commons_p = unnamed_commons;
299 
300  /* loop over the orphan list and remove current element from it */
301  while(unnamed_commons_p) {
302  st = unnamed_commons_p->car.e;
303  if(strcmp_(st->n.sym->name, s->name) == 0) {
304  gen_remove(&unnamed_commons, st);
305  break;
306  }
307  POP( unnamed_commons_p );
308  }
309  gfc2pips_debug(4, "element in common founded: %s\t\toffset: %d\n",
310  s->name, offset_common );
311 
312  /* Create an entity for current element */
313  entity in_common_entity = gfc2pips_symbol2entity(s);
314  entity_storage(in_common_entity)
316  com,
317  offset_common,
318  NIL));
319 
320  // Accumulate size of common
321  offset_common += array_size(in_common_entity);
322 
323  // Add current element to common layout
326  CONS( ENTITY, in_common_entity, NIL ));
327  common_entities = gen_cons(in_common_entity, common_entities);
328  }
329 
330  // Define the size of the common
331  set_common_to_size(com, offset_common);
332  gfc2pips_debug(3, "nb of elements in the common: %zu\n\t\tsize of the common: %d\n",
333  gen_length(
335  ),
336  offset_common
337  );
338  }
339 
340  /*
341  * If we still have orphan common elements, we create an "anonymous"
342  * common and we put all of them inside
343  */
344  int unnamed_commons_nb = gen_length(unnamed_commons);
345  if(unnamed_commons_nb) {
346  gfc2pips_debug(2, "nb of elements in %d unnamed common(s) founded\n",unnamed_commons_nb);
347 
349  entity com =
353 
355 
356  entity_storage(com)
358  StaticArea,
359  0,
360  NIL));
364  NIL,
367  int offset_common = stack_offset;
368  unnamed_commons_p = unnamed_commons;
369 
370  // Loop over orphan element
371  for (; unnamed_commons_p; POP( unnamed_commons_p )) {
372  gfc_symtree* st = unnamed_commons_p->car.e;
373  gfc_symbol *s = st->n.sym;
374  gfc2pips_debug(4, "element in common founded: %s\t\toffset: %d\n", s->name, offset_common );
375 
376  // Create entity
377  entity in_common_entity = gfc2pips_symbol2entity(s);
378  entity_storage(in_common_entity)
380  com,
381  offset_common,
382  NIL));
383 
384  // Accumulate size of common
385  offset_common += array_size(in_common_entity);
386 
387  // Add current element to common layout
390  CONS( ENTITY, in_common_entity, NIL ));
391 
392  common_entities = gen_cons(in_common_entity, common_entities);
393  }
394 
395  // Define the size of the common
396  set_common_to_size(com, offset_common);
397  gfc2pips_debug(3, "nb of elements in the common: %zu\n\t\tsize of the common: %d\n",
398  gen_length(
400  ),
401  offset_common
402  );
403  commons = gen_cons(com, commons);
404  }
405 
406  gfc2pips_debug(2, "%zu common(s) founded for %zu entities\n", gen_length(commons), gen_length(common_entities) );
407 
408  // declare DIMENSIONS => no need to handle, information
409  // already transfered to each and every entity
410 
411  // Mehdi : FIXME, unused !!
412  // we concatenate the entities from variables, commons and parameters and
413  // make sure they are declared only once. It seems parameters cannot be
414  // declared implicitly and have to be part of the list
415  list complete_list_of_entities = NULL, complete_list_of_entities_p = NULL;
416 
417  complete_list_of_entities_p = gen_union(complete_list_of_entities_p,
418  variables_p);
419  commons_p = commons;
420 
421  complete_list_of_entities_p = gen_union(commons_p,
422  complete_list_of_entities_p);
423 
424  complete_list_of_entities_p = gen_union(complete_list_of_entities_p,
425  parameters_name);
426 
427  complete_list_of_entities = complete_list_of_entities_p;
428  for (; complete_list_of_entities_p; POP( complete_list_of_entities_p )) {
429  //force value
430  if(entity_initial(ENTITY(CAR(complete_list_of_entities_p)))
431  ==value_undefined) {
432  entity_initial(ENTITY(CAR(complete_list_of_entities_p)))
433  = make_value_unknown();
434  }
435  }
436 
437  /*
438  * Get declarations
439  */
440  list list_of_declarations =
442  gfc2pips_debug(2, "%zu declaration(s) founded\n",gen_length(list_of_declarations));
443  complete_list_of_entities = gen_union(complete_list_of_entities,
444  list_of_declarations);
445 
446  /*
447  * Get extern entities
448  */
449  list list_of_extern_entities = gfc2pips_get_extern_entities(ns);
450  gfc2pips_debug(2, "%zu extern(s) founded\n",gen_length(list_of_extern_entities));
451 
452  gfc2pips_debug(2, "nb of entities: %zu\n",gen_length(complete_list_of_entities));
453 
454  /*
455  * Handle subroutines now
456  */
457  list list_of_subroutines, list_of_subroutines_p;
458  list_of_subroutines_p = list_of_subroutines
459  = getSymbolBy(ns, ns->sym_root, gfc2pips_test_subroutine);
460  for (; list_of_subroutines_p; POP( list_of_subroutines_p )) {
461  gfc_symtree* st = list_of_subroutines_p->car.e;
462 
463  list_of_subroutines_p->car.e = gfc2pips_symbol2entity(st->n.sym);
464  entity check_sub_entity = (entity)list_of_subroutines_p->car.e;
465  if(type_functional_p(entity_type(check_sub_entity))
466  && strcmp_(st->name, CurrentPackage) != 0) {
467  //check list of parameters;
468  list check_sub_parameters =
470  if(check_sub_parameters == NULL) {
471  // Error ?
472  }
473  gfc2pips_debug(4,"sub %s has %zu parameters\n",
474  entity_name(check_sub_entity),
475  gen_length(check_sub_parameters) );
476  }
477  }
478  gfc2pips_debug(2, "%zu subroutine(s) encountered\n",
479  gen_length(list_of_subroutines) );
480 
481  /*
482  * we need variables in commons to be in the list too
483  */
484  complete_list_of_entities = gen_union(complete_list_of_entities,
485  common_entities);
486 
487  /*
488  * sort the list again to get rid of IMPLICIT, BUT beware
489  * arguments with the current method we have a pb with the ouput
490  * of subroutines/functions arguments even if they are of the right type
491  */
492  /*complete_list_of_entities_p = complete_list_of_entities;
493  while( complete_list_of_entities_p ){
494  entity ent = complete_list_of_entities_p->car.e;
495  if( ent ){
496  gfc2pips_debug(9,"Look for %s %zu\n", entity_local_name(ent), gen_length(complete_list_of_entities_p) );
497  POP(complete_list_of_entities_p);
498  gfc_symtree* sort_entities = gfc2pips_getSymtreeByName(entity_local_name(ent),ns->sym_root);
499  if(
500  sort_entities && sort_entities->n.sym
501  && (
502  sort_entities->n.sym->attr.in_common
503  || sort_entities->n.sym->attr.implicit_type
504  )
505  ){
506  gen_remove( &complete_list_of_entities , ent );
507  gfc2pips_debug(9,"Remove %s from list of entities, element\n",entity_local_name(ent));
508  }
509  }else{
510  POP(complete_list_of_entities_p);
511  }
512  }*/
513 
514  ifdebug(9) {
515  complete_list_of_entities_p = complete_list_of_entities;
516  entity ent = entity_undefined;
517  for (; complete_list_of_entities_p; POP( complete_list_of_entities_p )) {
518  ent = ENTITY(CAR(complete_list_of_entities_p));
519  if(ent)
520  fprintf(stderr,
521  "Complete list of entities, element: %s\n",
522  entity_local_name(ent));
523  }
524  }
525 
527  = make_value_code(make_code(gen_union(list_of_extern_entities,
528  complete_list_of_entities),
529  strdup(""),
531  gen_union(list_of_extern_entities,
532  list_of_subroutines),
534 
535  gfc2pips_debug(2, "main entity creation finished\n");
536 
537  //get symbols with value, data and explicit-save
538  //sym->value is an expression to build the save
539  //create data $var /$val/
540  //save if explicit save, else nothing
542 
543  /***********************************************
544  * HERE WE BEGIN THE REAL PARSING OF THE CODE
545  */
546 
547  // declare code
548  gfc2pips_debug(2, "dumping code ...\n");
549  icf = gfc2pips_code2instruction__TOP(ns, ns->code);
550  gfc2pips_debug(2, "end of dumping code ...\n");
551  message_assert( "Dumping instruction failed\n", icf != instruction_undefined );
552 
553  /*
554  * END
555  ***********************************************/
556 
558 
559  //we automatically add a return statement
560  //we have got a problem with multiple return in the function
561  //and if the last statement is already a return ? badly handled
562  // FIXME
563  // insure_return_as_last_statement( gfc2pips_main_entity, &gfc_function_body );
564 
565 
566  // SetChains( ); // ??????????
567 
568  /*
569  * RR said :
570  * using ComputeAddresses() point a problem : entities in *STATIC*
571  * are computed two times, however we have to use it !
572  *
573  * But well... try it anyway !
574  */
576  //ComputeAddresses();
577 
578  //compute equivalences
579  //gfc2pips_computeEquiv(ns->equiv);
580 
581  //Syntax !!
582  //we have the job done 2 times if debug is at 9, one time if at 8
583  //update_common_sizes();
584  //print_common_layout(stderr,StaticArea,true);
585  gfc2pips_debug(2, "dumping done\n");
586 
587  //bad construction when parameter = subroutine
588  //text t = text_module(gfc2pips_main_entity,gfc_function_body);
589  //dump_text(t);
590 
591  /*gfc2pips_comments com;
592  gfc_code *current_code_linked_to_comments=NULL;
593  fprintf(stderr,"gfc2pips_comments_stack: %d\n",gfc2pips_comments_stack);
594  if( com=gfc2pips_pop_comment() ){
595  while(1){
596  fprintf(stderr,"comment: %d ",com);
597  if(com){
598  fprintf(stderr,"linked %s\n",com->done?"yes":"no");
599  current_code_linked_to_comments = com->num;
600  do{
601  fprintf(stderr,"\t %d > %s\n", com->num, com->s );
602  com=gfc2pips_pop_comment();
603  }while(
604  com
605  && current_code_linked_to_comments == com->num
606  );
607 
608  }else{
609  break;
610  }
611  fprintf(stderr,"\n");
612  }
613  fprintf(stderr,"\n");
614  }
615 
616  fprintf(stderr,"gfc2pips_list_of_declared_code: %d\n",gfc2pips_list_of_declared_code);
617  while( gfc2pips_list_of_declared_code ){
618  if(gfc2pips_list_of_declared_code->car.e){
619  fprintf(stderr,"gfc_code: %d %d %d %d %d\n",
620  gfc2pips_list_of_declared_code->car.e,
621  ((gfc_code*)gfc2pips_list_of_declared_code->car.e)->loc.nextc,
622  *((gfc_code*)gfc2pips_list_of_declared_code->car.e)->loc.nextc,
623  *((gfc_code*)gfc2pips_list_of_declared_code->car.e)->loc.lb->line,
624  ((gfc_code*)gfc2pips_list_of_declared_code->car.e)->loc.lb->location
625  );
626  fprintf(stderr,"%s\n",
627  gfc2pips_gfc_char_t2string2( ((gfc_code*)gfc2pips_list_of_declared_code->car.e)->loc.nextc )
628  );
629  fprintf(stderr,"\n");
630  }
631  POP(gfc2pips_list_of_declared_code);
632  }
633  fprintf(stderr,"\n");
634  */
635 
636  /*
637  * It's time to produce the resource in the PIPS workspace
638  */
639 
640  extern const char *main_input_filename;
641  extern const char *aux_base_name;
642 
643  // Get workspace directory
644  char *dir_name = (char *)aux_base_name;
645  char *source_file_orig = strdup(concatenate(dir_name,
646  "/",
648  ".f90",// FIXME get correct ext.
649  NULL));
650  char * unsplit_modname = NULL; // Will be followed by a ! for module
651  save_entities();
652 
653  /*
654  * FIXME : The following still need many many cleaning !
655  */
656 
657  // We don't produce output for module
658  if(bloc_token == MET_MODULE) {
659  pips_user_warning("Modules are ignored : %s\n", full_name);
660 
661  unsplit_modname = (char *)malloc(sizeof(char)
662  * (strlen(CurrentPackage) + 2));
663  sprintf(unsplit_modname, "%s", CurrentPackage);
664 
665  char *module_dir_name = strdup(concatenate(dir_name,
666  "/",
667  unsplit_modname,
668  NULL));
669  mkdir(module_dir_name, 0xffffffff);
670  pips_debug(2,"Creating module directory : %s\n", module_dir_name);
671 
672  // Produce SOURCE_FILE
673  string source_file = concatenate(module_dir_name,
674  "/",
675  unsplit_modname,
676  ".f90",// FIXME get correct ext.
677  NULL);
678  fcopy(main_input_filename, source_file);
679  source_file = concatenate(CurrentPackage, "/", CurrentPackage, ".f90",// FIXME get correct ext.
680  NULL);
681 
682  fcopy(main_input_filename, source_file_orig);
683 
684  char *parsedcode_filename = concatenate(module_dir_name,
685  "/",
686  "PARSED_CODE",
687  NULL);
688  FILE *parsedcode_file = safe_fopen(parsedcode_filename, "w");
689  printf("Write PArsed code in %s \n", parsedcode_filename);
690  gen_write(parsedcode_file, (void *)gfc_function_body);
691  safe_fclose(parsedcode_file, parsedcode_filename);
692 
693  char *callees_filename = concatenate(module_dir_name, "/", "CALLEES", NULL);
694  FILE *callees_file = safe_fopen(callees_filename, "w");
695  // printf("Write callees\n");
696  gen_write(callees_file, (void *)make_callees(gfc_module_callees));
697  safe_fclose(callees_file, callees_filename);
698 
699  string unsplit_source_file = concatenate(dir_name,
700  "/",
701  unsplit_modname,
702  ".f90",
703  NULL);
704 
705  printf("Writing %s\n\n", unsplit_source_file);
706  FILE *fp = safe_fopen(unsplit_source_file, "w");
707  fprintf(fp, "/* module still to be implemented ! */\n\n");
708  safe_fclose(fp, unsplit_source_file);
709 
710  } else {
711 
712  char *module_dir_name = strdup(concatenate(dir_name,
713  "/",
715  NULL));
716  mkdir(module_dir_name, 0xffffffff);
717  pips_debug(2,"Creating module directory : %s\n", module_dir_name);
718 
719  // Produce SOURCE_FILE
720  string source_file = concatenate(dir_name,
721  "/",
723  "/",
725  ".f90",// FIXME get correct ext.
726  NULL);
727  fcopy(main_input_filename, source_file);
728  source_file = concatenate(CurrentPackage, "/", CurrentPackage, ".f90",// FIXME get correct ext.
729  NULL);
730 
731  fcopy(main_input_filename, source_file_orig);
732 
733  unsplit_modname = strdup(CurrentPackage);
734 
735  char *parsedcode_filename = concatenate(module_dir_name,
736  "/",
737  "PARSED_CODE",
738  NULL);
739  FILE *parsedcode_file = safe_fopen(parsedcode_filename, "w");
740  // printf("Write PArsed code\n");
741  gen_write(parsedcode_file, (void *)gfc_function_body);
742  safe_fclose(parsedcode_file, parsedcode_filename);
743 
744  char *callees_filename = concatenate(module_dir_name, "/", "CALLEES", NULL);
745  FILE *callees_file = safe_fopen(callees_filename, "w");
746  // printf("Write callees\n");
747  gen_write(callees_file, (void *)make_callees(gfc_module_callees));
748  safe_fclose(callees_file, callees_filename);
749  }
750 
751  // FIXME free strdup
752 
753  ResetChains();
756 
757  char *file_list = concatenate(dir_name, "/.fsplit_file_list", NULL);
758  FILE *fp = safe_fopen(file_list, "a");
759  fprintf(fp, "%s %s/%s.f90\n", unsplit_modname, dir_name, unsplit_modname);
760  safe_fclose(fp, file_list);
761 
762  // Loop over contained procedures
763  for (ns = ns->contained; ns; ns = ns->sibling) {
764  fprintf(stderr, "CONTAINS\n");
765  gfc2pips_namespace(ns);
766  }
767 
768  // printf( "nend\n" );
769  // exit( 0 );
770 }
language make_language_fortran95(void)
Definition: ri.c:1256
value make_value_code(code _field_)
Definition: ri.c:2835
type make_type_area(area _field_)
Definition: ri.c:2712
area make_area(intptr_t a1, list a2)
Definition: ri.c:98
code make_code(list a1, string a2, sequence a3, list a4, language a5)
Definition: ri.c:353
sequence make_sequence(list a)
Definition: ri.c:2125
callees make_callees(list a)
Definition: ri.c:227
void InitAreas()
Definition: declaration.c:100
void reset_common_size_map()
Definition: declaration.c:954
void initialize_common_size_map()
Definition: declaration.c:947
const char * global_name_to_user_name(const char *global_name)
functions on strings for entity names
Definition: entity_names.c:136
void ResetChains()
undefine chains between two successives calls to parser
Definition: equivalence.c:65
FILE * safe_fopen(const char *filename, const char *what)
Definition: file.c:67
int safe_fclose(FILE *stream, const char *filename)
Definition: file.c:77
static int array_size(dim)
ARRAY_SIZE returns the number of elements in the array whose dimension list is DIM.
Definition: genClib.c:155
void gen_write(FILE *fd, gen_chunk *obj)
GEN_WRITE writes the OBJect on the stream FD.
Definition: genClib.c:1745
void gfc2pips_shift_comments(void)
We assign a gfc_code depending to a list of comments if any depending on the number of the statement.
list gen_union(list a, list b)
generate an union of unique elements taken from A and B
Definition: gfc2pips-util.c:47
int fcopy(const char *old, const char *new)
copy the content of the first file to the second one
void pips_init()
void save_entities()
list gfc_module_callees
Store the list of callees.
Definition: gfc2pips-util.c:40
list get_use_entities_list(struct gfc_namespace *ns)
bool gfc2pips_get_commons(gfc_namespace __attribute__((__unused__)) *ns, gfc_symtree __attribute__((__unused__)) *st)
test function to know if it is a common, always true because the tree is completely separated therefo...
Definition: gfc2pips.c:1477
list gfc2pips_parameters(gfc_namespace *ns, gfc2pips_main_entity_type bloc_token)
Definition: gfc2pips.c:793
void gfc2pips_getTypesDeclared(gfc_namespace *ns)
Definition: gfc2pips.c:1119
void gfc2pips_computeAdresses(void)
compute addresses of the stack, heap, dynamic and static areas
Definition: gfc2pips.c:4332
list gfc2pips_get_extern_entities(gfc_namespace *ns)
build a list of externals entities
Definition: gfc2pips.c:1219
void gfc2pips_namespace(gfc_namespace *ns)
Entry point for gfc2pips translation This will be called each time the parser encounter subroutine,...
Definition: gfc2pips.c:114
bool gfc2pips_test_subroutine(gfc_namespace __attribute__((__unused__)) *ns, gfc_symtree *st)
Definition: gfc2pips.c:1425
instruction gfc2pips_code2instruction__TOP(gfc_namespace *ns, gfc_code *c)
Declaration of instructions.
Definition: gfc2pips.c:2119
gfc2pips_main_entity_type get_symbol_token(gfc_symbol *root_sym)
Definition: gfc2pips.c:772
statement gfc_function_body
Definition: gfc2pips.c:95
list gfc2pips_vars(gfc_namespace *ns)
Extract every and each variable from a namespace.
Definition: gfc2pips.c:954
bool gfc2pips_get_incommon(gfc_namespace __attribute__((__unused__)) *ns, gfc_symtree __attribute__((__unused__)) *st)
Definition: gfc2pips.c:1481
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
void gen_remove(list *cpp, const void *o)
remove all occurences of item o from list *cpp, which is thus modified.
Definition: list.c:685
#define debug_on(env)
Definition: misc-local.h:157
#define COMMON_PREFIX
Definition: naming-local.h:34
#define DYNAMIC_AREA_LOCAL_NAME
Definition: naming-local.h:69
#define BLANK_COMMON_LOCAL_NAME
Definition: naming-local.h:68
string strupper(string, const char *)
Definition: string.c:213
#define string_undefined
Definition: newgen_types.h:40
void UpdateFunctionalType(entity f, list l)
This function analyzes the CurrentFunction formal parameter list to determine the CurrentFunction fun...
Definition: procedure.c:1131
#define entity_variable_p(e)
An entity_variable_p(e) may hide a typedef and hence a functional type.
@ ABSTRACT_LOCATION
@ ENTITY_DYNAMIC_AREA
entity make_new_common(string name, entity mod)
This function creates a common for a given name in a given module.
Definition: entity.c:1806
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
void AddEntityToDeclarations(entity, entity)
END_EOLE.
Definition: variable.c:108
#define type_functional_p(x)
Definition: ri.h:2950
#define functional_parameters(x)
Definition: ri.h:1442
#define ram_function(x)
Definition: ri.h:2247
#define entity_kind(x)
Definition: ri.h:2798
int printf()
static int variables[MAX_VAR]

References ABSTRACT_LOCATION, AddEntityToDeclarations(), area_layout, array_size(), BLANK_COMMON_LOCAL_NAME, cons::car, CAR, code_declarations, COMMON_PREFIX, concatenate(), CONS, CurrentPackage, debug_on, DYNAMIC_AREA_LOCAL_NAME, gen_chunk::e, ENTITY, entity_domain, ENTITY_DYNAMIC_AREA, entity_initial, entity_kind, entity_local_name(), entity_name, entity_storage, entity_type, entity_undefined, entity_variable_p, EntityCode(), fcopy(), FindOrCreateEntity(), FOREACH, fprintf(), full_name, functional_parameters, gen_cons(), gen_find_tabulated(), gen_length(), gen_nconc(), gen_remove(), gen_union(), gen_write(), get_current_module_entity(), get_symbol_token(), get_use_entities_list(), getSymbolBy(), gfc2pips_code2instruction__TOP(), gfc2pips_computeAdresses(), gfc2pips_debug, gfc2pips_format, gfc2pips_format2, gfc2pips_get_commons(), gfc2pips_get_extern_entities(), gfc2pips_get_incommon(), gfc2pips_getSymtreeByName(), gfc2pips_getTypesDeclared(), gfc2pips_main_entity, gfc2pips_namespace(), gfc2pips_parameters(), gfc2pips_shift_comments(), gfc2pips_symbol2entity(), gfc2pips_test_subroutine(), gfc2pips_vars(), gfc_function_body, gfc_module_callees, global_name_to_user_name(), ifdebug, InitAreas(), initialize_common_size_map(), instruction_to_statement(), instruction_undefined, local_name(), make_area(), make_callees(), make_code(), make_language_fortran95(), make_new_common(), make_ram(), make_sequence(), make_storage_ram(), make_storage_rom(), make_type_area(), make_value_code(), make_value_unknown(), malloc(), message_assert, MET_FUNC, MET_MODULE, MET_SUB, module_local_name(), MODULE_SEP_STRING, NIL, pips_debug, pips_init(), pips_user_warning, POP, printf(), ram_function, ram_section, reset_common_size_map(), reset_current_module_entity(), ResetChains(), safe_fclose(), safe_fopen(), save_entities(), set_common_to_size(), set_current_module_entity(), StaticArea, storage_ram, storage_ram_p, strcmp_(), strdup(), string_undefined, strupper(), TOP_LEVEL_MODULE_NAME, type_area, type_functional, type_functional_p, UpdateFunctionalType(), value_undefined, and variables.

Referenced by gfc2pips_namespace().

+ Here is the caller graph for this function:

◆ gfc2pips_parameters()

list gfc2pips_parameters ( gfc_namespace *  ns,
gfc2pips_main_entity_type  bloc_token 
)

Definition at line 793 of file gfc2pips.c.

794  {
795 
796  gfc2pips_debug(2, "Handle the list of parameters\n");
797  list parameters = NULL, parameters_name = NULL;
798  entity ent = entity_undefined;
799  switch(bloc_token) {
800  case MET_FUNC: {
801  // we add a special entity called "func:func" which
802  // is the return variable of the function
806  //don't know were to put it hence StackArea
807  entity_storage(ent)
809  StackArea,
811  NULL));
812  }
813  // No break
814  case MET_SUB:
815  // change it to put both name and namespace in order to catch the parameters
816  // of any subroutine ? or create a sub-function for gfc2pips_args
817  parameters = gfc2pips_args(ns);
818 
819  if(ent != entity_undefined) {
820  UpdateFunctionalType(ent, parameters);
821  }
822 
823  //we need a copy of the list of parameters entities (really ?)
824  parameters_name = gen_copy_seq(parameters);
826  //fprintf(stderr,"formal created ?? %d\n", storage_formal_p(entity_storage(ENTITY(CAR(parameters_name)))));
827  //ScanFormalParameters(gfc2pips_main_entity, add_formal_return_code(parameters));
828  gfc2pips_debug(2, "List of parameters done\t %zu parameters(s)\n", gen_length(parameters_name) );
829  break;
830  case MET_BLOCK: // Useful ?
833  make_type_void(NIL)));
834  break;
835  default:
836  break;
837  }
838  return parameters_name;
839 }
type make_type_void(list _field_)
Definition: ri.c:2727
value copy_value(value p)
VALUE.
Definition: ri.c:2784
list gfc2pips_args(gfc_namespace *ns)
Retrieve the list of names of every argument of the function, if any.
Definition: gfc2pips.c:847
void gfc2pips_generate_parameters_list(list parameters)
replace a list of entities by a list of parameters to those entities
Definition: gfc2pips.c:896
const char * get_current_module_name(void)
Get the name of the current module.
Definition: static.c:121

References copy_type(), copy_value(), CurrentPackage, entity_initial, entity_storage, entity_type, entity_undefined, FindOrCreateEntity(), gen_copy_seq(), gen_length(), get_current_module_entity(), get_current_module_name(), gfc2pips_args(), gfc2pips_debug, gfc2pips_generate_parameters_list(), gfc2pips_main_entity, make_functional(), make_ram(), make_storage_ram(), make_type_functional(), make_type_void(), MET_BLOCK, MET_FUNC, MET_SUB, NIL, StackArea, UNKNOWN_RAM_OFFSET, and UpdateFunctionalType().

Referenced by gfc2pips_namespace().

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

◆ gfc2pips_real2entity()

entity gfc2pips_real2entity ( double  r)

dump reals to PIPS entities

Parameters
rthe double to create
Returns
the corresponding entity

we have a big issue with reals: 16.53 => 16.530001 16.56 => 16.559999

Definition at line 1801 of file gfc2pips.c.

1801  {
1802  //create a more elaborate function to output a fortran format or something like it ?
1803  char str[60];
1804  if(r == 0. || r == (double)((int)r)) {//if the real represent an integer, display a string representing an integer then
1805  sprintf(str, "%d", (int)r);
1806  } else {
1807  //we need a test to know if we output in scientific or normal mode
1808  //sprintf(str,"%.32f",r);
1809  //sprintf(str,"%.6e",r);
1810  sprintf(str, "%.16e", r);
1811  //fprintf(stderr,"copy of the entity name(real) %s\n",str);
1812  }
1814  return MakeConstant(str, is_basic_float);
1815 }
void gfc2pips_truncate_useless_zeroes(char *s)
expurgates a string representing a REAL, could be a pre-prettyprinter processing
@ is_basic_float
Definition: ri.h:572

References gfc2pips_truncate_useless_zeroes(), is_basic_float, and MakeConstant().

Referenced by gfc2pips_expr2entity(), and gfc2pips_real2expression().

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

◆ gfc2pips_real2expression()

expression gfc2pips_real2expression ( double  r)

translate a real to an expression

Definition at line 1757 of file gfc2pips.c.

1757  {
1758  if(r < 0.) {
1761  } else {
1763  }
1764 }

References CreateIntrinsic(), entity_to_expression(), gfc2pips_real2entity(), and MakeFortranUnaryCall().

Referenced by gfc2pips_expr2expression(), and gfc2pips_make_zero_for_symbol().

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

◆ gfc2pips_reduce_repeated_values()

list gfc2pips_reduce_repeated_values ( list  l)

look for repeated values (integers or real) in the list (list for DATA instructions) and transform them in a FORTRAN repeat syntax

DATA x /1,1,1/ => DATA x /3*1/

TODO:

  • look into the consistency issue
  • add recognition of /3*1, 4*1/ to make it a /7*1/

fc2pips_debug( 9, "is a call ? %s\n\tis a constant ? %s\n\tfunctional ? %s\n", syntax_call_p(expression_syntax(curr))?"true":"false", ( syntax_call_p(expression_syntax(curr)) && entity_constant_p(call_function(syntax_call(expression_syntax(curr)))) ) ? "true" : "false", type_functional_p(entity_type(call_function(syntax_call(expression_syntax(curr))))) ? "true":"false" );

Definition at line 3669 of file gfc2pips.c.

3669  {
3670  //return l;
3671  expression curr = NULL, prec = NULL;
3672  list local_list = l, last_pointer_on_list = NULL;
3673  int nb_of_occurences = 0;
3674  gfc2pips_debug(9, "begin reduce of values\n");
3675  while(local_list) {
3676  curr = (expression)local_list->car.e;
3677  /*gfc2pips_debug( 9,
3678  "is a call ? %s\n\tis a constant ? %s\n\tfunctional ? %s\n",
3679  syntax_call_p(expression_syntax(curr))?"true":"false",
3680  (
3681  syntax_call_p(expression_syntax(curr))
3682  && entity_constant_p(call_function(syntax_call(expression_syntax(curr))))
3683  ) ? "true" : "false",
3684  type_functional_p(entity_type(call_function(syntax_call(expression_syntax(curr))))) ? "true":"false"
3685  );*/
3686  if(expression_is_constant_p(curr)) {
3687  if(prec && expression_is_constant_p(prec)) {
3690  gfc2pips_debug(10, "same as before\n");
3691  nb_of_occurences++;
3692  } else if(nb_of_occurences > 1) {
3693  //reduce
3694  gfc2pips_debug(9, "reduce1 %s %d\n",entity_name(reference_variable(syntax_reference(expression_syntax(prec)))),nb_of_occurences);
3695  last_pointer_on_list->car.e
3697  gfc2pips_int2expression(nb_of_occurences),
3698  prec);
3699  last_pointer_on_list->cdr = local_list;
3700 
3701  nb_of_occurences = 1;
3702  last_pointer_on_list = local_list;
3703  } else {
3704  gfc2pips_debug(10, "skip to next\n");
3705  nb_of_occurences = 1;
3706  last_pointer_on_list = local_list;
3707  }
3708  } else {
3709  gfc2pips_debug(10, "no previous\n");
3710  nb_of_occurences = 1;
3711  last_pointer_on_list = local_list;
3712  }
3713  prec = curr;
3714  } else {//we will not be able to reduce
3715  gfc2pips_debug(10, "not a constant\n");
3716  if(nb_of_occurences > 1) {
3717  //reduce
3719  9,
3720  "reduce2 %s %d %p\n",
3722  nb_of_occurences,
3723  last_pointer_on_list
3724  );
3725  if(last_pointer_on_list) {
3726  last_pointer_on_list->car.e
3728  gfc2pips_int2expression(nb_of_occurences),
3729  prec);
3730  last_pointer_on_list->cdr = local_list;
3731  } else {
3732  //an error has been introduced somewhere, last_pointer_on_list is NULL and it should point to the first repeated value
3733  pips_user_warning( "We don't know what to do ! We do not have a current pointer (and we should).\n" );
3734  }
3735  }
3736  nb_of_occurences = 0;//no dump, thus no increment
3737  last_pointer_on_list = local_list->cdr;//no correct reference needed
3738  }
3739  POP( local_list );
3740  }
3741  //a last sequence of data ?
3742  if(nb_of_occurences > 1) {
3743  //reduce
3744  gfc2pips_debug(9, "reduce3 %s %d\n",entity_name(reference_variable(syntax_reference(expression_syntax(prec)))),nb_of_occurences);
3745  last_pointer_on_list->car.e
3747  gfc2pips_int2expression(nb_of_occurences),
3748  prec);
3749  last_pointer_on_list->cdr = local_list;
3750  last_pointer_on_list = local_list;
3751  }
3752  gfc2pips_debug(9, "reduce of values done\n");
3753  return l;
3754 }
struct _newgen_struct_expression_ * expression
Definition: alias_private.h:21
bool expression_is_constant_p(expression e)
BEGIN_EOLE.
Definition: constant.c:666
#define MULTIPLY_OPERATOR_NAME
#define syntax_reference(x)
Definition: ri.h:2730
#define reference_variable(x)
Definition: ri.h:2326
struct cons * cdr
The pointer to the next element.
Definition: newgen_list.h:43

References cons::car, cons::cdr, CreateIntrinsic(), gen_chunk::e, entity_name, expression_is_constant_p(), expression_syntax, gfc2pips_debug, gfc2pips_int2expression(), MakeBinaryCall(), MULTIPLY_OPERATOR_NAME, pips_user_warning, POP, reference_variable, and syntax_reference.

Referenced by gfc2pips_symbol2data_instruction().

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

◆ gfc2pips_shiftAdressesOfArea()

void gfc2pips_shiftAdressesOfArea ( entity  _area,
int  old_offset,
int  size,
int  max_offset,
int  shift 
)

Definition at line 4488 of file gfc2pips.c.

4492  {
4494  list pcv = gen_copy_seq(_pcv);
4495  for (pcv = gen_nreverse(pcv); pcv != NIL; pcv = CDR( pcv )) {
4496  entity e = ENTITY(CAR(pcv));
4499  && ram_section(storage_ram(entity_storage(e))) == _area) {
4500  /*
4501  * put those two lines in one go (to process everything in one loop only)
4502  when shift, if offset of variable after <c>, retrieve size of <c>
4503  add to every variable after <a>+sizeof(<a>) the difference of offset
4504 
4505  when shift, if offset of variable after <b>, retrieve size of <b>
4506  add to every variable after <c(2)>+sizeof(<c>)-sizeof(<c(1)>) the difference of offset
4507 
4508  => when we move an array or a variable, use the full size of the array/variable
4509  when an element, use the full size of the array minus the offset of the element
4510  */
4511  gfc2pips_debug(9,"%s\told_offset: %d\tsize: %d\tmax_offset: %d\tshift: %d\tram_offset: %zu\n", entity_name(e), old_offset, size, max_offset, shift, ram_offset(storage_ram(entity_storage(e))) );
4512  int personnal_shift = 0;
4513  //if( ram_offset(storage_ram(entity_storage(e))) > old_offset+size ){
4514  personnal_shift -= shift;
4515  //}
4516  if(ram_offset(storage_ram(entity_storage(e))) > old_offset) {
4517  personnal_shift -= size;
4518  }
4519  ram_offset(storage_ram(entity_storage(e))) += personnal_shift;
4520  gfc2pips_debug(9,"%s shifted of %d\n",entity_name(e),personnal_shift);
4521  }
4522  }
4523 }

References CAR, CDR, code_declarations, ENTITY, entity_name, entity_storage, EntityCode(), gen_copy_seq(), gen_nreverse(), get_current_module_entity(), gfc2pips_debug, NIL, ram_offset, ram_section, storage_ram, storage_ram_p, and storage_undefined.

+ Here is the call graph for this function:

◆ gfc2pips_symbol2data_instruction()

instruction gfc2pips_symbol2data_instruction ( gfc_symbol *  sym)

build a DATA statement, filling blanks with zeroes.

TODO:

  • add variables which tell when split the declaration in parts or not ?
  • change this function into one returning a set of DATA statements for each sequence instead or filling with zeroes ? (add 0 is what will be done in the memory anyway)

or(i=0 , j=mpz_get_si(constr->n.offset) ; i<j ; i++ ){ values = CONS( EXPRESSION, gfc2pips_make_zero_for_symbol(sym), values ); }

or( i=1 , j=offset ; i<j ; i++ ){ values = CONS( EXPRESSION, gfc2pips_make_zero_for_symbol(sym), values ); }

or( i=0,j=mpz_get_si(constr->repeat) ; i<j ; i++ ){ values = CONS( EXPRESSION, gfc2pips_expr2expression(constr->expr), values ); }

or( i=1 , j=total_size/size_of_unit-offset_end ; i<j ; i++ ){ values = CONS( EXPRESSION, gfc2pips_make_zero_for_symbol(sym), values ); }

Definition at line 3501 of file gfc2pips.c.

3501  {
3502  gfc2pips_debug(3,"%s\n",sym->name);
3503  entity e1 =
3506 
3507  entity tagged_entity = gfc2pips_symbol2entity(sym);
3508  expression tagged_expr = entity_to_expression(tagged_entity);
3509 
3510  /*
3511  * FIXME, this is just a fix because
3512  * entity_to_expression may call reference_to_expression that may
3513  * normalize the expression. This will further produce an invalid
3514  * output when using gen_write_tabulated in order to dump entities
3515  * so we unlink the normalized field, there is probably a leak there...
3516  */
3517  // expression_normalized(tagged_expr) = normalized_undefined;
3518 
3519  list args1 = CONS( EXPRESSION, tagged_expr, NULL );/**/
3520  //add references for DATA variable(offset +-difference due to offset)
3521  //if(sym->component_access)
3522 
3523  //list of variables used int the data statement
3524  list init = CONS( EXPRESSION, make_call_expression( e1, args1 ), NULL );
3525  //list of values
3526  /*
3527  * data (z(i), i = min_off, max_off) /1+max_off-min_off*val/
3528  * gfc doesn't now the range between min_off and max_off it just state, one by one the value
3529  * how to know the range ? do we have to ?
3530  ** data z(offset+1) / value /
3531  * ? possible ?
3532  */
3533  list values = NULL;
3534  if(sym->value && sym->value->expr_type == EXPR_ARRAY) {
3535  gfc_constructor *constr = sym->value->value.constructor;
3536  gfc_constructor *prec = NULL;
3537  int i, j;
3538  for (; constr; constr = constr->next) {
3539  gfc2pips_debug( 9, "offset: %zu\trepeat: %zu\n", mpz_get_si(constr->n.offset), mpz_get_si(constr->repeat) );
3540 
3541  //add 0 to fill the gap at the beginning
3542  if(prec == NULL && mpz_get_si(constr->n.offset) > 0) {
3543  gfc2pips_debug(9,"we do not start the DATA statement at the beginning !\n");
3544  values = CONS( EXPRESSION,
3546  gfc2pips_int2expression( mpz_get_si( constr->n.offset ) ),
3548  values );
3549  /*for(i=0 , j=mpz_get_si(constr->n.offset) ; i<j ; i++ ){
3550  values = CONS( EXPRESSION, gfc2pips_make_zero_for_symbol(sym), values );
3551  }*/
3552  }
3553  //if precedent, we need to know if there has been a repetition of some kind
3554  if(prec) {
3555  int offset;
3556  //if there is a repetition, we need to compare to the end of it
3557  if(mpz_get_si(prec->repeat)) {
3558  offset = mpz_get_si(constr->n.offset) - mpz_get_si(prec->n.offset)
3559  - mpz_get_si(prec->repeat);
3560  } else {
3561  offset = mpz_get_si(constr->n.offset) - mpz_get_si(prec->n.offset);
3562  }
3563 
3564  //add 0 to fill the gaps between the values
3565  if(offset > 1) {
3566  gfc2pips_debug(9,"We have a gap in DATA %d\n",offset);
3567  values = CONS( EXPRESSION,
3571  values );
3572  /*for( i=1 , j=offset ; i<j ; i++ ){
3573  values = CONS( EXPRESSION, gfc2pips_make_zero_for_symbol(sym), values );
3574  }*/
3575  }
3576  }
3577  //if repetition on the current value, repeat, else just add
3578  if(mpz_get_si(constr->repeat)) {
3579  //if repeat => offset*value
3580  values = CONS( EXPRESSION,
3582  gfc2pips_int2expression( mpz_get_si( constr->repeat ) ),
3583  gfc2pips_expr2expression( constr->expr ) ),
3584  values );
3585  /*for( i=0,j=mpz_get_si(constr->repeat) ; i<j ; i++ ){
3586  values = CONS( EXPRESSION, gfc2pips_expr2expression(constr->expr), values );
3587  }*/
3588  } else {
3589  values = CONS( EXPRESSION,
3590  gfc2pips_expr2expression( constr->expr ),
3591  values );
3592  }
3593  prec = constr;
3594  }
3595 
3596  //add 0 to fill the gap at the end
3597  //we patch the size of a single object a little
3598  int size_of_unit = gfc2pips_symbol2size(sym);
3599  if(sym->ts.type == BT_COMPLEX)
3600  size_of_unit *= 2;
3601  if(sym->ts.type == BT_CHARACTER)
3602  size_of_unit = 1;
3603 
3604  int total_size;
3605  SizeOfArray(tagged_entity, &total_size);
3606  gfc2pips_debug(9,"total size: %d\n",total_size);
3607  int offset_end;
3608  if(prec) {
3609  if(mpz_get_si(prec->repeat)) {
3610  offset_end = mpz_get_si(prec->n.offset) + mpz_get_si(prec->repeat);
3611  } else {
3612  offset_end = mpz_get_si(prec->n.offset);
3613  }
3614  }
3615 
3616  if(prec && offset_end + 1 < ((double)total_size) / (double)size_of_unit) {
3617  gfc2pips_debug(9,"We fill all the remaining space in the DATA %d\n",offset_end);
3618  values = CONS( EXPRESSION,
3620  gfc2pips_int2expression( total_size
3621  / size_of_unit - offset_end - 1 ),
3623  values );
3624  /*for( i=1 , j=total_size/size_of_unit-offset_end ; i<j ; i++ ){
3625  values = CONS( EXPRESSION, gfc2pips_make_zero_for_symbol(sym), values );
3626  }*/
3627  }
3628  //fill in the remaining parts
3629  values = gen_nreverse(values);
3630  } else if(sym->value) {
3631  values = CONS( EXPRESSION, gfc2pips_expr2expression( sym->value ), NULL );
3632  } else {
3633  pips_user_error( "No value, incoherence\n" );
3634  return instruction_undefined;
3635  }
3636 
3640  values = gfc2pips_reduce_repeated_values(values);
3641  list args2 = gen_nconc(init, values);
3642  call call_ = make_call(e2, args2);
3643  return make_instruction_call(call_);
3644 }
expression gfc2pips_make_zero_for_symbol(gfc_symbol *sym)
Definition: gfc2pips.c:3646
list gfc2pips_reduce_repeated_values(list l)
look for repeated values (integers or real) in the list (list for DATA instructions) and transform th...
Definition: gfc2pips.c:3669
#define DATA_LIST_FUNCTION_NAME
Definition: ri-util-local.h:81
#define STATIC_INITIALIZATION_FUNCTION_NAME
Definition: ri-util-local.h:80
static int init
Maximal value set for Fortran 77.
Definition: entity.c:320
expression make_call_expression(entity e, list l)
Build an expression that call an function entity with an argument list.
Definition: expression.c:321

References CONS, CreateIntrinsic(), DATA_LIST_FUNCTION_NAME, entity_initial, entity_to_expression(), EXPRESSION, FindOrCreateEntity(), gen_nconc(), gen_nreverse(), gfc2pips_debug, gfc2pips_expr2expression(), gfc2pips_int2expression(), gfc2pips_make_zero_for_symbol(), gfc2pips_reduce_repeated_values(), gfc2pips_symbol2entity(), gfc2pips_symbol2size(), init, instruction_undefined, make_call(), make_call_expression(), make_instruction_call(), make_value_unknown(), MakeBinaryCall(), MULTIPLY_OPERATOR_NAME, offset, pips_user_error, SizeOfArray(), STATIC_INITIALIZATION_FUNCTION_NAME, and TOP_LEVEL_MODULE_NAME.

Referenced by gfc2pips_code2instruction__TOP().

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

◆ gfc2pips_symbol2entity()

entity gfc2pips_symbol2entity ( gfc_symbol *  s)

translate a gfc symbol to a PIPS entity, check if it is a function, program, subroutine or else

Allocatable handling : we convert it to a structure

Definition at line 1582 of file gfc2pips.c.

1582  {
1583  char* name = str2upper(gfc2pips_get_safe_name(s->name));
1584  entity e = entity_undefined;//gfc2pips_check_entity_doesnt_exists(name);
1585  bool module = false;
1586 
1587  if(s->attr.flavor == FL_PROGRAM || s->attr.is_main_program) {
1589  gfc2pips_debug(9, "create main program %s\n",name);
1591  }
1592  module = true;
1593  } else if(s->attr.function) {
1596  == entity_undefined) {
1597  gfc2pips_debug(0, "create function %s\n",str2upper( ( name ) ));
1598  e = make_empty_function(str2upper((name)),
1601  }
1602  }
1603  module = true;
1604  } else if(s->attr.subroutine) {
1606  gfc2pips_debug(1, "create subroutine %s\n",name);
1608  }
1609  module = true;
1610  } else if(s->attr.flavor == FL_BLOCK_DATA) {
1612  gfc2pips_debug(9, "block data \n");
1614  }
1615  module = true;
1616  } else if(s->attr.flavor == FL_MODULE) {
1617  char *module_name = str2upper(strdup(concatenate(name, "!", NULL)));
1619  ==entity_undefined) {
1620  gfc2pips_debug(1, "create module %s\n",module_name);
1622  }
1623  free(module_name);
1624  module = true;
1625  } else {
1626  gfc2pips_debug(9, "Try to resolve entity %s\n",str2upper( ( name ) ));
1627  if(s->ts.type == BT_DERIVED) {
1628  if(s->attr.allocatable) {
1629  /* Allocatable handling : we convert it to a structure */
1631  name,
1632  s->as->rank);
1633  // FIXME This is bad, we have the entity TYPE only. */
1634  } else {
1635  pips_user_error( "User-defined variables are not implemented yet\n" );
1636  //there is still a problem in the check of consistency of the domain names
1637  }
1638  } else {
1639  string location = strdup(CurrentPackage);
1640  if(s->attr.use_assoc) {
1641  gfc2pips_debug(2, "Entity %s is located in a module (%s)\n",
1642  name,
1643  s->module);
1644  free(location);
1645  location = str2upper(strdup(concatenate(s->module, "!", NULL)));
1646  e = FindEntity(location, name);
1647  if(e == entity_undefined) {
1648  pips_internal_error("Entity '%s' located in module '%s' can't be "
1649  "found in symbol table, are you sure that you parsed the module "
1650  "first ? Aborting\n",name, s->module);
1651  }
1652  } else {
1653  e = FindOrCreateEntity(location, name);
1654  }
1657  if(entity_type(e) == type_undefined)
1659  }
1660  //if(entity_storage(e)==storage_undefined) entity_storage(e) = make_storage_rom();
1661  free(name);
1662  return e;
1663  }
1664  //it is a module and we do not know it yet, so we put an empty content in it
1665  if(module) {
1666  //message_assert("arg ! bad handling",entity_initial(e)==value_undefined);
1667  //fprintf(stderr,"value ... ... ... %s\n",entity_initial(e)==value_undefined?"ok":"nok");
1668  if(entity_initial(e) == value_undefined) {
1670  strdup(""),
1671  make_sequence(NIL),
1672  NULL,
1674  }
1675 
1676  }
1677  free(name);
1678  return e;
1679 }
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
entity gfc2pips_check_entity_block_data_exists(char *s)
Definition: gfc2pips.c:1558
entity gfc2pips_check_entity_module_exists(char *s)
Definition: gfc2pips.c:1537
basic gfc2pips_getbasic(gfc_symbol *s)
Definition: gfc2pips.c:1909
entity gfc2pips_check_entity_program_exists(char *s)
Definition: gfc2pips.c:1527
static char * module
Definition: pips.c:74
entity FindEntity(const char *package, const char *name)
Retrieve an entity from its package/module name and its local name.
Definition: entity.c:1503
entity make_empty_program(const char *name, language l)
Definition: entity.c:261
entity make_empty_blockdata(const char *name, language l)
Definition: entity.c:290
entity make_empty_subroutine(const char *name, language l)
Definition: entity.c:268
entity make_empty_function(const char *name, type r, language l)
Definition: entity.c:283
entity make_empty_f95module(const char *name, language l)
Definition: entity.c:275

References concatenate(), CurrentPackage, entity_initial, entity_type, entity_undefined, find_or_create_allocatable_struct(), FindEntity(), FindOrCreateEntity(), free(), gfc2pips_check_entity_block_data_exists(), gfc2pips_check_entity_module_exists(), gfc2pips_check_entity_program_exists(), gfc2pips_debug, gfc2pips_get_safe_name(), gfc2pips_getbasic(), gfc2pips_symbol2type(), make_code(), make_empty_blockdata(), make_empty_f95module(), make_empty_function(), make_empty_program(), make_empty_subroutine(), make_language_fortran95(), make_sequence(), make_value_code(), make_value_unknown(), module, module_name(), NIL, pips_internal_error, pips_user_error, str2upper(), strdup(), TOP_LEVEL_MODULE_NAME, type_undefined, and value_undefined.

Referenced by gfc2pips_args(), gfc2pips_code2instruction_(), gfc2pips_code2instruction__TOP(), gfc2pips_expr2expression(), gfc2pips_get_extern_entities(), gfc2pips_namespace(), and gfc2pips_symbol2data_instruction().

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

◆ gfc2pips_symbol2size()

int gfc2pips_symbol2size ( gfc_symbol *  s)

return the size of an elementary element: REAL*16 A CHARACTER*17 B

Parameters
ssymbol of the entity

Definition at line 1990 of file gfc2pips.c.

1990  {
1991  if(s->ts.type == BT_CHARACTER && s->ts.cl && s->ts.cl->length) {
1993  9,
1994  "size of %s: %zu\n",
1995  s->name,
1996  mpz_get_si(s->ts.cl->length->value.integer)
1997  );
1998  return mpz_get_si(s->ts.cl->length->value.integer);
1999  } else {
2000  gfc2pips_debug(9, "size of %s: %d\n",s->name,s->ts.kind);
2001  return s->ts.kind;
2002  }
2003 }

References gfc2pips_debug.

Referenced by gfc2pips_getbasic(), gfc2pips_make_zero_for_symbol(), gfc2pips_symbol2data_instruction(), and gfc2pips_vars_().

+ Here is the caller graph for this function:

◆ gfc2pips_symbol2sizeArray()

int gfc2pips_symbol2sizeArray ( gfc_symbol *  s)

calculate the total size of the array whatever the bounds are: A(-5,5)

Parameters
ssymbol of the array

Definition at line 2008 of file gfc2pips.c.

2008  {
2009  int retour = 1;
2010  list list_of_dimensions = NULL;
2011  int i = 0, j = 0;
2012  if(s && s->attr.dimension) {
2013  gfc_array_spec *as = s->as;
2014  const char *c;
2015  if(as != NULL && as->rank != 0 && as->type == AS_EXPLICIT) {
2016  i = as->rank - 1;
2017  do {
2018  retour *= gfc2pips_expr2int(as->upper[i])
2019  - gfc2pips_expr2int(as->lower[i]) + 1;
2020  } while(--i >= j);
2021  }
2022  }
2023  gfc2pips_debug(9, "size of %s: %d\n",s->name,retour);
2024  return retour;
2025 }

References gfc2pips_debug, and gfc2pips_expr2int().

+ Here is the call graph for this function:

◆ gfc2pips_symbol2specialType()

type gfc2pips_symbol2specialType ( gfc_symbol *  s)

Definition at line 1981 of file gfc2pips.c.

1981  {
1982 
1983  return type_undefined;
1984 }

References type_undefined.

◆ gfc2pips_symbol2top_entity()

entity gfc2pips_symbol2top_entity ( gfc_symbol *  s)

translate a gfc symbol to a top-level entity

Definition at line 1684 of file gfc2pips.c.

1684  {
1685  char* name = gfc2pips_get_safe_name(s->name);
1687  if(e != entity_undefined) {
1688  gfc2pips_debug(9,"Entity %s already exists\n",name);
1689  free(name);
1690  return e;
1691  }
1695  if(entity_type(e) == type_undefined)
1697  //if(entity_storage(e)==storage_undefined) entity_storage(e) = make_storage_rom();
1698  free(name);
1699  return e;
1700 }
entity gfc2pips_check_entity_doesnt_exists(char *s)
Definition: gfc2pips.c:1497

References entity_initial, entity_type, entity_undefined, FindOrCreateEntity(), free(), gfc2pips_check_entity_doesnt_exists(), gfc2pips_debug, gfc2pips_get_safe_name(), gfc2pips_symbol2type(), make_value_unknown(), str2upper(), TOP_LEVEL_MODULE_NAME, type_undefined, and value_undefined.

+ Here is the call graph for this function:

◆ gfc2pips_symbol2type()

type gfc2pips_symbol2type ( gfc_symbol *  s)

try to create the PIPS type that would be associated by the PIPS default parser

Definition at line 1966 of file gfc2pips.c.

1966  {
1967  //beware the size of strings
1968  basic b = gfc2pips_getbasic(s);
1969  if(b == basic_undefined) {
1970  gfc2pips_debug( 5, "WARNING: unknown type !\n" );
1971  return MakeTypeUnknown();
1972  }
1973 
1974  if(basic_derived_p(b)) {
1975  return MakeTypeVariable(b, NULL);
1976  } else {
1978  }
1979 }
type MakeTypeUnknown(void)
Definition: type.c:97
type MakeTypeVariable(basic, cons *)
BEGIN_EOLE.
Definition: type.c:116
#define basic_derived_p(x)
Definition: ri.h:638

References basic_derived_p, basic_undefined, gfc2pips_debug, gfc2pips_get_list_of_dimensions2(), gfc2pips_getbasic(), MakeTypeUnknown(), and MakeTypeVariable().

Referenced by gfc2pips_expr2entity(), gfc2pips_symbol2entity(), gfc2pips_symbol2top_entity(), and gfc2pips_vars_().

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

◆ gfc2pips_test_allocatable()

bool gfc2pips_test_allocatable ( gfc_namespace __attribute__((__unused__)) *  ns,
gfc_symtree *  st 
)

test if it is a allocatable entity

Definition at line 1439 of file gfc2pips.c.

1440  {
1441  if(!st || !st->n.sym)
1442  return false;
1443  return st->n.sym->attr.allocatable;
1444 }

◆ gfc2pips_test_arg()

bool gfc2pips_test_arg ( gfc_namespace __attribute__((__unused__)) *  ns,
gfc_symtree *  st 
)

test if it is a dummy parameter (formal parameter)

Definition at line 1448 of file gfc2pips.c.

1449  {
1450  if(!st || !st->n.sym)
1451  return false;
1452  return st->n.sym->attr.flavor == EXPR_VARIABLE && st->n.sym->attr.dummy;
1453 }

◆ gfc2pips_test_data()

bool gfc2pips_test_data ( gfc_namespace __attribute__((__unused__)) *  ns,
gfc_symtree *  st 
)

test if there is a value to stock

Definition at line 1457 of file gfc2pips.c.

1458  {
1459  if(!st || !st->n.sym)
1460  return false;
1461  return st->n.sym->value && st->n.sym->attr.flavor != FL_PARAMETER
1462  && st->n.sym->attr.flavor != FL_PROCEDURE;
1463 }

Referenced by gfc2pips_get_data_vars().

+ Here is the caller graph for this function:

◆ gfc2pips_test_derived()

bool gfc2pips_test_derived ( gfc_namespace __attribute__((__unused__)) *  ns,
gfc_symtree *  st 
)

Definition at line 1407 of file gfc2pips.c.

1408  {
1409  if(!st || !st->n.sym)
1410  return false;
1411  return st->n.sym->attr.flavor == FL_DERIVED
1412  //&& !st->n.sym->attr.external
1413  && !st->n.sym->attr.pointer && !st->n.sym->attr.dummy;
1414 }

Referenced by gfc2pips_getTypesDeclared().

+ Here is the caller graph for this function:

◆ gfc2pips_test_dimensions()

bool gfc2pips_test_dimensions ( gfc_namespace __attribute__((__unused__)) *  ns,
gfc_symtree *  st 
)

Definition at line 1490 of file gfc2pips.c.

1491  {
1492  if(!st || !st->n.sym)
1493  return false;
1494  return st->n.sym->attr.dimension;
1495 }

◆ gfc2pips_test_extern()

bool gfc2pips_test_extern ( gfc_namespace __attribute__((__unused__)) *  ns,
gfc_symtree *  st 
)

test if it is an external function

Definition at line 1419 of file gfc2pips.c.

1420  {
1421  if(!st || !st->n.sym)
1422  return false;
1423  return st->n.sym->attr.external || st->n.sym->attr.proc == PROC_EXTERNAL;
1424 }

Referenced by gfc2pips_get_extern_entities().

+ Here is the caller graph for this function:

◆ gfc2pips_test_save()

bool gfc2pips_test_save ( gfc_namespace __attribute__((__unused__)) *  ns,
gfc_symtree *  st 
)

test if there is a SAVE to do

Definition at line 1467 of file gfc2pips.c.

1468  {
1469  if(!st || !st->n.sym)
1470  return false;
1471  return st->n.sym->attr.save != SAVE_NONE;
1472 }

Referenced by gfc2pips_get_save(), and gfc2pips_vars_().

+ Here is the caller graph for this function:

◆ gfc2pips_test_subroutine()

bool gfc2pips_test_subroutine ( gfc_namespace __attribute__((__unused__)) *  ns,
gfc_symtree *  st 
)

Definition at line 1425 of file gfc2pips.c.

1426  {
1427  if(!st || !st->n.sym)
1428  return false;
1429  return (st->n.sym->attr.flavor == FL_PROCEDURE && (st->n.sym->attr.subroutine
1430  || st->n.sym->attr.function) && strncmp(st->n.sym->name,
1431  "__",
1432  strlen("__")) != 0);
1433  //return st->n.sym->attr.subroutine && strcmp(str2upper(strdup(ns->proc_name->name)), str2upper(strdup(st->n.sym->name)))!=0;
1434 }

Referenced by gfc2pips_namespace().

+ Here is the caller graph for this function:

◆ gfc2pips_test_variable()

bool gfc2pips_test_variable ( gfc_namespace __attribute__((__unused__)) *  ns,
gfc_symtree *  st 
)

get variables who are not implicit or are needed to be declared for data statements hence variable that should be explicit in PIPS

& ( (!st->n.sym->attr.implicit_type||st->n.sym->attr.save==SAVE_EXPLICIT) || st->n.sym->value//very important )

Definition at line 1372 of file gfc2pips.c.

1373  {
1374  if(!st || !st->n.sym)
1375  return false;
1376  bool variable_p = TRUE;
1377 
1378  variable_p = (st->n.sym->attr.flavor == FL_VARIABLE || st->n.sym->attr.flavor
1379  == FL_PARAMETER);
1380 
1381  /*&& (
1382  (!st->n.sym->attr.implicit_type||st->n.sym->attr.save==SAVE_EXPLICIT)
1383  || st->n.sym->value//very important
1384  )*/
1385  variable_p = variable_p && !st->n.sym->attr.external;
1386  //&& !st->n.sym->attr.in_common
1387  variable_p = variable_p && !st->n.sym->attr.pointer;
1388  variable_p = variable_p && !st->n.sym->attr.dummy;
1389  variable_p = variable_p && !(st->n.sym->ts.type == BT_DERIVED);
1390 
1391  return variable_p;
1392 }
static bool variable_p(entity e)
lready exist in cprettyprint but in mode static.
Definition: prettyprint.c:207

References variable_p().

Referenced by gfc2pips_vars().

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

◆ gfc2pips_test_variable2()

bool gfc2pips_test_variable2 ( gfc_namespace __attribute__((__unused__)) *  ns,
gfc_symtree *  st 
)

Definition at line 1397 of file gfc2pips.c.

1398  {
1399  if(!st || !st->n.sym)
1400  return false;
1401  return st->n.sym->attr.flavor == EXPR_VARIABLE && !st->n.sym->attr.dummy;
1402 }

◆ gfc2pips_vars()

list gfc2pips_vars ( gfc_namespace *  ns)

Extract every and each variable from a namespace.

Definition at line 954 of file gfc2pips.c.

954  {
955  if(ns) {
957  ns->sym_root,
959  }
960  return NULL;
961 }
bool gfc2pips_test_variable(gfc_namespace __attribute__((__unused__)) *ns, gfc_symtree *st)
get variables who are not implicit or are needed to be declared for data statements hence variable th...
Definition: gfc2pips.c:1372
list gfc2pips_vars_(gfc_namespace *ns, list variables_p)
Convert the list of gfc symbols into a list of pips entities with storage, type, everything.
Definition: gfc2pips.c:966

References gen_nreverse(), getSymbolBy(), gfc2pips_test_variable(), and gfc2pips_vars_().

Referenced by gfc2pips_namespace().

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

◆ gfc2pips_vars_()

list gfc2pips_vars_ ( gfc_namespace *  ns,
list  variables_p 
)

Convert the list of gfc symbols into a list of pips entities with storage, type, everything.

=0;j=1; arguments_p = arguments; while(arguments_p){ fprintf(stderr,"%s %s\n",entity_local_name((entity)arguments_p->car.e),current_symtree->name); if(strcmp_( entity_local_name( (entity)arguments_p->car.e ), current_symtree->name )==0 ){ i=j; break; } j++; POP(arguments_p); }

f(entity_storage((entity)variables->car.e)==storage_undefined) entity_storage((entity)variables->car.e) = make_storage_formal( make_formal( gfc2pips_main_entity, i ) );

we do know this entity is allocatable, it's place is probably in the heap but it's not so evident we represent it with a struct encaspulating the real array !

f(current_symtree->n.sym->attr.pointer){ basic b = make_basic(is_basic_pointer, Type); type newType = make_type(is_type_variable, make_variable(b, NIL, NIL)); entity_type((entity)variables->car.e) = newType; }

Definition at line 966 of file gfc2pips.c.

966  {
967  list variables = NULL;
968  //variables_p = gen_nreverse(getSymbolBy(ns,ns->sym_root, gfc2pips_test_variable));
969  //balancer la suite dans une fonction à part afin de pouvoir la réutiliser pour les calls
970  //list arguments,arguments_p;
971  //arguments = arguments_p = gfc2pips_args(ns);
972  while(variables_p) {
973  type Type = type_undefined;
974  //create entities here
975  gfc_symtree *current_symtree = (gfc_symtree*)variables_p->car.e;
976  if(current_symtree && current_symtree->n.sym) {
977  gfc2pips_debug(3, "translation of entity start\n");
978  if(current_symtree->n.sym->attr.in_common) {
979  gfc2pips_debug(4, " %s is in a common, skipping\r\n", (current_symtree->name) );
980  //we have to skip them, they don't have any place here
981  POP( variables_p );
982  continue;
983  }
984  if(current_symtree->n.sym->attr.use_assoc) {
985  gfc2pips_debug(4, " %s is in a module, skipping\r\n", (current_symtree->name) );
986  //we have to skip them, they don't have any place here
987  POP( variables_p );
988  continue;
989  }
990  gfc2pips_debug(4, " symbol: %s size: %d\r\n", (current_symtree->name), current_symtree->n.sym->ts.kind );
991  intptr_t TypeSize = gfc2pips_symbol2size(current_symtree->n.sym);
992  value Value;// = make_value_unknown();
993  Type = gfc2pips_symbol2type(current_symtree->n.sym);
994  gfc2pips_debug(3, "Type done\n");
995 
996  //handle the value
997  //don't ask why it is is_value_constant
998  if(Type != type_undefined && current_symtree->n.sym->ts.type
999  == BT_CHARACTER) {
1000  gfc2pips_debug(5, "the symbol is a string\n");
1001  Value = make_value_constant(make_constant_litteral()//MakeConstant(current_symtree->n.sym->value->value.character.string,is_basic_string)
1002  );
1003  } else {
1004  gfc2pips_debug(5, "the symbol is a constant\n");
1006  }
1007 
1008  int i, j = 0;
1009  //list list_of_dimensions = gfc2pips_get_list_of_dimensions(current_symtree);
1010  //si allocatable alors on fait qqch d'un peu spécial
1011 
1012  /*
1013  * we look into the list of arguments to know if the entity is in and thus
1014  * the offset in the stack
1015  */
1016  /*i=0;j=1;
1017  arguments_p = arguments;
1018  while(arguments_p){
1019  //fprintf(stderr,"%s %s\n",entity_local_name((entity)arguments_p->car.e),current_symtree->name);
1020  if(strcmp_( entity_local_name( (entity)arguments_p->car.e ), current_symtree->name )==0 ){
1021  i=j;
1022  break;
1023  }
1024  j++;
1025  POP(arguments_p);
1026  }*/
1027  //fprintf(stderr,"%s %d\n",current_symtree->name,i);
1028 
1029  entity
1030  newEntity =
1032  str2upper(gfc2pips_get_safe_name(current_symtree->name)));
1033  variables = CONS( ENTITY,newEntity,variables );
1034  entity_type((entity)variables->car.e) = Type;
1035  entity_initial((entity)variables->car.e) = Value;
1036  if(current_symtree->n.sym->attr.dummy) {
1037  gfc2pips_debug(0,"dummy parameter \"%s\" put in FORMAL\n",current_symtree->n.sym->name);
1038  //we have a formal parameter (argument of the function/subroutine)
1039  /*if(entity_storage((entity)variables->car.e)==storage_undefined)
1040  entity_storage((entity)variables->car.e) = make_storage_formal(
1041  make_formal(
1042  gfc2pips_main_entity,
1043  i
1044  )
1045  );*/
1046  } else if(current_symtree->n.sym->attr.flavor == FL_PARAMETER) {
1047  gfc2pips_debug(9,"Variable \"%s\" (PARAMETER) put in FORMAL\n",current_symtree->n.sym->name);
1048  //we have a parameter, we rewrite some attributes of the entity
1049  entity_type((entity)variables->car.e)
1051  entity_type((entity)variables->car.e)));
1053  = MakeValueSymbolic(gfc2pips_expr2expression(current_symtree->n.sym->value));
1055  gfc2pips_debug(0,"!!!!!! Variable \"%s\" (PARAMETER) put in formal WITHOUT RANK\n",current_symtree->n.sym->name);
1058  }
1059  } else {
1060  //we have a variable
1062  if(gfc2pips_test_save(NULL, current_symtree)) {
1065  gfc2pips_debug(9,"Variable \"%s\" put in RAM \"%s\"\n",
1068  //set_common_to_size(StaticArea,CurrentOffsetOfArea(StaticArea,(entity)variables->car.e));
1069  } else {
1070  if(current_symtree->n.sym->as && current_symtree->n.sym->as->type
1071  != AS_EXPLICIT && !current_symtree->n.sym->value) {//some other criteria is needed
1072  if(current_symtree->n.sym->attr.allocatable) {
1073  /* we do know this entity is allocatable,
1074  * it's place is *probably* in the heap but it's not so evident
1075  * we represent it with a struct encaspulating the real array !
1076  */
1077  area = HeapArea;
1078  } else {
1079  area = StackArea;
1080  }
1081  } else {
1082  area = DynamicArea;
1083  }
1085  9,
1086  "Variable \"%s\" put in RAM \"%s\"\n",
1091  );
1092  }
1094  area,
1096  NULL);
1098  entity_storage( (entity)variables->car.e ) = make_storage_ram(_r_);
1099  }
1100 
1101  //code for pointers
1102  //if(Type!=type_undefined){
1103  //variable_dimensions(type_variable(entity_type( (entity)variables->car.e ))) = gfc2pips_get_list_of_dimensions(current_symtree);
1104  /*if(current_symtree->n.sym->attr.pointer){
1105  basic b = make_basic(is_basic_pointer, Type);
1106  type newType = make_type(is_type_variable, make_variable(b, NIL, NIL));
1107  entity_type((entity)variables->car.e) = newType;
1108  }*/
1109  //}
1110  gfc2pips_debug(3, "translation for %s end\n",entity_name(newEntity));
1111  } else {
1112  variables_p->car.e = NULL;
1113  }
1114  POP( variables_p );
1115  }
1116  return variables;
1117 }
value make_value_expression(expression _field_)
Definition: ri.c:2850
constant make_constant_litteral(void)
Definition: ri.c:418
int Value
value MakeValueSymbolic(expression e)
this function creates a value for a symbolic constant.
Definition: constant.c:581
#define ALLOCATABLE_AREA_LOCAL_NAME
Definition: naming-local.h:73
#define STACK_AREA_LOCAL_NAME
Definition: naming-local.h:72
@ ENTITY_STATIC_AREA
#define intptr_t
Definition: stdint.in.h:294

References ABSTRACT_LOCATION, ALLOCATABLE_AREA_LOCAL_NAME, cons::car, CONS, CurrentPackage, DYNAMIC_AREA_LOCAL_NAME, DynamicArea, gen_chunk::e, ENTITY, entity_initial, entity_kind, entity_local_name(), entity_name, ENTITY_STATIC_AREA, entity_storage, entity_type, entity_undefined, FindOrCreateEntity(), get_current_module_entity(), gfc2pips_debug, gfc2pips_expr2expression(), gfc2pips_get_safe_name(), gfc2pips_main_entity, gfc2pips_symbol2size(), gfc2pips_symbol2type(), gfc2pips_test_save(), HeapArea, int_to_expression(), intptr_t, make_constant_litteral(), make_formal(), make_functional(), make_ram(), make_storage_formal(), make_storage_ram(), make_type_functional(), make_value_constant(), make_value_expression(), MakeValueSymbolic(), NIL, POP, STACK_AREA_LOCAL_NAME, StackArea, STATIC_AREA_LOCAL_NAME, storage_undefined, str2upper(), type_undefined, UNKNOWN_RAM_OFFSET, and variables.

Referenced by gfc2pips_vars().

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

◆ strdup()

char* strdup ( const char *  )

EXPR_STRUCTURE, EXPR_SUBSTRING, EXPR_NULL, EXPR_ARRAY are not dumped.

EXPR_STRUCTURE is for user defined structures:

  • TYPE point
  • REAL x,y
  • END TYPE point not implemented in PIPS or partially: for C structures only

    EXPR_SUBSTRING is for a substring of a constant string, but never encountered even with specific test case

    EXPR_NULL The NULL pointer value (which also has a basic type), but POINTER is not implemented in PIPS

    EXPR_ARRAY array constructor but seem to be destroyed to the profit of RAW values

Referenced by gfc2pips_check_entity_block_data_exists(), gfc2pips_check_entity_doesnt_exists(), gfc2pips_check_entity_exists(), gfc2pips_check_entity_module_exists(), gfc2pips_check_entity_program_exists(), gfc2pips_get_list_of_dimensions2(), gfc2pips_get_safe_name(), gfc2pips_gfc_char_t2string(), gfc2pips_namespace(), and gfc2pips_symbol2entity().

+ Here is the caller graph for this function:

Variable Documentation

◆ CurrentPackage

◆ gfc2pips_format

list gfc2pips_format = NULL

◆ gfc2pips_format2

list gfc2pips_format2 = NULL

◆ gfc2pips_last_created_label

int gfc2pips_last_created_label = 95000
static

Definition at line 104 of file gfc2pips.c.

Referenced by gfc2pips_code2instruction(), and gfc2pips_code2instruction_().

◆ gfc2pips_last_created_label_step

int gfc2pips_last_created_label_step = 2
static

Definition at line 105 of file gfc2pips.c.

◆ gfc2pips_last_statement_is_loop

bool gfc2pips_last_statement_is_loop = false

Definition at line 2108 of file gfc2pips.c.

◆ gfc2pips_main_entity

◆ gfc_function_body

statement gfc_function_body

Definition at line 95 of file gfc2pips.c.

Referenced by gfc2pips_namespace().

◆ gfc_option

gfc_option_t gfc_option
extern

Cmd line options.

Referenced by load_entities(), and save_entities().

◆ global_current_offset

int global_current_offset = 0

Definition at line 98 of file gfc2pips.c.

Referenced by gfc2pips_expr2entity().