[llvm] [AMDGPU] Change getLdStRegisterOperand to !cond for better diagnostic (PR #95475)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 13 14:34:06 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-amdgpu
Author: Joe Nash (Sisyph)
<details>
<summary>Changes</summary>
If you would hit the unexpected case in these !if trees, you'd get an error message like "error: Not a known RegisterClass! def VReg_1..." This can happen when changing code quite indirectly related to these class definitions. We can use !cond here, which has a builtin facility to throw an error if no case in the !cond statement is hit.
NFC.
---
Full diff: https://github.com/llvm/llvm-project/pull/95475.diff
2 Files Affected:
- (modified) llvm/lib/Target/AMDGPU/BUFInstructions.td (+4-6)
- (modified) llvm/lib/Target/AMDGPU/SIInstrInfo.td (+5-7)
``````````diff
diff --git a/llvm/lib/Target/AMDGPU/BUFInstructions.td b/llvm/lib/Target/AMDGPU/BUFInstructions.td
index 50e62788c5eac..43e5434ea2700 100644
--- a/llvm/lib/Target/AMDGPU/BUFInstructions.td
+++ b/llvm/lib/Target/AMDGPU/BUFInstructions.td
@@ -399,12 +399,10 @@ class MUBUF_Invalidate <string opName, SDPatternOperator node = null_frag> :
class getLdStVDataRegisterOperand<RegisterClass RC, bit isTFE> {
RegisterOperand tfeVDataOp =
- !if(!eq(RC.Size, 32), AVLdSt_64,
- !if(!eq(RC.Size, 64), AVLdSt_96,
- !if(!eq(RC.Size, 96), AVLdSt_128,
- !if(!eq(RC.Size, 128), AVLdSt_160,
- RegisterOperand<VReg_1> // Invalid register.
- ))));
+ !cond(!eq(RC.Size, 32) : AVLdSt_64,
+ !eq(RC.Size, 64) : AVLdSt_96,
+ !eq(RC.Size, 96) : AVLdSt_128,
+ !eq(RC.Size, 128) : AVLdSt_160);
RegisterOperand ret = !if(isTFE, tfeVDataOp, getLdStRegisterOperand<RC>.ret);
}
diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.td b/llvm/lib/Target/AMDGPU/SIInstrInfo.td
index 3921b1469e15e..6682763210411 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.td
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.td
@@ -2242,13 +2242,11 @@ class getHasExt <int NumSrcArgs, ValueType DstVT = i32, ValueType Src0VT = i32,
// Return an AGPR+VGPR operand class for the given VGPR register class.
class getLdStRegisterOperand<RegisterClass RC> {
RegisterOperand ret =
- !if(!eq(RC.Size, 32), AVLdSt_32,
- !if(!eq(RC.Size, 64), AVLdSt_64,
- !if(!eq(RC.Size, 96), AVLdSt_96,
- !if(!eq(RC.Size, 128), AVLdSt_128,
- !if(!eq(RC.Size, 160), AVLdSt_160,
- RegisterOperand<VReg_1> // invalid register
- )))));
+ !cond(!eq(RC.Size, 32) : AVLdSt_32,
+ !eq(RC.Size, 64) : AVLdSt_64,
+ !eq(RC.Size, 96) : AVLdSt_96,
+ !eq(RC.Size, 128) : AVLdSt_128,
+ !eq(RC.Size, 160) : AVLdSt_160);
}
class getHasVOP3DPP <ValueType DstVT = i32, ValueType Src0VT = i32,
``````````
</details>
https://github.com/llvm/llvm-project/pull/95475
More information about the llvm-commits
mailing list