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::LDAWF_l2rus);
454 return DecodeL2RUSInstruction(Inst, Insn, Address, Decoder);
456 Inst.setOpcode(XCore::LDAWB_l2rus);
457 return DecodeL2RUSInstruction(Inst, Insn, Address, Decoder);
459 Inst.setOpcode(XCore::CRC_l3r);
460 return DecodeL3RSrcDstInstruction(Inst, Insn, Address, Decoder);
462 Inst.setOpcode(XCore::REMS_l3r);
463 return DecodeL3RInstruction(Inst, Insn, Address, Decoder);
465 Inst.setOpcode(XCore::REMU_l3r);
466 return DecodeL3RInstruction(Inst, Insn, Address, Decoder);
468 return MCDisassembler::Fail;
472 DecodeL2RInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
473 const void *Decoder) {
475 DecodeStatus S = Decode2OpInstruction(fieldFromInstruction(Insn, 0, 16),
477 if (S != MCDisassembler::Success)
478 return DecodeL2OpInstructionFail(Inst, Insn, Address, Decoder);
480 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
481 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
486 DecodeLR2RInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
487 const void *Decoder) {
489 DecodeStatus S = Decode2OpInstruction(fieldFromInstruction(Insn, 0, 16),
491 if (S != MCDisassembler::Success)
492 return DecodeL2OpInstructionFail(Inst, Insn, Address, Decoder);
494 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
495 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
500 Decode3RInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
501 const void *Decoder) {
502 unsigned Op1, Op2, Op3;
503 DecodeStatus S = Decode3OpInstruction(Insn, Op1, Op2, Op3);
504 if (S == MCDisassembler::Success) {
505 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
506 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
507 DecodeGRRegsRegisterClass(Inst, Op3, Address, Decoder);
513 Decode2RUSInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
514 const void *Decoder) {
515 unsigned Op1, Op2, Op3;
516 DecodeStatus S = Decode3OpInstruction(Insn, Op1, Op2, Op3);
517 if (S == MCDisassembler::Success) {
518 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
519 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
520 Inst.addOperand(MCOperand::CreateImm(Op3));
526 Decode2RUSBitpInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
527 const void *Decoder) {
528 unsigned Op1, Op2, Op3;
529 DecodeStatus S = Decode3OpInstruction(Insn, Op1, Op2, Op3);
530 if (S == MCDisassembler::Success) {
531 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
532 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
533 DecodeBitpOperand(Inst, Op3, Address, Decoder);
539 DecodeL3RInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
540 const void *Decoder) {
541 unsigned Op1, Op2, Op3;
543 Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
544 if (S == MCDisassembler::Success) {
545 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
546 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
547 DecodeGRRegsRegisterClass(Inst, Op3, Address, Decoder);
553 DecodeL3RSrcDstInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
554 const void *Decoder) {
555 unsigned Op1, Op2, Op3;
557 Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
558 if (S == MCDisassembler::Success) {
559 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
560 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
561 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
562 DecodeGRRegsRegisterClass(Inst, Op3, Address, Decoder);
568 DecodeL2RUSInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
569 const void *Decoder) {
570 unsigned Op1, Op2, Op3;
572 Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
573 if (S == MCDisassembler::Success) {
574 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
575 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
576 Inst.addOperand(MCOperand::CreateImm(Op3));
582 DecodeL2RUSBitpInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
583 const void *Decoder) {
584 unsigned Op1, Op2, Op3;
586 Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
587 if (S == MCDisassembler::Success) {
588 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
589 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
590 DecodeBitpOperand(Inst, Op3, Address, Decoder);
596 DecodeL6RInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
597 const void *Decoder) {
598 unsigned Op1, Op2, Op3, Op4, Op5, Op6;
600 Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
601 if (S != MCDisassembler::Success)
603 S = Decode3OpInstruction(fieldFromInstruction(Insn, 16, 16), Op4, Op5, Op6);
604 if (S != MCDisassembler::Success)
606 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
607 DecodeGRRegsRegisterClass(Inst, Op4, Address, Decoder);
608 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
609 DecodeGRRegsRegisterClass(Inst, Op3, Address, Decoder);
610 DecodeGRRegsRegisterClass(Inst, Op5, Address, Decoder);
611 DecodeGRRegsRegisterClass(Inst, Op6, Address, Decoder);
616 DecodeL5RInstructionFail(MCInst &Inst, unsigned Insn, uint64_t Address,
617 const void *Decoder) {
618 // Try and decode as a L6R instruction.
620 unsigned Opcode = fieldFromInstruction(Insn, 27, 5);
623 Inst.setOpcode(XCore::LMUL_l6r);
624 return DecodeL6RInstruction(Inst, Insn, Address, Decoder);
626 return MCDisassembler::Fail;
630 DecodeL5RInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
631 const void *Decoder) {
632 unsigned Op1, Op2, Op3, Op4, Op5;
634 Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
635 if (S != MCDisassembler::Success)
636 return DecodeL5RInstructionFail(Inst, Insn, Address, Decoder);
637 S = Decode2OpInstruction(fieldFromInstruction(Insn, 16, 16), Op4, Op5);
638 if (S != MCDisassembler::Success)
639 return DecodeL5RInstructionFail(Inst, Insn, Address, Decoder);
641 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
642 DecodeGRRegsRegisterClass(Inst, Op4, Address, Decoder);
643 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
644 DecodeGRRegsRegisterClass(Inst, Op3, Address, Decoder);
645 DecodeGRRegsRegisterClass(Inst, Op5, Address, Decoder);
650 DecodeL4RSrcDstInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
651 const void *Decoder) {
652 unsigned Op1, Op2, Op3;
653 unsigned Op4 = fieldFromInstruction(Insn, 16, 4);
655 Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
656 if (S == MCDisassembler::Success) {
657 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
658 S = DecodeGRRegsRegisterClass(Inst, Op4, Address, Decoder);
660 if (S == MCDisassembler::Success) {
661 DecodeGRRegsRegisterClass(Inst, Op4, Address, Decoder);
662 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
663 DecodeGRRegsRegisterClass(Inst, Op3, Address, Decoder);
669 DecodeL4RSrcDstSrcDstInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
670 const void *Decoder) {
671 unsigned Op1, Op2, Op3;
672 unsigned Op4 = fieldFromInstruction(Insn, 16, 4);
674 Decode3OpInstruction(fieldFromInstruction(Insn, 0, 16), Op1, Op2, Op3);
675 if (S == MCDisassembler::Success) {
676 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
677 S = DecodeGRRegsRegisterClass(Inst, Op4, Address, Decoder);
679 if (S == MCDisassembler::Success) {
680 DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
681 DecodeGRRegsRegisterClass(Inst, Op4, Address, Decoder);
682 DecodeGRRegsRegisterClass(Inst, Op2, Address, Decoder);
683 DecodeGRRegsRegisterClass(Inst, Op3, Address, Decoder);
688 MCDisassembler::DecodeStatus
689 XCoreDisassembler::getInstruction(MCInst &instr,
691 const MemoryObject &Region,
693 raw_ostream &vStream,
694 raw_ostream &cStream) const {
697 if (!readInstruction16(Region, Address, Size, insn16)) {
701 // Calling the auto-generated decoder function.
702 DecodeStatus Result = decodeInstruction(DecoderTable16, instr, insn16,
704 if (Result != Fail) {
711 if (!readInstruction32(Region, Address, Size, insn32)) {
715 // Calling the auto-generated decoder function.
716 Result = decodeInstruction(DecoderTable32, instr, insn32, Address, this, STI);
717 if (Result != Fail) {
726 extern Target TheXCoreTarget;
729 static MCDisassembler *createXCoreDisassembler(const Target &T,
730 const MCSubtargetInfo &STI) {
731 return new XCoreDisassembler(STI, T.createMCRegInfo(""));
734 extern "C" void LLVMInitializeXCoreDisassembler() {
735 // Register the disassembler.
736 TargetRegistry::RegisterMCDisassembler(TheXCoreTarget,
737 createXCoreDisassembler);