PandA-2024.02
|
Rebuild initialization function flow front-end step done after IR_lowering. More...
#include <rebuild_initializations.hpp>
Public Member Functions | |
rebuild_initialization2 (const ParameterConstRef Param, const application_managerRef AppM, unsigned int function_id, const DesignFlowManagerConstRef design_flow_manager) | |
Constructor. More... | |
~rebuild_initialization2 () override | |
Destructor. More... | |
DesignFlowStep_Status | InternalExec () override |
Rebuild initialization function flow front-end step. 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... | |
bool | HasToBeExecuted () const override |
Check if this step has actually to be executed. 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... | |
virtual void | Initialize () |
Initialize the step (i.e., like a constructor, but executed just before exec. 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 | |
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... | |
bool | extract_var_decl_ppe (tree_nodeRef addr_assign_op1, unsigned &vd_index, tree_nodeRef &vd_node) |
extract_var_decl_ppe More... | |
bool | extract_var_decl (const mem_ref *me, unsigned &vd_index, tree_nodeRef &vd_node, tree_nodeRef &addr_assign_op1) |
extract_var_decl return the variable decl referred by the mem_ref given it is resolvable More... | |
bool | look_for_ROMs () |
look_for_ROMs transforms the IR by looking for an initial sequence of writes followed by read only instructions. 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... | |
Rebuild initialization function flow front-end step done after IR_lowering.
Definition at line 102 of file rebuild_initializations.hpp.
rebuild_initialization2::rebuild_initialization2 | ( | 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 218 of file rebuild_initializations.cpp.
References DesignFlowStep::debug_level, DEBUG_LEVEL_NONE, and GET_CLASS.
|
overridedefault |
Destructor.
Referenced by ComputeFrontendRelationships().
|
overrideprivatevirtual |
Return the set of analyses in relationship with this design step.
relationship_type | is the type of relationship to be considered |
Implements FrontendFlowStep.
Definition at line 227 of file rebuild_initializations.cpp.
References DesignFlowStep::DEPENDENCE_RELATIONSHIP, DesignFlowStep::INVALIDATION_RELATIONSHIP, DesignFlowStep::PRECEDENCE_RELATIONSHIP, SAME_FUNCTION, THROW_UNREACHABLE, and ~rebuild_initialization2().
|
private |
extract_var_decl return the variable decl referred by the mem_ref given it is resolvable
me | is the memory reference node |
vd_index | is the variable decl index |
vd_node | is the variable decl tree re-index node |
addr_assign_op1 | is the pointer expression used by the mem_ref |
Definition at line 512 of file rebuild_initializations.cpp.
References extract_var_decl_ppe(), extractOp1(), tree_node::get_kind(), GET_NODE, tree_helper::GetConstValue(), THROW_ASSERT, unexpetedPattern(), and varFound().
Referenced by look_for_ROMs().
|
private |
extract_var_decl_ppe
vd_index | is the variable decl index |
vd_node | is the variable decl tree re-index node |
starting from this condition offset is not anymore null
Definition at line 295 of file rebuild_initializations.cpp.
References extractOp1(), GET_NODE, tree_helper::GetConstValue(), unexpetedPattern(), and varFound().
Referenced by extract_var_decl().
|
overridevirtual |
Rebuild initialization function flow front-end step.
Implements FunctionFrontendFlowStep.
Definition at line 1378 of file rebuild_initializations.cpp.
References FunctionFrontendFlowStep::function_behavior, look_for_ROMs(), SUCCESS, and UNCHANGED.
|
private |
look_for_ROMs transforms the IR by looking for an initial sequence of writes followed by read only instructions.
In case the writes have constant offset and the written values are constants a constant array may be defined.
for each basic block B in CFG compute constantVars candidates
are we writing a constant value
first check if the variable is initialized
then we check if the variable is an array
then in case we are fine we classify as good candidate for being a constant var
if it is still a good candidate
check if the offset is constant
index is constant
index is constant
else do nothing
compute the CFG
add vertices
add edges
add a connection between entry and exit thus avoiding problems with non terminating code
check if reads are consistent with writes: writes are always dominating the following reads
list all constant variables found
Definition at line 692 of file rebuild_initializations.cpp.
References FrontendFlowStep::AppM, B, BUILTIN_SRCP, CFG_SELECTOR, tree_helper::CGetElements(), tree_manager::CGetTreeNode(), tree_manager::CGetTreeReindex(), tree_helper::CGetType(), tree_manager::create_tree_node(), tree_manager::CreateUniqueIntegerCst(), DesignFlowStep::debug_level, DEBUG_LEVEL_VERY_PEDANTIC, bloc::ENTRY_BLOCK_ID, bloc::EXIT_BLOCK_ID, extract_var_decl(), foundNonConstant, FunctionFrontendFlowStep::function_behavior, FunctionFrontendFlowStep::function_id, tree_helper::get_array_dim_and_bitsize(), GET_CONST_NODE, tree_node::get_kind(), GET_NODE, tree_manager::get_tree_node_const(), getAssign(), tree_helper::GetConstValue(), tree_manipulation::GetSignedIntegerType(), tree_manager::GetTreeNode(), tree_manager::GetTreeReindex(), INDENT_DBG_MEX, index, tree_node::index, init(), graph::IsReachable(), key, tree_manager::new_tree_node_id(), DesignFlowStep::parameters, sl, STR, THROW_ASSERT, TOK, TOK_SCPE, TOK_SRCP, TOK_TYPE, ToString(), tree_node::ToString(), and unexpetedPattern2.
Referenced by InternalExec().