PandA-2024.02
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
BitLatticeManipulator Class Reference

#include <bit_lattice.hpp>

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

Public Member Functions

 BitLatticeManipulator (const tree_managerConstRef TM, const int debug_level)
 Constructor. More...
 
 ~BitLatticeManipulator ()
 Destructor. More...
 

Static Public Member Functions

static std::deque< bit_latticesign_extend_bitstring (const std::deque< bit_lattice > &bitstring, bool bitstring_is_signed, size_t final_size)
 Extends a bitstring. More...
 
static void sign_reduce_bitstring (std::deque< bit_lattice > &bitstring, bool bitstring_is_signed)
 Reduce the size of a bitstring erasing all but one most significant zeros in unsigned bitstring and all but one most significant values in signed bitstrings. More...
 
static bit_lattice bit_sup (const bit_lattice a, const bit_lattice b)
 
static bit_lattice bit_inf (const bit_lattice a, const bit_lattice b)
 
static std::deque< bit_latticesup (const std::deque< bit_lattice > &a, const std::deque< bit_lattice > &b, const size_t out_type_size, const bool out_is_signed, const bool out_is_bool)
 
static std::deque< bit_latticeinf (const std::deque< bit_lattice > &a, const std::deque< bit_lattice > &b, const size_t out_type_size, const bool out_is_signed, const bool out_is_bool)
 
static unsigned long long Size (const tree_nodeConstRef &t)
 
static unsigned long long size (const tree_managerConstRef tm, unsigned int index)
 
static bool isBetter (const std::string &a_string, const std::string &b_string)
 

Protected Member Functions

bool IsSignedIntegerType (const tree_nodeConstRef &tn) const
 
std::deque< bit_latticesup (const std::deque< bit_lattice > &a, const std::deque< bit_lattice > &b, const unsigned int output_uid) const
 Computes the sup between two bitstrings. More...
 
std::deque< bit_latticesup (const std::deque< bit_lattice > &a, const std::deque< bit_lattice > &b, const tree_nodeConstRef &out_node) const
 
std::deque< bit_latticeinf (const std::deque< bit_lattice > &a, const std::deque< bit_lattice > &b, const unsigned int output_uid) const
 Computes the inf between two bitstrings. More...
 
std::deque< bit_latticeinf (const std::deque< bit_lattice > &a, const std::deque< bit_lattice > &b, const tree_nodeConstRef &out_node) const
 
std::deque< bit_latticeconstructor_bitstring (const tree_nodeRef &ctor_tn, unsigned int ssa_node_id) const
 auxiliary function used to build the bitstring lattice for read-only arrays More...
 
std::deque< bit_latticestring_cst_bitstring (const tree_nodeRef &strcst_tn, unsigned int ssa_node_id) const
 auxiliary function used to build the bitstring lattice for read-only string_cst More...
 
bool IsHandledByBitvalue (const tree_nodeConstRef &tn) const
 Returns true if the type identified by type_id is handled by bitvalue analysis. More...
 
bool mix ()
 Mixes the content of current and best using the sup operation, storing the result in the best map. More...
 
bool update_current (std::deque< bit_lattice > &res, const tree_nodeConstRef &tn)
 Given a bitstring res, and the id of a tree node ouput_uid, this functions checks if it is necessary to update the bistring stored in the current map used by the bitvalue analysis algorithm. More...
 
void clear ()
 Clean up the internal data structures. More...
 

Protected Attributes

const tree_managerConstRef TM
 
CustomMap< unsigned int, std::deque< bit_lattice > > current
 Map of the current bit-values of each variable. More...
 
CustomMap< unsigned int, std::deque< bit_lattice > > best
 Map of the best bit-values of each variable. More...
 
CustomSet< unsigned int > signed_var
 Set storing the signed ssa. More...
 
const int bl_debug_level
 The debug level of methods of this class - it cannot be named debug_level because of ambiguity of FrontendFlowStep::debug_level derived classes. More...
 

Detailed Description

Definition at line 68 of file bit_lattice.hpp.

Constructor & Destructor Documentation

◆ BitLatticeManipulator()

BitLatticeManipulator::BitLatticeManipulator ( const tree_managerConstRef  _TM,
const int  _bl_debug_level 
)
explicit

Constructor.

