IDA C++ SDK 9.2
|
Microcode of one basic block. More...
#include <hexrays.hpp>
Public Member Functions | |
void | mark_lists_dirty () |
void | request_propagation () |
bool | needs_propagation () const |
void | request_demote64 () |
bool | lists_dirty () const |
bool | lists_ready () const |
int | make_lists_ready () |
int | npred () const |
Get number of block predecessors. | |
int | nsucc () const |
Get number of block successors. | |
int | pred (int n) const |
int | succ (int n) const |
mblock_t ()=delete | |
virtual | ~mblock_t () |
HEXRAYS_MEMORY_ALLOCATION_FUNCS () bool empty() const | |
void hexapi | print (vd_printer_t &vp) const |
Print block contents. | |
void hexapi | dump () const |
Dump block info. | |
AS_PRINTF (2, 0) void hexapi vdump_block(const char *title | |
AS_PRINTF (2, 3) void dump_block(const char *title | |
va_start (va, title) | |
vdump_block (title, va) | |
va_end (va) | |
minsn_t *hexapi | insert_into_block (minsn_t *nm, minsn_t *om) |
Insert instruction into the doubly linked list. | |
minsn_t *hexapi | remove_from_block (minsn_t *m) |
Remove instruction from the doubly linked list. | |
int hexapi | for_all_insns (minsn_visitor_t &mv) |
Visit all instructions. | |
int hexapi | for_all_ops (mop_visitor_t &mv) |
Visit all operands. | |
int hexapi | for_all_uses (mlist_t *list, minsn_t *i1, minsn_t *i2, mlist_mop_visitor_t &mmv) |
Visit all operands that use LIST. | |
int hexapi | optimize_insn (minsn_t *m, int optflags=OPTI_MINSTKREF|OPTI_COMBINSNS) |
Optimize one instruction in the context of the block. | |
int hexapi | optimize_block () |
Optimize a basic block. | |
int hexapi | build_lists (bool kill_deads) |
Build def-use lists and eliminate deads. | |
int hexapi | optimize_useless_jump () |
Remove a jump at the end of the block if it is useless. | |
void hexapi | append_use_list (mlist_t *list, const mop_t &op, maymust_t maymust, bitrange_t mask=MAXRANGE) const |
Append use-list of an operand. | |
void hexapi | append_def_list (mlist_t *list, const mop_t &op, maymust_t maymust) const |
Append def-list of an operand. | |
mlist_t hexapi | build_use_list (const minsn_t &ins, maymust_t maymust) const |
Build use-list of an instruction. | |
mlist_t hexapi | build_def_list (const minsn_t &ins, maymust_t maymust) const |
Build def-list of an instruction. | |
bool | is_used (mlist_t *list, const minsn_t *i1, const minsn_t *i2, maymust_t maymust=MAY_ACCESS) const |
Is the list used by the specified instruction range? | |
const minsn_t *hexapi | find_first_use (mlist_t *list, const minsn_t *i1, const minsn_t *i2, maymust_t maymust=MAY_ACCESS) const |
Find the first insn that uses the specified list in the insn range. | |
minsn_t * | find_first_use (mlist_t *list, minsn_t *i1, const minsn_t *i2, maymust_t maymust=MAY_ACCESS) const |
bool | is_redefined (const mlist_t &list, const minsn_t *i1, const minsn_t *i2, maymust_t maymust=MAY_ACCESS) const |
Is the list redefined by the specified instructions? | |
const minsn_t *hexapi | find_redefinition (const mlist_t &list, const minsn_t *i1, const minsn_t *i2, maymust_t maymust=MAY_ACCESS) const |
Find the first insn that redefines any part of the list in the insn range. | |
minsn_t * | find_redefinition (const mlist_t &list, minsn_t *i1, const minsn_t *i2, maymust_t maymust=MAY_ACCESS) const |
bool hexapi | is_rhs_redefined (const minsn_t *ins, const minsn_t *i1, const minsn_t *i2) const |
Is the right hand side of the instruction redefined the insn range? | |
minsn_t *hexapi | find_access (const mop_t &op, minsn_t **parent, const minsn_t *mend, int fdflags) const |
Find the instruction that accesses the specified operand. | |
minsn_t * | find_def (const mop_t &op, minsn_t **p_i1, const minsn_t *i2, int fdflags) |
minsn_t * | find_use (const mop_t &op, minsn_t **p_i1, const minsn_t *i2, int fdflags) |
bool hexapi | get_valranges (valrng_t *res, const vivl_t &vivl, int vrflags) const |
Find possible values for a block. | |
bool hexapi | get_valranges (valrng_t *res, const vivl_t &vivl, const minsn_t *m, int vrflags) const |
Find possible values for an instruction. | |
void | make_nop (minsn_t *m) |
Erase the instruction (convert it to nop) and mark the lists dirty. | |
size_t hexapi | get_reginsn_qty () const |
Calculate number of regular instructions in the block. | |
bool | is_call_block () const |
bool | is_unknown_call () const |
bool | is_nway () const |
bool | is_branch () const |
bool | is_simple_goto_block () const |
bool | is_simple_jcnd_block () const |
Public Attributes | |
mblock_t * | nextb |
next block in the doubly linked list | |
mblock_t * | prevb |
previous block in the doubly linked list | |
uint32 | flags |
combination of Basic block properties bits | |
ea_t | start |
start address | |
ea_t | end |
end address note: we cannot rely on start/end addresses very much because instructions are propagated between blocks | |
minsn_t * | head |
pointer to the first instruction of the block | |
minsn_t * | tail |
pointer to the last instruction of the block | |
mba_t * | mba |
the parent micro block array | |
int | serial |
block number | |
mblock_type_t | type |
block type (BLT_NONE - not computed yet) | |
mlist_t | dead_at_start |
data that is dead at the block entry | |
mlist_t | mustbuse |
data that must be used by the block | |
mlist_t | maybuse |
data that may be used by the block | |
mlist_t | mustbdef |
data that must be defined by the block | |
mlist_t | maybdef |
data that may be defined by the block | |
mlist_t | dnu |
data that is defined but not used in the block | |
sval_t | maxbsp |
maximal sp value in the block (0...stacksize) | |
sval_t | minbstkref |
lowest stack location accessible with indirect addressing (offset from the stack bottom) initially it is 0 (not computed) | |
sval_t | minbargref |
the same for arguments | |
intvec_t | predset |
control flow graph: list of our predecessors use npred() and pred() to access it | |
intvec_t | succset |
control flow graph: list of our successors use nsucc() and succ() to access it | |
char | reserved [] |
va_list va | const |
const |
Friends | |
class | codegen_t |
Microcode of one basic block.
All blocks are part of a doubly linked list. They can also be addressed by indexing the mba->natural array. A block contains a doubly linked list of instructions, various location lists that are used for data flow analysis, and other attributes.
|
delete |
|
virtual |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Get number of block predecessors.
|
inline |
Get number of block successors.
|
inline |
|
inline |
|
inline |
|
inline |
Print block contents.
vp | print helpers class. it can be used to direct the printed info to any destination |
|
inline |
Dump block info.
This function is useful for debugging, see mba_t::dump for info
mblock_t::AS_PRINTF | ( | 2 | , |
0 | ) const |
mblock_t::AS_PRINTF | ( | 2 | , |
3 | ) const |
mblock_t::va_start | ( | va | , |
title | ) |
mblock_t::vdump_block | ( | title | , |
va | ) |
mblock_t::va_end | ( | va | ) |
Insert instruction into the doubly linked list.
nm | new instruction |
om | existing instruction, part of the doubly linked list if nullptr, then the instruction will be inserted at the beginning of the list NM will be inserted immediately after OM |
Remove instruction from the doubly linked list.
m | instruction to remove The removed instruction is not deleted, the caller gets its ownership |
|
inline |
Visit all instructions.
This function visits subinstructions too.
mv | instruction visitor |
|
inline |
Visit all operands.
This function visit subinstruction operands too.
mv | operand visitor |
|
inline |
Visit all operands that use LIST.
list | ptr to the list of locations. it may be modified: parts that get redefined by the instructions in [i1,i2) will be deleted. |
i1 | starting instruction. must be a top level insn. |
i2 | ending instruction (excluded). must be a top level insn. |
mmv | operand visitor |
|
inline |
Optimize one instruction in the context of the block.
m | pointer to a top level instruction |
optflags | combination of optimization flags bits |
|
inline |
Optimize a basic block.
Usually there is no need to call this function explicitly because the decompiler will call it itself if optinsn_t::func or optblock_t::func return non-zero.
|
inline |
Build def-use lists and eliminate deads.
kill_deads | do delete dead instructions? |
|
inline |
Remove a jump at the end of the block if it is useless.
This function preserves any side effects when removing a useless jump. Both conditional and unconditional jumps are handled (and jtbl too). This function deletes useless jumps, not only replaces them with a nop. (please note that \optimize_insn does not handle useless jumps).
|
inline |
Append use-list of an operand.
This function calculates list of locations that may or must be used by the operand and appends it to LIST.
list | ptr to the output buffer. we will append to it. |
op | operand to calculate the use list of |
maymust | should we calculate 'may-use' or 'must-use' list? see maymust_t for more details. |
mask | if only part of the operand should be considered, a bitmask can be used to specify which part. example: op=AX,mask=0xFF means that we will consider only AL. |
Append def-list of an operand.
This function calculates list of locations that may or must be modified by the operand and appends it to LIST.
list | ptr to the output buffer. we will append to it. |
op | operand to calculate the def list of |
maymust | should we calculate 'may-def' or 'must-def' list? see maymust_t for more details. |
Build use-list of an instruction.
This function calculates list of locations that may or must be used by the instruction. Examples: "ldx ds.2, eax.4, ebx.4", may-list: all aliasable memory "ldx ds.2, eax.4, ebx.4", must-list: empty Since LDX uses EAX for indirect access, it may access any aliasable memory. On the other hand, we cannot tell for sure which memory cells will be accessed, this is why the must-list is empty.
ins | instruction to calculate the use list of |
maymust | should we calculate 'may-use' or 'must-use' list? see maymust_t for more details. |
Build def-list of an instruction.
This function calculates list of locations that may or must be modified by the instruction. Examples: "stx ebx.4, ds.2, eax.4", may-list: all aliasable memory "stx ebx.4, ds.2, eax.4", must-list: empty Since STX uses EAX for indirect access, it may modify any aliasable memory. On the other hand, we cannot tell for sure which memory cells will be modified, this is why the must-list is empty.
ins | instruction to calculate the def list of |
maymust | should we calculate 'may-def' or 'must-def' list? see maymust_t for more details. |
|
inline |
Is the list used by the specified instruction range?
list | list of locations. LIST may be modified by the function: redefined locations will be removed from it. |
i1 | starting instruction of the range (must be a top level insn) |
i2 | end instruction of the range (must be a top level insn) i2 is excluded from the range. it can be specified as nullptr. i1 and i2 must belong to the same block. |
maymust | should we search in 'may-access' or 'must-access' mode? |
|
inline |
Find the first insn that uses the specified list in the insn range.
list | list of locations. LIST may be modified by the function: redefined locations will be removed from it. |
i1 | starting instruction of the range (must be a top level insn) |
i2 | end instruction of the range (must be a top level insn) i2 is excluded from the range. it can be specified as nullptr. i1 and i2 must belong to the same block. |
maymust | should we search in 'may-access' or 'must-access' mode? |
|
inline |
|
inline |
Is the list redefined by the specified instructions?
list | list of locations to check. |
i1 | starting instruction of the range (must be a top level insn) |
i2 | end instruction of the range (must be a top level insn) i2 is excluded from the range. it can be specified as nullptr. i1 and i2 must belong to the same block. |
maymust | should we search in 'may-access' or 'must-access' mode? |
|
inline |
Find the first insn that redefines any part of the list in the insn range.
list | list of locations to check. |
i1 | starting instruction of the range (must be a top level insn) |
i2 | end instruction of the range (must be a top level insn) i2 is excluded from the range. it can be specified as nullptr. i1 and i2 must belong to the same block. |
maymust | should we search in 'may-access' or 'must-access' mode? |
|
inline |
|
inline |
Is the right hand side of the instruction redefined the insn range?
"right hand side" corresponds to the source operands of the instruction.
ins | instruction to consider |
i1 | starting instruction of the range (must be a top level insn) |
i2 | end instruction of the range (must be a top level insn) i2 is excluded from the range. it can be specified as nullptr. i1 and i2 must belong to the same block. |
|
inline |
Find the instruction that accesses the specified operand.
This function search inside one block.
op | operand to search for | |
[in,out] | parent | ptr to ptr to a top level instruction. in: denotes the beginning of the search range. out: denotes the parent of the found instruction. |
mend | end instruction of the range (must be a top level insn) mend is excluded from the range. it can be specified as nullptr. parent and mend must belong to the same block. | |
fdflags | combination of bits for mblock_t::find_access bits |
|
inline |
|
inline |
Find possible values for a block.
res | set of value ranges |
vivl | what to search for |
vrflags | combination of bits for get_valranges bits |
|
inline |
Find possible values for an instruction.
res | set of value ranges |
vivl | what to search for |
m | insn to search value ranges at. |
vrflags | combination of bits for get_valranges bits |
Erase the instruction (convert it to nop) and mark the lists dirty.
This is the recommended function to use because it also marks the block use-def lists dirty.
|
inline |
Calculate number of regular instructions in the block.
Assertions are skipped by this function.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
friend |
mblock_t* mblock_t::nextb |
next block in the doubly linked list
mblock_t* mblock_t::prevb |
previous block in the doubly linked list
uint32 mblock_t::flags |
combination of Basic block properties bits
ea_t mblock_t::start |
start address
ea_t mblock_t::end |
end address note: we cannot rely on start/end addresses very much because instructions are propagated between blocks
minsn_t* mblock_t::head |
pointer to the first instruction of the block
minsn_t* mblock_t::tail |
pointer to the last instruction of the block
mba_t* mblock_t::mba |
the parent micro block array
int mblock_t::serial |
block number
mblock_type_t mblock_t::type |
block type (BLT_NONE - not computed yet)
mlist_t mblock_t::dead_at_start |
data that is dead at the block entry
mlist_t mblock_t::mustbuse |
data that must be used by the block
mlist_t mblock_t::maybuse |
data that may be used by the block
mlist_t mblock_t::mustbdef |
data that must be defined by the block
mlist_t mblock_t::maybdef |
data that may be defined by the block
mlist_t mblock_t::dnu |
data that is defined but not used in the block
sval_t mblock_t::maxbsp |
maximal sp value in the block (0...stacksize)
sval_t mblock_t::minbstkref |
lowest stack location accessible with indirect addressing (offset from the stack bottom) initially it is 0 (not computed)
sval_t mblock_t::minbargref |
the same for arguments
intvec_t mblock_t::predset |
intvec_t mblock_t::succset |
char mblock_t::reserved[] |
va_list va mblock_t::const |
mblock_t::const |