[llvm] 7dfcf48 - PowerPC: Separate ELF and XCOFF @ specifiers
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 26 22:23:56 PDT 2025
Author: Fangrui Song
Date: 2025-06-26T22:23:51-07:00
New Revision: 7dfcf489fd9330e9f2289e8e7ad5c67701866104
URL: https://github.com/llvm/llvm-project/commit/7dfcf489fd9330e9f2289e8e7ad5c67701866104
DIFF: https://github.com/llvm/llvm-project/commit/7dfcf489fd9330e9f2289e8e7ad5c67701866104.diff
LOG: PowerPC: Separate ELF and XCOFF @ specifiers
`@l` was incorrectly parsed as ELF-specific S_LO. Change it to AIX-specific S_L.
Added:
Modified:
llvm/include/llvm/MC/MCAsmInfo.h
llvm/lib/MC/MCAsmInfo.cpp
llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp
llvm/test/MC/PowerPC/ppc64-abs-reloc.s
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCAsmInfo.h b/llvm/include/llvm/MC/MCAsmInfo.h
index 93ce3cc444213..5a9b39295ffd0 100644
--- a/llvm/include/llvm/MC/MCAsmInfo.h
+++ b/llvm/include/llvm/MC/MCAsmInfo.h
@@ -429,7 +429,7 @@ class LLVM_ABI MCAsmInfo {
llvm::DenseMap<uint32_t, StringRef> SpecifierToName;
llvm::StringMap<uint32_t> NameToSpecifier;
- void initializeVariantKinds(ArrayRef<VariantKindDesc> Descs);
+ void initializeVariantKinds(ArrayRef<AtSpecifier> Descs);
public:
explicit MCAsmInfo();
diff --git a/llvm/lib/MC/MCAsmInfo.cpp b/llvm/lib/MC/MCAsmInfo.cpp
index ba672d2fc2ec0..25edd30c3005e 100644
--- a/llvm/lib/MC/MCAsmInfo.cpp
+++ b/llvm/lib/MC/MCAsmInfo.cpp
@@ -124,7 +124,7 @@ bool MCAsmInfo::shouldOmitSectionDirective(StringRef SectionName) const {
(SectionName == ".bss" && !usesELFSectionDirectiveForBSS());
}
-void MCAsmInfo::initializeVariantKinds(ArrayRef<VariantKindDesc> Descs) {
+void MCAsmInfo::initializeVariantKinds(ArrayRef<AtSpecifier> Descs) {
assert(SpecifierToName.empty() && "cannot initialize twice");
for (auto Desc : Descs) {
[[maybe_unused]] auto It =
@@ -132,8 +132,7 @@ void MCAsmInfo::initializeVariantKinds(ArrayRef<VariantKindDesc> Descs) {
assert(It.second && "duplicate Kind");
[[maybe_unused]] auto It2 =
NameToSpecifier.try_emplace(Desc.Name.lower(), Desc.Kind);
- // Workaround for VK_PPC_L/VK_PPC_LO ("l").
- assert(It2.second || Desc.Name == "l");
+ assert(It2.second);
}
}
diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp
index 1da599a591dd5..9471aba65ca5f 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp
@@ -19,7 +19,7 @@ using namespace llvm;
void PPCELFMCAsmInfo::anchor() { }
-const MCAsmInfo::VariantKindDesc variantKindDescs[] = {
+const MCAsmInfo::AtSpecifier elfAtSpecifiers[] = {
{PPC::S_DTPREL, "DTPREL"},
{PPC::S_GOT, "GOT"},
{PPC::S_GOT_HA, "got at ha"},
@@ -34,7 +34,6 @@ const MCAsmInfo::VariantKindDesc variantKindDescs[] = {
{PPC::S_HIGHEST, "highest"},
{PPC::S_HIGHESTA, "highesta"},
{PPC::S_LO, "l"},
- {PPC::S_L, "l"}, // FIXME: share the name with VK_LO
{PPC::S_PCREL, "PCREL"},
{PPC::S_PLT, "PLT"},
{PPC::S_TLSGD, "tlsgd"},
@@ -95,7 +94,19 @@ const MCAsmInfo::VariantKindDesc variantKindDescs[] = {
{PPC::S_TPREL_HIGHEST, "tprel at highest"},
{PPC::S_TPREL_HIGHESTA, "tprel at highesta"},
{PPC::S_TPREL_LO, "tprel at l"},
+};
+
+const MCAsmInfo::AtSpecifier xcoffAtSpecifiers[] = {
+ // clang-format off
+ {PPC::S_AIX_TLSGD, "gd"},
+ {PPC::S_AIX_TLSGDM, "m"},
+ {PPC::S_AIX_TLSIE, "ie"},
+ {PPC::S_AIX_TLSLD, "ld"},
+ {PPC::S_AIX_TLSLE, "le"},
+ {PPC::S_AIX_TLSML, "ml"},
+ {PPC::S_L, "l"},
{PPC::S_U, "u"},
+ // clang-format on
};
static std::optional<int64_t> evaluateAsInt64(uint16_t specifier,
@@ -193,7 +204,7 @@ PPCELFMCAsmInfo::PPCELFMCAsmInfo(bool is64Bit, const Triple& T) {
AssemblerDialect = 1; // New-Style mnemonics.
LCOMMDirectiveAlignmentType = LCOMM::ByteAlignment;
- initializeVariantKinds(variantKindDescs);
+ initializeVariantKinds(elfAtSpecifiers);
}
void PPCELFMCAsmInfo::printSpecifierExpr(raw_ostream &OS,
@@ -229,7 +240,7 @@ PPCXCOFFMCAsmInfo::PPCXCOFFMCAsmInfo(bool Is64Bit, const Triple &T) {
UsesSetToEquateSymbol = true;
- initializeVariantKinds(variantKindDescs);
+ initializeVariantKinds(xcoffAtSpecifiers);
}
void PPCXCOFFMCAsmInfo::printSpecifierExpr(raw_ostream &OS,
diff --git a/llvm/test/MC/PowerPC/ppc64-abs-reloc.s b/llvm/test/MC/PowerPC/ppc64-abs-reloc.s
index d38e1f4b8dc13..4fa449d9a01a5 100644
--- a/llvm/test/MC/PowerPC/ppc64-abs-reloc.s
+++ b/llvm/test/MC/PowerPC/ppc64-abs-reloc.s
@@ -1,9 +1,6 @@
# RUN: llvm-mc -triple powerpc64le-unknown-linux-gnu %s -filetype=obj -o - | \
# RUN: llvm-objdump -D -r - | FileCheck %s
-# RUN: llvm-mc -triple powerpc64-ibm-aix-xcoff %s -filetype=obj -o - | \
-# RUN: llvm-objdump -D -r - | FileCheck %s
-
test: # @test
add 5, 3, 4
extsw 3, 5
More information about the llvm-commits
mailing list