]> granicus.if.org Git - llvm/commitdiff
AMDGPU: Verify that flat offsets aren't used pre-GFX9
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Mon, 12 Jun 2017 16:37:55 +0000 (16:37 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Mon, 12 Jun 2017 16:37:55 +0000 (16:37 +0000)
For convenience the operand is always present in the instruction,
but it isn't valid to use except on GFX9.

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

lib/Target/AMDGPU/SIInstrInfo.cpp

index 58c05cf16f15bdde0cbe96f8c18216a75c020683..d206a5ec9d5386f0a20cf8a172db747bf99a621d 100644 (file)
@@ -2331,11 +2331,12 @@ static bool isSubRegOf(const SIRegisterInfo &TRI,
 bool SIInstrInfo::verifyInstruction(const MachineInstr &MI,
                                     StringRef &ErrInfo) const {
   uint16_t Opcode = MI.getOpcode();
-
   if (SIInstrInfo::isGenericOpcode(MI.getOpcode()))
     return true;
 
-  const MachineRegisterInfo &MRI = MI.getParent()->getParent()->getRegInfo();
+  const MachineFunction *MF = MI.getParent()->getParent();
+  const MachineRegisterInfo &MRI = MF->getRegInfo();
+
   int Src0Idx = AMDGPU::getNamedOperandIdx(Opcode, AMDGPU::OpName::src0);
   int Src1Idx = AMDGPU::getNamedOperandIdx(Opcode, AMDGPU::OpName::src1);
   int Src2Idx = AMDGPU::getNamedOperandIdx(Opcode, AMDGPU::OpName::src2);
@@ -2565,6 +2566,14 @@ bool SIInstrInfo::verifyInstruction(const MachineInstr &MI,
     }
   }
 
+  if (isFLAT(MI) && !MF->getSubtarget<SISubtarget>().hasFlatInstOffsets()) {
+    const MachineOperand *Offset = getNamedOperand(MI, AMDGPU::OpName::offset);
+    if (Offset->getImm() != 0) {
+      ErrInfo = "subtarget does not support offsets in flat instructions";
+      return false;
+    }
+  }
+
   return true;
 }