clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name XCoreInstPrinter.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -ffunction-sections -fdata-sections -fcoverage-compilation-dir=/build/llvm-toolchain-snapshot-14~++20210903100615+fd66b44ec19e/build-llvm/lib/Target/XCore/MCTargetDesc -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /build/llvm-toolchain-snapshot-14~++20210903100615+fd66b44ec19e/build-llvm/lib/Target/XCore/MCTargetDesc -I /build/llvm-toolchain-snapshot-14~++20210903100615+fd66b44ec19e/llvm/lib/Target/XCore/MCTargetDesc -I /build/llvm-toolchain-snapshot-14~++20210903100615+fd66b44ec19e/llvm/lib/Target/XCore -I /build/llvm-toolchain-snapshot-14~++20210903100615+fd66b44ec19e/build-llvm/lib/Target/XCore -I /build/llvm-toolchain-snapshot-14~++20210903100615+fd66b44ec19e/build-llvm/include -I /build/llvm-toolchain-snapshot-14~++20210903100615+fd66b44ec19e/llvm/include -D NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wno-comment -std=c++14 -fdeprecated-macro -fdebug-compilation-dir=/build/llvm-toolchain-snapshot-14~++20210903100615+fd66b44ec19e/build-llvm/lib/Target/XCore/MCTargetDesc -fdebug-prefix-map=/build/llvm-toolchain-snapshot-14~++20210903100615+fd66b44ec19e=. -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2021-09-04-040900-46481-1 -x c++ /build/llvm-toolchain-snapshot-14~++20210903100615+fd66b44ec19e/llvm/lib/Target/XCore/MCTargetDesc/XCoreInstPrinter.cpp
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | #include "XCoreInstPrinter.h" |
14 | #include "llvm/ADT/StringRef.h" |
15 | #include "llvm/MC/MCExpr.h" |
16 | #include "llvm/MC/MCInst.h" |
17 | #include "llvm/MC/MCSymbol.h" |
18 | #include "llvm/Support/Casting.h" |
19 | #include "llvm/Support/ErrorHandling.h" |
20 | #include "llvm/Support/raw_ostream.h" |
21 | #include <cassert> |
22 | |
23 | using namespace llvm; |
24 | |
25 | #define DEBUG_TYPE "asm-printer" |
26 | |
27 | #include "XCoreGenAsmWriter.inc" |
28 | |
29 | void XCoreInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const { |
30 | OS << StringRef(getRegisterName(RegNo)).lower(); |
31 | } |
32 | |
33 | void XCoreInstPrinter::printInst(const MCInst *MI, uint64_t Address, |
34 | StringRef Annot, const MCSubtargetInfo &STI, |
35 | raw_ostream &O) { |
36 | printInstruction(MI, Address, O); |
| 1 | Calling 'XCoreInstPrinter::printInstruction' | |
|
37 | printAnnotation(O, Annot); |
38 | } |
39 | |
40 | void XCoreInstPrinter:: |
41 | printInlineJT(const MCInst *MI, int opNum, raw_ostream &O) { |
42 | report_fatal_error("can't handle InlineJT"); |
43 | } |
44 | |
45 | void XCoreInstPrinter:: |
46 | printInlineJT32(const MCInst *MI, int opNum, raw_ostream &O) { |
47 | report_fatal_error("can't handle InlineJT32"); |
48 | } |
49 | |
50 | static void printExpr(const MCExpr *Expr, const MCAsmInfo *MAI, |
51 | raw_ostream &OS) { |
52 | int Offset = 0; |
53 | const MCSymbolRefExpr *SRE; |
54 | |
55 | if (const MCBinaryExpr *BE = dyn_cast<MCBinaryExpr>(Expr)) { |
| 7 | | Assuming 'Expr' is not a 'MCBinaryExpr' | |
|
| |
56 | SRE = dyn_cast<MCSymbolRefExpr>(BE->getLHS()); |
57 | const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(BE->getRHS()); |
58 | assert(SRE && CE && "Binary expression must be sym+const."); |
59 | Offset = CE->getValue(); |
60 | } else { |
61 | SRE = dyn_cast<MCSymbolRefExpr>(Expr); |
| 9 | | Assuming 'Expr' is not a 'MCSymbolRefExpr' | |
|
| 10 | | Null pointer value stored to 'SRE' | |
|
62 | assert(SRE && "Unexpected MCExpr type."); |
63 | } |
64 | assert(SRE->getKind() == MCSymbolRefExpr::VK_None); |
65 | |
66 | SRE->getSymbol().print(OS, MAI); |
| 11 | | Called C++ object pointer is null |
|
67 | |
68 | if (Offset) { |
69 | if (Offset > 0) |
70 | OS << '+'; |
71 | OS << Offset; |
72 | } |
73 | } |
74 | |
75 | void XCoreInstPrinter:: |
76 | printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) { |
77 | const MCOperand &Op = MI->getOperand(OpNo); |
78 | if (Op.isReg()) { |
| |
79 | printRegName(O, Op.getReg()); |
80 | return; |
81 | } |
82 | |
83 | if (Op.isImm()) { |
| |
84 | O << Op.getImm(); |
85 | return; |
86 | } |
87 | |
88 | assert(Op.isExpr() && "unknown operand kind in printOperand"); |
89 | printExpr(Op.getExpr(), &MAI, O); |
| |
90 | } |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | std::pair<const char *, uint64_t> XCoreInstPrinter::getMnemonic(const MCInst *MI) { |
12 | |
13 | #ifdef __GNUC__ |
14 | #pragma GCC diagnostic push |
15 | #pragma GCC diagnostic ignored "-Woverlength-strings" |
16 | #endif |
17 | static const char AsmStrs[] = { |
18 | "ldap r11, \0" |
19 | "getsr r11, \0" |
20 | "set cp, \0" |
21 | "set dp, \0" |
22 | "set sp, \0" |
23 | "crc32 \0" |
24 | "lda16 \0" |
25 | "st16 \0" |
26 | "crc8 \0" |
27 | "st8 \0" |
28 | "# LDAWFI \0" |
29 | "# LDWFI \0" |
30 | "# STWFI \0" |
31 | "# EH_RETURN \0" |
32 | "# ADJCALLSTACKDOWN \0" |
33 | "# ADJCALLSTACKUP \0" |
34 | "# FRAME_TO_ARGS_OFFSET \0" |
35 | "bla \0" |
36 | "lsub \0" |
37 | "ldc \0" |
38 | "ladd \0" |
39 | "and \0" |
40 | "getd \0" |
41 | "bf \0" |
42 | "eef \0" |
43 | "waitef \0" |
44 | "ecallf \0" |
45 | "neg \0" |
46 | "dgetreg \0" |
47 | "peek \0" |
48 | "mkmsk \0" |
49 | "bl \0" |
50 | "testlcl \0" |
51 | "shl \0" |
52 | "kcall \0" |
53 | "lmul \0" |
54 | "endin \0" |
55 | "getn \0" |
56 | "extdp \0" |
57 | "retsp \0" |
58 | "kentsp \0" |
59 | "krestsp \0" |
60 | "extsp \0" |
61 | "eq \0" |
62 | "ashr \0" |
63 | "inshr \0" |
64 | "xor \0" |
65 | "clrsr \0" |
66 | "setsr \0" |
67 | "getr \0" |
68 | "ld16s \0" |
69 | "maccs \0" |
70 | "rems \0" |
71 | "lss \0" |
72 | "getts \0" |
73 | "divs \0" |
74 | "blat \0" |
75 | "bt \0" |
76 | "inct \0" |
77 | "testct \0" |
78 | "testwct \0" |
79 | "eet \0" |
80 | "get \0" |
81 | "waitet \0" |
82 | "ecallt \0" |
83 | "int \0" |
84 | "andnot \0" |
85 | "getst \0" |
86 | "sext \0" |
87 | "zext \0" |
88 | "ld8u \0" |
89 | "bau \0" |
90 | "bu \0" |
91 | "maccu \0" |
92 | "remu \0" |
93 | "bru \0" |
94 | "lsu \0" |
95 | "ldivu \0" |
96 | "byterev \0" |
97 | "bitrev \0" |
98 | "ldaw \0" |
99 | "ldw \0" |
100 | "inpw \0" |
101 | "stw \0" |
102 | "clz \0" |
103 | "# SELECT_CC PSEUDO!\0" |
104 | "# XRay Function Patchable RET.\0" |
105 | "# XRay Typed Event Log.\0" |
106 | "# XRay Custom Event Log.\0" |
107 | "# XRay Function Enter.\0" |
108 | "# XRay Tail Call Exit.\0" |
109 | "# XRay Function Exit.\0" |
110 | "set kep, r11\0" |
111 | "LIFETIME_END\0" |
112 | "PSEUDO_PROBE\0" |
113 | "BUNDLE\0" |
114 | "DBG_VALUE\0" |
115 | "DBG_INSTR_REF\0" |
116 | "DBG_PHI\0" |
117 | "DBG_LABEL\0" |
118 | "#MEMBARRIER\0" |
119 | "LIFETIME_START\0" |
120 | "DBG_VALUE_LIST\0" |
121 | "ldaw r11, cp[\0" |
122 | "ldw r11, cp[\0" |
123 | "bla cp[\0" |
124 | "msync res[\0" |
125 | "setpsc res[\0" |
126 | "setc res[\0" |
127 | "setd res[\0" |
128 | "setclk res[\0" |
129 | "mjoin res[\0" |
130 | "setn res[\0" |
131 | "syncr res[\0" |
132 | "freer res[\0" |
133 | "outshr res[\0" |
134 | "chkct res[\0" |
135 | "outct res[\0" |
136 | "clrpt res[\0" |
137 | "setpt res[\0" |
138 | "outt res[\0" |
139 | "out res[\0" |
140 | "edu res[\0" |
141 | "eeu res[\0" |
142 | "setev res[\0" |
143 | "setv res[\0" |
144 | "outpw res[\0" |
145 | "settw res[\0" |
146 | "setrdy res[\0" |
147 | "set ps[\0" |
148 | "set t[\0" |
149 | "init t[\0" |
150 | "start t[\0" |
151 | "ldw spc, sp[1]\0" |
152 | "stw spc, sp[1]\0" |
153 | "ldw ssr, sp[2]\0" |
154 | "stw ssr, sp[2]\0" |
155 | "ldw sed, sp[3]\0" |
156 | "stw sed, sp[3]\0" |
157 | "ldw et, sp[4]\0" |
158 | "stw et, sp[4]\0" |
159 | "ssync\0" |
160 | "get r11, ed\0" |
161 | "get r11, id\0" |
162 | "clre\0" |
163 | "# FEntry call\0" |
164 | "dcall\0" |
165 | "get r11, kep\0" |
166 | "get r11, ksp\0" |
167 | "dentsp\0" |
168 | "drestsp\0" |
169 | "tsetmr r\0" |
170 | "get r11, et\0" |
171 | "freet\0" |
172 | "dret\0" |
173 | "kret\0" |
174 | "waiteu\0" |
175 | }; |
176 | #ifdef __GNUC__ |
177 | #pragma GCC diagnostic pop |
178 | #endif |
179 | |
180 | static const uint32_t OpInfo0[] = { |
181 | 0U, |
182 | 0U, |
183 | 0U, |
184 | 0U, |
185 | 0U, |
186 | 0U, |
187 | 0U, |
188 | 0U, |
189 | 0U, |
190 | 0U, |
191 | 0U, |
192 | 0U, |
193 | 0U, |
194 | 826U, |
195 | 895U, |
196 | 836U, |
197 | 850U, |
198 | 858U, |
199 | 0U, |
200 | 0U, |
201 | 819U, |
202 | 880U, |
203 | 793U, |
204 | 806U, |
205 | 0U, |
206 | 0U, |
207 | 1376U, |
208 | 0U, |
209 | 0U, |
210 | 0U, |
211 | 0U, |
212 | 0U, |
213 | 0U, |
214 | 0U, |
215 | 0U, |
216 | 712U, |
217 | 632U, |
218 | 758U, |
219 | 735U, |
220 | 687U, |
221 | 663U, |
222 | 0U, |
223 | 0U, |
224 | 0U, |
225 | 0U, |
226 | 0U, |
227 | 0U, |
228 | 0U, |
229 | 0U, |
230 | 0U, |
231 | 0U, |
232 | 0U, |
233 | 0U, |
234 | 0U, |
235 | 0U, |
236 | 0U, |
237 | 0U, |
238 | 0U, |
239 | 0U, |
240 | 0U, |
241 | 0U, |
242 | 0U, |
243 | 0U, |
244 | 0U, |
245 | 0U, |
246 | 0U, |
247 | 0U, |
248 | 0U, |
249 | 0U, |
250 | 0U, |
251 | 0U, |
252 | 0U, |
253 | 0U, |
254 | 0U, |
255 | 0U, |
256 | 0U, |
257 | 0U, |
258 | 0U, |
259 | 0U, |
260 | 0U, |
261 | 0U, |
262 | 0U, |
263 | 0U, |
264 | 0U, |
265 | 0U, |
266 | 0U, |
267 | 0U, |
268 | 0U, |
269 | 0U, |
270 | 0U, |
271 | 0U, |
272 | 0U, |
273 | 0U, |
274 | 0U, |
275 | 0U, |
276 | 0U, |
277 | 0U, |
278 | 0U, |
279 | 0U, |
280 | 0U, |
281 | 0U, |
282 | 0U, |
283 | 0U, |
284 | 0U, |
285 | 0U, |
286 | 0U, |
287 | 0U, |
288 | 0U, |
289 | 0U, |
290 | 0U, |
291 | 0U, |
292 | 0U, |
293 | 0U, |
294 | 0U, |
295 | 0U, |
296 | 0U, |
297 | 0U, |
298 | 0U, |
299 | 0U, |
300 | 0U, |
301 | 0U, |
302 | 0U, |
303 | 0U, |
304 | 0U, |
305 | 0U, |
306 | 0U, |
307 | 0U, |
308 | 0U, |
309 | 0U, |
310 | 0U, |
311 | 0U, |
312 | 0U, |
313 | 0U, |
314 | 0U, |
315 | 0U, |
316 | 0U, |
317 | 0U, |
318 | 0U, |
319 | 0U, |
320 | 0U, |
321 | 0U, |
322 | 0U, |
323 | 0U, |
324 | 0U, |
325 | 0U, |
326 | 0U, |
327 | 0U, |
328 | 0U, |
329 | 0U, |
330 | 0U, |
331 | 0U, |
332 | 0U, |
333 | 0U, |
334 | 0U, |
335 | 0U, |
336 | 0U, |
337 | 0U, |
338 | 0U, |
339 | 0U, |
340 | 0U, |
341 | 0U, |
342 | 0U, |
343 | 0U, |
344 | 0U, |
345 | 0U, |
346 | 0U, |
347 | 0U, |
348 | 0U, |
349 | 0U, |
350 | 0U, |
351 | 0U, |
352 | 0U, |
353 | 0U, |
354 | 0U, |
355 | 0U, |
356 | 0U, |
357 | 0U, |
358 | 0U, |
359 | 0U, |
360 | 0U, |
361 | 0U, |
362 | 0U, |
363 | 0U, |
364 | 0U, |
365 | 0U, |
366 | 0U, |
367 | 0U, |
368 | 0U, |
369 | 0U, |
370 | 0U, |
371 | 0U, |
372 | 0U, |
373 | 0U, |
374 | 0U, |
375 | 0U, |
376 | 0U, |
377 | 0U, |
378 | 0U, |
379 | 0U, |
380 | 0U, |
381 | 0U, |
382 | 0U, |
383 | 0U, |
384 | 0U, |
385 | 0U, |
386 | 0U, |
387 | 0U, |
388 | 0U, |
389 | 0U, |
390 | 0U, |
391 | 0U, |
392 | 0U, |
393 | 0U, |
394 | 0U, |
395 | 0U, |
396 | 0U, |
397 | 0U, |
398 | 0U, |
399 | 0U, |
400 | 0U, |
401 | 0U, |
402 | 0U, |
403 | 0U, |
404 | 0U, |
405 | 0U, |
406 | 0U, |
407 | 0U, |
408 | 0U, |
409 | 0U, |
410 | 0U, |
411 | 0U, |
412 | 0U, |
413 | 0U, |
414 | 0U, |
415 | 0U, |
416 | 0U, |
417 | 0U, |
418 | 0U, |
419 | 0U, |
420 | 0U, |
421 | 0U, |
422 | 0U, |
423 | 2171U, |
424 | 10383U, |
425 | 283175U, |
426 | 545319U, |
427 | 2158U, |
428 | 10401U, |
429 | 868U, |
430 | 2130U, |
431 | 2140U, |
432 | 612U, |
433 | 2149U, |
434 | 2099402U, |
435 | 2099402U, |
436 | 788976U, |
437 | 2099407U, |
438 | 2099556U, |
439 | 2099556U, |
440 | 10769U, |
441 | 2625U, |
442 | 27561U, |
443 | 27561U, |
444 | 10672U, |
445 | 10672U, |
446 | 10425U, |
447 | 10510U, |
448 | 10510U, |
449 | 10510U, |
450 | 10510U, |
451 | 2266U, |
452 | 2266U, |
453 | 2486U, |
454 | 2486U, |
455 | 10774U, |
456 | 10774U, |
457 | 2266U, |
458 | 2266U, |
459 | 2486U, |
460 | 2486U, |
461 | 10774U, |
462 | 10774U, |
463 | 10791U, |
464 | 2616U, |
465 | 35871U, |
466 | 35871U, |
467 | 1371U, |
468 | 27701U, |
469 | 10614U, |
470 | 10614U, |
471 | 10614U, |
472 | 10614U, |
473 | 2655U, |
474 | 5247047U, |
475 | 19662899U, |
476 | 1390U, |
477 | 1422U, |
478 | 10488U, |
479 | 2099626U, |
480 | 2099762U, |
481 | 1429U, |
482 | 1464U, |
483 | 10475U, |
484 | 10723U, |
485 | 27742U, |
486 | 6334686U, |
487 | 6334929U, |
488 | 27751U, |
489 | 6334765U, |
490 | 10569U, |
491 | 10569U, |
492 | 2099552U, |
493 | 2099552U, |
494 | 10554U, |
495 | 10554U, |
496 | 10585U, |
497 | 10585U, |
498 | 27656U, |
499 | 1458U, |
500 | 6334676U, |
501 | 1347U, |
502 | 1446U, |
503 | 1359U, |
504 | 1396U, |
505 | 1409U, |
506 | 6334772U, |
507 | 51670U, |
508 | 2436U, |
509 | 10252U, |
510 | 10252U, |
511 | 6334968U, |
512 | 6334883U, |
513 | 6334906U, |
514 | 62646U, |
515 | 70838U, |
516 | 79030U, |
517 | 87222U, |
518 | 95414U, |
519 | 8432212U, |
520 | 7121258U, |
521 | 6334955U, |
522 | 6334768U, |
523 | 10528U, |
524 | 10528U, |
525 | 10528U, |
526 | 10568U, |
527 | 10568U, |
528 | 10576U, |
529 | 10576U, |
530 | 1469U, |
531 | 45093065U, |
532 | 12585354U, |
533 | 12585483U, |
534 | 14682170U, |
535 | 12585018U, |
536 | 10241U, |
537 | 10241U, |
538 | 10241U, |
539 | 10241U, |
540 | 10241U, |
541 | 14682697U, |
542 | 14682697U, |
543 | 27534U, |
544 | 27534U, |
545 | 100937U, |
546 | 100937U, |
547 | 12585545U, |
548 | 12585545U, |
549 | 109129U, |
550 | 109129U, |
551 | 2244U, |
552 | 2244U, |
553 | 1313U, |
554 | 186649137U, |
555 | 1283U, |
556 | 1223U, |
557 | 1253U, |
558 | 117327U, |
559 | 27548U, |
560 | 117327U, |
561 | 27548U, |
562 | 100943U, |
563 | 100943U, |
564 | 109135U, |
565 | 109135U, |
566 | 12585551U, |
567 | 12585551U, |
568 | 270534951U, |
569 | 2099614U, |
570 | 45093054U, |
571 | 2099756U, |
572 | 455084433U, |
573 | 455084570U, |
574 | 27624U, |
575 | 2311U, |
576 | 2311U, |
577 | 27569U, |
578 | 2099496U, |
579 | 2291U, |
580 | 2547U, |
581 | 2099570U, |
582 | 35882U, |
583 | 35882U, |
584 | 78681221U, |
585 | 39955U, |
586 | 35915U, |
587 | 35925U, |
588 | 6334721U, |
589 | 2099608U, |
590 | 2099745U, |
591 | 10561U, |
592 | 10561U, |
593 | 35804U, |
594 | 10264U, |
595 | 35784U, |
596 | 35784U, |
597 | 35784U, |
598 | 10273U, |
599 | 35794U, |
600 | 126064U, |
601 | 780U, |
602 | 35827U, |
603 | 35772U, |
604 | 36007U, |
605 | 35904U, |
606 | 35995U, |
607 | 10282U, |
608 | 10621U, |
609 | 10621U, |
610 | 10621U, |
611 | 10621U, |
612 | 35984U, |
613 | 126075U, |
614 | 788991U, |
615 | 788991U, |
616 | 2099483U, |
617 | 2099483U, |
618 | 2099557U, |
619 | 2099557U, |
620 | 1341U, |
621 | 12585025U, |
622 | 12585037U, |
623 | 1327U, |
624 | 1298U, |
625 | 1238U, |
626 | 1268U, |
627 | 100954U, |
628 | 100954U, |
629 | 109146U, |
630 | 109146U, |
631 | 12585562U, |
632 | 12585562U, |
633 | 2099391U, |
634 | 2099391U, |
635 | 27645U, |
636 | 6334912U, |
637 | 6334738U, |
638 | 6334920U, |
639 | 3485U, |
640 | 138415U, |
641 | 27838U, |
642 | 10467U, |
643 | 10715U, |
644 | 1474U, |
645 | 2099569U, |
646 | 788997U, |
647 | 788997U, |
648 | }; |
649 | |
650 | |
651 | uint32_t Bits = 0; |
652 | Bits |= OpInfo0[MI->getOpcode()] << 0; |
653 | return {AsmStrs+(Bits & 2047)-1, Bits}; |
654 | |
655 | } |
656 | |
657 | |
658 | void XCoreInstPrinter::printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O) { |
659 | O << "\t"; |
660 | |
661 | auto MnemonicInfo = getMnemonic(MI); |
662 | |
663 | O << MnemonicInfo.first; |
664 | |
665 | uint32_t Bits = MnemonicInfo.second; |
666 | assert(Bits != 0 && "Cannot print this instruction."); |
667 | |
668 | |
669 | switch ((Bits >> 11) & 3) { |
| 2 | | Control jumps to 'case 3:' at line 683 | |
|
670 | default: llvm_unreachable("Invalid command number."); |
671 | case 0: |
672 | |
673 | return; |
674 | break; |
675 | case 1: |
676 | |
677 | printOperand(MI, 0, O); |
678 | break; |
679 | case 2: |
680 | |
681 | printOperand(MI, 1, O); |
682 | break; |
683 | case 3: |
684 | |
685 | printOperand(MI, 2, O); |
| 3 | | Calling 'XCoreInstPrinter::printOperand' | |
|
686 | break; |
687 | } |
688 | |
689 | |
690 | |
691 | switch ((Bits >> 13) & 31) { |
692 | default: llvm_unreachable("Invalid command number."); |
693 | case 0: |
694 | |
695 | O << ", "; |
696 | break; |
697 | case 1: |
698 | |
699 | return; |
700 | break; |
701 | case 2: |
702 | |
703 | O << "\n"; |
704 | break; |
705 | case 3: |
706 | |
707 | O << ']'; |
708 | return; |
709 | break; |
710 | case 4: |
711 | |
712 | O << "], "; |
713 | break; |
714 | case 5: |
715 | |
716 | O << ", res["; |
717 | break; |
718 | case 6: |
719 | |
720 | O << ", ps["; |
721 | printOperand(MI, 1, O); |
722 | O << ']'; |
723 | return; |
724 | break; |
725 | case 7: |
726 | |
727 | O << "]:cp, "; |
728 | printOperand(MI, 0, O); |
729 | return; |
730 | break; |
731 | case 8: |
732 | |
733 | O << "]:dp, "; |
734 | printOperand(MI, 0, O); |
735 | return; |
736 | break; |
737 | case 9: |
738 | |
739 | O << "]:lr, "; |
740 | printOperand(MI, 0, O); |
741 | return; |
742 | break; |
743 | case 10: |
744 | |
745 | O << "]:pc, "; |
746 | printOperand(MI, 0, O); |
747 | return; |
748 | break; |
749 | case 11: |
750 | |
751 | O << "]:sp, "; |
752 | printOperand(MI, 0, O); |
753 | return; |
754 | break; |
755 | case 12: |
756 | |
757 | O << ", dp["; |
758 | printOperand(MI, 1, O); |
759 | O << ']'; |
760 | return; |
761 | break; |
762 | case 13: |
763 | |
764 | O << ", sp["; |
765 | printOperand(MI, 1, O); |
766 | O << ']'; |
767 | return; |
768 | break; |
769 | case 14: |
770 | |
771 | O << ", cp["; |
772 | printOperand(MI, 1, O); |
773 | O << ']'; |
774 | return; |
775 | break; |
776 | case 15: |
777 | |
778 | O << "], r11"; |
779 | return; |
780 | break; |
781 | case 16: |
782 | |
783 | O << "]:r"; |
784 | printOperand(MI, 0, O); |
785 | O << ", "; |
786 | printOperand(MI, 1, O); |
787 | return; |
788 | break; |
789 | } |
790 | |
791 | |
792 | |
793 | switch ((Bits >> 18) & 7) { |
794 | default: llvm_unreachable("Invalid command number."); |
795 | case 0: |
796 | |
797 | printOperand(MI, 1, O); |
798 | break; |
799 | case 1: |
800 | |
801 | printInlineJT(MI, 0, O); |
802 | return; |
803 | break; |
804 | case 2: |
805 | |
806 | printInlineJT32(MI, 0, O); |
807 | return; |
808 | break; |
809 | case 3: |
810 | |
811 | printOperand(MI, 2, O); |
812 | break; |
813 | case 4: |
814 | |
815 | printOperand(MI, 0, O); |
816 | O << ", "; |
817 | break; |
818 | } |
819 | |
820 | |
821 | |
822 | switch ((Bits >> 21) & 7) { |
823 | default: llvm_unreachable("Invalid command number."); |
824 | case 0: |
825 | |
826 | return; |
827 | break; |
828 | case 1: |
829 | |
830 | O << ", "; |
831 | break; |
832 | case 2: |
833 | |
834 | printOperand(MI, 3, O); |
835 | O << ", "; |
836 | printOperand(MI, 4, O); |
837 | return; |
838 | break; |
839 | case 3: |
840 | |
841 | O << ']'; |
842 | return; |
843 | break; |
844 | case 4: |
845 | |
846 | O << "], "; |
847 | printOperand(MI, 2, O); |
848 | return; |
849 | break; |
850 | case 5: |
851 | |
852 | printOperand(MI, 2, O); |
853 | break; |
854 | case 6: |
855 | |
856 | O << '['; |
857 | printOperand(MI, 2, O); |
858 | O << ']'; |
859 | return; |
860 | break; |
861 | case 7: |
862 | |
863 | O << "[-"; |
864 | printOperand(MI, 2, O); |
865 | O << ']'; |
866 | return; |
867 | break; |
868 | } |
869 | |
870 | |
871 | |
872 | switch ((Bits >> 24) & 7) { |
873 | default: llvm_unreachable("Invalid command number."); |
874 | case 0: |
875 | |
876 | printOperand(MI, 2, O); |
877 | break; |
878 | case 1: |
879 | |
880 | printOperand(MI, 3, O); |
881 | return; |
882 | break; |
883 | case 2: |
884 | |
885 | O << ", "; |
886 | printOperand(MI, 3, O); |
887 | O << ", "; |
888 | printOperand(MI, 4, O); |
889 | return; |
890 | break; |
891 | case 3: |
892 | |
893 | printOperand(MI, 4, O); |
894 | O << ", "; |
895 | break; |
896 | case 4: |
897 | |
898 | return; |
899 | break; |
900 | } |
901 | |
902 | |
903 | |
904 | switch ((Bits >> 27) & 3) { |
905 | default: llvm_unreachable("Invalid command number."); |
906 | case 0: |
907 | |
908 | return; |
909 | break; |
910 | case 1: |
911 | |
912 | printOperand(MI, 2, O); |
913 | O << ", "; |
914 | printOperand(MI, 3, O); |
915 | return; |
916 | break; |
917 | case 2: |
918 | |
919 | O << ", "; |
920 | printOperand(MI, 3, O); |
921 | O << ", "; |
922 | printOperand(MI, 4, O); |
923 | O << ", "; |
924 | printOperand(MI, 5, O); |
925 | return; |
926 | break; |
927 | case 3: |
928 | |
929 | printOperand(MI, 5, O); |
930 | return; |
931 | break; |
932 | } |
933 | |
934 | } |
935 | |
936 | |
937 | |
938 | |
939 | |
940 | const char *XCoreInstPrinter::getRegisterName(unsigned RegNo) { |
941 | assert(RegNo && RegNo < 17 && "Invalid register number!"); |
942 | |
943 | |
944 | #ifdef __GNUC__ |
945 | #pragma GCC diagnostic push |
946 | #pragma GCC diagnostic ignored "-Woverlength-strings" |
947 | #endif |
948 | static const char AsmStrs[] = { |
949 | "r10\0" |
950 | "r0\0" |
951 | "r11\0" |
952 | "r1\0" |
953 | "r2\0" |
954 | "r3\0" |
955 | "r4\0" |
956 | "r5\0" |
957 | "r6\0" |
958 | "r7\0" |
959 | "r8\0" |
960 | "r9\0" |
961 | "cp\0" |
962 | "dp\0" |
963 | "sp\0" |
964 | "lr\0" |
965 | }; |
966 | #ifdef __GNUC__ |
967 | #pragma GCC diagnostic pop |
968 | #endif |
969 | |
970 | static const uint8_t RegAsmOffset[] = { |
971 | 38, 41, 47, 44, 4, 11, 14, 17, 20, 23, 26, 29, 32, 35, |
972 | 0, 7, |
973 | }; |
974 | |
975 | assert (*(AsmStrs+RegAsmOffset[RegNo-1]) && |
976 | "Invalid alt name index for register!"); |
977 | return AsmStrs+RegAsmOffset[RegNo-1]; |
978 | } |
979 | |
980 | #ifdef PRINT_ALIAS_INSTR |
981 | #undef PRINT_ALIAS_INSTR |
982 | |
983 | bool XCoreInstPrinter::printAliasInstr(const MCInst *MI, uint64_t Address, raw_ostream &OS) { |
984 | return false; |
985 | } |
986 | |
987 | #endif // PRINT_ALIAS_INSTR |