PandA-2024.02
|
Structure the original short circuit. More...
#include <multi_way_if.hpp>
Public Member Functions | |
multi_way_if (const ParameterConstRef _Param, const application_managerRef _AppM, unsigned int function_id, const DesignFlowManagerConstRef design_flow_manager) | |
Constructor. More... | |
~multi_way_if () override | |
Destructor. More... | |
DesignFlowStep_Status | InternalExec () override |
Restructures the unstructured code. More... | |
void | Initialize () override |
Initialize the step (i.e., like a constructor, but executed just before exec. More... | |
bool | HasToBeExecuted () const override |
Check if this step has actually to be executed. More... | |
Public Member Functions inherited from FunctionFrontendFlowStep | |
FunctionFrontendFlowStep (const application_managerRef AppM, const unsigned int function_id, const FrontendFlowStepType frontend_flow_step_type, const DesignFlowManagerConstRef design_flow_manager, const ParameterConstRef parameters) | |
Constructor. More... | |
~FunctionFrontendFlowStep () override | |
Destructor. More... | |
void | ComputeRelationships (DesignFlowStepSet &relationship, const DesignFlowStep::RelationshipType relationship_type) override |
Compute the relationships of a step with other steps. More... | |
std::string | GetSignature () const override |
Return the signature of this step. More... | |
std::string | GetName () const override |
Return the name of this design step. More... | |
DesignFlowStep_Status | Exec () final |
Execute the step. More... | |
unsigned int | CGetBBVersion () const |
unsigned int | GetBitValueVersion () const |
void | PrintInitialIR () const override |
Dump the initial intermediate representation. More... | |
void | PrintFinalIR () const override |
Dump the final intermediate representation. More... | |
Public Member Functions inherited from FrontendFlowStep | |
FrontendFlowStep (const application_managerRef AppM, const FrontendFlowStepType frontend_flow_step_type, const DesignFlowManagerConstRef design_flow_manager, const ParameterConstRef parameters) | |
Constructor. More... | |
~FrontendFlowStep () override | |
Destructor. More... | |
virtual std::string | GetKindText () const |
Return the name of the type of this frontend flow step. More... | |
DesignFlowStepFactoryConstRef | CGetDesignFlowStepFactory () const override |
Return the factory to create this type of steps. More... | |
void | PrintTreeManager (const bool before) const |
Dump the tree manager. More... | |
Public Member Functions inherited from DesignFlowStep | |
DesignFlowStep (const DesignFlowManagerConstRef design_flow_manager, const ParameterConstRef parameters) | |
Constructor. More... | |
virtual | ~DesignFlowStep () |
Destructor. More... | |
DesignFlowStep_Status | GetStatus () const |
Return the status of this design step. More... | |
virtual void | WriteDot (std::ostream &out) const |
Write the label for a dot graph. More... | |
bool | IsComposed () const |
Returns if this step is composed. More... | |
int | CGetDebugLevel () const |
Return the debug level of the step. More... | |
Private Member Functions | |
void | MergeCondCond (const blocRef &pred_bb, const blocRef &curr_bb) |
Merge two basic blocks both ending with gimple_cond_K. More... | |
void | MergeCondMulti (const blocRef &pred_bb, const blocRef &curr_bb) |
Build the gimple_multi_way_if by mergin a gimple_cond with a gimple_multi_way_if. More... | |
void | MergeMultiCond (const blocRef &pred_bb, const blocRef &curr_bb) |
Merge a gimple_cond in a gimple_multi_way_if. More... | |
void | MergeMultiMulti (const blocRef &pred_bb, const blocRef &curr_bb) |
Merge two gimple_multi_way_if in a single one. More... | |
void | UpdateCfg (const blocRef &pred_bb, const blocRef &curr_bb) |
Update the basic block control flow graph data structure. More... | |
void | FixCfg (const blocRef &pred_bb, const blocRef &succ_bb) |
Insert a basic block on an edge. More... | |
const CustomUnorderedSet< std::pair< FrontendFlowStepType, FunctionRelationship > > | ComputeFrontendRelationships (const DesignFlowStep::RelationshipType relationship_type) const override |
Return the set of analyses in relationship with this design step. More... | |
Private Attributes | |
statement_list * | sl |
The statement list of the analyzed function. More... | |
tree_managerRef | TM |
The tree manager. More... | |
tree_manipulationRef | tree_man |
The tree manipulation. More... | |
bool | bb_modified |
Modified file. More... | |
Additional Inherited Members | |
Public Types inherited from FrontendFlowStep | |
using | FunctionRelationship = enum { ALL_FUNCTIONS, CALLED_FUNCTIONS, CALLING_FUNCTIONS, SAME_FUNCTION, WHOLE_APPLICATION } |
The different relationship type between function analysis. More... | |
Public Types inherited from DesignFlowStep | |
enum | RelationshipType { DEPENDENCE_RELATIONSHIP, INVALIDATION_RELATIONSHIP, PRECEDENCE_RELATIONSHIP } |
The relationship type. More... | |
Static Public Member Functions inherited from FunctionFrontendFlowStep | |
static const std::string | ComputeSignature (const FrontendFlowStepType frontend_flow_step_type, const unsigned int function_id) |
Compute the signature of a function frontend flow step. More... | |
Static Public Member Functions inherited from FrontendFlowStep | |
static void | CreateSteps (const DesignFlowManagerConstRef design_flow_manager, const CustomUnorderedSet< std::pair< FrontendFlowStepType, FunctionRelationship >> &frontend_relationships, const application_managerConstRef application_manager, DesignFlowStepSet &relationships) |
Create the relationship steps of a step with other steps starting from already specified dependencies between frontend flow steps. More... | |
static const std::string | EnumToKindText (const FrontendFlowStepType frontend_flow_step_type) |
Given a frontend flow step type, return the name of the type. More... | |
Protected Member Functions inherited from FunctionFrontendFlowStep | |
void | WriteBBGraphDot (const std::string &filename) const |
Write the current version of statement list in dot format. More... | |
Protected Attributes inherited from FunctionFrontendFlowStep | |
const FunctionBehaviorRef | function_behavior |
The function behavior of the function to be analyzed. More... | |
const unsigned int | function_id |
The index of the function to be analyzed. More... | |
unsigned int | bb_version |
The version of the basic block intermediate representation on which this step has been applied. More... | |
unsigned int | bitvalue_version |
The version of the bitvalue information on which this step has been applied. More... | |
Protected Attributes inherited from FrontendFlowStep | |
const application_managerRef | AppM |
The application manager. More... | |
const FrontendFlowStepType | frontend_flow_step_type |
The type of this step. More... | |
unsigned int | print_counter |
Print counter. More... | |
Protected Attributes inherited from DesignFlowStep | |
bool | composed |
True if this step represents a composition of design flow steps (e.g., a flow); must be set by specialized constructors. More... | |
const Wrefcount< const DesignFlowManager > | design_flow_manager |
The design flow manager. More... | |
const ParameterConstRef | parameters |
Set of input parameters. More... | |
int | debug_level |
The debug level. More... | |
const int | output_level |
The output level. More... | |
Structure the original short circuit.
Definition at line 64 of file multi_way_if.hpp.
multi_way_if::multi_way_if | ( | const ParameterConstRef | _Param, |
const application_managerRef | _AppM, | ||
unsigned int | function_id, | ||
const DesignFlowManagerConstRef | design_flow_manager | ||
) |
Constructor.
Param | is the set of the parameters |
AppM | is the application manager |
function_id | is the identifier of the function |
DesignFlowManagerConstRef | is the design flow manager |
Definition at line 75 of file multi_way_if.cpp.
References DesignFlowStep::debug_level, DEBUG_LEVEL_NONE, GET_CLASS, DesignFlowStep::parameters, and ~multi_way_if().
|
overridedefault |
|
overrideprivatevirtual |
Return the set of analyses in relationship with this design step.
relationship_type | is the type of relationship to be considered |
Not executed
If schedule is not up to date, do not execute this step and invalidate UpdateSchedule
Implements FrontendFlowStep.
Definition at line 87 of file multi_way_if.cpp.
References FrontendFlowStep::AppM, FunctionFrontendFlowStep::CGetBBVersion(), FunctionFrontendFlowStep::ComputeSignature(), DesignFlowStep::DEPENDENCE_RELATIONSHIP, DesignFlowStep::design_flow_manager, FunctionFrontendFlowStep::function_behavior, FunctionFrontendFlowStep::function_id, DesignFlowStep::GetStatus(), DesignFlowStep::INVALIDATION_RELATIONSHIP, Wrefcount< T >::lock(), DesignFlowStep::parameters, DesignFlowStep::PRECEDENCE_RELATIONSHIP, SAME_FUNCTION, SUCCESS, THROW_UNREACHABLE, and WHOLE_APPLICATION.
|
private |
Insert a basic block on an edge.
pred_bb | is the index of the first basic block |
succ_bb | is the index of the second basic block |
The index of the basic block to be created
Create the new basic block and set all the fields
Fix the predecessor
Fix the last statement of the predecessor
Fix the successor
Fix the phi
Definition at line 728 of file multi_way_if.cpp.
References DesignFlowStep::debug_level, DEBUG_LEVEL_VERY_PEDANTIC, GET_NODE, INDENT_DBG_MEX, statement_list::list_of_bloc, phi, sl, STR, THROW_ASSERT, and TM.
Referenced by InternalExec().
|
overridevirtual |
Check if this step has actually to be executed.
Multi way if can be executed only after vectorization
Reimplemented from FunctionFrontendFlowStep.
Definition at line 796 of file multi_way_if.cpp.
References FrontendFlowStep::AppM, FunctionFrontendFlowStep::CGetBBVersion(), FunctionFrontendFlowStep::ComputeSignature(), DesignFlowStep::design_flow_manager, FunctionFrontendFlowStep::function_behavior, FunctionFrontendFlowStep::function_id, FunctionFrontendFlowStep::HasToBeExecuted(), Wrefcount< T >::lock(), NULL_VERTEX, and DesignFlowStep::parameters.
|
overridevirtual |
Initialize the step (i.e., like a constructor, but executed just before exec.
Reimplemented from DesignFlowStep.
Definition at line 153 of file multi_way_if.cpp.
References FrontendFlowStep::AppM, bb_modified, tree_manager::CGetTreeNode(), FunctionFrontendFlowStep::function_id, GET_NODE, DesignFlowStep::parameters, sl, TM, and tree_man.
|
overridevirtual |
Restructures the unstructured code.
add edges
add a connection between entry and exit thus avoiding problems with non terminating code
sort basic block vertices from the entry till the exit
check for short circuit conditions: i.e., if they have at least a successor in common if so we add a basic block on the shortest path (e.g., predecessor –> common successor) In this way in the produced gimple_multi_way_if there cannot be multiple conditions with the same next bb phi_opt will remove the extra basic block
Fixed point since list of successor is changed by FixCfg
now the merging starts
Implements FunctionFrontendFlowStep.
Definition at line 222 of file multi_way_if.cpp.
References FrontendFlowStep::AppM, bb_modified, CFG_SELECTOR, BBGraph::CGetBBNodeInfo(), cyclic_topological_sort(), DesignFlowStep::debug_level, DEBUG_LEVEL_VERY_PEDANTIC, bloc::ENTRY_BLOCK_ID, bloc::EXIT_BLOCK_ID, FixCfg(), FunctionFrontendFlowStep::function_behavior, FunctionFrontendFlowStep::function_id, GET_NODE, FunctionFrontendFlowStep::GetName(), INDENT_DBG_MEX, statement_list::list_of_bloc, MergeCondCond(), MergeCondMulti(), MergeMultiCond(), MergeMultiMulti(), DesignFlowStep::parameters, test_panda::restart, sl, STR, SUCCESS, THROW_ASSERT, UNCHANGED, UpdateCfg(), and FunctionFrontendFlowStep::WriteBBGraphDot().
|
private |
Merge two basic blocks both ending with gimple_cond_K.
pred_bb | is the first basic block |
curr_bb | is the second basic block |
identify the first gimple_cond
identify the second gimple_cond
create the gimple_multi_way_if node
Definition at line 680 of file multi_way_if.cpp.
References FrontendFlowStep::AppM, BUILTIN_SRCP, tree_manager::create_tree_node(), tree_manipulation::CreateAndExpr(), tree_manipulation::CreateNotExpr(), DesignFlowStep::debug_level, DEBUG_LEVEL_VERY_PEDANTIC, tree_manipulation::ExtractCondition(), FunctionFrontendFlowStep::function_id, GET_CONST_NODE, GET_NODE, tree_manager::GetTreeReindex(), INDENT_DBG_MEX, tree_manager::new_tree_node_id(), STR, THROW_ASSERT, TM, TOK, TOK_SCPE, TOK_SRCP, and tree_man.
Referenced by InternalExec().
|
private |
Build the gimple_multi_way_if by mergin a gimple_cond with a gimple_multi_way_if.
pred_bb | is the basic block containing the gimple_cond |
second_bb | is the basic block containg the gimple_multi_way_if |
create the gimple_multi_way_if node
Create ce_condition
Remove old gimple_cond
Remove old gimple multi way if
First case: second bb is on the true edge
Skipped default condition
Second case: second bb is on the false edge
Definition at line 414 of file multi_way_if.cpp.
References FrontendFlowStep::AppM, BUILTIN_SRCP, tree_manager::create_tree_node(), tree_manipulation::CreateAndExpr(), tree_manipulation::CreateNotExpr(), DesignFlowStep::debug_level, DEBUG_LEVEL_VERY_PEDANTIC, tree_manipulation::ExtractCondition(), FunctionFrontendFlowStep::function_id, GET_CONST_NODE, tree_manager::get_tree_node_const(), tree_manager::GetTreeReindex(), INDENT_DBG_MEX, tree_manager::new_tree_node_id(), STR, TM, TOK, TOK_SCPE, TOK_SRCP, and tree_man.
Referenced by InternalExec().
|
private |
Merge a gimple_cond in a gimple_multi_way_if.
pred_bb | is the basic block containing the gimple_multi_way_if |
curr_bb | is the basic block containing the gimple_cond |
create the gimple_multi_way_if node
Remove old gimple_multi_way_if
Remove old gimple_cond
Create condition
Non default and succ is on this edge
Non default and succ is not on this edge
Default and succ is is on this edge
Building the and of the not of other conditions of cond
Default and second is not on this edge
Definition at line 602 of file multi_way_if.cpp.
References FrontendFlowStep::AppM, BUILTIN_SRCP, tree_manager::create_tree_node(), tree_manipulation::CreateAndExpr(), tree_manipulation::CreateNotExpr(), DesignFlowStep::debug_level, DEBUG_LEVEL_VERY_PEDANTIC, tree_manipulation::ExtractCondition(), FunctionFrontendFlowStep::function_id, GET_CONST_NODE, tree_manager::get_tree_node_const(), tree_manager::GetTreeReindex(), INDENT_DBG_MEX, tree_manager::new_tree_node_id(), STR, TM, TOK, TOK_SCPE, TOK_SRCP, and tree_man.
Referenced by InternalExec().
|
private |
Merge two gimple_multi_way_if in a single one.
pred_bb | is the basic block containing the first gimple_multi_way_if |
curr_bb | is the basic block containing the second gimple multi_way_if |
create the gimple_multi_way_if node
Remove old gimple_cond
Remove old gimple multi way if
Non default and succ is on this edge
Non default and succ is not on this edge
Default and succ is on this edge
Building the and of the not of other conditions of cond1
Default and second is not on this edge
Definition at line 480 of file multi_way_if.cpp.
References FrontendFlowStep::AppM, BUILTIN_SRCP, tree_manager::create_tree_node(), tree_manipulation::CreateAndExpr(), tree_manipulation::CreateNotExpr(), DesignFlowStep::debug_level, DEBUG_LEVEL_VERY_PEDANTIC, FunctionFrontendFlowStep::function_id, GET_CONST_NODE, tree_manager::get_tree_node_const(), tree_manager::GetTreeReindex(), INDENT_DBG_MEX, tree_manager::new_tree_node_id(), STR, TM, TOK, TOK_SCPE, TOK_SRCP, and tree_man.
Referenced by InternalExec().
|
private |
Update the basic block control flow graph data structure.
pred_bb | is the predecessor basic block |
curr_bb | is the current basic block |
Remove curr_bb from successor of pred_bb
For each successor succ of curr_bb
Remove curr_bb from its predecessor
Add pred_bb to its predecessor
Add succ to successor of pred_bb
Update phi information
Definition at line 174 of file multi_way_if.cpp.
References DesignFlowStep::debug_level, DEBUG_LEVEL_VERY_PEDANTIC, GET_NODE, INDENT_DBG_MEX, statement_list::list_of_bloc, phi, sl, THROW_ASSERT, and TM.
Referenced by InternalExec().
|
private |
Modified file.
Definition at line 77 of file multi_way_if.hpp.
Referenced by Initialize(), and InternalExec().
|
private |
The statement list of the analyzed function.
Definition at line 68 of file multi_way_if.hpp.
Referenced by FixCfg(), Initialize(), InternalExec(), and UpdateCfg().
|
private |
The tree manager.
Definition at line 71 of file multi_way_if.hpp.
Referenced by FixCfg(), Initialize(), MergeCondCond(), MergeCondMulti(), MergeMultiCond(), MergeMultiMulti(), and UpdateCfg().
|
private |
The tree manipulation.
Definition at line 74 of file multi_way_if.hpp.
Referenced by Initialize(), MergeCondCond(), MergeCondMulti(), MergeMultiCond(), and MergeMultiMulti().