Helper class to generate the initial microcode. More...
#include <hexrays.hpp>
Public Member Functions | |
virtual merror_t | analyze_prolog (const class qflow_chart_t &fc, const class bitset_t &reachable)=0 |
Analyze prolog/epilog of the function to decompile. More... | |
virtual merror_t | gen_micro ()=0 |
Generate microcode for one instruction. More... | |
virtual mreg_t | load_operand (int opnum, int flags=0)=0 |
Generate microcode to load one operand. More... | |
virtual void | microgen_completed () |
This method is called when the microcode generation is done. More... | |
virtual merror_t | prepare_gen_micro () |
Setup internal data to handle new instruction. More... | |
virtual mreg_t | load_effective_address (int n, int flags=0)=0 |
Generate microcode to calculate the address of a memory operand. More... | |
virtual bool | store_operand (int n, const mop_t &mop, int flags=0, minsn_t **outins=nullptr) |
Generate microcode to store an operand. More... | |
minsn_t * | emit (mcode_t code, int width, uval_t l, uval_t r, uval_t d, int offsize) |
Emit one microinstruction. More... | |
minsn_t * | emit_micro_mvm (mcode_t code, op_dtype_t dtype, uval_t l, uval_t r, uval_t d, int offsize) |
Emit one microinstruction. More... | |
minsn_t * | emit (mcode_t code, const mop_t *l, const mop_t *r, const mop_t *d) |
Emit one microinstruction. More... | |
Public Attributes | |
mba_t * | mba |
mblock_t * | mb = nullptr |
insn_t | insn |
char | ignore_micro = IM_NONE |
cdg_insn_iterator_t | ii |
size_t | reserved |
Detailed Description
Helper class to generate the initial microcode.
Definition at line 5158 of file hexrays.hpp.
Constructor & Destructor Documentation
◆ ~codegen_t()
|
virtual |
Definition at line 5169 of file hexrays.hpp.
Member Function Documentation
◆ analyze_prolog()
|
pure virtual |
Analyze prolog/epilog of the function to decompile.
If prolog is found, allocate and fill 'mba->pi' structure.
- Parameters
-
fc flow chart reachable bitmap of reachable blocks
- Returns
- error code
◆ emit() [1/2]
Emit one microinstruction.
This variant accepts pointers to operands. It is more difficult to use but permits to create virtually any instruction. Operands may be nullptr when it makes sense.
Definition at line 11446 of file hexrays.hpp.
◆ emit() [2/2]
minsn_t * codegen_t::emit | ( | mcode_t | code, |
int | width, | ||
uval_t | l, | ||
uval_t | r, | ||
uval_t | d, | ||
int | offsize | ||
) |
Emit one microinstruction.
The L, R, D arguments usually mean the register number. However, they depend on CODE. For example:
- for m_goto and m_jcnd L is the target address
- for m_ldc L is the constant value to load
- Parameters
-
code instruction opcode width operand size in bytes l left operand r right operand d destination operand offsize for ldx/stx, the size of the offset operand for ldc, operand number of the constant value -1, set the FP instruction (e.g. for m_mov)
- Returns
- created microinstruction. can be nullptr if the instruction got immediately optimized away.
Definition at line 11440 of file hexrays.hpp.
◆ emit_micro_mvm()
minsn_t * codegen_t::emit_micro_mvm | ( | mcode_t | code, |
op_dtype_t | dtype, | ||
uval_t | l, | ||
uval_t | r, | ||
uval_t | d, | ||
int | offsize | ||
) |
Emit one microinstruction.
This variant takes a data type not a size.
Definition at line 5245 of file hexrays.hpp.
◆ gen_micro()
|
pure virtual |
Generate microcode for one instruction.
The instruction is in INSN
- Returns
- MERR_OK - all ok MERR_BLOCK - all ok, need to switch to new block MERR_BADBLK - delete current block and continue other error codes are fatal
◆ load_effective_address()
|
pure virtual |
Generate microcode to calculate the address of a memory operand.
- Parameters
-
n - number of INSN operand flags - reserved for future use
- Returns
- register containing the operand address. mr_none - failed (not a memory operand)
◆ load_operand()
|
pure virtual |
Generate microcode to load one operand.
- Parameters
-
opnum number of INSN operand flags reserved for future use
- Returns
- register containing the operand.
◆ microgen_completed()
|
virtual |
This method is called when the microcode generation is done.
Definition at line 5197 of file hexrays.hpp.
◆ prepare_gen_micro()
|
virtual |
Setup internal data to handle new instruction.
This method should be called before calling gen_micro(). Usually gen_micro() is called by the decompiler. You have to call this function explicitly only if you yourself call gen_micro(). The instruction is in INSN
- Returns
- MERR_OK - all ok other error codes are fatal
Definition at line 5206 of file hexrays.hpp.
References MERR_OK.
◆ store_operand()
|
virtual |
Generate microcode to store an operand.
In case of success an arbitrary number of instructions can be generated (and even no instruction if the source and target are the same)
- Parameters
-
n - number of target INSN operand mop - operand to be stored flags - reserved for future use outins - (OUT) the last generated instruction
- Returns
- success
Member Data Documentation
◆ ignore_micro
char codegen_t::ignore_micro = IM_NONE |
Definition at line 5164 of file hexrays.hpp.
◆ ii
cdg_insn_iterator_t codegen_t::ii |
Definition at line 5165 of file hexrays.hpp.
◆ insn
insn_t codegen_t::insn |
Definition at line 5163 of file hexrays.hpp.
◆ mb
mblock_t* codegen_t::mb = nullptr |
Definition at line 5162 of file hexrays.hpp.
◆ mba
mba_t* codegen_t::mba |
Definition at line 5161 of file hexrays.hpp.
◆ reserved
size_t codegen_t::reserved |
Definition at line 5166 of file hexrays.hpp.