• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test sibling calls.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5declare void @ok(i8 %r2, i16 %r3, i32 %r4, i64 %r5, float %f0, double %f2,
6                 float %f4, double %f6)
7declare void @uses_r6(i8 %r2, i16 %r3, i32 %r4, i64 %r5, i64 %r6)
8declare void @uses_indirect(fp128 %r2)
9declare void @uses_stack(float %f0, float %f2, float %f4, float %f6,
10                         float %stack)
11declare i32 @returns_i32()
12declare i64 @returns_i64()
13
14; Check the maximum number of arguments that we can pass and still use
15; a sibling call.
16define void @f1() {
17; CHECK-LABEL: f1:
18; CHECK-DAG: lzer %f0
19; CHECK-DAG: lzdr %f2
20; CHECK-DAG: lhi %r2, 1
21; CHECK-DAG: lhi %r3, 2
22; CHECK-DAG: lhi %r4, 3
23; CHECK-DAG: lghi %r5, 4
24; CHECK-DAG: {{ler %f4, %f0|lzer %f4}}
25; CHECK-DAG: {{ldr %f6, %f2|lzdr %f6}}
26; CHECK: jg ok@PLT
27  tail call void @ok(i8 1, i16 2, i32 3, i64 4, float 0.0, double 0.0,
28                     float 0.0, double 0.0)
29  ret void
30}
31
32; Check a call that uses %r6 to pass an argument.  At the moment we don't
33; use sibling calls in that case.
34define void @f2() {
35; CHECK-LABEL: f2:
36; CHECK: brasl %r14, uses_r6@PLT
37; CHECK: br %r14
38  tail call void @uses_r6(i8 1, i16 2, i32 3, i64 4, i64 5)
39  ret void
40}
41
42; Check a call that passes indirect arguments.  We can't use sibling
43; calls in that case.
44define void @f3() {
45; CHECK-LABEL: f3:
46; CHECK: brasl %r14, uses_indirect@PLT
47; CHECK: br %r14
48  tail call void @uses_indirect(fp128 0xL00000000000000000000000000000000)
49  ret void
50}
51
52; Check a call that uses direct stack arguments, which again prevents
53; sibling calls
54define void @f4() {
55; CHECK-LABEL: f4:
56; CHECK: brasl %r14, uses_stack@PLT
57; CHECK: br %r14
58  tail call void @uses_stack(float 0.0, float 0.0, float 0.0, float 0.0,
59                             float 0.0)
60  ret void
61}
62
63; Check an indirect call.  In this case the only acceptable choice for
64; the target register is %r1.
65define void @f5(void(i32, i32, i32, i32) *%foo) {
66; CHECK-LABEL: f5:
67; CHECK: lgr %r1, %r2
68; CHECK-DAG: lhi %r2, 1
69; CHECK-DAG: lhi %r3, 2
70; CHECK-DAG: lhi %r4, 3
71; CHECK-DAG: lhi %r5, 4
72; CHECK: br %r1
73  tail call void %foo(i32 1, i32 2, i32 3, i32 4)
74  ret void
75}
76
77; Check an indirect call that will be forced into a call-saved GPR
78; (which should be %r13, the highest GPR not used for anything else).
79define void @f6(void(i32) *%foo) {
80; CHECK-LABEL: f6:
81; CHECK: stmg %r13, %r15, 104(%r15)
82; CHECK: lgr %r13, %r2
83; CHECK: brasl %r14, returns_i32
84; CHECK: lgr %r1, %r13
85; CHECK: lmg %r13, %r15, 264(%r15)
86; CHECK: br %r1
87  %arg = call i32 @returns_i32()
88  tail call void %foo(i32 %arg)
89  ret void
90}
91
92; Test a function that returns a value.
93define i64 @f7() {
94; CHECK-LABEL: f7:
95; CHECK: jg returns_i64@PLT
96  %res = tail call i64 @returns_i64()
97  ret i64 %res
98}
99
100; Test a function that returns a value truncated from i64 to i32.
101define i32 @f8() {
102; CHECK-LABEL: f8:
103; CHECK: jg returns_i64@PLT
104  %res = tail call i64 @returns_i64()
105  %trunc = trunc i64 %res to i32
106  ret i32 %trunc
107}
108
109; Test a function that returns a value truncated from i64 to i7.
110define i7 @f9() {
111; CHECK-LABEL: f9:
112; CHECK: jg returns_i64@PLT
113  %res = tail call i64 @returns_i64()
114  %trunc = trunc i64 %res to i7
115  ret i7 %trunc
116}
117
118; Test a function that returns a value truncated from i32 to i8.
119define i8 @f10() {
120; CHECK-LABEL: f10:
121; CHECK: jg returns_i32@PLT
122  %res = tail call i32 @returns_i32()
123  %trunc = trunc i32 %res to i8
124  ret i8 %trunc
125}
126