minsn_t Class Reference

Microinstruction class #insn. More...

Public Member Functions

bool is_optional (void) const
 
bool is_combined (void) const
 
bool is_farcall (void) const
 
bool is_cleaning_pop (void) const
 
bool is_extstx (void) const
 
bool is_tailcall (void) const
 
bool is_fpinsn (void) const
 
bool is_assert (void) const
 
bool is_persistent (void) const
 
bool is_wild_match (void) const
 
bool is_propagatable (void) const
 
bool is_ignlowsrc (void) const
 
bool is_inverted_jx (void) const
 
bool was_noret_icall (void) const
 
bool is_multimov (void) const
 
bool is_combinable (void) const
 
bool was_split (void) const
 
void set_optional (void)
 
void set_combined (void)
 
void clr_combined (void)
 
void set_farcall (void)
 
void set_cleaning_pop (void)
 
void set_extstx (void)
 
void set_tailcall (void)
 
void clr_tailcall (void)
 
void set_fpinsn (void)
 
void clr_fpinsn (void)
 
void set_assert (void)
 
void clr_assert (void)
 
void set_persistent (void)
 
void set_wild_match (void)
 
void clr_propagatable (void)
 
void set_ignlowsrc (void)
 
void clr_ignlowsrc (void)
 
void set_inverted_jx (void)
 
void set_noret_icall (void)
 
void clr_noret_icall (void)
 
void set_multimov (void)
 
void clr_multimov (void)
 
void set_combinable (void)
 
void clr_combinable (void)
 
void set_split_size (int s)
 
int get_split_size (void) const
 
 minsn_t (ea_t _ea)
 Constructor.
 
 minsn_t (const minsn_t &m)
 
minsn_toperator= (const minsn_t &m)
 Assignment operator. It does not copy prev/next fields.
 
void swap (minsn_t &m)
 Swap two instructions. More...
 
void print (qstring *vout, int shins_flags=SHINS_SHORT|SHINS_VALNUM) const
 Generate insn text into the buffer.
 
const char * dstr (void) const
 Get displayable text without tags in a static buffer.
 
void setaddr (ea_t new_ea)
 Change the instruction address. More...
 
int optimize_solo (int optflags=0)
 Optimize one instruction without context. More...
 
int optimize_subtree (mblock_t *blk, minsn_t *top, minsn_t *parent, minsn_t **converted_call, int optflags=OPTI_MINSTKREF)
 Optimize instruction in its context. More...
 
int for_all_ops (mop_visitor_t &mv)
 Visit all instruction operands. More...
 
int for_all_insns (minsn_visitor_t &mv)
 Visit all instructions. More...
 
void _make_nop (void)
 Convert instruction to nop. More...
 
bool equal_insns (const minsn_t &m, int eqflags) const
 Compare instructions. More...
 
bool operator< (const minsn_t &ri) const
 Lexographical comparison It can be used to store minsn_t in various containers, like std::set.
 
int lexcompare (const minsn_t &ri) const
 
bool is_noret_call (bool ignore_noret_icall=false)
 Is a non-returing call? More...
 
bool is_unknown_call (void) const
 Is an unknown call? Unknown calls are resolved by mbl_array_t::analyze_calls() They exist until the MMAT_CALLS maturity level. More...
 
bool is_helper (const char *name) const
 Is a helper call with the specified name? Helper calls usually have well-known function names (see Well known function names) but they may have any other name. More...
 
minsn_tfind_call (bool with_helpers=false) const
 Find a call instruction. More...
 
bool contains_call (bool with_helpers=false) const
 Does the instruction contain a call?
 
bool has_side_effects (bool include_ldx=false) const
 Does the instruction have a side effect? More...
 
funcrole_t get_role (void) const
 Get the function role of a call.
 
bool is_memcpy (void) const
 
bool is_memset (void) const
 
bool is_alloca (void) const
 
bool is_bswap (void) const
 
bool is_readflags (void) const
 
bool contains_opcode (mcode_t mcode) const
 Does the instruction have the specified opcode? This function searches subinstructions as well. More...
 
const minsn_tfind_opcode (mcode_t mcode) const
 Find a (sub)insruction with the specified opcode. More...
 
