Ghidra 11.3.2
Ghidra internal decompiler documentation.
Loading...
Searching...
No Matches
ghidra::BooleanMatch Class Reference

Static methods for determining if two boolean expressions are the same or complementary. More...

#include <op.hh>

Public Types

enum  { same = 1 , complementary = 2 , uncorrelated = 3 }
 

Static Public Member Functions

static int4 evaluate (Varnode *vn1, Varnode *vn2, int4 depth)
 Determine if two boolean Varnodes hold related values.
 

Static Private Member Functions

static bool sameOpComplement (PcodeOp *bin1op, PcodeOp *bin2op)
 Test if two operations with same opcode produce complementary boolean values.
 
static bool varnodeSame (Varnode *a, Varnode *b)
 Do the given Varnodes hold the same value, possibly as constants.
 

Detailed Description

Static methods for determining if two boolean expressions are the same or complementary.

Traverse (upto a specific depth) the two boolean expressions consisting of BOOL_AND, BOOL_OR, and BOOL_XOR operations. Leaf operators in the expression can be other operators with boolean output (INT_LESS, INT_SLESS, etc.).

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
same 

Pair always hold the same value.

complementary 

Pair always hold complementary values.

uncorrelated 

Pair values are uncorrelated.

Member Function Documentation

◆ evaluate()

int4 ghidra::BooleanMatch::evaluate ( Varnode vn1,
Varnode vn2,
int4  depth 
)
static

Determine if two boolean Varnodes hold related values.

The values may be the same, or opposite of each other (complementary). Otherwise the values are uncorrelated. The trees constructing each Varnode are examined up to a maximum depth. If this is exceeded uncorrelated is returned.

Parameters
vn1is the first boolean Varnode
vn2is the second boolean Varnode
depthis the maximum depth to traverse in the evaluation
Returns
the correlation class

References ghidra::PcodeOp::code(), complementary, ghidra::CPUI_BOOL_AND, ghidra::CPUI_BOOL_NEGATE, ghidra::CPUI_BOOL_OR, ghidra::CPUI_BOOL_XOR, ghidra::CPUI_MAX, evaluate(), ghidra::Varnode::getDef(), ghidra::PcodeOp::getIn(), ghidra::PcodeOp::isBoolOutput(), ghidra::Varnode::isWritten(), same, sameOpComplement(), uncorrelated, and varnodeSame().

Referenced by evaluate(), ghidra::RuleBooleanUndistribute::isMatch(), and ghidra::BooleanExpressionMatch::verifyCondition().

◆ sameOpComplement()

bool ghidra::BooleanMatch::sameOpComplement ( PcodeOp bin1op,
PcodeOp bin2op 
)
staticprivate

Test if two operations with same opcode produce complementary boolean values.

This only tests for cases where the opcode is INT_LESS or INT_SLESS and one of the inputs is constant.

Parameters
bin1opis the first p-code op to compare
bin2opis the second p-code op to compare
Returns
true if the two operations always produce complementary values

References ghidra::PcodeOp::code(), ghidra::CPUI_INT_LESS, ghidra::CPUI_INT_SLESS, ghidra::PcodeOp::getIn(), ghidra::Varnode::getOffset(), ghidra::Varnode::getSize(), ghidra::Varnode::isConstant(), and varnodeSame().

Referenced by evaluate().

◆ varnodeSame()

bool ghidra::BooleanMatch::varnodeSame ( Varnode a,
Varnode b 
)
staticprivate

Do the given Varnodes hold the same value, possibly as constants.

Parameters
ais the first Varnode to compare
bis the second Varnode
Returns
true if the Varnodes (always) hold the same value

References ghidra::Varnode::getOffset(), and ghidra::Varnode::isConstant().

Referenced by evaluate(), and sameOpComplement().


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