retdec
|
#include <asm_instruction.h>
Classes | |
class | iterator_impl |
Public Types | |
using | iterator = iterator_impl< std::bidirectional_iterator_tag, llvm::Instruction > |
using | const_iterator = iterator_impl< std::bidirectional_iterator_tag, const llvm::Instruction > |
using | reverse_iterator = std::reverse_iterator< iterator > |
using | const_reverse_iterator = std::reverse_iterator< const_iterator > |
Public Member Functions | |
AsmInstruction () | |
AsmInstruction (llvm::Instruction *inst) | |
AsmInstruction (llvm::BasicBlock *bb) | |
AsmInstruction (llvm::Function *f) | |
AsmInstruction (llvm::Module *m, retdec::common::Address addr) | |
bool | operator< (const AsmInstruction &o) const |
bool | operator== (const AsmInstruction &o) const |
bool | operator!= (const AsmInstruction &o) const |
operator bool () const | |
iterator | begin () |
iterator | end () |
reverse_iterator | rbegin () |
reverse_iterator | rend () |
const_iterator | begin () const |
const_iterator | end () const |
const_reverse_iterator | rbegin () const |
const_reverse_iterator | rend () const |
bool | isValid () const |
bool | isInvalid () const |
cs_insn * | getCapstoneInsn () const |
std::string | getDsm () const |
retdec::common::Address | getAddress () const |
retdec::common::Address | getEndAddress () const |
std::size_t | getByteSize () const |
std::size_t | getBitSize () const |
bool | contains (retdec::common::Address addr) const |
AsmInstruction | getNext () const |
AsmInstruction | getPrev () const |
bool | instructionsCanBeErased () |
bool | eraseInstructions () |
llvm::Instruction * | makeTerminal () |
llvm::BasicBlock * | makeStart (const std::string &name="") |
llvm::BasicBlock * | getBasicBlock () const |
llvm::Function * | getFunction () const |
llvm::Module * | getModule () const |
llvm::LLVMContext & | getContext () const |
std::vector< llvm::Instruction * > | getInstructions () |
std::vector< llvm::BasicBlock * > | getBasicBlocks () |
bool | empty () |
llvm::Instruction * | front () |
llvm::Instruction * | back () |
llvm::StoreInst * | getLlvmToAsmInstruction () const |
llvm::Instruction * | insertBack (llvm::Instruction *i) |
llvm::Instruction * | insertBackSafe (llvm::Instruction *i) |
bool | storesValue (llvm::Value *val) const |
std::string | dump () const |
template<typename T > | |
bool | containsInstruction () |
template<typename T > | |
T * | getInstructionFirst () |
Static Public Member Functions | |
static Llvm2CapstoneInsnMap & | getLlvmToCapstoneInsnMap (const llvm::Module *m) |
static llvm::GlobalVariable * | getLlvmToAsmGlobalVariable (const llvm::Module *m) |
static void | setLlvmToAsmGlobalVariable (const llvm::Module *m, llvm::GlobalVariable *gv) |
static retdec::common::Address | getInstructionAddress (llvm::Instruction *inst) |
static retdec::common::Address | getInstructionEndAddress (llvm::Instruction *inst) |
static retdec::common::Address | getBasicBlockAddress (llvm::BasicBlock *bb) |
static retdec::common::Address | getTrueBasicBlockAddress (llvm::BasicBlock *bb) |
static retdec::common::Address | getBasicBlockEndAddress (llvm::BasicBlock *bb) |
static retdec::common::Address | getFunctionAddress (llvm::Function *f) |
static retdec::common::Address | getFunctionEndAddress (llvm::Function *f) |
static bool | isLlvmToAsmInstruction (const llvm::Value *inst) |
static void | clear () |
Private Types | |
using | ModuleGlobalPair = std::pair< const llvm::Module *, llvm::GlobalVariable * > |
using | ModuleInstructionMap = std::pair< const llvm::Module *, std::map< llvm::StoreInst *, cs_insn * > > |
Private Member Functions | |
const llvm::GlobalVariable * | getLlvmToAsmGlobalVariablePrivate (llvm::Module *m) const |
bool | isLlvmToAsmInstructionPrivate (llvm::Value *inst) const |
Private Attributes | |
llvm::StoreInst * | _llvmToAsmInstr = nullptr |
Static Private Attributes | |
static std::vector< ModuleGlobalPair > | _module2global |
static std::vector< ModuleInstructionMap > | _module2instMap |
Friends | |
std::ostream & | operator<< (std::ostream &out, const AsmInstruction &a) |
Assembly instruction representation.
This is a lightway class that contains only one llvm::StoreInst pointer. I.e. this class can be passed by value instead of by reference or pointer.
using retdec::bin2llvmir::AsmInstruction::const_iterator = iterator_impl< std::bidirectional_iterator_tag, const llvm::Instruction> |
using retdec::bin2llvmir::AsmInstruction::const_reverse_iterator = std::reverse_iterator<const_iterator> |
using retdec::bin2llvmir::AsmInstruction::iterator = iterator_impl< std::bidirectional_iterator_tag, llvm::Instruction> |
|
private |
|
private |
using retdec::bin2llvmir::AsmInstruction::reverse_iterator = std::reverse_iterator<iterator> |
retdec::bin2llvmir::AsmInstruction::AsmInstruction | ( | ) |
retdec::bin2llvmir::AsmInstruction::AsmInstruction | ( | llvm::Instruction * | inst | ) |
retdec::bin2llvmir::AsmInstruction::AsmInstruction | ( | llvm::BasicBlock * | bb | ) |
retdec::bin2llvmir::AsmInstruction::AsmInstruction | ( | llvm::Function * | f | ) |
retdec::bin2llvmir::AsmInstruction::AsmInstruction | ( | llvm::Module * | m, |
retdec::common::Address | addr | ||
) |
llvm::Instruction * retdec::bin2llvmir::AsmInstruction::back | ( | ) |
nullptr
if ASM instruction is empty. AsmInstruction::iterator retdec::bin2llvmir::AsmInstruction::begin | ( | ) |
AsmInstruction::const_iterator retdec::bin2llvmir::AsmInstruction::begin | ( | ) | const |
|
static |
bool retdec::bin2llvmir::AsmInstruction::contains | ( | retdec::common::Address | addr | ) | const |
|
inline |
std::string retdec::bin2llvmir::AsmInstruction::dump | ( | ) | const |
bool retdec::bin2llvmir::AsmInstruction::empty | ( | ) |
AsmInstruction::iterator retdec::bin2llvmir::AsmInstruction::end | ( | ) |
AsmInstruction::const_iterator retdec::bin2llvmir::AsmInstruction::end | ( | ) | const |
bool retdec::bin2llvmir::AsmInstruction::eraseInstructions | ( | ) |
If possible (see instructionsCanBeErased()
), erase LLVM instructions belonging to this ASM instruction. If instructions can not be erased, they are not changed at all.
True
if all instructions were successfully erased, false
otherwise. llvm::Instruction * retdec::bin2llvmir::AsmInstruction::front | ( | ) |
nullptr
if ASM instruction is empty. retdec::common::Address retdec::bin2llvmir::AsmInstruction::getAddress | ( | ) | const |
llvm::BasicBlock * retdec::bin2llvmir::AsmInstruction::getBasicBlock | ( | ) | const |
nullptr
if ASM instruction not valid.
|
static |
|
static |
std::vector< llvm::BasicBlock * > retdec::bin2llvmir::AsmInstruction::getBasicBlocks | ( | ) |
std::size_t retdec::bin2llvmir::AsmInstruction::getBitSize | ( | ) | const |
std::size_t retdec::bin2llvmir::AsmInstruction::getByteSize | ( | ) | const |
cs_insn * retdec::bin2llvmir::AsmInstruction::getCapstoneInsn | ( | ) | const |
llvm::LLVMContext & retdec::bin2llvmir::AsmInstruction::getContext | ( | ) | const |
std::string retdec::bin2llvmir::AsmInstruction::getDsm | ( | ) | const |
retdec::common::Address retdec::bin2llvmir::AsmInstruction::getEndAddress | ( | ) | const |
llvm::Function * retdec::bin2llvmir::AsmInstruction::getFunction | ( | ) | const |
nullptr
if ASM instruction not valid.
|
static |
|
static |
|
static |
|
static |
|
inline |
std::vector< llvm::Instruction * > retdec::bin2llvmir::AsmInstruction::getInstructions | ( | ) |
|
static |
|
private |
llvm::StoreInst * retdec::bin2llvmir::AsmInstruction::getLlvmToAsmInstruction | ( | ) | const |
|
static |
llvm::Module * retdec::bin2llvmir::AsmInstruction::getModule | ( | ) | const |
nullptr
if ASM instruction not valid. AsmInstruction retdec::bin2llvmir::AsmInstruction::getNext | ( | ) | const |
AsmInstruction retdec::bin2llvmir::AsmInstruction::getPrev | ( | ) | const |
|
static |
llvm::Instruction * retdec::bin2llvmir::AsmInstruction::insertBack | ( | llvm::Instruction * | i | ) |
Insert instruction i at the end of LLVM instructions associated with this ASM instruction.
llvm::Instruction * retdec::bin2llvmir::AsmInstruction::insertBackSafe | ( | llvm::Instruction * | i | ) |
Same as insertBack()
but if asm instruction ends with terminator, the new instruction is inserted before it.
bool retdec::bin2llvmir::AsmInstruction::instructionsCanBeErased | ( | ) |
It is possible to erase LLVM instructions, if none of them is used outside of this ASM instruction – when erased, there will not be any users left.
True
if instruction can be erase, false
otherwise. bool retdec::bin2llvmir::AsmInstruction::isInvalid | ( | ) | const |
|
static |
|
private |
bool retdec::bin2llvmir::AsmInstruction::isValid | ( | ) | const |
llvm::BasicBlock * retdec::bin2llvmir::AsmInstruction::makeStart | ( | const std::string & | name = "" | ) |
Make this ASM instruction start in basic block – first in BB. If it already is first, nothing is modified and an existing BB is returned. If it is not first yet, split BB on it to create a new BB
llvm::Instruction * retdec::bin2llvmir::AsmInstruction::makeTerminal | ( | ) |
Make this ASM instruction terminal – last in BB, ending with terminator Instruction
. If it already is terminal, nothing is modified and an existing terminator is returned. If it is not terminal yet, BB is split on the next ASM instruction, this instruction ends with an unconditional branch to the new BB, and this branch is returned.
|
explicit |
True
it AsmInstruction
is valid, false
otherwise. bool retdec::bin2llvmir::AsmInstruction::operator!= | ( | const AsmInstruction & | o | ) | const |
bool retdec::bin2llvmir::AsmInstruction::operator< | ( | const AsmInstruction & | o | ) | const |
bool retdec::bin2llvmir::AsmInstruction::operator== | ( | const AsmInstruction & | o | ) | const |
AsmInstruction::reverse_iterator retdec::bin2llvmir::AsmInstruction::rbegin | ( | ) |
AsmInstruction::const_reverse_iterator retdec::bin2llvmir::AsmInstruction::rbegin | ( | ) | const |
AsmInstruction::reverse_iterator retdec::bin2llvmir::AsmInstruction::rend | ( | ) |
AsmInstruction::const_reverse_iterator retdec::bin2llvmir::AsmInstruction::rend | ( | ) | const |
|
static |
bool retdec::bin2llvmir::AsmInstruction::storesValue | ( | llvm::Value * | val | ) | const |
|
friend |
|
private |
|
staticprivate |
|
staticprivate |