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"
23 //===----------------------------------------------------------------------===//
24 // AMDGPU Target Machine (R600+)
25 //===----------------------------------------------------------------------===//
27 class AMDGPUTargetMachine : public LLVMTargetMachine {
29 std::unique_ptr<TargetLoweringObjectFile> TLOF;
30 AMDGPUIntrinsicInfo IntrinsicInfo;
32 StringRef getGPUName(const Function &F) const;
33 StringRef getFeatureString(const Function &F) const;
36 AMDGPUTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
37 StringRef FS, TargetOptions Options,
38 Optional<Reloc::Model> RM, CodeModel::Model CM,
39 CodeGenOpt::Level OL);
40 ~AMDGPUTargetMachine();
42 const AMDGPUSubtarget *getSubtargetImpl() const;
43 const AMDGPUSubtarget *getSubtargetImpl(const Function &) const override;
45 const AMDGPUIntrinsicInfo *getIntrinsicInfo() const override {
46 return &IntrinsicInfo;
48 TargetIRAnalysis getTargetIRAnalysis() override;
50 TargetLoweringObjectFile *getObjFileLowering() const override {
55 //===----------------------------------------------------------------------===//
56 // R600 Target Machine (R600 -> Cayman)
57 //===----------------------------------------------------------------------===//
59 class R600TargetMachine final : public AMDGPUTargetMachine {
61 mutable StringMap<std::unique_ptr<R600Subtarget>> SubtargetMap;
64 R600TargetMachine(const Target &T, const Triple &TT, StringRef CPU,
65 StringRef FS, TargetOptions Options,
66 Optional<Reloc::Model> RM, CodeModel::Model CM,
67 CodeGenOpt::Level OL);
69 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
71 const R600Subtarget *getSubtargetImpl(const Function &) const override;
74 //===----------------------------------------------------------------------===//
75 // GCN Target Machine (SI+)
76 //===----------------------------------------------------------------------===//
78 class GCNTargetMachine final : public AMDGPUTargetMachine {
80 mutable StringMap<std::unique_ptr<SISubtarget>> SubtargetMap;
83 GCNTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
84 StringRef FS, TargetOptions Options,
85 Optional<Reloc::Model> RM, CodeModel::Model CM,
86 CodeGenOpt::Level OL);
88 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
90 const SISubtarget *getSubtargetImpl(const Function &) const override;
93 inline const AMDGPUSubtarget *AMDGPUTargetMachine::getSubtargetImpl(
94 const Function &F) const {
95 if (getTargetTriple().getArch() == Triple::amdgcn)
96 return static_cast<const GCNTargetMachine *>(this)->getSubtargetImpl(F);
97 return static_cast<const R600TargetMachine *>(this)->getSubtargetImpl(F);
100 } // End namespace llvm