Skip to content

Commit 7747a14

Browse files
committed
[AMDGPU] GFX11: accept global_atomic_csub as an alias
GFX11 renamed this instruction to global_atomic_csub_u32 but should accept the old name as an alias, for consistency with the other global atomics and with buffer_atomic_csub. Differential Revision: https://reviews.llvm.org/D143176
1 parent da3e477 commit 7747a14

File tree

2 files changed

+40
-5
lines changed

2 files changed

+40
-5
lines changed

llvm/lib/Target/AMDGPU/FLATInstructions.td

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2171,12 +2171,16 @@ class FLAT_Real_gfx11 <bits<7> op, FLAT_Pseudo ps, string opName = ps.Mnemonic>
21712171
let Inst{55} = ps.sve;
21722172
}
21732173

2174-
multiclass FLAT_Real_Base_gfx11<bits<7> op, string ps, string opName, int renamed = false> {
2174+
multiclass FLAT_Aliases_gfx11<string ps, string opName, int renamed> {
2175+
if renamed then
2176+
def _renamed_gfx11 : MnemonicAlias<!cast<FLAT_Pseudo>(ps).Mnemonic, opName>, Requires<[isGFX11Plus]>;
2177+
}
2178+
2179+
multiclass FLAT_Real_Base_gfx11<bits<7> op, string ps, string opName, int renamed = false> :
2180+
FLAT_Aliases_gfx11<ps, opName, renamed> {
21752181
def _gfx11 : FLAT_Real_gfx11<op, !cast<FLAT_Pseudo>(ps), opName> {
21762182
let Inst{54-48} = !cast<int>(SGPR_NULL_gfx11plus.HWEncoding);
21772183
}
2178-
if renamed then
2179-
def _renamed_gfx11 : MnemonicAlias<!cast<FLAT_Pseudo>(ps).Mnemonic, opName>, Requires<[isGFX11Plus]>;
21802184
}
21812185

21822186
multiclass FLAT_Real_RTN_gfx11<bits<7> op, string ps, string opName> {
@@ -2219,7 +2223,8 @@ multiclass FLAT_Real_GlblAtomics_gfx11<bits<7> op, string ps, string opName, int
22192223
FLAT_Real_RTN_gfx11<op, ps, opName>,
22202224
FLAT_Real_SADDR_RTN_gfx11<op, ps, opName>;
22212225

2222-
multiclass FLAT_Real_GlblAtomics_RTN_gfx11<bits<7> op, string ps, string opName> :
2226+
multiclass FLAT_Real_GlblAtomics_RTN_gfx11<bits<7> op, string ps, string opName, int renamed = false> :
2227+
FLAT_Aliases_gfx11<ps#"_RTN", opName, renamed>,
22232228
FLAT_Real_RTN_gfx11<op, ps, opName>,
22242229
FLAT_Real_SADDR_RTN_gfx11<op, ps, opName>;
22252230

@@ -2312,7 +2317,7 @@ defm GLOBAL_ATOMIC_SWAP_B32 : FLAT_Real_GlblAtomics_gfx11<0x033, "GLOBAL_ATO
23122317
defm GLOBAL_ATOMIC_CMPSWAP_B32 : FLAT_Real_GlblAtomics_gfx11<0x034, "GLOBAL_ATOMIC_CMPSWAP", "global_atomic_cmpswap_b32", true>;
23132318
defm GLOBAL_ATOMIC_ADD_U32 : FLAT_Real_GlblAtomics_gfx11<0x035, "GLOBAL_ATOMIC_ADD", "global_atomic_add_u32", true>;
23142319
defm GLOBAL_ATOMIC_SUB_U32 : FLAT_Real_GlblAtomics_gfx11<0x036, "GLOBAL_ATOMIC_SUB", "global_atomic_sub_u32", true>;
2315-
defm GLOBAL_ATOMIC_CSUB_U32 : FLAT_Real_GlblAtomics_RTN_gfx11<0x037, "GLOBAL_ATOMIC_CSUB", "global_atomic_csub_u32">;
2320+
defm GLOBAL_ATOMIC_CSUB_U32 : FLAT_Real_GlblAtomics_RTN_gfx11<0x037, "GLOBAL_ATOMIC_CSUB", "global_atomic_csub_u32", true>;
23162321
defm GLOBAL_ATOMIC_MIN_I32 : FLAT_Real_GlblAtomics_gfx11<0x038, "GLOBAL_ATOMIC_SMIN", "global_atomic_min_i32", true>;
23172322
defm GLOBAL_ATOMIC_MIN_U32 : FLAT_Real_GlblAtomics_gfx11<0x039, "GLOBAL_ATOMIC_UMIN", "global_atomic_min_u32", true>;
23182323
defm GLOBAL_ATOMIC_MAX_I32 : FLAT_Real_GlblAtomics_gfx11<0x03a, "GLOBAL_ATOMIC_SMAX", "global_atomic_max_i32", true>;

llvm/test/MC/AMDGPU/gfx11_asm_flat.s

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,6 +1533,36 @@ global_atomic_cmpswap_x2 v[5:6], v255, v[2:5], vcc offset:4095 glc
15331533
global_atomic_cmpswap_x2 v[254:255], v255, v[252:255], ttmp[14:15] offset:-4096 glc slc dlc
15341534
// GFX11: [0x00,0xf0,0x0a,0xdd,0xff,0xfc,0x7a,0xfe]
15351535

1536+
global_atomic_csub v5, v[1:2], v2, off glc
1537+
// GFX11: [0x00,0x40,0xde,0xdc,0x01,0x02,0x7c,0x05]
1538+
1539+
global_atomic_csub v5, v[254:255], v2, off glc
1540+
// GFX11: [0x00,0x40,0xde,0xdc,0xfe,0x02,0x7c,0x05]
1541+
1542+
global_atomic_csub v5, v1, v2, s[6:7] glc
1543+
// GFX11: [0x00,0x40,0xde,0xdc,0x01,0x02,0x06,0x05]
1544+
1545+
global_atomic_csub v5, v1, v2, s[104:105] glc
1546+
// GFX11: [0x00,0x40,0xde,0xdc,0x01,0x02,0x68,0x05]
1547+
1548+
global_atomic_csub v5, v1, v2, vcc glc
1549+
// GFX11: [0x00,0x40,0xde,0xdc,0x01,0x02,0x6a,0x05]
1550+
1551+
global_atomic_csub v5, v1, v2, ttmp[14:15] glc
1552+
// GFX11: [0x00,0x40,0xde,0xdc,0x01,0x02,0x7a,0x05]
1553+
1554+
global_atomic_csub v5, v255, v2, s[6:7] offset:-1 glc
1555+
// GFX11: [0xff,0x5f,0xde,0xdc,0xff,0x02,0x06,0x05]
1556+
1557+
global_atomic_csub v5, v255, v2, s[104:105] offset:0 glc
1558+
// GFX11: [0x00,0x40,0xde,0xdc,0xff,0x02,0x68,0x05]
1559+
1560+
global_atomic_csub v5, v255, v2, vcc offset:4095 glc
1561+
// GFX11: [0xff,0x4f,0xde,0xdc,0xff,0x02,0x6a,0x05]
1562+
1563+
global_atomic_csub v255, v255, v255, ttmp[14:15] offset:-4096 glc slc dlc
1564+
// GFX11: [0x00,0xf0,0xde,0xdc,0xff,0xff,0x7a,0xff]
1565+
15361566
global_atomic_csub_u32 v5, v[1:2], v2, off glc
15371567
// GFX11: [0x00,0x40,0xde,0xdc,0x01,0x02,0x7c,0x05]
15381568

0 commit comments

Comments
 (0)