|
decompiler 1.0.0
|
Class for lightweight matching of two additive expressions. More...
#include <expression.hh>
Classes | |
| class | Term |
| A term in the expression. More... | |
Public Member Functions | |
| AddExpression (void) | |
| Construct an empty expression. | |
| void | gatherTwoTermsSubtract (Varnode *a, Varnode *b) |
| Walk expression given two roots being subtracted from one another. | |
| void | gatherTwoTermsAdd (Varnode *a, Varnode *b) |
| Walk expression given two roots being added to each other. | |
| void | gatherTwoTermsRoot (Varnode *root) |
| Gather up to 2 terms given root Varnode. | |
| bool | isEquivalent (const AddExpression &op2) const |
| Determine if 2 expressions are equivalent. | |
Private Member Functions | |
| void | add (Varnode *vn, uintb coeff) |
| Add a term to the expression. | |
| void | gather (Varnode *vn, uintb coeff, int4 depth) |
| Gather terms in the expression from a root point. | |
Private Attributes | |
| uintb | constval |
| Collected constants in the expression. | |
| int4 | numTerms |
| Number of terms. | |
| Term | terms [2] |
| Terms making up the expression. | |
Class for lightweight matching of two additive expressions.
Collect (up to 2) terms along with any constants and coefficients.
|
private |
Gather terms in the expression from a root point.
Recursively collect terms, up to the given depth. INT_ADD either contributes to the constant sum, or it is recursively walked. Term coefficients are collected from INT_MULT with a constant.
| vn | is the root of the (sub)expression |
| coeff | is the current multiplicative coefficient of the subexpression |
| depth | is the current depth |
References add(), ghidra::calc_mask(), ghidra::PcodeOp::code(), constval, ghidra::CPUI_INT_ADD, ghidra::CPUI_INT_MULT, gather(), ghidra::Varnode::getDef(), ghidra::PcodeOp::getIn(), ghidra::Varnode::getOffset(), ghidra::Varnode::getSize(), ghidra::Varnode::isConstant(), and ghidra::Varnode::isWritten().
Referenced by gather(), gatherTwoTermsAdd(), gatherTwoTermsRoot(), and gatherTwoTermsSubtract().
Walk expression given two roots being added to each other.
Gather up to two non-constant additive terms, given two root Varnodes being added
| a | is the first root |
| b | is the second root being added to the first |
References gather(), and ghidra::Varnode::isConstant().
Referenced by ghidra::RuleScarry::applyOp().
| void ghidra::AddExpression::gatherTwoTermsRoot | ( | Varnode * | root | ) |
Gather up to 2 terms given root Varnode.
Gather up to two non-constant additive terms in the expression at the given root.
| root | is the root Varnode |
References gather().
Referenced by ghidra::RuleSborrow::applyOp(), and ghidra::RuleScarry::applyOp().
Walk expression given two roots being subtracted from one another.
Gather up to two non-constant additive terms, given two root Varnodes that are being subtracted.
| a | is the first root |
| b | is the second root being subtracted from the first |
References ghidra::calc_mask(), gather(), ghidra::Varnode::getSize(), and ghidra::Varnode::isConstant().
Referenced by ghidra::RuleSborrow::applyOp().
| bool ghidra::AddExpression::isEquivalent | ( | const AddExpression & | op2 | ) | const |
Determine if 2 expressions are equivalent.
The value true is returned if it can be proven that the expressions always produce the same value.
| op2 | is the other expression to compare with this |
References constval, isEquivalent(), ghidra::AddExpression::Term::isEquivalent(), numTerms, and terms.
Referenced by ghidra::RuleSborrow::applyOp(), ghidra::RuleScarry::applyOp(), and isEquivalent().