Debian Codegraph @

arch/TriCore/TriCoreMapping.c

raw symbols SCIP
1 /* Capstone Disassembly Engine */cxx . . $ `<file>/arch/TriCore/TriCoreMapping.c`/
2 /* By Nguyen Anh Quynh <[email protected]>, 2013-2014 */
3
4 #ifdef CAPSTONE_HAS_TRICOREcxx . . $ `<built-in>:429:9`!
5
6 #include <stdio.h> // debug
7 #include <string.h>
8 #include <assert.h>
9
10 #include "../../utils.h"cxx . . $ `<file>/utils.h`/
11 #include "../../cs_simple_types.h"cxx . . $ `<file>/cs_simple_types.h`/
12
13 #include "TriCoreMapping.h"cxx . . $ `<file>/arch/TriCore/TriCoreMapping.h`/
14 #include "TriCoreLinkage.h"cxx . . $ `<file>/arch/TriCore/TriCoreLinkage.h`/
15
16 #define GET_INSTRINFO_ENUMcxx . . $ `arch/TriCore/TriCoreMapping.c:16:9`!
17
18 #include "TriCoreGenInstrInfo.inc"cxx . . $ `<file>/arch/TriCore/TriCoreGenInstrInfo.inc`/
19
20 static const insn_mapcxx . . $ insn_map# insnscxx . . $ insns.[] = {
21 // dummy item
22 { 0,
23 0,
24 #ifndef CAPSTONE_DIET
25 { 0 },
26 { 0 },
27 { 0 },
28 0,
29 0
30 #endif
31 },
32
33 #include "TriCoreGenCSMappingInsn.inc"cxx . . $ `<file>/arch/TriCore/TriCoreGenCSMappingInsn.inc`/
34 };
35
36 void TriCore_get_insn_idcxx . . $ TriCore_get_insn_id(b32a94ba649bfb5a).(cs_structcxx . . $ cs_struct# *h, cs_insncxx . . $ cs_insn# *insn, unsigned int id)
37 {
38 // Not used. Information is set after disassembly.
39 }
40
41 #ifndef CAPSTONE_DIET
42 static const tricore_regcxx . . $ tricore_reg# flag_regscxx . . $ flag_regs.[] = { TRICORE_REG_PSWcxx . . $ TRICORE_REG_PSW. };
43 #endif // CAPSTONE_DIET
44
45 static inline void check_updates_flagscxx . . $ check_updates_flags(94c8a3269074abe9).(MCInstcxx . . $ MCInst# *MI)
46 {
47 #ifndef CAPSTONE_DIET
48 if (!MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.)
49 return;
50 cs_detailcxx . . $ cs_detail# *detail = MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.;
51 for (int i = 0; i < detail->regs_write_countcxx . . $ cs_detail#regs_write_count.; ++i) {
52 if (detail->regs_writecxx . . $ cs_detail#regs_write.[i] == 0)
53 return;
54 for (int j = 0; j < ARR_SIZEcxx . . $ `utils.h:24:9`!(flag_regs); ++j) {
55 if (detail->regs_writecxx . . $ cs_detail#regs_write.[i] == flag_regscxx . . $ flag_regs.[j]) {
56 detail->tricorecxx . . $ cs_detail#$anonymous_type_0#tricore..update_flagscxx . . $ cs_tricore#update_flags. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
57 return;
58 }
59 }
60 }
61 #endif // CAPSTONE_DIET
62 }
63
64 void TriCore_set_instr_map_datacxx . . $ TriCore_set_instr_map_data(94c8a3269074abe9).(MCInstcxx . . $ MCInst# *MI)
65 {
66 map_cs_idcxx . . $ map_cs_id(4a809e07614e3f82).(MI, insnscxx . . $ insns., ARR_SIZEcxx . . $ `utils.h:24:9`!(insns));
67 map_implicit_readscxx . . $ map_implicit_reads(86236b952129e9c2).(MI, insnscxx . . $ insns.);
68 map_implicit_writescxx . . $ map_implicit_writes(86236b952129e9c2).(MI, insnscxx . . $ insns.);
69 check_updates_flagscxx . . $ check_updates_flags(94c8a3269074abe9).(MI);
70 map_groupscxx . . $ map_groups(86236b952129e9c2).(MI, insnscxx . . $ insns.);
71 }
72
73 #ifndef CAPSTONE_DIET
74
75 static const char * const insn_namescxx . . $ insn_names.[] = {
76 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
77
78 #include "TriCoreGenCSMappingInsnName.inc"cxx . . $ `<file>/arch/TriCore/TriCoreGenCSMappingInsnName.inc`/
79 };
80
81 // special alias insn
82 static const name_mapcxx . . $ name_map# alias_insn_namescxx . . $ alias_insn_names.[] = { { 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! } };
83 #endif
84
85 const char *TriCore_insn_namecxx . . $ TriCore_insn_name(efd1348d9ae5172e).(cshcxx . . $ csh# handle, unsigned int id)
86 {
87 #ifndef CAPSTONE_DIET
88 unsigned int i;
89
90 if (id >= TRICORE_INS_ENDINGcxx . . $ TRICORE_INS_ENDING.)
91 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
92
93 // handle special alias first
94 for (i = 0; i < ARR_SIZEcxx . . $ `utils.h:24:9`!(alias_insn_names); i++) {
95 if (alias_insn_namescxx . . $ alias_insn_names.[i].idcxx . . $ name_map#id. == id)
96 return alias_insn_namescxx . . $ alias_insn_names.[i].namecxx . . $ name_map#name.;
97 }
98
99 return insn_namescxx . . $ insn_names.[id];
100 #else
101 return NULL;
102 #endif
103 }
104
105 #ifndef CAPSTONE_DIET
106 static const name_mapcxx . . $ name_map# group_name_mapscxx . . $ group_name_maps.[] = {
107 { TRICORE_GRP_INVALIDcxx . . $ TRICORE_GRP_INVALID., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
108 { TRICORE_GRP_CALLcxx . . $ TRICORE_GRP_CALL., "call" },
109 { TRICORE_GRP_JUMPcxx . . $ TRICORE_GRP_JUMP., "jump" },
110 };
111 #endif
112
113 const char *TriCore_group_namecxx . . $ TriCore_group_name(efd1348d9ae5172e).(cshcxx . . $ csh# handle, unsigned int id)
114 {
115 #ifndef CAPSTONE_DIET
116 if (id >= TRICORE_GRP_ENDINGcxx . . $ TRICORE_GRP_ENDING.)
117 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
118
119 return group_name_mapscxx . . $ group_name_maps.[id].namecxx . . $ name_map#name.;
120 #else
121 return NULL;
122 #endif
123 }
124
125 #ifndef CAPSTONE_DIET
126 /// A LLVM<->CS Mapping entry of an operand.
127 typedef struct insn_opcxx . . $ insn_op# {
128 uint8_tcxx . . $ uint8_t# /* cs_op_type */ typecxx . . $ insn_op#type.; ///< Operand type (e.g.: reg, imm, mem)
129 uint8_tcxx . . $ uint8_t# /* cs_ac_type */ accesscxx . . $ insn_op#access.; ///< The access type (read, write)
130 uint8_tcxx . . $ uint8_t# /* cs_data_type */
131 dtypescxx . . $ insn_op#dtypes.[10]; ///< List of op types. Terminated by CS_DATA_TYPE_LAST
132 } insn_opcxx . . $ insn_op#;
133
134 ///< Operands of an instruction.
135 typedef structcxx . . $ $anonymous_type_62f19f3851b284dc_0# {
136 insn_opcxx . . $ insn_op# opscxx . . $ $anonymous_type_62f19f3851b284dc_0#ops.[16]; ///< NULL terminated array of operands.
137 } insn_opscxx . . $ insn_ops#;
138
139 const insn_opscxx . . $ insn_ops# insn_operandscxx . . $ insn_operands.[] = {
140 #include "TriCoreGenCSMappingInsnOp.inc"cxx . . $ `<file>/arch/TriCore/TriCoreGenCSMappingInsnOp.inc`/
141 };
142 #endif
143
144 void TriCore_set_accesscxx . . $ TriCore_set_access(94c8a3269074abe9).(MCInstcxx . . $ MCInst# *MI)
145 {
146 #ifndef CAPSTONE_DIET
147 if (!(MI->cshcxx . . $ MCInst#csh.->detailcxx . . $ cs_struct#detail. == CS_OPT_ONcxx . . $ CS_OPT_ON. && MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.))
148 return;
149
150 assertcxx . . $ `/usr/include/assert.h:169:12`!(MI->Opcode < ARR_SIZEcxx . . $ `utils.h:24:9`!(insn_operands));
151
152 cs_detailcxx . . $ cs_detail# *detail = MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.;
153 cs_tricorecxx . . $ cs_tricore# *tc = &(detail->tricorecxx . . $ cs_detail#$anonymous_type_0#tricore.);
154 for (int i = 0; i < tc->op_countcxx . . $ cs_tricore#op_count.; ++i) {
155 cs_ac_typecxx . . $ cs_ac_type# ac = map_get_op_accesscxx . . $ `Mapping.h:81:9`!(MI, i);
156 cs_tricore_opcxx . . $ cs_tricore_op# *op = &tc->operandscxx . . $ cs_tricore#operands.[i];
157 op->accesscxx . . $ cs_tricore_op#access. = ac;
158 cs_op_typecxx . . $ cs_op_type# op_type = map_get_op_typecxx . . $ `Mapping.h:74:9`!(MI, i);
159 if (op_type != CS_OP_REGcxx . . $ CS_OP_REG.) {
160 continue;
161 }
162 if (ac & CS_AC_READcxx . . $ CS_AC_READ.) {
163 detail->regs_readcxx . . $ cs_detail#regs_read.[detail->regs_read_countcxx . . $ cs_detail#regs_read_count.++] = op->regcxx . . $ cs_tricore_op#$anonymous_type_0#reg.;
164 }
165 if (ac & CS_AC_WRITEcxx . . $ CS_AC_WRITE.) {
166 detail->regs_writecxx . . $ cs_detail#regs_write.[detail->regs_write_countcxx . . $ cs_detail#regs_write_count.++] =
167 op->regcxx . . $ cs_tricore_op#$anonymous_type_0#reg.;
168 }
169 }
170 #endif
171 }
172
173 void TriCore_reg_accesscxx . . $ TriCore_reg_access(a4e53139cd2f126c).(const cs_insncxx . . $ cs_insn# *insn, cs_regscxx . . $ cs_regs# regs_read,
174 uint8_tcxx . . $ uint8_t# *regs_read_count, cs_regscxx . . $ cs_regs# regs_write,
175 uint8_tcxx . . $ uint8_t# *regs_write_count)
176 {
177 #ifndef CAPSTONE_DIET
178 uint8_tcxx . . $ uint8_t# read_count, write_count;
179 cs_detailcxx . . $ cs_detail# *detail = insn->detailcxx . . $ cs_insn#detail.;
180 read_count = detail->regs_read_countcxx . . $ cs_detail#regs_read_count.;
181 write_count = detail->regs_write_countcxx . . $ cs_detail#regs_write_count.;
182
183 // implicit registers
184 memcpycxx . . $ memcpy(cc817cb175f282d).(regs_read, detail->regs_readcxx . . $ cs_detail#regs_read.,
185 read_count * sizeof(detail->regs_readcxx . . $ cs_detail#regs_read.[0]));
186 memcpycxx . . $ memcpy(cc817cb175f282d).(regs_write, detail->regs_writecxx . . $ cs_detail#regs_write.,
187 write_count * sizeof(detail->regs_writecxx . . $ cs_detail#regs_write.[0]));
188
189 // explicit registers
190 cs_tricorecxx . . $ cs_tricore# *tc = &detail->tricorecxx . . $ cs_detail#$anonymous_type_0#tricore.;
191 for (uint8_tcxx . . $ uint8_t# i = 0; i < tc->op_countcxx . . $ cs_tricore#op_count.; i++) {
192 cs_tricore_opcxx . . $ cs_tricore_op# *op = &(tc->operandscxx . . $ cs_tricore#operands.[i]);
193 switch ((int)op->typecxx . . $ cs_tricore_op#type.) {
194 case TRICORE_OP_REGcxx . . $ TRICORE_OP_REG.:
195 if ((op->accesscxx . . $ cs_tricore_op#access. & CS_AC_READcxx . . $ CS_AC_READ.) &&
196 !arr_existcxx . . $ arr_exist(c35293ec828d81e3).(regs_read, read_count, op->regcxx . . $ cs_tricore_op#$anonymous_type_0#reg.)) {
197 regs_read[read_count] = (uint16_tcxx . . $ uint16_t#)op->regcxx . . $ cs_tricore_op#$anonymous_type_0#reg.;
198 read_count++;
199 }
200 if ((op->accesscxx . . $ cs_tricore_op#access. & CS_AC_WRITEcxx . . $ CS_AC_WRITE.) &&
201 !arr_existcxx . . $ arr_exist(c35293ec828d81e3).(regs_write, write_count, op->regcxx . . $ cs_tricore_op#$anonymous_type_0#reg.)) {
202 regs_write[write_count] = (uint16_tcxx . . $ uint16_t#)op->regcxx . . $ cs_tricore_op#$anonymous_type_0#reg.;
203 write_count++;
204 }
205 break;
206 case TRICORE_OP_MEMcxx . . $ TRICORE_OP_MEM.:
207 // registers appeared in memory references always being read
208 if ((op->memcxx . . $ cs_tricore_op#$anonymous_type_0#mem..basecxx . . $ tricore_op_mem#base. != ARM_REG_INVALIDcxx . . $ ARM_REG_INVALID.) &&
209 !arr_existcxx . . $ arr_exist(c35293ec828d81e3).(regs_read, read_count, op->memcxx . . $ cs_tricore_op#$anonymous_type_0#mem..basecxx . . $ tricore_op_mem#base.)) {
210 regs_read[read_count] = (uint16_tcxx . . $ uint16_t#)op->memcxx . . $ cs_tricore_op#$anonymous_type_0#mem..basecxx . . $ tricore_op_mem#base.;
211 read_count++;
212 }
213 default:
214 break;
215 }
216 }
217
218 *regs_read_count = read_count;
219 *regs_write_count = write_count;
220 #endif
221 }
222
223 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! TriCore_getInstructioncxx . . $ TriCore_getInstruction(fe94ce91eeab61e9).(cshcxx . . $ csh# handle, const uint8_tcxx . . $ uint8_t# *Bytes, size_t ByteLen,
224 MCInstcxx . . $ MCInst# *MI, uint16_tcxx . . $ uint16_t# *Size, uint64_tcxx . . $ uint64_t# Address,
225 void *Info)
226 {
227 return TriCore_LLVM_getInstructioncxx . . $ TriCore_LLVM_getInstruction(fe94ce91eeab61e9).(handle, Bytes, ByteLen, MI, Size,
228 Address, Info);
229 }
230
231 void TriCore_printInstcxx . . $ TriCore_printInst(6238f66e5ea10f57).(MCInstcxx . . $ MCInst# *MI, SStreamcxx . . $ SStream# *O, void *Info)
232 {
233 TriCore_LLVM_printInstcxx . . $ TriCore_LLVM_printInst(be4687a15353dc37).(MI, MI->addresscxx . . $ MCInst#address., O);
234 }
235
236 const char *TriCore_getRegisterNamecxx . . $ TriCore_getRegisterName(efd1348d9ae5172e).(cshcxx . . $ csh# handle, unsigned int RegNo)
237 {
238 return TriCore_LLVM_getRegisterNamecxx . . $ TriCore_LLVM_getRegisterName(81a3ae90da26a711).(RegNo);
239 }
240
241 #endif // CAPSTONE_HAS_TRICORE