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

Parsing for the semantic section of Constructors. More...

#include <slgh_compile.hh>

Inheritance diagram for ghidra::SleighPcode:
ghidra::PcodeCompile

Public Member Functions

 SleighPcode (void)
 Constructor.
 
void setCompiler (SleighCompile *comp)
 Hook in the main parser.
 
- Public Member Functions inherited from ghidra::PcodeCompile
 PcodeCompile (void)
 Constructor.
 
virtual ~PcodeCompile (void)
 Destructor.
 
virtual const Location * getLocation (SleighSymbol *sym) const =0
 Get the parse location associated with the given symbol. More...
 
virtual void reportError (const Location *loc, const string &msg)=0
 Report a fatal error in parsing. More...
 
virtual void reportWarning (const Location *loc, const string &msg)=0
 Report a non-fatal issue encountered during parsing. More...
 
void resetLabelCount (void)
 Reset labels. The next label generated will have id 0.
 
void setDefaultSpace (AddrSpace *spc)
 Set the SLEIGH default address space.
 
void setConstantSpace (AddrSpace *spc)
 Set the SLEIGH constant address space.
 
void setUniqueSpace (AddrSpace *spc)
 Set the SLEIGH unique address space.
 
void setEnforceLocalKey (bool val)
 Toggle whether use of the 'local' key is enforced.
 
AddrSpace * getDefaultSpace (void) const
 Get the default address space.
 
AddrSpace * getConstantSpace (void) const
 Get the constant address space.
 
VarnodeTpl * buildTemporary (void)
 Create a temporary register (with 0 size) More...
 
LabelSymbol * defineLabel (string *name)
 Create a SLEIGH label symbol. More...
 
vector< OpTpl * > * placeLabel (LabelSymbol *sym)
 Create a raw expression containing the given label. More...
 
vector< OpTpl * > * newOutput (bool usesLocalKey, ExprTree *rhs, string *varname, uint4 size=0)
 Create a new output VarnodeTpl for an expression. More...
 
void newLocalDefinition (string *varname, uint4 size=0)
 Create a new temporary symbol (without generating any p-code) More...
 
ExprTree * createOp (OpCode opc, ExprTree *vn)
 Add a new unary operation to the given expression. More...
 
ExprTree * createOp (OpCode opc, ExprTree *vn1, ExprTree *vn2)
 Create a new binary operation combining the given expressions. More...
 
ExprTree * createOpOut (VarnodeTpl *outvn, OpCode opc, ExprTree *vn1, ExprTree *vn2)
 Create a new binary operation combining the given input expressions and an explicit output VarnodeTpl. More...
 
ExprTree * createOpOutUnary (VarnodeTpl *outvn, OpCode opc, ExprTree *vn)
 Create a new unary operation with the given expression as input and an explicit output VarnodeTpl. More...
 
vector< OpTpl * > * createOpNoOut (OpCode opc, ExprTree *vn)
 Create a new unary operation with the given expression as input and no output. More...
 
vector< OpTpl * > * createOpNoOut (OpCode opc, ExprTree *vn1, ExprTree *vn2)
 Create a new binary operation with the given expressions as input and no output. More...
 
vector< OpTpl * > * createOpConst (OpCode opc, uintb val)
 Create a new unary operation with the given constant as input and no output. More...
 
ExprTree * createLoad (StarQuality *qual, ExprTree *ptr)
 Create a new LOAD operation with the given pointer expression as input. More...
 
vector< OpTpl * > * createStore (StarQuality *qual, ExprTree *ptr, ExprTree *val)
 Create a new STORE operation with the given expressions as inputs. More...
 
ExprTree * createUserOp (UserOpSymbol *sym, vector< ExprTree * > *param)
 Create a CALLOTHER p-code op with temporary output, given a symbol and parameter expressions. More...
 
vector< OpTpl * > * createUserOpNoOut (UserOpSymbol *sym, vector< ExprTree * > *param)
 Create a CALLOTHER p-code op, given a symbol and parameter expressions. More...
 
ExprTree * createVariadic (OpCode opc, vector< ExprTree * > *param)
 Create a new operation with a variable number of inputs and a temporary output. More...
 
void appendOp (OpCode opc, ExprTree *res, uintb constval, int4 constsz)
 Append a binary operation to the given expression. More...
 
