[lld] r234728 - [Mips] Create MipsTargetHandler class object using factory functions
Simon Atanasyan
simon at atanasyan.com
Mon Apr 13 01:34:56 PDT 2015
Author: atanasyan
Date: Mon Apr 13 03:34:56 2015
New Revision: 234728
URL: http://llvm.org/viewvc/llvm-project?rev=234728&view=rev
Log:
[Mips] Create MipsTargetHandler class object using factory functions
Right now MIPS instantiates MipsTargetHandler using Mips32ELType and
Mips64ELType. And in the future we can add a couple more types. That
leads to the large object file size because compiler has to create
copies of MipsTargetHandler and all realted classes for each types used
for instantiation.
The patch introduces two factory functions and puts each of them into
the separate cpp file. That allows to reduce size of single object file.
Added:
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler32EL.cpp
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler64EL.cpp
Modified:
lld/trunk/lib/ReaderWriter/ELF/Mips/CMakeLists.txt
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/CMakeLists.txt?rev=234728&r1=234727&r2=234728&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/CMakeLists.txt (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/CMakeLists.txt Mon Apr 13 03:34:56 2015
@@ -4,6 +4,8 @@ add_llvm_library(lldMipsELFTarget
MipsLinkingContext.cpp
MipsRelocationHandler.cpp
MipsRelocationPass.cpp
+ MipsTargetHandler32EL.cpp
+ MipsTargetHandler64EL.cpp
LINK_LIBS
lldELF
lldReaderWriter
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp?rev=234728&r1=234727&r2=234728&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp Mon Apr 13 03:34:56 2015
@@ -24,15 +24,13 @@ elf::createMipsLinkingContext(llvm::Trip
return nullptr;
}
-typedef std::unique_ptr<TargetHandler> TargetHandlerPtr;
-
-static TargetHandlerPtr createTarget(llvm::Triple triple,
- MipsLinkingContext &ctx) {
+static std::unique_ptr<TargetHandler> createTarget(llvm::Triple triple,
+ MipsLinkingContext &ctx) {
switch (triple.getArch()) {
case llvm::Triple::mipsel:
- return TargetHandlerPtr(new MipsTargetHandler<Mips32ELType>(ctx));
+ return createMips32ELTargetHandler(ctx);
case llvm::Triple::mips64el:
- return TargetHandlerPtr(new MipsTargetHandler<Mips64ELType>(ctx));
+ return createMips64ELTargetHandler(ctx);
default:
llvm_unreachable("Unhandled arch");
}
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=234728&r1=234727&r2=234728&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h Mon Apr 13 03:34:56 2015
@@ -162,6 +162,11 @@ private:
MipsTargetLayout<ELFT> &_targetLayout;
};
+std::unique_ptr<TargetHandler>
+createMips32ELTargetHandler(MipsLinkingContext &ctx);
+std::unique_ptr<TargetHandler>
+createMips64ELTargetHandler(MipsLinkingContext &ctx);
+
} // end namespace elf
} // end namespace lld
Added: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler32EL.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler32EL.cpp?rev=234728&view=auto
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler32EL.cpp (added)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler32EL.cpp Mon Apr 13 03:34:56 2015
@@ -0,0 +1,18 @@
+//===- lib/ReaderWriter/ELF/Mips/MipsTargetHandler32EL.cpp ----------------===//
+//
+// The LLVM Linker
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "MipsTargetHandler.h"
+
+using namespace lld;
+using namespace lld::elf;
+
+std::unique_ptr<TargetHandler>
+lld::elf::createMips32ELTargetHandler(MipsLinkingContext &ctx) {
+ return llvm::make_unique<MipsTargetHandler<Mips32ELType>>(ctx);
+}
Added: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler64EL.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler64EL.cpp?rev=234728&view=auto
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler64EL.cpp (added)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler64EL.cpp Mon Apr 13 03:34:56 2015
@@ -0,0 +1,18 @@
+//===- lib/ReaderWriter/ELF/Mips/MipsTargetHandler64EL.cpp ----------------===//
+//
+// The LLVM Linker
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "MipsTargetHandler.h"
+
+using namespace lld;
+using namespace lld::elf;
+
+std::unique_ptr<TargetHandler>
+lld::elf::createMips64ELTargetHandler(MipsLinkingContext &ctx) {
+ return llvm::make_unique<MipsTargetHandler<Mips64ELType>>(ctx);
+}
More information about the llvm-commits
mailing list