[llvm] 7e3e9d4 - [AMDGPU] Change getLdStRegisterOperand to !cond for better diagnostic (#95475)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 14 06:33:06 PDT 2024
Author: Joe Nash
Date: 2024-06-14T09:33:03-04:00
New Revision: 7e3e9d43086d21f9996a52f0d4f24e0edeb34991
URL: https://github.com/llvm/llvm-project/commit/7e3e9d43086d21f9996a52f0d4f24e0edeb34991
DIFF: https://github.com/llvm/llvm-project/commit/7e3e9d43086d21f9996a52f0d4f24e0edeb34991.diff
LOG: [AMDGPU] Change getLdStRegisterOperand to !cond for better diagnostic (#95475)
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.
Added:
Modified:
llvm/lib/Target/AMDGPU/BUFInstructions.td
llvm/lib/Target/AMDGPU/SIInstrInfo.td
Removed:
################################################################################
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,
More information about the llvm-commits
mailing list