Debian Codegraph @

arch/X86/X86Mapping.h

raw symbols SCIP
1 /* Capstone Disassembly Engine */
2 /* By Nguyen Anh Quynh <[email protected]>, 2013-2019 */
3
4 #ifndef CS_X86_MAP_H
5 #define CS_X86_MAP_H
6
7 #include "capstone/capstone.h"
8 #include "../../cs_priv.h"
9
10 // map instruction to its characteristics
11 typedef struct insn_map_x86 {
12 unsigned short id;
13 unsigned short mapid;
14 unsigned char is64bit;
15 #ifndef CAPSTONE_DIET
16 uint16_t regs_use[12]; // list of implicit registers used by this instruction
17 uint16_t regs_mod[20]; // list of implicit registers modified by this instruction
18 unsigned char groups[8]; // list of group this instruction belong to
19 bool branch; // branch instruction?
20 bool indirect_branch; // indirect branch instruction?
21 #endif
22 } insn_map_x86;
23
24 extern const insn_map_x86 insns[];
25
26 // map sib_base to x86_reg
27 x86_reg x86_map_sib_base(int r);
28
29 // map sib_index to x86_reg
30 x86_reg x86_map_sib_index(int r);
31
32 // map seg_override to x86_reg
33 x86_reg x86_map_segment(int r);
34
35 // return name of regiser in friendly string
36 const char *X86_reg_name(csh handle, unsigned int reg);
37
38 // given internal insn id, return public instruction info
39 void X86_get_insn_id(cs_struct *h, cs_insn *insn, unsigned int id);
40
41 // return insn name, given insn id
42 const char *X86_insn_name(csh handle, unsigned int id);
43
44 // return group name, given group id
45 const char *X86_group_name(csh handle, unsigned int id);
46
47 // return register of given instruction id
48 // return 0 if not found
49 // this is to handle instructions embedding accumulate registers into AsmStrs[]
50 x86_reg X86_insn_reg_intel(unsigned int id, enum cs_ac_type *access);
51 x86_reg X86_insn_reg_intel_h(cs_struct *h, unsigned int id, enum cs_ac_type *access);
52 x86_reg X86_insn_reg_att(unsigned int id, enum cs_ac_type *access);
53 x86_reg X86_insn_reg_att_h(cs_struct *h, unsigned int id, enum cs_ac_type *access);
54 bool X86_insn_reg_intel2(unsigned int id, x86_reg *reg1, enum cs_ac_type *access1, x86_reg *reg2, enum cs_ac_type *access2);
55 bool X86_insn_reg_att2(unsigned int id, x86_reg *reg1, enum cs_ac_type *access1, x86_reg *reg2, enum cs_ac_type *access2);
56
57 extern const uint64_t arch_masks[9];
58
59 // handle LOCK/REP/REPNE prefixes
60 // return True if we patch mnemonic, like in MULPD case
61 bool X86_lockrep(MCInst *MI, SStream *O);
62
63 // map registers to sizes
64 extern const uint8_t regsize_map_32[];
65 extern const uint8_t regsize_map_64[];
66
67 void op_addReg(MCInst *MI, int reg);
68 void op_addImm(MCInst *MI, int v);
69
70 void op_addAvxBroadcast(MCInst *MI, x86_avx_bcast v);
71
72 void op_addXopCC(MCInst *MI, int v);
73 void op_addSseCC(MCInst *MI, int v);
74 void op_addAvxCC(MCInst *MI, int v);
75
76 void op_addAvxZeroOpmask(MCInst *MI);
77
78 void op_addAvxSae(MCInst *MI);
79
80 void op_addAvxRoundingMode(MCInst *MI, int v);
81
82 // given internal insn id, return operand access info
83 const uint8_t *X86_get_op_access(cs_struct *h, unsigned int id, uint64_t *eflags);
84
85 void X86_reg_access(const cs_insn *insn,
86 cs_regs regs_read, uint8_t *regs_read_count,
87 cs_regs regs_write, uint8_t *regs_write_count);
88
89 // given the instruction id, return the size of its immediate operand (or 0)
90 uint8_t X86_immediate_size(unsigned int id, uint8_t *enc_size);
91
92 unsigned short X86_register_map(unsigned short id);
93
94 unsigned int find_insn(unsigned int id);
95
96 // Build per-handle O(1) lookup tables for x86. Called from X86_global_init().
97 void X86_build_lookup_tables(cs_struct *h);
98
99 void X86_postprinter(csh handle, cs_insn *insn, char *mnem, MCInst *mci);
100
101 #endif