LLVM  7.0.0svn
AMDGPUTargetMachine.h
Go to the documentation of this file.
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 /// 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"
24 #include "llvm/Support/CodeGen.h"
26 #include <memory>
27 
28 namespace llvm {
29 
30 //===----------------------------------------------------------------------===//
31 // AMDGPU Target Machine (R600+)
32 //===----------------------------------------------------------------------===//
33 
35 protected:
36  std::unique_ptr<TargetLoweringObjectFile> TLOF;
39 
40  StringRef getGPUName(const Function &F) const;
41  StringRef getFeatureString(const Function &F) const;
42 
43 public:
45 
46  AMDGPUTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
50  ~AMDGPUTargetMachine() override;
51 
52  const AMDGPUSubtarget *getSubtargetImpl() const;
53  const AMDGPUSubtarget *getSubtargetImpl(const Function &) const override = 0;
54 
55  const AMDGPUIntrinsicInfo *getIntrinsicInfo() const override {
56  return &IntrinsicInfo;
57  }
58 
60  return TLOF.get();
61  }
63  return AS;
64  }
65 
66  void adjustPassManager(PassManagerBuilder &) override;
67  /// Get the integer value of a null pointer in the given address space.
68  uint64_t getNullPointerValue(unsigned AddrSpace) const {
69  if (AddrSpace == AS.LOCAL_ADDRESS || AddrSpace == AS.REGION_ADDRESS)
70  return -1;
71  return 0;
72  }
73 };
74 
75 //===----------------------------------------------------------------------===//
76 // R600 Target Machine (R600 -> Cayman)
77 //===----------------------------------------------------------------------===//
78 
79 class R600TargetMachine final : public AMDGPUTargetMachine {
80 private:
81  mutable StringMap<std::unique_ptr<R600Subtarget>> SubtargetMap;
82 
83 public:
84  R600TargetMachine(const Target &T, const Triple &TT, StringRef CPU,
87  CodeGenOpt::Level OL, bool JIT);
88 
90 
91  const R600Subtarget *getSubtargetImpl(const Function &) const override;
92 
94 
95  bool isMachineVerifierClean() const override {
96  return false;
97  }
98 };
99 
100 //===----------------------------------------------------------------------===//
101 // GCN Target Machine (SI+)
102 //===----------------------------------------------------------------------===//
103 
104 class GCNTargetMachine final : public AMDGPUTargetMachine {
105 private:
106  mutable StringMap<std::unique_ptr<SISubtarget>> SubtargetMap;
107 
108 public:
109  GCNTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
112  CodeGenOpt::Level OL, bool JIT);
113 
115 
116  const SISubtarget *getSubtargetImpl(const Function &) const override;
117 
119 
120  bool useIPRA() const override {
121  return true;
122  }
123 };
124 
125 } // end namespace llvm
126 
127 #endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUTARGETMACHINE_H
PassManagerBuilder - This class is used to set up a standard optimization sequence for languages like...
AMDGPU specific subclass of TargetSubtarget.
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
bool useIPRA() const override
True if the target wants to use interprocedural register allocation by default.
F(f)
virtual TargetPassConfig * createPassConfig(PassManagerBase &PM)
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
StringRef getFeatureString(const Function &F) const
OpenCL uses address spaces to differentiate between various memory regions on the hardware...
Definition: AMDGPU.h:220
TargetTransformInfo getTargetTransformInfo(const Function &F) override
Get a TargetTransformInfo implementation for the target.
const AMDGPUSubtarget * getSubtargetImpl() const
Target-Independent Code Generator Pass Configuration Options.
std::unique_ptr< TargetLoweringObjectFile > TLOF
StringRef getGPUName(const Function &F) const
AMDGPUIntrinsicInfo IntrinsicInfo
void adjustPassManager(PassManagerBuilder &) override
Allow the target to modify the pass manager, e.g.
This class describes a target machine that is implemented with the LLVM target-independent code gener...
unsigned REGION_ADDRESS
Address space for region memory.
Definition: AMDGPU.h:224
AMDGPUTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, TargetOptions Options, Optional< Reloc::Model > RM, Optional< CodeModel::Model > CM, CodeGenOpt::Level OL)
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
bool isMachineVerifierClean() const override
Returns true if the target is expected to pass all machine verifier checks.
uint64_t getNullPointerValue(unsigned AddrSpace) const
Get the integer value of a null pointer in the given address space.
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition: StringMap.h:220
Target - Wrapper for Target specific information.
Interface for the AMDGPU Implementation of the Intrinsic Info class.
TargetLoweringObjectFile * getObjFileLowering() const override
TargetOptions Options
Definition: TargetMachine.h:98
const AMDGPUIntrinsicInfo * getIntrinsicInfo() const override
If intrinsic information is available, return it. If not, return null.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
This pass exposes codegen information to IR-level passes.
Address space for local memory.
Definition: AMDGPU.h:232