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

Compute the control flow graph for the operations. More...

#include <IR_lowering.hpp>

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

Public Member Functions

 IR_lowering (const ParameterConstRef Param, const application_managerRef AppM, unsigned int function_id, const DesignFlowManagerConstRef design_flow_manager)
 Constructor. More...
 
 ~IR_lowering () override
 Destructor. More...
 
DesignFlowStep_Status InternalExec () override
 traverse the data structure to simplify and make more homogeneous as possible. 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

tree_nodeRef expand_mult_const (const tree_nodeRef &op0, unsigned long long int val, const struct algorithm &alg, enum mult_variant &variant, const tree_nodeRef &stmt, const blocRef &block, const tree_nodeRef &type, const std::string &srcp_default)
 A subroutine of expand_mult, used for constant multiplications. More...
 
tree_nodeRef expand_smod_pow2 (const tree_nodeRef &op0, unsigned long long int d, const tree_nodeRef &stmt, const blocRef &block, const tree_nodeRef &type, const std::string &srcp_default)
 Expand signed modulus of OP0 by a power of two D in mode MODE. More...
 
tree_nodeRef expand_sdiv_pow2 (const tree_nodeRef &op0, unsigned long long int d, const tree_nodeRef &stmt, const blocRef &block, const tree_nodeRef &type, const std::string &srcp_default)
 Expand signed division of OP0 by a power of two D in mode MODE. More...
 
tree_nodeRef expand_MC (const tree_nodeRef &op0, const integer_cst *ic_node, const tree_nodeRef &old_target, const tree_nodeRef &stmt, const blocRef &block, const tree_nodeRef &type_expr, const std::string &srcp_default)
 
bool expand_target_mem_ref (target_mem_ref461 *tmr, const tree_nodeRef &stmt, const blocRef &block, const std::string &srcp_default, bool temp_addr)
 
tree_nodeRef expand_mult_highpart (const tree_nodeRef &op0, unsigned long long int ml, const tree_nodeRef &type_expr, int data_bitsize, const std::list< tree_nodeRef >::const_iterator it_los, const blocRef &block, const std::string &srcp_default)
 
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...
 
tree_nodeRef array_ref_lowering (array_ref *AR, const std::string &srcp_default, std::pair< unsigned int, blocRef > block, std::list< tree_nodeRef >::const_iterator it_los, bool temp_addr)
 
bool reached_max_transformation_limit (const tree_nodeRef &stmt)
 check if the max transformation limit has been reached More...
 
void division_by_a_constant (const std::pair< unsigned int, blocRef > &block, std::list< tree_nodeRef >::const_iterator &it_los, gimple_assign *ga, const tree_nodeRef &op1, enum kind code1, bool &restart_analysis, const std::string &srcp_default, const std::string &step_name)
 

Private Attributes

tree_managerRef TM
 The tree manager. More...
 
tree_manipulationRef tree_man
 The IR manipulation. 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 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

Compute the control flow graph for the operations.

Definition at line 84 of file IR_lowering.hpp.

Constructor & Destructor Documentation

◆ IR_lowering()

