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