diff options
author | Ikhlas Ajbar <iajbar@codeaurora.org> | 2015-05-14 13:52:08 +0000 |
---|---|---|
committer | Ikhlas Ajbar <iajbar@codeaurora.org> | 2015-05-14 13:52:08 +0000 |
commit | 522e6196f77a8fae8d20646a176426c2987e732f (patch) | |
tree | 1b46cf717e54c28b9677cd39dd703c26d9cb26a1 /clang/lib/Driver/Tools.cpp | |
parent | 772155cbc6a2592fc9204b083263ded74b378645 (diff) | |
download | bcm5719-llvm-522e6196f77a8fae8d20646a176426c2987e732f.tar.gz bcm5719-llvm-522e6196f77a8fae8d20646a176426c2987e732f.zip |
Factor out SmallDataThreshold
This patch factors out SmallDataThreshold code.
llvm-svn: 237364
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
-rw-r--r-- | clang/lib/Driver/Tools.cpp | 42 |
1 files changed, 11 insertions, 31 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index ee9b495edbf..ec00ff1d917 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -1734,34 +1734,17 @@ static inline bool HasPICArg(const ArgList &Args) { || Args.hasArg(options::OPT_fpic); } -static Arg *GetLastSmallDataThresholdArg(const ArgList &Args) { - return Args.getLastArg(options::OPT_G, - options::OPT_G_EQ, - options::OPT_msmall_data_threshold_EQ); -} - -static std::string GetHexagonSmallDataThresholdValue(const ArgList &Args) { - std::string value; - if (HasPICArg(Args)) - value = "0"; - else if (Arg *A = GetLastSmallDataThresholdArg(Args)) { - value = A->getValue(); - A->claim(); - } - return value; -} - void Clang::AddHexagonTargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const { CmdArgs.push_back("-fno-signed-char"); CmdArgs.push_back("-mqdsp6-compat"); CmdArgs.push_back("-Wreturn-type"); - std::string SmallDataThreshold = GetHexagonSmallDataThresholdValue(Args); - if (!SmallDataThreshold.empty()) { + if (const char* v = toolchains::Hexagon_TC::GetSmallDataThreshold(Args)) { + std::string SmallDataThreshold="-hexagon-small-data-threshold="; + SmallDataThreshold += v; CmdArgs.push_back ("-mllvm"); - CmdArgs.push_back(Args.MakeArgString( - "-hexagon-small-data-threshold=" + SmallDataThreshold)); + CmdArgs.push_back(Args.MakeArgString(SmallDataThreshold)); } if (!Args.hasArg(options::OPT_fno_short_enums)) @@ -5408,10 +5391,8 @@ void hexagon::Assemble::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-fsyntax-only"); } - std::string SmallDataThreshold = GetHexagonSmallDataThresholdValue(Args); - if (!SmallDataThreshold.empty()) - CmdArgs.push_back( - Args.MakeArgString(std::string("-G") + SmallDataThreshold)); + if (const char* v = toolchains::Hexagon_TC::GetSmallDataThreshold(Args)) + CmdArgs.push_back(Args.MakeArgString(std::string("-G") + v)); Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, options::OPT_Xassembler); @@ -5474,6 +5455,7 @@ static void constructHexagonLinkArgs(Compilation &C, const JobAction &JA, bool incStdLib = !Args.hasArg(options::OPT_nostdlib); bool incStartFiles = !Args.hasArg(options::OPT_nostartfiles); bool incDefLibs = !Args.hasArg(options::OPT_nodefaultlibs); + bool useG0 = false; bool useShared = buildingLib && !hasStaticArg; //---------------------------------------------------------------------------- @@ -5507,10 +5489,9 @@ static void constructHexagonLinkArgs(Compilation &C, const JobAction &JA, if (buildPIE && !buildingLib) CmdArgs.push_back("-pie"); - std::string SmallDataThreshold = GetHexagonSmallDataThresholdValue(Args); - if (!SmallDataThreshold.empty()) { - CmdArgs.push_back( - Args.MakeArgString(std::string("-G") + SmallDataThreshold)); + if (const char* v = toolchains::Hexagon_TC::GetSmallDataThreshold(Args)) { + CmdArgs.push_back(Args.MakeArgString(std::string("-G") + v)); + useG0 = toolchains::Hexagon_TC::UsesG0(v); } //---------------------------------------------------------------------------- @@ -5526,8 +5507,7 @@ static void constructHexagonLinkArgs(Compilation &C, const JobAction &JA, toolchains::Hexagon_TC::GetGnuDir(D.InstalledDir, Args) + "/"; const std::string StartFilesDir = RootDir + "hexagon/lib" - + (buildingLib - ? MarchG0Suffix : MarchSuffix); + + (useG0 ? MarchG0Suffix : MarchSuffix); //---------------------------------------------------------------------------- // moslib |