PIPS
|
#include <stdio.h>
#include <string.h>
#include "genC.h"
#include "text.h"
#include "constants.h"
#include "text-util.h"
#include "properties.h"
#include "misc.h"
#include "linear.h"
#include "ri.h"
#include "ri-util.h"
#include "pipsdbm.h"
#include "workspace-util.h"
#include "prettyprint.h"
Go to the source code of this file.
Macros | |
#define | EQUIV_DEBUG 8 |
debugging for equivalences More... | |
#define | ADD_WORD_LIST_TO_TEXT(t, l) ADD_WORD_LIST_TO_TEXT_WITH_MARGIN(t, l, 0) |
To deal with declarations above ri-util and pipsdbm and text-util. More... | |
#define | ADD_WORD_LIST_TO_TEXT_WITH_MARGIN(t, l, m) |
Functions | |
static list | f77_f95_style_management (list prev, string str, bool allocatable_pass_p, bool space_p) |
This handle the fact that a Fortran95 declaration use "::" as a separator between type and variable name. More... | |
static text | include (const char *file) |
if the common is declared similarly in all routines, generate "include 'COMMON.h'", and the file is put in Src. More... | |
static void | equiv_class_debug (list l_equiv) |
static int | equivalent_entity_compare (entity *ent1, entity *ent2) |
static int equivalent_entity_compare(entity *ent1, entity *ent2) input : two pointers on entities. More... | |
static text | text_equivalence_class (list l_equiv) |
static text text_equivalence_class(list l_equiv) input : a list of entities representing an equivalence class. More... | |
static text | text_equivalences (entity __attribute__((unused)) module, list ldecl, bool no_commons) |
input : the current module, and the list of declarations. More... | |
static sentence | sentence_f95use_declaration (entity e) |
Create a sentence for a USE directive. More... | |
static sentence | sentence_external (entity f) |
static sentence | sentence_symbolic (entity f, list *ppdl) |
static sentence | sentence_data (entity e) |
why is it assumed that the constant is an int ??? More... | |
static sentence | sentence_area (entity e, entity module, bool pp_dimensions, list *ppdl) |
special management of empty commons added. More... | |
static sentence | sentence_basic_declaration (entity e) |
static sentence | sentence_data_statement (statement is, list *ppdl) |
Prettyprint the initializations field of code. More... | |
static text | text_of_parameters (list lp) |
static string | default_common_hook (entity __attribute__((unused)) module, entity common) |
We add this function to cope with the declaration When the user declare sth. More... | |
void | reset_prettyprinter_common_hook (void) |
static text | text_area_included (entity common, entity module) |
static text | text_entity_declaration (entity module, list ldecl, bool force_common, list *ppdl) |
This function compute the list of declaration at the begining of a module. More... | |
text | text_declaration (entity module) |
exported for hpfc. More... | |
text | text_common_declaration (entity common, entity module) |
needed for hpfc More... | |
text | text_initializations (entity m) |
static text | __attribute__ ((unused)) |
returns the DATA initializations. More... | |
Variables | |
static string(* | common_hook )(entity, entity) |
#define ADD_WORD_LIST_TO_TEXT | ( | t, | |
l | |||
) | ADD_WORD_LIST_TO_TEXT_WITH_MARGIN(t, l, 0) |
To deal with declarations above ri-util and pipsdbm and text-util.
Definition at line 54 of file declarations2.c.
#define ADD_WORD_LIST_TO_TEXT_WITH_MARGIN | ( | t, | |
l, | |||
m | |||
) |
Definition at line 55 of file declarations2.c.
#define EQUIV_DEBUG 8 |
debugging for equivalences
Definition at line 48 of file declarations2.c.
|
static |
returns the DATA initializations.
limited to integers, because I do not know where is the value for other types... of entity
of sentence
Definition at line 1273 of file declarations2.c.
References CONS, constant_int_p, ENTITY, entity_initial, FOREACH, make_text(), NIL, SENTENCE, sentence_data(), value_constant, value_constant_p, and value_undefined_p.
|
static |
We add this function to cope with the declaration When the user declare sth.
there's no need to declare sth. for the user. When nothing is declared ( especially there is no way to know whether it's a SUBROUTINE or PROGRAM). We will go over the entire module to find all the variables and declare them properly. Lei ZHOU 18/10/91
the float length is now tested to generate REAL*4 or REAL*8. ??? something better could be done, printing "TYPE*%d". the problem is that you cannot mix REAL*4 and REAL*8 in the same program Fabien Coelho 12/08/93 and 15/09/93
pf4 and pf8 distinction added, FC 26/10/93
Is it really a good idea to print overloaded type variables~? FC 15/09/93 PARAMETERS added. FC 15/09/93
typed PARAMETERs FC 13/05/94 EXTERNALS are missing: added FC 13/05/94
Bug: parameters and their type should be put before other declarations since they may use them. Changed FC 08/06/94
COMMONS are also missing:-) added, FC 19/08/94
updated to fully control the list to be used. hook for commons, when not generated...
Definition at line 773 of file declarations2.c.
References concatenate(), entity_local_name(), and strdup().
Referenced by reset_prettyprinter_common_hook().
|
static |
Definition at line 101 of file declarations2.c.
References ENDP, ENTITY, entity_local_name(), fprintf(), and MAP.
Referenced by text_equivalence_class(), and text_equivalences().
static int equivalent_entity_compare(entity *ent1, entity *ent2) input : two pointers on entities.
output : an integer for qsort. modifies : nothing. comment : this is a comparison function for qsort; the purpose being to order a list of equivalent variables. algorithm: If two variables have the same offset, the longest one comes first; if they have the same length, use a lexicographic ordering. author: bc.
pips_debug(1, "entities: %s %s\n", entity_local_name(*ent1), entity_local_name(*ent2));
pips_debug(1, "same offset\n");
pips_debug(1, "same size\n");
Definition at line 123 of file declarations2.c.
References entity_local_name(), entity_storage, ram_offset, storage_ram, value_compare, and ValueSizeOfArray().
Referenced by text_equivalence_class().
|
static |
This handle the fact that a Fortran95 declaration use "::" as a separator between type and variable name.
It also adds an "allocatable" modifier if requested. Finally it add a "," between each variable if there more than one to declare.
Definition at line 67 of file declarations2.c.
References CHAIN_SWORD, NIL, and prettyprint_language_is_fortran95_p().
Referenced by text_entity_declaration().
|
static |
if the common is declared similarly in all routines, generate "include 'COMMON.h'", and the file is put in Src.
otherwise the full local declarations are generated. That's fun.
Definition at line 92 of file declarations2.c.
References concatenate(), CONS, is_sentence_formatted, make_sentence(), make_text(), NIL, SENTENCE, and strdup().
Referenced by c_code_string(), and text_area_included().
void reset_prettyprinter_common_hook | ( | void | ) |
Definition at line 787 of file declarations2.c.
References common_hook, and default_common_hook().
Referenced by hpfc_print_code().
special management of empty commons added.
this may happen in the hpfc generated code.
FI: POINTER declarations should be generated for the heap area
shouldn't get in?
the common is not output if it is empty
Definition at line 549 of file declarations2.c.
References area_layout, assert, BLANK_COMMON_LOCAL_NAME, CHAIN_SWORD, common_members_of_module(), concatenate(), dynamic_area_p(), ENDP, ENTITY, entity_local_name(), entity_name, entity_type, gen_copy_seq(), gen_free_list(), gen_nconc(), get_bool_property(), get_prettyprint_indentation(), heap_area_p(), is_sentence_formatted, is_sentence_unformatted, make_sentence(), make_unformatted(), MAP, module, module_local_name(), NIL, pips_user_warning, pointer_dummy_targets_area_p(), sentence_undefined, stack_area_p(), static_area_p(), strdup(), type_area, type_area_p, and words_declaration().
Referenced by text_entity_declaration().
Definition at line 618 of file declarations2.c.
References basic_to_string(), basic_undefined_p, CHAIN_SWORD, entity_basic(), entity_local_name(), get_prettyprint_indentation(), is_sentence_unformatted, make_sentence(), make_unformatted(), NIL, and pips_assert.
Referenced by text_entity_declaration(), and text_of_parameters().
why is it assumed that the constant is an int ???
Definition at line 522 of file declarations2.c.
References CHAIN_IWORD, CHAIN_SWORD, constant_int, constant_int_p, entity_initial, entity_local_name(), get_prettyprint_indentation(), is_sentence_unformatted, make_sentence(), make_unformatted(), NIL, sentence_undefined, value_constant, and value_constant_p.
Referenced by __attribute__().
Prettyprint the initializations field of code.
Argument List
Reference List
reference list expression, i.e. call to DATA LIST
DATA LIST entity function
Find all initialized variables pending from DATA LIST
Move al to the first value
Print all values
print out the repeat factor if it is not one
Definition at line 635 of file declarations2.c.
References binary_call_lhs, binary_call_rhs, call_arguments, call_function, CAR, CDR, CHAIN_SWORD, CONS, ENDP, ENTITY_DATA_LIST_P, ENTITY_STATIC_INITIALIZATION_P, entity_undefined, EXPRESSION, expression_call_p(), expression_syntax, expression_to_int(), expression_undefined, gen_length(), gen_nconc(), get_bool_property(), get_prettyprint_indentation(), instruction_call, instruction_call_p, integer_constant_expression_p(), is_sentence_unformatted, list_undefined, make_sentence(), make_unformatted(), module_local_name(), NIL, pips_assert, POP, REPEAT_VALUE_NAME, statement_instruction, STATEMENT_NUMBER_UNDEFINED, strdup(), STRING, syntax_call, unformatted_words, and words_expression().
Referenced by text_initializations().
Definition at line 493 of file declarations2.c.
References CHAIN_SWORD, entity_local_name(), f(), get_prettyprint_indentation(), is_sentence_unformatted, make_sentence(), make_unformatted(), and NIL.
Referenced by text_entity_declaration().
Create a sentence for a USE directive.
@description Use directive is handled by copying the string directly in the name of the entity during the parsing. So we juste get the local name and put it in a sentence.
Definition at line 482 of file declarations2.c.
References CHAIN_SWORD, entity_local_name(), INDENTATION, is_sentence_unformatted, make_sentence(), make_unformatted(), and NIL.
Referenced by text_entity_declaration().
Definition at line 504 of file declarations2.c.
References CHAIN_SWORD, entity_initial, entity_local_name(), f(), gen_nconc(), get_prettyprint_indentation(), is_sentence_unformatted, make_sentence(), make_unformatted(), NIL, symbolic_expression, value_symbolic, and words_expression().
Referenced by text_of_parameters().
the include was generated once before...
same declaration, generate the file!
touch the nofile to avoid the inclusion check latter on.
common | the common the declaration of which are of interest |
module | the module dealt with |
Definition at line 792 of file declarations2.c.
References BLANK_COMMON_LOCAL_NAME, check_common_inclusion(), concatenate(), db_get_directory_name_for_module(), f(), file_exists_p(), fprintf(), free(), include(), module, module_local_name(), print_text(), safe_fclose(), safe_fopen(), same_string_p, strdup(), text_common_declaration(), and WORKSPACE_SRC_SPACE.
Referenced by text_entity_declaration().
needed for hpfc
common | ommon |
module | odule |
Definition at line 1228 of file declarations2.c.
References common_members_of_module(), CONS, ENTITY, entity_type, gen_free_list(), module, NIL, pips_assert, text_entity_declaration(), and type_area_p.
Referenced by hpfc_print_common(), and text_area_included().
exported for hpfc.
Assume Fortran only!
module | odule |
Definition at line 1216 of file declarations2.c.
References code_declarations, entity_code(), gen_free_list(), module, NIL, and text_entity_declaration().
Referenced by ensure_comment_consistency(), and init_host_and_node_entities().
|
static |
This function compute the list of declaration at the begining of a module.
It's intended to be used with Fortran or Fortran95 only
ldecl | is the list of entity to be prettyprinted |
force_common | will force the prettyprint of common in include |
prettyprint common in include if possible...
Declarations cannot be sorted out because Fortran standard impose at least an order on parameters. Fortunately here, PARAMETER are mostly integers, defined from other integer parameters... I assume that PIPS would fail with an ENTRY referencing an integer array dimensionned with a real parameter. But real parameters are not really well processed by PIPS anyway... Also we are in trouble if arrays or functions are used dimension other arrays
list sorted_ldecl = gen_copy_seq(ldecl);
gen_sort_list(sorted_ldecl, compare_entities);
where to put the dimension information.
subroutines won't be declared
not parsed callee
Do not declare variables used to replace formal labels
PARAMETER
EXTERNAL
AREAS: COMMONS and SAVEs
simple integers are moved ahead...
nothing! some in hpfc I guess...
usually they are sorted in order, and appended backwards, hence the reversion.
all about COMMON and SAVE declarations
and EQUIVALENCE statements... - BC
sorted_
what about DATA statements! FC
More general way with with call to text_initializations(module) in text_named_module()
gen_free_list(sorted_ldecl);
We have to do a recursive call to get the allocatable declarations
ldecl | of entity |
Definition at line 856 of file declarations2.c.
References ADD_WORD_LIST_TO_TEXT, ADD_WORD_LIST_TO_TEXT_WITH_MARGIN, attach_declaration_size_type_to_words(), attach_declaration_type_to_words(), basic_complex, basic_float, basic_int, basic_overloaded_p, basic_string, basic_tag, CHAIN_IWORD, CHAIN_SWORD, check_fortran_declaration_dependencies(), common_hook, CONS, constant_int, constant_int_p, dynamic_area_p(), empty_static_area_p(), ENDP, ENTITY, entity_f95use_p(), entity_initial, entity_local_name(), entity_name, entity_special_area_p(), entity_storage, entity_type, f77_f95_style_management(), FOREACH, formal_label_replacement_p(), functional_result, gen_free_list(), gen_nconc(), gen_nreverse(), get_allocatable_data_entity(), get_bool_property(), get_prettyprint_indentation(), get_string_property(), heap_area_p(), INDENTATION, is_basic_complex, is_basic_derived, is_basic_float, is_basic_int, is_basic_logical, is_basic_overloaded, is_basic_string, is_sentence_formatted, make_sentence(), make_text(), MERGE_TEXTS, module, NIL, pips_debug, pips_internal_error, pl, pointer_dummy_targets_area_p(), prettyprint_language_is_fortran95_p(), ram_section, same_string_p, SENTENCE, sentence_area(), sentence_basic_declaration(), sentence_external(), sentence_f95use_declaration(), stack_area_p(), storage_formal_p, storage_ram, storage_ram_p, storage_rom_p, string_undefined, symbolic_expression, text_area_included(), text_equivalences(), text_of_parameters(), type_area_p, type_functional, type_functional_p, type_variable, type_variable_p, type_void_p, value_code_p, value_constant, value_constant_p, value_symbolic, value_symbolic_p, value_unknown_p, variable_basic, variable_dimensions, variable_static_p(), words_declaration(), and words_expression().
Referenced by text_common_declaration(), and text_declaration().
static text text_equivalence_class(list l_equiv) input : a list of entities representing an equivalence class.
output : a text, which is the prettyprint of this class. modifies : sorts l_equiv according to equivalent_entity_compare. comment : partially associated entities are not handled. author : bc.
FIRST, sort the list by increasing offset from the beginning of the memory suite. If two variables have the same offset, the longest one comes first; if they have the same lenght, use a lexicographic ordering
THEN, prettyprint the sorted list
At each step of the next loop, we consider two entities from the equivalence class. l1 points on the first entity list, and l2 on the second one. If l2 is associated with l1, we compute the output string, and l2 becomes the next entity. If l2 is not associated with l1, l1 becomes the next entity, until it is associated with l1. In the l_equiv list, l1 is always before l2.
loop initialization
If the two variables have the same offset, their first elements are equivalenced.
Else, we first check that there is an overlap
If there is no overlap, we change the reference variable
Else, we must compute the coordinates of the element of ent1 which corresponds to the first element of ent2
ATTENTION: Je n'ai pas considere le cas ou il y a association partielle. De ce fait, offset est divisiable par size_elt_1.
while
if-else: there is an overlap
if-else: not same offset
while
l_equiv | of entities |
Definition at line 159 of file declarations2.c.
References ADD_WORD_LIST_TO_TEXT, CAR, CDR, CHAIN_SWORD, DIMENSION, dimension_lower, ENDP, ENTITY, entity_local_name(), entity_storage, entity_type, equiv_class_debug(), EQUIV_DEBUG, equivalent_entity_compare(), gen_length(), gen_sort_list(), get_bool_property(), ifdebug, int2a(), make_text(), NIL, NORMALIZE_EXPRESSION, normalized_linear, NumberOfDimension(), offset, pips_assert, pips_debug, POP, ram_offset, size_elt_1, SizeOfElements(), SizeOfIthDimension(), storage_ram, type_variable, val_of, value_le, value_plus, VALUE_TO_INT, ValueSizeOfArray(), variable_basic, variable_dimensions, and vect_constant_p().
Referenced by text_equivalences().
|
static |
input : the current module, and the list of declarations.
output : a text for all the equivalences. modifies : nothing comment :
FIRST BUILD EQUIVALENCE CLASSES
consider each entity in the declaration
but only variables which have a ram storage must be considered
If this variable is statically aliased
We first look in already found equivalence classes if there is already a class in which one of the aliased variables appears
add the entities of shared which are not already in the existing equivalence class. Useful ??
!!!
add the list of variables in l_shared; necessary because variables may appear several times in l_shared.
!!! restricted to declared...
SECOND, PRETTYPRINT THEM
AND FREE THEM
THE END
module | the module dealt with |
ldecl | the list of declarations to consider |
no_commons | whether to print common equivivalences |
Definition at line 342 of file declarations2.c.
References CAR, CONS, ENDP, ENTITY, entity_local_name(), entity_special_area_p(), entity_storage, entity_type, equiv_class_debug(), EQUIV_DEBUG, gen_free_list(), ifdebug, LIST, make_text(), MAP, MERGE_TEXTS, NIL, pips_debug, POP, ram_section, ram_shared, storage_ram, storage_ram_p, text_equivalence_class(), type_variable_p, and variable_in_list_p().
Referenced by text_entity_declaration().
The previous declaration list is useless in Fortran, but the signature of functions designed for C or Fortran must be respected.
Definition at line 1244 of file declarations2.c.
References ADD_SENTENCE_TO_TEXT, code_initializations, empty_comments_p(), entity_initial, entity_module_p(), FOREACH, gen_free_list(), is_sentence_formatted, list_undefined, make_sentence(), make_text(), NIL, pips_assert, sentence_data_statement(), sequence_statements, STATEMENT, statement_comments, strdup(), and value_code.
Referenced by ensure_comment_consistency().
of sentence
generate the sentences
lp | of entity that are parameters |
Definition at line 729 of file declarations2.c.
References CONS, ENTITY, FOREACH, make_text(), NIL, SENTENCE, sentence_basic_declaration(), and sentence_symbolic().
Referenced by text_entity_declaration().
Definition at line 780 of file declarations2.c.
Referenced by reset_prettyprinter_common_hook(), and text_entity_declaration().