10 #ifndef LLVM_CLANG_DRIVER_TOOLCHAIN_H 11 #define LLVM_CLANG_DRIVER_TOOLCHAIN_H 20 #include "llvm/ADT/ArrayRef.h" 21 #include "llvm/ADT/SmallVector.h" 22 #include "llvm/ADT/StringRef.h" 23 #include "llvm/ADT/Triple.h" 24 #include "llvm/MC/MCTargetOptions.h" 25 #include "llvm/Option/Option.h" 26 #include "llvm/Support/VersionTuple.h" 27 #include "llvm/Target/TargetOptions.h" 70 const char *DriverMode =
nullptr;
73 bool TargetIsValid =
false;
77 : ModeSuffix(Suffix), DriverMode(Mode) {}
80 : TargetPrefix(Target), ModeSuffix(Suffix), DriverMode(Mode),
81 TargetIsValid(IsRegistered) {}
84 return TargetPrefix.empty() && ModeSuffix.empty() && DriverMode ==
nullptr;
113 const llvm::opt::ArgList &Args;
116 const llvm::opt::Arg *
const CachedRTTIArg;
129 mutable std::unique_ptr<Tool> Clang;
130 mutable std::unique_ptr<Tool>
Assemble;
131 mutable std::unique_ptr<Tool>
Link;
132 mutable std::unique_ptr<Tool> OffloadBundler;
134 Tool *getClang()
const;
135 Tool *getAssemble()
const;
136 Tool *getLink()
const;
137 Tool *getClangAs()
const;
138 Tool *getOffloadBundler()
const;
140 mutable std::unique_ptr<SanitizerArgs> SanitizerArguments;
141 mutable std::unique_ptr<XRayArgs> XRayArguments;
144 mutable llvm::Triple EffectiveTriple;
147 void setEffectiveTriple(llvm::Triple ET)
const {
148 EffectiveTriple = std::move(ET);
156 const llvm::opt::ArgList &Args);
158 void setTripleEnvironment(llvm::Triple::EnvironmentType Env);
160 virtual Tool *buildAssembler()
const;
161 virtual Tool *buildLinker()
const;
166 static void addSystemInclude(
const llvm::opt::ArgList &DriverArgs,
167 llvm::opt::ArgStringList &CC1Args,
169 static void addExternCSystemInclude(
const llvm::opt::ArgList &DriverArgs,
170 llvm::opt::ArgStringList &CC1Args,
173 addExternCSystemIncludeIfExists(
const llvm::opt::ArgList &DriverArgs,
174 llvm::opt::ArgStringList &CC1Args,
176 static void addSystemIncludes(
const llvm::opt::ArgList &DriverArgs,
177 llvm::opt::ArgStringList &CC1Args,
187 llvm::vfs::FileSystem &getVFS()
const;
188 const llvm::Triple &
getTriple()
const {
return Triple; }
200 virtual std::string getInputFilename(
const InputInfo &Input)
const;
202 llvm::Triple::ArchType
getArch()
const {
return Triple.getArch(); }
205 StringRef
getOS()
const {
return Triple.getOSName(); }
209 StringRef getDefaultUniversalArchName()
const;
212 return Triple.getTriple();
217 assert(!EffectiveTriple.getTriple().empty() &&
"No effective triple");
218 return EffectiveTriple;
236 const XRayArgs& getXRayArgs()
const;
239 const llvm::opt::Arg *
getRTTIArg()
const {
return CachedRTTIArg; }
258 static ParsedClangName getTargetAndModeFromProgramName(StringRef ProgName);
270 virtual llvm::opt::DerivedArgList *
279 virtual llvm::opt::DerivedArgList *TranslateOpenMPTargetArgs(
280 const llvm::opt::DerivedArgList &Args,
bool SameTripleAsHost,
291 std::string GetFilePath(
const char *Name)
const;
292 std::string GetProgramPath(
const char *Name)
const;
296 std::string GetLinkerPath()
const;
309 virtual bool isCrossCompiling()
const;
313 virtual bool HasNativeLLVMSupport()
const;
317 virtual types::ID LookupTypeForExtension(StringRef Ext)
const;
327 virtual bool useIntegratedAs()
const;
345 virtual bool useRelaxRelocations()
const;
364 return ToolChain::RLT_Libgcc;
368 return ToolChain::CST_Libstdcxx;
371 virtual std::string getCompilerRTPath()
const;
373 virtual std::string getCompilerRT(
const llvm::opt::ArgList &Args,
375 bool Shared =
false)
const;
377 const char *getCompilerRTArgString(
const llvm::opt::ArgList &Args,
379 bool Shared =
false)
const;
383 std::string getArchSpecificLibPath()
const;
386 StringRef getOSLibName()
const;
389 static bool needsProfileRT(
const llvm::opt::ArgList &Args);
392 static bool needsGCovInstrumentation(
const llvm::opt::ArgList &Args);
396 virtual bool IsUnwindTablesDefault(
const llvm::opt::ArgList &Args)
const;
399 virtual bool isPICDefault()
const = 0;
402 virtual bool isPIEDefault()
const = 0;
408 virtual bool isPICDefaultForced()
const = 0;
437 return llvm::DebuggerKind::GDB;
447 const llvm::opt::ArgList &Args)
const {}
450 virtual llvm::ExceptionHandling
451 GetExceptionModel(
const llvm::opt::ArgList &Args)
const;
460 virtual bool isThreadModelSupported(
const StringRef Model)
const;
465 ComputeLLVMTriple(
const llvm::opt::ArgList &Args,
473 virtual std::string ComputeEffectiveClangTriple(
474 const llvm::opt::ArgList &Args,
481 virtual ObjCRuntime getDefaultObjCRuntime(
bool isNonFragile)
const;
495 AddClangSystemIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
496 llvm::opt::ArgStringList &CC1Args)
const;
499 virtual void addClangTargetOptions(
const llvm::opt::ArgList &DriverArgs,
500 llvm::opt::ArgStringList &CC1Args,
504 virtual void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args)
const;
509 GetRuntimeLibType(
const llvm::opt::ArgList &Args)
const;
513 virtual CXXStdlibType GetCXXStdlibType(
const llvm::opt::ArgList &Args)
const;
518 AddClangCXXStdlibIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
519 llvm::opt::ArgStringList &CC1Args)
const;
523 bool ShouldLinkCXXStdlib(
const llvm::opt::ArgList &Args)
const;
527 virtual void AddCXXStdlibLibArgs(
const llvm::opt::ArgList &Args,
528 llvm::opt::ArgStringList &CmdArgs)
const;
531 void AddFilePathLibArgs(
const llvm::opt::ArgList &Args,
532 llvm::opt::ArgStringList &CmdArgs)
const;
536 virtual void AddCCKextLibArgs(
const llvm::opt::ArgList &Args,
537 llvm::opt::ArgStringList &CmdArgs)
const;
543 virtual bool AddFastMathRuntimeIfAvailable(
544 const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs)
const;
548 virtual void addProfileRTLibs(
const llvm::opt::ArgList &Args,
549 llvm::opt::ArgStringList &CmdArgs)
const;
552 virtual void AddCudaIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
553 llvm::opt::ArgStringList &CC1Args)
const;
556 virtual void AddIAMCUIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
557 llvm::opt::ArgStringList &CC1Args)
const;
560 virtual VersionTuple computeMSVCVersion(
const Driver *D,
561 const llvm::opt::ArgList &Args)
const;
577 TC.setEffectiveTriple(std::move(T));
587 #endif // LLVM_CLANG_DRIVER_TOOLCHAIN_H
std::string ModeSuffix
Driver mode part of the executable name, as g++.
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Set a ToolChain's effective triple.
RegisterEffectiveTriple(const ToolChain &TC, llvm::Triple T)
Defines the clang::SanitizerKind enum.
std::string TargetPrefix
Target part of the executable name, as i686-linux-android.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Defines the clang::LangOptions interface.
This corresponds to a single GCC Multilib, or a segment of one controlled by a command line flag...
ParsedClangName(std::string Suffix, const char *Mode)
Helper structure used to pass information extracted from clang executable name such as i686-linux-and...
Dataflow Directional Tag Classes.
The basic abstraction for the target Objective-C runtime.
ParsedClangName(std::string Target, std::string Suffix, const char *Mode, bool IsRegistered)
~RegisterEffectiveTriple()