blob: 2f2a152519a5ac45a00d1dbfc702866e745d4aba [file] [log] [blame]
Tom Stellard75aadc22012-12-11 21:25:42 +00001//=====-- AMDGPUSubtarget.h - Define Subtarget for the AMDIL ---*- 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 AMDGPU specific subclass of TargetSubtarget.
12//
13//===----------------------------------------------------------------------===//
14
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000015#ifndef LLVM_LIB_TARGET_R600_AMDGPUSUBTARGET_H
16#define LLVM_LIB_TARGET_R600_AMDGPUSUBTARGET_H
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000017#include "AMDGPU.h"
Eric Christopherac4b69e2014-07-25 22:22:39 +000018#include "AMDGPUFrameLowering.h"
Tom Stellard2e59a452014-06-13 01:32:00 +000019#include "AMDGPUInstrInfo.h"
Eric Christopherac4b69e2014-07-25 22:22:39 +000020#include "AMDGPUIntrinsicInfo.h"
21#include "AMDGPUSubtarget.h"
22#include "R600ISelLowering.h"
Tom Stellard75aadc22012-12-11 21:25:42 +000023#include "llvm/ADT/StringExtras.h"
24#include "llvm/ADT/StringRef.h"
25#include "llvm/Target/TargetSubtargetInfo.h"
26
27#define GET_SUBTARGETINFO_HEADER
28#include "AMDGPUGenSubtargetInfo.inc"
29
Tom Stellard75aadc22012-12-11 21:25:42 +000030namespace llvm {
31
Tom Stellarde99fb652015-01-20 19:33:04 +000032class SIMachineFunctionInfo;
33
Tom Stellard75aadc22012-12-11 21:25:42 +000034class AMDGPUSubtarget : public AMDGPUGenSubtargetInfo {
Tom Stellard2e59a452014-06-13 01:32:00 +000035
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000036public:
37 enum Generation {
38 R600 = 0,
39 R700,
40 EVERGREEN,
41 NORTHERN_ISLANDS,
Tom Stellard6e1ee472013-10-29 16:37:28 +000042 SOUTHERN_ISLANDS,
Marek Olsak5df00d62014-12-07 12:18:57 +000043 SEA_ISLANDS,
44 VOLCANIC_ISLANDS,
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000045 };
46
Tom Stellard75aadc22012-12-11 21:25:42 +000047private:
Tom Stellard75aadc22012-12-11 21:25:42 +000048 std::string DevName;
49 bool Is64bit;
Tom Stellard75aadc22012-12-11 21:25:42 +000050 bool DumpCode;
51 bool R600ALUInst;
Vincent Lejeunec2991642013-04-30 00:13:39 +000052 bool HasVertexCache;
Vincent Lejeunef9f4e1e2013-05-17 16:49:55 +000053 short TexVTXClauseSize;
Matt Arsenaultd782d052014-06-27 17:57:00 +000054 Generation Gen;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000055 bool FP64;
Matt Arsenaultf171cf22014-07-14 23:40:49 +000056 bool FP64Denormals;
57 bool FP32Denormals;
Matt Arsenaultb035a572015-01-29 19:34:25 +000058 bool FastFMAF32;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000059 bool CaymanISA;
Matt Arsenault3f981402014-09-15 15:41:53 +000060 bool FlatAddressSpace;
Tom Stellarded0ceec2013-10-10 17:11:12 +000061 bool EnableIRStructurizer;
Matt Arsenaultd9a23ab2014-07-13 02:08:26 +000062 bool EnablePromoteAlloca;
Tom Stellard783893a2013-11-18 19:43:33 +000063 bool EnableIfCvt;
Matt Arsenault41033282014-10-10 22:01:59 +000064 bool EnableLoadStoreOpt;
Tom Stellard8c347b02014-01-22 21:55:40 +000065 unsigned WavefrontSize;
Tom Stellard348273d2014-01-23 16:18:02 +000066 bool CFALUBug;
Tom Stellard880a80a2014-06-17 16:53:14 +000067 int LocalMemorySize;
Tom Stellarde99fb652015-01-20 19:33:04 +000068 bool EnableVGPRSpilling;
Tom Stellard75aadc22012-12-11 21:25:42 +000069
Eric Christopherac4b69e2014-07-25 22:22:39 +000070 AMDGPUFrameLowering FrameLowering;
Eric Christopherac4b69e2014-07-25 22:22:39 +000071 std::unique_ptr<AMDGPUTargetLowering> TLInfo;
72 std::unique_ptr<AMDGPUInstrInfo> InstrInfo;
Tom Stellard75aadc22012-12-11 21:25:42 +000073 InstrItineraryData InstrItins;
Tom Stellard794c8c02014-12-02 17:05:41 +000074 Triple TargetTriple;
Tom Stellard75aadc22012-12-11 21:25:42 +000075
76public:
Eric Christopherac4b69e2014-07-25 22:22:39 +000077 AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS, TargetMachine &TM);
Tom Stellardeba56482015-01-28 15:38:42 +000078 AMDGPUSubtarget &initializeSubtargetDependencies(StringRef TT, StringRef GPU,
79 StringRef FS);
Tom Stellard75aadc22012-12-11 21:25:42 +000080
Eric Christopherd9134482014-08-04 21:25:23 +000081 const AMDGPUFrameLowering *getFrameLowering() const override {
82 return &FrameLowering;
83 }
84 const AMDGPUInstrInfo *getInstrInfo() const override {
85 return InstrInfo.get();
86 }
87 const AMDGPURegisterInfo *getRegisterInfo() const override {
Eric Christopherac4b69e2014-07-25 22:22:39 +000088 return &InstrInfo->getRegisterInfo();
Tom Stellard2e59a452014-06-13 01:32:00 +000089 }
Eric Christopherd9134482014-08-04 21:25:23 +000090 AMDGPUTargetLowering *getTargetLowering() const override {
91 return TLInfo.get();
92 }
Eric Christopherd9134482014-08-04 21:25:23 +000093 const InstrItineraryData *getInstrItineraryData() const override {
94 return &InstrItins;
95 }
Matt Arsenaultd782d052014-06-27 17:57:00 +000096
Craig Topperee7b0f32014-04-30 05:53:27 +000097 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
Tom Stellard75aadc22012-12-11 21:25:42 +000098
Matt Arsenaultd782d052014-06-27 17:57:00 +000099 bool is64bit() const {
100 return Is64bit;
101 }
102
103 bool hasVertexCache() const {
104 return HasVertexCache;
105 }
106
107 short getTexVTXClauseSize() const {
Matt Arsenaultd9a23ab2014-07-13 02:08:26 +0000108 return TexVTXClauseSize;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000109 }
110
111 Generation getGeneration() const {
112 return Gen;
113 }
114
115 bool hasHWFP64() const {
116 return FP64;
117 }
118
119 bool hasCaymanISA() const {
120 return CaymanISA;
121 }
Matt Arsenaultfae02982014-03-17 18:58:11 +0000122
Matt Arsenaultf171cf22014-07-14 23:40:49 +0000123 bool hasFP32Denormals() const {
124 return FP32Denormals;
125 }
126
127 bool hasFP64Denormals() const {
128 return FP64Denormals;
129 }
130
Matt Arsenaultb035a572015-01-29 19:34:25 +0000131 bool hasFastFMAF32() const {
132 return FastFMAF32;
133 }
134
Matt Arsenault3f981402014-09-15 15:41:53 +0000135 bool hasFlatAddressSpace() const {
136 return FlatAddressSpace;
137 }
138
Matt Arsenaultfae02982014-03-17 18:58:11 +0000139 bool hasBFE() const {
140 return (getGeneration() >= EVERGREEN);
141 }
142
Matt Arsenault6e439652014-06-10 19:00:20 +0000143 bool hasBFI() const {
144 return (getGeneration() >= EVERGREEN);
145 }
146
Matt Arsenaultfae02982014-03-17 18:58:11 +0000147 bool hasBFM() const {
148 return hasBFE();
149 }
150
Matt Arsenault60425062014-06-10 19:18:28 +0000151 bool hasBCNT(unsigned Size) const {
152 if (Size == 32)
153 return (getGeneration() >= EVERGREEN);
154
Matt Arsenault3dd43fc2014-07-18 06:07:13 +0000155 if (Size == 64)
156 return (getGeneration() >= SOUTHERN_ISLANDS);
157
158 return false;
Matt Arsenault60425062014-06-10 19:18:28 +0000159 }
160
Tom Stellard50122a52014-04-07 19:45:41 +0000161 bool hasMulU24() const {
162 return (getGeneration() >= EVERGREEN);
163 }
164
165 bool hasMulI24() const {
166 return (getGeneration() >= SOUTHERN_ISLANDS ||
167 hasCaymanISA());
168 }
169
Jan Vesely6ddb8dd2014-07-15 15:51:09 +0000170 bool hasFFBL() const {
171 return (getGeneration() >= EVERGREEN);
172 }
173
174 bool hasFFBH() const {
175 return (getGeneration() >= EVERGREEN);
176 }
177
Matt Arsenaultd782d052014-06-27 17:57:00 +0000178 bool IsIRStructurizerEnabled() const {
179 return EnableIRStructurizer;
180 }
181
Matt Arsenaultd9a23ab2014-07-13 02:08:26 +0000182 bool isPromoteAllocaEnabled() const {
183 return EnablePromoteAlloca;
184 }
185
Matt Arsenaultd782d052014-06-27 17:57:00 +0000186 bool isIfCvtEnabled() const {
187 return EnableIfCvt;
188 }
189
Matt Arsenault41033282014-10-10 22:01:59 +0000190 bool loadStoreOptEnabled() const {
191 return EnableLoadStoreOpt;
192 }
193
Matt Arsenaultd782d052014-06-27 17:57:00 +0000194 unsigned getWavefrontSize() const {
195 return WavefrontSize;
196 }
197
Tom Stellarda40f9712014-01-22 21:55:43 +0000198 unsigned getStackEntrySize() const;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000199
200 bool hasCFAluBug() const {
201 assert(getGeneration() <= NORTHERN_ISLANDS);
202 return CFALUBug;
203 }
204
205 int getLocalMemorySize() const {
206 return LocalMemorySize;
207 }
Tom Stellard75aadc22012-12-11 21:25:42 +0000208
Tom Stellardb8fd6ef2014-12-02 22:00:07 +0000209 unsigned getAmdKernelCodeChipID() const;
210
Craig Topper5656db42014-04-29 07:57:24 +0000211 bool enableMachineScheduler() const override {
Tom Stellard83f0bce2015-01-29 16:55:25 +0000212 return true;
Andrew Trick978674b2013-09-20 05:14:41 +0000213 }
214
Tom Stellard83f0bce2015-01-29 16:55:25 +0000215 void overrideSchedPolicy(MachineSchedPolicy &Policy,
216 MachineInstr *begin, MachineInstr *end,
217 unsigned NumRegionInstrs) const override;
218
Tom Stellard75aadc22012-12-11 21:25:42 +0000219 // Helper functions to simplify if statements
Matt Arsenaultd782d052014-06-27 17:57:00 +0000220 bool isTargetELF() const {
221 return false;
222 }
Tom Stellard75aadc22012-12-11 21:25:42 +0000223
Matt Arsenaultd782d052014-06-27 17:57:00 +0000224 StringRef getDeviceName() const {
225 return DevName;
226 }
227
228 bool dumpCode() const {
229 return DumpCode;
230 }
231 bool r600ALUEncoding() const {
232 return R600ALUInst;
233 }
Tom Stellard794c8c02014-12-02 17:05:41 +0000234 bool isAmdHsaOS() const {
235 return TargetTriple.getOS() == Triple::AMDHSA;
236 }
Tom Stellarde99fb652015-01-20 19:33:04 +0000237 bool isVGPRSpillingEnabled(const SIMachineFunctionInfo *MFI) const;
Tom Stellard83f0bce2015-01-29 16:55:25 +0000238
239 unsigned getMaxWavesPerCU() const {
240 if (getGeneration() >= AMDGPUSubtarget::SOUTHERN_ISLANDS)
241 return 10;
242
243 // FIXME: Not sure what this is for other subtagets.
244 llvm_unreachable("do not know max waves per CU for this subtarget.");
245 }
Tom Stellardf6afc802015-02-04 23:14:18 +0000246
247 bool enableSubRegLiveness() const override {
248 return true;
249 }
Tom Stellard75aadc22012-12-11 21:25:42 +0000250};
251
252} // End namespace llvm
253
Benjamin Kramera7c40ef2014-08-13 16:26:38 +0000254#endif