decompiler  1.0.0
Public Member Functions | Private Member Functions | List of all members
ghidra::ActionLaneDivide Class Reference

Find Varnodes with a vectorized lane scheme and attempt to split the lanes. More...

#include <coreaction.hh>

Inheritance diagram for ghidra::ActionLaneDivide:
ghidra::Action

Public Member Functions

 ActionLaneDivide (const string &g)
 Constructor.
 
virtual Actionclone (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 ghidra::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 ActiongetSubAction (const string &specify)
 Retrieve a specific sub-action by name. More...
 
virtual RulegetSubRule (const string &specify)
 Retrieve a specific sub-rule by name. More...
 

Private Member Functions

void collectLaneSizes (Varnode *vn, const LanedRegister &allowedLanes, LanedRegister &checkLanes)
 Examine the PcodeOps using the given Varnode to determine possible lane sizes. More...
 
bool processVarnode (Funcdata &data, Varnode *vn, const LanedRegister &lanedRegister, int4 mode)
 Search for a likely lane size and try to divide a single Varnode into these lanes. More...
 

Additional Inherited Members

- Public Types inherited from ghidra::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 ghidra::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 ghidra::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.
 

Detailed Description

Find Varnodes with a vectorized lane scheme and attempt to split the lanes.

The Architecture lists (vector) registers that may be used to perform parallelized operations on lanes within the register. This action looks for these registers as Varnodes, determines if a particular lane scheme makes sense in terms of the function's data-flow, and then rewrites the data-flow so that the lanes become explicit Varnodes.

Member Function Documentation

◆ apply()

int4 ghidra::ActionLaneDivide::apply ( Funcdata data)
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.

Parameters
datais the function to inspect/modify
Returns
0 for a complete application, -1 for a partial completion (due to breakpoint)

Implements ghidra::Action.

References ghidra::Funcdata::beginLaneAccess(), ghidra::Funcdata::beginLoc(), ghidra::Funcdata::clearLanedAccessMap(), ghidra::Funcdata::endLaneAccess(), ghidra::Funcdata::endLoc(), and ghidra::Funcdata::setLanedRegGenerated().

◆ clone()

virtual Action* ghidra::ActionLaneDivide::clone ( const ActionGroupList grouplist) const
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.

Parameters
grouplistis the list of groups being cloned
Returns
the cloned Action or NULL

Implements ghidra::Action.

References ghidra::ActionStart::apply(), ghidra::ActionGroupList::contains(), and ghidra::Action::getGroup().

◆ collectLaneSizes()

void ghidra::ActionLaneDivide::collectLaneSizes ( Varnode vn,
const LanedRegister allowedLanes,
LanedRegister checkLanes 
)
private

Examine the PcodeOps using the given Varnode to determine possible lane sizes.

Run through the defining op and any descendant ops of the given Varnode, looking for CPUI_PIECE and CPUI_SUBPIECE. Use these to determine possible lane sizes and register them with the given LanedRegister object.

Parameters
vnis the given Varnode
allowedLanesis used to determine if a putative lane size is allowed
checkLanescollects the possible lane sizes

References ghidra::LanedRegister::addLaneSize(), ghidra::LanedRegister::allowedLane(), ghidra::Varnode::beginDescend(), ghidra::PcodeOp::code(), ghidra::CPUI_PIECE, ghidra::CPUI_SUBPIECE, ghidra::Varnode::endDescend(), ghidra::Varnode::getDef(), ghidra::PcodeOp::getIn(), ghidra::PcodeOp::getOut(), ghidra::Varnode::getSize(), and ghidra::Varnode::isWritten().

◆ processVarnode()

bool ghidra::ActionLaneDivide::processVarnode ( Funcdata data,
Varnode vn,
const LanedRegister lanedRegister,
int4  mode 
)
private

Search for a likely lane size and try to divide a single Varnode into these lanes.

There are different ways to search for a lane size:

Mode 0: Collect putative lane sizes based on the local ops using the Varnode. Attempt to divide based on each of those lane sizes in turn.

Mode 1: Similar to mode 0, except we allow for SUBPIECE operations that truncate to variables that are smaller than the lane size.

Mode 2: Attempt to divide based on a default lane size.

Parameters
datais the function being transformed
vnis the given single Varnode
lanedRegisteris acceptable set of lane sizes for the Varnode
modeis the lane size search mode (0, 1, or 2)
Returns
true if the Varnode (and its data-flow) was successfully split

References ghidra::LanedRegister::addLaneSize(), ghidra::LanedRegister::begin(), ghidra::LanedRegister::end(), and ghidra::LanedRegister::getWholeSize().


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