R600/SI: Don't crash when getting immediate operand size
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Sat, 21 Feb 2015 21:29:04 +0000 (21:29 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Sat, 21 Feb 2015 21:29:04 +0000 (21:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230147 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/R600/SIInstrInfo.h

index f3285cff6c4fd8ec0517158db41e475fad550968..4d3371b1aec5b1fc9f54a0967428437980fe6e72 100644 (file)
@@ -254,6 +254,13 @@ public:
   // instruction opcode.
   unsigned getOpSize(uint16_t Opcode, unsigned OpNo) const {
     const MCOperandInfo &OpInfo = get(Opcode).OpInfo[OpNo];
+
+    if (OpInfo.RegClass == -1) {
+      // If this is an immediate operand, this must be a 32-bit literal.
+      assert(OpInfo.OperandType == MCOI::OPERAND_IMMEDIATE);
+      return 4;
+    }
+
     return RI.getRegClass(OpInfo.RegClass)->getSize();
   }