minsn_tfind_opcode (mcode_t mcode)
 
const minsn_tfind_ins_op (const mop_t **other, mcode_t op=m_nop) const
 Find an operand that is a subinsruction with the specified opcode. More...
 
minsn_tfind_ins_op (mop_t **other, mcode_t op=m_nop)
 
const mop_tfind_num_op (const mop_t **other) const
 Find a numeric operand of the current instruction. More...
 
mop_tfind_num_op (mop_t **other)
 
bool is_mov (void) const
 
bool is_like_move (void) const
 
bool modifes_d (void) const
 Does the instruction modify its 'd' operand? Some instructions (e.g. More...
 
bool modifies_pair_mop (void) const
 
bool is_between (const minsn_t *m1, const minsn_t *m2) const
 Is the instruction in the specified range of instructions? More...
 
bool is_after (const minsn_t *m) const
 Is the instruction after the specified one? More...
 
bool may_use_aliased_memory (void) const
 Is it possible for the instruction to use aliased memory?
 

Public Attributes

mcode_t opcode
 instruction opcode
 
int iprops
 combination of instruction property bits bits
 
minsn_tnext
 next insn in doubly linked list. check also nexti()
 
minsn_tprev
 prev insn in doubly linked list. check also previ()
 
ea_t ea
 instruction address
 
mop_t l
 left operand
 
mop_t r
 right operand
 
mop_t d
 destination operand
 

Detailed Description

Microinstruction class #insn.

Examples:
hexrays_sample10.cpp, hexrays_sample11.cpp, and hexrays_sample12.cpp.

Definition at line 3213 of file hexrays.hpp.

Member Function Documentation

◆ _make_nop()

void minsn_t::_make_nop ( void  )

Convert instruction to nop.

This function erases all info but the prev/next fields. In most cases it is better to use mblock_t::make_nop(), which also marks the block lists as dirty.

Definition at line 10117 of file hexrays.hpp.

References hexdsp.

Referenced by mblock_t::make_nop().

◆ contains_opcode()

bool minsn_t::contains_opcode ( mcode_t  mcode) const

Does the instruction have the specified opcode? This function searches subinstructions as well.

Parameters
mcodeopcode to search for.

Definition at line 3451 of file hexrays.hpp.

◆ equal_insns()

bool minsn_t::equal_insns ( const minsn_t m,
int  eqflags 
) const

Compare instructions.

This is the main comparison function for instructions.

Parameters
minstruction to compare with
eqflagscombination of comparison bits bits

Definition at line 10123 of file hexrays.hpp.

References hexdsp.

◆ find_call()

minsn_t * minsn_t::find_call ( bool  with_helpers = false) const

Find a call instruction.

Check for the current instruction and its subinstructions.

Parameters
with_helpersconsider helper calls as well?

Definition at line 10147 of file hexrays.hpp.

References hexdsp.

◆ find_ins_op()

const minsn_t * minsn_t::find_ins_op ( const mop_t **  other,
mcode_t  op = m_nop 
) const

Find an operand that is a subinsruction with the specified opcode.

This function checks only the 'l' and 'r' operands of the current insn.

Parameters
[out]otherpointer to the other operand (&r if we return &l and vice versa)
opopcode to search for
Returns
&l or &r or NULL

Definition at line 10165 of file hexrays.hpp.

References hexdsp.

◆ find_num_op()

const mop_t * minsn_t::find_num_op ( const mop_t **  other) const

Find a numeric operand of the current instruction.

This function checks only the 'l' and 'r' operands of the current insn.

Parameters
[out]otherpointer to the other operand (&r if we return &l and vice versa)
Returns
&l or &r or NULL

Definition at line 10171 of file hexrays.hpp.

References hexdsp.

◆ find_opcode()

const minsn_t* minsn_t::find_opcode ( mcode_t  mcode) const

Find a (sub)insruction with the specified opcode.

Parameters
mcodeopcode to search for.

Definition at line 3455 of file hexrays.hpp.

References find_opcode(), and hexapi.

Referenced by find_opcode().

◆ for_all_insns()

int minsn_t::for_all_insns ( minsn_visitor_t mv)

Visit all instructions.

This function visits the instruction itself and all its subinstructions.

Parameters
mvinstruction visitor
Returns
non-zero value returned by mv.visit_mop() or zero

Definition at line 10111 of file hexrays.hpp.

References hexdsp.

◆ for_all_ops()

int minsn_t::for_all_ops ( mop_visitor_t mv)

Visit all instruction operands.

This function visits subinstruction operands as well.

Parameters
mvoperand visitor
Returns
non-zero value returned by mv.visit_mop() or zero

Definition at line 10105 of file hexrays.hpp.

References hexdsp.

◆ has_side_effects()

bool minsn_t::has_side_effects ( bool  include_ldx = false) const

Does the instruction have a side effect?

Parameters
include_ldxconsider ldx as having side effects? stx is always considered as having side effects. Apart from ldx/std only call may have side effects.

Definition at line 10153 of file hexrays.hpp.

References hexdsp.

◆ is_after()

bool minsn_t::is_after ( const minsn_t m) const

Is the instruction after the specified one?

Parameters
mthe instruction to compare against in the list

Definition at line 3492 of file hexrays.hpp.

References getb_reginsn(), getf_reginsn(), hexapi, and next.

◆ is_between()

bool minsn_t::is_between ( const minsn_t m1,
const minsn_t m2 
) const

Is the instruction in the specified range of instructions?

Parameters
m1beginning of the range in the doubly linked list
m2end of the range in the doubly linked list (excluded, may be NULL) This function assumes that m1 and m2 belong to the same basic block and they are top level instructions.

Definition at line 10183 of file hexrays.hpp.

References hexdsp.

◆ is_helper()

bool minsn_t::is_helper ( const char *  name) const

Is a helper call with the specified name? Helper calls usually have well-known function names (see Well known function names) but they may have any other name.

The decompiler does not assume any special meaning for non-well-known names.

Examples:
hexrays_sample10.cpp.

Definition at line 10141 of file hexrays.hpp.

References hexdsp.

◆ is_noret_call()

bool minsn_t::is_noret_call ( bool  ignore_noret_icall = false)

Is a non-returing call?

Parameters
ignore_noret_icallif set, indirect calls to noret functions will return false

Definition at line 10135 of file hexrays.hpp.

References hexdsp.

◆ is_unknown_call()

bool minsn_t::is_unknown_call ( void  ) const

Is an unknown call? Unknown calls are resolved by mbl_array_t::analyze_calls() They exist until the MMAT_CALLS maturity level.

Definition at line 3415 of file hexrays.hpp.

◆ modifes_d()

bool minsn_t::modifes_d ( void  ) const

Does the instruction modify its 'd' operand? Some instructions (e.g.

m_stx) do not modify the 'd' operand.

Definition at line 10177 of file hexrays.hpp.

References hexdsp.

◆ optimize_solo()

int minsn_t::optimize_solo ( int  optflags = 0)

Optimize one instruction without context.

This function does not have access to the instruction context (the previous and next instructions in the list, the block number, etc). It performs only basic optimizations that are available without this info.

Parameters
optflagscombination of optimization flags bits
Returns
number of changes, 0-unchanged See also mblock_t::optimize_insn()

Definition at line 3351 of file hexrays.hpp.

◆ optimize_subtree()

int minsn_t::optimize_subtree ( mblock_t blk,
minsn_t top,
minsn_t parent,
minsn_t **  converted_call,
int  optflags = OPTI_MINSTKREF 
)

Optimize instruction in its context.

Do not use this function, use mblock_t::optimize()

Definition at line 10099 of file hexrays.hpp.

References hexdsp.

◆ setaddr()

void minsn_t::setaddr ( ea_t  new_ea)

Change the instruction address.

This function modifies subinstructions as well.

Definition at line 10093 of file hexrays.hpp.

References hexdsp.

◆ swap()

void minsn_t::swap ( minsn_t m)

Swap two instructions.

The prev/next fields are not modified by this function because it would corrupt the doubly linked list.

Definition at line 10075 of file hexrays.hpp.

References hexdsp.