[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
//===--- Myriad.h - Myriad ToolChain Implementations ------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MYRIAD_H
|
|
|
|
#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MYRIAD_H
|
|
|
|
|
|
|
|
#include "Gnu.h"
|
|
|
|
#include "clang/Driver/Tool.h"
|
|
|
|
#include "clang/Driver/ToolChain.h"
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace driver {
|
|
|
|
namespace tools {
|
|
|
|
|
|
|
|
/// SHAVE tools -- Directly call moviCompile and moviAsm
|
|
|
|
namespace SHAVE {
|
|
|
|
class LLVM_LIBRARY_VISIBILITY Compiler : public Tool {
|
|
|
|
public:
|
|
|
|
Compiler(const ToolChain &TC) : Tool("moviCompile", "movicompile", TC) {}
|
|
|
|
|
|
|
|
bool hasIntegratedCPP() const override { return true; }
|
|
|
|
|
|
|
|
void ConstructJob(Compilation &C, const JobAction &JA,
|
|
|
|
const InputInfo &Output, const InputInfoList &Inputs,
|
|
|
|
const llvm::opt::ArgList &TCArgs,
|
|
|
|
const char *LinkingOutput) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
|
|
|
|
public:
|
|
|
|
Assembler(const ToolChain &TC) : Tool("moviAsm", "moviAsm", TC) {}
|
|
|
|
|
|
|
|
bool hasIntegratedCPP() const override { return false; } // not sure.
|
|
|
|
|
|
|
|
void ConstructJob(Compilation &C, const JobAction &JA,
|
|
|
|
const InputInfo &Output, const InputInfoList &Inputs,
|
|
|
|
const llvm::opt::ArgList &TCArgs,
|
|
|
|
const char *LinkingOutput) const override;
|
|
|
|
};
|
|
|
|
} // end namespace SHAVE
|
|
|
|
|
|
|
|
/// The Myriad toolchain uses tools that are in two different namespaces.
|
|
|
|
/// The Compiler and Assembler as defined above are in the SHAVE namespace,
|
|
|
|
/// whereas the linker, which accepts code for a mixture of Sparc and SHAVE,
|
|
|
|
/// is in the Myriad namespace.
|
|
|
|
namespace Myriad {
|
|
|
|
class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
|
|
|
|
public:
|
|
|
|
Linker(const ToolChain &TC) : GnuTool("shave::Linker", "ld", TC) {}
|
|
|
|
bool hasIntegratedCPP() const override { return false; }
|
|
|
|
bool isLinkJob() const override { return true; }
|
|
|
|
void ConstructJob(Compilation &C, const JobAction &JA,
|
|
|
|
const InputInfo &Output, const InputInfoList &Inputs,
|
|
|
|
const llvm::opt::ArgList &TCArgs,
|
|
|
|
const char *LinkingOutput) const override;
|
|
|
|
};
|
|
|
|
} // end namespace Myriad
|
|
|
|
} // end namespace tools
|
|
|
|
|
|
|
|
namespace toolchains {
|
|
|
|
|
|
|
|
/// MyriadToolChain - A tool chain using either clang or the external compiler
|
|
|
|
/// installed by the Movidius SDK to perform all subcommands.
|
|
|
|
class LLVM_LIBRARY_VISIBILITY MyriadToolChain : public Generic_ELF {
|
|
|
|
public:
|
|
|
|
MyriadToolChain(const Driver &D, const llvm::Triple &Triple,
|
|
|
|
const llvm::opt::ArgList &Args);
|
|
|
|
~MyriadToolChain() override;
|
|
|
|
|
|
|
|
void
|
|
|
|
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
|
|
|
|
llvm::opt::ArgStringList &CC1Args) const override;
|
2018-04-11 03:55:55 +08:00
|
|
|
void addLibCxxIncludePaths(
|
|
|
|
const llvm::opt::ArgList &DriverArgs,
|
|
|
|
llvm::opt::ArgStringList &CC1Args) const override;
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
void addLibStdCxxIncludePaths(
|
|
|
|
const llvm::opt::ArgList &DriverArgs,
|
|
|
|
llvm::opt::ArgStringList &CC1Args) const override;
|
|
|
|
Tool *SelectTool(const JobAction &JA) const override;
|
|
|
|
unsigned GetDefaultDwarfVersion() const override { return 2; }
|
|
|
|
SanitizerMask getSupportedSanitizers() const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Tool *buildLinker() const override;
|
|
|
|
bool isShaveCompilation(const llvm::Triple &T) const {
|
|
|
|
return T.getArch() == llvm::Triple::shave;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
mutable std::unique_ptr<Tool> Compiler;
|
|
|
|
mutable std::unique_ptr<Tool> Assembler;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace toolchains
|
|
|
|
} // end namespace driver
|
|
|
|
} // end namespace clang
|
|
|
|
|
|
|
|
#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MYRIAD_H
|