15#ifndef LIEF_ASM_INST_H
16#define LIEF_ASM_INST_H
43 std::ptrdiff_t, const Instruction*,
47 using iterator_facade_base::operator++;
81 std::unique_ptr<details::InstructionIt> impl_;
82 mutable std::unique_ptr<Instruction> cached_;
91 READ_WRITE = READ | WRITE,
101 const std::vector<uint8_t>&
raw()
const;
189 const T*
as()
const {
190 static_assert(std::is_base_of<Instruction, T>::value,
191 "Require Instruction inheritance");
192 if (T::classof(
this)) {
193 return static_cast<const T*
>(
this);
199 const Instruction& inst) {
207 static LIEF_LOCAL std::unique_ptr<Instruction>
208 create(std::unique_ptr<details::Instruction> impl);
211 LIEF_LOCAL const details::Instruction& impl()
const {
212 assert(impl_ !=
nullptr);
218 assert(impl_ !=
nullptr);
223 LIEF_LOCAL Instruction(std::unique_ptr<details::Instruction> impl);
224 std::unique_ptr<details::Instruction> impl_;
const Instruction & operator*() const
std::unique_ptr< Instruction > yield()
Transfer ownership of the instruction at the current position to the caller. Returns nullptr if the i...
const Instruction * operator->() const
Iterator & operator=(const Iterator &)
Iterator(Iterator &&) noexcept
Iterator(const Iterator &)
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:189
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 an indirect branch.
const llvm::MCInst & mcinst() const
Return the underlying llvm::MCInst implementation.
MemoryAccess
Memory operation flags.
Definition Instruction.hpp:87
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:198
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 immediately 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:729
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:77
Namespace related to assembly/disassembly support.
Definition Abstract/Binary.hpp:47
LIEF namespace.
Definition Abstract/Binary.hpp:40
Definition Abstract/Binary.hpp:35
#define LIEF_API
Definition visibility.h:45
#define LIEF_LOCAL
Definition visibility.h:46