From ecc6de35fba933b1081a7847b3687f2e99b3e34c Mon Sep 17 00:00:00 2001 From: "David L. Jones" Date: Fri, 24 Feb 2017 00:28:01 +0000 Subject: [Driver] Move architecture-specific free helper functions to their own files. This patch moves helper functions that are CPU-specific out of Driver.cpp and to separate implementation files. The new files are named for the architecture, e.g. ARMArch.cpp. The next step after this will be to move OS-specific code, which I expect will include many of the tool implementations, to similarly separate files. Some CPU-specific functions are not being moved just yet. In cases where the only caller is the platform-specific tools, I plan to move them together. An example is Hexagon, where the only caller of the architecture-specific functions are the tools themselves. (I'm happy to revise this choice, it just seems like less churn to me.) This does mean that some functions which were previously static are now exposed through the library header Driver.h. Reviewers: rsmith, javed.absar Subscribers: aemerson, danalbert, srhines, dschuff, jyknight, nemanjai, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D30315 llvm-svn: 296056 --- clang/lib/Driver/Tools.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'clang/lib/Driver/Tools.h') diff --git a/clang/lib/Driver/Tools.h b/clang/lib/Driver/Tools.h index 9d5b892d424..33f940ae424 100644 --- a/clang/lib/Driver/Tools.h +++ b/clang/lib/Driver/Tools.h @@ -38,11 +38,23 @@ class Compiler; } using llvm::opt::ArgStringList; +using llvm::opt::ArgList; SmallString<128> getCompilerRT(const ToolChain &TC, const llvm::opt::ArgList &Args, StringRef Component, bool Shared = false); +std::string getCPUName(const ArgList &Args, const llvm::Triple &T, + bool FromAs = false); + +void AddTargetFeature(const ArgList &Args, std::vector &Features, + llvm::opt::OptSpecifier OnOpt, + llvm::opt::OptSpecifier OffOpt, StringRef FeatureName); + +void handleTargetFeaturesGroup(const ArgList &Args, + std::vector &Features, + llvm::opt::OptSpecifier Group); + /// \brief Clang compiler tool. class LLVM_LIBRARY_VISIBILITY Clang : public Tool { public: @@ -321,6 +333,11 @@ bool hasCompactBranches(StringRef &CPU); void getMipsCPUAndABI(const llvm::opt::ArgList &Args, const llvm::Triple &Triple, StringRef &CPUName, StringRef &ABIName); +void getMIPSTargetFeatures(const Driver &D, const llvm::Triple &Triple, + const ArgList &Args, + std::vector &Features); +StringRef getGnuCompatibleMipsABIName(StringRef ABI); +mips::FloatABI getMipsFloatABI(const Driver &D, const ArgList &Args); std::string getMipsABILibSuffix(const llvm::opt::ArgList &Args, const llvm::Triple &Triple); bool hasMipsAbiArg(const llvm::opt::ArgList &Args, const char *Value); @@ -332,6 +349,7 @@ bool isFPXXDefault(const llvm::Triple &Triple, StringRef CPUName, bool shouldUseFPXX(const llvm::opt::ArgList &Args, const llvm::Triple &Triple, StringRef CPUName, StringRef ABIName, mips::FloatABI FloatABI); + } // end namespace mips namespace ppc { @@ -803,8 +821,23 @@ enum class FloatABI { }; FloatABI getARMFloatABI(const ToolChain &TC, const llvm::opt::ArgList &Args); + +bool useAAPCSForMachO(const llvm::Triple &T); +void getARMArchCPUFromArgs(const ArgList &Args, llvm::StringRef &Arch, + llvm::StringRef &CPU, bool FromAs = false); +void getARMTargetFeatures(const ToolChain &TC, const llvm::Triple &Triple, + const ArgList &Args, ArgStringList &CmdArgs, + std::vector &Features, bool ForAS); +int getARMSubArchVersionNumber(const llvm::Triple &Triple); +bool isARMMProfile(const llvm::Triple &Triple); } // end namespace arm +namespace aarch64 { +void getAArch64TargetFeatures(const Driver &D, const ArgList &Args, + std::vector &Features); +std::string getAArch64TargetCPU(const ArgList &Args, llvm::opt::Arg *&A); +} // end namespace aarch64 + namespace ppc { enum class FloatABI { Invalid, @@ -813,6 +846,11 @@ enum class FloatABI { }; FloatABI getPPCFloatABI(const Driver &D, const llvm::opt::ArgList &Args); + +std::string getPPCTargetCPU(const ArgList &Args); +void getPPCTargetFeatures(const Driver &D, const llvm::Triple &Triple, + const ArgList &Args, + std::vector &Features); } // end namespace ppc namespace sparc { @@ -823,6 +861,11 @@ enum class FloatABI { }; FloatABI getSparcFloatABI(const Driver &D, const llvm::opt::ArgList &Args); + +void getSparcTargetFeatures(const Driver &D, const ArgList &Args, + std::vector &Features); +const char *getSparcAsmModeForCPU(StringRef Name, + const llvm::Triple &Triple); } // end namespace sparc namespace XCore { @@ -1003,6 +1046,20 @@ public: }; } // end namespace AVR +namespace systemz { +const char *getSystemZTargetCPU(const ArgList &Args); +void getSystemZTargetFeatures(const ArgList &Args, + std::vector &Features); +} // end namespace systemz + +namespace x86 { +const char *getX86TargetCPU(const ArgList &Args, + const llvm::Triple &Triple); +void getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple, + const ArgList &Args, + std::vector &Features); +} // end namespace x86 + } // end namespace tools } // end namespace driver } // end namespace clang -- cgit v1.2.3