diff options
author | David L. Jones <dlj@google.com> | 2017-03-08 01:02:16 +0000 |
---|---|---|
committer | David L. Jones <dlj@google.com> | 2017-03-08 01:02:16 +0000 |
commit | 1c814d10cf1a5085e5b0496c6707b3c44ba86eb5 (patch) | |
tree | 4ed99109d1c3686579c17615e526479fb7b58bfe /lib/Driver/ToolChains/Hexagon.h | |
parent | 8e9494e0deb9375409f9fe35996d67145bc5fde1 (diff) | |
download | clang-1c814d10cf1a5085e5b0496c6707b3c44ba86eb5.tar.gz |
[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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@297250 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/ToolChains/Hexagon.h')
-rw-r--r-- | lib/Driver/ToolChains/Hexagon.h | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/lib/Driver/ToolChains/Hexagon.h b/lib/Driver/ToolChains/Hexagon.h new file mode 100644 index 0000000000..fb50ba3c72 --- /dev/null +++ b/lib/Driver/ToolChains/Hexagon.h @@ -0,0 +1,99 @@ +//===--- Hexagon.h - Hexagon 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_HEXAGON_H +#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HEXAGON_H + +#include "Linux.h" +#include "clang/Driver/Tool.h" +#include "clang/Driver/ToolChain.h" + +namespace clang { +namespace driver { +namespace tools { +namespace hexagon { +// For Hexagon, we do not need to instantiate tools for PreProcess, PreCompile +// and Compile. +// We simply use "clang -cc1" for those actions. +class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool { +public: + Assembler(const ToolChain &TC) + : GnuTool("hexagon::Assembler", "hexagon-as", TC) {} + + bool hasIntegratedCPP() const override { return false; } + + void RenderExtraToolArgs(const JobAction &JA, + llvm::opt::ArgStringList &CmdArgs) const; + 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 Linker : public GnuTool { +public: + Linker(const ToolChain &TC) : GnuTool("hexagon::Linker", "hexagon-ld", TC) {} + + bool hasIntegratedCPP() const override { return false; } + bool isLinkJob() const override { return true; } + + virtual void RenderExtraToolArgs(const JobAction &JA, + llvm::opt::ArgStringList &CmdArgs) const; + 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 hexagon. +} // end namespace tools + +namespace toolchains { + +class LLVM_LIBRARY_VISIBILITY HexagonToolChain : public Linux { +protected: + GCCVersion GCCLibAndIncVersion; + Tool *buildAssembler() const override; + Tool *buildLinker() const override; + +public: + HexagonToolChain(const Driver &D, const llvm::Triple &Triple, + const llvm::opt::ArgList &Args); + ~HexagonToolChain() override; + + void + AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args) const override; + void addLibStdCxxIncludePaths( + const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args) const override; + CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override; + + StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; } + bool IsIntegratedAssemblerDefault() const override { + return true; + } + + std::string getHexagonTargetDir( + const std::string &InstalledDir, + const SmallVectorImpl<std::string> &PrefixDirs) const; + void getHexagonLibraryPaths(const llvm::opt::ArgList &Args, + ToolChain::path_list &LibPaths) const; + + static const StringRef GetDefaultCPU(); + static const StringRef GetTargetCPUVersion(const llvm::opt::ArgList &Args); + + static Optional<unsigned> getSmallDataThreshold( + const llvm::opt::ArgList &Args); +}; + +} // end namespace toolchains +} // end namespace driver +} // end namespace clang + +#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HEXAGON_H |