PandA-2024.02
|
#include <bit_lattice.hpp>
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_lattice > | sign_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_lattice > | 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 std::deque< bit_lattice > | 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 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_lattice > | sup (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_lattice > | sup (const std::deque< bit_lattice > &a, const std::deque< bit_lattice > &b, const tree_nodeConstRef &out_node) const |
std::deque< bit_lattice > | inf (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_lattice > | inf (const std::deque< bit_lattice > &a, const std::deque< bit_lattice > &b, const tree_nodeConstRef &out_node) const |
std::deque< bit_lattice > | constructor_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_lattice > | string_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... | |
Definition at line 68 of file bit_lattice.hpp.
|
explicit |
Constructor.
Header include.
. include STD include STL includes tree includes utility includes
Definition at line 65 of file bit_lattice.cpp.
References ~BitLatticeManipulator().
|
default |
|
static |
Definition at line 258 of file bit_lattice.cpp.
Referenced by Bit_Value::backward_transfer(), and inf().
|
static |
Definition at line 77 of file bit_lattice.cpp.
Referenced by sup().
|
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().
|
protected |
auxiliary function used to build the bitstring lattice for read-only arrays
ctor_tn | is the tree reindex or a tree node of the contructor |
ssa_node_id | is 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().
|
protected |
Computes the inf between two bitstrings.
a | first bitstring |
b | second bitstring |
output_uid | is the id of the tree node for which the bitvalue is * computed |
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().
|
protected |
Definition at line 339 of file bit_lattice.cpp.
References tree_helper::CGetType(), GET_CONST_NODE, tree_node::get_kind(), tree_node::GetString(), inf(), tree_helper::IsBooleanType(), IsSignedIntegerType(), Size(), STR, THROW_ASSERT, and THROW_UNREACHABLE.
|
static |
Definition at line 282 of file bit_lattice.cpp.
References bit_inf(), sign_extend_bitstring(), sign_reduce_bitstring(), STR, THROW_ASSERT, and X.
|
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().
|
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().
|
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().
|
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().
|
static |
Extends a bitstring.
bitstring | to extend |
bitstring_is_signed | must be true if bitstring is signed |
final_size | desired length of the bitstrign |
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().
|
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
bitstring | bitstring to reduce. |
bitstring_is_signed | must 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().
|
static |
Definition at line 675 of file bit_lattice.cpp.
References CASE_BINARY_EXPRESSION, CASE_CPP_NODES, CASE_CST_NODES, CASE_DECL_NODES, CASE_PRAGMA_NODES, CASE_TERNARY_EXPRESSION, CASE_UNARY_EXPRESSION, GET_CONST_NODE, tree_node::get_kind(), tree_node::get_kind_text(), GET_NODE, tree_helper::GetConstValue(), tree_helper::IsConstant(), THROW_ASSERT, THROW_ERROR, THROW_UNREACHABLE, and test_panda::type.
Referenced by Bit_Value::backward_chain(), Bit_Value::backward_transfer(), Bit_Value_opt::constrainSSA(), BitValueIPA::Exec(), Bit_Value::forward(), Bit_Value::forward_transfer(), inf(), Bit_Value::initialize(), Bit_Value_opt::optimize(), size(), and sup().
|
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().
|
protected |
auxiliary function used to build the bitstring lattice for read-only string_cst
strcst_tn | is a tree reindex or a tree node of the string_cst |
ssa_node_id | is 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().
|
protected |
Computes the sup between two bitstrings.
a | first bitstring variable |
b | second bitstring variable |
output_uid | is the id of the tree node for which the bitvalue is * computed |
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().
|
protected |
Definition at line 224 of file bit_lattice.cpp.
References tree_helper::CGetType(), GET_CONST_NODE, tree_node::get_kind(), tree_node::GetString(), tree_helper::IsBooleanType(), IsSignedIntegerType(), Size(), STR, sup(), THROW_ASSERT, and THROW_UNREACHABLE.
|
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.
|
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().
|
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().
|
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().
|
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().
|
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().
|
protected |
Definition at line 71 of file bit_lattice.hpp.
Referenced by Bit_Value::backward(), Bit_Value::backward_chain(), Bit_Value::backward_transfer(), constructor_bitstring(), BitValueIPA::Exec(), Bit_Value::forward(), Bit_Value::forward_transfer(), inf(), Bit_Value::initialize(), Bit_Value::Initialize(), mix(), Bit_Value::pointer_resizing(), string_cst_bitstring(), sup(), and Bit_Value::update_IR().