Header include.

. include STD include STL includes tree includes utility includes

Definition at line 65 of file bit_lattice.cpp.

References ~BitLatticeManipulator().

Here is the call graph for this function:

◆ ~BitLatticeManipulator()

BitLatticeManipulator::~BitLatticeManipulator ( )
default

Destructor.

Referenced by BitLatticeManipulator().

Here is the caller graph for this function:

Member Function Documentation

◆ bit_inf()

bit_lattice BitLatticeManipulator::bit_inf ( const bit_lattice  a,
const bit_lattice  b 
)
static

Definition at line 258 of file bit_lattice.cpp.

References U, and X.

Referenced by Bit_Value::backward_transfer(), and inf().

Here is the caller graph for this function:

◆ bit_sup()

bit_lattice BitLatticeManipulator::bit_sup ( const bit_lattice  a,
const bit_lattice  b 
)
static

Definition at line 77 of file bit_lattice.cpp.

References U, and X.

Referenced by sup().

Here is the caller graph for this function:

◆ clear()

void BitLatticeManipulator::clear ( )
protected

Clean up the internal data structures.

Definition at line 565 of file bit_lattice.cpp.

References best, current, and signed_var.

Referenced by BitValueIPA::Exec(), Bit_Value::initialize(), and Bit_Value::InternalExec().

Here is the caller graph for this function:

◆ constructor_bitstring()

std::deque< bit_lattice > BitLatticeManipulator::constructor_bitstring ( const tree_nodeRef ctor_tn,
unsigned int  ssa_node_id 
) const
protected

auxiliary function used to build the bitstring lattice for read-only arrays

Parameters
ctor_tnis the tree reindex or a tree node of the contructor
ssa_node_idis the ssa node id of the lattice destination

Definition at line 427 of file bit_lattice.cpp.

References convert_fp_to_string(), create_bitstring_from_constant(), create_u_bitstring(), el, tree_helper::get_array_dim_and_bitsize(), GET_CONST_NODE, GET_INDEX_CONST_NODE, tree_node::get_kind(), GET_NODE, tree_helper::GetConstValue(), inf(), tree_helper::is_int(), sign_reduce_bitstring(), STR, string_to_bitstring(), THROW_ASSERT, TM, tree_node::ToString(), test_panda::type, and X.

Referenced by Bit_Value::initialize().

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

◆ inf() [1/3]

std::deque< bit_lattice > BitLatticeManipulator::inf ( const std::deque< bit_lattice > &  a,
const std::deque< bit_lattice > &  b,
const unsigned int  output_uid 
) const
protected

Computes the inf between two bitstrings.

Parameters
afirst bitstring
bsecond bitstring
output_uidis the id of the tree node for which the bitvalue is * computed
Returns
inf between the two bitstrings

Definition at line 333 of file bit_lattice.cpp.

References TM.

Referenced by Bit_Value::backward_chain(), Bit_Value::backward_transfer(), constructor_bitstring(), BitValueIPA::Exec(), Bit_Value::forward(), Bit_Value::forward_transfer(), inf(), Bit_Value::initialize(), and string_cst_bitstring().

Here is the caller graph for this function:

◆ inf() [2/3]

std::deque< bit_lattice > BitLatticeManipulator::inf ( const std::deque< bit_lattice > &  a,
const std::deque< bit_lattice > &  b,
const tree_nodeConstRef out_node 
) const
protected

◆ inf() [3/3]

std::deque< bit_lattice > BitLatticeManipulator::inf ( const std::deque< bit_lattice > &  a,
const std::deque< bit_lattice > &  b,
const size_t  out_type_size,
const bool  out_is_signed,
const bool  out_is_bool 
)
static

Definition at line 282 of file bit_lattice.cpp.

References bit_inf(), sign_extend_bitstring(), sign_reduce_bitstring(), STR, THROW_ASSERT, and X.

Here is the call graph for this function:

◆ isBetter()

bool BitLatticeManipulator::isBetter ( const std::string &  a_string,
const std::string &  b_string 
)
static

Definition at line 842 of file bit_lattice.cpp.

References string_to_bitstring(), U, and X.

Referenced by BitValueIPA::Exec(), Bit_Value::update_IR(), and VarNode::updateIR().

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

◆ IsHandledByBitvalue()

