PIPS
|
#include "local.h"
Go to the source code of this file.
Macros | |
#define | INTEGER_DECL " INTEGER" |
We define a set of constant in order to a more generic function for the insert of the declarations of the new created variables. More... | |
#define | REAL_DECL " REAL" |
#define | COMPLEX_DECL " COMPLEX" |
#define | LOGICAL_DECL " LOGICAL" |
#define | DOUBLE_DECL " DOUBLE PRECISION" |
#define | CHARACTER_DECL " CHARACTER" |
#define | SPACE " " |
#define | COMA "," |
#define | NEWLINE "\n *" |
#define | ENDLINE "\nC\n" |
#define | LINE_LENGHT 68 |
#define | MARGIN_LENGHT 7 |
Functions | |
static expression | find_tmp_of_exp (expression exp) |
=========================================================================== More... | |
void | put_stmt_in_Block (statement new_stmt, Block *cb) |
=========================================================================== More... | |
expression | assign_tmp_to_exp (expression exp, Block *cb) |
=========================================================================== More... | |
void | insert_one_type_declaration (entity mod_entity, list var_to_decl, string type_decl) |
=========================================================================== More... | |
void | insert_new_declarations (char *mod_name) |
=========================================================================== More... | |
void | store_expression (expression exp, Block *cb) |
=========================================================================== More... | |
Variables | |
hash_table | MemToTmp |
– codegen.c More... | |
#define INTEGER_DECL " INTEGER" |
expression assign_tmp_to_exp | ( | expression | exp, |
Block * | cb | ||
) |
===========================================================================
expression assign_tmp_to_exp(expression exp, Block *cb): Produces an assign statement of "exp" in a temporary (this is a load), puts it in "cb" and returns the expression of the temporary.
There are two cases:
The variable "cb" memorises the information about the block of statements that contains the expressions.
Called functions : _ entity_scalar_p() : ri-util/entity.c _ make_entity_expression() : ri-util/util.c _ make_assign_statement() : ri-util/statement.c
If this expression is a scalar variable already loaded in a temporary, then it is unnecessary to loaded it again. The only thing to do is to find the temporary that was used and return it.
We compute the basic of "exp".
We create a new temporary with the basic "tmp_basic".
If "exp_ent" is a scalar variable, this temporary is placed in MemToTmp at the key "exp_ent".
We create a new expression with this temporary.
The new assign statement is created ...
... and put in the current Block.
The new temporary is returned.
exp | xp |
cb | b |
Definition at line 155 of file codegen.c.
References basic_of_expression(), entity_scalar_p(), entity_undefined, exp, expression_syntax, expression_undefined, find_tmp_of_exp(), hash_put(), is_syntax_reference, make_assign_statement(), make_entity_expression(), make_new_entity(), MemToTmp, NIL, put_stmt_in_Block(), reference_variable, syntax_reference, syntax_tag, and TMP_ENT.
Referenced by atomizer_of_expression().
|
static |
===========================================================================
expression find_tmp_of_exp(expression exp): Returns the expression of the temporary in which the variable of "exp" was loaded. If "exp" is not atomic, or, if "exp" was not yet loaded, this function returns "expression_undefined".
This function uses the hash table MemToTmp. For a given memory variable you may have an associated temporary. This association is built when such a variable is loaded for the first time.
Called functions : _ entity_scalar_p() : ri-util/entity.c _ make_entity_expression() : ri-util/util.c
Definition at line 58 of file codegen.c.
References entity_scalar_p(), entity_undefined, exp, expression_syntax, expression_undefined, hash_get(), is_syntax_reference, make_entity_expression(), MemToTmp, NIL, reference_variable, syntax_reference, and syntax_tag.
Referenced by assign_tmp_to_exp().
void insert_new_declarations | ( | char * | mod_name | ) |
===========================================================================
void insert_new_declarations(char *mod_name): puts in the declaration text of the module "mod_name" the declarations for the temporary, auxiliary and NLC variables.
Called functions : _ local_name_to_top_level_entity() : ri-util/entity.c
We declare only variables that are not INTEGER or REAL simple precision.
mod_name | od_name |
Definition at line 285 of file codegen.c.
References char_entities, CHARACTER_DECL, COMPLEX_DECL, complex_entities, DOUBLE_DECL, double_entities, gen_free_list(), gen_nreverse(), insert_one_type_declaration(), integer_entities, local_name_to_top_level_entity(), LOGICAL_DECL, logical_entities, and real_entities.
===========================================================================
void insert_one_type_declaration(entity mod_entity, list var_to_decl, string type_decl): Inserts in the module "mod_entity" the declarations of the entities in the list "var_to_decl" with the type "type_decl".
Type declaration.
Lenght of the declaration to insert.
If the line is to long ..., we begin a new line!!
We separate the variables between comas.
mod_entity | od_entity |
var_to_decl | ar_to_decl |
type_decl | ype_decl |
Definition at line 229 of file codegen.c.
References CAR, CDR, code_decls_text, COMA, concatenate(), ENDLINE, ENTITY, entity_code(), entity_local_name(), LINE_LENGHT, MARGIN_LENGHT, NEWLINE, NIL, SPACE, and strdup().
Referenced by insert_new_declarations().
===========================================================================
codegen.c
void put_stmt_in_Block(statement new_stmt, Block *cb): Puts "new_stmt" at the end of the list "cb->first".
First, if "new_stmt" is the first statement generated by the statement being translated (the current statement), then the caracteritics of "new_stmt" are taken from those of the current statement.
Second, "new_stmt" is added to the list of statements of "cb".
The current statement is the first element of the list "cb->last".
"stmt_generated" is false if the current statement has not produced any statement yet, in which case the new statement gets the "label", "number", "ordering" and "comments" (cf. RI) of the current statement.
The new statement gets the caracteristic of the current statement, while the latter gets the caracteristics of the new statement.
The current statement has, now, generated at least one statement.
The new statement is put just before the current statement in the block. Thus, it is put in last position in the list "cb->first".
new_stmt | ew_stmt |
cb | b |
Definition at line 89 of file codegen.c.
References CAR, CONS, current_stmt, Block::first, gen_nconc(), Block::last, NIL, STATEMENT, statement_comments, statement_label, statement_number, STATEMENT_NUMBER_UNDEFINED, statement_ordering, STATEMENT_ORDERING_UNDEFINED, Block::stmt_generated, and string_undefined.
Referenced by assign_tmp_to_exp(), and atomizer_of_external().
void store_expression | ( | expression | exp, |
Block * | cb | ||
) |
===========================================================================
void store_expression(expression exp, Block *cb): Removes the key of the hash table MemToTmp corresponding to the variable contained in "exp". It means that the value of this variable is no longer equal to the value of the temporary stored in MemToTmp.
Note: "exp" must have a "syntax_tag" equal to "reference".
Called functions : _ entity_scalar_p() : ri-util/entity.c _ make_entity_expression() : ri-util/util.c _ make_assign_statement() : ri-util/statement.c
entity tmp_ent;
exp | xp |
cb | b |
Definition at line 335 of file codegen.c.
References entity_scalar_p(), exp, expression_syntax, hash_del(), is_syntax_reference, MemToTmp, pips_assert, pips_user_error, reference_variable, syntax_reference, and syntax_tag.
|
extern |
– codegen.c
Functions that generates the new instructions. A hash table to map temporary variables (entities) to memory variables (entities).
– codegen.c
They are used for the declarations of the temporaries and the auxiliaries. A hash table to map temporary variables (entities) to memory variables (entities).
Definition at line 95 of file atomizer.c.
Referenced by assign_tmp_to_exp(), atomizer_of_external(), atomizer_of_intrinsic(), atomizer_of_loop(), atomizer_of_unstructured(), find_tmp_of_exp(), initialize_global_variables(), reset_global_variables(), and store_expression().