IR_lowering::IR_lowering ( 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 82 of file IR_lowering.cpp.

References DesignFlowStep::debug_level, GET_CLASS, and DesignFlowStep::parameters.

◆ ~IR_lowering()

IR_lowering::~IR_lowering ( )
overridedefault

Destructor.

Referenced by ComputeFrontendRelationships().

Here is the caller graph for this function:

Member Function Documentation

◆ array_ref_lowering()

tree_nodeRef IR_lowering::array_ref_lowering ( array_ref *  AR,
const std::string &  srcp_default,
std::pair< unsigned int, blocRef >  block,
std::list< tree_nodeRef >::const_iterator  it_los,
bool  temp_addr 
)
private

◆ ComputeFrontendRelationships()

const CustomUnorderedSet< std::pair< FrontendFlowStepType, FrontendFlowStep::FunctionRelationship > > IR_lowering::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 90 of file IR_lowering.cpp.

References DesignFlowStep::DEPENDENCE_RELATIONSHIP, DesignFlowStep::INVALIDATION_RELATIONSHIP, DesignFlowStep::PRECEDENCE_RELATIONSHIP, SAME_FUNCTION, THROW_UNREACHABLE, WHOLE_APPLICATION, and ~IR_lowering().

Here is the call graph for this function:

◆ ComputeRelationships()

void IR_lowering::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 129 of file IR_lowering.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:

◆ division_by_a_constant()

void IR_lowering::division_by_a_constant ( const std::pair< unsigned int, blocRef > &  block,
std::list< tree_nodeRef >::const_iterator &  it_los,
gimple_assign ga,
const tree_nodeRef op1,
enum kind  code1,
bool restart_analysis,
const std::string &  srcp_default,
const std::string &  step_name 
)
private

◆ expand_MC()

tree_nodeRef IR_lowering::expand_MC ( const tree_nodeRef op0,
const integer_cst ic_node,
const tree_nodeRef old_target,
const tree_nodeRef stmt,
const blocRef &  block,
const tree_nodeRef type_expr,
const std::string &  srcp_default 
)
private

◆ expand_mult_const()

tree_nodeRef IR_lowering::expand_mult_const ( const tree_nodeRef op0,
unsigned long long int  val,
const struct algorithm alg,
enum mult_variant variant,
const tree_nodeRef stmt,
const blocRef &  block,
const tree_nodeRef type,
const std::string &  srcp_default 
)
private

A subroutine of expand_mult, used for constant multiplications.

Multiply OP0 by VAL in mode MODE, storing the result in TARGET if convenient. Use the shift/add sequence described by ALG and apply the final fixup specified by VARIANT.

Compare only the bits of val and val_so_far that are significant in the result mode, to avoid sign-/zero-extension confusion.

Definition at line 782 of file IR_lowering.cpp.

References add_variant, alg_add_factor, alg_add_t2_m, alg_add_t_m2, alg_impossible, alg_m, alg_shift, alg_sub_factor, alg_sub_t2_m, alg_sub_t_m2, alg_unknown, alg_zero, FrontendFlowStep::AppM, tree_helper::CGetType(), tree_manipulation::create_binary_operation(), tree_manipulation::create_unary_operation(), tree_manipulation::CreateGimpleAssign(), tree_manager::CreateUniqueIntegerCst(), DesignFlowStep::debug_level, DEBUG_LEVEL_VERY_PEDANTIC, FunctionFrontendFlowStep::function_id, GET_NODE, INDENT_DBG_MEX, algorithm::log, negate_variant, algorithm::op, algorithm::ops, tree_helper::Size(), THROW_ASSERT, THROW_ERROR, THROW_UNREACHABLE, TM, tree_node::ToString(), and tree_man.

Referenced by expand_MC().

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

◆ expand_mult_highpart()

tree_nodeRef IR_lowering::expand_mult_highpart ( const tree_nodeRef op0,
unsigned long long int  ml,
const tree_nodeRef type_expr,
int  data_bitsize,
const std::list< tree_nodeRef >::const_iterator  it_los,
const blocRef &  block,
const std::string &  srcp_default 
)
private

long long int u0, v0, u1, v1, u0v0, u0v0h, u1v0, u0v0hu1v0, u0v1, u0v0hu1v0u0v1, u0v0hu1v0u0v1h, u1v1; u0 = u & ((1LL<<32)-1); u1 = u >>32; v0 = v & ((1LL<<32)-1); v1 = v >>32; u0v0 = u0 * v0; u0v0h = u0v0>>32; u0v0hU = u0v0h & ((1LL<<32)-1);///only for signed computation u1v0 = u1 * v0; u0v0hu1v0 = u0v0hU + u1v0; w1 = u0v0hu1v0 & ((1LL<<32)-1); w2 = u0v0hu1v0 >>32; u0v1 = u0 * v1; w1u0v1 = w1+u0v1; w1u0v1h = w1u0v1 >> 32; u1v1 = u1 * v1; w1u0v1hw2 = w1u0v1h + w2; return w1u0v1hw2 + u1v1;

Definition at line 1466 of file IR_lowering.cpp.

References FrontendFlowStep::AppM, tree_manipulation::create_binary_operation(), tree_manipulation::CreateGimpleAssign(), tree_manager::CreateUniqueIntegerCst(), FunctionFrontendFlowStep::function_id, GET_INDEX_NODE, GET_NODE, tree_helper::is_unsigned(), THROW_ASSERT, TM, and tree_man.

Referenced by division_by_a_constant().

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

◆ expand_sdiv_pow2()

tree_nodeRef IR_lowering::expand_sdiv_pow2 ( const tree_nodeRef op0,
unsigned long long int  d,
const tree_nodeRef stmt,
const blocRef &  block,
const tree_nodeRef type,
const std::string &  srcp_default 
)
private

Expand signed division of OP0 by a power of two D in mode MODE.

This routine is only called for positive values of D.

Definition at line 1116 of file IR_lowering.cpp.

References FrontendFlowStep::AppM, tree_manipulation::create_binary_operation(), tree_manipulation::create_ternary_operation(), tree_manipulation::CreateGimpleAssign(), tree_manager::CreateUniqueIntegerCst(), floor_log2(), FunctionFrontendFlowStep::function_id, GET_NODE, tree_manipulation::GetBooleanType(), TM, and tree_man.

Referenced by division_by_a_constant().

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

◆ expand_smod_pow2()

tree_nodeRef IR_lowering::expand_smod_pow2 ( const tree_nodeRef op0,
unsigned long long int  d,
const tree_nodeRef stmt,
const blocRef &  block,
const tree_nodeRef type,
const std::string &  srcp_default 
)
private

◆ expand_target_mem_ref()

bool IR_lowering::expand_target_mem_ref ( target_mem_ref461 tmr,
const tree_nodeRef stmt,
const blocRef &  block,
const std::string &  srcp_default,
bool  temp_addr 
)
private

◆ Initialize()

void IR_lowering::Initialize ( )
overridevirtual

Initialize the step (i.e., like a constructor, but executed just before exec.

Reimplemented from DesignFlowStep.

Definition at line 123 of file IR_lowering.cpp.

References FrontendFlowStep::AppM, DesignFlowStep::parameters, TM, and tree_man.

◆ InternalExec()

DesignFlowStep_Status IR_lowering::InternalExec ( )
overridevirtual

traverse the data structure to simplify and make more homogeneous as possible.

Returns
the exit status of this step

first analyze phis

It is required to de-share some IR nodes

for each basic block B in CFG do > Consider all blocks successively

found a a clobber assignment do nothing

required by the CLANG/LLVM plugin

required by the CLANG/LLVM plugin

required by the CLANG/LLVM plugin

required by the CLANG/LLVM plugin

check for a missing cast

normalize op0

expose some part of the target_mem_ref statement

check missing cast

split the target_mem_ref in a address computation statement and in a load statement

check if there is a misaligned access

required by CLANG/LLVM plugin

required by CLANG/LLVM plugin

if the previous transformation still give a multiplication let's check if this multiplication is actually widen_mult_expr

check if a mult_expr may become a widen_mult_expr

check if there is a misaligned access

check if the mem_ref corresponds to an implicit memset and then it will be lowered to simple loop initializing the variable

split the target_mem_ref in a address computation statement and in a store statement

manage something as binary operand

required by the CLANG/LLVM plugin

required by the CLANG/LLVM plugin

optimize less than 0 or greater than or equal than 0

required by the CLANG/LLVM plugin

Implements FunctionFrontendFlowStep.

Definition at line 1035 of file IR_lowering_exec.cpp.

References align(), FrontendFlowStep::AppM, test_panda::arg, array_ref_lowering(), tree_helper::CGetElements(), tree_helper::CGetType(), tree_manipulation::create_binary_operation(), tree_manipulation::create_unary_operation(), tree_manipulation::CreateAddrExpr(), tree_manipulation::CreateGimpleAssign(), tree_manipulation::CreateNopExpr(), tree_manager::CreateUniqueIntegerCst(), tree_manipulation::CreateUnsigned(), tree_manipulation::CreateVectorBooleanType(), DesignFlowStep::debug_level, DEBUG_LEVEL_PEDANTIC, DEBUG_LEVEL_VERY_PEDANTIC, division_by_a_constant(), expand_MC(), expand_target_mem_ref(), FunctionFrontendFlowStep::function_behavior, FunctionFrontendFlowStep::function_id, tree_helper::get_base_index(), GET_CONST_NODE, GET_INDEX_CONST_NODE, GET_INDEX_NODE, tree_node::get_kind(), GET_NODE, tree_manager::get_tree_node_const(), tree_helper::get_type_index(), tree_manipulation::GetBooleanType(), tree_helper::GetConstValue(), tree_manipulation::GetCustomIntegerType(), tree_helper::GetFunctionReturnType(), FunctionFrontendFlowStep::GetName(), tree_manipulation::GetPointerType(), tree_manipulation::GetSizeType(), tree_manager::GetTreeNode(), tree_manager::GetTreeReindex(), INDENT_DBG_MEX, INDENT_OUT_MEX, tree_helper::is_int(), tree_helper::is_real(), tree_helper::IsBooleanType(), tree_helper::IsRealType(), tree_helper::IsSameType(), tree_helper::IsSignedIntegerType(), tree_helper::IsUnsignedIntegerType(), tree_helper::IsVectorType(), max, offset, DesignFlowStep::output_level, OUTPUT_LEVEL_MINIMUM, DesignFlowStep::parameters, phi, tree_helper::print_function_name(), reached_max_transformation_limit(), tree_helper::Size(), sl, STR, SUCCESS, THROW_ASSERT, THROW_ERROR, THROW_UNREACHABLE, THROW_WARNING, TM, ToString(), tree_man, and test_panda::type.

Here is the call graph for this function:

◆ reached_max_transformation_limit()

bool IR_lowering::reached_max_transformation_limit ( const tree_nodeRef stmt)
private

check if the max transformation limit has been reached

Parameters
stmtis the current statement
Returns
true in case all the next transformations have to be skipped

Definition at line 1792 of file IR_lowering.cpp.

References FrontendFlowStep::AppM, GET_CONST_NODE, and tree_node::get_kind().

Referenced by InternalExec().

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

Field Documentation

◆ TM

tree_managerRef IR_lowering::TM
private

◆ tree_man

tree_manipulationRef IR_lowering::tree_man
private

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

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