blob: 5321fe148738d1386a344d264aaad2e75f82f54e [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 Arsenault24ee0782016-02-12 02:40:47 +0000178class FeatureMaxPrivateElementSize<int size> : SubtargetFeature<
179 "max-private-element-size-"#size,
180 "MaxPrivateElementSize",
181 !cast<string>(size),
182 "Maximum private access size may be "#size
183>;
184
185def FeatureMaxPrivateElementSize4 : FeatureMaxPrivateElementSize<4>;
186def FeatureMaxPrivateElementSize8 : FeatureMaxPrivateElementSize<8>;
187def FeatureMaxPrivateElementSize16 : FeatureMaxPrivateElementSize<16>;
188
189
Matt Arsenault382d9452016-01-26 04:49:22 +0000190def FeatureEnableHugeScratchBuffer : SubtargetFeature<
191 "huge-scratch-buffer",
192 "EnableHugeScratchBuffer",
193 "true",
194 "Enable scratch buffer sizes greater than 128 GB"
195>;
196
197def FeatureVGPRSpilling : SubtargetFeature<"vgpr-spilling",
198 "EnableVGPRSpilling",
199 "true",
200 "Enable spilling of VGPRs to scratch memory"
201>;
202
203def FeatureDumpCode : SubtargetFeature <"DumpCode",
204 "DumpCode",
205 "true",
206 "Dump MachineInstrs in the CodeEmitter"
207>;
208
209def FeatureDumpCodeLower : SubtargetFeature <"dumpcode",
210 "DumpCode",
211 "true",
212 "Dump MachineInstrs in the CodeEmitter"
213>;
214
215def FeatureIRStructurizer : SubtargetFeature <"disable-irstructurizer",
216 "EnableIRStructurizer",
217 "false",
218 "Disable IR Structurizer"
219>;
220
221def FeaturePromoteAlloca : SubtargetFeature <"promote-alloca",
222 "EnablePromoteAlloca",
223 "true",
224 "Enable promote alloca pass"
225>;
226
227// XXX - This should probably be removed once enabled by default
228def FeatureEnableLoadStoreOpt : SubtargetFeature <"load-store-opt",
229 "EnableLoadStoreOpt",
230 "true",
231 "Enable SI load/store optimizer pass"
232>;
233
234// Performance debugging feature. Allow using DS instruction immediate
235// offsets even if the base pointer can't be proven to be base. On SI,
236// base pointer values that won't give the same result as a 16-bit add
237// are not safe to fold, but this will override the conservative test
238// for the base pointer.
239def FeatureEnableUnsafeDSOffsetFolding : SubtargetFeature <
240 "unsafe-ds-offset-folding",
241 "EnableUnsafeDSOffsetFolding",
242 "true",
243 "Force using DS instruction immediate offsets on SI"
244>;
245
246def FeatureIfCvt : SubtargetFeature <"disable-ifcvt",
247 "EnableIfCvt",
248 "false",
249 "Disable the if conversion pass"
250>;
251
252def FeatureEnableSIScheduler : SubtargetFeature<"si-scheduler",
253 "EnableSIScheduler",
254 "true",
255 "Enable SI Machine Scheduler"
256>;
257
258def FeatureFlatForGlobal : SubtargetFeature<"flat-for-global",
259 "FlatForGlobal",
260 "true",
261 "Force to generate flat instruction for global"
262>;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000263
264// Dummy feature used to disable assembler instructions.
265def FeatureDisable : SubtargetFeature<"",
Matt Arsenault382d9452016-01-26 04:49:22 +0000266 "FeatureDisable","true",
267 "Dummy feature to disable assembler instructions"
268>;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000269
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000270class SubtargetFeatureGeneration <string Value,
271 list<SubtargetFeature> Implies> :
272 SubtargetFeature <Value, "Gen", "AMDGPUSubtarget::"#Value,
273 Value#" GPU generation", Implies>;
274
Tom Stellard880a80a2014-06-17 16:53:14 +0000275def FeatureLocalMemorySize0 : SubtargetFeatureLocalMemorySize<0>;
276def FeatureLocalMemorySize32768 : SubtargetFeatureLocalMemorySize<32768>;
277def FeatureLocalMemorySize65536 : SubtargetFeatureLocalMemorySize<65536>;
278
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000279def FeatureR600 : SubtargetFeatureGeneration<"R600",
Matt Arsenault382d9452016-01-26 04:49:22 +0000280 [FeatureR600ALUInst, FeatureFetchLimit8, FeatureLocalMemorySize0]
281>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000282
283def FeatureR700 : SubtargetFeatureGeneration<"R700",
Matt Arsenault382d9452016-01-26 04:49:22 +0000284 [FeatureFetchLimit16, FeatureLocalMemorySize0]
285>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000286
287def FeatureEvergreen : SubtargetFeatureGeneration<"EVERGREEN",
Matt Arsenault382d9452016-01-26 04:49:22 +0000288 [FeatureFetchLimit16, FeatureLocalMemorySize32768]
289>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000290
291def FeatureNorthernIslands : SubtargetFeatureGeneration<"NORTHERN_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000292 [FeatureFetchLimit16, FeatureWavefrontSize64,
293 FeatureLocalMemorySize32768]
Tom Stellard880a80a2014-06-17 16:53:14 +0000294>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000295
296def FeatureSouthernIslands : SubtargetFeatureGeneration<"SOUTHERN_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000297 [FeatureFP64, FeatureLocalMemorySize32768,
298 FeatureWavefrontSize64, FeatureGCN, FeatureGCN1Encoding,
299 FeatureLDSBankCount32]
300>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000301
Tom Stellard6e1ee472013-10-29 16:37:28 +0000302def FeatureSeaIslands : SubtargetFeatureGeneration<"SEA_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000303 [FeatureFP64, FeatureLocalMemorySize65536,
304 FeatureWavefrontSize64, FeatureGCN, FeatureFlatAddressSpace,
305 FeatureGCN1Encoding, FeatureCIInsts]
306>;
Marek Olsak5df00d62014-12-07 12:18:57 +0000307
308def FeatureVolcanicIslands : SubtargetFeatureGeneration<"VOLCANIC_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000309 [FeatureFP64, FeatureLocalMemorySize65536,
310 FeatureWavefrontSize64, FeatureFlatAddressSpace, FeatureGCN,
Marek Olsake86f2522016-01-27 11:19:45 +0000311 FeatureGCN3Encoding, FeatureCIInsts]
Matt Arsenault382d9452016-01-26 04:49:22 +0000312>;
Marek Olsak5df00d62014-12-07 12:18:57 +0000313
Tom Stellard3498e4f2013-06-07 20:28:55 +0000314//===----------------------------------------------------------------------===//
Tom Stellard75aadc22012-12-11 21:25:42 +0000315
316def AMDGPUInstrInfo : InstrInfo {
317 let guessInstructionProperties = 1;
Matt Arsenault1ecac062015-02-18 02:15:32 +0000318 let noNamedPositionallyEncodedOperands = 1;
Tom Stellard75aadc22012-12-11 21:25:42 +0000319}
320
Tom Stellard9d7ddd52014-11-14 14:08:00 +0000321def AMDGPUAsmParser : AsmParser {
322 // Some of the R600 registers have the same name, so this crashes.
323 // For example T0_XYZW and T0_XY both have the asm name T0.
324 let ShouldEmitMatchRegisterName = 0;
325}
326
Tom Stellard75aadc22012-12-11 21:25:42 +0000327def AMDGPU : Target {
328 // Pull in Instruction Info:
329 let InstructionSet = AMDGPUInstrInfo;
Tom Stellard9d7ddd52014-11-14 14:08:00 +0000330 let AssemblyParsers = [AMDGPUAsmParser];
Tom Stellard75aadc22012-12-11 21:25:42 +0000331}
332
Tom Stellardbc5b5372014-06-13 16:38:59 +0000333// Dummy Instruction itineraries for pseudo instructions
334def ALU_NULL : FuncUnit;
335def NullALU : InstrItinClass;
336
Tom Stellard0e70de52014-05-16 20:56:45 +0000337//===----------------------------------------------------------------------===//
338// Predicate helper class
339//===----------------------------------------------------------------------===//
340
Tom Stellardd1f0f022015-04-23 19:33:54 +0000341def TruePredicate : Predicate<"true">;
Matt Arsenault382d9452016-01-26 04:49:22 +0000342
Tom Stellardd1f0f022015-04-23 19:33:54 +0000343def isSICI : Predicate<
344 "Subtarget->getGeneration() == AMDGPUSubtarget::SOUTHERN_ISLANDS ||"
345 "Subtarget->getGeneration() == AMDGPUSubtarget::SEA_ISLANDS"
346>, AssemblerPredicate<"FeatureGCN1Encoding">;
347
Tom Stellard5ebdfbe2015-12-24 03:18:18 +0000348def isVI : Predicate <
349 "Subtarget->getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS">,
350 AssemblerPredicate<"FeatureGCN3Encoding">;
351
Matt Arsenault382d9452016-01-26 04:49:22 +0000352def isCIVI : Predicate <
353 "Subtarget->getGeneration() == AMDGPUSubtarget::SEA_ISLANDS || "
354 "Subtarget->getGeneration() == AMDGPUSubtarget::VOLCANIC_ISLANDS"
355>, AssemblerPredicate<"FeatureCIInsts">;
356
357def HasFlatAddressSpace : Predicate<"Subtarget->hasFlatAddressSpace()">;
358
Tom Stellard0e70de52014-05-16 20:56:45 +0000359class PredicateControl {
360 Predicate SubtargetPredicate;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000361 Predicate SIAssemblerPredicate = isSICI;
Tom Stellard5ebdfbe2015-12-24 03:18:18 +0000362 Predicate VIAssemblerPredicate = isVI;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000363 list<Predicate> AssemblerPredicates = [];
Tom Stellardd1f0f022015-04-23 19:33:54 +0000364 Predicate AssemblerPredicate = TruePredicate;
Tom Stellard0e70de52014-05-16 20:56:45 +0000365 list<Predicate> OtherPredicates = [];
Tom Stellardd1f0f022015-04-23 19:33:54 +0000366 list<Predicate> Predicates = !listconcat([SubtargetPredicate, AssemblerPredicate],
Tom Stellardd7e6f132015-04-08 01:09:26 +0000367 AssemblerPredicates,
Tom Stellard0e70de52014-05-16 20:56:45 +0000368 OtherPredicates);
369}
370
Tom Stellard75aadc22012-12-11 21:25:42 +0000371// Include AMDGPU TD files
372include "R600Schedule.td"
373include "SISchedule.td"
374include "Processors.td"
375include "AMDGPUInstrInfo.td"
376include "AMDGPUIntrinsics.td"
377include "AMDGPURegisterInfo.td"
378include "AMDGPUInstructions.td"
Christian Konig2c8f6d52013-03-07 09:03:52 +0000379include "AMDGPUCallingConv.td"