3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 declare void @ok(i8 %r2, i16 %r3, i32 %r4, i64 %r5, float %f0, double %f2,
7 declare void @uses_r6(i8 %r2, i16 %r3, i32 %r4, i64 %r5, i64 %r6)
8 declare void @uses_indirect(fp128 %r2)
9 declare void @uses_stack(float %f0, float %f2, float %f4, float %f6,
11 declare i32 @returns_i32()
12 declare i64 @returns_i64()
14 ; Check the maximum number of arguments that we can pass and still use
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}}
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)
32 ; Check a call that uses %r6 to pass an argument. At the moment we don't
33 ; use sibling calls in that case.
36 ; CHECK: brasl %r14, uses_r6@PLT
38 tail call void @uses_r6(i8 1, i16 2, i32 3, i64 4, i64 5)
42 ; Check a call that passes indirect arguments. We can't use sibling
46 ; CHECK: brasl %r14, uses_indirect@PLT
48 tail call void @uses_indirect(fp128 0xL00000000000000000000000000000000)
52 ; Check a call that uses direct stack arguments, which again prevents
56 ; CHECK: brasl %r14, uses_stack@PLT
58 tail call void @uses_stack(float 0.0, float 0.0, float 0.0, float 0.0,
63 ; Check an indirect call. In this case the only acceptable choice for
64 ; the target register is %r1.
65 define void @f5(void(i32, i32, i32, i32) *%foo) {
68 ; CHECK-DAG: lhi %r2, 1
69 ; CHECK-DAG: lhi %r3, 2
70 ; CHECK-DAG: lhi %r4, 3
71 ; CHECK-DAG: lhi %r5, 4
73 tail call void %foo(i32 1, i32 2, i32 3, i32 4)
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).
79 define void @f6(void(i32) *%foo) {
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)
87 %arg = call i32 @returns_i32()
88 tail call void %foo(i32 %arg)
92 ; Test a function that returns a value.
95 ; CHECK: jg returns_i64@PLT
96 %res = tail call i64 @returns_i64()
100 ; Test a function that returns a value truncated from i64 to i32.
103 ; CHECK: jg returns_i64@PLT
104 %res = tail call i64 @returns_i64()
105 %trunc = trunc i64 %res to i32
109 ; Test a function that returns a value truncated from i64 to i7.
112 ; CHECK: jg returns_i64@PLT
113 %res = tail call i64 @returns_i64()
114 %trunc = trunc i64 %res to i7
118 ; Test a function that returns a value truncated from i32 to i8.
121 ; CHECK: jg returns_i32@PLT
122 %res = tail call i32 @returns_i32()
123 %trunc = trunc i32 %res to i8