Coverage Report

Created: 2017-10-03 07:32

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
Line
Count
Source (jump to first uncovered line)
1
//===-- AMDGPUTargetMachine.h - AMDGPU TargetMachine Interface --*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
/// \file
11
/// \brief The AMDGPU TargetMachine interface definition for hw codgen targets.
12
//
13
//===----------------------------------------------------------------------===//
14
15
#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUTARGETMACHINE_H
16
#define LLVM_LIB_TARGET_AMDGPU_AMDGPUTARGETMACHINE_H
17
18
#include "AMDGPUIntrinsicInfo.h"
19
#include "AMDGPUSubtarget.h"
20
#include "llvm/ADT/Optional.h"
21
#include "llvm/ADT/StringMap.h"
22
#include "llvm/ADT/StringRef.h"
23
#include "llvm/Analysis/TargetTransformInfo.h"
24
#include "llvm/Support/CodeGen.h"
25
#include "llvm/Target/TargetMachine.h"
26
#include <memory>
27
28
namespace llvm {
29
30
//===----------------------------------------------------------------------===//
31
// AMDGPU Target Machine (R600+)
32
//===----------------------------------------------------------------------===//
33
34
class AMDGPUTargetMachine : public LLVMTargetMachine {
35
protected:
36
  std::unique_ptr<TargetLoweringObjectFile> TLOF;
37
  AMDGPUIntrinsicInfo IntrinsicInfo;
38
  AMDGPUAS AS;
39
40
  StringRef getGPUName(const Function &F) const;
41
  StringRef getFeatureString(const Function &F) const;
42
43
public:
44
  AMDGPUTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
45
                      StringRef FS, TargetOptions Options,
46
                      Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
47
                      CodeGenOpt::Level OL);
48
  ~AMDGPUTargetMachine() override;
49
50
  const AMDGPUSubtarget *getSubtargetImpl() const;
51
  const AMDGPUSubtarget *getSubtargetImpl(const Function &) const override = 0;
52
53
12.8k
  const AMDGPUIntrinsicInfo *getIntrinsicInfo() const override {
54
12.8k
    return &IntrinsicInfo;
55
12.8k
  }
56
  TargetIRAnalysis getTargetIRAnalysis() override;
57
58
64.9k
  TargetLoweringObjectFile *getObjFileLowering() const override {
59
64.9k
    return TLOF.get();
60
64.9k
  }
61
18.9k
  AMDGPUAS getAMDGPUAS() const {
62
18.9k
    return AS;
63
18.9k
  }
64
65
  void adjustPassManager(PassManagerBuilder &) override;
66
  /// Get the integer value of a null pointer in the given address space.
67
100
  uint64_t getNullPointerValue(unsigned AddrSpace) const {
68
100
    if (
AddrSpace == AS.LOCAL_ADDRESS || 100
AddrSpace == AS.REGION_ADDRESS81
)
69
21
      return -1;
70
79
    return 0;
71
100
  }
72
};
73
74
//===----------------------------------------------------------------------===//
75
// R600 Target Machine (R600 -> Cayman)
76
//===----------------------------------------------------------------------===//
77
78
class R600TargetMachine final : public AMDGPUTargetMachine {
79
private:
80
  mutable StringMap<std::unique_ptr<R600Subtarget>> SubtargetMap;
81
82
public:
83
  R600TargetMachine(const Target &T, const Triple &TT, StringRef CPU,
84
                    StringRef FS, TargetOptions Options,
85
                    Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
86
                    CodeGenOpt::Level OL, bool JIT);
87
88
  TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
89
90
  const R600Subtarget *getSubtargetImpl(const Function &) const override;
91
92
0
  bool isMachineVerifierClean() const override {
93
0
    return false;
94
0
  }
95
};
96
97
//===----------------------------------------------------------------------===//
98
// GCN Target Machine (SI+)
99
//===----------------------------------------------------------------------===//
100
101
class GCNTargetMachine final : public AMDGPUTargetMachine {
102
private:
103
  mutable StringMap<std::unique_ptr<SISubtarget>> SubtargetMap;
104
105
public:
106
  GCNTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
107
                   StringRef FS, TargetOptions Options,
108
                   Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
109
                   CodeGenOpt::Level OL, bool JIT);
110
111
  TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
112
113
  const SISubtarget *getSubtargetImpl(const Function &) const override;
114
};
115
116
} // end namespace llvm
117
118
#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUTARGETMACHINE_H