bool BitLatticeManipulator::IsHandledByBitvalue ( const tree_nodeConstRef tn) const
protected

Returns true if the type identified by type_id is handled by bitvalue analysis.

Definition at line 503 of file bit_lattice.cpp.

References tree_helper::CGetType(), tree_helper::IsComplexType(), tree_helper::IsRealType(), tree_helper::IsStructType(), tree_helper::IsVectorType(), and test_panda::type.

Referenced by Bit_Value::backward(), Bit_Value::backward_chain(), Bit_Value::backward_transfer(), BitValueIPA::Exec(), Bit_Value::forward(), Bit_Value::forward_transfer(), and Bit_Value::initialize().

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

◆ IsSignedIntegerType()

bool BitLatticeManipulator::IsSignedIntegerType ( const tree_nodeConstRef tn) const
protected

Definition at line 72 of file bit_lattice.cpp.

References tree_node::index, tree_helper::IsSignedIntegerType(), and signed_var.

Referenced by Bit_Value::backward_transfer(), Bit_Value::forward(), Bit_Value::forward_transfer(), inf(), sup(), and update_current().

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

◆ mix()

bool BitLatticeManipulator::mix ( )
protected

Mixes the content of current and best using the sup operation, storing the result in the best map.

Returns true if the best map was updated, false otherwise.

Definition at line 510 of file bit_lattice.cpp.

References best, bitstring_to_string(), bl_debug_level, current, DEBUG_LEVEL_VERY_PEDANTIC, tree_helper::GetMangledFunctionName(), INDENT_DBG_MEX, STR, sup(), and TM.

Referenced by BitValueIPA::Exec(), and Bit_Value::InternalExec().

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

◆ sign_extend_bitstring()

std::deque< bit_lattice > BitLatticeManipulator::sign_extend_bitstring ( const std::deque< bit_lattice > &  bitstring,
bool  bitstring_is_signed,
size_t  final_size 
)
static

Extends a bitstring.

Parameters
bitstringto extend
bitstring_is_signedmust be true if bitstring is signed
final_sizedesired length of the bitstrign
Returns
the extended bitstring

Definition at line 409 of file bit_lattice.cpp.

References THROW_ASSERT, X, and ZERO.

Referenced by Bit_Value::backward_transfer(), Bit_Value::forward_transfer(), Range::fromBitValues(), Range::getBitValues(), RealRange::getBitValues(), inf(), Bit_Value::initialize(), and sup().

Here is the caller graph for this function:

◆ sign_reduce_bitstring()

void BitLatticeManipulator::sign_reduce_bitstring ( std::deque< bit_lattice > &  bitstring,
bool  bitstring_is_signed 
)
static

Reduce the size of a bitstring erasing all but one most significant zeros in unsigned bitstring and all but one most significant values in signed bitstrings.

function slightly different than tree_helper.cpp: sign_reduce_bitstring

Parameters
bitstringbitstring to reduce.
bitstring_is_signedmust be true if bitstring is signed

Definition at line 372 of file bit_lattice.cpp.

References THROW_ASSERT, U, X, and ZERO.

Referenced by constructor_bitstring(), Range::getBitValues(), inf(), Bit_Value::initialize(), sup(), and update_current().

Here is the caller graph for this function:

◆ Size()

unsigned long long BitLatticeManipulator::Size ( const tree_nodeConstRef t)
static

◆ size()

unsigned long long BitLatticeManipulator::size ( const tree_managerConstRef  tm,
unsigned int  index 
)
static

Definition at line 670 of file bit_lattice.cpp.

References Size().

Referenced by Bit_Value::backward_transfer(), BitValueIPA::Exec(), and Bit_Value::pointer_resizing().

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

◆ string_cst_bitstring()

std::deque< bit_lattice > BitLatticeManipulator::string_cst_bitstring ( const tree_nodeRef strcst_tn,
unsigned int  ssa_node_id 
) const
protected

auxiliary function used to build the bitstring lattice for read-only string_cst

Parameters
strcst_tnis a tree reindex or a tree node of the string_cst
ssa_node_idis the ssa node id of the lattice destination

Definition at line 487 of file bit_lattice.cpp.

References create_bitstring_from_constant(), tree_node::get_kind(), inf(), tree_helper::is_int(), str, THROW_ASSERT, and TM.

