PandA-2024.02
Public Member Functions | Private Member Functions | Private Attributes
lut_transformation Class Reference

#include <lut_transformation.hpp>

Inheritance diagram for lut_transformation:
Inheritance graph
[legend]
Collaboration diagram for lut_transformation:
Collaboration graph
[legend]

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 kindlutBooleanExpressibleOperations
 The list of all operation that can be converted to a lut. More...
 
const std::vector< enum kindlutIntegerExpressibleOperations
 

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 DesignFlowManagerdesign_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...
 

Detailed Description

Definition at line 70 of file lut_transformation.hpp.

Constructor & Destructor Documentation

◆ lut_transformation()

lut_transformation::lut_transformation ( const ParameterConstRef  Param,
const application_managerRef  AppM,
unsigned int  function_id,
const DesignFlowManagerConstRef  design_flow_manager 
)

Constructor.

Parameters
Paramis the set of the parameters
AppMis the application manager
function_idis the identifier of the function
DesignFlowManagerConstRefis 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().

Here is the call graph for this function:

◆ ~lut_transformation()

lut_transformation::~lut_transformation ( )
overridedefault

Destructor.

Referenced by lut_transformation().

Here is the caller graph for this function:

Member Function Documentation

◆ cannotBeLUT()

bool lut_transformation::cannotBeLUT ( tree_nodeRef  op) const
private

cannotBeLUT returns true in case the op is an operation that cannot be translated in a LUT

Parameters
opis an operation
Returns
true in case op cannot be translated in a LUT, false otherwise.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CHECK_BIN_EXPR_BOOL_SIZE()

bool lut_transformation::CHECK_BIN_EXPR_BOOL_SIZE ( binary_expr be) const
private

◆ CHECK_BIN_EXPR_INT_SIZE()

bool lut_transformation::CHECK_BIN_EXPR_INT_SIZE ( binary_expr be,
unsigned int  max 
) const
private

◆ CHECK_COND_EXPR_SIZE()

bool lut_transformation::CHECK_COND_EXPR_SIZE ( cond_expr *  ce) const
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CHECK_NOT_EXPR_SIZE()

bool lut_transformation::CHECK_NOT_EXPR_SIZE ( unary_expr ne) const
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckIfPI()

bool lut_transformation::CheckIfPI ( tree_nodeRef  in,
unsigned int  BB_index 
)
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.

Parameters
inis the ssa variable to check
Returns
whether the provided ssa variable is a primary input
Parameters
ina 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckIfPO()

bool lut_transformation::CheckIfPO ( gimple_assign gimpleAssign)
private

Checks if the provided gimple_assign is a primary output of lut network.

Parameters
gimpleAssignthe gimple_assign to check
Returns
whether the provided 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckIfProcessable()

bool lut_transformation::CheckIfProcessable ( std::pair< unsigned int, blocRef >  block)
private

Checks if the provided basic block can be further processed.

There are two cases in which this condition is true:

  • the basic block contains an instruction convertible to a lut_expr_K
  • the basic block contains a lut_expr_K that has constant inputs
Parameters
blockthe block to check
Returns
whether the provided basic block can be further processed

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ComputeFrontendRelationships()

const CustomUnorderedSet< std::pair< FrontendFlowStepType, FrontendFlowStep::FunctionRelationship > > lut_transformation::ComputeFrontendRelationships ( const DesignFlowStep::RelationshipType  relationship_type) const
overrideprivatevirtual

Return the set of analyses in relationship with this design step.

Parameters
relationship_typeis 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.

Here is the call graph for this function:

◆ ComputeRelationships()

void lut_transformation::ComputeRelationships ( DesignFlowStepSet relationship,
const DesignFlowStep::RelationshipType  relationship_type 
)
overridevirtual

Compute the relationships of a step with other steps.

Parameters
dependenciesis where relationships will be stored
relationship_typeis 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.

Here is the call graph for this function:

◆ CreateBitSelectionNodeOrCast()

tree_nodeRef lut_transformation::CreateBitSelectionNodeOrCast ( const tree_nodeRef  source,
int  index,
std::vector< tree_nodeRef > &  prev_stmts_to_add 
)
private

◆ Initialize()

void lut_transformation::Initialize ( )
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.

◆ InternalExec()

DesignFlowStep_Status lut_transformation::InternalExec ( )
overridevirtual

Computes the operations CFG graph data structure.

Returns
the exit status of this step

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.

Here is the call graph for this function:

◆ ProcessBasicBlock()

bool lut_transformation::ProcessBasicBlock ( std::pair< unsigned int, blocRef >  block)
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().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ lutBooleanExpressibleOperations

const std::vector<enum kind> lut_transformation::lutBooleanExpressibleOperations
private
Initial value:
= {
bit_and_expr_K, truth_and_expr_K, bit_ior_expr_K, truth_or_expr_K, truth_orif_expr_K,
bit_xor_expr_K, truth_xor_expr_K, eq_expr_K, ge_expr_K, lut_expr_K,
cond_expr_K, gt_expr_K, le_expr_K, lt_expr_K, ne_expr_K}

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().

◆ lutIntegerExpressibleOperations

const std::vector<enum kind> lut_transformation::lutIntegerExpressibleOperations
private
Initial value:
= {eq_expr_K, ne_expr_K, lt_expr_K,
le_expr_K, gt_expr_K, ge_expr_K}

Definition at line 88 of file lut_transformation.hpp.

Referenced by cannotBeLUT(), and ProcessBasicBlock().

◆ max_lut_size

size_t lut_transformation::max_lut_size
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().

◆ TM

tree_managerRef lut_transformation::TM
private

The tree manager.

Definition at line 74 of file lut_transformation.hpp.

Referenced by CreateBitSelectionNodeOrCast(), Initialize(), InternalExec(), and ProcessBasicBlock().

◆ tree_man

tree_manipulationRef lut_transformation::tree_man
private

The lut manipulation.

Definition at line 77 of file lut_transformation.hpp.

Referenced by CreateBitSelectionNodeOrCast(), Initialize(), and ProcessBasicBlock().


The documentation for this class was generated from the following files:

Generated on Mon Feb 12 2024 13:03:57 for PandA-2024.02 by doxygen 1.8.13