decompiler  1.0.0
Public Member Functions | Public Attributes | List of all members
ghidra::RuleOrPredicate::MultiPredicate Struct Reference

A helper class to mark up predicated INT_OR expressions. More...

Public Member Functions

bool discoverZeroSlot (Varnode *vn)
 Check if vn is produced by a 2-branch MULTIEQUAL, one side of which is a zero constant. More...
 
bool discoverCbranch (void)
 Find CBRANCH operation that determines whether zero is set or not. More...
 
void discoverPathIsTrue (void)
 Does the condBlock true outgoing edge flow to the block that sets zero. More...
 
bool discoverConditionalZero (Varnode *vn)
 Verify that CBRANCH boolean expression is either (vn == 0) or (vn != 0) More...
 

Public Attributes

PcodeOpop
 Base MULTIEQUAL op.
 
int4 zeroSlot
 Input slot containing path that sets zero.
 
const FlowBlockzeroBlock
 Final block in path that sets zero.
 
const FlowBlockcondBlock
 Conditional block determining if zero is set or not.
 
PcodeOpcbranch
 CBRANCH determining if zero is set.
 
VarnodeotherVn
 Other (non-zero) Varnode getting set on other path.
 
bool zeroPathIsTrue
 True if path to zero set is the true path out of condBlock.
 

Detailed Description

A helper class to mark up predicated INT_OR expressions.

Member Function Documentation

◆ discoverCbranch()

bool ghidra::RuleOrPredicate::MultiPredicate::discoverCbranch ( void  )

Find CBRANCH operation that determines whether zero is set or not.

Assuming that op is a 2-branch MULTIEQUAL as per discoverZeroSlot(), try to find a single CBRANCH whose two out edges correspond to the in edges of the MULTIEQUAL. In this case, the boolean expression controlling the CBRANCH is also controlling whether zero flows into the MULTIEQUAL output Varnode.

Returns
true if a single controlling CBRANCH is found

References ghidra::CPUI_CBRANCH, ghidra::FlowBlock::getIn(), ghidra::FlowBlock::getParent(), ghidra::FlowBlock::lastOp(), ghidra::FlowBlock::sizeIn(), and ghidra::FlowBlock::sizeOut().

Referenced by ghidra::RuleOrPredicate::applyOp(), and ghidra::RuleOrPredicate::checkSingle().

◆ discoverConditionalZero()

bool ghidra::RuleOrPredicate::MultiPredicate::discoverConditionalZero ( Varnode vn)

Verify that CBRANCH boolean expression is either (vn == 0) or (vn != 0)

Modify zeroPathIsTrue so that if it is true, then: A vn value equal to zero, causes execution to flow to where the output of MULTIEQUAL is set to zero.

Parameters
vnis the given Varnode
Returns
true if the boolean expression has a matching form

References ghidra::ConditionMarker::boolvn, ghidra::PcodeOp::code(), ghidra::CPUI_INT_EQUAL, ghidra::CPUI_INT_NOTEQUAL, ghidra::Varnode::getDef(), ghidra::PcodeOp::getIn(), ghidra::Varnode::getOffset(), ghidra::Varnode::isConstant(), and ghidra::Varnode::isWritten().

Referenced by ghidra::RuleOrPredicate::checkSingle().

◆ discoverPathIsTrue()

void ghidra::RuleOrPredicate::MultiPredicate::discoverPathIsTrue ( void  )

Does the condBlock true outgoing edge flow to the block that sets zero.

The zeroPathIsTrue variable is set based on the current configuration

Referenced by ghidra::RuleOrPredicate::applyOp(), and ghidra::RuleOrPredicate::checkSingle().

◆ discoverZeroSlot()

bool ghidra::RuleOrPredicate::MultiPredicate::discoverZeroSlot ( Varnode vn)

Check if vn is produced by a 2-branch MULTIEQUAL, one side of which is a zero constant.

Parameters
vnis the given Varnode
Returns
true if the expression producing vn matches the form

References ghidra::PcodeOp::code(), ghidra::CPUI_COPY, ghidra::CPUI_MULTIEQUAL, ghidra::Varnode::getDef(), ghidra::PcodeOp::getIn(), ghidra::Varnode::getOffset(), ghidra::Varnode::isConstant(), and ghidra::Varnode::isWritten().

Referenced by ghidra::RuleOrPredicate::applyOp().


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