Skip to content

Commit 7814806

Browse files
authored
[AMDGPU] Fix CPol operands of MUBUF atomics. (#73118)
Resolves AsmParser ambiguities, e.g., between BUFFER_ATOMIC_XOR_X2_BOTHEN_vi and BUFFER_ATOMIC_XOR_X2_BOTHEN_RTN_vi. Part of <#69256>.
1 parent af09219 commit 7814806

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

llvm/lib/Target/AMDGPU/BUFInstructions.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,8 @@ class getMUBUFAtomicInsDA<RegisterClass vdataClass, bit vdata_in,
637637
dag VData = !if(vdata_in, (ins vdata_op:$vdata_in), (ins vdata_op:$vdata));
638638
dag Data = !if(!empty(vaddrList), VData, !con(VData, (ins vaddrClass:$vaddr)));
639639
dag MainInputs = (ins SReg_128:$srsrc, SCSrc_b32:$soffset, offset:$offset);
640-
dag CPol = !if(vdata_in, (ins CPol_GLC1:$cpol), (ins CPol_0:$cpol));
640+
dag CPol = !if(vdata_in, (ins CPol_GLC_WithDefault:$cpol),
641+
(ins CPol_NonGLC_WithDefault:$cpol));
641642

642643
dag ret = !con(Data, MainInputs, CPol);
643644
}

llvm/lib/Target/AMDGPU/SIInstrInfo.td

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,9 +1035,8 @@ class NamedBitOperand<string Id, string Name = NAME>
10351035

10361036
class DefaultOperand<CustomOperand Op, int Value>
10371037
: OperandWithDefaultOps<Op.Type, (ops (Op.Type Value))>,
1038-
CustomOperandProps<1, Op.ParserMatchClass.Name> {
1039-
let PredicateMethod = Op.ParserMatchClass.PredicateMethod;
1040-
let ParserMethod = Op.ParserMatchClass.ParserMethod;
1038+
CustomOperandProps<1> {
1039+
let ParserMatchClass = Op.ParserMatchClass;
10411040
let PrintMethod = Op.PrintMethod;
10421041
}
10431042

@@ -1080,6 +1079,8 @@ def CPol_0 : DefaultOperand<CPol, 0>;
10801079
def CPol_GLC1 : DefaultOperand<CPol, 1>;
10811080
def CPol_GLC : ValuePredicatedOperand<CPol, "Op.getImm() & CPol::GLC">;
10821081
def CPol_NonGLC : ValuePredicatedOperand<CPol, "!(Op.getImm() & CPol::GLC)", 1>;
1082+
def CPol_GLC_WithDefault : DefaultOperand<CPol_GLC, !shl(1, CPolBit.GLC)>;
1083+
def CPol_NonGLC_WithDefault : DefaultOperand<CPol_NonGLC, 0>;
10831084

10841085
def TFE : NamedBitOperand<"tfe">;
10851086
def UNorm : NamedBitOperand<"unorm">;

llvm/test/MC/AMDGPU/atomic-fadd-insts.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ buffer_atomic_add_f32 v5, off, s[8:11], s3 offset:7
4141
// GFX908: encoding: [0x07,0x00,0x34,0xe1,0x00,0x05,0x02,0x03]
4242

4343
buffer_atomic_add_f32 v5, off, s[8:11], s3 offset:4095 glc
44-
// GFX908-ERR: :[[@LINE-1]]:{{[0-9]+}}: error: instruction must not use glc
44+
// GFX908-ERR: :[[@LINE-1]]:{{[0-9]+}}: error: operands are not valid for this GPU or mode
4545

4646
buffer_atomic_add_f32 v5, off, s[8:11], s3 offset:4095 slc
4747
// GFX908: encoding: [0xff,0x0f,0x36,0xe1,0x00,0x05,0x02,0x03]
@@ -86,7 +86,7 @@ buffer_atomic_pk_add_f16 v5, off, s[8:11], s3 offset:7
8686
// GFX908: encoding: [0x07,0x00,0x38,0xe1,0x00,0x05,0x02,0x03]
8787

8888
buffer_atomic_pk_add_f16 v5, off, s[8:11], s3 offset:4095 glc
89-
// GFX908-ERR: :[[@LINE-1]]:{{[0-9]+}}: error: instruction must not use glc
89+
// GFX908-ERR: :[[@LINE-1]]:{{[0-9]+}}: error: operands are not valid for this GPU or mode
9090

9191
buffer_atomic_pk_add_f16 v5, off, s[8:11], s3 offset:4095 slc
9292
// GFX908: encoding: [0xff,0x0f,0x3a,0xe1,0x00,0x05,0x02,0x03]

llvm/test/MC/AMDGPU/gfx90a_asm_features.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -955,17 +955,17 @@ v_xor_b32 v6, v29, v27 row_newbcast:15
955955

956956
// GFX90A: buffer_atomic_add_f32 v0, v2, s[4:7], 0 idxen glc ; encoding: [0x00,0x60,0x34,0xe1,0x02,0x00,0x01,0x80]
957957
// GFX1010: :[[@LINE+2]]:{{[0-9]+}}: error: instruction not supported on this GPU
958-
// GFX908: :[[@LINE+1]]:{{[0-9]+}}: error: instruction must not use glc
958+
// GFX908: :[[@LINE+1]]:{{[0-9]+}}: error: operands are not valid for this GPU or mode
959959
buffer_atomic_add_f32 v0, v2, s[4:7], 0 idxen glc
960960

961961
// GFX90A: buffer_atomic_add_f32 v0, v2, s[4:7], 0 idxen glc ; encoding: [0x00,0x60,0x34,0xe1,0x02,0x00,0x01,0x80]
962962
// GFX1010: :[[@LINE+2]]:{{[0-9]+}}: error: instruction not supported on this GPU
963-
// GFX908: :[[@LINE+1]]:{{[0-9]+}}: error: instruction must not use glc
963+
// GFX908: :[[@LINE+1]]:{{[0-9]+}}: error: operands are not valid for this GPU or mode
964964
buffer_atomic_add_f32 v0, v2, s[4:7], 0 idxen glc
965965

966966
// GFX90A: buffer_atomic_pk_add_f16 v0, v2, s[4:7], 0 idxen glc ; encoding: [0x00,0x60,0x38,0xe1,0x02,0x00,0x01,0x80]
967967
// GFX1010: :[[@LINE+2]]:{{[0-9]+}}: error: instruction not supported on this GPU
968-
// GFX908: :[[@LINE+1]]:{{[0-9]+}}: error: instruction must not use glc
968+
// GFX908: :[[@LINE+1]]:{{[0-9]+}}: error: operands are not valid for this GPU or mode
969969
buffer_atomic_pk_add_f16 v0, v2, s[4:7], 0 idxen glc
970970

971971
// GFX90A: global_atomic_add_f32 v0, v[0:1], v2, off glc ; encoding: [0x00,0x80,0x35,0xdd,0x00,0x02,0x7f,0x00]

0 commit comments

Comments
 (0)