Referenced by Bit_Value::initialize().

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

◆ sup() [1/3]

std::deque< bit_lattice > BitLatticeManipulator::sup ( const std::deque< bit_lattice > &  a,
const std::deque< bit_lattice > &  b,
const unsigned int  output_uid 
) const
protected

Computes the sup between two bitstrings.

Parameters
afirst bitstring variable
bsecond bitstring variable
output_uidis the id of the tree node for which the bitvalue is * computed
Returns
the sup of the two bitstrings.

Definition at line 218 of file bit_lattice.cpp.

References TM.

Referenced by BitValueIPA::Exec(), Bit_Value::initialize(), mix(), sup(), update_current(), and VarNode::updateIR().

Here is the caller graph for this function:

◆ sup() [2/3]

std::deque< bit_lattice > BitLatticeManipulator::sup ( const std::deque< bit_lattice > &  a,
const std::deque< bit_lattice > &  b,
const tree_nodeConstRef out_node 
) const
protected

◆ sup() [3/3]

std::deque< bit_lattice > BitLatticeManipulator::sup ( const std::deque< bit_lattice > &  a,
const std::deque< bit_lattice > &  b,
const size_t  out_type_size,
const bool  out_is_signed,
const bool  out_is_bool 
)
static

Definition at line 101 of file bit_lattice.cpp.

References bit_sup(), bitstring_to_string(), min, ONE, sign_extend_bitstring(), sign_reduce_bitstring(), THROW_ASSERT, X, and ZERO.

Here is the call graph for this function:

◆ update_current()

bool BitLatticeManipulator::update_current ( std::deque< bit_lattice > &  res,
const tree_nodeConstRef tn 
)
protected

Given a bitstring res, and the id of a tree node ouput_uid, this functions checks if it is necessary to update the bistring stored in the current map used by the bitvalue analysis algorithm.

Definition at line 542 of file bit_lattice.cpp.

References best, bitstring_constant(), current, tree_node::index, IsSignedIntegerType(), sign_reduce_bitstring(), sup(), THROW_ASSERT, X, and ZERO.

Referenced by Bit_Value::backward(), BitValueIPA::Exec(), and Bit_Value::forward().

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

Field Documentation

◆ best

CustomMap<unsigned int, std::deque<bit_lattice> > BitLatticeManipulator::best
protected

Map of the best bit-values of each variable.

Map storing the best bit-values of the variables at the end of all the iterations of forward_transfer or backward_transfer.

Definition at line 85 of file bit_lattice.hpp.

Referenced by Bit_Value::backward_chain(), Bit_Value::backward_transfer(), clear(), Bit_Value::clear_current(), BitValueIPA::Exec(), Bit_Value::forward(), Bit_Value::get_current(), Bit_Value::get_current_or_best(), Bit_Value::initialize(), Bit_Value::InternalExec(), mix(), update_current(), and Bit_Value::update_IR().

◆ bl_debug_level

const int BitLatticeManipulator::bl_debug_level
protected

The debug level of methods of this class - it cannot be named debug_level because of ambiguity of FrontendFlowStep::debug_level derived classes.

Definition at line 94 of file bit_lattice.hpp.

Referenced by mix().

◆ current

CustomMap<unsigned int, std::deque<bit_lattice> > BitLatticeManipulator::current
protected

Map of the current bit-values of each variable.

Map storing the current bit-values of the variables at the end of each iteration of forward_transfer or backward_transfer.

Definition at line 78 of file bit_lattice.hpp.

Referenced by Bit_Value::backward(), Bit_Value::backward_chain(), Bit_Value::backward_transfer(), clear(), Bit_Value::clear_current(), BitValueIPA::Exec(), Bit_Value::forward(), Bit_Value::get_current(), Bit_Value::get_current_or_best(), mix(), and update_current().

◆ signed_var

CustomSet<unsigned int> BitLatticeManipulator::signed_var
protected

Set storing the signed ssa.

Definition at line 90 of file bit_lattice.hpp.

Referenced by clear(), BitValueIPA::Exec(), Bit_Value::initialize(), and IsSignedIntegerType().

◆ TM

const tree_managerConstRef BitLatticeManipulator::TM
protected

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

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