Coverage Report

Created: 2020-09-19 12:23

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Driver/ToolChains/AMDGPU.h
Line
Count
Source (jump to first uncovered line)
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 "ROCm.h"
14
#include "clang/Basic/TargetID.h"
15
#include "clang/Driver/Options.h"
16
#include "clang/Driver/Tool.h"
17
#include "clang/Driver/ToolChain.h"
18
#include "llvm/ADT/SmallString.h"
19
#include "llvm/Support/TargetParser.h"
20
21
#include <map>
22
23
namespace clang {
24
namespace driver {
25
26
namespace tools {
27
namespace amdgpu {
28
29
class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
30
public:
31
63
  Linker(const ToolChain &TC) : Tool("amdgpu::Linker", "ld.lld", TC) {}
32
0
  bool isLinkJob() const override { return true; }
33
63
  bool hasIntegratedCPP() const override { return false; }
34
  void ConstructJob(Compilation &C, const JobAction &JA,
35
                    const InputInfo &Output, const InputInfoList &Inputs,
36
                    const llvm::opt::ArgList &TCArgs,
37
                    const char *LinkingOutput) const override;
38
};
39
40
void getAMDGPUTargetFeatures(const Driver &D, const llvm::Triple &Triple,
41
                             const llvm::opt::ArgList &Args,
42
                             std::vector<StringRef> &Features);
43
44
} // end namespace amdgpu
45
} // end namespace tools
46
47
namespace toolchains {
48
49
class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public Generic_ELF {
50
protected:
51
  const std::map<options::ID, const StringRef> OptionsDefault;
52
53
  Tool *buildLinker() const override;
54
7
  const StringRef getOptionDefault(options::ID OptID) const {
55
7
    auto opt = OptionsDefault.find(OptID);
56
7
    assert(opt != OptionsDefault.end() && "No Default for Option");
57
7
    return opt->second;
58
7
  }
59
60
public:
61
  AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple,
62
                  const llvm::opt::ArgList &Args);
63
15
  unsigned GetDefaultDwarfVersion() const override { return 4; }
64
839
  bool IsIntegratedAssemblerDefault() const override { return true; }
65
99
  bool IsMathErrnoDefault() const override { return false; }
66
67
  llvm::opt::DerivedArgList *
68
  TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
69
                Action::OffloadKind DeviceOffloadKind) const override;
70
71
  void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
72
                             llvm::opt::ArgStringList &CC1Args,
73
                             Action::OffloadKind DeviceOffloadKind) const override;
74
75
  /// Return whether denormals should be flushed, and treated as 0 by default
76
  /// for the subtarget.
77
  static bool getDefaultDenormsAreZeroForTarget(llvm::AMDGPU::GPUKind GPUKind);
78
79
  llvm::DenormalMode getDefaultDenormalModeForType(
80
      const llvm::opt::ArgList &DriverArgs, const JobAction &JA,
81
      const llvm::fltSemantics *FPType = nullptr) const override;
82
83
  static bool isWave64(const llvm::opt::ArgList &DriverArgs,
84
                       llvm::AMDGPU::GPUKind Kind);
85
  /// Needed for using lto.
86
63
  bool HasNativeLLVMSupport() const override {
87
63
    return true;
88
63
  }
89
90
  /// Needed for translating LTO options.
91
119
  const char *getDefaultLinker() const override { return "ld.lld"; }
92
93
protected:
94
  /// Translate -mcpu option containing target ID to cc1 options.
95
  /// Returns the GPU name.
96
  StringRef translateTargetID(const llvm::opt::ArgList &DriverArgs,
97
                              llvm::opt::ArgStringList &CC1Args) const;
98
99
  StringRef getGPUArch(const llvm::opt::ArgList &DriverArgs) const;
100
};
101
102
class LLVM_LIBRARY_VISIBILITY ROCMToolChain : public AMDGPUToolChain {
103
public:
104
  ROCMToolChain(const Driver &D, const llvm::Triple &Triple,
105
                const llvm::opt::ArgList &Args);
106
  void
107
  addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
108
                        llvm::opt::ArgStringList &CC1Args,
109
                        Action::OffloadKind DeviceOffloadKind) const override;
110
};
111
112
} // end namespace toolchains
113
} // end namespace driver
114
} // end namespace clang
115
116
#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AMDGPU_H