1//=====-- R600Subtarget.h - Define Subtarget for AMDGPU R600 ----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//==-----------------------------------------------------------------------===//
8//
9/// \file
10/// AMDGPU R600 specific subclass of TargetSubtarget.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_AMDGPU_R600SUBTARGET_H
15#define LLVM_LIB_TARGET_AMDGPU_R600SUBTARGET_H
16
17#include "AMDGPUSubtarget.h"
18#include "R600FrameLowering.h"
19#include "R600ISelLowering.h"
20#include "R600InstrInfo.h"
21#include "Utils/AMDGPUBaseInfo.h"
22
23#define GET_SUBTARGETINFO_HEADER
24#include "R600GenSubtargetInfo.inc"
25
26namespace llvm {
27
28class AMDGPUTargetMachine;
29
30class R600Subtarget final : public R600GenSubtargetInfo,
31 public AMDGPUSubtarget {
32
33#define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \
34 bool ATTRIBUTE = DEFAULT;
35#include "R600GenSubtargetInfo.inc"
36
37private:
38 R600InstrInfo InstrInfo;
39 R600FrameLowering FrameLowering;
40 short TexVTXClauseSize = 0;
41 Generation Gen = R600;
42 R600TargetLowering TLInfo;
43 InstrItineraryData InstrItins;
44 std::unique_ptr<const SelectionDAGTargetInfo> TSInfo;
45
46public:
47 R600Subtarget(const Triple &TT, StringRef CPU, StringRef FS,
48 const AMDGPUTargetMachine &TM);
49
50 ~R600Subtarget() override;
51
52 const R600InstrInfo *getInstrInfo() const override { return &InstrInfo; }
53
54 const R600FrameLowering *getFrameLowering() const override {
55 return &FrameLowering;
56 }
57
58 const R600TargetLowering *getTargetLowering() const override {
59 return &TLInfo;
60 }
61
62 const R600RegisterInfo *getRegisterInfo() const override {
63 return &InstrInfo.getRegisterInfo();
64 }
65
66 const InstrItineraryData *getInstrItineraryData() const override {
67 return &InstrItins;
68 }
69
70 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override;
71
72 void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
73
74 Generation getGeneration() const {
75 return Gen;
76 }
77
78 Align getStackAlignment() const { return Align(4); }
79
80 R600Subtarget &initializeSubtargetDependencies(const Triple &TT,
81 StringRef GPU, StringRef FS);
82
83 bool hasBFE() const {
84 return (getGeneration() >= EVERGREEN);
85 }
86
87 bool hasBFI() const {
88 return (getGeneration() >= EVERGREEN);
89 }
90
91 bool hasBCNT(unsigned Size) const {
92 if (Size == 32)
93 return (getGeneration() >= EVERGREEN);
94
95 return false;
96 }
97
98 bool hasBORROW() const {
99 return (getGeneration() >= EVERGREEN);
100 }
101
102 bool hasCARRY() const {
103 return (getGeneration() >= EVERGREEN);
104 }
105
106 bool hasCaymanISA() const { return HasCaymanISA; }
107
108 bool hasFFBL() const {
109 return (getGeneration() >= EVERGREEN);
110 }
111
112 bool hasFFBH() const {
113 return (getGeneration() >= EVERGREEN);
114 }
115
116 bool hasFMA() const override { return HasFMA; }
117
118 bool hasMadMacF32Insts() const override { return HasMadMacF32Insts; }
119
120 bool hasFP64() const override { return HasFP64; }
121
122 bool hasCFALUBug() const { return HasCFALUBug; }
123
124 bool hasVertexCache() const { return HasVertexCache; }
125
126 short getTexVTXClauseSize() const { return TexVTXClauseSize; }
127
128 bool enableMachineScheduler() const override {
129 return true;
130 }
131
132 bool enableSubRegLiveness() const override {
133 return true;
134 }
135
136 /// \returns Maximum number of work groups per compute unit supported by the
137 /// subtarget and limited by given \p FlatWorkGroupSize.
138 unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const override {
139 return AMDGPU::IsaInfo::getMaxWorkGroupsPerCU(STI: *this, FlatWorkGroupSize);
140 }
141
142 /// \returns Minimum flat work group size supported by the subtarget.
143 unsigned getMinFlatWorkGroupSize() const override {
144 return AMDGPU::getMinFlatWorkGroupSize();
145 }
146
147 /// \returns Maximum flat work group size supported by the subtarget.
148 unsigned getMaxFlatWorkGroupSize() const override {
149 return AMDGPU::getMaxFlatWorkGroupSize();
150 }
151
152 /// \returns Number of waves per execution unit required to support the given
153 /// \p FlatWorkGroupSize.
154 unsigned
155 getWavesPerEUForWorkGroup(unsigned FlatWorkGroupSize) const override {
156 return AMDGPU::IsaInfo::getWavesPerEUForWorkGroup(STI: *this, FlatWorkGroupSize);
157 }
158
159 /// \returns Minimum number of waves per execution unit supported by the
160 /// subtarget.
161 unsigned getMinWavesPerEU() const override {
162 return AMDGPU::getMinWavesPerEU();
163 }
164
165 bool requiresDisjointEarlyClobberAndUndef() const override {
166 // AMDGPU doesn't care if early-clobber and undef operands are allocated
167 // to the same register.
168 return false;
169 }
170};
171
172} // end namespace llvm
173
174#endif // LLVM_LIB_TARGET_AMDGPU_R600SUBTARGET_H
175