blob: c8c550cd0e5b0caa3e76da606f889e00b60d91aa [file] [log] [blame]
Matt Arsenault382d9452016-01-26 04:49:22 +00001//===-- AMDGPU.td - AMDGPU Tablegen files --------*- tablegen -*-===//
Tom Stellard75aadc22012-12-11 21:25:42 +00002//
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//
Matt Arsenault382d9452016-01-26 04:49:22 +00008//===------------------------------------------------------------===//
Tom Stellard75aadc22012-12-11 21:25:42 +00009
Tom Stellardbc5b5372014-06-13 16:38:59 +000010include "llvm/Target/Target.td"
Tom Stellard75aadc22012-12-11 21:25:42 +000011
Matt Arsenault382d9452016-01-26 04:49:22 +000012//===------------------------------------------------------------===//
13// Subtarget Features (device properties)
14//===------------------------------------------------------------===//
Tom Stellard783893a2013-11-18 19:43:33 +000015
Matt Arsenaultf5e29972014-06-20 06:50:05 +000016def FeatureFP64 : SubtargetFeature<"fp64",
Matt Arsenault382d9452016-01-26 04:49:22 +000017 "FP64",
18 "true",
19 "Enable double precision operations"
20>;
Matt Arsenaultf171cf22014-07-14 23:40:49 +000021
Matt Arsenaultb035a572015-01-29 19:34:25 +000022def FeatureFastFMAF32 : SubtargetFeature<"fast-fmaf",
Matt Arsenault382d9452016-01-26 04:49:22 +000023 "FastFMAF32",
24 "true",
25 "Assuming f32 fma is at least as fast as mul + add"
26>;
Matt Arsenaultb035a572015-01-29 19:34:25 +000027
Matt Arsenaulte83690c2016-01-18 21:13:50 +000028def HalfRate64Ops : SubtargetFeature<"half-rate-64-ops",
Matt Arsenault382d9452016-01-26 04:49:22 +000029 "HalfRate64Ops",
30 "true",
31 "Most fp64 instructions are half rate instead of quarter"
32>;
Matt Arsenaultf171cf22014-07-14 23:40:49 +000033
Tom Stellard99792772013-06-07 20:28:49 +000034def FeatureR600ALUInst : SubtargetFeature<"R600ALUInst",
Matt Arsenault382d9452016-01-26 04:49:22 +000035 "R600ALUInst",
36 "false",
37 "Older version of ALU instructions encoding"
38>;
Tom Stellard99792772013-06-07 20:28:49 +000039
40def FeatureVertexCache : SubtargetFeature<"HasVertexCache",
Matt Arsenault382d9452016-01-26 04:49:22 +000041 "HasVertexCache",
42 "true",
43 "Specify use of dedicated vertex cache"
44>;
Tom Stellard99792772013-06-07 20:28:49 +000045
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000046def FeatureCaymanISA : SubtargetFeature<"caymanISA",
Matt Arsenault382d9452016-01-26 04:49:22 +000047 "CaymanISA",
48 "true",
49 "Use Cayman ISA"
50>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000051
Tom Stellard348273d2014-01-23 16:18:02 +000052def FeatureCFALUBug : SubtargetFeature<"cfalubug",
Matt Arsenault382d9452016-01-26 04:49:22 +000053 "CFALUBug",
54 "true",
55 "GPU has CF_ALU bug"
56>;
Changpeng Fangb41574a2015-12-22 20:55:23 +000057
Matt Arsenault3f981402014-09-15 15:41:53 +000058def FeatureFlatAddressSpace : SubtargetFeature<"flat-address-space",
Matt Arsenault382d9452016-01-26 04:49:22 +000059 "FlatAddressSpace",
60 "true",
61 "Support flat address space"
62>;
Matt Arsenault3f981402014-09-15 15:41:53 +000063
Nicolai Haehnle5b504972016-01-04 23:35:53 +000064def FeatureXNACK : SubtargetFeature<"xnack",
Matt Arsenault382d9452016-01-26 04:49:22 +000065 "EnableXNACK",
66 "true",
67 "Enable XNACK support"
68>;
Tom Stellarde99fb652015-01-20 19:33:04 +000069
Marek Olsak4d00dd22015-03-09 15:48:09 +000070def FeatureSGPRInitBug : SubtargetFeature<"sgpr-init-bug",
Matt Arsenault382d9452016-01-26 04:49:22 +000071 "SGPRInitBug",
72 "true",
73 "VI SGPR initilization bug requiring a fixed SGPR allocation size"
74>;
Tom Stellardde008d32016-01-21 04:28:34 +000075
Tom Stellard3498e4f2013-06-07 20:28:55 +000076class SubtargetFeatureFetchLimit <string Value> :
77 SubtargetFeature <"fetch"#Value,
Matt Arsenault382d9452016-01-26 04:49:22 +000078 "TexVTXClauseSize",
79 Value,
80 "Limit the maximum number of fetches in a clause to "#Value
81>;
Tom Stellard99792772013-06-07 20:28:49 +000082
Tom Stellard3498e4f2013-06-07 20:28:55 +000083def FeatureFetchLimit8 : SubtargetFeatureFetchLimit <"8">;
84def FeatureFetchLimit16 : SubtargetFeatureFetchLimit <"16">;
85
Tom Stellard8c347b02014-01-22 21:55:40 +000086class SubtargetFeatureWavefrontSize <int Value> : SubtargetFeature<
Matt Arsenault382d9452016-01-26 04:49:22 +000087 "wavefrontsize"#Value,
88 "WavefrontSize",
89 !cast<string>(Value),
90 "The number of threads per wavefront"
91>;
Tom Stellard8c347b02014-01-22 21:55:40 +000092
93def FeatureWavefrontSize16 : SubtargetFeatureWavefrontSize<16>;
94def FeatureWavefrontSize32 : SubtargetFeatureWavefrontSize<32>;
95def FeatureWavefrontSize64 : SubtargetFeatureWavefrontSize<64>;
96
Tom Stellardec87f842015-05-25 16:15:54 +000097class SubtargetFeatureLDSBankCount <int Value> : SubtargetFeature <
Matt Arsenault382d9452016-01-26 04:49:22 +000098 "ldsbankcount"#Value,
99 "LDSBankCount",
100 !cast<string>(Value),
101 "The number of LDS banks per compute unit."
102>;
Tom Stellardec87f842015-05-25 16:15:54 +0000103
104def FeatureLDSBankCount16 : SubtargetFeatureLDSBankCount<16>;
105def FeatureLDSBankCount32 : SubtargetFeatureLDSBankCount<32>;
106
Tom Stellard347ac792015-06-26 21:15:07 +0000107class SubtargetFeatureISAVersion <int Major, int Minor, int Stepping>
108 : SubtargetFeature <
Matt Arsenault382d9452016-01-26 04:49:22 +0000109 "isaver"#Major#"."#Minor#"."#Stepping,
110 "IsaVersion",
111 "ISAVersion"#Major#"_"#Minor#"_"#Stepping,
112 "Instruction set version number"
Tom Stellard347ac792015-06-26 21:15:07 +0000113>;
114
115def FeatureISAVersion7_0_0 : SubtargetFeatureISAVersion <7,0,0>;
116def FeatureISAVersion7_0_1 : SubtargetFeatureISAVersion <7,0,1>;
117def FeatureISAVersion8_0_0 : SubtargetFeatureISAVersion <8,0,0>;
118def FeatureISAVersion8_0_1 : SubtargetFeatureISAVersion <8,0,1>;
Changpeng Fangc16be002016-01-13 20:39:25 +0000119def FeatureISAVersion8_0_3 : SubtargetFeatureISAVersion <8,0,3>;
Tom Stellard347ac792015-06-26 21:15:07 +0000120
Tom Stellard880a80a2014-06-17 16:53:14 +0000121class SubtargetFeatureLocalMemorySize <int Value> : SubtargetFeature<
Matt Arsenault382d9452016-01-26 04:49:22 +0000122 "localmemorysize"#Value,
123 "LocalMemorySize",
124 !cast<string>(Value),
125 "The size of local memory in bytes"
126>;
Tom Stellard880a80a2014-06-17 16:53:14 +0000127
Tom Stellardd7e6f132015-04-08 01:09:26 +0000128def FeatureGCN : SubtargetFeature<"gcn",
Matt Arsenault382d9452016-01-26 04:49:22 +0000129 "IsGCN",
130 "true",
131 "GCN or newer GPU"
132>;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000133
134def FeatureGCN1Encoding : SubtargetFeature<"gcn1-encoding",
Matt Arsenault382d9452016-01-26 04:49:22 +0000135 "GCN1Encoding",
136 "true",
137 "Encoding format for SI and CI"
138>;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000139
140def FeatureGCN3Encoding : SubtargetFeature<"gcn3-encoding",
Matt Arsenault382d9452016-01-26 04:49:22 +0000141 "GCN3Encoding",
142 "true",
143 "Encoding format for VI"
144>;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000145
146def FeatureCIInsts : SubtargetFeature<"ci-insts",
Matt Arsenault382d9452016-01-26 04:49:22 +0000147 "CIInsts",
148 "true",
149 "Additional intstructions for CI+"
150>;
151
152//===------------------------------------------------------------===//
153// Subtarget Features (options and debugging)
154//===------------------------------------------------------------===//
155
156// Some instructions do not support denormals despite this flag. Using
157// fp32 denormals also causes instructions to run at the double
158// precision rate for the device.
159def FeatureFP32Denormals : SubtargetFeature<"fp32-denormals",
160 "FP32Denormals",
161 "true",
162 "Enable single precision denormal handling"
163>;
164
165def FeatureFP64Denormals : SubtargetFeature<"fp64-denormals",
166 "FP64Denormals",
167 "true",
168 "Enable double precision denormal handling",
169 [FeatureFP64]
170>;
171
172def FeatureEnableHugeScratchBuffer : SubtargetFeature<
173 "huge-scratch-buffer",
174 "EnableHugeScratchBuffer",
175 "true",
176 "Enable scratch buffer sizes greater than 128 GB"
177>;
178
179def FeatureVGPRSpilling : SubtargetFeature<"vgpr-spilling",
180 "EnableVGPRSpilling",
181 "true",
182 "Enable spilling of VGPRs to scratch memory"
183>;
184
185def FeatureDumpCode : SubtargetFeature <"DumpCode",
186 "DumpCode",
187 "true",
188 "Dump MachineInstrs in the CodeEmitter"
189>;
190
191def FeatureDumpCodeLower : SubtargetFeature <"dumpcode",
192 "DumpCode",
193 "true",
194 "Dump MachineInstrs in the CodeEmitter"
195>;
196
197def FeatureIRStructurizer : SubtargetFeature <"disable-irstructurizer",
198 "EnableIRStructurizer",
199 "false",
200 "Disable IR Structurizer"
201>;
202
203def FeaturePromoteAlloca : SubtargetFeature <"promote-alloca",
204 "EnablePromoteAlloca",
205 "true",
206 "Enable promote alloca pass"
207>;
208
209// XXX - This should probably be removed once enabled by default
210def FeatureEnableLoadStoreOpt : SubtargetFeature <"load-store-opt",
211 "EnableLoadStoreOpt",
212 "true",
213 "Enable SI load/store optimizer pass"
214>;
215
216// Performance debugging feature. Allow using DS instruction immediate
217// offsets even if the base pointer can't be proven to be base. On SI,
218// base pointer values that won't give the same result as a 16-bit add
219// are not safe to fold, but this will override the conservative test
220// for the base pointer.
221def FeatureEnableUnsafeDSOffsetFolding : SubtargetFeature <
222 "unsafe-ds-offset-folding",
223 "EnableUnsafeDSOffsetFolding",
224 "true",
225 "Force using DS instruction immediate offsets on SI"
226>;
227
228def FeatureIfCvt : SubtargetFeature <"disable-ifcvt",
229 "EnableIfCvt",
230 "false",
231 "Disable the if conversion pass"
232>;
233
234def FeatureEnableSIScheduler : SubtargetFeature<"si-scheduler",
235 "EnableSIScheduler",
236 "true",
237 "Enable SI Machine Scheduler"
238>;
239
240def FeatureFlatForGlobal : SubtargetFeature<"flat-for-global",
241 "FlatForGlobal",
242 "true",
243 "Force to generate flat instruction for global"
244>;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000245
246// Dummy feature used to disable assembler instructions.
247def FeatureDisable : SubtargetFeature<"",
Matt Arsenault382d9452016-01-26 04:49:22 +0000248 "FeatureDisable","true",
249 "Dummy feature to disable assembler instructions"
250>;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000251
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000252class SubtargetFeatureGeneration <string Value,
253 list<SubtargetFeature> Implies> :
254 SubtargetFeature <Value, "Gen", "AMDGPUSubtarget::"#Value,
255 Value#" GPU generation", Implies>;
256
Tom Stellard880a80a2014-06-17 16:53:14 +0000257def FeatureLocalMemorySize0 : SubtargetFeatureLocalMemorySize<0>;
258def FeatureLocalMemorySize32768 : SubtargetFeatureLocalMemorySize<32768>;
259def FeatureLocalMemorySize65536 : SubtargetFeatureLocalMemorySize<65536>;
260
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000261def FeatureR600 : SubtargetFeatureGeneration<"R600",
Matt Arsenault382d9452016-01-26 04:49:22 +0000262 [FeatureR600ALUInst, FeatureFetchLimit8, FeatureLocalMemorySize0]
263>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000264
265def FeatureR700 : SubtargetFeatureGeneration<"R700",
Matt Arsenault382d9452016-01-26 04:49:22 +0000266 [FeatureFetchLimit16, FeatureLocalMemorySize0]
267>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000268
269def FeatureEvergreen : SubtargetFeatureGeneration<"EVERGREEN",
Matt Arsenault382d9452016-01-26 04:49:22 +0000270 [FeatureFetchLimit16, FeatureLocalMemorySize32768]
271>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000272
273def FeatureNorthernIslands : SubtargetFeatureGeneration<"NORTHERN_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000274 [FeatureFetchLimit16, FeatureWavefrontSize64,
275 FeatureLocalMemorySize32768]
Tom Stellard880a80a2014-06-17 16:53:14 +0000276>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000277
278def FeatureSouthernIslands : SubtargetFeatureGeneration<"SOUTHERN_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000279 [FeatureFP64, FeatureLocalMemorySize32768,
280 FeatureWavefrontSize64, FeatureGCN, FeatureGCN1Encoding,
281 FeatureLDSBankCount32]
282>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000283
Tom Stellard6e1ee472013-10-29 16:37:28 +0000284def FeatureSeaIslands : SubtargetFeatureGeneration<"SEA_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000285 [FeatureFP64, FeatureLocalMemorySize65536,
286 FeatureWavefrontSize64, FeatureGCN, FeatureFlatAddressSpace,
287 FeatureGCN1Encoding, FeatureCIInsts]
288>;
Marek Olsak5df00d62014-12-07 12:18:57 +0000289
290def FeatureVolcanicIslands : SubtargetFeatureGeneration<"VOLCANIC_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000291 [FeatureFP64, FeatureLocalMemorySize65536,
292 FeatureWavefrontSize64, FeatureFlatAddressSpace, FeatureGCN,
Marek Olsake86f2522016-01-27 11:19:45 +0000293 FeatureGCN3Encoding, FeatureCIInsts]
Matt Arsenault382d9452016-01-26 04:49:22 +0000294>;
Marek Olsak5df00d62014-12-07 12:18:57 +0000295
Tom Stellard3498e4f2013-06-07 20:28:55 +0000296//===----------------------------------------------------------------------===//
Tom Stellard75aadc22012-12-11 21:25:42 +0000297
298def AMDGPUInstrInfo : InstrInfo {
299 let guessInstructionProperties = 1;
Matt Arsenault1ecac062015-02-18 02:15:32 +0000300 let noNamedPositionallyEncodedOperands = 1;
Tom Stellard75aadc22012-12-11 21:25:42 +0000301}
302
Tom Stellard9d7ddd52014-11-14 14:08:00 +0000303def AMDGPUAsmParser : AsmParser {
304 // Some of the R600 registers have the same name, so this crashes.
305 // For example T0_XYZW and T0_XY both have the asm name T0.
306 let ShouldEmitMatchRegisterName = 0;
307}
308
Tom Stellard75aadc22012-12-11 21:25:42 +0000309def AMDGPU : Target {
310 // Pull in Instruction Info:
311 let InstructionSet = AMDGPUInstrInfo;
Tom Stellard9d7ddd52014-11-14 14:08:00 +0000312 let AssemblyParsers = [AMDGPUAsmParser];
Tom Stellard75aadc22012-12-11 21:25:42 +0000313}
314
Tom Stellardbc5b5372014-06-13 16:38:59 +0000315// Dummy Instruction itineraries for pseudo instructions
316def ALU_NULL : FuncUnit;
317def NullALU : InstrItinClass;
318
Tom Stellard0e70de52014-05-16 20:56:45 +0000319//===----------------------------------------------------------------------===//
320// Predicate helper class
321//===----------------------------------------------------------------------===//
322
Tom Stellardd1f0f022015-04-23 19:33:54 +0000323def TruePredicate : Predicate<"true">;
Matt Arsenault382d9452016-01-26 04:49:22 +0000324
Tom Stellardd1f0f022015-04-23 19:33:54 +0000325def isSICI : Predicate<
326 "Subtarget->getGeneration() == AMDGPUSubtarget::SOUTHERN_ISLANDS ||"
327 "Subtarget->getGeneration() == AMDGPUSubtarget::SEA_ISLANDS"
328>, AssemblerPredicate<"FeatureGCN1Encoding">;
329
Tom Stellard5ebdfbe2015-12-24 03:18:18 +0000330def isVI : Predicate <
331 "Subtarget->getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS">,
332 AssemblerPredicate<"FeatureGCN3Encoding">;
333
Matt Arsenault382d9452016-01-26 04:49:22 +0000334def isCIVI : Predicate <
335 "Subtarget->getGeneration() == AMDGPUSubtarget::SEA_ISLANDS || "
336 "Subtarget->getGeneration() == AMDGPUSubtarget::VOLCANIC_ISLANDS"
337>, AssemblerPredicate<"FeatureCIInsts">;
338
339def HasFlatAddressSpace : Predicate<"Subtarget->hasFlatAddressSpace()">;
340
Tom Stellard0e70de52014-05-16 20:56:45 +0000341class PredicateControl {
342 Predicate SubtargetPredicate;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000343 Predicate SIAssemblerPredicate = isSICI;
Tom Stellard5ebdfbe2015-12-24 03:18:18 +0000344 Predicate VIAssemblerPredicate = isVI;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000345 list<Predicate> AssemblerPredicates = [];
Tom Stellardd1f0f022015-04-23 19:33:54 +0000346 Predicate AssemblerPredicate = TruePredicate;
Tom Stellard0e70de52014-05-16 20:56:45 +0000347 list<Predicate> OtherPredicates = [];
Tom Stellardd1f0f022015-04-23 19:33:54 +0000348 list<Predicate> Predicates = !listconcat([SubtargetPredicate, AssemblerPredicate],
Tom Stellardd7e6f132015-04-08 01:09:26 +0000349 AssemblerPredicates,
Tom Stellard0e70de52014-05-16 20:56:45 +0000350 OtherPredicates);
351}
352
Tom Stellard75aadc22012-12-11 21:25:42 +0000353// Include AMDGPU TD files
354include "R600Schedule.td"
355include "SISchedule.td"
356include "Processors.td"
357include "AMDGPUInstrInfo.td"
358include "AMDGPUIntrinsics.td"
359include "AMDGPURegisterInfo.td"
360include "AMDGPUInstructions.td"
Christian Konig2c8f6d52013-03-07 09:03:52 +0000361include "AMDGPUCallingConv.td"