decompiler
1.0.0
|
Perform Common Sub-expression Elimination on CPUI_MULTIEQUAL ops. More...
#include <coreaction.hh>
Public Member Functions | |
ActionMultiCse (const string &g) | |
Constructor. | |
virtual Action * | clone (const ActionGroupList &grouplist) const |
Clone the Action. More... | |
virtual int4 | apply (Funcdata &data) |
Make a single attempt to apply this Action. More... | |
Public Member Functions inherited from Action | |
Action (uint4 f, const string &nm, const string &g) | |
Base constructor for an Action. More... | |
virtual | ~Action (void) |
Destructor. | |
virtual void | printStatistics (ostream &s) const |
Dump statistics to stream. More... | |
int4 | perform (Funcdata &data) |
Perform this action (if necessary) More... | |
bool | setBreakPoint (uint4 tp, const string &specify) |
Set a breakpoint on this action. More... | |
virtual void | clearBreakPoints (void) |
Clear all breakpoints set on this Action. | |
bool | setWarning (bool val, const string &specify) |
Set a warning on this action. More... | |
bool | disableRule (const string &specify) |
Disable a specific Rule within this. More... | |
bool | enableRule (const string &specify) |
Enable a specific Rule within this. More... | |
const string & | getName (void) const |
Get the Action's name. | |
const string & | getGroup (void) const |
Get the Action's group. | |
uint4 | getStatus (void) const |
Get the current status of this Action. | |
uint4 | getNumTests (void) |
Get the number of times apply() was invoked. | |
uint4 | getNumApply (void) |
virtual void | reset (Funcdata &data) |
Reset the Action for a new function. More... | |
virtual void | resetStats (void) |
Reset all the counts to zero. More... | |
virtual int4 | print (ostream &s, int4 num, int4 depth) const |
Print a description of this Action to stream. More... | |
virtual void | printState (ostream &s) const |
Print status to stream. More... | |
virtual void | saveXml (ostream &s) const |
Save specifics of this action to stream. | |
virtual void | restoreXml (const Element *el, Funcdata *fd) |
Load specifics of action from XML. | |
virtual Action * | getSubAction (const string &specify) |
Retrieve a specific sub-action by name. More... | |
virtual Rule * | getSubRule (const string &specify) |
Retrieve a specific sub-rule by name. More... | |
Private Member Functions | |
bool | processBlock (Funcdata &data, BlockBasic *bl) |
Search a block for equivalent CPUI_MULTIEQUAL. More... | |
Static Private Member Functions | |
static bool | preferredOutput (Varnode *out1, Varnode *out2) |
Which of two outputs is preferred. More... | |
static PcodeOp * | findMatch (BlockBasic *bl, PcodeOp *target, Varnode *in) |
Find match to CPUI_MULTIEQUAL. More... | |
Additional Inherited Members | |
Public Types inherited from Action | |
enum | ruleflags { rule_repeatapply = 4, rule_onceperfunc = 8, rule_oneactperfunc = 16, rule_debug = 32, rule_warnings_on = 64, rule_warnings_given = 128 } |
Boolean behavior properties governing this particular Action. More... | |
enum | statusflags { status_start =1, status_breakstarthit =2, status_repeat =4, status_mid =8, status_end =16, status_actionbreak =32 } |
Boolean properties describing the status of an action. More... | |
enum | breakflags { break_start = 1, tmpbreak_start = 2, break_action = 4, tmpbreak_action = 8 } |
Break points associated with an Action. More... | |
Protected Member Functions inherited from Action | |
void | issueWarning (Architecture *glb) |
Warn that this Action has applied. More... | |
bool | checkStartBreak (void) |
Check start breakpoint. More... | |
bool | checkActionBreak (void) |
Check action breakpoint. More... | |
void | turnOnWarnings (void) |
Enable warnings for this Action. | |
void | turnOffWarnings (void) |
Disable warnings for this Action. | |
Protected Attributes inherited from Action | |
int4 | lcount |
Changes not including last call to apply() | |
int4 | count |
Number of changes made by this action so far. | |
uint4 | status |
Current status. | |
uint4 | breakpoint |
Breakpoint properties. | |
uint4 | flags |
Behavior properties. | |
uint4 | count_tests |
Number of times apply() has been called. | |
uint4 | count_apply |
Number of times apply() made changes. | |
string | name |
Name of the action. | |
string | basegroup |
Base group this action belongs to. | |
Perform Common Sub-expression Elimination on CPUI_MULTIEQUAL ops.
|
virtual |
Make a single attempt to apply this Action.
This is the main entry point for applying changes to a function that are specific to this Action. The method can inspect whatever it wants to decide if the Action does or does not apply. Changes are indicated by incrementing the count field.
data | is the function to inspect/modify |
Implements Action.
References Funcdata::getBasicBlocks(), and BlockGraph::getSize().
|
inlinevirtual |
Clone the Action.
If this Action is a member of one of the groups in the grouplist, this returns a clone of the Action, otherwise NULL is returned.
grouplist | is the list of groups being cloned |
Implements Action.
References ActionStart::apply(), ActionGroupList::contains(), and Action::getGroup().
|
staticprivate |
Find match to CPUI_MULTIEQUAL.
Find any matching CPUI_MULTIEQUAL that occurs before target that has in as an input. Then test to see if the target and the recovered op are functionally equivalent.
bl | is the parent block |
target | is the given target CPUI_MULTIEQUAL |
in | is the specific input Varnode |
References BlockBasic::beginOp(), PcodeOp::code(), CPUI_COPY, functionalEqualityLevel(), Varnode::getDef(), PcodeOp::getIn(), Varnode::isWritten(), and PcodeOp::numInput().
Which of two outputs is preferred.
We are substituting either -out1- for -out2- OR -out2- for -out1- Return true if we prefer substituting -out2- for -out1-
out1 | is one output |
out2 | is the other output |
References Varnode::beginDescend(), PcodeOp::code(), CPUI_RETURN, Varnode::endDescend(), Varnode::getSpace(), AddrSpace::getType(), IPTR_INTERNAL, and Varnode::isAddrTied().
|
private |
Search a block for equivalent CPUI_MULTIEQUAL.
Search for pairs of CPUI_MULTIEQUAL ops in bl that share an input. If the pairs found are functionally equivalent, delete one of the two.
data | is the function owning the block |
bl | is the specific basic block return true if a CPUI_MULTIEQUAL was (successfully) deleted |
References BlockBasic::beginOp(), PcodeOp::code(), CPUI_COPY, CPUI_MULTIEQUAL, BlockBasic::endOp(), Varnode::getDef(), PcodeOp::getIn(), PcodeOp::getOut(), Varnode::isMark(), Varnode::isWritten(), PcodeOp::numInput(), Funcdata::opDestroy(), and Funcdata::totalReplace().