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 "prettyprint.h"
#include "effects-util.h"
#include "pipsdbm.h"
#include "text-util.h"
#include "dg.h"
#include "control.h"
#include "callgraph.h"
#include "spaghettify.h"
#include "phrase_tools.h"
Go to the source code of this file.
Functions | |
static control | full_spaghettify_statement (statement stat, const char *module_name, unstructured u, control current_control, control next_control) |
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 control | connect_unstructured (statement unstructured_statement, control current_control, control next_control) |
This function connect the unstructured unstructured_statement to the current Control Flow Graph between control nodes current_control and next_control. More... | |
static void | reduce_sequence (control current_control, sequence seq, control *new_entry, control *new_exit) |
This function reduce the sequence seq at the position in the control graph indicated by control current_control. More... | |
static void | flatten_unstructured (unstructured the_unstructured) |
This function takes as entry an unstructured and flatten it: More... | |
static control | replace_control_with_unstructured (unstructured the_unstructured, control current_control) |
This function connect the unstructured the_unstructured to the current Control Flow Graph at the place of specified control the_control. More... | |
static statement | full_spaghettify_module (statement module_statement, const char *module_name) |
bool | full_spaghettify (const char *module_name) |
full_spaghettify.c More... | |
|
static |
This function connect the unstructured unstructured_statement to the current Control Flow Graph between control nodes current_control and next_control.
pips_assert("Entry with no predecessor in CONNECT_UNSTRUCTURED", gen_length(control_predecessors(entry)) == 0);
Definition at line 388 of file full_spaghettify.c.
References CONTROL, control_predecessors, control_successors, exit, flatten_unstructured(), gen_length(), gen_nth(), ifdebug, instruction_unstructured, link_2_control_nodes(), pips_assert, pips_debug, print_statement(), statement_instruction, unlink_2_control_nodes(), unstructured_entry, and unstructured_exit.
Referenced by full_spaghettify_statement().
|
static |
This function takes as entry an unstructured and flatten it:
Repeat until there is no more sequences to reduce and unstructured to flatten
First, check all the sequences to reduce
Do the job on the sequences
ree_control(current_control);
Check the unstructured to flatten
Do the job on the unstructured
ree_control(current_control);
Definition at line 271 of file full_spaghettify.c.
References CONS, CONTROL, CONTROL_MAP, control_statement, control_undefined, debug_control(), FOREACH, gen_length(), ifdebug, instruction_sequence, instruction_tag, instruction_unstructured, is_instruction_sequence, is_instruction_unstructured, MAP, NIL, pips_debug, reduce_sequence(), replace_control_with_unstructured(), short_debug_unstructured(), statement_instruction, unstructured_entry, and unstructured_exit.
Referenced by connect_unstructured(), and replace_control_with_unstructured().
bool full_spaghettify | ( | const char * | module_name | ) |
get the resources
Now do the job
Reorder the module, because new statements have been added
Restructure the module
Reorder the module, because new statements have been added
ATTENTION after simple_restructure_statement, statement stat is not longer a unstructured, but may be a sequence !!!
update/release resources
module_name | odule_name |
Definition at line 603 of file full_spaghettify.c.
References compute_callees(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, full_spaghettify_module(), ifdebug, module_name(), module_name_to_entity(), module_reorder(), pips_assert, pips_debug, print_statement(), reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), simple_restructure_statement(), statement_consistent_p(), statement_unstructured(), and unstructured_consistent_p().
|
static |
Definition at line 93 of file full_spaghettify.c.
References CONTROL_MAP, control_statement, debug_control(), empty_comments, entity_empty_label(), exit, full_spaghettify_statement(), ifdebug, is_instruction_unstructured, link_2_control_nodes(), make_continue_statement(), make_control(), make_instruction(), make_statement(), make_synchronization_none(), make_unstructured(), module_name(), module_statement, NIL, pips_assert, statement_consistent_p(), statement_extensions, statement_number, and statement_ordering.
Referenced by full_spaghettify().
|
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 function recursively takes the stat statement and transform the Control Flow Graph module_unstructured in order to generate equivalent code.
This phases transforms all the module in a unique unstructured statement where all the control nodes are:
In fact the module becomes a sequence statement with a beginning statement, the unstructured statement and a final statement
full_spaghettify > MODULE.code < PROGRAM.entities < MODULE.code
The statement to transform is assumed to be executed between controls current_control and next_control.
Generated unstructured is equivalent to a FSM where all the states are the different nodes of the Control Flow Graph
This function return the control node corresponding to the new position in the Control Flow Graph
ree_statement(stat);
Definition at line 498 of file full_spaghettify.c.
References connect_unstructured(), CONTROL, control_predecessors, control_successors, debug_statement(), gen_length(), gen_nth(), ifdebug, instruction_sequence, instruction_tag, is_instruction_call, is_instruction_forloop, is_instruction_loop, is_instruction_sequence, is_instruction_test, is_instruction_unstructured, is_instruction_whileloop, link_2_control_nodes(), make_control(), MAP, module_name(), NIL, pips_assert, pips_debug, pips_user_warning, print_statement(), sequence_statements, spaghettify_forloop(), spaghettify_loop(), spaghettify_test(), spaghettify_whileloop(), STATEMENT, statement_instruction, and unlink_2_control_nodes().
Referenced by full_spaghettify_module().
|
static |
This function reduce the sequence seq at the position in the control graph indicated by control current_control.
The sequence is reduced by the creation of new control nodes corresponding to all the statements in the sequence. In addition new_entry and new_exit control pointers are updated according to the transformation. NOTE: this function don't do recursively the job, but is generally called by flatten_unstructured which do the job recursively.
Conserve lists of predecessors and successors
Deconnect all the predecessors
Deconnect all the successors
We iterate on each statement in the sequence
We build a new control node from current statement
For the first statement...
Reconnect all the predecessors
ATTENTION link_2_control_nodes add to the list at the first position, so we need to reconnect in the reverse order
Reconnect all the successors
ATTENTION link_2_control_nodes add to the list at the first position, so we need to reconnect in the reverse order
If this is not the first statement, we have to link it with the previous one
Deconnect all the OLD successors
Reconnect all the NEW successors
ATTENTION link_2_control_nodes add to the list at the first position, so we need to reconnect in the reverse order
Definition at line 156 of file full_spaghettify.c.
References CONTROL, control_predecessors, control_statement, control_successors, control_undefined, FOREACH, gen_copy_seq(), gen_length(), gen_nth(), ifdebug, int, link_2_control_nodes(), make_control(), NIL, pips_debug, predecessors(), print_statement(), sequence_statements, STATEMENT, successors(), and unlink_2_control_nodes().
Referenced by flatten_unstructured().
|
static |
This function connect the unstructured the_unstructured to the current Control Flow Graph at the place of specified control the_control.
The predecessors and successors will be the same as the_control predecessors and successors. Return the new current control, which is the exit of passed unstructured
Conserve lists of predecessors and successors
Deconnect all the predecessors
Deconnect all the successors
ips_assert("Entry of unstructured has no predecessor", gen_length(control_predecessors(entry)) == 0);
Reconnect all the predecessors
ATTENTION link_2_control_nodes add to the list at the first position, so we need to reconnect in the reverse order
Reconnect all the successors
ATTENTION link_2_control_nodes add to the list at the first position, so we need to reconnect in the reverse order
Definition at line 438 of file full_spaghettify.c.
References CONTROL, control_predecessors, control_successors, exit, flatten_unstructured(), gen_copy_seq(), gen_length(), gen_nth(), int, link_2_control_nodes(), pips_assert, predecessors(), successors(), unlink_2_control_nodes(), unstructured_entry, and unstructured_exit.
Referenced by flatten_unstructured().