[llvm] [AMDGPU] Change getLdStRegisterOperand to !cond for better diagnostic (PR #95475)
Joe Nash via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 13 14:33:33 PDT 2024
https://github.com/Sisyph created https://github.com/llvm/llvm-project/pull/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.
>From 457c3b3e4889da57e7c76df9006086aa95d87276 Mon Sep 17 00:00:00 2001
From: Joe Nash <joseph.nash at amd.com>
Date: Thu, 13 Jun 2024 17:16:20 -0400
Subject: [PATCH] [AMDGPU] Change getLdStRegisterOperand to !cond for better
diagnostic
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.
---
llvm/lib/Target/AMDGPU/BUFInstructions.td | 10 ++++------
llvm/lib/Target/AMDGPU/SIInstrInfo.td | 12 +++++-------
2 files changed, 9 insertions(+), 13 deletions(-)
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