]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/AMDGPU/SIRegisterInfo.td
Merge llvm trunk r321414 to contrib/llvm.
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / AMDGPU / SIRegisterInfo.td
1 //===-- SIRegisterInfo.td - SI Register defs ---------------*- 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 //===----------------------------------------------------------------------===//
11 //  Helpers
12 //===----------------------------------------------------------------------===//
13
14 class getSubRegs<int size> {
15   list<SubRegIndex> ret2 = [sub0, sub1];
16   list<SubRegIndex> ret3 = [sub0, sub1, sub2];
17   list<SubRegIndex> ret4 = [sub0, sub1, sub2, sub3];
18   list<SubRegIndex> ret8 = [sub0, sub1, sub2, sub3, sub4, sub5, sub6, sub7];
19   list<SubRegIndex> ret16 = [sub0, sub1, sub2, sub3,
20                              sub4, sub5, sub6, sub7,
21                              sub8, sub9, sub10, sub11,
22                              sub12, sub13, sub14, sub15];
23
24   list<SubRegIndex> ret = !if(!eq(size, 2), ret2,
25                               !if(!eq(size, 3), ret3,
26                                   !if(!eq(size, 4), ret4,
27                                       !if(!eq(size, 8), ret8, ret16))));
28 }
29
30 //===----------------------------------------------------------------------===//
31 //  Declarations that describe the SI registers
32 //===----------------------------------------------------------------------===//
33 class SIReg <string n, bits<16> regIdx = 0> : Register<n>,
34   DwarfRegNum<[!cast<int>(HWEncoding)]> {
35   let Namespace = "AMDGPU";
36
37   // This is the not yet the complete register encoding. An additional
38   // bit is set for VGPRs.
39   let HWEncoding = regIdx;
40 }
41
42 // Special Registers
43 def VCC_LO : SIReg<"vcc_lo", 106>;
44 def VCC_HI : SIReg<"vcc_hi", 107>;
45
46 // Pseudo-registers: Used as placeholders during isel and immediately
47 // replaced, never seeing the verifier.
48 def PRIVATE_RSRC_REG : SIReg<"", 0>;
49 def FP_REG : SIReg<"", 0>;
50 def SP_REG : SIReg<"", 0>;
51 def SCRATCH_WAVE_OFFSET_REG : SIReg<"", 0>;
52
53 // VCC for 64-bit instructions
54 def VCC : RegisterWithSubRegs<"vcc", [VCC_LO, VCC_HI]>,
55           DwarfRegAlias<VCC_LO> {
56   let Namespace = "AMDGPU";
57   let SubRegIndices = [sub0, sub1];
58   let HWEncoding = 106;
59 }
60
61 def EXEC_LO : SIReg<"exec_lo", 126>;
62 def EXEC_HI : SIReg<"exec_hi", 127>;
63
64 def EXEC : RegisterWithSubRegs<"EXEC", [EXEC_LO, EXEC_HI]>,
65            DwarfRegAlias<EXEC_LO> {
66   let Namespace = "AMDGPU";
67   let SubRegIndices = [sub0, sub1];
68   let HWEncoding = 126;
69 }
70
71 def SCC : SIReg<"scc", 253>;
72 def M0 : SIReg <"m0", 124>;
73
74 def SRC_SHARED_BASE : SIReg<"src_shared_base", 235>;
75 def SRC_SHARED_LIMIT : SIReg<"src_shared_limit", 236>;
76 def SRC_PRIVATE_BASE : SIReg<"src_private_base", 237>;
77 def SRC_PRIVATE_LIMIT : SIReg<"src_private_limit", 238>;
78
79 // Trap handler registers
80 def TBA_LO : SIReg<"tba_lo", 108>;
81 def TBA_HI : SIReg<"tba_hi", 109>;
82
83 def TBA : RegisterWithSubRegs<"tba", [TBA_LO, TBA_HI]>,
84           DwarfRegAlias<TBA_LO> {
85   let Namespace = "AMDGPU";
86   let SubRegIndices = [sub0, sub1];
87   let HWEncoding = 108;
88 }
89
90 def TMA_LO : SIReg<"tma_lo", 110>;
91 def TMA_HI : SIReg<"tma_hi", 111>;
92
93 def TMA : RegisterWithSubRegs<"tma", [TMA_LO, TMA_HI]>,
94           DwarfRegAlias<TMA_LO> {
95   let Namespace = "AMDGPU";
96   let SubRegIndices = [sub0, sub1];
97   let HWEncoding = 110;
98 }
99
100 foreach Index = 0-15 in {
101   def TTMP#Index#_vi   : SIReg<"ttmp"#Index, !add(112, Index)>;
102   def TTMP#Index#_gfx9 : SIReg<"ttmp"#Index, !add(108, Index)>;
103   def TTMP#Index       : SIReg<"", 0>;
104 }
105
106 multiclass FLAT_SCR_LOHI_m <string n, bits<16> ci_e, bits<16> vi_e> {
107   def _ci : SIReg<n, ci_e>;
108   def _vi : SIReg<n, vi_e>;
109   def "" : SIReg<"", 0>;
110 }
111
112 class FlatReg <Register lo, Register hi, bits<16> encoding> :
113     RegisterWithSubRegs<"flat_scratch", [lo, hi]>,
114     DwarfRegAlias<lo> {
115   let Namespace = "AMDGPU";
116   let SubRegIndices = [sub0, sub1];
117   let HWEncoding = encoding;
118 }
119
120 defm FLAT_SCR_LO : FLAT_SCR_LOHI_m<"flat_scratch_lo", 104, 102>; // Offset in units of 256-bytes.
121 defm FLAT_SCR_HI : FLAT_SCR_LOHI_m<"flat_scratch_hi", 105, 103>; // Size is the per-thread scratch size, in bytes.
122
123 def FLAT_SCR_ci : FlatReg<FLAT_SCR_LO_ci, FLAT_SCR_HI_ci, 104>;
124 def FLAT_SCR_vi : FlatReg<FLAT_SCR_LO_vi, FLAT_SCR_HI_vi, 102>;
125 def FLAT_SCR : FlatReg<FLAT_SCR_LO, FLAT_SCR_HI, 0>;
126
127 // SGPR registers
128 foreach Index = 0-103 in {
129   def SGPR#Index : SIReg <"SGPR"#Index, Index>;
130 }
131
132 // VGPR registers
133 foreach Index = 0-255 in {
134   def VGPR#Index : SIReg <"VGPR"#Index, Index> {
135     let HWEncoding{8} = 1;
136   }
137 }
138
139 //===----------------------------------------------------------------------===//
140 //  Groupings using register classes and tuples
141 //===----------------------------------------------------------------------===//
142
143 def SCC_CLASS : RegisterClass<"AMDGPU", [i1], 1, (add SCC)> {
144   let CopyCost = -1;
145   let isAllocatable = 0;
146 }
147
148 def M0_CLASS : RegisterClass<"AMDGPU", [i32], 32, (add M0)> {
149   let CopyCost = 1;
150   let isAllocatable = 0;
151 }
152
153 // TODO: Do we need to set DwarfRegAlias on register tuples?
154
155 // SGPR 32-bit registers
156 def SGPR_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
157                             (add (sequence "SGPR%u", 0, 103))> {
158   // Give all SGPR classes higher priority than VGPR classes, because
159   // we want to spill SGPRs to VGPRs.
160   let AllocationPriority = 7;
161 }
162
163 // SGPR 64-bit registers
164 def SGPR_64Regs : RegisterTuples<getSubRegs<2>.ret,
165                              [(add (decimate SGPR_32, 2)),
166                               (add (decimate (shl SGPR_32, 1), 2))]>;
167
168 // SGPR 128-bit registers
169 def SGPR_128Regs : RegisterTuples<getSubRegs<4>.ret,
170                               [(add (decimate SGPR_32, 4)),
171                                (add (decimate (shl SGPR_32, 1), 4)),
172                                (add (decimate (shl SGPR_32, 2), 4)),
173                                (add (decimate (shl SGPR_32, 3), 4))]>;
174
175 // SGPR 256-bit registers
176 def SGPR_256Regs : RegisterTuples<getSubRegs<8>.ret,
177                               [(add (decimate SGPR_32, 4)),
178                                (add (decimate (shl SGPR_32, 1), 4)),
179                                (add (decimate (shl SGPR_32, 2), 4)),
180                                (add (decimate (shl SGPR_32, 3), 4)),
181                                (add (decimate (shl SGPR_32, 4), 4)),
182                                (add (decimate (shl SGPR_32, 5), 4)),
183                                (add (decimate (shl SGPR_32, 6), 4)),
184                                (add (decimate (shl SGPR_32, 7), 4))]>;
185
186 // SGPR 512-bit registers
187 def SGPR_512Regs : RegisterTuples<getSubRegs<16>.ret,
188                               [(add (decimate SGPR_32, 4)),
189                                (add (decimate (shl SGPR_32, 1), 4)),
190                                (add (decimate (shl SGPR_32, 2), 4)),
191                                (add (decimate (shl SGPR_32, 3), 4)),
192                                (add (decimate (shl SGPR_32, 4), 4)),
193                                (add (decimate (shl SGPR_32, 5), 4)),
194                                (add (decimate (shl SGPR_32, 6), 4)),
195                                (add (decimate (shl SGPR_32, 7), 4)),
196                                (add (decimate (shl SGPR_32, 8), 4)),
197                                (add (decimate (shl SGPR_32, 9), 4)),
198                                (add (decimate (shl SGPR_32, 10), 4)),
199                                (add (decimate (shl SGPR_32, 11), 4)),
200                                (add (decimate (shl SGPR_32, 12), 4)),
201                                (add (decimate (shl SGPR_32, 13), 4)),
202                                (add (decimate (shl SGPR_32, 14), 4)),
203                                (add (decimate (shl SGPR_32, 15), 4))]>;
204
205 // Trap handler TMP 32-bit registers
206 def TTMP_32 : RegisterClass<"AMDGPU", [i32, f32, v2i16, v2f16], 32,
207                             (add (sequence "TTMP%u", 0, 15))> {
208   let isAllocatable = 0;
209 }
210
211 // Trap handler TMP 64-bit registers
212 def TTMP_64Regs : RegisterTuples<getSubRegs<2>.ret,
213                              [(add (decimate TTMP_32, 2)),
214                               (add (decimate (shl TTMP_32, 1), 2))]>;
215
216 // Trap handler TMP 128-bit registers
217 def TTMP_128Regs : RegisterTuples<getSubRegs<4>.ret,
218                               [(add (decimate TTMP_32, 4)),
219                                (add (decimate (shl TTMP_32, 1), 4)),
220                                (add (decimate (shl TTMP_32, 2), 4)),
221                                (add (decimate (shl TTMP_32, 3), 4))]>;
222
223 def TTMP_256Regs : RegisterTuples<getSubRegs<8>.ret,
224                               [(add (decimate TTMP_32, 4)),
225                                (add (decimate (shl TTMP_32, 1), 4)),
226                                (add (decimate (shl TTMP_32, 2), 4)),
227                                (add (decimate (shl TTMP_32, 3), 4)),
228                                (add (decimate (shl TTMP_32, 4), 4)),
229                                (add (decimate (shl TTMP_32, 5), 4)),
230                                (add (decimate (shl TTMP_32, 6), 4)),
231                                (add (decimate (shl TTMP_32, 7), 4))]>;
232
233 def TTMP_512Regs : RegisterTuples<getSubRegs<16>.ret,
234                               [(add (decimate TTMP_32, 4)),
235                                (add (decimate (shl TTMP_32, 1), 4)),
236                                (add (decimate (shl TTMP_32, 2), 4)),
237                                (add (decimate (shl TTMP_32, 3), 4)),
238                                (add (decimate (shl TTMP_32, 4), 4)),
239                                (add (decimate (shl TTMP_32, 5), 4)),
240                                (add (decimate (shl TTMP_32, 6), 4)),
241                                (add (decimate (shl TTMP_32, 7), 4)),
242                                (add (decimate (shl TTMP_32, 8), 4)),
243                                (add (decimate (shl TTMP_32, 9), 4)),
244                                (add (decimate (shl TTMP_32, 10), 4)),
245                                (add (decimate (shl TTMP_32, 11), 4)),
246                                (add (decimate (shl TTMP_32, 12), 4)),
247                                (add (decimate (shl TTMP_32, 13), 4)),
248                                (add (decimate (shl TTMP_32, 14), 4)),
249                                (add (decimate (shl TTMP_32, 15), 4))]>;
250
251 class TmpRegTuplesBase<int index, int size,
252                        list<Register> subRegs,
253                        list<SubRegIndex> indices = getSubRegs<size>.ret,
254                        int index1 = !add(index, !add(size, -1)),
255                        string name = "ttmp["#index#":"#index1#"]"> :
256   RegisterWithSubRegs<name, subRegs> {
257   let HWEncoding = subRegs[0].HWEncoding;
258   let SubRegIndices = indices;
259 }
260
261 class TmpRegTuples<string tgt,
262                    int size,
263                    int index0,
264                    int index1 = !add(index0, 1),
265                    int index2 = !add(index0, !if(!eq(size, 2), 1, 2)),
266                    int index3 = !add(index0, !if(!eq(size, 2), 1, 3)),
267                    int index4 = !add(index0, !if(!eq(size, 8), 4, 1)),
268                    int index5 = !add(index0, !if(!eq(size, 8), 5, 1)),
269                    int index6 = !add(index0, !if(!eq(size, 8), 6, 1)),
270                    int index7 = !add(index0, !if(!eq(size, 8), 7, 1)),
271                    Register r0 = !cast<Register>("TTMP"#index0#tgt),
272                    Register r1 = !cast<Register>("TTMP"#index1#tgt),
273                    Register r2 = !cast<Register>("TTMP"#index2#tgt),
274                    Register r3 = !cast<Register>("TTMP"#index3#tgt),
275                    Register r4 = !cast<Register>("TTMP"#index4#tgt),
276                    Register r5 = !cast<Register>("TTMP"#index5#tgt),
277                    Register r6 = !cast<Register>("TTMP"#index6#tgt),
278                    Register r7 = !cast<Register>("TTMP"#index7#tgt)> :
279   TmpRegTuplesBase<index0, size,
280                    !if(!eq(size, 2), [r0, r1],
281                        !if(!eq(size, 4), [r0, r1, r2, r3],
282                                          [r0, r1, r2, r3, r4, r5, r6, r7])),
283                    getSubRegs<size>.ret>;
284
285 foreach Index = {0, 2, 4, 6, 8, 10, 12, 14} in {
286   def TTMP#Index#_TTMP#!add(Index,1)#_vi   : TmpRegTuples<"_vi",   2, Index>;
287   def TTMP#Index#_TTMP#!add(Index,1)#_gfx9 : TmpRegTuples<"_gfx9", 2, Index>;
288 }
289
290 foreach Index = {0, 4, 8, 12} in {
291   def TTMP#Index#_TTMP#!add(Index,1)#
292                  _TTMP#!add(Index,2)#
293                  _TTMP#!add(Index,3)#_vi : TmpRegTuples<"_vi",   4, Index>;
294   def TTMP#Index#_TTMP#!add(Index,1)#
295                  _TTMP#!add(Index,2)#
296                  _TTMP#!add(Index,3)#_gfx9 : TmpRegTuples<"_gfx9", 4, Index>;
297 }
298
299 foreach Index = {0, 4, 8} in {
300   def TTMP#Index#_TTMP#!add(Index,1)#
301                  _TTMP#!add(Index,2)#
302                  _TTMP#!add(Index,3)#
303                  _TTMP#!add(Index,4)#
304                  _TTMP#!add(Index,5)#
305                  _TTMP#!add(Index,6)#
306                  _TTMP#!add(Index,7)#_vi : TmpRegTuples<"_vi",   8, Index>;
307   def TTMP#Index#_TTMP#!add(Index,1)#
308                  _TTMP#!add(Index,2)#
309                  _TTMP#!add(Index,3)#
310                  _TTMP#!add(Index,4)#
311                  _TTMP#!add(Index,5)#
312                  _TTMP#!add(Index,6)#
313                  _TTMP#!add(Index,7)#_gfx9 : TmpRegTuples<"_gfx9", 8, Index>;
314 }
315
316 def TTMP0_TTMP1_TTMP2_TTMP3_TTMP4_TTMP5_TTMP6_TTMP7_TTMP8_TTMP9_TTMP10_TTMP11_TTMP12_TTMP13_TTMP14_TTMP15_vi :
317   TmpRegTuplesBase<0, 16,
318                    [TTMP0_vi, TTMP1_vi, TTMP2_vi, TTMP3_vi,
319                     TTMP4_vi, TTMP5_vi, TTMP6_vi, TTMP7_vi,
320                     TTMP8_vi, TTMP9_vi, TTMP10_vi, TTMP11_vi,
321                     TTMP12_vi, TTMP13_vi, TTMP14_vi, TTMP15_vi]>;
322
323 def TTMP0_TTMP1_TTMP2_TTMP3_TTMP4_TTMP5_TTMP6_TTMP7_TTMP8_TTMP9_TTMP10_TTMP11_TTMP12_TTMP13_TTMP14_TTMP15_gfx9 :
324   TmpRegTuplesBase<0, 16,
325                    [TTMP0_gfx9, TTMP1_gfx9, TTMP2_gfx9, TTMP3_gfx9,
326                     TTMP4_gfx9, TTMP5_gfx9, TTMP6_gfx9, TTMP7_gfx9,
327                     TTMP8_gfx9, TTMP9_gfx9, TTMP10_gfx9, TTMP11_gfx9,
328                     TTMP12_gfx9, TTMP13_gfx9, TTMP14_gfx9, TTMP15_gfx9]>;
329
330
331 // VGPR 32-bit registers
332 // i16/f16 only on VI+
333 def VGPR_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
334                             (add (sequence "VGPR%u", 0, 255))> {
335   let AllocationPriority = 1;
336   let Size = 32;
337 }
338
339 // VGPR 64-bit registers
340 def VGPR_64 : RegisterTuples<getSubRegs<2>.ret,
341                              [(add (trunc VGPR_32, 255)),
342                               (add (shl VGPR_32, 1))]>;
343
344 // VGPR 96-bit registers
345 def VGPR_96 : RegisterTuples<getSubRegs<3>.ret,
346                              [(add (trunc VGPR_32, 254)),
347                               (add (shl VGPR_32, 1)),
348                               (add (shl VGPR_32, 2))]>;
349
350 // VGPR 128-bit registers
351 def VGPR_128 : RegisterTuples<getSubRegs<4>.ret,
352                               [(add (trunc VGPR_32, 253)),
353                                (add (shl VGPR_32, 1)),
354                                (add (shl VGPR_32, 2)),
355                                (add (shl VGPR_32, 3))]>;
356
357 // VGPR 256-bit registers
358 def VGPR_256 : RegisterTuples<getSubRegs<8>.ret,
359                               [(add (trunc VGPR_32, 249)),
360                                (add (shl VGPR_32, 1)),
361                                (add (shl VGPR_32, 2)),
362                                (add (shl VGPR_32, 3)),
363                                (add (shl VGPR_32, 4)),
364                                (add (shl VGPR_32, 5)),
365                                (add (shl VGPR_32, 6)),
366                                (add (shl VGPR_32, 7))]>;
367
368 // VGPR 512-bit registers
369 def VGPR_512 : RegisterTuples<getSubRegs<16>.ret,
370                               [(add (trunc VGPR_32, 241)),
371                                (add (shl VGPR_32, 1)),
372                                (add (shl VGPR_32, 2)),
373                                (add (shl VGPR_32, 3)),
374                                (add (shl VGPR_32, 4)),
375                                (add (shl VGPR_32, 5)),
376                                (add (shl VGPR_32, 6)),
377                                (add (shl VGPR_32, 7)),
378                                (add (shl VGPR_32, 8)),
379                                (add (shl VGPR_32, 9)),
380                                (add (shl VGPR_32, 10)),
381                                (add (shl VGPR_32, 11)),
382                                (add (shl VGPR_32, 12)),
383                                (add (shl VGPR_32, 13)),
384                                (add (shl VGPR_32, 14)),
385                                (add (shl VGPR_32, 15))]>;
386
387 //===----------------------------------------------------------------------===//
388 //  Register classes used as source and destination
389 //===----------------------------------------------------------------------===//
390
391 def Pseudo_SReg_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
392   (add FP_REG, SP_REG, SCRATCH_WAVE_OFFSET_REG)> {
393   let isAllocatable = 0;
394   let CopyCost = -1;
395 }
396
397 def Pseudo_SReg_128 : RegisterClass<"AMDGPU", [v4i32, v2i64], 32,
398   (add PRIVATE_RSRC_REG)> {
399   let isAllocatable = 0;
400   let CopyCost = -1;
401 }
402
403 // Subset of SReg_32 without M0 for SMRD instructions and alike.
404 // See comments in SIInstructions.td for more info.
405 def SReg_32_XM0_XEXEC : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
406   (add SGPR_32, VCC_LO, VCC_HI, FLAT_SCR_LO, FLAT_SCR_HI,
407    TTMP_32, TMA_LO, TMA_HI, TBA_LO, TBA_HI, SRC_SHARED_BASE, SRC_SHARED_LIMIT,
408    SRC_PRIVATE_BASE, SRC_PRIVATE_LIMIT)> {
409   let AllocationPriority = 7;
410 }
411
412 def SReg_32_XEXEC_HI : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
413   (add SReg_32_XM0_XEXEC, EXEC_LO, M0_CLASS)> {
414   let AllocationPriority = 7;
415 }
416
417 def SReg_32_XM0 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
418   (add SReg_32_XM0_XEXEC, EXEC_LO, EXEC_HI)> {
419   let AllocationPriority = 7;
420 }
421
422 // Register class for all scalar registers (SGPRs + Special Registers)
423 def SReg_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
424   (add SReg_32_XM0, M0_CLASS, EXEC_LO, EXEC_HI, SReg_32_XEXEC_HI)> {
425   let AllocationPriority = 7;
426 }
427
428 def SGPR_64 : RegisterClass<"AMDGPU", [v2i32, i64, f64], 32, (add SGPR_64Regs)> {
429   let CopyCost = 1;
430   let AllocationPriority = 8;
431 }
432
433 def TTMP_64 : RegisterClass<"AMDGPU", [v2i32, i64, f64], 32, (add TTMP_64Regs)> {
434   let isAllocatable = 0;
435 }
436
437 def SReg_64_XEXEC : RegisterClass<"AMDGPU", [v2i32, i64, f64, i1], 32,
438   (add SGPR_64, VCC, FLAT_SCR, TTMP_64, TBA, TMA)> {
439   let CopyCost = 1;
440   let AllocationPriority = 8;
441 }
442
443 def SReg_64 : RegisterClass<"AMDGPU", [v2i32, i64, f64, i1], 32,
444   (add SReg_64_XEXEC, EXEC)> {
445   let CopyCost = 1;
446   let AllocationPriority = 8;
447 }
448
449 // Requires 2 s_mov_b64 to copy
450 let CopyCost = 2 in {
451
452 def SGPR_128 : RegisterClass<"AMDGPU", [v4i32, v16i8, v2i64], 32, (add SGPR_128Regs)> {
453   let AllocationPriority = 10;
454 }
455
456 def TTMP_128 : RegisterClass<"AMDGPU", [v4i32, v16i8, v2i64], 32, (add TTMP_128Regs)> {
457   let isAllocatable = 0;
458 }
459
460 def SReg_128 : RegisterClass<"AMDGPU", [v4i32, v16i8, v2i64], 32,
461   (add SGPR_128, TTMP_128)> {
462   let AllocationPriority = 10;
463 }
464
465 } // End CopyCost = 2
466
467 def SGPR_256 : RegisterClass<"AMDGPU", [v8i32, v8f32], 32, (add SGPR_256Regs)> {
468   let AllocationPriority = 11;
469 }
470
471 def TTMP_256 : RegisterClass<"AMDGPU", [v8i32, v8f32], 32, (add TTMP_256Regs)> {
472   let isAllocatable = 0;
473 }
474
475 def SReg_256 : RegisterClass<"AMDGPU", [v8i32, v8f32], 32,
476   (add SGPR_256, TTMP_256)> {
477   // Requires 4 s_mov_b64 to copy
478   let CopyCost = 4;
479   let AllocationPriority = 11;
480 }
481
482 def SGPR_512 : RegisterClass<"AMDGPU", [v16i32, v16f32], 32, (add SGPR_512Regs)> {
483   let AllocationPriority = 12;
484 }
485
486 def TTMP_512 : RegisterClass<"AMDGPU", [v16i32, v16f32], 32, (add TTMP_512Regs)> {
487   let isAllocatable = 0;
488 }
489
490 def SReg_512 : RegisterClass<"AMDGPU", [v16i32, v16f32], 32,
491   (add SGPR_512, TTMP_512)> {
492   // Requires 8 s_mov_b64 to copy
493   let CopyCost = 8;
494   let AllocationPriority = 12;
495 }
496
497 // Register class for all vector registers (VGPRs + Interploation Registers)
498 def VReg_64 : RegisterClass<"AMDGPU", [i64, f64, v2i32, v2f32], 32, (add VGPR_64)> {
499   let Size = 64;
500
501   // Requires 2 v_mov_b32 to copy
502   let CopyCost = 2;
503   let AllocationPriority = 2;
504 }
505
506 def VReg_96 : RegisterClass<"AMDGPU", [untyped], 32, (add VGPR_96)> {
507   let Size = 96;
508
509   // Requires 3 v_mov_b32 to copy
510   let CopyCost = 3;
511   let AllocationPriority = 3;
512 }
513
514 def VReg_128 : RegisterClass<"AMDGPU", [v4i32, v4f32, v2i64, v2f64], 32, (add VGPR_128)> {
515   let Size = 128;
516
517   // Requires 4 v_mov_b32 to copy
518   let CopyCost = 4;
519   let AllocationPriority = 4;
520 }
521
522 def VReg_256 : RegisterClass<"AMDGPU", [v8i32, v8f32], 32, (add VGPR_256)> {
523   let Size = 256;
524   let CopyCost = 8;
525   let AllocationPriority = 5;
526 }
527
528 def VReg_512 : RegisterClass<"AMDGPU", [v16i32, v16f32], 32, (add VGPR_512)> {
529   let Size = 512;
530   let CopyCost = 16;
531   let AllocationPriority = 6;
532 }
533
534 def VReg_1 : RegisterClass<"AMDGPU", [i1], 32, (add VGPR_32)> {
535   let Size = 32;
536 }
537
538 def VS_32 : RegisterClass<"AMDGPU", [i32, f32, i16, f16, v2i16, v2f16], 32,
539                           (add VGPR_32, SReg_32)> {
540   let isAllocatable = 0;
541 }
542
543 def VS_64 : RegisterClass<"AMDGPU", [i64, f64], 32, (add VReg_64, SReg_64)> {
544   let isAllocatable = 0;
545 }
546
547 //===----------------------------------------------------------------------===//
548 //  Register operands
549 //===----------------------------------------------------------------------===//
550
551 class RegImmMatcher<string name> : AsmOperandClass {
552   let Name = name;
553   let RenderMethod = "addRegOrImmOperands";
554 }
555
556 multiclass SIRegOperand <string rc, string MatchName, string opType> {
557   let OperandNamespace = "AMDGPU" in {
558     def _b16 : RegisterOperand<!cast<RegisterClass>(rc#"_32")> {
559       let OperandType = opType#"_INT16";
560       let ParserMatchClass = RegImmMatcher<MatchName#"B16">;
561       let DecoderMethod = "decodeOperand_VSrc16";
562     }
563
564     def _f16 : RegisterOperand<!cast<RegisterClass>(rc#"_32")> {
565       let OperandType = opType#"_FP16";
566       let ParserMatchClass = RegImmMatcher<MatchName#"F16">;
567       let DecoderMethod = "decodeOperand_VSrc16";
568     }
569
570     def _b32 : RegisterOperand<!cast<RegisterClass>(rc#"_32")> {
571       let OperandType = opType#"_INT32";
572       let ParserMatchClass = RegImmMatcher<MatchName#"B32">;
573     }
574
575     def _f32 : RegisterOperand<!cast<RegisterClass>(rc#"_32")> {
576       let OperandType = opType#"_FP32";
577       let ParserMatchClass = RegImmMatcher<MatchName#"F32">;
578     }
579
580     def _b64 : RegisterOperand<!cast<RegisterClass>(rc#"_64")> {
581       let OperandType = opType#"_INT64";
582       let ParserMatchClass = RegImmMatcher<MatchName#"B64">;
583     }
584
585     def _f64 : RegisterOperand<!cast<RegisterClass>(rc#"_64")> {
586       let OperandType = opType#"_FP64";
587       let ParserMatchClass = RegImmMatcher<MatchName#"F64">;
588     }
589
590     def _v2b16 : RegisterOperand<!cast<RegisterClass>(rc#"_32")> {
591       let OperandType = opType#"_V2INT16";
592       let ParserMatchClass = RegImmMatcher<MatchName#"V2B16">;
593       let DecoderMethod = "decodeOperand_VSrcV216";
594     }
595
596     def _v2f16 : RegisterOperand<!cast<RegisterClass>(rc#"_32")> {
597       let OperandType = opType#"_V2FP16";
598       let ParserMatchClass = RegImmMatcher<MatchName#"V2F16">;
599       let DecoderMethod = "decodeOperand_VSrcV216";
600     }
601   }
602 }
603
604 // FIXME: 64-bit sources can sometimes use 32-bit constants.
605 multiclass RegImmOperand <string rc, string MatchName>
606   : SIRegOperand<rc, MatchName, "OPERAND_REG_IMM">;
607
608 multiclass RegInlineOperand <string rc, string MatchName>
609   : SIRegOperand<rc, MatchName, "OPERAND_REG_INLINE_C">;
610
611 //===----------------------------------------------------------------------===//
612 //  SSrc_* Operands with an SGPR or a 32-bit immediate
613 //===----------------------------------------------------------------------===//
614
615 defm SSrc : RegImmOperand<"SReg", "SSrc">;
616
617 //===----------------------------------------------------------------------===//
618 //  SCSrc_* Operands with an SGPR or a inline constant
619 //===----------------------------------------------------------------------===//
620
621 defm SCSrc : RegInlineOperand<"SReg", "SCSrc"> ;
622
623 def SCSrc_i1 : RegisterOperand<SReg_64_XEXEC>;
624
625 //===----------------------------------------------------------------------===//
626 //  VSrc_* Operands with an SGPR, VGPR or a 32-bit immediate
627 //===----------------------------------------------------------------------===//
628
629 defm VSrc : RegImmOperand<"VS", "VSrc">;
630
631 def VSrc_128 : RegisterOperand<VReg_128> {
632   let DecoderMethod = "DecodeVS_128RegisterClass";
633 }
634
635 //===----------------------------------------------------------------------===//
636 //  VSrc_* Operands with an VGPR
637 //===----------------------------------------------------------------------===//
638
639 // This is for operands with the enum(9), VSrc encoding restriction,
640 // but only allows VGPRs.
641 def VRegSrc_32 : RegisterOperand<VGPR_32> {
642   //let ParserMatchClass = RegImmMatcher<"VRegSrc32">;
643   let DecoderMethod = "DecodeVS_32RegisterClass";
644 }
645
646 //===----------------------------------------------------------------------===//
647 //  VCSrc_* Operands with an SGPR, VGPR or an inline constant
648 //===----------------------------------------------------------------------===//
649
650 defm VCSrc : RegInlineOperand<"VS", "VCSrc">;