PIPS
|
#include "genC.h"
#include "gfc2pips.h"
#include "linear.h"
#include "ri.h"
#include "ri-util.h"
#include "parser_private.h"
#include "syntax.h"
Go to the source code of this file.
Macros | |
#define | gfc2pips_debug pips_debug |
Typedefs | |
typedef enum gfc2pips_main_entity_type | gfc2pips_main_entity_type |
Enumerations | |
enum | gfc2pips_main_entity_type { MET_PROG , MET_SUB , MET_FUNC , MET_MOD , MET_BLOCK , MET_MODULE } |
Functions | |
int | asprintf (char **strp, const char *fmt,...) |
We have here to HACK GCC include that prevent use of these function. More... | |
void | gfc2pips_add_to_callees (entity e) |
Add an entity to the list of callees. More... | |
void | pips_init () |
list | get_use_entities_list (struct gfc_namespace *ns) |
void | save_entities () |
basic | gfc2pips_getbasic (gfc_symbol *s) |
char * | str2upper (char s[]) |
put the given char table to upper case More... | |
char * | strn2upper (char s[], size_t n) |
put the n first elements of the given char table to upper case More... | |
char * | strrcpy (char *dest, __const char *src) |
same as strcpy, but begin by the end of the string allowing you to give twice the same string More... | |
int | strcmp_ (__const char *__s1, __const char *__s2) |
compare the strings in upper case mode More... | |
int | strncmp_ (__const char *__s1, __const char *__s2, size_t __n) |
compare the strings in upper case mode More... | |
int | fcopy (const char *old, const char *new) |
copy the content of the first file to the second one More... | |
void | gfc2pips_truncate_useless_zeroes (char *s) |
expurgates a string representing a REAL, could be a pre-prettyprinter processing 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... | |
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... | |
gfc_symtree * | gfc2pips_getSymtreeByName (const char *name, gfc_symtree *st) |
gfc2pips_main_entity_type | get_symbol_token (gfc_symbol *root_sym) |
list | gfc2pips_vars (gfc_namespace *ns) |
Extract every and each variable from a namespace. More... | |
list | gfc2pips_parameters (gfc_namespace *ns, gfc2pips_main_entity_type bloc_token) |
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) |
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) |
bool | gfc2pips_test_subroutine (gfc_namespace *__attribute__((__unused__)) ns, gfc_symtree *st) |
bool | gfc2pips_test_data (gfc_namespace *__attribute__((__unused__)) ns, gfc_symtree *st) |
bool | gfc2pips_test_save (gfc_namespace *__attribute__((__unused__)) ns, gfc_symtree *st) |
bool | gfc2pips_get_commons (gfc_namespace *__attribute__((__unused__)) ns, gfc_symtree *__attribute__((__unused__)) st) |
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 *sym) |
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 *sym) |
translate a gfc symbol to a top-level entity More... | |
entity | gfc2pips_char2entity (char *p, 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 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... | |
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... | |
value | gfc2pips_symbol2value (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... | |
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... | |
bool | gfc2pips_there_is_a_range (gfc_array_ref *ar) |
list | gfc2pips_mkRangeExpression (gfc_array_ref *ar) |
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 *tested_variable, 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_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) |
list | gfc2pips_arglist2arglist (gfc_actual_arglist *act) |
void | gfc2pips_initAreas (void) |
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_shiftAdressesOfArea (entity _area, int old_offset, int size, int max_offset, int shift) |
void | gfc2pips_push_comment (locus l, unsigned long nb, char s) |
bool | gfc2pips_check_already_done (locus l) |
unsigned long | gfc2pips_get_num_of_gfc_code (gfc_code *c) |
string | gfc2pips_get_comment_of_code (gfc_code *c) |
gfc2pips_comments | gfc2pips_pop_comment (void) |
void | gfc2pips_set_last_comments_done (unsigned long nb) |
void | gfc2pips_assign_num_to_last_comments (unsigned long nb) |
void | gfc2pips_assign_gfc_code_to_last_comments (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) |
bool | gfc2pips_comment_num_exists (unsigned long num) |
void | gfc2pips_pop_not_done_comments (void) |
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. More... | |
void | gfc2pips_push_last_code (gfc_code *c) |
gfc_code * | gfc2pips_get_last_loop (void) |
void | gfc2pips_push_loop (gfc_code *c) |
void | gfc2pips_pop_loop (void) |
list | gen_union (list a, list b) |
generate an union of unique elements taken from A and B More... | |
Variables | |
list | gfc_module_callees |
Store the list of callees. More... | |
list | gfc2pips_list_of_declared_code |
list | gfc2pips_list_of_loops |
list * | gfc2pips_list_of_all_modules |
#define gfc2pips_debug pips_debug |
Definition at line 59 of file gfc2pips-private.h.
typedef enum gfc2pips_main_entity_type gfc2pips_main_entity_type |
Enumerator | |
---|---|
MET_PROG | |
MET_SUB | |
MET_FUNC | |
MET_MOD | |
MET_BLOCK | |
MET_MODULE |
Definition at line 62 of file gfc2pips-private.h.
int asprintf | ( | char ** | resultp, |
const char * | format, | ||
... | |||
) |
We have here to HACK GCC include that prevent use of these function.
We have here to HACK GCC include that prevent use of these function.
Copyright (C) 1999, 2002, 2006-2007, 2009-2014 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/.
Specification.
Definition at line 30 of file asprintf.c.
References vasprintf().
int fcopy | ( | const char * | old, |
const char * | new | ||
) |
copy the content of the first file to the second one
copy the content of the first file to the second one
Definition at line 143 of file gfc2pips-util.c.
Referenced by gfc2pips_namespace().
generate an union of unique elements taken from A and B
Definition at line 47 of file gfc2pips-util.c.
References CAR, CHUNK, gen_cons(), gen_in_list_p(), and POP.
Referenced by gfc2pips_namespace().
gfc2pips_main_entity_type get_symbol_token | ( | gfc_symbol * | root_sym | ) |
Definition at line 772 of file gfc2pips.c.
References fprintf(), MET_BLOCK, MET_FUNC, MET_MODULE, MET_PROG, MET_SUB, and pips_user_error.
Referenced by gfc2pips_namespace().
list get_use_entities_list | ( | struct gfc_namespace * | ns | ) |
Create an entity
Definition at line 316 of file gfc2pips-util.c.
References asprintf, CONS, CurrentPackage, ENTITY, entity_initial, entity_name, entity_storage, entity_type, F95_USE_LOCAL_NAME, FindOrCreateEntity(), FOREACH, hash_get(), HASH_UNDEFINED_VALUE, make_storage_rom(), make_type_unknown(), make_value_unknown(), malloc(), and ns2use.
Referenced by gfc2pips_namespace().
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.
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().
void gfc2pips_add_to_callees | ( | entity | e | ) |
Add an entity to the list of callees.
Definition at line 67 of file gfc2pips-util.c.
References CONS, CurrentPackage, entity_local_name(), gfc2pips_debug, gfc_module_callees, intrinsic_entity_p(), and strcmp_().
Referenced by gfc2pips_code2instruction_(), and gfc2pips_get_extern_entities().
list gfc2pips_arglist2arglist | ( | gfc_actual_arglist * | act | ) |
Definition at line 4287 of file gfc2pips.c.
References CDR, CONS, EXPRESSION, expression_undefined, gfc2pips_expr2expression(), and NIL.
Referenced by gfc2pips_code2instruction_().
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.
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().
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)
ar | the 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.
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().
void gfc2pips_assign_gfc_code_to_last_comments | ( | gfc_code * | c | ) |
Definition at line 165 of file gfc2pips-comments.c.
References _gfc2pips_comments_::done, _gfc2pips_comments_::gfc, gfc2pips_comments_stack_, _gfc2pips_comments_::next, and _gfc2pips_comments_::num.
void gfc2pips_assign_gfc_code_to_num_comments | ( | gfc_code * | c, |
unsigned long | num | ||
) |
Definition at line 196 of file gfc2pips-comments.c.
References _gfc2pips_comments_::gfc, gfc2pips_comments_stack_, _gfc2pips_comments_::next, num, and _gfc2pips_comments_::num.
Referenced by gfc2pips_code2instruction__TOP().
void gfc2pips_assign_num_to_last_comments | ( | unsigned long | nb | ) |
Definition at line 156 of file gfc2pips-comments.c.
References _gfc2pips_comments_::done, gfc2pips_comments_stack, _gfc2pips_comments_::num, and _gfc2pips_comments_::prev.
expression gfc2pips_buildCaseTest | ( | gfc_expr * | tested_variable, |
gfc_case * | cp | ||
) |
Definition at line 3364 of file gfc2pips.c.
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().
entity gfc2pips_char2entity | ( | char * | p, |
char * | s | ||
) |
a little bit more elaborated FindOrCreateEntity
Definition at line 1705 of file gfc2pips.c.
References entity_initial, entity_type, FindOrCreateEntity(), free(), gfc2pips_get_safe_name(), make_type_unknown(), make_value_unknown(), package, str2upper(), type_undefined, and value_undefined.
bool gfc2pips_check_already_done | ( | locus | l | ) |
Definition at line 68 of file gfc2pips-comments.c.
References gfc2pips_comments_stack, _gfc2pips_comments_::l, and _gfc2pips_comments_::prev.
Referenced by gfc2pips_push_comment().
entity gfc2pips_check_entity_block_data_exists | ( | char * | s | ) |
Definition at line 1558 of file gfc2pips.c.
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().
entity gfc2pips_check_entity_doesnt_exists | ( | char * | s | ) |
Definition at line 1497 of file gfc2pips.c.
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().
entity gfc2pips_check_entity_exists | ( | const char * | s | ) |
Definition at line 1567 of file gfc2pips.c.
References concatenate(), CurrentPackage, entity_domain, full_name, gen_find_tabulated(), MODULE_SEP_STRING, str2upper(), and strdup().
Referenced by gfc2pips_computeEquiv().
entity gfc2pips_check_entity_module_exists | ( | char * | s | ) |
Definition at line 1537 of file gfc2pips.c.
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().
entity gfc2pips_check_entity_program_exists | ( | char * | s | ) |
Definition at line 1527 of file gfc2pips.c.
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().
entity gfc2pips_code2get_label | ( | gfc_code * | c | ) |
Definition at line 3756 of file gfc2pips.c.
References entity_empty_label(), gfc2pips_debug, and gfc2pips_int2label().
Referenced by gfc2pips_code2instruction(), gfc2pips_code2instruction_(), gfc2pips_code2instruction__TOP(), and gfc2pips_dumpSELECT().
entity gfc2pips_code2get_label2 | ( | gfc_code * | c | ) |
Definition at line 3778 of file gfc2pips.c.
References entity_empty_label(), gfc2pips_debug, and gfc2pips_int2label().
Referenced by gfc2pips_code2instruction_().
entity gfc2pips_code2get_label3 | ( | gfc_code * | c | ) |
Definition at line 3796 of file gfc2pips.c.
References entity_empty_label(), gfc2pips_debug, and gfc2pips_int2label().
Referenced by gfc2pips_code2instruction_().
entity gfc2pips_code2get_label4 | ( | gfc_code * | c | ) |
Definition at line 3814 of file gfc2pips.c.
References entity_empty_label(), gfc2pips_debug, and gfc2pips_int2label().
Referenced by gfc2pips_code2instruction_().
instruction gfc2pips_code2instruction | ( | gfc_code * | c, |
bool | force_sequence | ||
) |
Build an instruction sequence.
same as {func}__TOP but without the declarations
ns | the top-level entity from gfc. We need it to retrieve some more informations |
c | the struct containing information about the instruction |
Definition at line 2368 of file gfc2pips.c.
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().
instruction gfc2pips_code2instruction_ | ( | gfc_code * | c | ) |
this function create an atomic statement, no block of data
c | the instruction to translate from gfc |
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.
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().
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
ns | the top-level entity from gfc. We need it to retrieve some more informations |
c | the 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.
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().
bool gfc2pips_comment_num_exists | ( | unsigned long | num | ) |
Definition at line 204 of file gfc2pips-comments.c.
References gfc2pips_comments_stack, num, _gfc2pips_comments_::num, and _gfc2pips_comments_::prev.
void gfc2pips_computeAdresses | ( | void | ) |
compute addresses of the stack, heap, dynamic and static areas
Definition at line 4332 of file gfc2pips.c.
References gfc2pips_computeAdressesDynamic(), gfc2pips_computeAdressesHeap(), and gfc2pips_computeAdressesStatic().
Referenced by gfc2pips_namespace().
void gfc2pips_computeAdressesDynamic | ( | void | ) |
compute the addresses of the entities declared in DynamicArea
Definition at line 4347 of file gfc2pips.c.
References DynamicArea, and gfc2pips_computeAdressesOfArea().
Referenced by gfc2pips_computeAdresses().
void gfc2pips_computeAdressesHeap | ( | void | ) |
compute the addresses of the entities declared in StaticArea
Definition at line 4353 of file gfc2pips.c.
References gfc2pips_computeAdressesOfArea(), and HeapArea.
Referenced by gfc2pips_computeAdresses().
compute the addresses of the entities declared in the given entity
Definition at line 4360 of file gfc2pips.c.
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().
void gfc2pips_computeAdressesStatic | ( | void | ) |
compute the addresses of the entities declared in StaticArea
Definition at line 4341 of file gfc2pips.c.
References gfc2pips_computeAdressesOfArea(), and StaticArea.
Referenced by gfc2pips_computeAdresses().
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.
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().
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.
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_().
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.
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_().
int gfc2pips_expr2int | ( | gfc_expr * | expr | ) |
Definition at line 4238 of file gfc2pips.c.
Referenced by gfc2pips_expr2expression(), and gfc2pips_symbol2sizeArray().
Definition at line 4309 of file gfc2pips.c.
References CONS, EXPRESSION, gfc2pips_expr2expression(), and MakeCharacterConstantExpression().
Referenced by gfc2pips_code2instruction_().
Definition at line 4314 of file gfc2pips.c.
References CONS, EXPRESSION, gfc2pips_int2label(), MakeCharacterConstantExpression(), and MakeNullaryCall().
Referenced by gfc2pips_code2instruction_().
Definition at line 4319 of file gfc2pips.c.
References CONS, CurrentPackage, EXPRESSION, FindOrCreateEntity(), gfc2pips_get_safe_name(), MakeCharacterConstantExpression(), and MakeNullaryCall().
Referenced by gfc2pips_code2instruction_().
bool gfc2pips_exprIsVariable | ( | gfc_expr * | expr | ) |
Definition at line 4242 of file gfc2pips.c.
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.
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().
string gfc2pips_get_comment_of_code | ( | gfc_code * | c | ) |
Definition at line 93 of file gfc2pips-comments.c.
References empty_comments, free(), _gfc2pips_comments_::gfc, gfc2pips_comments_stack_, malloc(), _gfc2pips_comments_::next, and _gfc2pips_comments_::s.
Referenced by gfc2pips_code2instruction(), and gfc2pips_code2instruction__TOP().
bool gfc2pips_get_commons | ( | gfc_namespace *__attribute__((__unused__)) | ns, |
gfc_symtree *__attribute__((__unused__)) | st | ||
) |
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.
References getSymbolBy(), and gfc2pips_test_data().
Referenced by gfc2pips_code2instruction__TOP().
list gfc2pips_get_extern_entities | ( | gfc_namespace * | ns | ) |
build a list of externals entities
Definition at line 1219 of file gfc2pips.c.
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().
bool gfc2pips_get_incommon | ( | gfc_namespace *__attribute__((__unused__)) | ns, |
gfc_symtree *__attribute__((__unused__)) | st | ||
) |
gfc_code* gfc2pips_get_last_loop | ( | void | ) |
Definition at line 348 of file gfc2pips-util.c.
References cons::car, gen_chunk::e, and gfc2pips_list_of_loops.
Referenced by gfc2pips_code2instruction(), and gfc2pips_code2instruction_().
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.
References 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.
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().
unsigned long gfc2pips_get_num_of_gfc_code | ( | gfc_code * | c | ) |
Definition at line 79 of file gfc2pips-comments.c.
References _gfc2pips_comments_::gfc, gfc2pips_comments_stack_, and _gfc2pips_comments_::next.
Referenced by gfc2pips_code2instruction__TOP().
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.
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_().
list gfc2pips_get_save | ( | gfc_namespace * | ns | ) |
return a list of SAVE elements
Definition at line 1250 of file gfc2pips.c.
References getSymbolBy(), and gfc2pips_test_save().
Referenced by gfc2pips_code2instruction__TOP().
basic gfc2pips_getbasic | ( | gfc_symbol * | s | ) |
Allocatable handling : we convert it to a structure
Definition at line 1909 of file gfc2pips.c.
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().
gfc_symtree* gfc2pips_getSymtreeByName | ( | const char * | name, |
gfc_symtree * | st | ||
) |
Referenced by __attribute__(), gfc2pips_args(), and gfc2pips_namespace().
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.
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().
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
c | the table of integers in gfc |
nb | the 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.
References gfc2pips_gfc_char_t2string_(), and strdup().
Referenced by gfc2pips_expr2expression().
char* gfc2pips_gfc_char_t2string2 | ( | gfc_char_t * | c | ) |
translate the <nb> first elements of from a wide integer representation to a char representation
c | the gfc integer table |
Definition at line 1875 of file gfc2pips.c.
References malloc().
Referenced by gfc2pips_push_comment().
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
c | the table of integers in gfc |
nb | the 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.
References malloc().
Referenced by gfc2pips_gfc_char_t2string().
void gfc2pips_initAreas | ( | void | ) |
create a <dimension> from the integer value given
Definition at line 1736 of file gfc2pips.c.
References gfc2pips_int2expression(), int_to_expression(), make_dimension(), and NIL.
expression gfc2pips_int2expression | ( | int | n | ) |
translate a int to an expression
Definition at line 1745 of file gfc2pips.c.
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().
dump an integer to a PIPS label entity
n | the value of the integer |
Definition at line 1785 of file gfc2pips.c.
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().
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.
References is_basic_int, and MakeConstant().
Referenced by gfc2pips_expr2entity(), and gfc2pips_int2expression().
translate a boolean to a PIPS/fortran entity
Definition at line 1820 of file gfc2pips.c.
References is_basic_logical, and MakeConstant().
Referenced by gfc2pips_expr2entity(), and gfc2pips_logical2expression().
expression gfc2pips_logical2expression | ( | bool | b | ) |
translate a bool to an expression
Definition at line 1768 of file gfc2pips.c.
References entity_to_expression(), and gfc2pips_logical2entity().
Referenced by gfc2pips_expr2expression().
expression gfc2pips_make_zero_for_symbol | ( | gfc_symbol * | sym | ) |
Definition at line 3646 of file gfc2pips.c.
References gfc2pips_int2expression(), gfc2pips_real2expression(), gfc2pips_symbol2size(), and MakeComplexConstantExpression().
Referenced by gfc2pips_symbol2data_instruction().
list gfc2pips_mkRangeExpression | ( | gfc_array_ref * | ar | ) |
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.
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().
list gfc2pips_parameters | ( | gfc_namespace * | ns, |
gfc2pips_main_entity_type | bloc_token | ||
) |
Definition at line 793 of file gfc2pips.c.
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().
gfc2pips_comments gfc2pips_pop_comment | ( | void | ) |
Definition at line 128 of file gfc2pips-comments.c.
References gfc2pips_comments_stack, gfc2pips_comments_stack_, _gfc2pips_comments_::next, and _gfc2pips_comments_::prev.
Referenced by gfc2pips_pop_not_done_comments().
void gfc2pips_pop_loop | ( | void | ) |
Definition at line 356 of file gfc2pips-util.c.
References gfc2pips_list_of_loops, and POP.
Referenced by gfc2pips_code2instruction_().
void gfc2pips_pop_not_done_comments | ( | void | ) |
Definition at line 215 of file gfc2pips-comments.c.
void gfc2pips_push_comment | ( | locus | l, |
unsigned long | nb, | ||
char | s | ||
) |
Definition at line 37 of file gfc2pips-comments.c.
References _gfc2pips_comments_::done, _gfc2pips_comments_::gfc, gfc2pips_check_already_done(), gfc2pips_comments_stack, gfc2pips_comments_stack_, gfc2pips_gfc_char_t2string2(), _gfc2pips_comments_::l, malloc(), _gfc2pips_comments_::next, num, _gfc2pips_comments_::num, _gfc2pips_comments_::prev, printf(), _gfc2pips_comments_::s, and strrcpy().
void gfc2pips_push_last_code | ( | gfc_code * | c | ) |
Definition at line 242 of file gfc2pips-comments.c.
References gen_cons(), and gfc2pips_list_of_declared_code.
void gfc2pips_push_loop | ( | gfc_code * | c | ) |
Definition at line 353 of file gfc2pips-util.c.
References gen_cons(), and gfc2pips_list_of_loops.
Referenced by gfc2pips_code2instruction_().
entity gfc2pips_real2entity | ( | double | r | ) |
dump reals to PIPS entities
r | the double to create |
we have a big issue with reals: 16.53 => 16.530001 16.56 => 16.559999
Definition at line 1801 of file gfc2pips.c.
References gfc2pips_truncate_useless_zeroes(), is_basic_float, and MakeConstant().
Referenced by gfc2pips_expr2entity(), and gfc2pips_real2expression().
expression gfc2pips_real2expression | ( | double | r | ) |
translate a real to an expression
Definition at line 1757 of file gfc2pips.c.
References CreateIntrinsic(), entity_to_expression(), gfc2pips_real2entity(), and MakeFortranUnaryCall().
Referenced by gfc2pips_expr2expression(), and gfc2pips_make_zero_for_symbol().
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:
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.
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().
void gfc2pips_replace_comments_num | ( | unsigned long | old, |
unsigned long | new | ||
) |
Definition at line 182 of file gfc2pips-comments.c.
void gfc2pips_set_last_comments_done | ( | unsigned long | nb | ) |
Definition at line 145 of file gfc2pips-comments.c.
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.
Definition at line 225 of file gfc2pips-comments.c.
References cons::car, gen_chunk::e, gen_nreverse(), gen_nthcdr(), _gfc2pips_comments_::gfc, gfc2pips_comments_stack, gfc2pips_list_of_declared_code, _gfc2pips_comments_::num, and _gfc2pips_comments_::prev.
Referenced by gfc2pips_namespace().
void gfc2pips_shiftAdressesOfArea | ( | entity | _area, |
int | old_offset, | ||
int | size, | ||
int | max_offset, | ||
int | shift | ||
) |
Definition at line 4488 of file gfc2pips.c.
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.
instruction gfc2pips_symbol2data_instruction | ( | gfc_symbol * | sym | ) |
build a DATA statement, filling blanks with zeroes.
TODO:
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.
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().
entity gfc2pips_symbol2entity | ( | gfc_symbol * | sym | ) |
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.
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().
int gfc2pips_symbol2size | ( | gfc_symbol * | s | ) |
return the size of an elementary element: REAL*16 A CHARACTER*17 B
s | symbol of the entity |
Definition at line 1990 of file gfc2pips.c.
References gfc2pips_debug.
Referenced by gfc2pips_getbasic(), gfc2pips_make_zero_for_symbol(), gfc2pips_symbol2data_instruction(), and gfc2pips_vars_().
int gfc2pips_symbol2sizeArray | ( | gfc_symbol * | s | ) |
calculate the total size of the array whatever the bounds are: A(-5,5)
s | symbol of the array |
Definition at line 2008 of file gfc2pips.c.
References gfc2pips_debug, and gfc2pips_expr2int().
entity gfc2pips_symbol2top_entity | ( | gfc_symbol * | sym | ) |
translate a gfc symbol to a top-level entity
Definition at line 1684 of file gfc2pips.c.
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.
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.
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_().
value gfc2pips_symbol2value | ( | gfc_symbol * | s | ) |
bool gfc2pips_test_data | ( | gfc_namespace *__attribute__((__unused__)) | ns, |
gfc_symtree * | st | ||
) |
bool gfc2pips_test_derived | ( | gfc_namespace __attribute__((__unused__)) * | ns, |
gfc_symtree * | st | ||
) |
Definition at line 1407 of file gfc2pips.c.
Referenced by gfc2pips_getTypesDeclared().
bool gfc2pips_test_dimensions | ( | gfc_namespace *__attribute__((__unused__)) | ns, |
gfc_symtree * | st | ||
) |
bool gfc2pips_test_extern | ( | gfc_namespace *__attribute__((__unused__)) | ns, |
gfc_symtree * | st | ||
) |
bool gfc2pips_test_save | ( | gfc_namespace *__attribute__((__unused__)) | ns, |
gfc_symtree * | st | ||
) |
bool gfc2pips_test_subroutine | ( | gfc_namespace *__attribute__((__unused__)) | ns, |
gfc_symtree * | st | ||
) |
bool gfc2pips_test_variable | ( | gfc_namespace *__attribute__((__unused__)) | ns, |
gfc_symtree * | st | ||
) |
bool gfc2pips_test_variable2 | ( | gfc_namespace *__attribute__((__unused__)) | ns, |
gfc_symtree * | st | ||
) |
bool gfc2pips_there_is_a_range | ( | gfc_array_ref * | ar | ) |
void gfc2pips_truncate_useless_zeroes | ( | char * | s | ) |
expurgates a string representing a REAL, could be a pre-prettyprinter processing
1.0000000000e+00 becomes 1. 1234.5670000e+18 becomes 1234.567e+18
f(*s=='.'){ s='\0'; s–; gfc2pips_debug(9,"final dot retrieved\n"); }
Definition at line 172 of file gfc2pips-util.c.
References gfc2pips_debug, and start.
Referenced by gfc2pips_real2entity().
list gfc2pips_vars | ( | gfc_namespace * | ns | ) |
Extract every and each variable from a namespace.
Definition at line 954 of file gfc2pips.c.
References gen_nreverse(), getSymbolBy(), gfc2pips_test_variable(), and gfc2pips_vars_().
Referenced by gfc2pips_namespace().
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.
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().
void pips_init | ( | ) |
get NewGen data type description
Definition at line 240 of file gfc2pips-util.c.
References c_parser_private_spec, gen_init_external(), gen_read_spec(), load_entities(), parser_private_spec, PVECTEUR_NEWGEN_EXTERNAL, ri_spec, set_pips_meta_informations(), text_spec, vect_gen_allocated_memory(), vect_gen_copy_tree(), vect_gen_free(), vect_gen_read(), and vect_gen_write().
Referenced by gfc2pips_namespace().
void save_entities | ( | ) |
Definition at line 233 of file gfc2pips-util.c.
References entity_domain, gen_write_tabulated(), gfc_option, safe_fclose(), and safe_fopen().
Referenced by gfc2pips_namespace().
char* str2upper | ( | char | s[] | ) |
put the given char table to upper case
put the given char table to upper case
replace lower case char by upper case ones
Definition at line 83 of file gfc2pips-util.c.
Referenced by gfc2pips_char2entity(), 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_expr2entity(), gfc2pips_expr2expression(), gfc2pips_getbasic(), gfc2pips_symbol2entity(), gfc2pips_symbol2top_entity(), gfc2pips_vars_(), strcmp_(), and strncmp_().
int strcmp_ | ( | __const char * | __s1, |
__const char * | __s2 | ||
) |
compare the strings in upper case mode
compare the strings in upper case mode
Definition at line 119 of file gfc2pips-util.c.
References free(), ret, str2upper(), and strdup().
Referenced by __attribute__(), gfc2pips_add_to_callees(), and gfc2pips_namespace().
char* strn2upper | ( | char | s[], |
size_t | n | ||
) |
put the n first elements of the given char table to upper case
put the n first elements of the given char table to upper case
Definition at line 100 of file gfc2pips-util.c.
compare the strings in upper case mode
compare the strings in upper case mode
Definition at line 131 of file gfc2pips-util.c.
References free(), ret, str2upper(), and strdup().
Referenced by gfc2pips_get_safe_name().
char* strrcpy | ( | char * | dest, |
__const char * | src | ||
) |
same as strcpy, but begin by the end of the string allowing you to give twice the same string
same as strcpy, but begin by the end of the string allowing you to give twice the same string
Definition at line 110 of file gfc2pips-util.c.
References src.
Referenced by gfc2pips_push_comment().
list* gfc2pips_list_of_all_modules |
Definition at line 237 of file gfc2pips-private.h.
|
extern |
Definition at line 41 of file gfc2pips-util.c.
Referenced by gfc2pips_code2instruction__TOP(), gfc2pips_push_last_code(), and gfc2pips_shift_comments().
|
extern |
Definition at line 42 of file gfc2pips-util.c.
Referenced by gfc2pips_get_last_loop(), gfc2pips_pop_loop(), and gfc2pips_push_loop().
|
extern |
Store the list of callees.
Store the list of callees.
Definition at line 40 of file gfc2pips-util.c.
Referenced by gfc2pips_add_to_callees(), and gfc2pips_namespace().