Skip to content

Commit cc0371f

Browse files
authored
[AMDGPU] Use ListSeparator. NFC. (#169347)
1 parent 51fef12 commit cc0371f

File tree

1 file changed

+17
-36
lines changed

1 file changed

+17
-36
lines changed

llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "SIDefines.h"
1313
#include "Utils/AMDGPUAsmUtils.h"
1414
#include "Utils/AMDGPUBaseInfo.h"
15+
#include "llvm/ADT/StringExtras.h"
1516
#include "llvm/MC/MCAsmInfo.h"
1617
#include "llvm/MC/MCExpr.h"
1718
#include "llvm/MC/MCInst.h"
@@ -1341,12 +1342,9 @@ void AMDGPUInstPrinter::printPackedModifier(const MCInst *MI,
13411342
return;
13421343

13431344
O << Name;
1344-
for (int I = 0; I < NumOps; ++I) {
1345-
if (I != 0)
1346-
O << ',';
1347-
1348-
O << !!(Ops[I] & Mod);
1349-
}
1345+
ListSeparator Sep(",");
1346+
for (int I = 0; I < NumOps; ++I)
1347+
O << Sep << !!(Ops[I] & Mod);
13501348

13511349
if (HasDstSel) {
13521350
O << ',' << !!(Ops[0] & SISrcMods::DST_OP_SEL);
@@ -1584,14 +1582,10 @@ void AMDGPUInstPrinter::printGPRIdxMode(const MCInst *MI, unsigned OpNo,
15841582
O << formatHex(static_cast<uint64_t>(Val));
15851583
} else {
15861584
O << "gpr_idx(";
1587-
bool NeedComma = false;
1585+
ListSeparator Sep(",");
15881586
for (unsigned ModeId = ID_MIN; ModeId <= ID_MAX; ++ModeId) {
1589-
if (Val & (1 << ModeId)) {
1590-
if (NeedComma)
1591-
O << ',';
1592-
O << IdSymbolic[ModeId];
1593-
NeedComma = true;
1594-
}
1587+
if (Val & (1 << ModeId))
1588+
O << Sep << IdSymbolic[ModeId];
15951589
}
15961590
O << ')';
15971591
}
@@ -1798,25 +1792,16 @@ void AMDGPUInstPrinter::printSWaitCnt(const MCInst *MI, unsigned OpNo,
17981792
bool IsDefaultLgkmcnt = Lgkmcnt == getLgkmcntBitMask(ISA);
17991793
bool PrintAll = IsDefaultVmcnt && IsDefaultExpcnt && IsDefaultLgkmcnt;
18001794

1801-
bool NeedSpace = false;
1795+
ListSeparator Sep(" ");
18021796

1803-
if (!IsDefaultVmcnt || PrintAll) {
1804-
O << "vmcnt(" << Vmcnt << ')';
1805-
NeedSpace = true;
1806-
}
1797+
if (!IsDefaultVmcnt || PrintAll)
1798+
O << Sep << "vmcnt(" << Vmcnt << ')';
18071799

1808-
if (!IsDefaultExpcnt || PrintAll) {
1809-
if (NeedSpace)
1810-
O << ' ';
1811-
O << "expcnt(" << Expcnt << ')';
1812-
NeedSpace = true;
1813-
}
1800+
if (!IsDefaultExpcnt || PrintAll)
1801+
O << Sep << "expcnt(" << Expcnt << ')';
18141802

1815-
if (!IsDefaultLgkmcnt || PrintAll) {
1816-
if (NeedSpace)
1817-
O << ' ';
1818-
O << "lgkmcnt(" << Lgkmcnt << ')';
1819-
}
1803+
if (!IsDefaultLgkmcnt || PrintAll)
1804+
O << Sep << "lgkmcnt(" << Lgkmcnt << ')';
18201805
}
18211806

18221807
void AMDGPUInstPrinter::printDepCtr(const MCInst *MI, unsigned OpNo,
@@ -1832,14 +1817,10 @@ void AMDGPUInstPrinter::printDepCtr(const MCInst *MI, unsigned OpNo,
18321817
StringRef Name;
18331818
unsigned Val;
18341819
bool IsDefault;
1835-
bool NeedSpace = false;
1820+
ListSeparator Sep(" ");
18361821
while (decodeDepCtr(Imm16, Id, Name, Val, IsDefault, STI)) {
1837-
if (!IsDefault || !HasNonDefaultVal) {
1838-
if (NeedSpace)
1839-
O << ' ';
1840-
O << Name << '(' << Val << ')';
1841-
NeedSpace = true;
1842-
}
1822+
if (!IsDefault || !HasNonDefaultVal)
1823+
O << Sep << Name << '(' << Val << ')';
18431824
}
18441825
} else {
18451826
O << formatHex(Imm16);

0 commit comments

Comments
 (0)