Skip to content

Commit 074fe3b

Browse files
authored
[AMDGPU] Simplify and refactor VBUFFER_Real class definitions. NFC. (#84521)
Abstracting out a new base class VBUFFER_Real_gfx12 just highlights that the only difference between the MUBUF and MTBUF forms is in the handling of the "format" field.
1 parent e460da1 commit 074fe3b

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

llvm/lib/Target/AMDGPU/BUFInstructions.td

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2365,7 +2365,7 @@ multiclass MUBUF_Real_gfx7<bits<8> op> {
23652365
// Base ENC_VBUFFER for GFX12.
23662366
//===----------------------------------------------------------------------===//
23672367

2368-
class VBUFFER_Real <BUF_Pseudo ps, string real_name = ps.Mnemonic> :
2368+
class VBUFFER_Real <bits<8> op, BUF_Pseudo ps, string real_name> :
23692369
InstSI <ps.OutOperandList, ps.InOperandList, real_name # ps.AsmOperands, []>, Enc96 {
23702370

23712371
let isPseudo = 0;
@@ -2389,6 +2389,8 @@ class VBUFFER_Real <BUF_Pseudo ps, string real_name = ps.Mnemonic> :
23892389
let IsAtomicNoRet = ps.IsAtomicNoRet;
23902390
let VALU = ps.VALU;
23912391
let LGKM_CNT = ps.LGKM_CNT;
2392+
let MUBUF = ps.MUBUF;
2393+
let MTBUF = ps.MTBUF;
23922394

23932395
bits<24> offset;
23942396
bits<8> vaddr;
@@ -2405,6 +2407,7 @@ class VBUFFER_Real <BUF_Pseudo ps, string real_name = ps.Mnemonic> :
24052407
let Inst{47-41} = !if(ps.has_srsrc, srsrc, ?);
24062408
let Inst{49-48} = 0b00;
24072409
let Inst{6-0} = !if(ps.has_soffset, soffset, ?);
2410+
let Inst{21-14} = op;
24082411
let Inst{22} = ps.tfe;
24092412
let Inst{62} = ps.offen;
24102413
let Inst{63} = ps.idxen;
@@ -2416,33 +2419,27 @@ class VBUFFER_Real <BUF_Pseudo ps, string real_name = ps.Mnemonic> :
24162419
let Inst{31-26} = 0b110001;
24172420
}
24182421

2422+
class VBUFFER_Real_gfx12<bits<8> op, BUF_Pseudo ps, string real_name> :
2423+
VBUFFER_Real<op, ps, real_name>,
2424+
SIMCInstr<ps.PseudoInstr, SIEncodingFamily.GFX12> {
2425+
let AssemblerPredicate = isGFX12Only;
2426+
let DecoderNamespace = "GFX12";
2427+
}
2428+
24192429
multiclass VBUFFER_MUBUF_Real_gfx12<bits<8> op, string real_name> {
24202430
defvar ps = !cast<MUBUF_Pseudo>(NAME);
2421-
def _gfx12 : VBUFFER_Real<ps, real_name>,
2422-
SIMCInstr<ps.PseudoInstr, SIEncodingFamily.GFX12> {
2423-
let MUBUF = 1;
2424-
2431+
def _gfx12 : VBUFFER_Real_gfx12<op, ps, real_name> {
24252432
// Set the last bit of format to 1 to avoid round-trip issues, as some tools
24262433
// print BUF_FMT_INVALID for format 0.
24272434
let Inst{55} = 0b1;
2428-
let Inst{21-14} = op;
2429-
let AssemblerPredicate = isGFX12Only;
2430-
let DecoderNamespace = "GFX12";
24312435
}
24322436
}
24332437

24342438
multiclass VBUFFER_MTBUF_Real_gfx12<bits<4> op, string real_name> {
24352439
defvar ps = !cast<MTBUF_Pseudo>(NAME);
2436-
def _gfx12 : VBUFFER_Real<ps, real_name>, SIMCInstr<ps.PseudoInstr, SIEncodingFamily.GFX12> {
2437-
let MTBUF = 1;
2438-
2439-
bits<7> format;
2440-
2441-
let Inst{17-14} = op;
2442-
let Inst{21-18} = 0b1000;
2440+
def _gfx12 : VBUFFER_Real_gfx12<{0b1000, op}, ps, real_name> {
2441+
bits<7> format;
24432442
let Inst{61-55} = format;
2444-
let AssemblerPredicate = isGFX12Only;
2445-
let DecoderNamespace = "GFX12";
24462443
}
24472444
}
24482445

0 commit comments

Comments
 (0)