1 //===---- AMDCallingConv.td - Calling Conventions for Radeon GPUs ---------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This describes the calling conventions for the AMD Radeon GPUs.
12 //===----------------------------------------------------------------------===//
14 // Inversion of CCIfInReg
15 class CCIfNotInReg<CCAction A> : CCIf<"!ArgFlags.isInReg()", A> {}
17 // Calling convention for SI
18 def CC_SI : CallingConv<[
20 CCIfInReg<CCIfType<[f32, i32, f16] , CCAssignToReg<[
21 SGPR0, SGPR1, SGPR2, SGPR3, SGPR4, SGPR5, SGPR6, SGPR7,
22 SGPR8, SGPR9, SGPR10, SGPR11, SGPR12, SGPR13, SGPR14, SGPR15,
23 SGPR16, SGPR17, SGPR18, SGPR19, SGPR20, SGPR21, SGPR22, SGPR23,
24 SGPR24, SGPR25, SGPR26, SGPR27, SGPR28, SGPR29, SGPR30, SGPR31,
25 SGPR32, SGPR33, SGPR34, SGPR35, SGPR36, SGPR37, SGPR38, SGPR39
28 // We have no way of referring to the generated register tuples
29 // here, so use a custom function.
30 CCIfInReg<CCIfType<[i64], CCCustom<"allocateSGPRTuple">>>,
31 CCIfByVal<CCIfType<[i64], CCCustom<"allocateSGPRTuple">>>,
33 // 32*4 + 4 is the minimum for a fetch shader consumer with 32 inputs.
34 CCIfNotInReg<CCIfType<[f32, i32, f16] , CCAssignToReg<[
35 VGPR0, VGPR1, VGPR2, VGPR3, VGPR4, VGPR5, VGPR6, VGPR7,
36 VGPR8, VGPR9, VGPR10, VGPR11, VGPR12, VGPR13, VGPR14, VGPR15,
37 VGPR16, VGPR17, VGPR18, VGPR19, VGPR20, VGPR21, VGPR22, VGPR23,
38 VGPR24, VGPR25, VGPR26, VGPR27, VGPR28, VGPR29, VGPR30, VGPR31,
39 VGPR32, VGPR33, VGPR34, VGPR35, VGPR36, VGPR37, VGPR38, VGPR39,
40 VGPR40, VGPR41, VGPR42, VGPR43, VGPR44, VGPR45, VGPR46, VGPR47,
41 VGPR48, VGPR49, VGPR50, VGPR51, VGPR52, VGPR53, VGPR54, VGPR55,
42 VGPR56, VGPR57, VGPR58, VGPR59, VGPR60, VGPR61, VGPR62, VGPR63,
43 VGPR64, VGPR65, VGPR66, VGPR67, VGPR68, VGPR69, VGPR70, VGPR71,
44 VGPR72, VGPR73, VGPR74, VGPR75, VGPR76, VGPR77, VGPR78, VGPR79,
45 VGPR80, VGPR81, VGPR82, VGPR83, VGPR84, VGPR85, VGPR86, VGPR87,
46 VGPR88, VGPR89, VGPR90, VGPR91, VGPR92, VGPR93, VGPR94, VGPR95,
47 VGPR96, VGPR97, VGPR98, VGPR99, VGPR100, VGPR101, VGPR102, VGPR103,
48 VGPR104, VGPR105, VGPR106, VGPR107, VGPR108, VGPR109, VGPR110, VGPR111,
49 VGPR112, VGPR113, VGPR114, VGPR115, VGPR116, VGPR117, VGPR118, VGPR119,
50 VGPR120, VGPR121, VGPR122, VGPR123, VGPR124, VGPR125, VGPR126, VGPR127,
51 VGPR128, VGPR129, VGPR130, VGPR131, VGPR132, VGPR133, VGPR134, VGPR135
55 def RetCC_SI : CallingConv<[
56 CCIfType<[i32] , CCAssignToReg<[
57 SGPR0, SGPR1, SGPR2, SGPR3, SGPR4, SGPR5, SGPR6, SGPR7,
58 SGPR8, SGPR9, SGPR10, SGPR11, SGPR12, SGPR13, SGPR14, SGPR15,
59 SGPR16, SGPR17, SGPR18, SGPR19, SGPR20, SGPR21, SGPR22, SGPR23,
60 SGPR24, SGPR25, SGPR26, SGPR27, SGPR28, SGPR29, SGPR30, SGPR31,
61 SGPR32, SGPR33, SGPR34, SGPR35, SGPR36, SGPR37, SGPR38, SGPR39
64 // 32*4 + 4 is the minimum for a fetch shader with 32 outputs.
65 CCIfType<[f32, f16] , CCAssignToReg<[
66 VGPR0, VGPR1, VGPR2, VGPR3, VGPR4, VGPR5, VGPR6, VGPR7,
67 VGPR8, VGPR9, VGPR10, VGPR11, VGPR12, VGPR13, VGPR14, VGPR15,
68 VGPR16, VGPR17, VGPR18, VGPR19, VGPR20, VGPR21, VGPR22, VGPR23,
69 VGPR24, VGPR25, VGPR26, VGPR27, VGPR28, VGPR29, VGPR30, VGPR31,
70 VGPR32, VGPR33, VGPR34, VGPR35, VGPR36, VGPR37, VGPR38, VGPR39,
71 VGPR40, VGPR41, VGPR42, VGPR43, VGPR44, VGPR45, VGPR46, VGPR47,
72 VGPR48, VGPR49, VGPR50, VGPR51, VGPR52, VGPR53, VGPR54, VGPR55,
73 VGPR56, VGPR57, VGPR58, VGPR59, VGPR60, VGPR61, VGPR62, VGPR63,
74 VGPR64, VGPR65, VGPR66, VGPR67, VGPR68, VGPR69, VGPR70, VGPR71,
75 VGPR72, VGPR73, VGPR74, VGPR75, VGPR76, VGPR77, VGPR78, VGPR79,
76 VGPR80, VGPR81, VGPR82, VGPR83, VGPR84, VGPR85, VGPR86, VGPR87,
77 VGPR88, VGPR89, VGPR90, VGPR91, VGPR92, VGPR93, VGPR94, VGPR95,
78 VGPR96, VGPR97, VGPR98, VGPR99, VGPR100, VGPR101, VGPR102, VGPR103,
79 VGPR104, VGPR105, VGPR106, VGPR107, VGPR108, VGPR109, VGPR110, VGPR111,
80 VGPR112, VGPR113, VGPR114, VGPR115, VGPR116, VGPR117, VGPR118, VGPR119,
81 VGPR120, VGPR121, VGPR122, VGPR123, VGPR124, VGPR125, VGPR126, VGPR127,
82 VGPR128, VGPR129, VGPR130, VGPR131, VGPR132, VGPR133, VGPR134, VGPR135
86 // Calling convention for R600
87 def CC_R600 : CallingConv<[
88 CCIfInReg<CCIfType<[v4f32, v4i32] , CCAssignToReg<[
89 T0_XYZW, T1_XYZW, T2_XYZW, T3_XYZW, T4_XYZW, T5_XYZW, T6_XYZW, T7_XYZW,
90 T8_XYZW, T9_XYZW, T10_XYZW, T11_XYZW, T12_XYZW, T13_XYZW, T14_XYZW, T15_XYZW,
91 T16_XYZW, T17_XYZW, T18_XYZW, T19_XYZW, T20_XYZW, T21_XYZW, T22_XYZW,
92 T23_XYZW, T24_XYZW, T25_XYZW, T26_XYZW, T27_XYZW, T28_XYZW, T29_XYZW,
93 T30_XYZW, T31_XYZW, T32_XYZW
97 // Calling convention for compute kernels
98 def CC_AMDGPU_Kernel : CallingConv<[
99 CCCustom<"allocateKernArg">
102 def CC_AMDGPU : CallingConv<[
103 CCIf<"static_cast<const AMDGPUSubtarget&>"
104 "(State.getMachineFunction().getSubtarget()).getGeneration() >="
105 "AMDGPUSubtarget::SOUTHERN_ISLANDS && "
106 "!AMDGPU::isShader(State.getCallingConv())",
107 CCDelegateTo<CC_AMDGPU_Kernel>>,
108 CCIf<"static_cast<const AMDGPUSubtarget&>"
109 "(State.getMachineFunction().getSubtarget()).getGeneration() < "
110 "AMDGPUSubtarget::SOUTHERN_ISLANDS && "
111 "!AMDGPU::isShader(State.getCallingConv())",
112 CCDelegateTo<CC_AMDGPU_Kernel>>,
113 CCIf<"static_cast<const AMDGPUSubtarget&>"
114 "(State.getMachineFunction().getSubtarget()).getGeneration() >= "
115 "AMDGPUSubtarget::SOUTHERN_ISLANDS",
116 CCDelegateTo<CC_SI>>,
117 CCIf<"static_cast<const AMDGPUSubtarget&>"
118 "(State.getMachineFunction().getSubtarget()).getGeneration() < "
119 "AMDGPUSubtarget::SOUTHERN_ISLANDS",
120 CCDelegateTo<CC_R600>>