retdec
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
retdec::bin2llvmir::Abi Class Referenceabstract

#include <abi.h>

Inheritance diagram for retdec::bin2llvmir::Abi:
Inheritance graph
[legend]
Collaboration diagram for retdec::bin2llvmir::Abi:
Collaboration graph
[legend]

Public Member Functions

 Abi (llvm::Module *m, Config *c)
 
virtual ~Abi ()=default
 
bool isRegister (const llvm::Value *val) const
 
bool isRegister (const llvm::Value *val, uint32_t r) const
 
bool isFlagRegister (const llvm::Value *val)
 
bool isStackPointerRegister (const llvm::Value *val) const
 
bool isZeroRegister (const llvm::Value *val)
 
virtual bool isGeneralPurposeRegister (const llvm::Value *val) const =0
 
llvm::GlobalVariable * getRegister (uint32_t r, bool use=true) const
 
uint32_t getRegisterId (const llvm::Value *r) const
 
const std::vector< llvm::GlobalVariable * > & getRegisters () const
 
llvm::GlobalVariable * getStackPointerRegister () const
 
llvm::GlobalVariable * getZeroRegister () const
 
std::size_t getRegisterByteSize (uint32_t r) const
 
void addRegister (uint32_t id, llvm::GlobalVariable *reg)
 
llvm::GlobalVariable * getSyscallIdRegister ()
 
llvm::GlobalVariable * getSyscallReturnRegister ()
 
llvm::GlobalVariable * getSyscallArgumentRegister (unsigned n)
 
bool isStackVariable (const llvm::Value *val) const
 
bool isNopInstruction (AsmInstruction ai)
 
virtual bool isNopInstruction (cs_insn *insn)=0
 
virtual std::size_t getTypeByteSize (llvm::Type *t) const
 
virtual std::size_t getTypeBitSize (llvm::Type *t) const
 
llvm::IntegerType * getDefaultType () const
 
llvm::PointerType * getDefaultPointerType () const
 
std::size_t getWordSize () const
 
bool isMips () const
 
bool isMips64 () const
 
bool isArm () const
 
bool isArm64 () const
 
bool isX86 () const
 
bool isX64 () const
 
bool isPowerPC () const
 
bool isPowerPC64 () const
 
bool isPic32 () const
 
bool supportsCallingConvention (const CallingConvention::ID &cc)
 
CallingConventiongetCallingConvention (const CallingConvention::ID &cc)
 
CallingConventiongetDefaultCallingConvention ()
 
CallingConvention::ID getDefaultCallingConventionID () const
 
ConfiggetConfig () const
 

Static Public Member Functions

static std::size_t getTypeByteSize (llvm::Module *m, llvm::Type *t)
 
static std::size_t getTypeBitSize (llvm::Module *m, llvm::Type *t)
 
static llvm::IntegerType * getDefaultType (llvm::Module *m)
 
static llvm::Type * getDefaultFPType (llvm::Module *m)
 
static llvm::PointerType * getDefaultPointerType (llvm::Module *m)
 
static std::size_t getWordSize (llvm::Module *m)
 

Static Public Attributes

static const uint32_t REG_INVALID = 0
 
static const unsigned DEFAULT_ADDR_SPACE = 0
 

Protected Attributes

llvm::Module * _module = nullptr
 
Config_config = nullptr
 
std::vector< llvm::GlobalVariable * > _regs
 
std::vector< llvm::GlobalVariable * > _id2regs
 Fast "capstone id -> LLVM value" search. More...
 
std::map< const llvm::Value *, uint32_t > _regs2id
 
uint32_t _regStackPointerId = REG_INVALID
 ID of stack pointer register. More...
 
uint32_t _regFunctionReturnId = REG_INVALID
 ID of register where function return values are stored. More...
 
std::vector< uint32_t > _syscallRegs
 Ordered list of registers used in system calls. More...
 
uint32_t _regSyscallReturn = REG_INVALID
 Register used for returning values from system calls. More...
 
uint32_t _regSyscallId = REG_INVALID
 Register used to pass system call ID. More...
 
uint32_t _regZeroReg = REG_INVALID
 Register that is always equal to zero - not every arch have this. More...
 
std::map< CallingConvention::ID, CallingConvention::Ptr_id2cc
 
CallingConvention::ID _defcc
 

Constructor & Destructor Documentation

◆ Abi()

retdec::bin2llvmir::Abi::Abi ( llvm::Module *  m,
Config c 
)

