xref: /netbsd-src/external/apache2/llvm/dist/clang/lib/Driver/ToolChains/CommonArgs.h (revision e038c9c4676b0f19b1b7dd08a940c6ed64a6d5ae)
17330f729Sjoerg //===--- CommonArgs.h - Args handling for multiple toolchains ---*- C++ -*-===//
27330f729Sjoerg //
37330f729Sjoerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
47330f729Sjoerg // See https://llvm.org/LICENSE.txt for license information.
57330f729Sjoerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
67330f729Sjoerg //
77330f729Sjoerg //===----------------------------------------------------------------------===//
87330f729Sjoerg 
97330f729Sjoerg #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_COMMONARGS_H
107330f729Sjoerg #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_COMMONARGS_H
117330f729Sjoerg 
127330f729Sjoerg #include "InputInfo.h"
137330f729Sjoerg #include "clang/Driver/Driver.h"
147330f729Sjoerg #include "clang/Driver/Multilib.h"
157330f729Sjoerg #include "clang/Driver/Tool.h"
167330f729Sjoerg #include "clang/Driver/ToolChain.h"
177330f729Sjoerg #include "llvm/Support/CodeGen.h"
187330f729Sjoerg 
197330f729Sjoerg namespace clang {
207330f729Sjoerg namespace driver {
217330f729Sjoerg namespace tools {
227330f729Sjoerg 
237330f729Sjoerg void addPathIfExists(const Driver &D, const Twine &Path,
247330f729Sjoerg                      ToolChain::path_list &Paths);
257330f729Sjoerg 
267330f729Sjoerg void AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs,
277330f729Sjoerg                      const llvm::opt::ArgList &Args,
287330f729Sjoerg                      llvm::opt::ArgStringList &CmdArgs, const JobAction &JA);
297330f729Sjoerg 
30*e038c9c4Sjoerg void addLinkerCompressDebugSectionsOption(const ToolChain &TC,
31*e038c9c4Sjoerg                                           const llvm::opt::ArgList &Args,
32*e038c9c4Sjoerg                                           llvm::opt::ArgStringList &CmdArgs);
33*e038c9c4Sjoerg 
347330f729Sjoerg void claimNoWarnArgs(const llvm::opt::ArgList &Args);
357330f729Sjoerg 
367330f729Sjoerg bool addSanitizerRuntimes(const ToolChain &TC, const llvm::opt::ArgList &Args,
377330f729Sjoerg                           llvm::opt::ArgStringList &CmdArgs);
387330f729Sjoerg 
397330f729Sjoerg void linkSanitizerRuntimeDeps(const ToolChain &TC,
407330f729Sjoerg                               llvm::opt::ArgStringList &CmdArgs);
417330f729Sjoerg 
427330f729Sjoerg bool addXRayRuntime(const ToolChain &TC, const llvm::opt::ArgList &Args,
437330f729Sjoerg                     llvm::opt::ArgStringList &CmdArgs);
447330f729Sjoerg 
457330f729Sjoerg void linkXRayRuntimeDeps(const ToolChain &TC,
467330f729Sjoerg                          llvm::opt::ArgStringList &CmdArgs);
477330f729Sjoerg 
487330f729Sjoerg void AddRunTimeLibs(const ToolChain &TC, const Driver &D,
497330f729Sjoerg                     llvm::opt::ArgStringList &CmdArgs,
507330f729Sjoerg                     const llvm::opt::ArgList &Args);
517330f729Sjoerg 
52*e038c9c4Sjoerg const char *SplitDebugName(const JobAction &JA, const llvm::opt::ArgList &Args,
537330f729Sjoerg                            const InputInfo &Input, const InputInfo &Output);
547330f729Sjoerg 
557330f729Sjoerg void SplitDebugInfo(const ToolChain &TC, Compilation &C, const Tool &T,
567330f729Sjoerg                     const JobAction &JA, const llvm::opt::ArgList &Args,
577330f729Sjoerg                     const InputInfo &Output, const char *OutFile);
587330f729Sjoerg 
59*e038c9c4Sjoerg void addLTOOptions(const ToolChain &ToolChain, const llvm::opt::ArgList &Args,
607330f729Sjoerg                    llvm::opt::ArgStringList &CmdArgs, const InputInfo &Output,
617330f729Sjoerg                    const InputInfo &Input, bool IsThinLTO);
627330f729Sjoerg 
637330f729Sjoerg std::tuple<llvm::Reloc::Model, unsigned, bool>
647330f729Sjoerg ParsePICArgs(const ToolChain &ToolChain, const llvm::opt::ArgList &Args);
657330f729Sjoerg 
667330f729Sjoerg unsigned ParseFunctionAlignment(const ToolChain &TC,
677330f729Sjoerg                                 const llvm::opt::ArgList &Args);
687330f729Sjoerg 
69*e038c9c4Sjoerg unsigned ParseDebugDefaultVersion(const ToolChain &TC,
70*e038c9c4Sjoerg                                   const llvm::opt::ArgList &Args);
71*e038c9c4Sjoerg 
727330f729Sjoerg void AddAssemblerKPIC(const ToolChain &ToolChain,
737330f729Sjoerg                       const llvm::opt::ArgList &Args,
747330f729Sjoerg                       llvm::opt::ArgStringList &CmdArgs);
757330f729Sjoerg 
767330f729Sjoerg void addArchSpecificRPath(const ToolChain &TC, const llvm::opt::ArgList &Args,
777330f729Sjoerg                           llvm::opt::ArgStringList &CmdArgs);
787330f729Sjoerg /// Returns true, if an OpenMP runtime has been added.
797330f729Sjoerg bool addOpenMPRuntime(llvm::opt::ArgStringList &CmdArgs, const ToolChain &TC,
807330f729Sjoerg                       const llvm::opt::ArgList &Args,
817330f729Sjoerg                       bool ForceStaticHostRuntime = false,
827330f729Sjoerg                       bool IsOffloadingHost = false, bool GompNeedsRT = false);
837330f729Sjoerg 
847330f729Sjoerg llvm::opt::Arg *getLastProfileUseArg(const llvm::opt::ArgList &Args);
857330f729Sjoerg llvm::opt::Arg *getLastProfileSampleUseArg(const llvm::opt::ArgList &Args);
867330f729Sjoerg 
877330f729Sjoerg bool isObjCAutoRefCount(const llvm::opt::ArgList &Args);
887330f729Sjoerg 
89*e038c9c4Sjoerg llvm::StringRef getLTOParallelism(const llvm::opt::ArgList &Args,
90*e038c9c4Sjoerg                                   const Driver &D);
917330f729Sjoerg 
927330f729Sjoerg bool areOptimizationsEnabled(const llvm::opt::ArgList &Args);
937330f729Sjoerg 
947330f729Sjoerg bool isUseSeparateSections(const llvm::Triple &Triple);
957330f729Sjoerg 
96*e038c9c4Sjoerg /// \p EnvVar is split by system delimiter for environment variables.
97*e038c9c4Sjoerg /// If \p ArgName is "-I", "-L", or an empty string, each entry from \p EnvVar
98*e038c9c4Sjoerg /// is prefixed by \p ArgName then added to \p Args. Otherwise, for each
99*e038c9c4Sjoerg /// entry of \p EnvVar, \p ArgName is added to \p Args first, then the entry
100*e038c9c4Sjoerg /// itself is added.
1017330f729Sjoerg void addDirectoryList(const llvm::opt::ArgList &Args,
1027330f729Sjoerg                       llvm::opt::ArgStringList &CmdArgs, const char *ArgName,
1037330f729Sjoerg                       const char *EnvVar);
1047330f729Sjoerg 
1057330f729Sjoerg void AddTargetFeature(const llvm::opt::ArgList &Args,
1067330f729Sjoerg                       std::vector<StringRef> &Features,
1077330f729Sjoerg                       llvm::opt::OptSpecifier OnOpt,
1087330f729Sjoerg                       llvm::opt::OptSpecifier OffOpt, StringRef FeatureName);
1097330f729Sjoerg 
1107330f729Sjoerg std::string getCPUName(const llvm::opt::ArgList &Args, const llvm::Triple &T,
1117330f729Sjoerg                        bool FromAs = false);
1127330f729Sjoerg 
113*e038c9c4Sjoerg /// Iterate \p Args and convert -mxxx to +xxx and -mno-xxx to -xxx and
114*e038c9c4Sjoerg /// append it to \p Features.
115*e038c9c4Sjoerg ///
116*e038c9c4Sjoerg /// Note: Since \p Features may contain default values before calling
117*e038c9c4Sjoerg /// this function, or may be appended with entries to override arguments,
118*e038c9c4Sjoerg /// entries in \p Features are not unique.
1197330f729Sjoerg void handleTargetFeaturesGroup(const llvm::opt::ArgList &Args,
1207330f729Sjoerg                                std::vector<StringRef> &Features,
1217330f729Sjoerg                                llvm::opt::OptSpecifier Group);
1227330f729Sjoerg 
123*e038c9c4Sjoerg /// If there are multiple +xxx or -xxx features, keep the last one.
124*e038c9c4Sjoerg std::vector<StringRef>
125*e038c9c4Sjoerg unifyTargetFeatures(const std::vector<StringRef> &Features);
126*e038c9c4Sjoerg 
1277330f729Sjoerg /// Handles the -save-stats option and returns the filename to save statistics
1287330f729Sjoerg /// to.
1297330f729Sjoerg SmallString<128> getStatsFileName(const llvm::opt::ArgList &Args,
1307330f729Sjoerg                                   const InputInfo &Output,
1317330f729Sjoerg                                   const InputInfo &Input, const Driver &D);
1327330f729Sjoerg 
1337330f729Sjoerg /// \p Flag must be a flag accepted by the driver with its leading '-' removed,
1347330f729Sjoerg //     otherwise '-print-multi-lib' will not emit them correctly.
1357330f729Sjoerg void addMultilibFlag(bool Enabled, const char *const Flag,
1367330f729Sjoerg                      Multilib::flags_list &Flags);
1377330f729Sjoerg 
138*e038c9c4Sjoerg void addX86AlignBranchArgs(const Driver &D, const llvm::opt::ArgList &Args,
139*e038c9c4Sjoerg                            llvm::opt::ArgStringList &CmdArgs, bool IsLTO);
1407330f729Sjoerg 
141*e038c9c4Sjoerg void checkAMDGPUCodeObjectVersion(const Driver &D,
142*e038c9c4Sjoerg                                   const llvm::opt::ArgList &Args);
1437330f729Sjoerg 
144*e038c9c4Sjoerg unsigned getAMDGPUCodeObjectVersion(const Driver &D,
145*e038c9c4Sjoerg                                     const llvm::opt::ArgList &Args);
146*e038c9c4Sjoerg 
147*e038c9c4Sjoerg bool haveAMDGPUCodeObjectVersionArgument(const Driver &D,
148*e038c9c4Sjoerg                                          const llvm::opt::ArgList &Args);
149*e038c9c4Sjoerg 
150*e038c9c4Sjoerg void addMachineOutlinerArgs(const Driver &D, const llvm::opt::ArgList &Args,
151*e038c9c4Sjoerg                             llvm::opt::ArgStringList &CmdArgs,
152*e038c9c4Sjoerg                             const llvm::Triple &Triple, bool IsLTO);
153*e038c9c4Sjoerg 
154*e038c9c4Sjoerg void addOpenMPDeviceRTL(const Driver &D, const llvm::opt::ArgList &DriverArgs,
155*e038c9c4Sjoerg                         llvm::opt::ArgStringList &CC1Args,
156*e038c9c4Sjoerg                         StringRef BitcodeSuffix, const llvm::Triple &Triple);
1577330f729Sjoerg } // end namespace tools
1587330f729Sjoerg } // end namespace driver
1597330f729Sjoerg } // end namespace clang
1607330f729Sjoerg 
1617330f729Sjoerg #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_COMMONARGS_H
162