clang 19.0.0git
HIPSPV.h
Go to the documentation of this file.
1//===--- HIPSPV.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_HIPSPV_H
10#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPSPV_H
11
12#include "SPIRV.h"
13#include "clang/Driver/Tool.h"
15
16namespace clang {
17namespace driver {
18namespace tools {
19namespace HIPSPV {
20
21// Runs llvm-link/opt/llc/lld, which links multiple LLVM bitcode, together with
22// device library, then compiles it to SPIR-V in a shared object.
23class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {
24public:
25 Linker(const ToolChain &TC) : Tool("HIPSPV::Linker", "hipspv-link", TC) {}
26
27 bool hasIntegratedCPP() const override { return false; }
28
29 void ConstructJob(Compilation &C, const JobAction &JA,
30 const InputInfo &Output, const InputInfoList &Inputs,
31 const llvm::opt::ArgList &TCArgs,
32 const char *LinkingOutput) const override;
33
34private:
35 void constructLinkAndEmitSpirvCommand(Compilation &C, const JobAction &JA,
36 const InputInfoList &Inputs,
37 const InputInfo &Output,
38 const llvm::opt::ArgList &Args) const;
39};
40
41} // namespace HIPSPV
42} // namespace tools
43
44namespace toolchains {
45
46class LLVM_LIBRARY_VISIBILITY HIPSPVToolChain final : public ToolChain {
47public:
48 HIPSPVToolChain(const Driver &D, const llvm::Triple &Triple,
49 const ToolChain &HostTC, const llvm::opt::ArgList &Args);
50
51 const llvm::Triple *getAuxTriple() const override {
52 return &HostTC.getTriple();
53 }
54
55 void
56 addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
57 llvm::opt::ArgStringList &CC1Args,
58 Action::OffloadKind DeviceOffloadKind) const override;
59 void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
60 CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
61 void
62 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
63 llvm::opt::ArgStringList &CC1Args) const override;
64 void AddClangCXXStdlibIncludeArgs(
65 const llvm::opt::ArgList &Args,
66 llvm::opt::ArgStringList &CC1Args) const override;
67 void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
68 llvm::opt::ArgStringList &CC1Args) const override;
69 void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
70 llvm::opt::ArgStringList &CC1Args) const override;
72 getDeviceLibs(const llvm::opt::ArgList &Args) const override;
73
74 SanitizerMask getSupportedSanitizers() const override;
75
76 VersionTuple
77 computeMSVCVersion(const Driver *D,
78 const llvm::opt::ArgList &Args) const override;
79
80 void adjustDebugInfoKind(llvm::codegenoptions::DebugInfoKind &DebugInfoKind,
81 const llvm::opt::ArgList &Args) const override;
82 bool IsMathErrnoDefault() const override { return false; }
83 bool useIntegratedAs() const override { return true; }
84 bool isCrossCompiling() const override { return true; }
85 bool isPICDefault() const override { return false; }
86 bool isPIEDefault(const llvm::opt::ArgList &Args) const override {
87 return false;
88 }
89 bool isPICDefaultForced() const override { return false; }
90 bool SupportsProfiling() const override { return false; }
91
93
94protected:
95 Tool *buildLinker() const override;
96};
97
98} // end namespace toolchains
99} // end namespace driver
100} // end namespace clang
101
102#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPSPV_H
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:45
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:77
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:92
const llvm::Triple & getTriple() const
Definition: ToolChain.h:247
Tool - Information on a specific compilation tool.
Definition: Tool.h:32
bool useIntegratedAs() const override
Check if the toolchain should use the integrated assembler.
Definition: HIPSPV.h:83
bool IsMathErrnoDefault() const override
IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
Definition: HIPSPV.h:82
const llvm::Triple * getAuxTriple() const override
Get the toolchain's aux triple, if it has one.
Definition: HIPSPV.h:51
bool isPICDefault() const override
Test whether this toolchain defaults to PIC.
Definition: HIPSPV.h:85
bool isPIEDefault(const llvm::opt::ArgList &Args) const override
Test whether this toolchain defaults to PIE.
Definition: HIPSPV.h:86
bool isCrossCompiling() const override
Returns true if the toolchain is targeting a non-native architecture.
Definition: HIPSPV.h:84
bool isPICDefaultForced() const override
Tests whether this toolchain forces its default for PIC, PIE or non-PIC.
Definition: HIPSPV.h:89
bool SupportsProfiling() const override
SupportsProfiling - Does this tool chain support -pg.
Definition: HIPSPV.h:90
Linker(const ToolChain &TC)
Definition: HIPSPV.h:25
bool hasIntegratedCPP() const override
Definition: HIPSPV.h:27
The JSON file list parser is used to communicate input to InstallAPI.