LLVM  4.0.0
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 /// \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"
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;
38 
39  StringRef getGPUName(const Function &F) const;
40  StringRef getFeatureString(const Function &F) const;
41 
42 public:
43  AMDGPUTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
47  ~AMDGPUTargetMachine() override;
48 
49  const AMDGPUSubtarget *getSubtargetImpl() const;
50  const AMDGPUSubtarget *getSubtargetImpl(const Function &) const override = 0;
51 
52  const AMDGPUIntrinsicInfo *getIntrinsicInfo() const override {
53  return &IntrinsicInfo;
54  }
56 
58  return TLOF.get();
59  }
60  void addEarlyAsPossiblePasses(PassManagerBase &PM) override;
61 };
62 
63 //===----------------------------------------------------------------------===//
64 // R600 Target Machine (R600 -> Cayman)
65 //===----------------------------------------------------------------------===//
66 
67 class R600TargetMachine final : public AMDGPUTargetMachine {
68 private:
69  mutable StringMap<std::unique_ptr<R600Subtarget>> SubtargetMap;
70 
71 public:
72  R600TargetMachine(const Target &T, const Triple &TT, StringRef CPU,
76 
77  TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
78 
79  const R600Subtarget *getSubtargetImpl(const Function &) const override;
80 };
81 
82 //===----------------------------------------------------------------------===//
83 // GCN Target Machine (SI+)
84 //===----------------------------------------------------------------------===//
85 
86 class GCNTargetMachine final : public AMDGPUTargetMachine {
87 private:
88  mutable StringMap<std::unique_ptr<SISubtarget>> SubtargetMap;
89 
90 public:
91  GCNTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
95 
96  TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
97 
98  const SISubtarget *getSubtargetImpl(const Function &) const override;
99 };
100 
101 } // end namespace llvm
102 
103 #endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUTARGETMACHINE_H
AMDGPU specific subclass of TargetSubtarget.
const AMDGPUSubtarget * getSubtargetImpl() const
Analysis pass providing the TargetTransformInfo.
GCNTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, TargetOptions Options, Optional< Reloc::Model > RM, CodeModel::Model CM, CodeGenOpt::Level OL)
R600TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, TargetOptions Options, Optional< Reloc::Model > RM, CodeModel::Model CM, CodeGenOpt::Level OL)
Target-Independent Code Generator Pass Configuration Options.
std::unique_ptr< TargetLoweringObjectFile > TLOF
#define F(x, y, z)
Definition: MD5.cpp:51
AMDGPUIntrinsicInfo IntrinsicInfo
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
This class describes a target machine that is implemented with the LLVM target-independent code gener...
AMDGPUTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, TargetOptions Options, Optional< Reloc::Model > RM, CodeModel::Model CM, CodeGenOpt::Level OL)
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
StringRef getFeatureString(const Function &F) const
void addEarlyAsPossiblePasses(PassManagerBase &PM) override
Add target-specific function passes that should be run as early as possible in the optimization pipel...
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition: StringMap.h:223
Target - Wrapper for Target specific information.
Interface for the AMDGPU Implementation of the Intrinsic Info class.
TargetLoweringObjectFile * getObjFileLowering() const override
StringRef getGPUName(const Function &F) const
TargetIRAnalysis getTargetIRAnalysis() override
Get a TargetIRAnalysis implementation for the target.
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:47
This pass exposes codegen information to IR-level passes.
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...