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

Build p-code from a pre-parsed instruction. More...

#include <sleigh.hh>

Inheritance diagram for ghidra::SleighBuilder:

Public Member Functions

 SleighBuilder (ParserWalker *w, DisassemblyCache *dcache, PcodeCacher *pc, AddrSpace *cspc, AddrSpace *uspc, uint4 umask)
 Constructor. More...
 
virtual void appendBuild (OpTpl *bld, int4 secnum)
 
virtual void delaySlot (OpTpl *op)
 
virtual void setLabel (OpTpl *op)
 
virtual void appendCrossBuild (OpTpl *bld, int4 secnum)
 

Private Member Functions

virtual void dump (OpTpl *op)
 
void buildEmpty (Constructor *ct, int4 secnum)
 Build a named p-code section of a constructor that contains only implied BUILD directives. More...
 
void generateLocation (const VarnodeTpl *vntpl, VarnodeData &vn)
 Generate a concrete VarnodeData object from the given template (VarnodeTpl) More...
 
AddrSpacegeneratePointer (const VarnodeTpl *vntpl, VarnodeData &vn)
 Generate a pointer VarnodeData from a dynamic template (VarnodeTpl) More...
 
void generatePointerAdd (PcodeData *op, const VarnodeTpl *vntpl)
 
void setUniqueOffset (const Address &addr)
 Set uniquifying bits for the current instruction. More...
 

Private Attributes

AddrSpaceconst_space
 The constant address space.
 
AddrSpaceuniq_space
 The unique address space.
 
uintb uniquemask
 Mask of address bits to use to uniquify temporary registers.
 
uintb uniqueoffset
 Uniquifier bits for this instruction.
 
DisassemblyCachediscache
 Cache of disassembled instructions.
 
PcodeCachercache
 Cache accumulating p-code data for the instruction.
 

Detailed Description

Build p-code from a pre-parsed instruction.

Through the build() method, this walks the parse tree and prepares data for final emission as p-code. (The final emitting is done separately through the PcodeCacher.emit() method). Generally, only p-code for one instruction is prepared. But, through the delay-slot mechanism, build() may recursively visit additional instructions.

Constructor & Destructor Documentation

◆ SleighBuilder()

ghidra::SleighBuilder::SleighBuilder ( ParserWalker *  w,
DisassemblyCache dcache,
PcodeCacher pc,
AddrSpace cspc,
AddrSpace uspc,
uint4  umask 
)

Constructor.

Parameters
wis the parsed instruction
dcacheis a cache of nearby instruction parses
pcwill hold the PcodeData and VarnodeData objects produced by this builder
cspcis the constant address space
uspcis the unique address space
umaskis the mask to use to find unique bits within an Address

References ghidra::PcodeCacher::addLabel(), buildEmpty(), cache, const_space, discache, ghidra::DisassemblyCache::getParserContext(), setUniqueOffset(), uniq_space, uniquemask, uniqueoffset, and ghidra::AddrSpace::wrapOffset().

Member Function Documentation

◆ buildEmpty()

void ghidra::SleighBuilder::buildEmpty ( Constructor *  ct,
int4  secnum 
)
private

Build a named p-code section of a constructor that contains only implied BUILD directives.

If a named section of a constructor is empty, we still need to walk through any subtables that might contain p-code in their named sections. This method treats each subtable operand as an implied build directive, in the otherwise empty section.

Parameters
ctis the matching currently Constructor being built
secnumis the particular named section number to build

Referenced by SleighBuilder().

◆ generateLocation()

void ghidra::SleighBuilder::generateLocation ( const VarnodeTpl *  vntpl,
VarnodeData vn 
)
private

Generate a concrete VarnodeData object from the given template (VarnodeTpl)

Parameters
vntplis the template to reference
vnis the object to fill in with concrete values

References ghidra::calc_mask(), ghidra::VarnodeData::offset, ghidra::VarnodeData::size, ghidra::VarnodeData::space, and ghidra::AddrSpace::wrapOffset().

◆ generatePointer()

AddrSpace * ghidra::SleighBuilder::generatePointer ( const VarnodeTpl *  vntpl,
VarnodeData vn 
)
private

Generate a pointer VarnodeData from a dynamic template (VarnodeTpl)

The symbol represents a value referenced through a dynamic pointer. This method generates the varnode representing the pointer itself and also returns the address space in anticipation of generating the LOAD or STORE that actually manipulates the value.

Parameters
vntplis the dynamic template to reference
vnis the object to fill with concrete values
Returns
the address space being pointed to

References ghidra::calc_mask(), ghidra::CPUI_INT_ADD, ghidra::CPUI_LOAD, ghidra::CPUI_STORE, ghidra::PcodeData::invar, ghidra::PcodeData::isize, ghidra::VarnodeData::offset, ghidra::PcodeData::opc, ghidra::PcodeData::outvar, ghidra::Translate::RUNTIME_BITRANGE_EA, ghidra::VarnodeData::size, ghidra::VarnodeData::space, and ghidra::AddrSpace::wrapOffset().

◆ setUniqueOffset()

void ghidra::SleighBuilder::setUniqueOffset ( const Address addr)
private

Set uniquifying bits for the current instruction.

Bits used to make temporary registers unique across multiple instructions are generated based on the given address.

Parameters
addris the given Address

References ghidra::Address::getOffset().

Referenced by SleighBuilder().


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