OSDN Git Service

[AMDGPU] fix failure on printing of non-existing instruction operands.
authorValery Pykhtin <Valery.Pykhtin@amd.com>
Thu, 11 Aug 2016 13:49:46 +0000 (13:49 +0000)
committerValery Pykhtin <Valery.Pykhtin@amd.com>
Thu, 11 Aug 2016 13:49:46 +0000 (13:49 +0000)
Differential revision: https://reviews.llvm.org/D23323

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278333 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp
test/MC/Disassembler/AMDGPU/missing_op.txt [new file with mode: 0644]

index 2932d3b..7dd0f00 100644 (file)
@@ -370,6 +370,11 @@ void AMDGPUInstPrinter::printImmediate64(uint64_t Imm, raw_ostream &O) {
 void AMDGPUInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
                                      raw_ostream &O) {
 
+  if (OpNo >= MI->getNumOperands()) {
+    O << "/*Missing OP" << OpNo << "*/";
+    return;
+  }
+
   const MCOperand &Op = MI->getOperand(OpNo);
   if (Op.isReg()) {
     switch (Op.getReg()) {
diff --git a/test/MC/Disassembler/AMDGPU/missing_op.txt b/test/MC/Disassembler/AMDGPU/missing_op.txt
new file mode 100644 (file)
index 0000000..a731f20
--- /dev/null
@@ -0,0 +1,5 @@
+# RUN: llvm-mc -arch=amdgcn -mcpu=fiji -disassemble -show-encoding < %s | FileCheck %s -check-prefix=VI
+
+#TODO: this test will fail when we fix v_interp_p2_f32 signature, remove it then
+#VI: v_interp_p2_f32 16, [/*Missing OP1*/], /*Missing OP2*/, /*Missing OP3*/, /*Missing OP4*/
+0xd4 0x41 0x1d 0xd4