◆ ~Abi()

virtual retdec::bin2llvmir::Abi::~Abi ( )
virtualdefault

Member Function Documentation

◆ addRegister()

void retdec::bin2llvmir::Abi::addRegister ( uint32_t  id,
llvm::GlobalVariable *  reg 
)

◆ getCallingConvention()

CallingConvention * retdec::bin2llvmir::Abi::getCallingConvention ( const CallingConvention::ID cc)

◆ getConfig()

Config * retdec::bin2llvmir::Abi::getConfig ( ) const

◆ getDefaultCallingConvention()

CallingConvention * retdec::bin2llvmir::Abi::getDefaultCallingConvention ( )

◆ getDefaultCallingConventionID()

CallingConvention::ID retdec::bin2llvmir::Abi::getDefaultCallingConventionID ( ) const

◆ getDefaultFPType()

llvm::Type * retdec::bin2llvmir::Abi::getDefaultFPType ( llvm::Module *  m)
static

◆ getDefaultPointerType() [1/2]

llvm::PointerType * retdec::bin2llvmir::Abi::getDefaultPointerType ( ) const

◆ getDefaultPointerType() [2/2]

llvm::PointerType * retdec::bin2llvmir::Abi::getDefaultPointerType ( llvm::Module *  m)
static

◆ getDefaultType() [1/2]

llvm::IntegerType * retdec::bin2llvmir::Abi::getDefaultType ( ) const

◆ getDefaultType() [2/2]

llvm::IntegerType * retdec::bin2llvmir::Abi::getDefaultType ( llvm::Module *  m)
static

◆ getRegister()

llvm::GlobalVariable * retdec::bin2llvmir::Abi::getRegister ( uint32_t  r,
bool  use = true 
) const
Parameters
rRegister ID to get. Warning! We are using Capstone register IDs which overlaps. E.g. MIPS_REG_0 has the same ID as X86_REG_AL.
useShould the register be really got. This solves the problem with overlapping IDs when used like this: Abi::getRegister(MIPS_REG_GP, Abi::isMips())

◆ getRegisterByteSize()

std::size_t retdec::bin2llvmir::Abi::getRegisterByteSize ( uint32_t  r) const

◆ getRegisterId()

uint32_t retdec::bin2llvmir::Abi::getRegisterId ( const llvm::Value *  r) const

◆ getRegisters()

const std::vector< llvm::GlobalVariable * > & retdec::bin2llvmir::Abi::getRegisters ( ) const

◆ getStackPointerRegister()

llvm::GlobalVariable * retdec::bin2llvmir::Abi::getStackPointerRegister ( ) const

◆ getSyscallArgumentRegister()

llvm::GlobalVariable * retdec::bin2llvmir::Abi::getSyscallArgumentRegister ( unsigned  n)

◆ getSyscallIdRegister()

llvm::GlobalVariable * retdec::bin2llvmir::Abi::getSyscallIdRegister ( )

◆ getSyscallReturnRegister()

llvm::GlobalVariable * retdec::bin2llvmir::Abi::getSyscallReturnRegister ( )

◆ getTypeBitSize() [1/2]

std::size_t retdec::bin2llvmir::Abi::getTypeBitSize ( llvm::Module *  m,
llvm::Type *  t 
)
static

◆ getTypeBitSize() [2/2]

std::size_t retdec::bin2llvmir::Abi::getTypeBitSize ( llvm::Type *  t) const
virtual

Reimplemented in retdec::bin2llvmir::AbiPic32.

◆ getTypeByteSize() [1/2]

std::size_t retdec::bin2llvmir::Abi::getTypeByteSize ( llvm::Module *  m,
llvm::Type *  t 
)
static

◆ getTypeByteSize() [2/2]

std::size_t retdec::bin2llvmir::Abi::getTypeByteSize ( llvm::Type *  t) const
virtual

Reimplemented in retdec::bin2llvmir::AbiPic32.

◆ getWordSize() [1/2]

std::size_t retdec::bin2llvmir::Abi::getWordSize ( ) const

◆ getWordSize() [2/2]

std::size_t retdec::bin2llvmir::Abi::getWordSize ( llvm::Module *  m)
static

◆ getZeroRegister()

llvm::GlobalVariable * retdec::bin2llvmir::Abi::getZeroRegister ( ) const

◆ isArm()

bool retdec::bin2llvmir::Abi::isArm ( ) const

◆ isArm64()

bool retdec::bin2llvmir::Abi::isArm64 ( ) const

