[lld] r233867 - ELF: Remove <Arch>TargetHandler::kindString.
Rui Ueyama
ruiu at google.com
Wed Apr 1 16:55:11 PDT 2015
Author: ruiu
Date: Wed Apr 1 18:55:10 2015
New Revision: 233867
URL: http://llvm.org/viewvc/llvm-project?rev=233867&view=rev
Log:
ELF: Remove <Arch>TargetHandler::kindString.
<Arch>TargetHandler::kindString is a static member variable
containg a list of names of relocation types.
The member is used only by one function, registerRelocationNames,
so they don't have to be a static member.
This patch makes the visibility of the data narrower by making
them file-scoped variables in small files.
Modified:
lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.cpp
lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h
lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.cpp
lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.cpp
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h
lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp
lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.h
lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp
lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h
Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.cpp?rev=233867&r1=233866&r2=233867&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.cpp Wed Apr 1 18:55:10 2015
@@ -21,6 +21,13 @@ AArch64TargetHandler::AArch64TargetHandl
_aarch64TargetLayout(new AArch64TargetLayout<AArch64ELFType>(ctx)),
_aarch64RelocationHandler(new AArch64TargetRelocationHandler()) {}
+static const Registry::KindStrings kindStrings[] = {
+#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
+#include "llvm/Support/ELFRelocs/AArch64.def"
+#undef ELF_RELOC
+ LLD_KIND_STRING_END
+};
+
void AArch64TargetHandler::registerRelocationNames(Registry ®istry) {
registry.addKindTable(Reference::KindNamespace::ELF,
Reference::KindArch::AArch64, kindStrings);
@@ -40,12 +47,3 @@ std::unique_ptr<Writer> AArch64TargetHan
llvm_unreachable("unsupported output type");
}
}
-
-#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
-
-const Registry::KindStrings AArch64TargetHandler::kindStrings[] = {
-#include "llvm/Support/ELFRelocs/AArch64.def"
- LLD_KIND_STRING_END
-};
-
-#undef ELF_RELOC
Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h?rev=233867&r1=233866&r2=233867&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h Wed Apr 1 18:55:10 2015
@@ -46,7 +46,6 @@ public:
std::unique_ptr<Writer> getWriter() override;
private:
- static const Registry::KindStrings kindStrings[];
AArch64LinkingContext &_ctx;
std::unique_ptr<AArch64TargetLayout<AArch64ELFType>> _aarch64TargetLayout;
std::unique_ptr<AArch64TargetRelocationHandler> _aarch64RelocationHandler;
Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.cpp?rev=233867&r1=233866&r2=233867&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.cpp Wed Apr 1 18:55:10 2015
@@ -20,6 +20,13 @@ ARMTargetHandler::ARMTargetHandler(ARMLi
_armRelocationHandler(
new ARMTargetRelocationHandler(*_armTargetLayout.get())) {}
+static const Registry::KindStrings kindStrings[] = {
+#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
+#include "llvm/Support/ELFRelocs/ARM.def"
+#undef ELF_RELOC
+ LLD_KIND_STRING_END
+};
+
void ARMTargetHandler::registerRelocationNames(Registry ®istry) {
registry.addKindTable(Reference::KindNamespace::ELF, Reference::KindArch::ARM,
kindStrings);
@@ -34,10 +41,3 @@ std::unique_ptr<Writer> ARMTargetHandler
llvm_unreachable("unsupported output type");
}
}
-
-#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
-
-const Registry::KindStrings ARMTargetHandler::kindStrings[] = {
-#include "llvm/Support/ELFRelocs/ARM.def"
- LLD_KIND_STRING_END
-};
Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h?rev=233867&r1=233866&r2=233867&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h Wed Apr 1 18:55:10 2015
@@ -78,7 +78,6 @@ public:
std::unique_ptr<Writer> getWriter() override;
private:
- static const Registry::KindStrings kindStrings[];
ARMLinkingContext &_ctx;
std::unique_ptr<ARMTargetLayout<ARMELFType>> _armTargetLayout;
std::unique_ptr<ARMTargetRelocationHandler> _armRelocationHandler;
Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp?rev=233867&r1=233866&r2=233867&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp Wed Apr 1 18:55:10 2015
@@ -314,16 +314,14 @@ void elf::HexagonLinkingContext::addPass
ELFLinkingContext::addPasses(pm);
}
-void HexagonTargetHandler::registerRelocationNames(Registry ®istry) {
- registry.addKindTable(Reference::KindNamespace::ELF,
- Reference::KindArch::Hexagon, kindStrings);
-}
-
+static const Registry::KindStrings kindStrings[] = {
#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
-
-const Registry::KindStrings HexagonTargetHandler::kindStrings[] = {
#include "llvm/Support/ELFRelocs/Hexagon.def"
+#undef ELF_RELOC
LLD_KIND_STRING_END
};
-#undef ELF_RELOC
+void HexagonTargetHandler::registerRelocationNames(Registry ®istry) {
+ registry.addKindTable(Reference::KindNamespace::ELF,
+ Reference::KindArch::Hexagon, kindStrings);
+}
Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h?rev=233867&r1=233866&r2=233867&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h Wed Apr 1 18:55:10 2015
@@ -117,7 +117,6 @@ public:
std::unique_ptr<Writer> getWriter() override;
private:
- static const Registry::KindStrings kindStrings[];
HexagonLinkingContext &_ctx;
std::unique_ptr<HexagonRuntimeFile<HexagonELFType>> _runtimeFile;
std::unique_ptr<HexagonTargetLayout<HexagonELFType>> _targetLayout;
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.cpp?rev=233867&r1=233866&r2=233867&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.cpp Wed Apr 1 18:55:10 2015
@@ -12,15 +12,10 @@
using namespace lld;
using namespace elf;
-void MipsRelocationStringTable::registerTable(Registry ®istry) {
- registry.addKindTable(Reference::KindNamespace::ELF,
- Reference::KindArch::Mips, kindStrings);
-}
-
+const Registry::KindStrings kindStrings[] = {
#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
-
-const Registry::KindStrings MipsRelocationStringTable::kindStrings[] = {
#include "llvm/Support/ELFRelocs/Mips.def"
+#undef ELF_RELOC
LLD_KIND_STRING_ENTRY(LLD_R_MIPS_GLOBAL_GOT),
LLD_KIND_STRING_ENTRY(LLD_R_MIPS_32_HI16),
LLD_KIND_STRING_ENTRY(LLD_R_MIPS_64_HI16),
@@ -32,4 +27,7 @@ const Registry::KindStrings MipsRelocati
LLD_KIND_STRING_END
};
-#undef ELF_RELOC
+void MipsRelocationStringTable::registerTable(Registry ®istry) {
+ registry.addKindTable(Reference::KindNamespace::ELF,
+ Reference::KindArch::Mips, kindStrings);
+}
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h?rev=233867&r1=233866&r2=233867&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h Wed Apr 1 18:55:10 2015
@@ -92,8 +92,6 @@ public:
/// \brief Auxiliary class holds relocation's names table.
class MipsRelocationStringTable {
- static const Registry::KindStrings kindStrings[];
-
public:
static void registerTable(Registry ®istry);
};
Modified: lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp?rev=233867&r1=233866&r2=233867&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp Wed Apr 1 18:55:10 2015
@@ -33,15 +33,13 @@ std::unique_ptr<Writer> X86TargetHandler
}
}
+static const Registry::KindStrings kindStrings[] = {
#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
-
-const Registry::KindStrings X86TargetHandler::kindStrings[] = {
#include "llvm/Support/ELFRelocs/i386.def"
+#undef ELF_RELOC
LLD_KIND_STRING_END
};
-#undef ELF_RELOC
-
void X86TargetHandler::registerRelocationNames(Registry ®istry) {
registry.addKindTable(Reference::KindNamespace::ELF, Reference::KindArch::x86,
kindStrings);
Modified: lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.h?rev=233867&r1=233866&r2=233867&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.h Wed Apr 1 18:55:10 2015
@@ -46,7 +46,6 @@ public:
std::unique_ptr<Writer> getWriter() override;
protected:
- static const Registry::KindStrings kindStrings[];
X86LinkingContext &_ctx;
std::unique_ptr<X86TargetLayout<X86ELFType>> _x86TargetLayout;
std::unique_ptr<X86TargetRelocationHandler> _x86RelocationHandler;
Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp?rev=233867&r1=233866&r2=233867&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp Wed Apr 1 18:55:10 2015
@@ -21,6 +21,14 @@ X86_64TargetHandler::X86_64TargetHandler
_x86_64RelocationHandler(
new X86_64TargetRelocationHandler(*_x86_64TargetLayout.get())) {}
+static const Registry::KindStrings kindStrings[] = {
+#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
+#include "llvm/Support/ELFRelocs/x86_64.def"
+#undef ELF_RELOC
+ LLD_KIND_STRING_ENTRY(LLD_R_X86_64_GOTRELINDEX),
+ LLD_KIND_STRING_END
+};
+
void X86_64TargetHandler::registerRelocationNames(Registry ®istry) {
registry.addKindTable(Reference::KindNamespace::ELF,
Reference::KindArch::x86_64, kindStrings);
@@ -40,13 +48,3 @@ std::unique_ptr<Writer> X86_64TargetHand
llvm_unreachable("unsupported output type");
}
}
-
-#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
-
-const Registry::KindStrings X86_64TargetHandler::kindStrings[] = {
-#include "llvm/Support/ELFRelocs/x86_64.def"
- LLD_KIND_STRING_ENTRY(LLD_R_X86_64_GOTRELINDEX),
- LLD_KIND_STRING_END
-};
-
-#undef ELF_RELOC
Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h?rev=233867&r1=233866&r2=233867&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h Wed Apr 1 18:55:10 2015
@@ -50,7 +50,6 @@ public:
std::unique_ptr<Writer> getWriter() override;
protected:
- static const Registry::KindStrings kindStrings[];
X86_64LinkingContext &_ctx;
std::unique_ptr<X86_64TargetLayout> _x86_64TargetLayout;
std::unique_ptr<X86_64TargetRelocationHandler> _x86_64RelocationHandler;
More information about the llvm-commits
mailing list