diff options
| author | Dmitry Preobrazhensky <dmitry.preobrazhensky@amd.com> | 2018-02-05 12:45:43 +0000 |
|---|---|---|
| committer | Dmitry Preobrazhensky <dmitry.preobrazhensky@amd.com> | 2018-02-05 12:45:43 +0000 |
| commit | e3271aee447f510e89bab0c599b149b4085b325e (patch) | |
| tree | a30e74b6927b7e251abbc11d204ac84b04573198 /llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp | |
| parent | 5bc157443e02d6288ff8ff1162372a3b6e6a2b03 (diff) | |
| download | bcm5719-llvm-e3271aee447f510e89bab0c599b149b4085b325e.tar.gz bcm5719-llvm-e3271aee447f510e89bab0c599b149b4085b325e.zip | |
[AMDGPU][MC] Added validation of d16 and r128 modifiers of MIMG opcodes
See bugs 36094, 36095:
https://bugs.llvm.org/show_bug.cgi?id=36094
https://bugs.llvm.org/show_bug.cgi?id=36095
Differential Revision: https://reviews.llvm.org/D42692
Reviewers: vpykhtin, artem.tamazov, arsenm
llvm-svn: 324231
Diffstat (limited to 'llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp')
| -rw-r--r-- | llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp index 3ccfd85ae0f..5d5fe6ecee7 100644 --- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp +++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp @@ -907,6 +907,10 @@ public: return AMDGPU::hasXNACK(getSTI()); } + bool hasMIMG_R128() const { + return AMDGPU::hasMIMG_R128(getSTI()); + } + bool isSI() const { return AMDGPU::isSI(getSTI()); } @@ -1042,6 +1046,8 @@ private: bool validateIntClampSupported(const MCInst &Inst); bool validateMIMGAtomicDMask(const MCInst &Inst); bool validateMIMGDataSize(const MCInst &Inst); + bool validateMIMGR128(const MCInst &Inst); + bool validateMIMGD16(const MCInst &Inst); bool usesConstantBus(const MCInst &Inst, unsigned OpIdx); bool isInlineConstant(const MCInst &Inst, unsigned OpIdx) const; unsigned findImplicitSGPRReadInVOP(const MCInst &Inst) const; @@ -2326,6 +2332,35 @@ bool AMDGPUAsmParser::validateMIMGAtomicDMask(const MCInst &Inst) { return DMask == 0x1 || DMask == 0x3 || DMask == 0xf; } +bool AMDGPUAsmParser::validateMIMGR128(const MCInst &Inst) { + + const unsigned Opc = Inst.getOpcode(); + const MCInstrDesc &Desc = MII.get(Opc); + + if ((Desc.TSFlags & SIInstrFlags::MIMG) == 0) + return true; + + int Idx = AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::r128); + assert(Idx != -1); + + bool R128 = (Inst.getOperand(Idx).getImm() != 0); + + return !R128 || hasMIMG_R128(); +} + +bool AMDGPUAsmParser::validateMIMGD16(const MCInst &Inst) { + + const unsigned Opc = Inst.getOpcode(); + const MCInstrDesc &Desc = MII.get(Opc); + + if ((Desc.TSFlags & SIInstrFlags::MIMG) == 0) + return true; + if ((Desc.TSFlags & SIInstrFlags::D16) == 0) + return true; + + return !isCI() && !isSI(); +} + bool AMDGPUAsmParser::validateInstruction(const MCInst &Inst, const SMLoc &IDLoc) { if (!validateConstantBusLimitations(Inst)) { @@ -2353,6 +2388,17 @@ bool AMDGPUAsmParser::validateInstruction(const MCInst &Inst, "invalid atomic image dmask"); return false; } + if (!validateMIMGR128(Inst)) { + Error(IDLoc, + "r128 modifier is not supported on this GPU"); + return false; + } + // For MUBUF/MTBUF d16 is a part of opcode, so there is nothing to validate. + if (!validateMIMGD16(Inst)) { + Error(IDLoc, + "d16 modifier is not supported on this GPU"); + return false; + } return true; } |

