Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/capstone/arch/X86/X86Mapping.h
4389 views
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_att(unsigned int id, enum cs_ac_type *access);
52
bool X86_insn_reg_intel2(unsigned int id, x86_reg *reg1, enum cs_ac_type *access1, x86_reg *reg2, enum cs_ac_type *access2);
53
bool X86_insn_reg_att2(unsigned int id, x86_reg *reg1, enum cs_ac_type *access1, x86_reg *reg2, enum cs_ac_type *access2);
54
55
extern const uint64_t arch_masks[9];
56
57
// handle LOCK/REP/REPNE prefixes
58
// return True if we patch mnemonic, like in MULPD case
59
bool X86_lockrep(MCInst *MI, SStream *O);
60
61
// map registers to sizes
62
extern const uint8_t regsize_map_32[];
63
extern const uint8_t regsize_map_64[];
64
65
void op_addReg(MCInst *MI, int reg);
66
void op_addImm(MCInst *MI, int v);
67
68
void op_addAvxBroadcast(MCInst *MI, x86_avx_bcast v);
69
70
void op_addXopCC(MCInst *MI, int v);
71
void op_addSseCC(MCInst *MI, int v);
72
void op_addAvxCC(MCInst *MI, int v);
73
74
void op_addAvxZeroOpmask(MCInst *MI);
75
76
void op_addAvxSae(MCInst *MI);
77
78
void op_addAvxRoundingMode(MCInst *MI, int v);
79
80
// given internal insn id, return operand access info
81
const uint8_t *X86_get_op_access(cs_struct *h, unsigned int id, uint64_t *eflags);
82
83
void X86_reg_access(const cs_insn *insn,
84
cs_regs regs_read, uint8_t *regs_read_count,
85
cs_regs regs_write, uint8_t *regs_write_count);
86
87
// given the instruction id, return the size of its immediate operand (or 0)
88
uint8_t X86_immediate_size(unsigned int id, uint8_t *enc_size);
89
90
unsigned short X86_register_map(unsigned short id);
91
92
unsigned int find_insn(unsigned int id);
93
94
void X86_postprinter(csh handle, cs_insn *insn, char *mnem, MCInst *mci);
95
96
#endif
97
98