1 //===--- CommonArgs.h - Args handling for multiple toolchains ---*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_COMMONARGS_H 10 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_COMMONARGS_H 11 12 #include "InputInfo.h" 13 #include "clang/Driver/Driver.h" 14 #include "clang/Driver/Multilib.h" 15 #include "clang/Driver/Tool.h" 16 #include "clang/Driver/ToolChain.h" 17 #include "llvm/Support/CodeGen.h" 18 19 namespace clang { 20 namespace driver { 21 namespace tools { 22 23 void addPathIfExists(const Driver &D, const Twine &Path, 24 ToolChain::path_list &Paths); 25 26 void AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs, 27 const llvm::opt::ArgList &Args, 28 llvm::opt::ArgStringList &CmdArgs, const JobAction &JA); 29 30 void claimNoWarnArgs(const llvm::opt::ArgList &Args); 31 32 bool addSanitizerRuntimes(const ToolChain &TC, const llvm::opt::ArgList &Args, 33 llvm::opt::ArgStringList &CmdArgs); 34 35 void linkSanitizerRuntimeDeps(const ToolChain &TC, 36 llvm::opt::ArgStringList &CmdArgs); 37 38 bool addXRayRuntime(const ToolChain &TC, const llvm::opt::ArgList &Args, 39 llvm::opt::ArgStringList &CmdArgs); 40 41 void linkXRayRuntimeDeps(const ToolChain &TC, 42 llvm::opt::ArgStringList &CmdArgs); 43 44 void AddRunTimeLibs(const ToolChain &TC, const Driver &D, 45 llvm::opt::ArgStringList &CmdArgs, 46 const llvm::opt::ArgList &Args); 47 48 void AddOpenMPLinkerScript(const ToolChain &TC, Compilation &C, 49 const InputInfo &Output, 50 const InputInfoList &Inputs, 51 const llvm::opt::ArgList &Args, 52 llvm::opt::ArgStringList &CmdArgs, 53 const JobAction &JA); 54 55 void AddHIPLinkerScript(const ToolChain &TC, Compilation &C, 56 const InputInfo &Output, const InputInfoList &Inputs, 57 const llvm::opt::ArgList &Args, 58 llvm::opt::ArgStringList &CmdArgs, const JobAction &JA, 59 const Tool &T); 60 61 const char *SplitDebugName(const llvm::opt::ArgList &Args, 62 const InputInfo &Input, const InputInfo &Output); 63 64 void SplitDebugInfo(const ToolChain &TC, Compilation &C, const Tool &T, 65 const JobAction &JA, const llvm::opt::ArgList &Args, 66 const InputInfo &Output, const char *OutFile); 67 68 void AddGoldPlugin(const ToolChain &ToolChain, const llvm::opt::ArgList &Args, 69 llvm::opt::ArgStringList &CmdArgs, const InputInfo &Output, 70 const InputInfo &Input, bool IsThinLTO); 71 72 std::tuple<llvm::Reloc::Model, unsigned, bool> 73 ParsePICArgs(const ToolChain &ToolChain, const llvm::opt::ArgList &Args); 74 75 unsigned ParseFunctionAlignment(const ToolChain &TC, 76 const llvm::opt::ArgList &Args); 77 78 void AddAssemblerKPIC(const ToolChain &ToolChain, 79 const llvm::opt::ArgList &Args, 80 llvm::opt::ArgStringList &CmdArgs); 81 82 void addArchSpecificRPath(const ToolChain &TC, const llvm::opt::ArgList &Args, 83 llvm::opt::ArgStringList &CmdArgs); 84 /// Returns true, if an OpenMP runtime has been added. 85 bool addOpenMPRuntime(llvm::opt::ArgStringList &CmdArgs, const ToolChain &TC, 86 const llvm::opt::ArgList &Args, 87 bool IsOffloadingHost = false, bool GompNeedsRT = false); 88 89 llvm::opt::Arg *getLastProfileUseArg(const llvm::opt::ArgList &Args); 90 llvm::opt::Arg *getLastProfileSampleUseArg(const llvm::opt::ArgList &Args); 91 92 bool isObjCAutoRefCount(const llvm::opt::ArgList &Args); 93 94 unsigned getLTOParallelism(const llvm::opt::ArgList &Args, const Driver &D); 95 96 bool areOptimizationsEnabled(const llvm::opt::ArgList &Args); 97 98 bool isUseSeparateSections(const llvm::Triple &Triple); 99 100 void addDirectoryList(const llvm::opt::ArgList &Args, 101 llvm::opt::ArgStringList &CmdArgs, const char *ArgName, 102 const char *EnvVar); 103 104 void AddTargetFeature(const llvm::opt::ArgList &Args, 105 std::vector<StringRef> &Features, 106 llvm::opt::OptSpecifier OnOpt, 107 llvm::opt::OptSpecifier OffOpt, StringRef FeatureName); 108 109 std::string getCPUName(const llvm::opt::ArgList &Args, const llvm::Triple &T, 110 bool FromAs = false); 111 112 void handleTargetFeaturesGroup(const llvm::opt::ArgList &Args, 113 std::vector<StringRef> &Features, 114 llvm::opt::OptSpecifier Group); 115 116 /// Handles the -save-stats option and returns the filename to save statistics 117 /// to. 118 SmallString<128> getStatsFileName(const llvm::opt::ArgList &Args, 119 const InputInfo &Output, 120 const InputInfo &Input, const Driver &D); 121 122 /// \p Flag must be a flag accepted by the driver with its leading '-' removed, 123 // otherwise '-print-multi-lib' will not emit them correctly. 124 void addMultilibFlag(bool Enabled, const char *const Flag, 125 Multilib::flags_list &Flags); 126 127 } // end namespace tools 128 } // end namespace driver 129 } // end namespace clang 130 131 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_COMMONARGS_H 132