PIPS
fsm_generation.c File Reference
#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 "pipsdbm.h"
#include "text-util.h"
#include "dg.h"
#include "graph.h"
#include "ray_dte.h"
#include "sommet.h"
#include "sg.h"
#include "polyedre.h"
#include "control.h"
#include "callgraph.h"
#include "properties.h"
#include "phrase_tools.h"
#include "fsm_generation.h"
+ Include dependency graph for fsm_generation.c:

Go to the source code of this file.

Typedefs

typedef dg_arc_label arc_label
 This phase is used for PHRASE project. More...
 
typedef dg_vertex_label vertex_label
 

Functions

bool fsm_generation (const char *module_name)
 fsm_generation.c More...
 

Typedef Documentation

◆ arc_label

This phase is used for PHRASE project.

NB: The PHRASE project is an attempt to automatically (or semi-automatically) transform high-level language for partial evaluation in reconfigurable logic (such as FPGAs or DataPaths).

This library provides phases allowing to build and modify "Finite State Machine"-like code portions which will be later synthetized in reconfigurable units.

This phase tries to generate finite state machine from arbitrary code by applying rules numeroting branches of the syntax tree and using it as state variable for the finite state machine.

This phase recursively transform each UNSTRUCTURED statement in a WHILE-LOOP statement controlled by a state variable, whose different values are associated to the different statements.

To add flexibility, the behavior of FSM_GENERATION is controlled by the property FSMIZE_WITH_GLOBAL_VARIABLE which control the fact that the same global variable (global to the current module) must be used for each FSMized statements.

alias fsm_generation 'FSM Generation'

fsm_generation > MODULE.code > PROGRAM.entities < PROGRAM.entities < MODULE.code

Definition at line 80 of file fsm_generation.c.

◆ vertex_label

Definition at line 81 of file fsm_generation.c.

Function Documentation

◆ fsm_generation()

bool fsm_generation ( const char *  module_name)

fsm_generation.c

get the resources

dependence_graph = (graph) db_get_memory_resource(DBR_DG, module_name, true);

Now do the job

If property FSMIZE_WITH_GLOBAL_VARIABLE is set to true, we declare here the state variable which will be used in the whole module

Reorder the module, because new statements have been added

update/release resources

Parameters
module_nameodule_name

Definition at line 103 of file fsm_generation.c.

104 {
105  entity state_variable = NULL;
106 
107  /* get the resources */
108  statement stat = (statement) db_get_memory_resource(DBR_CODE,
109  module_name,
110  true);
111 
112 
115  /* dependence_graph =
116  (graph) db_get_memory_resource(DBR_DG, module_name, true); */
117 
118  debug_on("FSM_GENERATION_DEBUG_LEVEL");
119 
120  /* Now do the job */
121 
122  /* If property FSMIZE_WITH_GLOBAL_VARIABLE is set to true, we
123  * declare here the state variable which will be used in the whole
124  * module */
125  if (get_bool_property("FSMIZE_WITH_GLOBAL_VARIABLE")) {
126  state_variable = create_state_variable(module_name, 0);
127  }
128 
129  stat = fsmize_statement(stat, state_variable, module_name);
130 
131  pips_assert("Statement is consistent after FSM_GENERATION",
132  statement_consistent_p(stat));
133 
134  /* Reorder the module, because new statements have been added */
135  module_reorder(stat);
136  DB_PUT_MEMORY_RESOURCE(DBR_CODE, module_name, stat);
137  DB_PUT_MEMORY_RESOURCE(DBR_CALLEES, module_name,
138  compute_callees(stat));
139 
140  /* update/release resources */
143 
144  debug_off();
145 
146  return true;
147 }
bool statement_consistent_p(statement p)
Definition: ri.c:2195
callees compute_callees(const statement stat)
Recompute the callees of a module statement.
Definition: callgraph.c:355
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
statement fsmize_statement(statement stat, entity state_variable, const char *module_name)
This function is recursively called during FSMization.
Definition: fsm_tools.c:536
entity create_state_variable(const char *module_name, int name_identifier)
This function creates (and add declaration) state variable.
Definition: fsm_tools.c:84
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
void reset_current_module_statement(void)
Reset the current module statement.
Definition: static.c:221
statement set_current_module_statement(statement)
Set the current module statement.
Definition: static.c:165
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
#define debug_on(env)
Definition: misc-local.h:157
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define debug_off()
Definition: misc-local.h:160
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
Definition: reorder.c:244
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479

References compute_callees(), create_state_variable(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, fsmize_statement(), get_bool_property(), module_name(), module_name_to_entity(), module_reorder(), pips_assert, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), and statement_consistent_p().

+ Here is the call graph for this function: