1//===--- HIPAMD.h - HIP 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_HIPAMD_H
10#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPAMD_H
11
12#include "AMDGPU.h"
13#include "clang/Driver/SyclInstallationDetector.h"
14#include "clang/Driver/Tool.h"
15#include "clang/Driver/ToolChain.h"
16
17namespace clang {
18namespace driver {
19
20namespace tools {
21
22namespace AMDGCN {
23// Runs llvm-link/opt/llc/lld, which links multiple LLVM bitcode, together with
24// device library, then compiles it to ISA in a shared object.
25class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {
26public:
27 Linker(const ToolChain &TC) : Tool("AMDGCN::Linker", "amdgcn-link", TC) {}
28
29 bool hasIntegratedCPP() const override { return false; }
30
31 void ConstructJob(Compilation &C, const JobAction &JA,
32 const InputInfo &Output, const InputInfoList &Inputs,
33 const llvm::opt::ArgList &TCArgs,
34 const char *LinkingOutput) const override;
35
36private:
37 void constructLldCommand(Compilation &C, const JobAction &JA,
38 const InputInfoList &Inputs, const InputInfo &Output,
39 const llvm::opt::ArgList &Args) const;
40 void constructLLVMLinkCommand(Compilation &C, const JobAction &JA,
41 const InputInfoList &Inputs,
42 const InputInfo &Output,
43 const llvm::opt::ArgList &Args) const;
44 void constructLinkAndEmitSpirvCommand(Compilation &C, const JobAction &JA,
45 const InputInfoList &Inputs,
46 const InputInfo &Output,
47 const llvm::opt::ArgList &Args) const;
48};
49
50} // end namespace AMDGCN
51} // end namespace tools
52
53namespace toolchains {
54
55class LLVM_LIBRARY_VISIBILITY SPIRVAMDToolChain final : public AMDGPUToolChain {
56public:
57 SPIRVAMDToolChain(const Driver &D, const llvm::Triple &Triple,
58 const llvm::opt::ArgList &Args);
59
60 /// SPIR-V uses LTO by default to link device bitcode.
61 LTOKind getDefaultLTOMode() const override { return LTOK_Full; }
62
63protected:
64 Tool *buildLinker() const override;
65};
66
67} // end namespace toolchains
68} // end namespace driver
69} // end namespace clang
70
71#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPAMD_H
72