Skip to content

Commit 7dfcf48

Browse files
committed
PowerPC: Separate ELF and XCOFF @ specifiers
`@l` was incorrectly parsed as ELF-specific S_LO. Change it to AIX-specific S_L.
1 parent 60a18d6 commit 7dfcf48

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

llvm/include/llvm/MC/MCAsmInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ class LLVM_ABI MCAsmInfo {
429429

430430
llvm::DenseMap<uint32_t, StringRef> SpecifierToName;
431431
llvm::StringMap<uint32_t> NameToSpecifier;
432-
void initializeVariantKinds(ArrayRef<VariantKindDesc> Descs);
432+
void initializeVariantKinds(ArrayRef<AtSpecifier> Descs);
433433

434434
public:
435435
explicit MCAsmInfo();

llvm/lib/MC/MCAsmInfo.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,15 @@ bool MCAsmInfo::shouldOmitSectionDirective(StringRef SectionName) const {
124124
(SectionName == ".bss" && !usesELFSectionDirectiveForBSS());
125125
}
126126

127-
void MCAsmInfo::initializeVariantKinds(ArrayRef<VariantKindDesc> Descs) {
127+
void MCAsmInfo::initializeVariantKinds(ArrayRef<AtSpecifier> Descs) {
128128
assert(SpecifierToName.empty() && "cannot initialize twice");
129129
for (auto Desc : Descs) {
130130
[[maybe_unused]] auto It =
131131
SpecifierToName.try_emplace(Desc.Kind, Desc.Name);
132132
assert(It.second && "duplicate Kind");
133133
[[maybe_unused]] auto It2 =
134134
NameToSpecifier.try_emplace(Desc.Name.lower(), Desc.Kind);
135-
// Workaround for VK_PPC_L/VK_PPC_LO ("l").
136-
assert(It2.second || Desc.Name == "l");
135+
assert(It2.second);
137136
}
138137
}
139138

llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ using namespace llvm;
1919

2020
void PPCELFMCAsmInfo::anchor() { }
2121

22-
const MCAsmInfo::VariantKindDesc variantKindDescs[] = {
22+
const MCAsmInfo::AtSpecifier elfAtSpecifiers[] = {
2323
{PPC::S_DTPREL, "DTPREL"},
2424
{PPC::S_GOT, "GOT"},
2525
{PPC::S_GOT_HA, "got@ha"},
@@ -34,7 +34,6 @@ const MCAsmInfo::VariantKindDesc variantKindDescs[] = {
3434
{PPC::S_HIGHEST, "highest"},
3535
{PPC::S_HIGHESTA, "highesta"},
3636
{PPC::S_LO, "l"},
37-
{PPC::S_L, "l"}, // FIXME: share the name with VK_LO
3837
{PPC::S_PCREL, "PCREL"},
3938
{PPC::S_PLT, "PLT"},
4039
{PPC::S_TLSGD, "tlsgd"},
@@ -95,7 +94,19 @@ const MCAsmInfo::VariantKindDesc variantKindDescs[] = {
9594
{PPC::S_TPREL_HIGHEST, "tprel@highest"},
9695
{PPC::S_TPREL_HIGHESTA, "tprel@highesta"},
9796
{PPC::S_TPREL_LO, "tprel@l"},
97+
};
98+
99+
const MCAsmInfo::AtSpecifier xcoffAtSpecifiers[] = {
100+
// clang-format off
101+
{PPC::S_AIX_TLSGD, "gd"},
102+
{PPC::S_AIX_TLSGDM, "m"},
103+
{PPC::S_AIX_TLSIE, "ie"},
104+
{PPC::S_AIX_TLSLD, "ld"},
105+
{PPC::S_AIX_TLSLE, "le"},
106+
{PPC::S_AIX_TLSML, "ml"},
107+
{PPC::S_L, "l"},
98108
{PPC::S_U, "u"},
109+
// clang-format on
99110
};
100111

101112
static std::optional<int64_t> evaluateAsInt64(uint16_t specifier,
@@ -193,7 +204,7 @@ PPCELFMCAsmInfo::PPCELFMCAsmInfo(bool is64Bit, const Triple& T) {
193204
AssemblerDialect = 1; // New-Style mnemonics.
194205
LCOMMDirectiveAlignmentType = LCOMM::ByteAlignment;
195206

196-
initializeVariantKinds(variantKindDescs);
207+
initializeVariantKinds(elfAtSpecifiers);
197208
}
198209

199210
void PPCELFMCAsmInfo::printSpecifierExpr(raw_ostream &OS,
@@ -229,7 +240,7 @@ PPCXCOFFMCAsmInfo::PPCXCOFFMCAsmInfo(bool Is64Bit, const Triple &T) {
229240

230241
UsesSetToEquateSymbol = true;
231242

232-
initializeVariantKinds(variantKindDescs);
243+
initializeVariantKinds(xcoffAtSpecifiers);
233244
}
234245

235246
void PPCXCOFFMCAsmInfo::printSpecifierExpr(raw_ostream &OS,

llvm/test/MC/PowerPC/ppc64-abs-reloc.s

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# RUN: llvm-mc -triple powerpc64le-unknown-linux-gnu %s -filetype=obj -o - | \
22
# RUN: llvm-objdump -D -r - | FileCheck %s
33

4-
# RUN: llvm-mc -triple powerpc64-ibm-aix-xcoff %s -filetype=obj -o - | \
5-
# RUN: llvm-objdump -D -r - | FileCheck %s
6-
74
test: # @test
85
add 5, 3, 4
96
extsw 3, 5

0 commit comments

Comments
 (0)