◆ isFlagRegister()

bool retdec::bin2llvmir::Abi::isFlagRegister ( const llvm::Value *  val)

◆ isGeneralPurposeRegister()

virtual bool retdec::bin2llvmir::Abi::isGeneralPurposeRegister ( const llvm::Value *  val) const
pure virtual

◆ isMips()

bool retdec::bin2llvmir::Abi::isMips ( ) const

◆ isMips64()

bool retdec::bin2llvmir::Abi::isMips64 ( ) const

◆ isNopInstruction() [1/2]

bool retdec::bin2llvmir::Abi::isNopInstruction ( AsmInstruction  ai)

◆ isNopInstruction() [2/2]

virtual bool retdec::bin2llvmir::Abi::isNopInstruction ( cs_insn *  insn)
pure virtual

◆ isPic32()

bool retdec::bin2llvmir::Abi::isPic32 ( ) const

◆ isPowerPC()

bool retdec::bin2llvmir::Abi::isPowerPC ( ) const

◆ isPowerPC64()

bool retdec::bin2llvmir::Abi::isPowerPC64 ( ) const

◆ isRegister() [1/2]

bool retdec::bin2llvmir::Abi::isRegister ( const llvm::Value *  val) const

◆ isRegister() [2/2]

bool retdec::bin2llvmir::Abi::isRegister ( const llvm::Value *  val,
uint32_t  r 
) const

◆ isStackPointerRegister()

bool retdec::bin2llvmir::Abi::isStackPointerRegister ( const llvm::Value *  val) const

◆ isStackVariable()

bool retdec::bin2llvmir::Abi::isStackVariable ( const llvm::Value *  val) const

◆ isX64()

bool retdec::bin2llvmir::Abi::isX64 ( ) const

◆ isX86()

bool retdec::bin2llvmir::Abi::isX86 ( ) const

◆ isZeroRegister()

bool retdec::bin2llvmir::Abi::isZeroRegister ( const llvm::Value *  val)

◆ supportsCallingConvention()

bool retdec::bin2llvmir::Abi::supportsCallingConvention ( const CallingConvention::ID cc)

Member Data Documentation

◆ _config

Config* retdec::bin2llvmir::Abi::_config = nullptr
protected

◆ _defcc

CallingConvention::ID retdec::bin2llvmir::Abi::_defcc
protected

◆ _id2cc

std::map<CallingConvention::ID, CallingConvention::Ptr> retdec::bin2llvmir::Abi::_id2cc
protected

◆ _id2regs

std::vector<llvm::GlobalVariable*> retdec::bin2llvmir::Abi::_id2regs
protected

Fast "capstone id -> LLVM value" search.

◆ _module

llvm::Module* retdec::bin2llvmir::Abi::_module = nullptr
protected

◆ _regFunctionReturnId

uint32_t retdec::bin2llvmir::Abi::_regFunctionReturnId = REG_INVALID
protected

ID of register where function return values are stored.

◆ _regs

std::vector<llvm::GlobalVariable*> retdec::bin2llvmir::Abi::_regs
protected

Fast iteration over all registers. id2regs may contain nullptr values.

◆ _regs2id

std::map<const llvm::Value*, uint32_t> retdec::bin2llvmir::Abi::_regs2id
protected

Fast "is LLVM value a register?" check. Fast "LLVM value -> capstone id" search.

◆ _regStackPointerId

uint32_t retdec::bin2llvmir::Abi::_regStackPointerId = REG_INVALID
protected

ID of stack pointer register.

◆ _regSyscallId

uint32_t retdec::bin2llvmir::Abi::_regSyscallId = REG_INVALID
protected

Register used to pass system call ID.

◆ _regSyscallReturn

uint32_t retdec::bin2llvmir::Abi::_regSyscallReturn = REG_INVALID
protected

Register used for returning values from system calls.

◆ _regZeroReg

uint32_t retdec::bin2llvmir::Abi::_regZeroReg = REG_INVALID
protected

Register that is always equal to zero - not every arch have this.

◆ _syscallRegs

std::vector<uint32_t> retdec::bin2llvmir::Abi::_syscallRegs
protected

Ordered list of registers used in system calls.

◆ DEFAULT_ADDR_SPACE

const unsigned retdec::bin2llvmir::Abi::DEFAULT_ADDR_SPACE = 0
static

◆ REG_INVALID

const uint32_t retdec::bin2llvmir::Abi::REG_INVALID = 0
static

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