File indexing completed on 2026-05-10 08:36:53
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_CLANG_DRIVER_TOOLCHAIN_H
0010 #define LLVM_CLANG_DRIVER_TOOLCHAIN_H
0011
0012 #include "clang/Basic/LLVM.h"
0013 #include "clang/Basic/LangOptions.h"
0014 #include "clang/Basic/Sanitizers.h"
0015 #include "clang/Driver/Action.h"
0016 #include "clang/Driver/Multilib.h"
0017 #include "clang/Driver/Types.h"
0018 #include "llvm/ADT/APFloat.h"
0019 #include "llvm/ADT/ArrayRef.h"
0020 #include "llvm/ADT/FloatingPointMode.h"
0021 #include "llvm/ADT/SmallVector.h"
0022 #include "llvm/ADT/StringRef.h"
0023 #include "llvm/Frontend/Debug/Options.h"
0024 #include "llvm/MC/MCTargetOptions.h"
0025 #include "llvm/Option/Option.h"
0026 #include "llvm/Support/VersionTuple.h"
0027 #include "llvm/Target/TargetOptions.h"
0028 #include "llvm/TargetParser/Triple.h"
0029 #include <cassert>
0030 #include <climits>
0031 #include <memory>
0032 #include <optional>
0033 #include <string>
0034 #include <utility>
0035
0036 namespace llvm {
0037 namespace opt {
0038
0039 class Arg;
0040 class ArgList;
0041 class DerivedArgList;
0042
0043 }
0044 namespace vfs {
0045
0046 class FileSystem;
0047
0048 }
0049 }
0050
0051 namespace clang {
0052
0053 class ObjCRuntime;
0054
0055 namespace driver {
0056
0057 class Driver;
0058 class InputInfo;
0059 class SanitizerArgs;
0060 class Tool;
0061 class XRayArgs;
0062
0063
0064
0065 struct ParsedClangName {
0066
0067 std::string TargetPrefix;
0068
0069
0070 std::string ModeSuffix;
0071
0072
0073 const char *DriverMode = nullptr;
0074
0075
0076 bool TargetIsValid = false;
0077
0078 ParsedClangName() = default;
0079 ParsedClangName(std::string Suffix, const char *Mode)
0080 : ModeSuffix(Suffix), DriverMode(Mode) {}
0081 ParsedClangName(std::string Target, std::string Suffix, const char *Mode,
0082 bool IsRegistered)
0083 : TargetPrefix(Target), ModeSuffix(Suffix), DriverMode(Mode),
0084 TargetIsValid(IsRegistered) {}
0085
0086 bool isEmpty() const {
0087 return TargetPrefix.empty() && ModeSuffix.empty() && DriverMode == nullptr;
0088 }
0089 };
0090
0091
0092 class ToolChain {
0093 public:
0094 using path_list = SmallVector<std::string, 16>;
0095
0096 enum CXXStdlibType {
0097 CST_Libcxx,
0098 CST_Libstdcxx
0099 };
0100
0101 enum RuntimeLibType {
0102 RLT_CompilerRT,
0103 RLT_Libgcc
0104 };
0105
0106 enum UnwindLibType {
0107 UNW_None,
0108 UNW_CompilerRT,
0109 UNW_Libgcc
0110 };
0111
0112 enum class UnwindTableLevel {
0113 None,
0114 Synchronous,
0115 Asynchronous,
0116 };
0117
0118 enum RTTIMode {
0119 RM_Enabled,
0120 RM_Disabled,
0121 };
0122
0123 enum ExceptionsMode {
0124 EM_Enabled,
0125 EM_Disabled,
0126 };
0127
0128 struct BitCodeLibraryInfo {
0129 std::string Path;
0130 bool ShouldInternalize;
0131 BitCodeLibraryInfo(StringRef Path, bool ShouldInternalize = true)
0132 : Path(Path), ShouldInternalize(ShouldInternalize) {}
0133 };
0134
0135 enum FileType { FT_Object, FT_Static, FT_Shared };
0136
0137 private:
0138 friend class RegisterEffectiveTriple;
0139
0140 const Driver &D;
0141 llvm::Triple Triple;
0142 const llvm::opt::ArgList &Args;
0143
0144
0145 const llvm::opt::Arg *const CachedRTTIArg;
0146
0147 const RTTIMode CachedRTTIMode;
0148
0149 const ExceptionsMode CachedExceptionsMode;
0150
0151
0152 path_list LibraryPaths;
0153
0154
0155 path_list FilePaths;
0156
0157
0158 path_list ProgramPaths;
0159
0160 mutable std::unique_ptr<Tool> Clang;
0161 mutable std::unique_ptr<Tool> Flang;
0162 mutable std::unique_ptr<Tool> Assemble;
0163 mutable std::unique_ptr<Tool> Link;
0164 mutable std::unique_ptr<Tool> StaticLibTool;
0165 mutable std::unique_ptr<Tool> IfsMerge;
0166 mutable std::unique_ptr<Tool> OffloadBundler;
0167 mutable std::unique_ptr<Tool> OffloadPackager;
0168 mutable std::unique_ptr<Tool> LinkerWrapper;
0169
0170 Tool *getClang() const;
0171 Tool *getFlang() const;
0172 Tool *getAssemble() const;
0173 Tool *getLink() const;
0174 Tool *getStaticLibTool() const;
0175 Tool *getIfsMerge() const;
0176 Tool *getClangAs() const;
0177 Tool *getOffloadBundler() const;
0178 Tool *getOffloadPackager() const;
0179 Tool *getLinkerWrapper() const;
0180
0181 mutable bool SanitizerArgsChecked = false;
0182 mutable std::unique_ptr<XRayArgs> XRayArguments;
0183
0184
0185 mutable llvm::Triple EffectiveTriple;
0186
0187
0188 void setEffectiveTriple(llvm::Triple ET) const {
0189 EffectiveTriple = std::move(ET);
0190 }
0191
0192 std::optional<std::string>
0193 getFallbackAndroidTargetPath(StringRef BaseDir) const;
0194
0195 mutable std::optional<CXXStdlibType> cxxStdlibType;
0196 mutable std::optional<RuntimeLibType> runtimeLibType;
0197 mutable std::optional<UnwindLibType> unwindLibType;
0198
0199 protected:
0200 MultilibSet Multilibs;
0201 llvm::SmallVector<Multilib> SelectedMultilibs;
0202
0203 ToolChain(const Driver &D, const llvm::Triple &T,
0204 const llvm::opt::ArgList &Args);
0205
0206
0207 llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
0208 executeToolChainProgram(StringRef Executable) const;
0209
0210 void setTripleEnvironment(llvm::Triple::EnvironmentType Env);
0211
0212 virtual Tool *buildAssembler() const;
0213 virtual Tool *buildLinker() const;
0214 virtual Tool *buildStaticLibTool() const;
0215 virtual Tool *getTool(Action::ActionClass AC) const;
0216
0217 virtual std::string buildCompilerRTBasename(const llvm::opt::ArgList &Args,
0218 StringRef Component,
0219 FileType Type,
0220 bool AddArch) const;
0221
0222
0223
0224
0225 std::optional<std::string> getTargetSubDirPath(StringRef BaseDir) const;
0226
0227
0228
0229 static void addSystemInclude(const llvm::opt::ArgList &DriverArgs,
0230 llvm::opt::ArgStringList &CC1Args,
0231 const Twine &Path);
0232 static void addExternCSystemInclude(const llvm::opt::ArgList &DriverArgs,
0233 llvm::opt::ArgStringList &CC1Args,
0234 const Twine &Path);
0235 static void
0236 addExternCSystemIncludeIfExists(const llvm::opt::ArgList &DriverArgs,
0237 llvm::opt::ArgStringList &CC1Args,
0238 const Twine &Path);
0239 static void addSystemIncludes(const llvm::opt::ArgList &DriverArgs,
0240 llvm::opt::ArgStringList &CC1Args,
0241 ArrayRef<StringRef> Paths);
0242
0243 static std::string concat(StringRef Path, const Twine &A, const Twine &B = "",
0244 const Twine &C = "", const Twine &D = "");
0245
0246
0247 public:
0248 virtual ~ToolChain();
0249
0250
0251
0252 const Driver &getDriver() const { return D; }
0253 llvm::vfs::FileSystem &getVFS() const;
0254 const llvm::Triple &getTriple() const { return Triple; }
0255
0256
0257
0258
0259
0260
0261 virtual const llvm::Triple *getAuxTriple() const { return nullptr; }
0262
0263
0264
0265
0266 virtual std::string getInputFilename(const InputInfo &Input) const;
0267
0268 llvm::Triple::ArchType getArch() const { return Triple.getArch(); }
0269 StringRef getArchName() const { return Triple.getArchName(); }
0270 StringRef getPlatform() const { return Triple.getVendorName(); }
0271 StringRef getOS() const { return Triple.getOSName(); }
0272
0273
0274
0275 StringRef getDefaultUniversalArchName() const;
0276
0277 std::string getTripleString() const {
0278 return Triple.getTriple();
0279 }
0280
0281
0282 const llvm::Triple &getEffectiveTriple() const {
0283 assert(!EffectiveTriple.getTriple().empty() && "No effective triple");
0284 return EffectiveTriple;
0285 }
0286
0287 bool hasEffectiveTriple() const {
0288 return !EffectiveTriple.getTriple().empty();
0289 }
0290
0291 path_list &getLibraryPaths() { return LibraryPaths; }
0292 const path_list &getLibraryPaths() const { return LibraryPaths; }
0293
0294 path_list &getFilePaths() { return FilePaths; }
0295 const path_list &getFilePaths() const { return FilePaths; }
0296
0297 path_list &getProgramPaths() { return ProgramPaths; }
0298 const path_list &getProgramPaths() const { return ProgramPaths; }
0299
0300 const MultilibSet &getMultilibs() const { return Multilibs; }
0301
0302 const llvm::SmallVector<Multilib> &getSelectedMultilibs() const {
0303 return SelectedMultilibs;
0304 }
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315
0316 Multilib::flags_list getMultilibFlags(const llvm::opt::ArgList &) const;
0317
0318 SanitizerArgs getSanitizerArgs(const llvm::opt::ArgList &JobArgs) const;
0319
0320 const XRayArgs& getXRayArgs() const;
0321
0322
0323 const llvm::opt::Arg *getRTTIArg() const { return CachedRTTIArg; }
0324
0325
0326 RTTIMode getRTTIMode() const { return CachedRTTIMode; }
0327
0328
0329 ExceptionsMode getExceptionsMode() const { return CachedExceptionsMode; }
0330
0331
0332
0333
0334
0335
0336
0337
0338
0339
0340
0341
0342
0343
0344
0345 static ParsedClangName getTargetAndModeFromProgramName(StringRef ProgName);
0346
0347
0348
0349
0350
0351
0352
0353
0354
0355
0356
0357 virtual llvm::opt::DerivedArgList *
0358 TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
0359 Action::OffloadKind DeviceOffloadKind) const {
0360 return nullptr;
0361 }
0362
0363
0364
0365
0366 virtual llvm::opt::DerivedArgList *TranslateOpenMPTargetArgs(
0367 const llvm::opt::DerivedArgList &Args, bool SameTripleAsHost,
0368 SmallVectorImpl<llvm::opt::Arg *> &AllocatedArgs) const;
0369
0370
0371
0372
0373 virtual void TranslateXarchArgs(
0374 const llvm::opt::DerivedArgList &Args, llvm::opt::Arg *&A,
0375 llvm::opt::DerivedArgList *DAL,
0376 SmallVectorImpl<llvm::opt::Arg *> *AllocatedArgs = nullptr) const;
0377
0378
0379
0380
0381 virtual llvm::opt::DerivedArgList *
0382 TranslateXarchArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
0383 Action::OffloadKind DeviceOffloadKind,
0384 SmallVectorImpl<llvm::opt::Arg *> *AllocatedArgs) const;
0385
0386
0387
0388
0389
0390 virtual Tool *SelectTool(const JobAction &JA) const;
0391
0392
0393
0394 std::string GetFilePath(const char *Name) const;
0395 std::string GetProgramPath(const char *Name) const;
0396
0397
0398
0399
0400
0401
0402
0403 std::string GetLinkerPath(bool *LinkerIsLLD = nullptr) const;
0404
0405
0406 std::string GetStaticLibToolPath() const;
0407
0408
0409
0410
0411
0412
0413 virtual void printVerboseInfo(raw_ostream &OS) const {}
0414
0415
0416
0417
0418
0419 virtual bool isCrossCompiling() const;
0420
0421
0422
0423 virtual bool HasNativeLLVMSupport() const;
0424
0425
0426
0427 virtual types::ID LookupTypeForExtension(StringRef Ext) const;
0428
0429
0430 virtual bool IsBlocksDefault() const { return false; }
0431
0432
0433
0434 virtual bool IsIntegratedAssemblerDefault() const { return true; }
0435
0436
0437
0438 virtual bool IsIntegratedBackendDefault() const { return true; }
0439
0440
0441
0442 virtual bool IsIntegratedBackendSupported() const { return true; }
0443
0444
0445
0446 virtual bool IsNonIntegratedBackendSupported() const { return false; }
0447
0448
0449 virtual bool useIntegratedAs() const;
0450
0451
0452 virtual bool useIntegratedBackend() const;
0453
0454
0455
0456 virtual bool parseInlineAsmUsingAsmParser() const { return false; }
0457
0458
0459 virtual bool IsMathErrnoDefault() const { return true; }
0460
0461
0462
0463 virtual bool IsEncodeExtendedBlockSignatureDefault() const { return false; }
0464
0465
0466
0467 virtual bool IsObjCNonFragileABIDefault() const { return false; }
0468
0469
0470
0471 virtual bool UseObjCMixedDispatch() const { return false; }
0472
0473
0474 virtual bool useRelaxRelocations() const;
0475
0476
0477 bool defaultToIEEELongDouble() const;
0478
0479
0480
0481 virtual LangOptions::StackProtectorMode
0482 GetDefaultStackProtectorLevel(bool KernelOrKext) const {
0483 return LangOptions::SSPOff;
0484 }
0485
0486
0487 virtual LangOptions::TrivialAutoVarInitKind
0488 GetDefaultTrivialAutoVarInit() const {
0489 return LangOptions::TrivialAutoVarInitKind::Uninitialized;
0490 }
0491
0492
0493 virtual const char *getDefaultLinker() const { return "ld"; }
0494
0495
0496 virtual RuntimeLibType GetDefaultRuntimeLibType() const {
0497 return ToolChain::RLT_Libgcc;
0498 }
0499
0500 virtual CXXStdlibType GetDefaultCXXStdlibType() const {
0501 return ToolChain::CST_Libstdcxx;
0502 }
0503
0504 virtual UnwindLibType GetDefaultUnwindLibType() const {
0505 return ToolChain::UNW_None;
0506 }
0507
0508 virtual std::string getCompilerRTPath() const;
0509
0510 virtual std::string getCompilerRT(const llvm::opt::ArgList &Args,
0511 StringRef Component,
0512 FileType Type = ToolChain::FT_Static) const;
0513
0514 const char *
0515 getCompilerRTArgString(const llvm::opt::ArgList &Args, StringRef Component,
0516 FileType Type = ToolChain::FT_Static) const;
0517
0518 std::string getCompilerRTBasename(const llvm::opt::ArgList &Args,
0519 StringRef Component,
0520 FileType Type = ToolChain::FT_Static) const;
0521
0522
0523 std::optional<std::string> getRuntimePath() const;
0524
0525
0526 std::optional<std::string> getStdlibPath() const;
0527
0528
0529 std::optional<std::string> getStdlibIncludePath() const;
0530
0531
0532
0533 virtual path_list getArchSpecificLibPaths() const;
0534
0535
0536 virtual StringRef getOSLibName() const;
0537
0538
0539 static bool needsProfileRT(const llvm::opt::ArgList &Args);
0540
0541
0542 static bool needsGCovInstrumentation(const llvm::opt::ArgList &Args);
0543
0544
0545 virtual UnwindTableLevel
0546 getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const;
0547
0548
0549 virtual bool
0550 IsAArch64OutlineAtomicsDefault(const llvm::opt::ArgList &Args) const {
0551 return false;
0552 }
0553
0554
0555 virtual bool isPICDefault() const = 0;
0556
0557
0558 virtual bool isPIEDefault(const llvm::opt::ArgList &Args) const = 0;
0559
0560
0561
0562
0563
0564 virtual bool isPICDefaultForced() const = 0;
0565
0566
0567 virtual bool SupportsProfiling() const { return true; }
0568
0569
0570 virtual void CheckObjCARC() const {}
0571
0572
0573 virtual llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const {
0574 return llvm::codegenoptions::DIF_DWARF;
0575 }
0576
0577
0578
0579 virtual bool UseDwarfDebugFlags() const { return false; }
0580
0581
0582 virtual std::string GetGlobalDebugPathRemapping() const { return {}; }
0583
0584
0585
0586 virtual unsigned GetDefaultDwarfVersion() const { return 5; }
0587
0588
0589
0590
0591 virtual unsigned getMaxDwarfVersion() const { return UINT_MAX; }
0592
0593
0594
0595
0596
0597 virtual bool GetDefaultStandaloneDebug() const { return false; }
0598
0599
0600 virtual llvm::DebuggerKind getDefaultDebuggerTuning() const {
0601 return llvm::DebuggerKind::GDB;
0602 }
0603
0604
0605 virtual bool supportsDebugInfoOption(const llvm::opt::Arg *) const {
0606 return true;
0607 }
0608
0609
0610 virtual void
0611 adjustDebugInfoKind(llvm::codegenoptions::DebugInfoKind &DebugInfoKind,
0612 const llvm::opt::ArgList &Args) const {}
0613
0614
0615 virtual llvm::ExceptionHandling
0616 GetExceptionModel(const llvm::opt::ArgList &Args) const;
0617
0618
0619 virtual bool SupportsEmbeddedBitcode() const { return false; }
0620
0621
0622 virtual std::string getThreadModel() const { return "posix"; }
0623
0624
0625 virtual bool isThreadModelSupported(const StringRef Model) const;
0626
0627
0628 virtual bool isBareMetal() const { return false; }
0629
0630 virtual std::string getMultiarchTriple(const Driver &D,
0631 const llvm::Triple &TargetTriple,
0632 StringRef SysRoot) const {
0633 return TargetTriple.str();
0634 }
0635
0636
0637
0638 virtual std::string
0639 ComputeLLVMTriple(const llvm::opt::ArgList &Args,
0640 types::ID InputType = types::TY_INVALID) const;
0641
0642
0643
0644
0645
0646
0647 virtual std::string ComputeEffectiveClangTriple(
0648 const llvm::opt::ArgList &Args,
0649 types::ID InputType = types::TY_INVALID) const;
0650
0651
0652
0653
0654
0655 virtual ObjCRuntime getDefaultObjCRuntime(bool isNonFragile) const;
0656
0657
0658
0659
0660
0661
0662 virtual bool hasBlocksRuntime() const { return true; }
0663
0664
0665
0666 virtual std::string computeSysRoot() const;
0667
0668
0669
0670
0671
0672 virtual void
0673 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
0674 llvm::opt::ArgStringList &CC1Args) const;
0675
0676
0677 virtual void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
0678 llvm::opt::ArgStringList &CC1Args,
0679 Action::OffloadKind DeviceOffloadKind) const;
0680
0681
0682 virtual void
0683 addClangCC1ASTargetOptions(const llvm::opt::ArgList &Args,
0684 llvm::opt::ArgStringList &CC1ASArgs) const;
0685
0686
0687 virtual void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const;
0688
0689
0690
0691 virtual SmallVector<std::string>
0692 getMultilibMacroDefinesStr(llvm::opt::ArgList &Args) const {
0693 return {};
0694 };
0695
0696
0697
0698 virtual RuntimeLibType
0699 GetRuntimeLibType(const llvm::opt::ArgList &Args) const;
0700
0701
0702
0703 virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const;
0704
0705
0706
0707 virtual UnwindLibType GetUnwindLibType(const llvm::opt::ArgList &Args) const;
0708
0709
0710 virtual std::string detectLibcxxVersion(StringRef IncludePath) const;
0711
0712
0713
0714 virtual void
0715 AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
0716 llvm::opt::ArgStringList &CC1Args) const;
0717
0718
0719
0720 void AddClangCXXStdlibIsystemArgs(const llvm::opt::ArgList &DriverArgs,
0721 llvm::opt::ArgStringList &CC1Args) const;
0722
0723
0724
0725 bool ShouldLinkCXXStdlib(const llvm::opt::ArgList &Args) const;
0726
0727
0728
0729 virtual void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
0730 llvm::opt::ArgStringList &CmdArgs) const;
0731
0732
0733 void AddFilePathLibArgs(const llvm::opt::ArgList &Args,
0734 llvm::opt::ArgStringList &CmdArgs) const;
0735
0736
0737
0738 virtual void AddCCKextLibArgs(const llvm::opt::ArgList &Args,
0739 llvm::opt::ArgStringList &CmdArgs) const;
0740
0741
0742
0743
0744
0745 virtual bool isFastMathRuntimeAvailable(
0746 const llvm::opt::ArgList &Args, std::string &Path) const;
0747
0748
0749
0750
0751
0752 bool addFastMathRuntimeIfAvailable(
0753 const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const;
0754
0755
0756 virtual Expected<SmallVector<std::string>>
0757 getSystemGPUArchs(const llvm::opt::ArgList &Args) const;
0758
0759
0760
0761 virtual void addProfileRTLibs(const llvm::opt::ArgList &Args,
0762 llvm::opt::ArgStringList &CmdArgs) const;
0763
0764
0765 virtual void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
0766 llvm::opt::ArgStringList &CC1Args) const;
0767
0768
0769 virtual void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
0770 llvm::opt::ArgStringList &CC1Args) const;
0771
0772
0773 virtual void addSYCLIncludeArgs(const llvm::opt::ArgList &DriverArgs,
0774 llvm::opt::ArgStringList &CC1Args) const;
0775
0776
0777 virtual void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
0778 llvm::opt::ArgStringList &CC1Args) const;
0779
0780
0781 virtual VersionTuple computeMSVCVersion(const Driver *D,
0782 const llvm::opt::ArgList &Args) const;
0783
0784
0785 virtual llvm::SmallVector<BitCodeLibraryInfo, 12>
0786 getDeviceLibs(const llvm::opt::ArgList &Args) const;
0787
0788
0789
0790 virtual void AddHIPRuntimeLibArgs(const llvm::opt::ArgList &Args,
0791 llvm::opt::ArgStringList &CmdArgs) const {}
0792
0793
0794 virtual SanitizerMask getSupportedSanitizers() const;
0795
0796
0797 virtual SanitizerMask getDefaultSanitizers() const {
0798 return SanitizerMask();
0799 }
0800
0801
0802
0803 virtual bool canSplitThinLTOUnit() const { return true; }
0804
0805
0806
0807
0808 virtual llvm::DenormalMode getDefaultDenormalModeForType(
0809 const llvm::opt::ArgList &DriverArgs, const JobAction &JA,
0810 const llvm::fltSemantics *FPType = nullptr) const {
0811 return llvm::DenormalMode::getIEEE();
0812 }
0813
0814
0815
0816 static llvm::Triple getOpenMPTriple(StringRef TripleStr) {
0817 llvm::Triple TT(TripleStr);
0818 if (TT.getVendor() == llvm::Triple::UnknownVendor ||
0819 TT.getOS() == llvm::Triple::UnknownOS) {
0820 if (TT.getArch() == llvm::Triple::nvptx)
0821 return llvm::Triple("nvptx-nvidia-cuda");
0822 if (TT.getArch() == llvm::Triple::nvptx64)
0823 return llvm::Triple("nvptx64-nvidia-cuda");
0824 if (TT.getArch() == llvm::Triple::amdgcn)
0825 return llvm::Triple("amdgcn-amd-amdhsa");
0826 }
0827 return TT;
0828 }
0829 };
0830
0831
0832
0833 class RegisterEffectiveTriple {
0834 const ToolChain &TC;
0835
0836 public:
0837 RegisterEffectiveTriple(const ToolChain &TC, llvm::Triple T) : TC(TC) {
0838 TC.setEffectiveTriple(std::move(T));
0839 }
0840
0841 ~RegisterEffectiveTriple() { TC.setEffectiveTriple(llvm::Triple()); }
0842 };
0843
0844 }
0845
0846 }
0847
0848 #endif