1 //===--- CommonArgs.h - Args handling for multiple toolchains ---*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_COMMONARGS_H
10 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_COMMONARGS_H
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"
23 void addPathIfExists(const Driver &D, const Twine &Path,
24 ToolChain::path_list &Paths);
26 void AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs,
27 const llvm::opt::ArgList &Args,
28 llvm::opt::ArgStringList &CmdArgs, const JobAction &JA);
30 void claimNoWarnArgs(const llvm::opt::ArgList &Args);
32 bool addSanitizerRuntimes(const ToolChain &TC, const llvm::opt::ArgList &Args,
33 llvm::opt::ArgStringList &CmdArgs);
35 void linkSanitizerRuntimeDeps(const ToolChain &TC,
36 llvm::opt::ArgStringList &CmdArgs);
38 bool addXRayRuntime(const ToolChain &TC, const llvm::opt::ArgList &Args,
39 llvm::opt::ArgStringList &CmdArgs);
41 void linkXRayRuntimeDeps(const ToolChain &TC,
42 llvm::opt::ArgStringList &CmdArgs);
44 void AddRunTimeLibs(const ToolChain &TC, const Driver &D,
45 llvm::opt::ArgStringList &CmdArgs,
46 const llvm::opt::ArgList &Args);
48 void 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,
54 const char *SplitDebugName(const llvm::opt::ArgList &Args,
55 const InputInfo &Input, const InputInfo &Output);
57 void 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);
61 void AddGoldPlugin(const ToolChain &ToolChain, const llvm::opt::ArgList &Args,
62 llvm::opt::ArgStringList &CmdArgs, const InputInfo &Output,
63 const InputInfo &Input, bool IsThinLTO);
65 std::tuple<llvm::Reloc::Model, unsigned, bool>
66 ParsePICArgs(const ToolChain &ToolChain, const llvm::opt::ArgList &Args);
68 unsigned ParseFunctionAlignment(const ToolChain &TC,
69 const llvm::opt::ArgList &Args);
71 void AddAssemblerKPIC(const ToolChain &ToolChain,
72 const llvm::opt::ArgList &Args,
73 llvm::opt::ArgStringList &CmdArgs);
75 void addArchSpecificRPath(const ToolChain &TC, const llvm::opt::ArgList &Args,
76 llvm::opt::ArgStringList &CmdArgs);
77 /// Returns true, if an OpenMP runtime has been added.
78 bool addOpenMPRuntime(llvm::opt::ArgStringList &CmdArgs, const ToolChain &TC,
79 const llvm::opt::ArgList &Args,
80 bool ForceStaticHostRuntime = false,
81 bool IsOffloadingHost = false, bool GompNeedsRT = false);
83 llvm::opt::Arg *getLastProfileUseArg(const llvm::opt::ArgList &Args);
84 llvm::opt::Arg *getLastProfileSampleUseArg(const llvm::opt::ArgList &Args);
86 bool isObjCAutoRefCount(const llvm::opt::ArgList &Args);
88 unsigned getLTOParallelism(const llvm::opt::ArgList &Args, const Driver &D);
90 bool areOptimizationsEnabled(const llvm::opt::ArgList &Args);
92 bool isUseSeparateSections(const llvm::Triple &Triple);
94 void addDirectoryList(const llvm::opt::ArgList &Args,
95 llvm::opt::ArgStringList &CmdArgs, const char *ArgName,
98 void AddTargetFeature(const llvm::opt::ArgList &Args,
99 std::vector<StringRef> &Features,
100 llvm::opt::OptSpecifier OnOpt,
101 llvm::opt::OptSpecifier OffOpt, StringRef FeatureName);
103 std::string getCPUName(const llvm::opt::ArgList &Args, const llvm::Triple &T,
104 bool FromAs = false);
106 void handleTargetFeaturesGroup(const llvm::opt::ArgList &Args,
107 std::vector<StringRef> &Features,
108 llvm::opt::OptSpecifier Group);
110 /// Handles the -save-stats option and returns the filename to save statistics
112 SmallString<128> getStatsFileName(const llvm::opt::ArgList &Args,
113 const InputInfo &Output,
114 const InputInfo &Input, const Driver &D);
116 /// \p Flag must be a flag accepted by the driver with its leading '-' removed,
117 // otherwise '-print-multi-lib' will not emit them correctly.
118 void addMultilibFlag(bool Enabled, const char *const Flag,
119 Multilib::flags_list &Flags);
121 StringRef getTargetABI(const llvm::opt::ArgList &Args,
122 const llvm::Triple &Triple);
124 void getTargetFeatures(const ToolChain &TC, const llvm::Triple &Triple,
125 const llvm::opt::ArgList &Args,
126 llvm::opt::ArgStringList &CmdArgs, bool ForAS,
127 bool ForLTOPlugin = false);
129 } // end namespace tools
130 } // end namespace driver
131 } // end namespace clang
133 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_COMMONARGS_H