Debian Codegraph @

arch/XCore/XCoreMapping.c

raw symbols SCIP
1 /* Capstone Disassembly Engine */cxx . . $ `<file>/arch/XCore/XCoreMapping.c`/
2 /* By Nguyen Anh Quynh <[email protected]>, 2013-2015 */
3
4 #ifdef CAPSTONE_HAS_XCOREcxx . . $ `<built-in>:421:9`!
5
6 #include <stdio.h> // debug
7 #include <string.h>
8
9 #include "../../utils.h"cxx . . $ `<file>/utils.h`/
10
11 #include "XCoreMapping.h"cxx . . $ `<file>/arch/XCore/XCoreMapping.h`/
12
13 #define GET_INSTRINFO_ENUMcxx . . $ `arch/XCore/XCoreMapping.c:13:9`!
14 #include "XCoreGenInstrInfo.inc"cxx . . $ `<file>/arch/XCore/XCoreGenInstrInfo.inc`/
15
16 static const name_mapcxx . . $ name_map# reg_name_mapscxx . . $ reg_name_maps.[] = {
17 { XCORE_REG_INVALIDcxx . . $ XCORE_REG_INVALID., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
18
19 { XCORE_REG_CPcxx . . $ XCORE_REG_CP., "cp" },
20 { XCORE_REG_DPcxx . . $ XCORE_REG_DP., "dp" },
21 { XCORE_REG_LRcxx . . $ XCORE_REG_LR., "lr" },
22 { XCORE_REG_SPcxx . . $ XCORE_REG_SP., "sp" },
23 { XCORE_REG_R0cxx . . $ XCORE_REG_R0., "r0" },
24 { XCORE_REG_R1cxx . . $ XCORE_REG_R1., "r1" },
25 { XCORE_REG_R2cxx . . $ XCORE_REG_R2., "r2" },
26 { XCORE_REG_R3cxx . . $ XCORE_REG_R3., "r3" },
27 { XCORE_REG_R4cxx . . $ XCORE_REG_R4., "r4" },
28 { XCORE_REG_R5cxx . . $ XCORE_REG_R5., "r5" },
29 { XCORE_REG_R6cxx . . $ XCORE_REG_R6., "r6" },
30 { XCORE_REG_R7cxx . . $ XCORE_REG_R7., "r7" },
31 { XCORE_REG_R8cxx . . $ XCORE_REG_R8., "r8" },
32 { XCORE_REG_R9cxx . . $ XCORE_REG_R9., "r9" },
33 { XCORE_REG_R10cxx . . $ XCORE_REG_R10., "r10" },
34 { XCORE_REG_R11cxx . . $ XCORE_REG_R11., "r11" },
35
36 // pseudo registers
37 { XCORE_REG_PCcxx . . $ XCORE_REG_PC., "pc" },
38
39 { XCORE_REG_SCPcxx . . $ XCORE_REG_SCP., "scp" },
40 { XCORE_REG_SSRcxx . . $ XCORE_REG_SSR., "ssr" },
41 { XCORE_REG_ETcxx . . $ XCORE_REG_ET., "et" },
42 { XCORE_REG_EDcxx . . $ XCORE_REG_ED., "ed" },
43 { XCORE_REG_SEDcxx . . $ XCORE_REG_SED., "sed" },
44 { XCORE_REG_KEPcxx . . $ XCORE_REG_KEP., "kep" },
45 { XCORE_REG_KSPcxx . . $ XCORE_REG_KSP., "ksp" },
46 { XCORE_REG_IDcxx . . $ XCORE_REG_ID., "id" },
47 };
48
49 const char *XCore_reg_namecxx . . $ XCore_reg_name(efd1348d9ae5172e).(cshcxx . . $ csh# handle, unsigned int reg)
50 {
51 #ifndef CAPSTONE_DIET
52 if (reg >= ARR_SIZEcxx . . $ `utils.h:24:9`!(reg_name_maps))
53 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
54
55 return reg_name_mapscxx . . $ reg_name_maps.[reg].namecxx . . $ name_map#name.;
56 #else
57 return NULL;
58 #endif
59 }
60
61 xcore_regcxx . . $ xcore_reg# XCore_reg_idcxx . . $ XCore_reg_id(fbc3349276a8bd32).(char *name)
62 {
63 int i;
64
65 for(i = 1; i < ARR_SIZEcxx . . $ `utils.h:24:9`!(reg_name_maps); i++) {
66 if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(name, reg_name_mapscxx . . $ reg_name_maps.[i].namecxx . . $ name_map#name.))
67 return reg_name_mapscxx . . $ reg_name_maps.[i].idcxx . . $ name_map#id.;
68 }
69
70 // not found
71 return 0;
72 }
73
74 static const insn_mapcxx . . $ insn_map# insnscxx . . $ insns.[] = {
75 // dummy item
76 {
77 0, 0,
78 #ifndef CAPSTONE_DIET
79 { 0 }, { 0 }, { 0 }, 0, 0
80 #endif
81 },
82
83 #include "XCoreMappingInsn.inc"cxx . . $ `<file>/arch/XCore/XCoreMappingInsn.inc`/
84 };
85
86 // given internal insn id, return public instruction info
87 void XCore_get_insn_idcxx . . $ XCore_get_insn_id(b32a94ba649bfb5a).(cs_structcxx . . $ cs_struct# *h, cs_insncxx . . $ cs_insn# *insn, unsigned int id)
88 {
89 unsigned short i;
90
91 i = insn_findcxx . . $ insn_find(1ce6b9640f5aa651).(insnscxx . . $ insns., ARR_SIZEcxx . . $ `utils.h:24:9`!(insns), id, &h->insn_cachecxx . . $ cs_struct#insn_cache.);
92 if (i != 0) {
93 insn->idcxx . . $ cs_insn#id. = insnscxx . . $ insns.[i].mapidcxx . . $ insn_map#mapid.;
94
95 if (h->detailcxx . . $ cs_struct#detail.) {
96 #ifndef CAPSTONE_DIET
97 memcpycxx . . $ memcpy(cc817cb175f282d).(insn->detailcxx . . $ cs_insn#detail.->regs_readcxx . . $ cs_detail#regs_read., insnscxx . . $ insns.[i].regs_usecxx . . $ insn_map#regs_use., sizeof(insnscxx . . $ insns.[i].regs_usecxx . . $ insn_map#regs_use.));
98 insn->detailcxx . . $ cs_insn#detail.->regs_read_countcxx . . $ cs_detail#regs_read_count. = (uint8_tcxx . . $ uint8_t#)count_positivecxx . . $ count_positive(ad0aaa07bfcd0593).(insnscxx . . $ insns.[i].regs_usecxx . . $ insn_map#regs_use.);
99
100 memcpycxx . . $ memcpy(cc817cb175f282d).(insn->detailcxx . . $ cs_insn#detail.->regs_writecxx . . $ cs_detail#regs_write., insnscxx . . $ insns.[i].regs_modcxx . . $ insn_map#regs_mod., sizeof(insnscxx . . $ insns.[i].regs_modcxx . . $ insn_map#regs_mod.));
101 insn->detailcxx . . $ cs_insn#detail.->regs_write_countcxx . . $ cs_detail#regs_write_count. = (uint8_tcxx . . $ uint8_t#)count_positivecxx . . $ count_positive(ad0aaa07bfcd0593).(insnscxx . . $ insns.[i].regs_modcxx . . $ insn_map#regs_mod.);
102
103 memcpycxx . . $ memcpy(cc817cb175f282d).(insn->detailcxx . . $ cs_insn#detail.->groupscxx . . $ cs_detail#groups., insnscxx . . $ insns.[i].groupscxx . . $ insn_map#groups., sizeof(insnscxx . . $ insns.[i].groupscxx . . $ insn_map#groups.));
104 insn->detailcxx . . $ cs_insn#detail.->groups_countcxx . . $ cs_detail#groups_count. = (uint8_tcxx . . $ uint8_t#)count_positive8cxx . . $ count_positive8(ca1608e2c87725e2).(insnscxx . . $ insns.[i].groupscxx . . $ insn_map#groups.);
105
106 if (insnscxx . . $ insns.[i].branchcxx . . $ insn_map#branch. || insnscxx . . $ insns.[i].indirect_branchcxx . . $ insn_map#indirect_branch.) {
107 // this insn also belongs to JUMP group. add JUMP group
108 insn->detailcxx . . $ cs_insn#detail.->groupscxx . . $ cs_detail#groups.[insn->detailcxx . . $ cs_insn#detail.->groups_countcxx . . $ cs_detail#groups_count.] = XCORE_GRP_JUMPcxx . . $ XCORE_GRP_JUMP.;
109 insn->detailcxx . . $ cs_insn#detail.->groups_countcxx . . $ cs_detail#groups_count.++;
110 }
111 #endif
112 }
113 }
114 }
115
116 #ifndef CAPSTONE_DIET
117 static const name_mapcxx . . $ name_map# insn_name_mapscxx . . $ insn_name_maps.[] = {
118 { XCORE_INS_INVALIDcxx . . $ XCORE_INS_INVALID., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
119
120 { XCORE_INS_ADDcxx . . $ XCORE_INS_ADD., "add" },
121 { XCORE_INS_ANDNOTcxx . . $ XCORE_INS_ANDNOT., "andnot" },
122 { XCORE_INS_ANDcxx . . $ XCORE_INS_AND., "and" },
123 { XCORE_INS_ASHRcxx . . $ XCORE_INS_ASHR., "ashr" },
124 { XCORE_INS_BAUcxx . . $ XCORE_INS_BAU., "bau" },
125 { XCORE_INS_BITREVcxx . . $ XCORE_INS_BITREV., "bitrev" },
126 { XCORE_INS_BLAcxx . . $ XCORE_INS_BLA., "bla" },
127 { XCORE_INS_BLATcxx . . $ XCORE_INS_BLAT., "blat" },
128 { XCORE_INS_BLcxx . . $ XCORE_INS_BL., "bl" },
129 { XCORE_INS_BFcxx . . $ XCORE_INS_BF., "bf" },
130 { XCORE_INS_BTcxx . . $ XCORE_INS_BT., "bt" },
131 { XCORE_INS_BUcxx . . $ XCORE_INS_BU., "bu" },
132 { XCORE_INS_BRUcxx . . $ XCORE_INS_BRU., "bru" },
133 { XCORE_INS_BYTEREVcxx . . $ XCORE_INS_BYTEREV., "byterev" },
134 { XCORE_INS_CHKCTcxx . . $ XCORE_INS_CHKCT., "chkct" },
135 { XCORE_INS_CLREcxx . . $ XCORE_INS_CLRE., "clre" },
136 { XCORE_INS_CLRPTcxx . . $ XCORE_INS_CLRPT., "clrpt" },
137 { XCORE_INS_CLRSRcxx . . $ XCORE_INS_CLRSR., "clrsr" },
138 { XCORE_INS_CLZcxx . . $ XCORE_INS_CLZ., "clz" },
139 { XCORE_INS_CRC8cxx . . $ XCORE_INS_CRC8., "crc8" },
140 { XCORE_INS_CRC32cxx . . $ XCORE_INS_CRC32., "crc32" },
141 { XCORE_INS_DCALLcxx . . $ XCORE_INS_DCALL., "dcall" },
142 { XCORE_INS_DENTSPcxx . . $ XCORE_INS_DENTSP., "dentsp" },
143 { XCORE_INS_DGETREGcxx . . $ XCORE_INS_DGETREG., "dgetreg" },
144 { XCORE_INS_DIVScxx . . $ XCORE_INS_DIVS., "divs" },
145 { XCORE_INS_DIVUcxx . . $ XCORE_INS_DIVU., "divu" },
146 { XCORE_INS_DRESTSPcxx . . $ XCORE_INS_DRESTSP., "drestsp" },
147 { XCORE_INS_DRETcxx . . $ XCORE_INS_DRET., "dret" },
148 { XCORE_INS_ECALLFcxx . . $ XCORE_INS_ECALLF., "ecallf" },
149 { XCORE_INS_ECALLTcxx . . $ XCORE_INS_ECALLT., "ecallt" },
150 { XCORE_INS_EDUcxx . . $ XCORE_INS_EDU., "edu" },
151 { XCORE_INS_EEFcxx . . $ XCORE_INS_EEF., "eef" },
152 { XCORE_INS_EETcxx . . $ XCORE_INS_EET., "eet" },
153 { XCORE_INS_EEUcxx . . $ XCORE_INS_EEU., "eeu" },
154 { XCORE_INS_ENDINcxx . . $ XCORE_INS_ENDIN., "endin" },
155 { XCORE_INS_ENTSPcxx . . $ XCORE_INS_ENTSP., "entsp" },
156 { XCORE_INS_EQcxx . . $ XCORE_INS_EQ., "eq" },
157 { XCORE_INS_EXTDPcxx . . $ XCORE_INS_EXTDP., "extdp" },
158 { XCORE_INS_EXTSPcxx . . $ XCORE_INS_EXTSP., "extsp" },
159 { XCORE_INS_FREERcxx . . $ XCORE_INS_FREER., "freer" },
160 { XCORE_INS_FREETcxx . . $ XCORE_INS_FREET., "freet" },
161 { XCORE_INS_GETDcxx . . $ XCORE_INS_GETD., "getd" },
162 { XCORE_INS_GETcxx . . $ XCORE_INS_GET., "get" },
163 { XCORE_INS_GETNcxx . . $ XCORE_INS_GETN., "getn" },
164 { XCORE_INS_GETRcxx . . $ XCORE_INS_GETR., "getr" },
165 { XCORE_INS_GETSRcxx . . $ XCORE_INS_GETSR., "getsr" },
166 { XCORE_INS_GETSTcxx . . $ XCORE_INS_GETST., "getst" },
167 { XCORE_INS_GETTScxx . . $ XCORE_INS_GETTS., "getts" },
168 { XCORE_INS_INCTcxx . . $ XCORE_INS_INCT., "inct" },
169 { XCORE_INS_INITcxx . . $ XCORE_INS_INIT., "init" },
170 { XCORE_INS_INPWcxx . . $ XCORE_INS_INPW., "inpw" },
171 { XCORE_INS_INSHRcxx . . $ XCORE_INS_INSHR., "inshr" },
172 { XCORE_INS_INTcxx . . $ XCORE_INS_INT., "int" },
173 { XCORE_INS_INcxx . . $ XCORE_INS_IN., "in" },
174 { XCORE_INS_KCALLcxx . . $ XCORE_INS_KCALL., "kcall" },
175 { XCORE_INS_KENTSPcxx . . $ XCORE_INS_KENTSP., "kentsp" },
176 { XCORE_INS_KRESTSPcxx . . $ XCORE_INS_KRESTSP., "krestsp" },
177 { XCORE_INS_KRETcxx . . $ XCORE_INS_KRET., "kret" },
178 { XCORE_INS_LADDcxx . . $ XCORE_INS_LADD., "ladd" },
179 { XCORE_INS_LD16Scxx . . $ XCORE_INS_LD16S., "ld16s" },
180 { XCORE_INS_LD8Ucxx . . $ XCORE_INS_LD8U., "ld8u" },
181 { XCORE_INS_LDA16cxx . . $ XCORE_INS_LDA16., "lda16" },
182 { XCORE_INS_LDAPcxx . . $ XCORE_INS_LDAP., "ldap" },
183 { XCORE_INS_LDAWcxx . . $ XCORE_INS_LDAW., "ldaw" },
184 { XCORE_INS_LDCcxx . . $ XCORE_INS_LDC., "ldc" },
185 { XCORE_INS_LDWcxx . . $ XCORE_INS_LDW., "ldw" },
186 { XCORE_INS_LDIVUcxx . . $ XCORE_INS_LDIVU., "ldivu" },
187 { XCORE_INS_LMULcxx . . $ XCORE_INS_LMUL., "lmul" },
188 { XCORE_INS_LSScxx . . $ XCORE_INS_LSS., "lss" },
189 { XCORE_INS_LSUBcxx . . $ XCORE_INS_LSUB., "lsub" },
190 { XCORE_INS_LSUcxx . . $ XCORE_INS_LSU., "lsu" },
191 { XCORE_INS_MACCScxx . . $ XCORE_INS_MACCS., "maccs" },
192 { XCORE_INS_MACCUcxx . . $ XCORE_INS_MACCU., "maccu" },
193 { XCORE_INS_MJOINcxx . . $ XCORE_INS_MJOIN., "mjoin" },
194 { XCORE_INS_MKMSKcxx . . $ XCORE_INS_MKMSK., "mkmsk" },
195 { XCORE_INS_MSYNCcxx . . $ XCORE_INS_MSYNC., "msync" },
196 { XCORE_INS_MULcxx . . $ XCORE_INS_MUL., "mul" },
197 { XCORE_INS_NEGcxx . . $ XCORE_INS_NEG., "neg" },
198 { XCORE_INS_NOTcxx . . $ XCORE_INS_NOT., "not" },
199 { XCORE_INS_ORcxx . . $ XCORE_INS_OR., "or" },
200 { XCORE_INS_OUTCTcxx . . $ XCORE_INS_OUTCT., "outct" },
201 { XCORE_INS_OUTPWcxx . . $ XCORE_INS_OUTPW., "outpw" },
202 { XCORE_INS_OUTSHRcxx . . $ XCORE_INS_OUTSHR., "outshr" },
203 { XCORE_INS_OUTTcxx . . $ XCORE_INS_OUTT., "outt" },
204 { XCORE_INS_OUTcxx . . $ XCORE_INS_OUT., "out" },
205 { XCORE_INS_PEEKcxx . . $ XCORE_INS_PEEK., "peek" },
206 { XCORE_INS_REMScxx . . $ XCORE_INS_REMS., "rems" },
207 { XCORE_INS_REMUcxx . . $ XCORE_INS_REMU., "remu" },
208 { XCORE_INS_RETSPcxx . . $ XCORE_INS_RETSP., "retsp" },
209 { XCORE_INS_SETCLKcxx . . $ XCORE_INS_SETCLK., "setclk" },
210 { XCORE_INS_SETcxx . . $ XCORE_INS_SET., "set" },
211 { XCORE_INS_SETCcxx . . $ XCORE_INS_SETC., "setc" },
212 { XCORE_INS_SETDcxx . . $ XCORE_INS_SETD., "setd" },
213 { XCORE_INS_SETEVcxx . . $ XCORE_INS_SETEV., "setev" },
214 { XCORE_INS_SETNcxx . . $ XCORE_INS_SETN., "setn" },
215 { XCORE_INS_SETPSCcxx . . $ XCORE_INS_SETPSC., "setpsc" },
216 { XCORE_INS_SETPTcxx . . $ XCORE_INS_SETPT., "setpt" },
217 { XCORE_INS_SETRDYcxx . . $ XCORE_INS_SETRDY., "setrdy" },
218 { XCORE_INS_SETSRcxx . . $ XCORE_INS_SETSR., "setsr" },
219 { XCORE_INS_SETTWcxx . . $ XCORE_INS_SETTW., "settw" },
220 { XCORE_INS_SETVcxx . . $ XCORE_INS_SETV., "setv" },
221 { XCORE_INS_SEXTcxx . . $ XCORE_INS_SEXT., "sext" },
222 { XCORE_INS_SHLcxx . . $ XCORE_INS_SHL., "shl" },
223 { XCORE_INS_SHRcxx . . $ XCORE_INS_SHR., "shr" },
224 { XCORE_INS_SSYNCcxx . . $ XCORE_INS_SSYNC., "ssync" },
225 { XCORE_INS_ST16cxx . . $ XCORE_INS_ST16., "st16" },
226 { XCORE_INS_ST8cxx . . $ XCORE_INS_ST8., "st8" },
227 { XCORE_INS_STWcxx . . $ XCORE_INS_STW., "stw" },
228 { XCORE_INS_SUBcxx . . $ XCORE_INS_SUB., "sub" },
229 { XCORE_INS_SYNCRcxx . . $ XCORE_INS_SYNCR., "syncr" },
230 { XCORE_INS_TESTCTcxx . . $ XCORE_INS_TESTCT., "testct" },
231 { XCORE_INS_TESTLCLcxx . . $ XCORE_INS_TESTLCL., "testlcl" },
232 { XCORE_INS_TESTWCTcxx . . $ XCORE_INS_TESTWCT., "testwct" },
233 { XCORE_INS_TSETMRcxx . . $ XCORE_INS_TSETMR., "tsetmr" },
234 { XCORE_INS_STARTcxx . . $ XCORE_INS_START., "start" },
235 { XCORE_INS_WAITEFcxx . . $ XCORE_INS_WAITEF., "waitef" },
236 { XCORE_INS_WAITETcxx . . $ XCORE_INS_WAITET., "waitet" },
237 { XCORE_INS_WAITEUcxx . . $ XCORE_INS_WAITEU., "waiteu" },
238 { XCORE_INS_XORcxx . . $ XCORE_INS_XOR., "xor" },
239 { XCORE_INS_ZEXTcxx . . $ XCORE_INS_ZEXT., "zext" },
240 };
241
242 // special alias insn
243 static const name_mapcxx . . $ name_map# alias_insn_namescxx . . $ alias_insn_names.[] = {
244 { 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! }
245 };
246 #endif
247
248 const char *XCore_insn_namecxx . . $ XCore_insn_name(efd1348d9ae5172e).(cshcxx . . $ csh# handle, unsigned int id)
249 {
250 #ifndef CAPSTONE_DIET
251 unsigned int i;
252
253 if (id >= XCORE_INS_ENDINGcxx . . $ XCORE_INS_ENDING.)
254 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
255
256 // handle special alias first
257 for (i = 0; i < ARR_SIZEcxx . . $ `utils.h:24:9`!(alias_insn_names); i++) {
258 if (alias_insn_namescxx . . $ alias_insn_names.[i].idcxx . . $ name_map#id. == id)
259 return alias_insn_namescxx . . $ alias_insn_names.[i].namecxx . . $ name_map#name.;
260 }
261
262 return insn_name_mapscxx . . $ insn_name_maps.[id].namecxx . . $ name_map#name.;
263 #else
264 return NULL;
265 #endif
266 }
267
268 #ifndef CAPSTONE_DIET
269 static const name_mapcxx . . $ name_map# group_name_mapscxx . . $ group_name_maps.[] = {
270 { XCORE_GRP_INVALIDcxx . . $ XCORE_GRP_INVALID., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! },
271 { XCORE_GRP_JUMPcxx . . $ XCORE_GRP_JUMP., "jump" },
272 };
273 #endif
274
275 const char *XCore_group_namecxx . . $ XCore_group_name(efd1348d9ae5172e).(cshcxx . . $ csh# handle, unsigned int id)
276 {
277 #ifndef CAPSTONE_DIET
278 return id2namecxx . . $ id2name(92d4aec78e87b576).(group_name_mapscxx . . $ group_name_maps., ARR_SIZEcxx . . $ `utils.h:24:9`!(group_name_maps), id);
279 #else
280 return NULL;
281 #endif
282 }
283
284 // map internal raw register to 'public' register
285 xcore_regcxx . . $ xcore_reg# XCore_map_registercxx . . $ XCore_map_register(7a5e20811a7fae0).(unsigned int r)
286 {
287 static const unsigned int map[] = { 0,
288 };
289
290 if (r < ARR_SIZEcxx . . $ `utils.h:24:9`!(map))
291 return map[r];
292
293 // cannot find this register
294 return 0;
295 }
296
297 #endif