blob: 9a311708f3ae33df1ec9513f07e660f63bce9cde [file] [log] [blame]
David L. Jonesf561aba2017-03-08 01:02:16 +00001//===--- CommonArgs.h - Args handling for multiple toolchains ---*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
David L. Jonesf561aba2017-03-08 01:02:16 +00006//
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"
Petr Hosekb58561b2019-04-27 00:25:13 +000014#include "clang/Driver/Multilib.h"
David L. Jonesf561aba2017-03-08 01:02:16 +000015#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
Dean Michael Berris62440372018-04-06 03:53:04 +000038bool 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
David L. Jonesf561aba2017-03-08 01:02:16 +000044void AddRunTimeLibs(const ToolChain &TC, const Driver &D,
45 llvm::opt::ArgStringList &CmdArgs,
46 const llvm::opt::ArgList &Args);
47
Gheorghe-Teodor Bercea2c926932017-08-08 14:33:05 +000048void 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
Yaxun Liu29155b02018-05-18 15:07:56 +000055void 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
David L. Jonesf561aba2017-03-08 01:02:16 +000061const char *SplitDebugName(const llvm::opt::ArgList &Args,
George Rimar36d71da2019-03-27 11:00:03 +000062 const InputInfo &Input, const InputInfo &Output);
David L. Jonesf561aba2017-03-08 01:02:16 +000063
64void 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
68void AddGoldPlugin(const ToolChain &ToolChain, const llvm::opt::ArgList &Args,
Florian Hahn2e081d12018-04-20 12:50:10 +000069 llvm::opt::ArgStringList &CmdArgs, const InputInfo &Output,
70 const InputInfo &Input, bool IsThinLTO);
David L. Jonesf561aba2017-03-08 01:02:16 +000071
72std::tuple<llvm::Reloc::Model, unsigned, bool>
73ParsePICArgs(const ToolChain &ToolChain, const llvm::opt::ArgList &Args);
74
Saleem Abdulrasool3fe5b7a2018-04-19 23:14:57 +000075unsigned ParseFunctionAlignment(const ToolChain &TC,
76 const llvm::opt::ArgList &Args);
77
David L. Jonesf561aba2017-03-08 01:02:16 +000078void AddAssemblerKPIC(const ToolChain &ToolChain,
79 const llvm::opt::ArgList &Args,
80 llvm::opt::ArgStringList &CmdArgs);
81
82void addArchSpecificRPath(const ToolChain &TC, const llvm::opt::ArgList &Args,
83 llvm::opt::ArgStringList &CmdArgs);
Jonas Hahnfeld8ea76fa2017-04-19 13:55:39 +000084/// Returns true, if an OpenMP runtime has been added.
85bool addOpenMPRuntime(llvm::opt::ArgStringList &CmdArgs, const ToolChain &TC,
86 const llvm::opt::ArgList &Args,
87 bool IsOffloadingHost = false, bool GompNeedsRT = false);
David L. Jonesf561aba2017-03-08 01:02:16 +000088
89llvm::opt::Arg *getLastProfileUseArg(const llvm::opt::ArgList &Args);
Dehao Chenea4b78f2017-03-21 21:40:53 +000090llvm::opt::Arg *getLastProfileSampleUseArg(const llvm::opt::ArgList &Args);
David L. Jonesf561aba2017-03-08 01:02:16 +000091
92bool isObjCAutoRefCount(const llvm::opt::ArgList &Args);
93
94unsigned getLTOParallelism(const llvm::opt::ArgList &Args, const Driver &D);
95
96bool areOptimizationsEnabled(const llvm::opt::ArgList &Args);
97
98bool isUseSeparateSections(const llvm::Triple &Triple);
99
100void addDirectoryList(const llvm::opt::ArgList &Args,
101 llvm::opt::ArgStringList &CmdArgs, const char *ArgName,
102 const char *EnvVar);
103
104void AddTargetFeature(const llvm::opt::ArgList &Args,
105 std::vector<StringRef> &Features,
106 llvm::opt::OptSpecifier OnOpt,
107 llvm::opt::OptSpecifier OffOpt, StringRef FeatureName);
108
109std::string getCPUName(const llvm::opt::ArgList &Args, const llvm::Triple &T,
110 bool FromAs = false);
111
112void handleTargetFeaturesGroup(const llvm::opt::ArgList &Args,
113 std::vector<StringRef> &Features,
114 llvm::opt::OptSpecifier Group);
115
Florian Hahn2e081d12018-04-20 12:50:10 +0000116/// Handles the -save-stats option and returns the filename to save statistics
117/// to.
118SmallString<128> getStatsFileName(const llvm::opt::ArgList &Args,
119 const InputInfo &Output,
120 const InputInfo &Input, const Driver &D);
Petr Hosekb58561b2019-04-27 00:25:13 +0000121
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.
124void addMultilibFlag(bool Enabled, const char *const Flag,
125 Multilib::flags_list &Flags);
126
David L. Jonesf561aba2017-03-08 01:02:16 +0000127} // end namespace tools
128} // end namespace driver
129} // end namespace clang
130
131#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_COMMONARGS_H