1 //===--- AMDGPU.h - AMDGPU ToolChain Implementations ----------*- C++ -*-===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AMDGPU_H 10 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AMDGPU_H 11 12 #include "Gnu.h" 13 #include "clang/Driver/Options.h" 14 #include "clang/Driver/Tool.h" 15 #include "clang/Driver/ToolChain.h" 16 #include <map> 17 18 namespace clang { 19 namespace driver { 20 namespace tools { 21 namespace amdgpu { 22 23 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool { 24 public: 25 Linker(const ToolChain &TC) : GnuTool("amdgpu::Linker", "ld.lld", TC) {} 26 bool isLinkJob() const override { return true; } 27 bool hasIntegratedCPP() const override { return false; } 28 void ConstructJob(Compilation &C, const JobAction &JA, 29 const InputInfo &Output, const InputInfoList &Inputs, 30 const llvm::opt::ArgList &TCArgs, 31 const char *LinkingOutput) const override; 32 }; 33 34 void getAMDGPUTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args, 35 std::vector<StringRef> &Features); 36 37 } // end namespace amdgpu 38 } // end namespace tools 39 40 namespace toolchains { 41 42 class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public Generic_ELF { 43 44 private: 45 const std::map<options::ID, const StringRef> OptionsDefault; 46 47 protected: 48 Tool *buildLinker() const override; 49 const StringRef getOptionDefault(options::ID OptID) const { 50 auto opt = OptionsDefault.find(OptID); 51 assert(opt != OptionsDefault.end() && "No Default for Option"); 52 return opt->second; 53 } 54 55 public: 56 AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple, 57 const llvm::opt::ArgList &Args); 58 unsigned GetDefaultDwarfVersion() const override { return 4; } 59 bool IsIntegratedAssemblerDefault() const override { return true; } 60 bool IsMathErrnoDefault() const override { return false; } 61 62 llvm::opt::DerivedArgList * 63 TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch, 64 Action::OffloadKind DeviceOffloadKind) const override; 65 66 void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, 67 llvm::opt::ArgStringList &CC1Args, 68 Action::OffloadKind DeviceOffloadKind) const override; 69 }; 70 71 } // end namespace toolchains 72 } // end namespace driver 73 } // end namespace clang 74 75 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AMDGPU_H 76