Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 29df731

Browse files
committed
AMDGPU: Add f16 to shader calling conventions
Mostly useful for writing tests for f16 features. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296370 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 724703a commit 29df731

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

lib/Target/AMDGPU/AMDGPUCallingConv.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class CCIfNotInReg<CCAction A> : CCIf<"!ArgFlags.isInReg()", A> {}
1717
// Calling convention for SI
1818
def CC_SI : CallingConv<[
1919

20-
CCIfInReg<CCIfType<[f32, i32] , CCAssignToReg<[
20+
CCIfInReg<CCIfType<[f32, i32, f16] , CCAssignToReg<[
2121
SGPR0, SGPR1, SGPR2, SGPR3, SGPR4, SGPR5, SGPR6, SGPR7,
2222
SGPR8, SGPR9, SGPR10, SGPR11, SGPR12, SGPR13, SGPR14, SGPR15,
2323
SGPR16, SGPR17, SGPR18, SGPR19, SGPR20, SGPR21, SGPR22, SGPR23,
@@ -35,7 +35,7 @@ def CC_SI : CallingConv<[
3535
>>>,
3636

3737
// 32*4 + 4 is the minimum for a fetch shader consumer with 32 inputs.
38-
CCIfNotInReg<CCIfType<[f32, i32] , CCAssignToReg<[
38+
CCIfNotInReg<CCIfType<[f32, i32, f16] , CCAssignToReg<[
3939
VGPR0, VGPR1, VGPR2, VGPR3, VGPR4, VGPR5, VGPR6, VGPR7,
4040
VGPR8, VGPR9, VGPR10, VGPR11, VGPR12, VGPR13, VGPR14, VGPR15,
4141
VGPR16, VGPR17, VGPR18, VGPR19, VGPR20, VGPR21, VGPR22, VGPR23,
@@ -76,7 +76,7 @@ def RetCC_SI : CallingConv<[
7676
]>>,
7777

7878
// 32*4 + 4 is the minimum for a fetch shader with 32 outputs.
79-
CCIfType<[f32] , CCAssignToReg<[
79+
CCIfType<[f32, f16] , CCAssignToReg<[
8080
VGPR0, VGPR1, VGPR2, VGPR3, VGPR4, VGPR5, VGPR6, VGPR7,
8181
VGPR8, VGPR9, VGPR10, VGPR11, VGPR12, VGPR13, VGPR14, VGPR15,
8282
VGPR16, VGPR17, VGPR18, VGPR19, VGPR20, VGPR21, VGPR22, VGPR23,
Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,45 @@
1-
; RUN: llc < %s -march=amdgcn -mcpu=SI -verify-machineinstrs | FileCheck --check-prefix=SI %s
1+
; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=SI %s
2+
; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=VI %s
23

34
; Make sure we don't crash or assert on spir_kernel calling convention.
45

5-
; SI-LABEL: {{^}}kernel:
6-
; SI: s_endpgm
6+
; GCN-LABEL: {{^}}kernel:
7+
; GCN: s_endpgm
78
define spir_kernel void @kernel(i32 addrspace(1)* %out) {
89
entry:
910
store i32 0, i32 addrspace(1)* %out
1011
ret void
1112
}
1213

1314
; FIXME: This is treated like a kernel
14-
; SI-LABEL: {{^}}func:
15-
; SI: s_endpgm
15+
; GCN-LABEL: {{^}}func:
16+
; GCN: s_endpgm
1617
define spir_func void @func(i32 addrspace(1)* %out) {
1718
entry:
1819
store i32 0, i32 addrspace(1)* %out
1920
ret void
2021
}
22+
23+
; GCN-LABEL: {{^}}ps_ret_cc_f16:
24+
; SI: v_cvt_f16_f32_e32 v0, v0
25+
; SI: v_cvt_f32_f16_e32 v0, v0
26+
; SI: v_add_f32_e32 v0, 1.0, v0
27+
28+
; VI: v_add_f16_e32 v0, 1.0, v0
29+
; VI: ; return
30+
define amdgpu_ps half @ps_ret_cc_f16(half %arg0) {
31+
%add = fadd half %arg0, 1.0
32+
ret half %add
33+
}
34+
35+
; GCN-LABEL: {{^}}ps_ret_cc_inreg_f16:
36+
; SI: v_cvt_f16_f32_e32 v0, s0
37+
; SI: v_cvt_f32_f16_e32 v0, v0
38+
; SI: v_add_f32_e32 v0, 1.0, v0
39+
40+
; VI: v_add_f16_e64 v0, s0, 1.0
41+
; VI: ; return
42+
define amdgpu_ps half @ps_ret_cc_inreg_f16(half inreg %arg0) {
43+
%add = fadd half %arg0, 1.0
44+
ret half %add
45+
}

0 commit comments

Comments
 (0)