1 //===- MBlazeDisassembler.cpp - Disassembler for MicroBlaze ----*- 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 //===----------------------------------------------------------------------===//
10 // This file is part of the MBlaze Disassembler. It contains code to translate
11 // the data produced by the decoder into MCInsts.
13 //===----------------------------------------------------------------------===//
16 #include "MBlazeInstrInfo.h"
17 #include "MBlazeDisassembler.h"
19 #include "llvm/MC/EDInstInfo.h"
20 #include "llvm/MC/MCDisassembler.h"
21 #include "llvm/MC/MCDisassembler.h"
22 #include "llvm/MC/MCInst.h"
23 #include "llvm/Target/TargetRegistry.h"
24 #include "llvm/Support/Debug.h"
25 #include "llvm/Support/MemoryObject.h"
26 #include "llvm/Support/raw_ostream.h"
28 // #include "MBlazeGenDecoderTables.inc"
29 // #include "MBlazeGenRegisterNames.inc"
30 #include "MBlazeGenInstrInfo.inc"
31 #include "MBlazeGenEDInfo.inc"
35 const unsigned UNSUPPORTED = -1;
37 static unsigned mblazeBinary2Opcode[] = {
38 MBlaze::ADD, MBlaze::RSUB, MBlaze::ADDC, MBlaze::RSUBC, //00,01,02,03
39 MBlaze::ADDK, MBlaze::RSUBK, MBlaze::ADDKC, MBlaze::RSUBKC, //04,05,06,07
40 MBlaze::ADDI, MBlaze::RSUBI, MBlaze::ADDIC, MBlaze::RSUBIC, //08,09,0A,0B
41 MBlaze::ADDIK, MBlaze::RSUBIK, MBlaze::ADDIKC, MBlaze::RSUBIKC, //0C,0D,0E,0F
43 MBlaze::MUL, MBlaze::BSRL, MBlaze::IDIV, MBlaze::GETD, //10,11,12,13
44 UNSUPPORTED, UNSUPPORTED, MBlaze::FADD, UNSUPPORTED, //14,15,16,17
45 MBlaze::MULI, MBlaze::BSRLI, UNSUPPORTED, MBlaze::GET, //18,19,1A,1B
46 UNSUPPORTED, UNSUPPORTED, UNSUPPORTED, UNSUPPORTED, //1C,1D,1E,1F
48 MBlaze::OR, MBlaze::AND, MBlaze::XOR, MBlaze::ANDN, //20,21,22,23
49 MBlaze::SEXT8, MBlaze::MFS, MBlaze::BR, MBlaze::BEQ, //24,25,26,27
50 MBlaze::ORI, MBlaze::ANDI, MBlaze::XORI, MBlaze::ANDNI, //28,29,2A,2B
51 MBlaze::IMM, MBlaze::RTSD, MBlaze::BRI, MBlaze::BEQI, //2C,2D,2E,2F
53 MBlaze::LBU, MBlaze::LHU, MBlaze::LW, UNSUPPORTED, //30,31,32,33
54 MBlaze::SB, MBlaze::SH, MBlaze::SW, UNSUPPORTED, //34,35,36,37
55 MBlaze::LBUI, MBlaze::LHUI, MBlaze::LWI, UNSUPPORTED, //38,39,3A,3B
56 MBlaze::SBI, MBlaze::SHI, MBlaze::SWI, UNSUPPORTED, //3C,3D,3E,3F
59 static unsigned getRD(uint32_t insn) {
60 if (!MBlazeRegisterInfo::isRegister((insn>>21)&0x1F))
62 return MBlazeRegisterInfo::getRegisterFromNumbering((insn>>21)&0x1F);
65 static unsigned getRA(uint32_t insn) {
66 if (!MBlazeRegisterInfo::getRegisterFromNumbering((insn>>16)&0x1F))
68 return MBlazeRegisterInfo::getRegisterFromNumbering((insn>>16)&0x1F);
71 static unsigned getRB(uint32_t insn) {
72 if (!MBlazeRegisterInfo::getRegisterFromNumbering((insn>>11)&0x1F))
74 return MBlazeRegisterInfo::getRegisterFromNumbering((insn>>11)&0x1F);
77 static int64_t getRS(uint32_t insn) {
78 if (!MBlazeRegisterInfo::isSpecialRegister(insn&0x3FFF))
80 return MBlazeRegisterInfo::getSpecialRegisterFromNumbering(insn&0x3FFF);
83 static int64_t getIMM(uint32_t insn) {
84 int16_t val = (insn & 0xFFFF);
88 static int64_t getSHT(uint32_t insn) {
89 int16_t val = (insn & 0x1F);
93 static unsigned getFLAGS(int32_t insn) {
94 return (insn & 0x7FF);
97 static int64_t getFSL(uint32_t insn) {
98 int16_t val = (insn & 0xF);
102 static unsigned decodeMUL(uint32_t insn) {
103 switch (getFLAGS(insn)) {
104 default: return UNSUPPORTED;
105 case 0: return MBlaze::MUL;
106 case 1: return MBlaze::MULH;
107 case 2: return MBlaze::MULHSU;
108 case 3: return MBlaze::MULHU;
112 static unsigned decodeSEXT(uint32_t insn) {
113 switch (insn&0x7FF) {
114 default: return UNSUPPORTED;
115 case 0x60: return MBlaze::SEXT8;
116 case 0x68: return MBlaze::WIC;
117 case 0x64: return MBlaze::WDC;
118 case 0x66: return MBlaze::WDCC;
119 case 0x74: return MBlaze::WDCF;
120 case 0x61: return MBlaze::SEXT16;
121 case 0x41: return MBlaze::SRL;
122 case 0x21: return MBlaze::SRC;
123 case 0x01: return MBlaze::SRA;
127 static unsigned decodeBEQ(uint32_t insn) {
128 switch ((insn>>21)&0x1F) {
129 default: return UNSUPPORTED;
130 case 0x00: return MBlaze::BEQ;
131 case 0x10: return MBlaze::BEQD;
132 case 0x05: return MBlaze::BGE;
133 case 0x15: return MBlaze::BGED;
134 case 0x04: return MBlaze::BGT;
135 case 0x14: return MBlaze::BGTD;
136 case 0x03: return MBlaze::BLE;
137 case 0x13: return MBlaze::BLED;
138 case 0x02: return MBlaze::BLT;
139 case 0x12: return MBlaze::BLTD;
140 case 0x01: return MBlaze::BNE;
141 case 0x11: return MBlaze::BNED;
145 static unsigned decodeBEQI(uint32_t insn) {
146 switch ((insn>>21)&0x1F) {
147 default: return UNSUPPORTED;
148 case 0x00: return MBlaze::BEQI;
149 case 0x10: return MBlaze::BEQID;
150 case 0x05: return MBlaze::BGEI;
151 case 0x15: return MBlaze::BGEID;
152 case 0x04: return MBlaze::BGTI;
153 case 0x14: return MBlaze::BGTID;
154 case 0x03: return MBlaze::BLEI;
155 case 0x13: return MBlaze::BLEID;
156 case 0x02: return MBlaze::BLTI;
157 case 0x12: return MBlaze::BLTID;
158 case 0x01: return MBlaze::BNEI;
159 case 0x11: return MBlaze::BNEID;
163 static unsigned decodeBR(uint32_t insn) {
164 switch ((insn>>16)&0x1F) {
165 default: return UNSUPPORTED;
166 case 0x00: return MBlaze::BR;
167 case 0x08: return MBlaze::BRA;
168 case 0x0C: return MBlaze::BRK;
169 case 0x10: return MBlaze::BRD;
170 case 0x14: return MBlaze::BRLD;
171 case 0x18: return MBlaze::BRAD;
172 case 0x1C: return MBlaze::BRALD;
176 static unsigned decodeBRI(uint32_t insn) {
177 switch ((insn>>16)&0x1F) {
178 default: return UNSUPPORTED;
179 case 0x00: return MBlaze::BRI;
180 case 0x08: return MBlaze::BRAI;
181 case 0x0C: return MBlaze::BRKI;
182 case 0x10: return MBlaze::BRID;
183 case 0x14: return MBlaze::BRLID;
184 case 0x18: return MBlaze::BRAID;
185 case 0x1C: return MBlaze::BRALID;
189 static unsigned decodeBSRL(uint32_t insn) {
190 switch ((insn>>9)&0x3) {
191 default: return UNSUPPORTED;
192 case 0x2: return MBlaze::BSLL;
193 case 0x1: return MBlaze::BSRA;
194 case 0x0: return MBlaze::BSRL;
198 static unsigned decodeBSRLI(uint32_t insn) {
199 switch ((insn>>9)&0x3) {
200 default: return UNSUPPORTED;
201 case 0x2: return MBlaze::BSLLI;
202 case 0x1: return MBlaze::BSRAI;
203 case 0x0: return MBlaze::BSRLI;
207 static unsigned decodeRSUBK(uint32_t insn) {
208 switch (getFLAGS(insn)) {
209 default: return UNSUPPORTED;
210 case 0x0: return MBlaze::RSUBK;
211 case 0x1: return MBlaze::CMP;
212 case 0x3: return MBlaze::CMPU;
216 static unsigned decodeFADD(uint32_t insn) {
217 switch (getFLAGS(insn)) {
218 default: return UNSUPPORTED;
219 case 0x000: return MBlaze::FADD;
220 case 0x080: return MBlaze::FRSUB;
221 case 0x100: return MBlaze::FMUL;
222 case 0x180: return MBlaze::FDIV;
223 case 0x200: return MBlaze::FCMP_UN;
224 case 0x210: return MBlaze::FCMP_LT;
225 case 0x220: return MBlaze::FCMP_EQ;
226 case 0x230: return MBlaze::FCMP_LE;
227 case 0x240: return MBlaze::FCMP_GT;
228 case 0x250: return MBlaze::FCMP_NE;
229 case 0x260: return MBlaze::FCMP_GE;
230 case 0x280: return MBlaze::FLT;
231 case 0x300: return MBlaze::FINT;
232 case 0x380: return MBlaze::FSQRT;
236 static unsigned decodeGET(uint32_t insn) {
237 switch ((insn>>10)&0x3F) {
238 default: return UNSUPPORTED;
239 case 0x00: return MBlaze::GET;
240 case 0x01: return MBlaze::EGET;
241 case 0x02: return MBlaze::AGET;
242 case 0x03: return MBlaze::EAGET;
243 case 0x04: return MBlaze::TGET;
244 case 0x05: return MBlaze::TEGET;
245 case 0x06: return MBlaze::TAGET;
246 case 0x07: return MBlaze::TEAGET;
247 case 0x08: return MBlaze::CGET;
248 case 0x09: return MBlaze::ECGET;
249 case 0x0A: return MBlaze::CAGET;
250 case 0x0B: return MBlaze::ECAGET;
251 case 0x0C: return MBlaze::TCGET;
252 case 0x0D: return MBlaze::TECGET;
253 case 0x0E: return MBlaze::TCAGET;
254 case 0x0F: return MBlaze::TECAGET;
255 case 0x10: return MBlaze::NGET;
256 case 0x11: return MBlaze::NEGET;
257 case 0x12: return MBlaze::NAGET;
258 case 0x13: return MBlaze::NEAGET;
259 case 0x14: return MBlaze::TNGET;
260 case 0x15: return MBlaze::TNEGET;
261 case 0x16: return MBlaze::TNAGET;
262 case 0x17: return MBlaze::TNEAGET;
263 case 0x18: return MBlaze::NCGET;
264 case 0x19: return MBlaze::NECGET;
265 case 0x1A: return MBlaze::NCAGET;
266 case 0x1B: return MBlaze::NECAGET;
267 case 0x1C: return MBlaze::TNCGET;
268 case 0x1D: return MBlaze::TNECGET;
269 case 0x1E: return MBlaze::TNCAGET;
270 case 0x1F: return MBlaze::TNECAGET;
271 case 0x20: return MBlaze::PUT;
272 case 0x22: return MBlaze::APUT;
273 case 0x24: return MBlaze::TPUT;
274 case 0x26: return MBlaze::TAPUT;
275 case 0x28: return MBlaze::CPUT;
276 case 0x2A: return MBlaze::CAPUT;
277 case 0x2C: return MBlaze::TCPUT;
278 case 0x2E: return MBlaze::TCAPUT;
279 case 0x30: return MBlaze::NPUT;
280 case 0x32: return MBlaze::NAPUT;
281 case 0x34: return MBlaze::TNPUT;
282 case 0x36: return MBlaze::TNAPUT;
283 case 0x38: return MBlaze::NCPUT;
284 case 0x3A: return MBlaze::NCAPUT;
285 case 0x3C: return MBlaze::TNCPUT;
286 case 0x3E: return MBlaze::TNCAPUT;
290 static unsigned decodeGETD(uint32_t insn) {
291 switch ((insn>>5)&0x3F) {
292 default: return UNSUPPORTED;
293 case 0x00: return MBlaze::GETD;
294 case 0x01: return MBlaze::EGETD;
295 case 0x02: return MBlaze::AGETD;
296 case 0x03: return MBlaze::EAGETD;
297 case 0x04: return MBlaze::TGETD;
298 case 0x05: return MBlaze::TEGETD;
299 case 0x06: return MBlaze::TAGETD;
300 case 0x07: return MBlaze::TEAGETD;
301 case 0x08: return MBlaze::CGETD;
302 case 0x09: return MBlaze::ECGETD;
303 case 0x0A: return MBlaze::CAGETD;
304 case 0x0B: return MBlaze::ECAGETD;
305 case 0x0C: return MBlaze::TCGETD;
306 case 0x0D: return MBlaze::TECGETD;
307 case 0x0E: return MBlaze::TCAGETD;
308 case 0x0F: return MBlaze::TECAGETD;
309 case 0x10: return MBlaze::NGETD;
310 case 0x11: return MBlaze::NEGETD;
311 case 0x12: return MBlaze::NAGETD;
312 case 0x13: return MBlaze::NEAGETD;
313 case 0x14: return MBlaze::TNGETD;
314 case 0x15: return MBlaze::TNEGETD;
315 case 0x16: return MBlaze::TNAGETD;
316 case 0x17: return MBlaze::TNEAGETD;
317 case 0x18: return MBlaze::NCGETD;
318 case 0x19: return MBlaze::NECGETD;
319 case 0x1A: return MBlaze::NCAGETD;
320 case 0x1B: return MBlaze::NECAGETD;
321 case 0x1C: return MBlaze::TNCGETD;
322 case 0x1D: return MBlaze::TNECGETD;
323 case 0x1E: return MBlaze::TNCAGETD;
324 case 0x1F: return MBlaze::TNECAGETD;
325 case 0x20: return MBlaze::PUTD;
326 case 0x22: return MBlaze::APUTD;
327 case 0x24: return MBlaze::TPUTD;
328 case 0x26: return MBlaze::TAPUTD;
329 case 0x28: return MBlaze::CPUTD;
330 case 0x2A: return MBlaze::CAPUTD;
331 case 0x2C: return MBlaze::TCPUTD;
332 case 0x2E: return MBlaze::TCAPUTD;
333 case 0x30: return MBlaze::NPUTD;
334 case 0x32: return MBlaze::NAPUTD;
335 case 0x34: return MBlaze::TNPUTD;
336 case 0x36: return MBlaze::TNAPUTD;
337 case 0x38: return MBlaze::NCPUTD;
338 case 0x3A: return MBlaze::NCAPUTD;
339 case 0x3C: return MBlaze::TNCPUTD;
340 case 0x3E: return MBlaze::TNCAPUTD;
344 static unsigned decodeIDIV(uint32_t insn) {
346 default: return UNSUPPORTED;
347 case 0x0: return MBlaze::IDIV;
348 case 0x2: return MBlaze::IDIVU;
352 static unsigned decodeLBU(uint32_t insn) {
353 switch ((insn>>9)&0x1) {
354 default: return UNSUPPORTED;
355 case 0x0: return MBlaze::LBU;
356 case 0x1: return MBlaze::LBUR;
360 static unsigned decodeLHU(uint32_t insn) {
361 switch ((insn>>9)&0x1) {
362 default: return UNSUPPORTED;
363 case 0x0: return MBlaze::LHU;
364 case 0x1: return MBlaze::LHUR;
368 static unsigned decodeLW(uint32_t insn) {
369 switch ((insn>>9)&0x3) {
370 default: return UNSUPPORTED;
371 case 0x0: return MBlaze::LW;
372 case 0x1: return MBlaze::LWR;
373 case 0x2: return MBlaze::LWX;
377 static unsigned decodeSB(uint32_t insn) {
378 switch ((insn>>9)&0x1) {
379 default: return UNSUPPORTED;
380 case 0x0: return MBlaze::SB;
381 case 0x1: return MBlaze::SBR;
385 static unsigned decodeSH(uint32_t insn) {
386 switch ((insn>>9)&0x1) {
387 default: return UNSUPPORTED;
388 case 0x0: return MBlaze::SH;
389 case 0x1: return MBlaze::SHR;
393 static unsigned decodeSW(uint32_t insn) {
394 switch ((insn>>9)&0x3) {
395 default: return UNSUPPORTED;
396 case 0x0: return MBlaze::SW;
397 case 0x1: return MBlaze::SWR;
398 case 0x2: return MBlaze::SWX;
402 static unsigned decodeMFS(uint32_t insn) {
403 switch ((insn>>15)&0x1) {
404 default: return UNSUPPORTED;
406 switch ((insn>>16)&0x1) {
407 default: return UNSUPPORTED;
408 case 0x0: return MBlaze::MSRSET;
409 case 0x1: return MBlaze::MSRCLR;
412 switch ((insn>>14)&0x1) {
413 default: return UNSUPPORTED;
414 case 0x0: return MBlaze::MFS;
415 case 0x1: return MBlaze::MTS;
420 static unsigned decodeOR(uint32_t insn) {
421 switch (getFLAGS(insn)) {
422 default: return UNSUPPORTED;
423 case 0x000: return MBlaze::OR;
424 case 0x400: return MBlaze::PCMPBF;
428 static unsigned decodeXOR(uint32_t insn) {
429 switch (getFLAGS(insn)) {
430 default: return UNSUPPORTED;
431 case 0x000: return MBlaze::XOR;
432 case 0x400: return MBlaze::PCMPEQ;
436 static unsigned decodeANDN(uint32_t insn) {
437 switch (getFLAGS(insn)) {
438 default: return UNSUPPORTED;
439 case 0x000: return MBlaze::ANDN;
440 case 0x400: return MBlaze::PCMPNE;
444 static unsigned decodeRTSD(uint32_t insn) {
445 switch ((insn>>21)&0x1F) {
446 default: return UNSUPPORTED;
447 case 0x10: return MBlaze::RTSD;
448 case 0x11: return MBlaze::RTID;
449 case 0x12: return MBlaze::RTBD;
450 case 0x14: return MBlaze::RTED;
454 static unsigned getOPCODE(uint32_t insn) {
455 unsigned opcode = mblazeBinary2Opcode[ (insn>>26)&0x3F ];
457 case MBlaze::MUL: return decodeMUL(insn);
458 case MBlaze::SEXT8: return decodeSEXT(insn);
459 case MBlaze::BEQ: return decodeBEQ(insn);
460 case MBlaze::BEQI: return decodeBEQI(insn);
461 case MBlaze::BR: return decodeBR(insn);
462 case MBlaze::BRI: return decodeBRI(insn);
463 case MBlaze::BSRL: return decodeBSRL(insn);
464 case MBlaze::BSRLI: return decodeBSRLI(insn);
465 case MBlaze::RSUBK: return decodeRSUBK(insn);
466 case MBlaze::FADD: return decodeFADD(insn);
467 case MBlaze::GET: return decodeGET(insn);
468 case MBlaze::GETD: return decodeGETD(insn);
469 case MBlaze::IDIV: return decodeIDIV(insn);
470 case MBlaze::LBU: return decodeLBU(insn);
471 case MBlaze::LHU: return decodeLHU(insn);
472 case MBlaze::LW: return decodeLW(insn);
473 case MBlaze::SB: return decodeSB(insn);
474 case MBlaze::SH: return decodeSH(insn);
475 case MBlaze::SW: return decodeSW(insn);
476 case MBlaze::MFS: return decodeMFS(insn);
477 case MBlaze::OR: return decodeOR(insn);
478 case MBlaze::XOR: return decodeXOR(insn);
479 case MBlaze::ANDN: return decodeANDN(insn);
480 case MBlaze::RTSD: return decodeRTSD(insn);
481 default: return opcode;
485 EDInstInfo *MBlazeDisassembler::getEDInfo() const {
486 return instInfoMBlaze;
490 // Public interface for the disassembler
493 bool MBlazeDisassembler::getInstruction(MCInst &instr,
495 const MemoryObject ®ion,
497 raw_ostream &vStream) const {
498 // The machine instruction.
503 // By default we consume 1 byte on failure
506 // We want to read exactly 4 bytes of data.
507 if (region.readBytes(address, 4, (uint8_t*)bytes, &read) == -1 || read < 4)
510 // Encoded as a big-endian 32-bit word in the stream.
511 insn = (bytes[0]<<24) | (bytes[1]<<16) | (bytes[2]<< 8) | (bytes[3]<<0);
513 // Get the MCInst opcode from the binary instruction and make sure
514 // that it is a valid instruction.
515 unsigned opcode = getOPCODE(insn);
516 if (opcode == UNSUPPORTED)
519 instr.setOpcode(opcode);
521 unsigned RD = getRD(insn);
522 unsigned RA = getRA(insn);
523 unsigned RB = getRB(insn);
524 unsigned RS = getRS(insn);
526 uint64_t tsFlags = MBlazeInsts[opcode].TSFlags;
527 switch ((tsFlags & MBlazeII::FormMask)) {
531 case MBlazeII::FRRRR:
532 if (RD == UNSUPPORTED || RA == UNSUPPORTED || RB == UNSUPPORTED)
534 instr.addOperand(MCOperand::CreateReg(RD));
535 instr.addOperand(MCOperand::CreateReg(RB));
536 instr.addOperand(MCOperand::CreateReg(RA));
540 if (RD == UNSUPPORTED || RA == UNSUPPORTED || RB == UNSUPPORTED)
542 instr.addOperand(MCOperand::CreateReg(RD));
543 instr.addOperand(MCOperand::CreateReg(RA));
544 instr.addOperand(MCOperand::CreateReg(RB));
552 if (RD == UNSUPPORTED)
554 instr.addOperand(MCOperand::CreateReg(RD));
555 instr.addOperand(MCOperand::CreateImm(insn&0x3FFF));
558 if (RA == UNSUPPORTED)
560 instr.addOperand(MCOperand::CreateImm(insn&0x3FFF));
561 instr.addOperand(MCOperand::CreateReg(RA));
565 if (RD == UNSUPPORTED)
567 instr.addOperand(MCOperand::CreateReg(RD));
568 instr.addOperand(MCOperand::CreateImm(insn&0x7FFF));
574 if (RD == UNSUPPORTED || RA == UNSUPPORTED)
576 instr.addOperand(MCOperand::CreateReg(RD));
577 instr.addOperand(MCOperand::CreateReg(RA));
580 instr.addOperand(MCOperand::CreateImm(getIMM(insn)));
585 instr.addOperand(MCOperand::CreateImm(insn&0x1F));
591 if (RA == UNSUPPORTED || RB == UNSUPPORTED)
593 instr.addOperand(MCOperand::CreateReg(RA));
594 instr.addOperand(MCOperand::CreateReg(RB));
598 if (RA == UNSUPPORTED)
600 instr.addOperand(MCOperand::CreateReg(RA));
601 instr.addOperand(MCOperand::CreateImm(getIMM(insn)));
605 if (RD == UNSUPPORTED || RB == UNSUPPORTED)
607 instr.addOperand(MCOperand::CreateReg(RD));
608 instr.addOperand(MCOperand::CreateReg(RB));
612 if (RD == UNSUPPORTED)
614 instr.addOperand(MCOperand::CreateReg(RD));
615 instr.addOperand(MCOperand::CreateImm(getIMM(insn)));
619 if (RB == UNSUPPORTED)
621 instr.addOperand(MCOperand::CreateReg(RB));
625 instr.addOperand(MCOperand::CreateImm(getIMM(insn)));
628 case MBlazeII::FRRCI:
629 if (RD == UNSUPPORTED || RA == UNSUPPORTED)
631 instr.addOperand(MCOperand::CreateReg(RD));
632 instr.addOperand(MCOperand::CreateReg(RA));
633 instr.addOperand(MCOperand::CreateImm(getSHT(insn)));
637 if (RD == UNSUPPORTED || RA == UNSUPPORTED)
639 instr.addOperand(MCOperand::CreateReg(RD));
640 instr.addOperand(MCOperand::CreateReg(RA));
644 if (RD == UNSUPPORTED)
646 instr.addOperand(MCOperand::CreateReg(RD));
647 instr.addOperand(MCOperand::CreateImm(getFSL(insn)));
651 if (RD == UNSUPPORTED || RS == UNSUPPORTED)
653 instr.addOperand(MCOperand::CreateReg(RD));
654 instr.addOperand(MCOperand::CreateReg(RS));
657 case MBlazeII::FCRCS:
658 if (RS == UNSUPPORTED || RA == UNSUPPORTED)
660 instr.addOperand(MCOperand::CreateReg(RS));
661 instr.addOperand(MCOperand::CreateReg(RA));
664 case MBlazeII::FCRCX:
665 if (RA == UNSUPPORTED)
667 instr.addOperand(MCOperand::CreateReg(RA));
668 instr.addOperand(MCOperand::CreateImm(getFSL(insn)));
672 instr.addOperand(MCOperand::CreateImm(getFSL(insn)));
676 if (RB == UNSUPPORTED)
678 instr.addOperand(MCOperand::CreateReg(RB));
682 if (RD == UNSUPPORTED || RA == UNSUPPORTED)
684 instr.addOperand(MCOperand::CreateReg(RD));
685 instr.addOperand(MCOperand::CreateImm(getIMM(insn)));
686 instr.addOperand(MCOperand::CreateReg(RA));
690 // We always consume 4 bytes of data on success
696 static MCDisassembler *createMBlazeDisassembler(const Target &T) {
697 return new MBlazeDisassembler;
700 extern "C" void LLVMInitializeMBlazeDisassembler() {
701 // Register the disassembler.
702 TargetRegistry::RegisterMCDisassembler(TheMBlazeTarget,
703 createMBlazeDisassembler);