1 //===- XCoreDisassembler.cpp - Disassembler for XCore -----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief This file is part of the XCore Disassembler.
13 //===----------------------------------------------------------------------===//
16 #include "XCoreRegisterInfo.h"
17 #include "llvm/MC/MCDisassembler.h"
18 #include "llvm/MC/MCFixedLenDisassembler.h"
19 #include "llvm/MC/MCInst.h"
20 #include "llvm/MC/MCSubtargetInfo.h"
21 #include "llvm/Support/MemoryObject.h"
22 #include "llvm/Support/TargetRegistry.h"
26 typedef MCDisassembler::DecodeStatus DecodeStatus;
30 /// \brief A disassembler class for XCore.
31 class XCoreDisassembler : public MCDisassembler {
32 const MCRegisterInfo *RegInfo;
34 XCoreDisassembler(const MCSubtargetInfo &STI, const MCRegisterInfo *Info) :
35 MCDisassembler(STI), RegInfo(Info) {}
37 /// \brief See MCDisassembler.
38 virtual DecodeStatus getInstruction(MCInst &instr,
40 const MemoryObject ®ion,
43 raw_ostream &cStream) const;
45 const MCRegisterInfo *getRegInfo() const { return RegInfo; }
49 static bool readInstruction16(const MemoryObject ®ion,
55 // We want to read exactly 2 Bytes of data.
56 if (region.readBytes(address, 2, Bytes, NULL) == -1) {
60 // Encoded as a little-endian 16-bit word in the stream.
61 insn = (Bytes[0] << 0) | (Bytes[1] << 8);
65 static bool readInstruction32(const MemoryObject ®ion,
71 // We want to read exactly 4 Bytes of data.
72 if (region.readBytes(address, 4, Bytes, NULL) == -1) {
76 // Encoded as a little-endian 32-bit word in the stream.
77 insn = (Bytes[0] << 0) | (Bytes[1] << 8) | (Bytes[2] << 16) |
82 static unsigned getReg(const void *D, unsigned RC, unsigned RegNo) {
83 const XCoreDisassembler *Dis = static_cast<const XCoreDisassembler*>(D);
84 return *(Dis->getRegInfo()->getRegClass(RC).begin() + RegNo);
87 static DecodeStatus DecodeGRRegsRegisterClass(MCInst &Inst,
92 static DecodeStatus DecodeBitpOperand(MCInst &Inst, unsigned Val,
93 uint64_t Address, const void *Decoder);
95 static DecodeStatus DecodeMEMiiOperand(MCInst &Inst, unsigned Val,
96 uint64_t Address, const void *Decoder);
98 static DecodeStatus Decode2RInstruction(MCInst &Inst,
101 const void *Decoder);
103 static DecodeStatus DecodeR2RInstruction(MCInst &Inst,
106 const void *Decoder);
108 static DecodeStatus Decode2RSrcDstInstruction(MCInst &Inst,
111 const void *Decoder);
113 static DecodeStatus DecodeRUSInstruction(MCInst &Inst,
116 const void *Decoder);
118 static DecodeStatus DecodeRUSBitpInstruction(MCInst &Inst,
121 const void *Decoder);
123 static DecodeStatus DecodeRUSSrcDstBitpInstruction(MCInst &Inst,
126 const void *Decoder);
128 static DecodeStatus DecodeL2RInstruction(MCInst &Inst,
131 const void *Decoder);
133 static DecodeStatus DecodeLR2RInstruction(MCInst &Inst,
136 const void *Decoder);
138 static DecodeStatus Decode3RInstruction(MCInst &Inst,
141 const void *Decoder);
143 static DecodeStatus Decode2RUSInstruction(MCInst &Inst,
146 const void *Decoder);
148 static DecodeStatus Decode2RUSBitpInstruction(MCInst &Inst,
151 const void *Decoder);
153 static DecodeStatus DecodeL3RInstruction(MCInst &Inst,
156 const void *Decoder);
158 static DecodeStatus DecodeL3RSrcDstInstruction(MCInst &Inst,
161 const void *Decoder);
163 static DecodeStatus DecodeL2RUSInstruction(MCInst &Inst,
166 const void *Decoder);
168 static DecodeStatus DecodeL2RUSBitpInstruction(MCInst &Inst,
171 const void *Decoder);
173 static DecodeStatus DecodeL6RInstruction(MCInst &Inst,
176 const void *Decoder);
178 static DecodeStatus DecodeL5RInstruction(MCInst &Inst,
181 const void *Decoder);
183 static DecodeStatus DecodeL4RSrcDstInstruction(MCInst &Inst,
186 const void *Decoder);
188 static DecodeStatus DecodeL4RSrcDstSrcDstInstruction(MCInst &Inst,
191 const void *Decoder);
193 #include "XCoreGenDisassemblerTables.inc"
195 static DecodeStatus DecodeGRRegsRegisterClass(MCInst &Inst,
201 return MCDisassembler::Fail;
202 unsigned Reg = getReg(Decoder, XCore::GRRegsRegClassID, RegNo);
203 Inst.addOperand(MCOperand::CreateReg(Reg));
204 return MCDisassembler::Success;
207 static DecodeStatus DecodeBitpOperand(MCInst &Inst, unsigned Val,
208 uint64_t Address, const void *Decoder) {
210 return MCDisassembler::Fail;
211 static unsigned Values[] = {
212 32 /*bpw*/, 1, 2, 3, 4, 5, 6, 7, 8, 16, 24, 32
214 Inst.addOperand(MCOperand::CreateImm(Values[Val]));
215 return MCDisassembler::Success;
218 static DecodeStatus DecodeMEMiiOperand(MCInst &Inst, unsigned Val,
219 uint64_t Address, const void *Decoder) {
220 Inst.addOperand(MCOperand::CreateImm(Val));
221 Inst.addOperand(MCOperand::CreateImm(0));
222 return MCDisassembler::Success;
226 Decode2OpInstruction(unsigned Insn, unsigned &Op1, unsigned &Op2) {
227 unsigned Combined = fieldFromInstruction(Insn, 6, 5);
229 return MCDisassembler::Fail;
230 if (fieldFromInstruction(Insn, 5, 1)) {
232 return MCDisassembler::Fail;
236 unsigned Op1High = Combined % 3;
237 unsigned Op2High = Combined / 3;
238 Op1 = (Op1High << 2) | fieldFromInstruction(Insn, 2, 2);
239 Op2 = (Op2High << 2) | fieldFromInstruction(Insn, 0, 2);
240 return MCDisassembler::Success;
244 Decode3OpInstruction(unsigned Insn, unsigned &Op1, unsigned &Op2,
246 unsigned Combined = fieldFromInstruction(Insn, 6, 5);
248 return MCDisassembler::Fail;
250 unsigned Op1High = Combined % 3;
251 unsigned Op2High = (Combined / 3) % 3;
252 unsigned Op3High = Combined / 9;
253 Op1 = (Op1High << 2) | fieldFromInstruction(Insn, 4, 2);
254 Op2 = (Op2High << 2) | fieldFromInstruction(Insn, 2, 2);
255 Op3 = (Op3High << 2) | fieldFromInstruction(Insn, 0, 2);
256 return MCDisassembler::Success;
260 Decode2OpInstructionFail(MCInst &Inst, unsigned Insn, uint64_t Address,
261 const void *Decoder) {
262 // Try and decode as a 3R instruction.
263 unsigned Opcode = fieldFromInstruction(Insn, 11, 5);
266 Inst.setOpcode(XCore::STW_2rus);
267 return Decode2RUSInstruction(Inst, Insn, Address, Decoder);
269 Inst.setOpcode(XCore::LDW_2rus);
270 return Decode2RUSInstruction(Inst, Insn, Address, Decoder);
272 Inst.setOpcode(XCore::ADD_3r);
273 return Decode3RInstruction(Inst, Insn, Address, Decoder);
275 Inst.setOpcode(XCore::SUB_3r);
276 return Decode3RInstruction(Inst, Insn, Address, Decoder);
278 Inst.setOpcode(XCore::SHL_3r);
279 return Decode3RInstruction(Inst, Insn, Address, Decoder);
281 Inst.setOpcode(XCore::SHR_3r);
282 return Decode3RInstruction(Inst, Insn, Address, Decoder);
284 Inst.setOpcode(XCore::EQ_3r);
285 return Decode3RInstruction(Inst, Insn, Address, Decoder);
287 Inst.setOpcode(XCore::AND_3r);
288 return Decode3RInstruction(Inst, Insn, Address, Decoder);
290 Inst.setOpcode(XCore::OR_3r);
291 return Decode3RInstruction(Inst, Insn, Address, Decoder);
293 Inst.setOpcode(XCore::LDW_3r);
294 return Decode3RInstruction(Inst, Insn, Address, Decoder);
296 Inst.setOpcode(XCore::LD16S_3r);
297 return Decode3RInstruction(Inst, Insn, Address, Decoder);
299 Inst.setOpcode(XCore::LD8U_3r);
300 return Decode3RInstruction(Inst, Insn, Address, Decoder);
302 Inst.setOpcode(XCore::ADD_2rus);
303 return Decode2RUSInstruction(Inst, Insn, Address, Decoder);
305 Inst.setOpcode(XCore::SUB_2rus);
306 return Decode2RUSInstruction(Inst, Insn, Address, Decoder);
308 Inst.setOpcode(XCore::SHL_2rus);
309 return Decode2RUSBitpInstruction(Inst, Insn, Address, Decoder);
311 Inst.setOpcode(XCore::SHR_2rus);
312 return Decode2RUSBitpInstruction(Inst, Insn, Address, Decoder);
314 Inst.setOpcode(XCore::EQ_2rus);
315 return Decode2RUSInstruction(Inst, Insn, Address, Decoder);
317 Inst.setOpcode(XCore::LSS_3r);
318 return Decode3RInstruction(Inst, Insn, Address, Decoder);
320 Inst.setOpcode(XCore::LSU_3r);
321 return Decode3RInstruction(Inst, Insn, Address, Decoder);
323 return MCDisassembler::Fail;
327 Decode2RInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
328 const void *Decoder) {
330 DecodeStatus S = Decode2OpInstruction(Insn, Op1, Op2);
331 if (S != MCDisassembler::Success)
332 return Decode2OpInstructionFail(Inst, Insn, Address, Decoder);
334 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
335 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
340 DecodeR2RInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
341 const void *Decoder) {
343 DecodeStatus S = Decode2OpInstruction(Insn, Op2, Op1);
344 if (S != MCDisassembler::Success)
345 return Decode2OpInstructionFail(Inst, Insn, Address, Decoder);
347 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
348 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
353 Decode2RSrcDstInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
354 const void *Decoder) {
356 DecodeStatus S = Decode2OpInstruction(Insn, Op1, Op2);
357 if (S != MCDisassembler::Success)
358 return Decode2OpInstructionFail(Inst, Insn, Address, Decoder);
360 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
361 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
362 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
367 DecodeRUSInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
368 const void *Decoder) {
370 DecodeStatus S = Decode2OpInstruction(Insn, Op1, Op2);
371 if (S != MCDisassembler::Success)
372 return Decode2OpInstructionFail(Inst, Insn, Address, Decoder);
374 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
375 Inst.addOperand(MCOperand::CreateImm(Op2));
380 DecodeRUSBitpInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
381 const void *Decoder) {
383 DecodeStatus S = Decode2OpInstruction(Insn, Op1, Op2);
384 if (S != MCDisassembler::Success)
385 return Decode2OpInstructionFail(Inst, Insn, Address, Decoder);
387 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
388 DecodeBitpOperand(Inst, Op2, Address, Decoder);
393 DecodeRUSSrcDstBitpInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
394 const void *Decoder) {
396 DecodeStatus S = Decode2OpInstruction(Insn, Op1, Op2);
397 if (S != MCDisassembler::Success)
398 return Decode2OpInstructionFail(Inst, Insn, Address, Decoder);
400 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
401 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
402 DecodeBitpOperand(Inst, Op2, Address, Decoder);
407 DecodeL2OpInstructionFail(MCInst &Inst, unsigned Insn, uint64_t Address,
408 const void *Decoder) {
409 // Try and decode as a L3R / L2RUS instruction.
410 unsigned Opcode = fieldFromInstruction(Insn, 16, 4) |
411 fieldFromInstruction(Insn, 27, 5) << 4;
414 Inst.setOpcode(XCore::STW_l3r);
415 return DecodeL3RInstruction(Inst, Insn, Address, Decoder);
417 Inst.setOpcode(XCore::XOR_l3r);
418 return DecodeL3RInstruction(Inst, Insn, Address, Decoder);
420 Inst.setOpcode(XCore::ASHR_l3r);
421 return DecodeL3RInstruction(Inst, Insn, Address, Decoder);
423 Inst.setOpcode(XCore::LDAWF_l3r);
424 return DecodeL3RInstruction(Inst, Insn, Address, Decoder);
426 Inst.setOpcode(XCore::LDAWB_l3r);
427 return DecodeL3RInstruction(Inst, Insn, Address, Decoder);
429 Inst.setOpcode(XCore::LDA16F_l3r);
430 return DecodeL3RInstruction(Inst, Insn, Address, Decoder);
432 Inst.setOpcode(XCore::LDA16B_l3r);
433 return DecodeL3RInstruction(Inst, Insn, Address, Decoder);
435 Inst.setOpcode(XCore::MUL_l3r);
436 return DecodeL3RInstruction(Inst, Insn, Address, Decoder);
438 Inst.setOpcode(XCore::DIVS_l3r);
439 return DecodeL3RInstruction(Inst, Insn, Address, Decoder);
441 Inst.setOpcode(XCore::DIVU_l3r);
442 return DecodeL3RInstruction(Inst, Insn, Address, Decoder);
444 Inst.setOpcode(XCore::ST16_l3r);
445 return DecodeL3RInstruction(Inst, Insn, Address, Decoder);
447 Inst.setOpcode(XCore::ST8_l3r);
448 return DecodeL3RInstruction(Inst, Insn, Address, Decoder);
450 Inst.setOpcode(XCore::ASHR_l2rus);
451 return DecodeL2RUSBitpInstruction(Inst, Insn, Address, Decoder);
453 Inst.setOpcode(XCore::OUTPW_l2rus);
454 return DecodeL2RUSBitpInstruction(Inst, Insn, Address, Decoder);
456 Inst.setOpcode(XCore::INPW_l2rus);
457 return DecodeL2RUSBitpInstruction(Inst, Insn, Address, Decoder);
459 Inst.setOpcode(XCore::LDAWF_l2rus);
460 return DecodeL2RUSInstruction(Inst, Insn, Address, Decoder);
462 Inst.setOpcode(XCore::LDAWB_l2rus);
463 return DecodeL2RUSInstruction(Inst, Insn, Address, Decoder);
465 Inst.setOpcode(XCore::CRC_l3r);
466 return DecodeL3RSrcDstInstruction(Inst, Insn, Address, Decoder);
468 Inst.setOpcode(XCore::REMS_l3r);
469 return DecodeL3RInstruction(Inst, Insn, Address, Decoder);
471 Inst.setOpcode(XCore::REMU_l3r);
472 return DecodeL3RInstruction(Inst, Insn, Address, Decoder);
474 return MCDisassembler::Fail;
478 DecodeL2RInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
479 const void *Decoder) {
481 DecodeStatus S = Decode2OpInstruction(fieldFromInstruction(Insn, 0, 16),
483 if (S != MCDisassembler::Success)
484 return DecodeL2OpInstructionFail(Inst, Insn, Address, Decoder);
486 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
487 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
492 DecodeLR2RInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
493 const void *Decoder) {
495 DecodeStatus S = Decode2OpInstruction(fieldFromInstruction(Insn, 0, 16),
497 if (S != MCDisassembler::Success)
498 return DecodeL2OpInstructionFail(Inst, Insn, Address, Decoder);
500 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
501 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
506 Decode3RInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
507 const void *Decoder) {
508 unsigned Op1, Op2, Op3;
509 DecodeStatus S = Decode3OpInstruction(Insn, Op1, Op2, Op3);
510 if (S == MCDisassembler::Success) {
511 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
512 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
513 DecodeGRRegsRegisterClass(Inst, Op3, Address, Decoder);
519 Decode2RUSInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
520 const void *Decoder) {
521 unsigned Op1, Op2, Op3;
522 DecodeStatus S = Decode3OpInstruction(Insn, Op1, Op2, Op3);
523 if (S == MCDisassembler::Success) {
524 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
525 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
526 Inst.addOperand(MCOperand::CreateImm(Op3));
532 Decode2RUSBitpInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
533 const void *Decoder) {
534 unsigned Op1, Op2, Op3;
535 DecodeStatus S = Decode3OpInstruction(Insn, Op1, Op2, Op3);
536 if (S == MCDisassembler::Success) {
537 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
538 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
539 DecodeBitpOperand(Inst, Op3, Address, Decoder);
545 DecodeL3RInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
546 const void *Decoder) {
547 unsigned Op1, Op2, Op3;
549 Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
550 if (S == MCDisassembler::Success) {
551 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
552 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
553 DecodeGRRegsRegisterClass(Inst, Op3, Address, Decoder);
559 DecodeL3RSrcDstInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
560 const void *Decoder) {
561 unsigned Op1, Op2, Op3;
563 Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
564 if (S == MCDisassembler::Success) {
565 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
566 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
567 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
568 DecodeGRRegsRegisterClass(Inst, Op3, Address, Decoder);
574 DecodeL2RUSInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
575 const void *Decoder) {
576 unsigned Op1, Op2, Op3;
578 Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
579 if (S == MCDisassembler::Success) {
580 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
581 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
582 Inst.addOperand(MCOperand::CreateImm(Op3));
588 DecodeL2RUSBitpInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
589 const void *Decoder) {
590 unsigned Op1, Op2, Op3;
592 Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
593 if (S == MCDisassembler::Success) {
594 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
595 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
596 DecodeBitpOperand(Inst, Op3, Address, Decoder);
602 DecodeL6RInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
603 const void *Decoder) {
604 unsigned Op1, Op2, Op3, Op4, Op5, Op6;
606 Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
607 if (S != MCDisassembler::Success)
609 S = Decode3OpInstruction(fieldFromInstruction(Insn, 16, 16), Op4, Op5, Op6);
610 if (S != MCDisassembler::Success)
612 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
613 DecodeGRRegsRegisterClass(Inst, Op4, Address, Decoder);
614 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
615 DecodeGRRegsRegisterClass(Inst, Op3, Address, Decoder);
616 DecodeGRRegsRegisterClass(Inst, Op5, Address, Decoder);
617 DecodeGRRegsRegisterClass(Inst, Op6, Address, Decoder);
622 DecodeL5RInstructionFail(MCInst &Inst, unsigned Insn, uint64_t Address,
623 const void *Decoder) {
624 // Try and decode as a L6R instruction.
626 unsigned Opcode = fieldFromInstruction(Insn, 27, 5);
629 Inst.setOpcode(XCore::LMUL_l6r);
630 return DecodeL6RInstruction(Inst, Insn, Address, Decoder);
632 return MCDisassembler::Fail;
636 DecodeL5RInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
637 const void *Decoder) {
638 unsigned Op1, Op2, Op3, Op4, Op5;
640 Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
641 if (S != MCDisassembler::Success)
642 return DecodeL5RInstructionFail(Inst, Insn, Address, Decoder);
643 S = Decode2OpInstruction(fieldFromInstruction(Insn, 16, 16), Op4, Op5);
644 if (S != MCDisassembler::Success)
645 return DecodeL5RInstructionFail(Inst, Insn, Address, Decoder);
647 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
648 DecodeGRRegsRegisterClass(Inst, Op4, Address, Decoder);
649 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
650 DecodeGRRegsRegisterClass(Inst, Op3, Address, Decoder);
651 DecodeGRRegsRegisterClass(Inst, Op5, Address, Decoder);
656 DecodeL4RSrcDstInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
657 const void *Decoder) {
658 unsigned Op1, Op2, Op3;
659 unsigned Op4 = fieldFromInstruction(Insn, 16, 4);
661 Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
662 if (S == MCDisassembler::Success) {
663 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
664 S = DecodeGRRegsRegisterClass(Inst, Op4, Address, Decoder);
666 if (S == MCDisassembler::Success) {
667 DecodeGRRegsRegisterClass(Inst, Op4, Address, Decoder);
668 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
669 DecodeGRRegsRegisterClass(Inst, Op3, Address, Decoder);
675 DecodeL4RSrcDstSrcDstInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
676 const void *Decoder) {
677 unsigned Op1, Op2, Op3;
678 unsigned Op4 = fieldFromInstruction(Insn, 16, 4);
680 Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
681 if (S == MCDisassembler::Success) {
682 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
683 S = DecodeGRRegsRegisterClass(Inst, Op4, Address, Decoder);
685 if (S == MCDisassembler::Success) {
686 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
687 DecodeGRRegsRegisterClass(Inst, Op4, Address, Decoder);
688 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
689 DecodeGRRegsRegisterClass(Inst, Op3, Address, Decoder);
694 MCDisassembler::DecodeStatus
695 XCoreDisassembler::getInstruction(MCInst &instr,
697 const MemoryObject &Region,
699 raw_ostream &vStream,
700 raw_ostream &cStream) const {
703 if (!readInstruction16(Region, Address, Size, insn16)) {
707 // Calling the auto-generated decoder function.
708 DecodeStatus Result = decodeInstruction(DecoderTable16, instr, insn16,
710 if (Result != Fail) {
717 if (!readInstruction32(Region, Address, Size, insn32)) {
721 // Calling the auto-generated decoder function.
722 Result = decodeInstruction(DecoderTable32, instr, insn32, Address, this, STI);
723 if (Result != Fail) {
732 extern Target TheXCoreTarget;
735 static MCDisassembler *createXCoreDisassembler(const Target &T,
736 const MCSubtargetInfo &STI) {
737 return new XCoreDisassembler(STI, T.createMCRegInfo(""));
740 extern "C" void LLVMInitializeXCoreDisassembler() {
741 // Register the disassembler.
742 TargetRegistry::RegisterMCDisassembler(TheXCoreTarget,
743 createXCoreDisassembler);