[ELF][x86-64] Make the X86_64LinkingContext and X86_64TargetHandler derivable.

llvm-svn: 230593
This commit is contained in:
Michael J. Spencer 2015-02-26 00:47:34 +00:00
parent 49ff203ec4
commit 6a272cdc83
3 changed files with 21 additions and 14 deletions

View File

@ -12,22 +12,27 @@
#include "X86_64RelocationPass.h"
using namespace lld;
using namespace elf;
std::unique_ptr<ELFLinkingContext>
elf::X86_64LinkingContext::create(llvm::Triple triple) {
if (triple.getArch() == llvm::Triple::x86_64)
return std::unique_ptr<ELFLinkingContext>(
new elf::X86_64LinkingContext(triple));
return nullptr;
}
X86_64LinkingContext::X86_64LinkingContext(
llvm::Triple triple, std::unique_ptr<TargetHandlerBase> handler)
: ELFLinkingContext(triple, std::move(handler)) {}
elf::X86_64LinkingContext::X86_64LinkingContext(llvm::Triple triple)
: ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
new X86_64TargetHandler(*this))) {}
X86_64LinkingContext::X86_64LinkingContext(llvm::Triple triple)
: X86_64LinkingContext(triple,
llvm::make_unique<X86_64TargetHandler>(*this)) {}
void elf::X86_64LinkingContext::addPasses(PassManager &pm) {
void X86_64LinkingContext::addPasses(PassManager &pm) {
auto pass = createX86_64RelocationPass(*this);
if (pass)
pm.add(std::move(pass));
ELFLinkingContext::addPasses(pm);
}
std::unique_ptr<ELFLinkingContext>
X86_64LinkingContext::create(llvm::Triple triple) {
if (triple.getArch() == llvm::Triple::x86_64)
return std::unique_ptr<ELFLinkingContext>(
new elf::X86_64LinkingContext(triple));
return nullptr;
}

View File

@ -24,7 +24,9 @@ enum {
LLD_R_X86_64_GOTRELINDEX = 1024,
};
class X86_64LinkingContext final : public ELFLinkingContext {
class X86_64LinkingContext : public ELFLinkingContext {
protected:
X86_64LinkingContext(llvm::Triple, std::unique_ptr<TargetHandlerBase>);
public:
static std::unique_ptr<ELFLinkingContext> create(llvm::Triple);
X86_64LinkingContext(llvm::Triple);

View File

@ -26,7 +26,7 @@ public:
: TargetLayout(context) {}
};
class X86_64TargetHandler final
class X86_64TargetHandler
: public DefaultTargetHandler<X86_64ELFType> {
public:
X86_64TargetHandler(X86_64LinkingContext &context);
@ -51,7 +51,7 @@ public:
std::unique_ptr<Writer> getWriter() override;
private:
protected:
static const Registry::KindStrings kindStrings[];
X86_64LinkingContext &_context;
std::unique_ptr<X86_64TargetLayout> _x86_64TargetLayout;