PandA-2024.02
|
#include <lut_transformation.hpp>
Public Member Functions | |
lut_transformation (const ParameterConstRef Param, const application_managerRef AppM, unsigned int function_id, const DesignFlowManagerConstRef design_flow_manager) | |
Constructor. More... | |
~lut_transformation () override | |
Destructor. More... | |
DesignFlowStep_Status | InternalExec () override |
Computes the operations CFG graph data structure. More... | |
void | Initialize () override |
Initialize the step (i.e., like a constructor, but executed just before exec. More... | |
void | ComputeRelationships (DesignFlowStepSet &relationship, const DesignFlowStep::RelationshipType relationship_type) override |
Compute the relationships of a step with other steps. 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... | |
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... | |
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 | |
bool | CHECK_BIN_EXPR_BOOL_SIZE (binary_expr *be) const |
bool | CHECK_BIN_EXPR_INT_SIZE (binary_expr *be, unsigned int max) const |
bool | CHECK_COND_EXPR_SIZE (cond_expr *ce) const |
bool | CHECK_NOT_EXPR_SIZE (unary_expr *ne) const |
bool | cannotBeLUT (tree_nodeRef op) const |
cannotBeLUT returns true in case the op is an operation that cannot be translated in a LUT More... | |
bool | CheckIfPO (gimple_assign *gimpleAssign) |
Checks if the provided gimple_assign is a primary output of lut network. More... | |
bool | CheckIfPI (tree_nodeRef in, unsigned int BB_index) |
Checks if the ssa variable is a primary input of lut network. More... | |
bool | ProcessBasicBlock (std::pair< unsigned int, blocRef > block) |
bool | CheckIfProcessable (std::pair< unsigned int, blocRef > block) |
Checks if the provided basic block can be further processed. More... | |
tree_nodeRef | CreateBitSelectionNodeOrCast (const tree_nodeRef source, int index, std::vector< tree_nodeRef > &prev_stmts_to_add) |
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 | |
tree_managerRef | TM |
The tree manager. More... | |
tree_manipulationRef | tree_man |
The lut manipulation. More... | |
size_t | max_lut_size |
The maximum number of inputs of a lut. More... | |
const std::vector< enum kind > | lutBooleanExpressibleOperations |
The list of all operation that can be converted to a lut. More... | |
const std::vector< enum kind > | lutIntegerExpressibleOperations |
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... | |
Definition at line 70 of file lut_transformation.hpp.
lut_transformation::lut_transformation | ( | 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 1885 of file lut_transformation.cpp.
References DesignFlowStep::debug_level, DEBUG_LEVEL_NONE, GET_CLASS, and ~lut_transformation().
|
overridedefault |
|
private |
cannotBeLUT returns true in case the op is an operation that cannot be translated in a LUT
op | is an operation |
Definition at line 200 of file lut_transformation.cpp.
References CHECK_BIN_EXPR_BOOL_SIZE(), CHECK_BIN_EXPR_INT_SIZE(), CHECK_COND_EXPR_SIZE(), CHECK_NOT_EXPR_SIZE(), GET_NODE, lutBooleanExpressibleOperations, lutIntegerExpressibleOperations, DesignFlowStep::parameters, and VECT_CONTAINS.
Referenced by CheckIfPI(), CheckIfPO(), and CheckIfProcessable().
|
private |
Definition at line 117 of file lut_transformation.cpp.
References b0, b1, tree_helper::CGetType(), tree_helper::IsComplexType(), tree_helper::IsRealType(), tree_helper::IsSignedIntegerType(), tree_helper::IsStructType(), tree_helper::IsVectorType(), binary_expr::op0, binary_expr::op1, and tree_helper::Size().
Referenced by cannotBeLUT(), and ProcessBasicBlock().
|
private |
Definition at line 137 of file lut_transformation.cpp.
References b0, b1, tree_helper::CGetType(), GET_CONST_NODE, tree_node::get_kind(), tree_helper::GetConstValue(), tree_helper::IsComplexType(), tree_helper::IsRealType(), tree_helper::IsStructType(), tree_helper::IsVectorType(), k, max, binary_expr::op0, binary_expr::op1, DesignFlowStep::parameters, and tree_helper::Size().
Referenced by cannotBeLUT(), and ProcessBasicBlock().
|
private |
Definition at line 163 of file lut_transformation.cpp.
References c0, c1, tree_helper::CGetType(), tree_helper::IsComplexType(), tree_helper::IsRealType(), tree_helper::IsSignedIntegerType(), tree_helper::IsStructType(), tree_helper::IsVectorType(), and tree_helper::Size().
Referenced by cannotBeLUT(), and ProcessBasicBlock().
|
private |
Definition at line 183 of file lut_transformation.cpp.
References c0, tree_helper::CGetType(), tree_helper::IsComplexType(), tree_helper::IsRealType(), tree_helper::IsSignedIntegerType(), tree_helper::IsStructType(), tree_helper::IsVectorType(), unary_expr::op, and tree_helper::Size().
Referenced by cannotBeLUT(), and ProcessBasicBlock().
|
private |
Checks if the ssa variable is a primary input of lut network.
Checks whether the provided node is a primary input of lut network.
in | is the ssa variable to check |
in | a tree_nodeRef |
Definition at line 574 of file lut_transformation.cpp.
References cannotBeLUT(), tree_node::get_kind(), GET_NODE, and THROW_ERROR.
Referenced by ProcessBasicBlock().
|
private |
Checks if the provided gimple_assign
is a primary output of lut network.
gimpleAssign | the gimple_assign to check |
gimple_assign
is a primary output the index of the basic block holding the provided gimpleAssign
Definition at line 656 of file lut_transformation.cpp.
References gimple_node::bb_index, cannotBeLUT(), DesignFlowStep::debug_level, DEBUG_LEVEL_VERY_PEDANTIC, GET_NODE, INDENT_DBG_MEX, gimple_assign::op0, and THROW_ASSERT.
Referenced by ProcessBasicBlock().
|
private |
Checks if the provided basic block can be further processed.
There are two cases in which this condition is true:
lut_expr_K
lut_expr_K
that has constant inputsblock | the block to check |
Definition at line 602 of file lut_transformation.cpp.
References cannotBeLUT(), DesignFlowStep::debug_level, DEBUG_LEVEL_VERY_PEDANTIC, GET_NODE, and INDENT_DBG_MEX.
Referenced by InternalExec().
|
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 1896 of file lut_transformation.cpp.
References DesignFlowStep::DEPENDENCE_RELATIONSHIP, DesignFlowStep::GetStatus(), DesignFlowStep::INVALIDATION_RELATIONSHIP, DesignFlowStep::parameters, DesignFlowStep::PRECEDENCE_RELATIONSHIP, SAME_FUNCTION, SUCCESS, THROW_UNREACHABLE, and WHOLE_APPLICATION.
|
overridevirtual |
Compute the relationships of a step with other steps.
dependencies | is where relationships will be stored |
relationship_type | is the type of relationship to be computed |
Reimplemented from FunctionFrontendFlowStep.
Definition at line 1934 of file lut_transformation.cpp.
References FunctionFrontendFlowStep::ComputeRelationships(), TechnologyFlowStep::ComputeSignature(), DesignFlowStep::DEPENDENCE_RELATIONSHIP, DesignFlowStep::design_flow_manager, DesignFlowStep::INVALIDATION_RELATIONSHIP, LOAD_TECHNOLOGY, Wrefcount< T >::lock(), DesignFlowStep::PRECEDENCE_RELATIONSHIP, and THROW_UNREACHABLE.
|
private |
Definition at line 746 of file lut_transformation.cpp.
References tree_manipulation::create_extract_bit_expr(), tree_manipulation::CreateGimpleAssign(), tree_manager::CreateUniqueIntegerCst(), FunctionFrontendFlowStep::function_id, GET_CONST_NODE, tree_manipulation::GetBooleanType(), tree_manipulation::GetUnsignedLongLongType(), TM, and tree_man.
Referenced by ProcessBasicBlock().
|
overridevirtual |
Initialize the step (i.e., like a constructor, but executed just before exec.
Reimplemented from DesignFlowStep.
Definition at line 1965 of file lut_transformation.cpp.
References FrontendFlowStep::AppM, max_lut_size, DesignFlowStep::parameters, THROW_ASSERT, TM, and tree_man.
|
overridevirtual |
Computes the operations CFG graph data structure.
Implements FunctionFrontendFlowStep.
Definition at line 1975 of file lut_transformation.cpp.
References tree_manager::CGetTreeNode(), CheckIfProcessable(), FunctionFrontendFlowStep::function_behavior, FunctionFrontendFlowStep::function_id, GET_CONST_NODE, max_lut_size, DesignFlowStep::parameters, ProcessBasicBlock(), sl, SUCCESS, THROW_ASSERT, TM, and UNCHANGED.
|
private |
Creates a const expression with 0 (gnd) as value, used for constant LUT inputs (index 0 in mockturtle)
Creates a const expression with 1 (vdd) as value, used for constant LUT inputs (index 1 in mockturtle)
whether the BB has been modified
add previous statements defining non-primary outputs just before the current statement
add selection bit stmts
check if operands are of bool type
check if operands are of bool type
dependencies could be broken so we may need to reorder the lut based statements
Definition at line 1135 of file lut_transformation.cpp.
References FrontendFlowStep::AppM, BUILTIN_SRCP, tree_helper::CGetType(), CHECK_BIN_EXPR_BOOL_SIZE(), CHECK_BIN_EXPR_INT_SIZE(), CHECK_COND_EXPR_SIZE(), CHECK_NOT_EXPR_SIZE(), CheckIfPI(), CheckIfPO(), ConvertBitsToString(), klut_network_ext::create_lut(), tree_manipulation::create_lut_expr(), klut_network_ext::create_pi_v(), klut_network_ext::create_po_v(), tree_manipulation::create_unary_operation(), CreateBitSelectionNodeOrCast(), tree_manipulation::CreateGimpleAssign(), tree_manipulation::CreateNopExpr(), tree_manager::CreateUniqueIntegerCst(), DesignFlowStep::debug_level, DEBUG_LEVEL_VERY_PEDANTIC, FunctionFrontendFlowStep::function_id, klut_network_ext::get_constant_v(), GET_INDEX_NODE, GET_NODE, GetBooleanNodeCreationFunction(), tree_manipulation::GetBooleanType(), tree_helper::GetConstValue(), GetIntegerNodeCreationFunction(), FunctionFrontendFlowStep::GetName(), tree_manipulation::GetUnsignedLongLongType(), INDENT_DBG_MEX, index, IntegerToBitArray(), tree_helper::is_int(), tree_helper::IsBooleanType(), lutBooleanExpressibleOperations, lutIntegerExpressibleOperations, max, max_lut_size, DesignFlowStep::parameters, ParseKLutNetwork(), tree_manager::ReplaceTreeNode(), SimplifyLutNetwork(), tree_helper::Size(), STR, THROW_ASSERT, THROW_ERROR, TM, ToString(), tree_man, and VECT_CONTAINS.
Referenced by InternalExec().
|
private |
The list of all operation that can be converted to a lut.
Definition at line 83 of file lut_transformation.hpp.
Referenced by cannotBeLUT(), and ProcessBasicBlock().
|
private |
Definition at line 88 of file lut_transformation.hpp.
Referenced by cannotBeLUT(), and ProcessBasicBlock().
|
private |
The maximum number of inputs of a lut.
Definition at line 80 of file lut_transformation.hpp.
Referenced by Initialize(), InternalExec(), ProcessBasicBlock(), and SimplifyLutNetwork().
|
private |
The tree manager.
Definition at line 74 of file lut_transformation.hpp.
Referenced by CreateBitSelectionNodeOrCast(), Initialize(), InternalExec(), and ProcessBasicBlock().
|
private |
The lut manipulation.
Definition at line 77 of file lut_transformation.hpp.
Referenced by CreateBitSelectionNodeOrCast(), Initialize(), and ProcessBasicBlock().