|
Ghidra 11.4.2
Ghidra internal decompiler documentation.
|
Remove certain NaN operations by assuming their result is always false. More...
Public Member Functions | |
| RuleIgnoreNan (const string &g) | |
| Constructor. | |
| virtual Rule * | clone (const ActionGroupList &grouplist) const |
| Clone the Rule. | |
| virtual void | getOpList (vector< uint4 > &oplist) const |
| List of op codes this rule operates on. | |
| virtual int4 | applyOp (PcodeOp *op, Funcdata &data) |
| Attempt to apply this Rule. | |
Public Member Functions inherited from ghidra::Rule | |
| Rule (const string &g, uint4 fl, const string &nm) | |
| Construct given group, properties name. | |
| virtual | ~Rule (void) |
| Destructor. | |
| const string & | getName (void) const |
| Return the name of this Rule. | |
| const string & | getGroup (void) const |
| Return the group this Rule belongs to. | |
| uint4 | getNumTests (void) |
| Get number of attempted applications. | |
| uint4 | getNumApply (void) |
| Get number of successful applications. | |
| void | setBreak (uint4 tp) |
| Set a breakpoint on this Rule. | |
| void | clearBreak (uint4 tp) |
| Clear a breakpoint on this Rule. | |
| void | clearBreakPoints (void) |
| Clear all breakpoints on this Rule. | |
| void | turnOnWarnings (void) |
| Enable warnings for this Rule. | |
| void | turnOffWarnings (void) |
| Disable warnings for this Rule. | |
| bool | isDisabled (void) const |
| Return true if this Rule is disabled. | |
| void | setDisable (void) |
| Disable this Rule (within its pool) | |
| void | clearDisable (void) |
| Enable this Rule (within its pool) | |
| bool | checkActionBreak (void) |
| Check if an action breakpoint is turned on. | |
| uint4 | getBreakPoint (void) const |
| Return breakpoint toggles. | |
| virtual void | reset (Funcdata &data) |
| Reset this Rule. | |
| virtual void | resetStats (void) |
| Reset Rule statistics. | |
| virtual void | printStatistics (ostream &s) const |
| Print statistics for this Rule. | |
Static Private Member Functions | |
| static bool | checkBackForCompare (Varnode *floatVar, Varnode *root) |
| Check if a boolean Varnode incorporates a floating-point comparison with the given value. | |
| static bool | isAnotherNan (Varnode *vn) |
| Test if the given Varnode is produced by a NaN operation. | |
| static Varnode * | testForComparison (Varnode *floatVar, PcodeOp *op, int4 slot, OpCode matchCode, int4 &count, Funcdata &data) |
| Test if a boolean expression incorporates a floating-point comparison, and remove the NaN data-flow if it does. | |
Additional Inherited Members | |
Public Types inherited from ghidra::Rule | |
| enum | typeflags { type_disable = 1 , rule_debug = 2 , warnings_on = 4 , warnings_given = 8 } |
| Properties associated with a Rule. More... | |
Remove certain NaN operations by assuming their result is always false.
This rule can be configured to remove either all FLOAT_NAN operations or only those that protect floating-point comparisons.
Attempt to apply this Rule.
This method contains the main logic for applying the Rule. It must use a given PcodeOp as the point at which the Rule applies. If it does apply, changes are made directly to the function and 1 (non-zero) is returned, otherwise 0 is returned.
Reimplemented from ghidra::Rule.
References ghidra::Varnode::beginDescend(), ghidra::PcodeOp::code(), ghidra::CPUI_BOOL_AND, ghidra::CPUI_BOOL_NEGATE, ghidra::CPUI_BOOL_OR, ghidra::CPUI_COPY, ghidra::Varnode::endDescend(), ghidra::Funcdata::getArch(), ghidra::PcodeOp::getIn(), ghidra::PcodeOp::getOut(), ghidra::PcodeOp::getSlot(), ghidra::Varnode::isFree(), ghidra::Architecture::nan_ignore_all, ghidra::Funcdata::newConstant(), ghidra::Funcdata::opSetInput(), ghidra::Funcdata::opSetOpcode(), and testForComparison().
|
staticprivate |
Check if a boolean Varnode incorporates a floating-point comparison with the given value.
The Varnode can either be the direct output of a comparison, or it can be a BOOL_OR or BOOL_AND, combining output from the comparison.
| floatVar | is the given value the comparison must take as input |
| root | is the boolean Varnode |
References ghidra::PcodeOp::code(), ghidra::CPUI_BOOL_AND, ghidra::CPUI_BOOL_NEGATE, ghidra::CPUI_BOOL_OR, ghidra::Varnode::getDef(), ghidra::PcodeOp::getIn(), ghidra::PcodeOp::getOpcode(), ghidra::PcodeOp::isBoolOutput(), ghidra::TypeOp::isFloatingPointOp(), ghidra::Varnode::isWritten(), and ghidra::PcodeOp::numInput().
Referenced by testForComparison().
|
inlinevirtual |
Clone the Rule.
If this Rule is a member of one of the groups in the grouplist, this returns a clone of the Rule, otherwise NULL is returned.
| grouplist | is the list of groups being cloned |
Implements ghidra::Rule.
References ghidra::ActionGroupList::contains(), and ghidra::Rule::getGroup().
|
virtual |
List of op codes this rule operates on.
Populate the given array with all possible OpCodes this Rule might apply to. By default, this method returns all possible OpCodes
| oplist | is the array to populate |
Reimplemented from ghidra::Rule.
References ghidra::CPUI_FLOAT_NAN.
|
staticprivate |
Test if the given Varnode is produced by a NaN operation.
The Varnode can be the direct or negated output of a NaN.
| vn | is the given Varnode |
References ghidra::PcodeOp::code(), ghidra::CPUI_BOOL_NEGATE, ghidra::CPUI_FLOAT_NAN, ghidra::Varnode::getDef(), ghidra::PcodeOp::getIn(), and ghidra::Varnode::isWritten().
Referenced by testForComparison().
|
staticprivate |
Test if a boolean expression incorporates a floating-point comparison, and remove the NaN data-flow if it does.
The given PcodeOp takes input from a NaN operation through a specific slot. We look for a floating-point comparison PcodeOp (FLOAT_LESS, FLOAT_LESSEQUAL, FLOAT_EQUAL, or FLOAT_NOTEQUAL) that is combined with the given PcodeOp and has the same input Varnode as the NaN. The data-flow must be combined either through a BOOL_OR, BOOL_AND, INT_EQUAL, or INT_NOTEQUAL operation, or the given PcodeOp must be a CBRANCH that protects immediate control-flow to another CBRANCH taking the result of the comparison as input. If a matching comparison is found, the NaN input to the given PcodeOp is removed, assuming the output of the NaN operation is always false. If a NaN result is combined through a BOOL_OR, it must be unmodified, but a NaN result combined through a BOOL_AND must be negated.
| floatVar | is the input Varnode to NaN operation |
| op | is the given PcodeOp to test |
| slot | is the input index of the NaN operation |
| matchCode | is BOOL_AND if the NaN result has been negated, BOOL_OR if not |
| count | is incremented if a comparison is found and the NaN input is removed |
| data | is the function |
References checkBackForCompare(), ghidra::PcodeOp::code(), ghidra::CPUI_BOOL_OR, ghidra::CPUI_CBRANCH, ghidra::CPUI_COPY, ghidra::CPUI_INT_EQUAL, ghidra::CPUI_INT_NOTEQUAL, ghidra::PcodeOp::getIn(), ghidra::FlowBlock::getOut(), ghidra::PcodeOp::getOut(), ghidra::PcodeOp::getParent(), isAnotherNan(), ghidra::PcodeOp::isBooleanFlip(), ghidra::FlowBlock::lastOp(), ghidra::Funcdata::newConstant(), ghidra::Funcdata::opRemoveInput(), ghidra::Funcdata::opSetInput(), and ghidra::Funcdata::opSetOpcode().
Referenced by applyOp().