Skip to content

Commit 7e3e9d4

Browse files
authored
[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.
1 parent c81d5b1 commit 7e3e9d4

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

llvm/lib/Target/AMDGPU/BUFInstructions.td

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -399,12 +399,10 @@ class MUBUF_Invalidate <string opName, SDPatternOperator node = null_frag> :
399399

400400
class getLdStVDataRegisterOperand<RegisterClass RC, bit isTFE> {
401401
RegisterOperand tfeVDataOp =
402-
!if(!eq(RC.Size, 32), AVLdSt_64,
403-
!if(!eq(RC.Size, 64), AVLdSt_96,
404-
!if(!eq(RC.Size, 96), AVLdSt_128,
405-
!if(!eq(RC.Size, 128), AVLdSt_160,
406-
RegisterOperand<VReg_1> // Invalid register.
407-
))));
402+
!cond(!eq(RC.Size, 32) : AVLdSt_64,
403+
!eq(RC.Size, 64) : AVLdSt_96,
404+
!eq(RC.Size, 96) : AVLdSt_128,
405+
!eq(RC.Size, 128) : AVLdSt_160);
408406

409407
RegisterOperand ret = !if(isTFE, tfeVDataOp, getLdStRegisterOperand<RC>.ret);
410408
}

llvm/lib/Target/AMDGPU/SIInstrInfo.td

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,13 +2242,11 @@ class getHasExt <int NumSrcArgs, ValueType DstVT = i32, ValueType Src0VT = i32,
22422242
// Return an AGPR+VGPR operand class for the given VGPR register class.
22432243
class getLdStRegisterOperand<RegisterClass RC> {
22442244
RegisterOperand ret =
2245-
!if(!eq(RC.Size, 32), AVLdSt_32,
2246-
!if(!eq(RC.Size, 64), AVLdSt_64,
2247-
!if(!eq(RC.Size, 96), AVLdSt_96,
2248-
!if(!eq(RC.Size, 128), AVLdSt_128,
2249-
!if(!eq(RC.Size, 160), AVLdSt_160,
2250-
RegisterOperand<VReg_1> // invalid register
2251-
)))));
2245+
!cond(!eq(RC.Size, 32) : AVLdSt_32,
2246+
!eq(RC.Size, 64) : AVLdSt_64,
2247+
!eq(RC.Size, 96) : AVLdSt_96,
2248+
!eq(RC.Size, 128) : AVLdSt_128,
2249+
!eq(RC.Size, 160) : AVLdSt_160);
22522250
}
22532251

22542252
class getHasVOP3DPP <ValueType DstVT = i32, ValueType Src0VT = i32,

0 commit comments

Comments
 (0)