Debian Codegraph @

Mapping.h

raw symbols SCIP
1 /* Capstone Disassembly Engine */cxx . . $ `<file>/Mapping.h`/
2 /* By Nguyen Anh Quynh <[email protected]>, 2013-2019 */
3 /* Rot127 <[email protected]>, 2022-2023 */
4
5 #ifndef CS_MAPPING_H
6 #define CS_MAPPING_Hcxx . . $ `Mapping.h:6:9`!
7
8 #if defined(CAPSTONE_HAS_OSXKERNEL)
9 #include <libkern/libkern.h>
10 #else
11 #include "include/capstone/capstone.h"cxx . . $ `<file>/include/capstone/capstone.h`/
12 #include <stddef.h>
13 #endif
14 #include "cs_priv.h"cxx . . $ `<file>/cs_priv.h`/
15 #include <assert.h>
16 #include <string.h>
17
18 // map instruction to its characteristics
19 typedef struct insn_mapcxx . . $ insn_map# {
20 unsigned short idcxx . . $ insn_map#id.; // The LLVM instruction id
21 unsigned short mapidcxx . . $ insn_map#mapid.; // The Capstone instruction id
22 #ifndef CAPSTONE_DIET
23 uint16_tcxx . . $ uint16_t# regs_usecxx . . $ insn_map#regs_use.[MAX_IMPL_R_REGScxx . . $ `include/capstone/capstone.h:403:9`!]; ///< list of implicit registers used by
24 ///< this instruction
25 uint16_tcxx . . $ uint16_t# regs_modcxx . . $ insn_map#regs_mod.[MAX_IMPL_W_REGScxx . . $ `include/capstone/capstone.h:402:9`!]; ///< list of implicit registers modified
26 ///< by this instruction
27 unsigned char groupscxx . . $ insn_map#groups.
28 [MAX_NUM_GROUPScxx . . $ `include/capstone/capstone.h:404:9`!]; ///< list of group this instruction belong to
29 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! branchcxx . . $ insn_map#branch.; // branch instruction?
30 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! indirect_branchcxx . . $ insn_map#indirect_branch.; // indirect branch instruction?
31 #endif
32 } insn_mapcxx . . $ insn_map#;
33
34 // look for @id in @m, given its size in @max. first time call will update
35 // @cache. return 0 if not found
36 unsigned short insn_findcxx . . $ insn_find(1ce6b9640f5aa651).(const insn_mapcxx . . $ insn_map# *m, unsigned int max, unsigned int id,
37 unsigned short **cache);
38
39 unsigned int find_cs_idcxx . . $ find_cs_id(cca7d6eccb98dd8e).(unsigned MC_Opcode, const insn_mapcxx . . $ insn_map# *imap,
40 unsigned imap_size);
41
42 #define MAX_NO_DATA_TYPEScxx . . $ `Mapping.h:42:9`! 10
43
44 ///< A LLVM<->CS Mapping entry of an MCOperand.
45 typedef structcxx . . $ $anonymous_type_338b1da8dd16858f_0# {
46 uint8_tcxx . . $ uint8_t# /* cs_op_type */ typecxx . . $ $anonymous_type_338b1da8dd16858f_0#type.; ///< Operand type (e.g.: reg, imm, mem)
47 uint8_tcxx . . $ uint8_t# /* cs_ac_type */ accesscxx . . $ $anonymous_type_338b1da8dd16858f_0#access.; ///< The access type (read, write)
48 uint8_tcxx . . $ uint8_t# /* cs_data_type */
49 dtypescxx . . $ $anonymous_type_338b1da8dd16858f_0#dtypes.[MAX_NO_DATA_TYPEScxx . . $ `Mapping.h:42:9`!]; ///< List of op types. Terminated by
50 ///< CS_DATA_TYPE_LAST
51 } mapping_opcxx . . $ mapping_op#;
52
53 #define MAX_NO_INSN_MAP_OPScxx . . $ `Mapping.h:53:9`! 16
54
55 ///< MCOperands of an instruction.
56 typedef structcxx . . $ $anonymous_type_338b1da8dd16858f_1# {
57 mapping_opcxx . . $ mapping_op#
58 opscxx . . $ $anonymous_type_338b1da8dd16858f_1#ops.[MAX_NO_INSN_MAP_OPScxx . . $ `Mapping.h:53:9`!]; ///< NULL terminated array of insn_op.
59 } map_insn_opscxx . . $ map_insn_ops#;
60
61 /// Only usable by `auto-sync` archs!
62 const cs_op_typecxx . . $ cs_op_type# mapping_get_op_typecxx . . $ mapping_get_op_type(8296293786d992b4).(MCInstcxx . . $ MCInst# *MI, unsigned OpNum,
63 const map_insn_opscxx . . $ map_insn_ops# *insn_ops_map,
64 size_t map_size);
65
66 /// Only usable by `auto-sync` archs!
67 const cs_ac_typecxx . . $ cs_ac_type# mapping_get_op_accesscxx . . $ mapping_get_op_access(caa755bed75115f0).(MCInstcxx . . $ MCInst# *MI, unsigned OpNum,
68 const map_insn_opscxx . . $ map_insn_ops# *insn_ops_map,
69 size_t map_size);
70
71 /// Macro for easier access of operand types from the map.
72 /// Assumes the istruction operands map is called "insn_operands"
73 /// Only usable by `auto-sync` archs!
74 #define map_get_op_typecxx . . $ `Mapping.h:74:9`!(MI, OpNum) \
75 mapping_get_op_type(MI, OpNum, (const map_insn_ops *)insn_operands, \
76 sizeof(insn_operands) / sizeof(insn_operands[0]))
77
78 /// Macro for easier access of operand access flags from the map.
79 /// Assumes the istruction operands map is called "insn_operands"
80 /// Only usable by `auto-sync` archs!
81 #define map_get_op_accesscxx . . $ `Mapping.h:81:9`!(MI, OpNum) \
82 mapping_get_op_access(MI, OpNum, (const map_insn_ops *)insn_operands, \
83 sizeof(insn_operands) / \
84 sizeof(insn_operands[0]))
85
86 ///< Map for ids to their string
87 typedef struct name_mapcxx . . $ name_map# {
88 unsigned int idcxx . . $ name_map#id.;
89 const char *namecxx . . $ name_map#name.;
90 } name_mapcxx . . $ name_map#;
91
92 // map a name to its ID
93 // return 0 if not found
94 int name2idcxx . . $ name2id(b6128f0fa858e731).(const name_mapcxx . . $ name_map# *map, int max, const char *name);
95
96 // map ID to a name
97 // return NULL if not found
98 const char *id2namecxx . . $ id2name(92d4aec78e87b576).(const name_mapcxx . . $ name_map# *map, int max, const unsigned int id);
99
100 void map_add_implicit_writecxx . . $ map_add_implicit_write(1d3fdd902ae43da2).(MCInstcxx . . $ MCInst# *MI, uint32_tcxx . . $ uint32_t# Reg);
101
102 void map_implicit_readscxx . . $ map_implicit_reads(86236b952129e9c2).(MCInstcxx . . $ MCInst# *MI, const insn_mapcxx . . $ insn_map# *imap);
103
104 void map_implicit_writescxx . . $ map_implicit_writes(86236b952129e9c2).(MCInstcxx . . $ MCInst# *MI, const insn_mapcxx . . $ insn_map# *imap);
105
106 void map_groupscxx . . $ map_groups(86236b952129e9c2).(MCInstcxx . . $ MCInst# *MI, const insn_mapcxx . . $ insn_map# *imap);
107
108 void map_cs_idcxx . . $ map_cs_id(4a809e07614e3f82).(MCInstcxx . . $ MCInst# *MI, const insn_mapcxx . . $ insn_map# *imap, unsigned int imap_size);
109
110 #define DECL_get_detail_opcxx . . $ `Mapping.h:110:9`!(arch, ARCH) \
111 cs_##arch##_op *ARCH##_get_detail_op(MCInst *MI, int offset);
112
113 DECL_get_detail_opcxx . . $ MCInst#(arm, ARM);
114 DECL_get_detail_opcxx . . $ `Mapping.h:110:9`!(ppc, PPC);
115 DECL_get_detail_opcxx . . $ MCInst#(tricore, TriCore);
116
117 /// Increments the detail->arch.op_count by one.
118 #define DEFINE_inc_detail_op_countcxx . . $ `Mapping.h:118:9`!(arch, ARCH) \
119 static inline void ARCH##_inc_op_count(MCInst *MI) \
120 { \
121 MI->flat_insn->detail->arch.op_count++; \
122 }
123
124 /// Decrements the detail->arch.op_count by one.
125 #define DEFINE_dec_detail_op_countcxx . . $ `Mapping.h:125:9`!(arch, ARCH) \
126 static inline void ARCH##_dec_op_count(MCInst *MI) \
127 { \
128 MI->flat_insn->detail->arch.op_count--; \
129 }
130
131 DEFINE_inc_detail_op_countcxx . . $ cs_detail#$anonymous_type_0#arm.(arm, ARM);
132 DEFINE_dec_detail_op_countcxx . . $ cs_arm#op_count.(arm, ARM);
133 DEFINE_inc_detail_op_countcxx . . $ MCInst#(ppc, PPC);
134 DEFINE_dec_detail_op_countcxx . . $ cs_detail#$anonymous_type_0#ppc.(ppc, PPC);
135 DEFINE_inc_detail_op_countcxx . . $ `Mapping.h:118:9`!(tricore, TriCore);
136 DEFINE_dec_detail_op_countcxx . . $ MCInst#(tricore, TriCore);
137
138 /// Returns true if a memory operand is currently edited.
139 static inline boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! doing_memcxx . . $ doing_mem(2b3b922391fd40f3).(const MCInstcxx . . $ MCInst# *MI)
140 {
141 return MI->cshcxx . . $ MCInst#csh.->doing_memcxx . . $ cs_struct#doing_mem.;
142 }
143
144 /// Sets the doing_mem flag to @status.
145 static inline void set_doing_memcxx . . $ set_doing_mem(d038c2e3285cca59).(const MCInstcxx . . $ MCInst# *MI, boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! status)
146 {
147 MI->cshcxx . . $ MCInst#csh.->doing_memcxx . . $ cs_struct#doing_mem. = status;
148 }
149
150 /// Returns detail->arch
151 #define DEFINE_get_arch_detailcxx . . $ `Mapping.h:151:9`!(arch, ARCH) \
152 static inline cs_##arch *ARCH##_get_detail(const MCInst *MI) \
153 { \
154 assertcxx . . $ `<external>/4398592474888995393/assert.h:169:12`!(MI && MI->flat_insn && MI->flat_insn->detail); \
155 return &MI->flat_insn->detail->arch; \
156 }
157
158 DEFINE_get_arch_detailcxx . . $ MCInst#(arm, ARM);
159 DEFINE_get_arch_detailcxx . . $ PPC_get_detail(b054ea23accce9ed).(ppc, PPC);
160 DEFINE_get_arch_detailcxx . . $ MCInst#(tricore, TriCore);
161
162 static inline boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! detail_is_setcxx . . $ detail_is_set(2b3b922391fd40f3).(const MCInstcxx . . $ MCInst# *MI)
163 {
164 assertcxx . . $ MCInst#flat_insn.(MI && MI->flat_insn);
165 return MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
166 }
167
168 static inline cs_detailcxx . . $ cs_detail# *get_detailcxx . . $ get_detail(fd5c8398f8f07c9c).(const MCInstcxx . . $ MCInst# *MI)
169 {
170 assertcxx . . $ `<external>/4398592474888995393/assert.h:169:12`!(MI && MI->flat_insn);
171 return MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.;
172 }
173
174 #endif // CS_MAPPING_H