blob: b842ba17675a001444a606e0039838593e543c2d [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
Matt Arsenaultf639c322016-01-28 20:53:42 +0000172def FeatureFPExceptions : SubtargetFeature<"fp-exceptions",
173 "FPExceptions",
174 "true",
175 "Enable floating point exceptions"
176>;
177
Matt Arsenault382d9452016-01-26 04:49:22 +0000178def FeatureEnableHugeScratchBuffer : SubtargetFeature<
179 "huge-scratch-buffer",
180 "EnableHugeScratchBuffer",
181 "true",
182 "Enable scratch buffer sizes greater than 128 GB"
183>;
184
185def FeatureVGPRSpilling : SubtargetFeature<"vgpr-spilling",
186 "EnableVGPRSpilling",
187 "true",
188 "Enable spilling of VGPRs to scratch memory"
189>;
190
191def FeatureDumpCode : SubtargetFeature <"DumpCode",
192 "DumpCode",
193 "true",
194 "Dump MachineInstrs in the CodeEmitter"
195>;
196
197def FeatureDumpCodeLower : SubtargetFeature <"dumpcode",
198 "DumpCode",
199 "true",
200 "Dump MachineInstrs in the CodeEmitter"
201>;
202
203def FeatureIRStructurizer : SubtargetFeature <"disable-irstructurizer",
204 "EnableIRStructurizer",
205 "false",
206 "Disable IR Structurizer"
207>;
208
209def FeaturePromoteAlloca : SubtargetFeature <"promote-alloca",
210 "EnablePromoteAlloca",
211 "true",
212 "Enable promote alloca pass"
213>;
214
215// XXX - This should probably be removed once enabled by default
216def FeatureEnableLoadStoreOpt : SubtargetFeature <"load-store-opt",
217 "EnableLoadStoreOpt",
218 "true",
219 "Enable SI load/store optimizer pass"
220>;
221
222// Performance debugging feature. Allow using DS instruction immediate
223// offsets even if the base pointer can't be proven to be base. On SI,
224// base pointer values that won't give the same result as a 16-bit add
225// are not safe to fold, but this will override the conservative test
226// for the base pointer.
227def FeatureEnableUnsafeDSOffsetFolding : SubtargetFeature <
228 "unsafe-ds-offset-folding",
229 "EnableUnsafeDSOffsetFolding",
230 "true",
231 "Force using DS instruction immediate offsets on SI"
232>;
233
234def FeatureIfCvt : SubtargetFeature <"disable-ifcvt",
235 "EnableIfCvt",
236 "false",
237 "Disable the if conversion pass"
238>;
239
240def FeatureEnableSIScheduler : SubtargetFeature<"si-scheduler",
241 "EnableSIScheduler",
242 "true",
243 "Enable SI Machine Scheduler"
244>;
245
246def FeatureFlatForGlobal : SubtargetFeature<"flat-for-global",
247 "FlatForGlobal",
248 "true",
249 "Force to generate flat instruction for global"
250>;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000251
252// Dummy feature used to disable assembler instructions.
253def FeatureDisable : SubtargetFeature<"",
Matt Arsenault382d9452016-01-26 04:49:22 +0000254 "FeatureDisable","true",
255 "Dummy feature to disable assembler instructions"
256>;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000257
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000258class SubtargetFeatureGeneration <string Value,
259 list<SubtargetFeature> Implies> :
260 SubtargetFeature <Value, "Gen", "AMDGPUSubtarget::"#Value,
261 Value#" GPU generation", Implies>;
262
Tom Stellard880a80a2014-06-17 16:53:14 +0000263def FeatureLocalMemorySize0 : SubtargetFeatureLocalMemorySize<0>;
264def FeatureLocalMemorySize32768 : SubtargetFeatureLocalMemorySize<32768>;
265def FeatureLocalMemorySize65536 : SubtargetFeatureLocalMemorySize<65536>;
266
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000267def FeatureR600 : SubtargetFeatureGeneration<"R600",
Matt Arsenault382d9452016-01-26 04:49:22 +0000268 [FeatureR600ALUInst, FeatureFetchLimit8, FeatureLocalMemorySize0]
269>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000270
271def FeatureR700 : SubtargetFeatureGeneration<"R700",
Matt Arsenault382d9452016-01-26 04:49:22 +0000272 [FeatureFetchLimit16, FeatureLocalMemorySize0]
273>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000274
275def FeatureEvergreen : SubtargetFeatureGeneration<"EVERGREEN",
Matt Arsenault382d9452016-01-26 04:49:22 +0000276 [FeatureFetchLimit16, FeatureLocalMemorySize32768]
277>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000278
279def FeatureNorthernIslands : SubtargetFeatureGeneration<"NORTHERN_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000280 [FeatureFetchLimit16, FeatureWavefrontSize64,
281 FeatureLocalMemorySize32768]
Tom Stellard880a80a2014-06-17 16:53:14 +0000282>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000283
284def FeatureSouthernIslands : SubtargetFeatureGeneration<"SOUTHERN_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000285 [FeatureFP64, FeatureLocalMemorySize32768,
286 FeatureWavefrontSize64, FeatureGCN, FeatureGCN1Encoding,
287 FeatureLDSBankCount32]
288>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000289
Tom Stellard6e1ee472013-10-29 16:37:28 +0000290def FeatureSeaIslands : SubtargetFeatureGeneration<"SEA_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000291 [FeatureFP64, FeatureLocalMemorySize65536,
292 FeatureWavefrontSize64, FeatureGCN, FeatureFlatAddressSpace,
293 FeatureGCN1Encoding, FeatureCIInsts]
294>;
Marek Olsak5df00d62014-12-07 12:18:57 +0000295
296def FeatureVolcanicIslands : SubtargetFeatureGeneration<"VOLCANIC_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000297 [FeatureFP64, FeatureLocalMemorySize65536,
298 FeatureWavefrontSize64, FeatureFlatAddressSpace, FeatureGCN,
Marek Olsake86f2522016-01-27 11:19:45 +0000299 FeatureGCN3Encoding, FeatureCIInsts]
Matt Arsenault382d9452016-01-26 04:49:22 +0000300>;
Marek Olsak5df00d62014-12-07 12:18:57 +0000301
Tom Stellard3498e4f2013-06-07 20:28:55 +0000302//===----------------------------------------------------------------------===//
Tom Stellard75aadc22012-12-11 21:25:42 +0000303
304def AMDGPUInstrInfo : InstrInfo {
305 let guessInstructionProperties = 1;
Matt Arsenault1ecac062015-02-18 02:15:32 +0000306 let noNamedPositionallyEncodedOperands = 1;
Tom Stellard75aadc22012-12-11 21:25:42 +0000307}
308
Tom Stellard9d7ddd52014-11-14 14:08:00 +0000309def AMDGPUAsmParser : AsmParser {
310 // Some of the R600 registers have the same name, so this crashes.
311 // For example T0_XYZW and T0_XY both have the asm name T0.
312 let ShouldEmitMatchRegisterName = 0;
313}
314
Tom Stellard75aadc22012-12-11 21:25:42 +0000315def AMDGPU : Target {
316 // Pull in Instruction Info:
317 let InstructionSet = AMDGPUInstrInfo;
Tom Stellard9d7ddd52014-11-14 14:08:00 +0000318 let AssemblyParsers = [AMDGPUAsmParser];
Tom Stellard75aadc22012-12-11 21:25:42 +0000319}
320
Tom Stellardbc5b5372014-06-13 16:38:59 +0000321// Dummy Instruction itineraries for pseudo instructions
322def ALU_NULL : FuncUnit;
323def NullALU : InstrItinClass;
324
Tom Stellard0e70de52014-05-16 20:56:45 +0000325//===----------------------------------------------------------------------===//
326// Predicate helper class
327//===----------------------------------------------------------------------===//
328
Tom Stellardd1f0f022015-04-23 19:33:54 +0000329def TruePredicate : Predicate<"true">;
Matt Arsenault382d9452016-01-26 04:49:22 +0000330
Tom Stellardd1f0f022015-04-23 19:33:54 +0000331def isSICI : Predicate<
332 "Subtarget->getGeneration() == AMDGPUSubtarget::SOUTHERN_ISLANDS ||"
333 "Subtarget->getGeneration() == AMDGPUSubtarget::SEA_ISLANDS"
334>, AssemblerPredicate<"FeatureGCN1Encoding">;
335
Tom Stellard5ebdfbe2015-12-24 03:18:18 +0000336def isVI : Predicate <
337 "Subtarget->getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS">,
338 AssemblerPredicate<"FeatureGCN3Encoding">;
339
Matt Arsenault382d9452016-01-26 04:49:22 +0000340def isCIVI : Predicate <
341 "Subtarget->getGeneration() == AMDGPUSubtarget::SEA_ISLANDS || "
342 "Subtarget->getGeneration() == AMDGPUSubtarget::VOLCANIC_ISLANDS"
343>, AssemblerPredicate<"FeatureCIInsts">;
344
345def HasFlatAddressSpace : Predicate<"Subtarget->hasFlatAddressSpace()">;
346
Tom Stellard0e70de52014-05-16 20:56:45 +0000347class PredicateControl {
348 Predicate SubtargetPredicate;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000349 Predicate SIAssemblerPredicate = isSICI;
Tom Stellard5ebdfbe2015-12-24 03:18:18 +0000350 Predicate VIAssemblerPredicate = isVI;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000351 list<Predicate> AssemblerPredicates = [];
Tom Stellardd1f0f022015-04-23 19:33:54 +0000352 Predicate AssemblerPredicate = TruePredicate;
Tom Stellard0e70de52014-05-16 20:56:45 +0000353 list<Predicate> OtherPredicates = [];
Tom Stellardd1f0f022015-04-23 19:33:54 +0000354 list<Predicate> Predicates = !listconcat([SubtargetPredicate, AssemblerPredicate],
Tom Stellardd7e6f132015-04-08 01:09:26 +0000355 AssemblerPredicates,
Tom Stellard0e70de52014-05-16 20:56:45 +0000356 OtherPredicates);
357}
358
Tom Stellard75aadc22012-12-11 21:25:42 +0000359// Include AMDGPU TD files
360include "R600Schedule.td"
361include "SISchedule.td"
362include "Processors.td"
363include "AMDGPUInstrInfo.td"
364include "AMDGPUIntrinsics.td"
365include "AMDGPURegisterInfo.td"
366include "AMDGPUInstructions.td"
Christian Konig2c8f6d52013-03-07 09:03:52 +0000367include "AMDGPUCallingConv.td"