Teach the MBlaze disassembler to disassemble special purpose registers.
authorWesley Peck <peckw@wesleypeck.com>
Mon, 20 Dec 2010 21:18:04 +0000 (21:18 +0000)
committerWesley Peck <peckw@wesleypeck.com>
Mon, 20 Dec 2010 21:18:04 +0000 (21:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122269 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/MBlaze/Disassembler/MBlazeDisassembler.cpp
lib/Target/MBlaze/MBlazeInstrInfo.td
test/MC/Disassembler/MBlaze/mblaze_special.txt

index b2a2474422857cfce67301e2bf3039136ac05916..3379ac2169723b53090bf8ae2bbebcd435ec7c74 100644 (file)
@@ -69,8 +69,7 @@ static unsigned getRB(uint32_t insn) {
 }
 
 static int64_t getRS(uint32_t insn) {
-    int16_t val = (insn & 0x3FFF);
-    return val;
+  return MBlazeRegisterInfo::getSpecialRegisterFromNumbering(insn&0x3FFF);
 }
 
 static int64_t getIMM(uint32_t insn) {
@@ -606,12 +605,12 @@ bool MBlazeDisassembler::getInstruction(MCInst &instr,
 
   case MBlazeII::FRCS:
     instr.addOperand(MCOperand::CreateReg(getRD(insn)));
-    instr.addOperand(MCOperand::CreateImm(getRS(insn)));
+    instr.addOperand(MCOperand::CreateReg(getRS(insn)));
     break;
 
   case MBlazeII::FCRCS:
+    instr.addOperand(MCOperand::CreateReg(getRS(insn)));
     instr.addOperand(MCOperand::CreateReg(getRA(insn)));
-    instr.addOperand(MCOperand::CreateImm(getRS(insn)));
     break;
 
   case MBlazeII::FCRCX:
index 186ede5febb07b83921ec1b7ad60417127a54f1e..3de608ceff0061b76da886ce45156b4ae4a1f8ea 100644 (file)
@@ -599,11 +599,15 @@ let isCodeGenOnly=1 in {
 //===----------------------------------------------------------------------===//
 // Misc. instructions
 //===----------------------------------------------------------------------===//
-def MFS : SPC<0x25, 0x2, (outs GPR:$dst), (ins SPR:$src),
-              "mfs       $dst, $src", [], IIAlu>;
+let Form=FRCS in {
+  def MFS : SPC<0x25, 0x2, (outs GPR:$dst), (ins SPR:$src),
+                "mfs       $dst, $src", [], IIAlu>;
+}
 
-def MTS : SPC<0x25, 0x3, (outs SPR:$dst), (ins GPR:$src),
-              "mts       $dst, $src", [], IIAlu>;
+let Form=FCRCS in {
+  def MTS : SPC<0x25, 0x3, (outs SPR:$dst), (ins GPR:$src),
+                "mts       $dst, $src", [], IIAlu>;
+}
 
 def MSRSET : MSR<0x25, 0x20, (outs GPR:$dst), (ins uimm15:$set),
                  "msrset    $dst, $set", [], IIAlu>;
index 6691bbf44fa0b14acb1e866b2506ead150a2d9e8..a808cc9ccfb32c4e36a5a7fc18ccbcf7852e5d16 100644 (file)
@@ -4,7 +4,7 @@
 # Special instructions
 ################################################################################
 
-# CHECK:    mfs         r0, 0
+# CHECK:    mfs         r0, rpc
 0x94 0x00 0x80 0x00
 
 # CHECK:    msrclr      r0, 0
@@ -13,7 +13,7 @@
 # CHECK:    msrset      r0, 0
 0x94 0x10 0x00 0x00
 
-# CHECK:    mts         0, r0
+# CHECK:    mts         rpc, r0
 0x94 0x00 0xc0 0x00
 
 # CHECK:    wdc         r0, r1
 
 # CHECK:    wic         r0, r1
 0x90 0x00 0x08 0x68
+
+################################################################################
+# Special registers
+################################################################################
+
+# CHECK:    mfs         r1, rpc
+0x94 0x20 0x80 0x00
+
+# CHECK:    mfs         r1, rmsr
+0x94 0x20 0x80 0x01
+
+# CHECK:    mfs         r1, rear
+0x94 0x20 0x80 0x03
+
+# CHECK:    mfs         r1, resr
+0x94 0x20 0x80 0x05
+
+# CHECK:    mfs         r1, rfsr
+0x94 0x20 0x80 0x07
+
+# CHECK:    mfs         r1, rbtr
+0x94 0x20 0x80 0x0b
+
+# CHECK:    mfs         r1, redr
+0x94 0x20 0x80 0x0d
+
+# CHECK:    mfs         r1, rpid
+0x94 0x20 0x90 0x00
+
+# CHECK:    mfs         r1, rzpr
+0x94 0x20 0x90 0x01
+
+# CHECK:    mfs         r1, rtlbx
+0x94 0x20 0x90 0x02
+
+# CHECK:    mfs         r1, rtlbhi
+0x94 0x20 0x90 0x04
+
+# CHECK:    mfs         r1, rtlblo
+0x94 0x20 0x90 0x03
+
+# CHECK:    mfs         r1, rpvr0
+0x94 0x20 0xa0 0x00
+
+# CHECK:    mfs         r1, rpvr1
+0x94 0x20 0xa0 0x01
+
+# CHECK:    mfs         r1, rpvr2
+0x94 0x20 0xa0 0x02
+
+# CHECK:    mfs         r1, rpvr3
+0x94 0x20 0xa0 0x03
+
+# CHECK:    mfs         r1, rpvr4
+0x94 0x20 0xa0 0x04
+
+# CHECK:    mfs         r1, rpvr5
+0x94 0x20 0xa0 0x05
+
+# CHECK:    mfs         r1, rpvr6
+0x94 0x20 0xa0 0x06
+
+# CHECK:    mfs         r1, rpvr7
+0x94 0x20 0xa0 0x07
+
+# CHECK:    mfs         r1, rpvr8
+0x94 0x20 0xa0 0x08
+
+# CHECK:    mfs         r1, rpvr9
+0x94 0x20 0xa0 0x09
+
+# CHECK:    mfs         r1, rpvr10
+0x94 0x20 0xa0 0x0a
+
+# CHECK:    mfs         r1, rpvr11
+0x94 0x20 0xa0 0x0b