aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/CodeGen/AMDGPU/call-c-function.ll
blob: 4fbc7271ba0c5f4c4dc54783a5499cd570600666 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
; RUN: llc -global-isel=0 -stop-after=finalize-isel -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx900 -o - %s | FileCheck -check-prefix=SDAG -enable-var-scope %s
; RUN: llc -global-isel=1 -stop-after=finalize-isel -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx900 -o - %s | FileCheck -check-prefix=GISEL -enable-var-scope %s

; Test that we don't explode on calls from shaders to functions with the C calling convention.

define amdgpu_ps void @amdgpu_ps_call_default_cc() {
  ; SDAG-LABEL: name: amdgpu_ps_call_default_cc
  ; SDAG: bb.0.main_body:
  ; SDAG-NEXT:   S_ENDPGM 0
  ;
  ; GISEL-LABEL: name: amdgpu_ps_call_default_cc
  ; GISEL: bb.1.main_body:
  ; GISEL-NEXT:   ADJCALLSTACKUP 0, 0, implicit-def $scc, implicit-def $sgpr32, implicit $sgpr32
  ; GISEL-NEXT:   [[DEF:%[0-9]+]]:sreg_64 = IMPLICIT_DEF
  ; GISEL-NEXT:   [[DEF1:%[0-9]+]]:sreg_64 = IMPLICIT_DEF
  ; GISEL-NEXT:   [[DEF2:%[0-9]+]]:sreg_32 = IMPLICIT_DEF
  ; GISEL-NEXT:   [[COPY:%[0-9]+]]:sgpr_128 = COPY $sgpr96_sgpr97_sgpr98_sgpr99
  ; GISEL-NEXT:   $sgpr0_sgpr1_sgpr2_sgpr3 = COPY [[COPY]]
  ; GISEL-NEXT:   $sgpr4_sgpr5 = COPY [[DEF]]
  ; GISEL-NEXT:   $sgpr6_sgpr7 = COPY [[DEF]]
  ; GISEL-NEXT:   [[S_MOV_B:%[0-9]+]]:sreg_64 = S_MOV_B64_IMM_PSEUDO 0
  ; GISEL-NEXT:   $sgpr8_sgpr9 = COPY [[S_MOV_B]]
  ; GISEL-NEXT:   $sgpr10_sgpr11 = COPY [[DEF1]]
  ; GISEL-NEXT:   $sgpr12 = COPY [[DEF2]]
  ; GISEL-NEXT:   $sgpr13 = COPY [[DEF2]]
  ; GISEL-NEXT:   $sgpr14 = COPY [[DEF2]]
  ; GISEL-NEXT:   $sgpr15 = COPY [[DEF2]]
  ; GISEL-NEXT:   $vgpr31 = COPY [[DEF2]]
  ; GISEL-NEXT:   [[S_MOV_B1:%[0-9]+]]:sreg_64 = S_MOV_B64_IMM_PSEUDO 0
  ; GISEL-NEXT:   $sgpr30_sgpr31 = noconvergent SI_CALL [[S_MOV_B1]], 0, csr_amdgpu, implicit $sgpr0_sgpr1_sgpr2_sgpr3, implicit $sgpr4_sgpr5, implicit $sgpr6_sgpr7, implicit $sgpr8_sgpr9, implicit $sgpr10_sgpr11, implicit $sgpr12, implicit $sgpr13, implicit $sgpr14, implicit $sgpr15, implicit $vgpr31
  ; GISEL-NEXT:   ADJCALLSTACKDOWN 0, 0, implicit-def $scc, implicit-def $sgpr32, implicit $sgpr32
  ; GISEL-NEXT:   S_ENDPGM 0
main_body:
  call void null()
  ret void
}

define amdgpu_gfx void @amdgpu_gfx_call_default_cc() {
  ; SDAG-LABEL: name: amdgpu_gfx_call_default_cc
  ; SDAG: bb.0.main_body:
  ; SDAG-NEXT:   SI_RETURN
  ;
  ; GISEL-LABEL: name: amdgpu_gfx_call_default_cc
  ; GISEL: bb.1.main_body:
  ; GISEL-NEXT:   ADJCALLSTACKUP 0, 0, implicit-def $scc, implicit-def $sgpr32, implicit $sgpr32
  ; GISEL-NEXT:   [[DEF:%[0-9]+]]:sreg_64 = IMPLICIT_DEF
  ; GISEL-NEXT:   [[DEF1:%[0-9]+]]:sreg_64 = IMPLICIT_DEF
  ; GISEL-NEXT:   [[DEF2:%[0-9]+]]:sreg_32 = IMPLICIT_DEF
  ; GISEL-NEXT:   [[COPY:%[0-9]+]]:sgpr_128 = COPY $sgpr0_sgpr1_sgpr2_sgpr3
  ; GISEL-NEXT:   $sgpr0_sgpr1_sgpr2_sgpr3 = COPY [[COPY]]
  ; GISEL-NEXT:   $sgpr4_sgpr5 = COPY [[DEF]]
  ; GISEL-NEXT:   $sgpr6_sgpr7 = COPY [[DEF]]
  ; GISEL-NEXT:   [[S_MOV_B:%[0-9]+]]:sreg_64 = S_MOV_B64_IMM_PSEUDO 0
  ; GISEL-NEXT:   $sgpr8_sgpr9 = COPY [[S_MOV_B]]
  ; GISEL-NEXT:   $sgpr10_sgpr11 = COPY [[DEF1]]
  ; GISEL-NEXT:   $sgpr12 = COPY [[DEF2]]
  ; GISEL-NEXT:   $sgpr13 = COPY [[DEF2]]
  ; GISEL-NEXT:   $sgpr14 = COPY [[DEF2]]
  ; GISEL-NEXT:   $sgpr15 = COPY [[DEF2]]
  ; GISEL-NEXT:   $vgpr31 = COPY [[DEF2]]
  ; GISEL-NEXT:   [[S_MOV_B1:%[0-9]+]]:sreg_64 = S_MOV_B64_IMM_PSEUDO 0
  ; GISEL-NEXT:   $sgpr30_sgpr31 = noconvergent SI_CALL [[S_MOV_B1]], 0, csr_amdgpu, implicit $sgpr0_sgpr1_sgpr2_sgpr3, implicit $sgpr4_sgpr5, implicit $sgpr6_sgpr7, implicit $sgpr8_sgpr9, implicit $sgpr10_sgpr11, implicit $sgpr12, implicit $sgpr13, implicit $sgpr14, implicit $sgpr15, implicit $vgpr31
  ; GISEL-NEXT:   ADJCALLSTACKDOWN 0, 0, implicit-def $scc, implicit-def $sgpr32, implicit $sgpr32
  ; GISEL-NEXT:   SI_RETURN
main_body:
  call void null()
  ret void
}