1 //===-- AMDGPUTargetMachine.h - AMDGPU TargetMachine Interface --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief The AMDGPU TargetMachine interface definition for hw codgen targets.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUTARGETMACHINE_H
16 #define LLVM_LIB_TARGET_AMDGPU_AMDGPUTARGETMACHINE_H
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"
30 //===----------------------------------------------------------------------===//
31 // AMDGPU Target Machine (R600+)
32 //===----------------------------------------------------------------------===//
34 class AMDGPUTargetMachine : public LLVMTargetMachine {
36 std::unique_ptr<TargetLoweringObjectFile> TLOF;
37 AMDGPUIntrinsicInfo IntrinsicInfo;
40 StringRef getGPUName(const Function &F) const;
41 StringRef getFeatureString(const Function &F) const;
44 AMDGPUTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
45 StringRef FS, TargetOptions Options,
46 Optional<Reloc::Model> RM, CodeModel::Model CM,
47 CodeGenOpt::Level OL);
48 ~AMDGPUTargetMachine() override;
50 const AMDGPUSubtarget *getSubtargetImpl() const;
51 const AMDGPUSubtarget *getSubtargetImpl(const Function &) const override = 0;
53 const AMDGPUIntrinsicInfo *getIntrinsicInfo() const override {
54 return &IntrinsicInfo;
56 TargetIRAnalysis getTargetIRAnalysis() override;
58 TargetLoweringObjectFile *getObjFileLowering() const override {
61 AMDGPUAS getAMDGPUAS() const {
65 void adjustPassManager(PassManagerBuilder &) override;
66 /// Get the integer value of a null pointer in the given address space.
67 uint64_t getNullPointerValue(unsigned AddrSpace) const {
68 if (AddrSpace == AS.LOCAL_ADDRESS || AddrSpace == AS.REGION_ADDRESS)
75 //===----------------------------------------------------------------------===//
76 // R600 Target Machine (R600 -> Cayman)
77 //===----------------------------------------------------------------------===//
79 class R600TargetMachine final : public AMDGPUTargetMachine {
81 mutable StringMap<std::unique_ptr<R600Subtarget>> SubtargetMap;
84 R600TargetMachine(const Target &T, const Triple &TT, StringRef CPU,
85 StringRef FS, TargetOptions Options,
86 Optional<Reloc::Model> RM, CodeModel::Model CM,
87 CodeGenOpt::Level OL);
89 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
91 const R600Subtarget *getSubtargetImpl(const Function &) const override;
94 //===----------------------------------------------------------------------===//
95 // GCN Target Machine (SI+)
96 //===----------------------------------------------------------------------===//
98 class GCNTargetMachine final : public AMDGPUTargetMachine {
100 mutable StringMap<std::unique_ptr<SISubtarget>> SubtargetMap;
103 GCNTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
104 StringRef FS, TargetOptions Options,
105 Optional<Reloc::Model> RM, CodeModel::Model CM,
106 CodeGenOpt::Level OL);
108 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
110 const SISubtarget *getSubtargetImpl(const Function &) const override;
113 } // end namespace llvm
115 #endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUTARGETMACHINE_H