VarnodeTpl * buildTruncatedVarnode (VarnodeTpl *basevn, uint4 bitoffset, uint4 numbits)
 Build a truncated VarnodeTpl, if possible, from the given bit range. More...
 
vector< OpTpl * > * assignBitRange (VarnodeTpl *vn, uint4 bitoffset, uint4 numbits, ExprTree *rhs)
 Assign an expression to a bit range within a given VarnodeTpl. More...
 
ExprTree * createBitRange (SpecificSymbol *sym, uint4 bitoffset, uint4 numbits)
 Create an expression computing the indicated bit range of a symbol. More...
 
VarnodeTpl * addressOf (VarnodeTpl *var, uint4 size)
 Produce a constant VarnodeTpl that is the offset of the storage address of the given VarnodeTpl. More...
 

Private Member Functions

virtual uint4 allocateTemp (void)
 Get the offset for the next available temporary register. More...
 
virtual const Location * getLocation (SleighSymbol *sym) const
 Get the parse location associated with the given symbol. More...
 
virtual void reportError (const Location *loc, const string &msg)
 Report a fatal error in parsing. More...
 
virtual void reportWarning (const Location *loc, const string &msg)
 Report a non-fatal issue encountered during parsing. More...
 
virtual void addSymbol (SleighSymbol *sym)
 Add a new symbol to the current scope. More...
 

Private Attributes

SleighCompile * compiler
 The main SLEIGH parser.
 

Additional Inherited Members

- Static Public Member Functions inherited from ghidra::PcodeCompile
static void force_size (VarnodeTpl *vt, const ConstTpl &size, const vector< OpTpl * > &ops)
 Force a size on a specific VarnodeTpl if possible. More...
 
static void matchSize (int4 j, OpTpl *op, bool inputonly, const vector< OpTpl * > &ops)
 Try to propagate a known size across a p-code operation to zero size inputs and outputs. More...
 
static void fillinZero (OpTpl *op, const vector< OpTpl * > &ops)
 Try to deduce the size of all input and output VarnodeTpl for the given OpTpl. More...
 
static bool propagateSize (ConstructTpl *ct)
 Propagate a size to all VarnodeTpl whose size is unknown. More...
 

Detailed Description

Parsing for the semantic section of Constructors.

This is just the base p-code compiler for building OpTpl and VarnodeTpl. Symbols, locations, and error/warning messages are tied into to the main parser.

Member Function Documentation

◆ addSymbol()

void ghidra::SleighPcode::addSymbol ( SleighSymbol *  sym)
privatevirtual

Add a new symbol to the current scope.

Parameters
symis the symbol being added

Implements ghidra::PcodeCompile.

References ghidra::SleighCompile::addSymbol(), and ghidra::ConsistencyChecker::compiler.

◆ allocateTemp()

uint4 ghidra::SleighPcode::allocateTemp ( void  )
privatevirtual

Get the offset for the next available temporary register.

A fixed number of bytes in the unique space is consumed.

Returns
the reserved offset

Implements ghidra::PcodeCompile.

References ghidra::ConsistencyChecker::compiler, and ghidra::SleighCompile::getUniqueAddr().

◆ getLocation()

const Location * ghidra::SleighPcode::getLocation ( SleighSymbol *  sym) const
privatevirtual

Get the parse location associated with the given symbol.

This is generally where the symbol is first defined.

Parameters
symis the given symbol
Returns
the location if known, or NULL otherwise

Implements ghidra::PcodeCompile.

References ghidra::ConsistencyChecker::compiler, and ghidra::SleighCompile::getLocation().

◆ reportError()

void ghidra::SleighPcode::reportError ( const Location *  loc,
const string &  msg 
)
privatevirtual

Report a fatal error in parsing.

Parsing may continue, but a final output is not produced.

Parameters
locis the location of the error
msgis a description of the error

Implements ghidra::PcodeCompile.

References ghidra::ConsistencyChecker::compiler, and ghidra::SleighCompile::reportError().

◆ reportWarning()

void ghidra::SleighPcode::reportWarning ( const Location *  loc,
const string &  msg 
)
privatevirtual

Report a non-fatal issue encountered during parsing.

Parameters
locis the location of the issue
msgis a description of the issue

Implements ghidra::PcodeCompile.

References ghidra::ConsistencyChecker::compiler, and ghidra::SleighCompile::reportWarning().


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