15#ifndef LIEF_ASM_INST_H
16#define LIEF_ASM_INST_H
43 std::ptrdiff_t, Instruction*, std::unique_ptr<Instruction>>
72 std::unique_ptr<details::InstructionIt> impl_;
90 const std::vector<uint8_t>&
raw()
const;
96 std::string
to_string(
bool with_address =
true)
const;
178 const T*
as()
const {
179 static_assert(std::is_base_of<Instruction, T>::value,
180 "Require Instruction inheritance");
181 if (T::classof(
this)) {
182 return static_cast<const T*
>(
this);
195 static LIEF_LOCAL std::unique_ptr<Instruction>
196 create(std::unique_ptr<details::Instruction> impl);
199 LIEF_LOCAL const details::Instruction& impl()
const {
200 assert(impl_ !=
nullptr);
206 assert(impl_ !=
nullptr);
211 LIEF_LOCAL Instruction(std::unique_ptr<details::Instruction> impl);
212 std::unique_ptr<details::Instruction> impl_;
Iterator & operator=(const Iterator &)
Iterator(Iterator &&) noexcept
Iterator(const Iterator &)
std::unique_ptr< Instruction > operator*() const
Disassemble and output an Instruction at the current iterator's position.
details::InstructionIt implementation
Definition Instruction.hpp:46
Iterator(std::unique_ptr< details::InstructionIt > impl)
MemoryAccess memory_access() const
Memory access flags.
bool is_move_reg() const
True if the instruction is a register to register move.
bool is_terminator() const
True if the instruction marks the end of a basic block.
const T * as() const
This function can be used to down cast an Instruction instance:
Definition Instruction.hpp:178
bool is_compare() const
True if the instruction is a comparison.
bool is_conditional_branch() const
True if the instruction is conditionally jumping to the next instruction or an instruction into some ...
bool is_move_immediate() const
True if the instruction is moving an immediate.
bool is_syscall() const
True if the instruction is a syscall.
bool is_indirect_branch() const
True if the instruction is and indirect branch.
const llvm::MCInst & mcinst() const
Return the underlying llvm::MCInst implementation.
MemoryAccess
Memory operation flags.
Definition Instruction.hpp:76
@ READ
Definition Instruction.hpp:78
@ READ_WRITE
Definition Instruction.hpp:80
@ NONE
Definition Instruction.hpp:77
@ WRITE
Definition Instruction.hpp:79
bool is_branch() const
True if the instruction is a branch.
std::string mnemonic() const
Instruction mnemonic (e.g. br).
std::string to_string(bool with_address=true) const
Representation of the current instruction in a pretty assembly way.
bool is_bitcast() const
True if the instruction is doing a bitcast.
bool is_trap() const
True if the instruction is a trap.
bool is_unconditional_branch() const
True if the instruction is jumping (unconditionally) to some other basic block.
bool is_return() const
True if the instruction is a return.
uint64_t address() const
Address of the instruction.
bool is_add() const
True if the instruction performs an arithmetic addition.
bool is_call() const
True if the instruction is a call.
const std::vector< uint8_t > & raw() const
Raw bytes of the current instruction.
friend std::ostream & operator<<(std::ostream &os, const Instruction &inst)
Definition Instruction.hpp:187
bool is_memory_access() const
True if the instruction performs a memory access.
bool is_barrier() const
True if the instruction prevents executing the instruction that immediatly follows the current....
result< uint64_t > branch_target() const
Given a is_branch() instruction, try to evaluate the address of the destination.
size_t size() const
Size of the instruction in bytes.
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition iterators.hpp:590
Namespace related to assembly/disassembly support.
Definition Abstract/Binary.hpp:47
LIEF namespace.
Definition Abstract/Binary.hpp:40
tl::expected< T, lief_errors > result
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:75
Definition Abstract/Binary.hpp:35
#define LIEF_API
Definition visibility.h:41
#define LIEF_LOCAL
Definition visibility.h:42