mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 02:09:44 +02:00
added RuleOrConsume
This commit is contained in:
parent
992d32dd87
commit
40d840085f
3 changed files with 40 additions and 0 deletions
|
@ -390,6 +390,35 @@ int4 RuleAndMask::applyOp(PcodeOp *op,Funcdata &data)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/// \class RuleOrConsume
|
||||
/// \brief Simply OR with unconsumed input: `V = A | B => V = B if nzm(A) & consume(V) == 0
|
||||
void RuleOrConsume::getOpList(vector<uint4> &oplist) const
|
||||
|
||||
{
|
||||
oplist.push_back(CPUI_INT_OR);
|
||||
oplist.push_back(CPUI_INT_XOR);
|
||||
}
|
||||
|
||||
int4 RuleOrConsume::applyOp(PcodeOp *op,Funcdata &data)
|
||||
|
||||
{
|
||||
Varnode *outvn = op->getOut();
|
||||
int4 size = outvn->getSize();
|
||||
if (size > sizeof(uintb)) return 0; // FIXME: uintb should be arbitrary precision
|
||||
uintb consume = outvn->getConsume();
|
||||
if ((consume & op->getIn(0)->getNZMask()) == 0) {
|
||||
data.opRemoveInput(op,0);
|
||||
data.opSetOpcode(op, CPUI_COPY);
|
||||
return 1;
|
||||
}
|
||||
else if ((consume & op->getIn(1)->getNZMask()) == 0) {
|
||||
data.opRemoveInput(op,1);
|
||||
data.opSetOpcode(op, CPUI_COPY);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// \class RuleOrCollapse
|
||||
/// \brief Collapse unnecessary INT_OR
|
||||
///
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue