PIPS
|
#include <stdio.h>
#include <ctype.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "resources.h"
#include "misc.h"
#include "ri-util.h"
#include "effects-util.h"
#include "text-util.h"
#include "dg.h"
#include "phrase_tools.h"
#include "spaghettify.h"
Go to the source code of this file.
Functions | |
static entity | make_index_variable (loop the_loop, statement stat, const char *module_name) |
The spaghettifier is used in context of PHRASE project while creating "Finite State Machine"-like code portions in order to synthetise them in reconfigurables units. More... | |
static entity | make_begin_variable (loop the_loop, statement stat, const char *module_name) |
Creates begin variable for a loop the_loop of a statement stat. More... | |
static entity | make_end_variable (loop the_loop, statement stat, const char *module_name) |
Creates end variable for a loop the_loop of a statement stat. More... | |
static entity | make_increment_variable (loop the_loop, statement stat, const char *module_name) |
Creates increment variable for a loop the_loop of a statement stat. More... | |
static control | make_initialization_from_loop (loop the_loop, statement stat, entity index_variable, entity begin_variable, entity end_variable, entity increment_variable) |
Build and return a new control containing initialization statement of the unstructured loop. More... | |
static control | make_condition_from_loop (loop the_loop, statement stat, entity index_variable, entity end_variable, entity increment_variable) |
Build and return a new control containing condition statement of the unstructured loop. More... | |
static control | make_exit_from_loop () |
Build and return a new control containing exit statement of the unstructured loop (this is a continue statement) More... | |
static control | make_body_from_loop (loop the_loop, const char *module_name, statement stat, entity index_variable, entity increment_variable) |
Build and return a new control containing body statement of the unstructured loop. More... | |
static unstructured | make_unstructured_from_loop (loop the_loop, statement stat, const char *module_name) |
Build and return a new unstructured coding the "destructured" loop. More... | |
statement | spaghettify_loop (statement stat, const char *module_name) |
This function takes the statement stat as parameter and return a new spaghettized statement, asserting stat is a LOOP statement. More... | |
|
static |
Creates begin variable for a loop the_loop of a statement stat.
Definition at line 135 of file loop_spaghettify.c.
References BEGIN_VARIABLE_NAME, loop_index, make_variable_from_name_and_entity(), and module_name().
Referenced by make_unstructured_from_loop().
|
static |
Build and return a new control containing body statement of the unstructured loop.
Definition at line 307 of file loop_spaghettify.c.
References CONS, empty_comments, entity_empty_label(), entity_intrinsic(), entity_to_expression(), is_instruction_sequence, loop_body, loop_index, make_assignement_statement(), make_control(), make_instruction(), make_sequence(), make_statement(), make_synchronization_none(), MakeBinaryCall(), module_name(), NIL, PLUS_OPERATOR_NAME, spaghettify_statement(), STATEMENT, statement_extensions, statement_number, and statement_ordering.
Referenced by make_unstructured_from_loop().
|
static |
Build and return a new control containing condition statement of the unstructured loop.
Definition at line 228 of file loop_spaghettify.c.
References AND_OPERATOR_NAME, empty_comments, entity_empty_label(), entity_intrinsic(), entity_to_expression(), expression_integer_value(), GREATER_OR_EQUAL_OPERATOR_NAME, int_to_expression(), intptr_t, is_instruction_test, LESS_OR_EQUAL_OPERATOR_NAME, loop_range, make_continue_statement(), make_control(), make_instruction(), make_statement(), make_synchronization_none(), make_test(), MakeBinaryCall(), NIL, OR_OPERATOR_NAME, range_increment, statement_extensions, statement_number, statement_ordering, and test_condition.
Referenced by make_unstructured_from_loop().
Creates end variable for a loop the_loop of a statement stat.
Definition at line 148 of file loop_spaghettify.c.
References END_VARIABLE_NAME, loop_index, make_variable_from_name_and_entity(), and module_name().
Referenced by make_unstructured_from_loop().
|
static |
Build and return a new control containing exit statement of the unstructured loop (this is a continue statement)
Definition at line 298 of file loop_spaghettify.c.
References entity_empty_label(), make_continue_statement(), make_control(), and NIL.
Referenced by make_unstructured_from_loop().
|
static |
Creates increment variable for a loop the_loop of a statement stat.
Definition at line 161 of file loop_spaghettify.c.
References INCREMENT_VARIABLE_NAME, loop_index, make_variable_from_name_and_entity(), and module_name().
Referenced by make_unstructured_from_loop().
|
static |
The spaghettifier is used in context of PHRASE project while creating "Finite State Machine"-like code portions in order to synthetise them in reconfigurables units.
This file contains the code used for spaghettify loops.
General syntax of loop in Fortran are:
DO INDEX=BEGIN, END, INCREMENT STATEMENT END DO
where INDEX is an entity (variable) and BEGIN, END, INCREMENT are expressions.
Be careful: Fortran interprets all the values of the loop INDEX, BEGIN, END, INCREMENT before to enter the loop, and those values could therefore be modified inside the loop (during the execution of STATEMENT). That's the reason, to generate equivalent code, why we introduce the variables: INDEX', BEGIN', END', INCREMENT'
If INCREMENT is evaluable and POSITIVE, following code is generated:
BEGIN' = BEGIN END' = END INC' = INC INDEX' = BEGIN' 10 IF (INDEX'.LE.END') THEN INDEX = INDEX' STATEMENT INDEX' = INDEX' + INC' GOTO 10 ENDIF 20 CONTINUE
If INCREMENT is evaluable and NEGATIVE, following code is generated:
BEGIN' = BEGIN END' = END INC' = INC INDEX' = BEGIN' 10 IF (INDEX'.GE.END') THEN INDEX = INDEX' STATEMENT INDEX' = INDEX' + INC' GOTO 10 ENDIF 20 CONTINUE
If INCREMENT is not evaluable, following code is generated:
BEGIN' = BEGIN END' = END INC' = INC INDEX' = BEGIN' 10 IF (((INDEX'.LE.END').AND.(INC'.GE.0)).OR.((INDEX'.GE.END').AND.(INC'.LE.0))) THEN INDEX = INDEX' STATEMENT INDEX' = INDEX' + INC' GOTO 10 ENDIF 20 CONTINUE Creates index variable for a loop the_loop of a statement stat
Definition at line 122 of file loop_spaghettify.c.
References INDEX_VARIABLE_NAME, loop_index, make_variable_from_name_and_entity(), and module_name().
Referenced by make_unstructured_from_loop().
|
static |
Build and return a new control containing initialization statement of the unstructured loop.
Definition at line 175 of file loop_spaghettify.c.
References CONS, empty_comments, entity_empty_label(), entity_to_expression(), is_instruction_sequence, loop_range, make_assignement_statement(), make_control(), make_instruction(), make_sequence(), make_statement(), make_synchronization_none(), NIL, range_increment, range_lower, range_upper, STATEMENT, statement_extensions, statement_number, and statement_ordering.
Referenced by make_unstructured_from_loop().
|
static |
Build and return a new unstructured coding the "destructured" loop.
after init, we test
The first connexion is the false one
false condition, we exit from loop
true condition, we go to body
after body, we go back to condition
Definition at line 349 of file loop_spaghettify.c.
References exit, initialization(), link_2_control_nodes(), make_begin_variable(), make_body_from_loop(), make_condition_from_loop(), make_end_variable(), make_exit_from_loop(), make_increment_variable(), make_index_variable(), make_initialization_from_loop(), make_unstructured(), and module_name().
Referenced by spaghettify_loop().
This function takes the statement stat as parameter and return a new spaghettized statement, asserting stat is a LOOP statement.
stat | tat |
module_name | odule_name |
Definition at line 391 of file loop_spaghettify.c.
References instruction_tag, is_instruction_loop, is_instruction_unstructured, make_instruction(), make_unstructured_from_loop(), module_name(), pips_assert, pips_debug, statement_instruction, and statement_loop().
Referenced by full_spaghettify_statement(), and spaghettify_statement().