PIPS
|
Go to the source code of this file.
Macros | |
#define | STATE_VARIABLE_NAME "FSM%d_STATE" |
#define | STATE_VARIABLE_NAME_NO_REF "FSM_STATE" |
#define | FSM_BEGIN_COMMENT "! BEGIN FSM, %s\n" |
#define | FSM_TRANSITION_COMMENT "! Transition %s=%d\n" |
Functions | |
expression | make_expression_with_state_variable (entity state_variable, int value, string intrinsic_name) |
Build and return an expression (eg. More... | |
entity | create_state_variable (const char *module_name, int name_identifier) |
This function creates (and add declaration) state variable. More... | |
statement | make_state_variable_assignement_statement (statement stat, entity state_variable, int assignement_value) |
This function build and return a statement representing the initial assigment of the state_variable, given the UNSTRUCTURED statement stat. More... | |
int | entry_state_variable_value_for_unstructured (statement stat) |
Return the state variable value corresponding to the entry in a unstructured statement. More... | |
int | exit_state_variable_value_for_unstructured (statement stat) |
Return the state variable value corresponding to the exit in a unstructured statement NB: always return 0. More... | |
statement | make_reset_state_variable_statement (statement stat, entity state_variable) |
This function build and return a statement representing the initial assigment of the state_variable, given the UNSTRUCTURED statement stat. More... | |
statement | make_transition_statement (control current_node, statement root_statement, entity state_variable, const char *module_name) |
This function build a transition statement (a TEST statement) corresponding to the current control current_node and the root_statement root_statement. More... | |
statement | make_fsm_transitions_statement (statement stat, entity state_variable, const char *module_name) |
This function build and return a statement representing the transitions computation in the FSM, given the UNSTRUCTURED statement stat. More... | |
statement | make_fsm_from_statement (statement stat, entity state_variable, const char *module_name) |
This function build and return a statement representing the FSM code equivalent to the given unstructured statement stat. More... | |
statement | fsmize_statement (statement stat, entity state_variable, const char *module_name) |
This function is recursively called during FSMization. More... | |
#define FSM_BEGIN_COMMENT "! BEGIN FSM, %s\n" |
Definition at line 29 of file fsm_generation.h.
#define FSM_TRANSITION_COMMENT "! Transition %s=%d\n" |
Definition at line 30 of file fsm_generation.h.
#define STATE_VARIABLE_NAME "FSM%d_STATE" |
Definition at line 27 of file fsm_generation.h.
#define STATE_VARIABLE_NAME_NO_REF "FSM_STATE" |
Definition at line 28 of file fsm_generation.h.
This function creates (and add declaration) state variable.
The name of this variable is obtained by the concatenation of string STATE_VARIABLE_NAME and name identifier. If the variable doesn't exist with this name, then the variable is created, added to declarations, and returned. If this variable exists, then this functions search a new name by incrementing the integer name_identifier
Assert that module represent a value code
This variable doesn't exist
Definition at line 84 of file fsm_tools.c.
References AddEntityToDeclarations(), asprintf, concatenate(), create_state_variable(), entity_domain, entity_initial, entity_undefined, find_or_create_scalar_entity(), gen_find_tabulated(), is_basic_int, module, module_name(), module_name_to_entity(), MODULE_SEP_STRING, pips_assert, STATE_VARIABLE_NAME, STATE_VARIABLE_NAME_NO_REF, strdup(), and value_code_p.
Referenced by fsm_generation().
Return the state variable value corresponding to the entry in a unstructured statement.
Definition at line 162 of file fsm_tools.c.
References beautify_ordering(), control_statement, instruction_tag, instruction_unstructured, is_instruction_unstructured, pips_assert, statement_instruction, statement_ordering, and unstructured_entry.
Return the state variable value corresponding to the exit in a unstructured statement NB: always return 0.
Definition at line 180 of file fsm_tools.c.
References instruction_tag, is_instruction_unstructured, pips_assert, and statement_instruction.
This function is recursively called during FSMization.
It takes the statement to fsmize stat as parameter, while module_name is the name of the module where FSMization is applied. If global variable is used for the whole module, state_variable contains this element. If state_variable is null, then new state_variable is created for this statement.
= beautify_ordering (statement_ordering(stat));
Definition at line 536 of file fsm_tools.c.
References create_state_variable(), fsmize_statement(), gen_list_patch(), ifdebug, instruction_sequence, instruction_tag, instruction_test, is_instruction_call, is_instruction_forloop, is_instruction_goto, is_instruction_loop, is_instruction_sequence, is_instruction_test, is_instruction_unstructured, is_instruction_whileloop, make_fsm_from_statement(), MAP, module_name(), pips_debug, print_statement(), sequence_statements, STATEMENT, statement_comments, statement_domain_number, statement_instruction, statement_number, statement_ordering, statement_type_as_string(), statement_with_empty_comment_p(), test_false, and test_true.
Referenced by fsm_generation().
expression make_expression_with_state_variable | ( | entity | state_variable, |
int | value, | ||
string | intrinsic_name | ||
) |
Build and return an expression (eg.
state = 23), given an entity state_variable, an int value value, and an intrinsic name
Definition at line 66 of file fsm_tools.c.
References entity_intrinsic(), entity_to_expression(), int_to_expression(), and MakeBinaryCall().
statement make_fsm_from_statement | ( | statement | stat, |
entity | state_variable, | ||
const char * | module_name | ||
) |
This function build and return a statement representing the FSM code equivalent to the given unstructured statement stat.
tring comment; char buffer[256];
Assert that given stat is UNSTRUCTURED
Create loop condition: state variable is not equal to exit value
Evaluation is done BEFORE to enter the loop
No label for loop
Computes the statement representing the transitions
Build the loop
printf (buffer, FSM_BEGIN_COMMENT, entity_local_name(state_variable)); comment = strdup(buffer);
tatement_instruction(loop_body) = make_instruction_block(CONS(STATEMENT,returned_statement,NIL));
Definition at line 447 of file fsm_tools.c.
References CONS, empty_comments, entity_empty_label(), exit_state_variable_value_for_unstructured(), instruction_tag, is_instruction_sequence, is_instruction_unstructured, is_instruction_whileloop, loop_body, make_evaluation_before(), make_expression_with_state_variable(), make_fsm_transitions_statement(), make_instruction(), make_reset_state_variable_statement(), make_sequence(), make_statement(), make_synchronization_none(), make_whileloop(), module_name(), NIL, NON_EQUAL_OPERATOR_NAME, pips_assert, STATEMENT, statement_extensions, statement_instruction, statement_label, statement_number, and statement_ordering.
statement make_fsm_transitions_statement | ( | statement | stat, |
entity | state_variable, | ||
const char * | module_name | ||
) |
This function build and return a statement representing the transitions computation in the FSM, given the UNSTRUCTURED statement stat.
en_recurse(unstructured_entry(nodes_graph), control_domain, transitions_filter, transitions_statements);
Definition at line 400 of file fsm_tools.c.
References CONTROL_MAP, current_statement, gen_length(), instruction_tag, instruction_test, instruction_unstructured, is_instruction_test, is_instruction_unstructured, make_transition_statement(), module_name(), NIL, pips_assert, pips_debug, statement_instruction, test_false, and unstructured_entry.
This function build and return a statement representing the initial assigment of the state_variable, given the UNSTRUCTURED statement stat.
Definition at line 194 of file fsm_tools.c.
References entry_state_variable_value_for_unstructured(), and make_state_variable_assignement_statement().
statement make_state_variable_assignement_statement | ( | statement | stat, |
entity | state_variable, | ||
int | assignement_value | ||
) |
This function build and return a statement representing the initial assigment of the state_variable, given the UNSTRUCTURED statement stat.
tatement_label(stat),
Definition at line 129 of file fsm_tools.c.
References ASSIGN_OPERATOR_NAME, CONS, empty_comments, entity_empty_label(), entity_intrinsic(), entity_to_expression(), EXPRESSION, int_to_expression(), is_instruction_call, make_call(), make_instruction(), make_statement(), make_synchronization_none(), NIL, statement_extensions, statement_number, and statement_ordering.
statement make_transition_statement | ( | control | current_node, |
statement | root_statement, | ||
entity | state_variable, | ||
const char * | module_name | ||
) |
This function build a transition statement (a TEST statement) corresponding to the current control current_node and the root_statement root_statement.
This TEST statement takes a condition on the state_variable having the value matching the statement ordering value, and the control statement for the test_true value. The test_false value is set with a continue statement, before to be eventually replaced in next control node by a new statement.
tring comment; char buffer[50];
This is the exit node, or a non-test statement
This is the exit node, just generate exit code for state_variable
successors_nb == 1
This is a "normal" node, ie not a TEST statement, just add assignement for state_variable with new value
NULL here because we will generate a new state variable, since the potential other FSMs are deeper
This is a "test" node, ie with a TEST statement, just add assignement for state_variable with new value after each statement in TEST
:-)
printf (buffer, FSM_TRANSITION_COMMENT, entity_local_name(state_variable), current_transition_number); comment = strdup(buffer);
tatement_label(root_statement),
Definition at line 212 of file fsm_tools.c.
References beautify_ordering(), CONS, CONTROL, control_statement, control_successors, debug_control(), empty_comments, entity_empty_label(), entity_undefined, EQUAL_OPERATOR_NAME, exit_state_variable_value_for_unstructured(), fsmize_statement(), gen_length(), gen_nth(), instruction_tag, instruction_test, is_instruction_sequence, is_instruction_test, make_continue_statement(), make_expression_with_state_variable(), make_instruction(), make_sequence(), make_state_variable_assignement_statement(), make_statement(), make_synchronization_none(), make_test(), module_name(), NIL, pips_assert, STATEMENT, statement_extensions, statement_instruction, statement_number, statement_ordering, test_condition, test_false, and test_true.