2e7e39a54d3385f9ca9430345e0221037d8169dd
[oota-llvm.git] / lib / Target / AMDGPU / AMDGPU.td
1 //===-- AMDGPU.td - AMDGPU Tablegen files ------------------*- tablegen -*-===//
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 include "llvm/Target/Target.td"
11
12 //===----------------------------------------------------------------------===//
13 // Subtarget Features
14 //===----------------------------------------------------------------------===//
15
16 // Debugging Features
17
18 def FeatureDumpCode : SubtargetFeature <"DumpCode",
19         "DumpCode",
20         "true",
21         "Dump MachineInstrs in the CodeEmitter">;
22
23 def FeatureDumpCodeLower : SubtargetFeature <"dumpcode",
24         "DumpCode",
25         "true",
26         "Dump MachineInstrs in the CodeEmitter">;
27
28 def FeatureIRStructurizer : SubtargetFeature <"disable-irstructurizer",
29         "EnableIRStructurizer",
30         "false",
31         "Disable IR Structurizer">;
32
33 def FeaturePromoteAlloca : SubtargetFeature <"promote-alloca",
34         "EnablePromoteAlloca",
35         "true",
36         "Enable promote alloca pass">;
37
38 // Target features
39
40 def FeatureIfCvt : SubtargetFeature <"disable-ifcvt",
41         "EnableIfCvt",
42         "false",
43         "Disable the if conversion pass">;
44
45 def FeatureFP64 : SubtargetFeature<"fp64",
46         "FP64",
47         "true",
48         "Enable double precision operations">;
49
50 def FeatureFP64Denormals : SubtargetFeature<"fp64-denormals",
51         "FP64Denormals",
52         "true",
53         "Enable double precision denormal handling",
54         [FeatureFP64]>;
55
56 def FeatureFastFMAF32 : SubtargetFeature<"fast-fmaf",
57         "FastFMAF32",
58         "true",
59         "Assuming f32 fma is at least as fast as mul + add",
60         []>;
61
62 // Some instructions do not support denormals despite this flag. Using
63 // fp32 denormals also causes instructions to run at the double
64 // precision rate for the device.
65 def FeatureFP32Denormals : SubtargetFeature<"fp32-denormals",
66         "FP32Denormals",
67         "true",
68         "Enable single precision denormal handling">;
69
70 def Feature64BitPtr : SubtargetFeature<"64BitPtr",
71         "Is64bit",
72         "true",
73         "Specify if 64-bit addressing should be used">;
74
75 def FeatureR600ALUInst : SubtargetFeature<"R600ALUInst",
76         "R600ALUInst",
77         "false",
78         "Older version of ALU instructions encoding">;
79
80 def FeatureVertexCache : SubtargetFeature<"HasVertexCache",
81         "HasVertexCache",
82         "true",
83         "Specify use of dedicated vertex cache">;
84
85 def FeatureCaymanISA : SubtargetFeature<"caymanISA",
86         "CaymanISA",
87         "true",
88         "Use Cayman ISA">;
89
90 def FeatureCFALUBug : SubtargetFeature<"cfalubug",
91         "CFALUBug",
92         "true",
93         "GPU has CF_ALU bug">;
94
95 // XXX - This should probably be removed once enabled by default
96 def FeatureEnableLoadStoreOpt : SubtargetFeature <"load-store-opt",
97         "EnableLoadStoreOpt",
98         "true",
99         "Enable SI load/store optimizer pass">;
100
101 def FeatureFlatAddressSpace : SubtargetFeature<"flat-address-space",
102         "FlatAddressSpace",
103         "true",
104         "Support flat address space">;
105
106 def FeatureVGPRSpilling : SubtargetFeature<"vgpr-spilling",
107         "EnableVGPRSpilling",
108         "true",
109         "Enable spilling of VGPRs to scratch memory">;
110
111 def FeatureSGPRInitBug : SubtargetFeature<"sgpr-init-bug",
112         "SGPRInitBug",
113         "true",
114         "VI SGPR initilization bug requiring a fixed SGPR allocation size">;
115
116 class SubtargetFeatureFetchLimit <string Value> :
117                           SubtargetFeature <"fetch"#Value,
118         "TexVTXClauseSize",
119         Value,
120         "Limit the maximum number of fetches in a clause to "#Value>;
121
122 def FeatureFetchLimit8 : SubtargetFeatureFetchLimit <"8">;
123 def FeatureFetchLimit16 : SubtargetFeatureFetchLimit <"16">;
124
125 class SubtargetFeatureWavefrontSize <int Value> : SubtargetFeature<
126         "wavefrontsize"#Value,
127         "WavefrontSize",
128         !cast<string>(Value),
129         "The number of threads per wavefront">;
130
131 def FeatureWavefrontSize16 : SubtargetFeatureWavefrontSize<16>;
132 def FeatureWavefrontSize32 : SubtargetFeatureWavefrontSize<32>;
133 def FeatureWavefrontSize64 : SubtargetFeatureWavefrontSize<64>;
134
135 class SubtargetFeatureLDSBankCount <int Value> : SubtargetFeature <
136       "ldsbankcount"#Value,
137       "LDSBankCount",
138       !cast<string>(Value),
139       "The number of LDS banks per compute unit.">;
140
141 def FeatureLDSBankCount16 : SubtargetFeatureLDSBankCount<16>;
142 def FeatureLDSBankCount32 : SubtargetFeatureLDSBankCount<32>;
143
144 class SubtargetFeatureLocalMemorySize <int Value> : SubtargetFeature<
145         "localmemorysize"#Value,
146         "LocalMemorySize",
147         !cast<string>(Value),
148         "The size of local memory in bytes">;
149
150 def FeatureGCN : SubtargetFeature<"gcn",
151         "IsGCN",
152         "true",
153         "GCN or newer GPU">;
154
155 def FeatureGCN1Encoding : SubtargetFeature<"gcn1-encoding",
156         "GCN1Encoding",
157         "true",
158         "Encoding format for SI and CI">;
159
160 def FeatureGCN3Encoding : SubtargetFeature<"gcn3-encoding",
161         "GCN3Encoding",
162         "true",
163         "Encoding format for VI">;
164
165 def FeatureCIInsts : SubtargetFeature<"ci-insts",
166         "CIInsts",
167         "true",
168         "Additional intstructions for CI+">;
169
170 // Dummy feature used to disable assembler instructions.
171 def FeatureDisable : SubtargetFeature<"",
172                                       "FeatureDisable","true",
173                                       "Dummy feature to disable assembler"
174                                       " instructions">;
175
176 class SubtargetFeatureGeneration <string Value,
177                                   list<SubtargetFeature> Implies> :
178         SubtargetFeature <Value, "Gen", "AMDGPUSubtarget::"#Value,
179                           Value#" GPU generation", Implies>;
180
181 def FeatureLocalMemorySize0 : SubtargetFeatureLocalMemorySize<0>;
182 def FeatureLocalMemorySize32768 : SubtargetFeatureLocalMemorySize<32768>;
183 def FeatureLocalMemorySize65536 : SubtargetFeatureLocalMemorySize<65536>;
184
185 def FeatureR600 : SubtargetFeatureGeneration<"R600",
186         [FeatureR600ALUInst, FeatureFetchLimit8, FeatureLocalMemorySize0]>;
187
188 def FeatureR700 : SubtargetFeatureGeneration<"R700",
189         [FeatureFetchLimit16, FeatureLocalMemorySize0]>;
190
191 def FeatureEvergreen : SubtargetFeatureGeneration<"EVERGREEN",
192         [FeatureFetchLimit16, FeatureLocalMemorySize32768]>;
193
194 def FeatureNorthernIslands : SubtargetFeatureGeneration<"NORTHERN_ISLANDS",
195         [FeatureFetchLimit16, FeatureWavefrontSize64,
196          FeatureLocalMemorySize32768]
197 >;
198
199 def FeatureSouthernIslands : SubtargetFeatureGeneration<"SOUTHERN_ISLANDS",
200         [Feature64BitPtr, FeatureFP64, FeatureLocalMemorySize32768,
201          FeatureWavefrontSize64, FeatureGCN, FeatureGCN1Encoding,
202          FeatureLDSBankCount32]>;
203
204 def FeatureSeaIslands : SubtargetFeatureGeneration<"SEA_ISLANDS",
205         [Feature64BitPtr, FeatureFP64, FeatureLocalMemorySize65536,
206          FeatureWavefrontSize64, FeatureGCN, FeatureFlatAddressSpace,
207          FeatureGCN1Encoding, FeatureCIInsts]>;
208
209 def FeatureVolcanicIslands : SubtargetFeatureGeneration<"VOLCANIC_ISLANDS",
210         [Feature64BitPtr, FeatureFP64, FeatureLocalMemorySize65536,
211          FeatureWavefrontSize64, FeatureFlatAddressSpace, FeatureGCN,
212          FeatureGCN3Encoding, FeatureCIInsts, FeatureLDSBankCount32]>;
213
214 //===----------------------------------------------------------------------===//
215
216 def AMDGPUInstrInfo : InstrInfo {
217   let guessInstructionProperties = 1;
218   let noNamedPositionallyEncodedOperands = 1;
219 }
220
221 def AMDGPUAsmParser : AsmParser {
222   // Some of the R600 registers have the same name, so this crashes.
223   // For example T0_XYZW and T0_XY both have the asm name T0.
224   let ShouldEmitMatchRegisterName = 0;
225 }
226
227 def AMDGPU : Target {
228   // Pull in Instruction Info:
229   let InstructionSet = AMDGPUInstrInfo;
230   let AssemblyParsers = [AMDGPUAsmParser];
231 }
232
233 // Dummy Instruction itineraries for pseudo instructions
234 def ALU_NULL : FuncUnit;
235 def NullALU : InstrItinClass;
236
237 //===----------------------------------------------------------------------===//
238 // Predicate helper class
239 //===----------------------------------------------------------------------===//
240
241 def TruePredicate : Predicate<"true">;
242 def isSICI : Predicate<
243   "Subtarget->getGeneration() == AMDGPUSubtarget::SOUTHERN_ISLANDS ||"
244   "Subtarget->getGeneration() == AMDGPUSubtarget::SEA_ISLANDS"
245 >, AssemblerPredicate<"FeatureGCN1Encoding">;
246
247 class PredicateControl {
248   Predicate SubtargetPredicate;
249   Predicate SIAssemblerPredicate = isSICI;
250   list<Predicate> AssemblerPredicates = [];
251   Predicate AssemblerPredicate = TruePredicate;
252   list<Predicate> OtherPredicates = [];
253   list<Predicate> Predicates = !listconcat([SubtargetPredicate, AssemblerPredicate],
254                                             AssemblerPredicates,
255                                             OtherPredicates);
256 }
257
258 // Include AMDGPU TD files
259 include "R600Schedule.td"
260 include "SISchedule.td"
261 include "Processors.td"
262 include "AMDGPUInstrInfo.td"
263 include "AMDGPUIntrinsics.td"
264 include "AMDGPURegisterInfo.td"
265 include "AMDGPUInstructions.td"
266 include "AMDGPUCallingConv.td"