1; RUN: llc < %s -mtriple=ve-unknown-unknown | FileCheck %s
2
3declare i32 @sample_add(i32, i32)
4declare i32 @stack_callee_int(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32)
5declare i32 @stack_callee_int_szext(i1 signext, i8 zeroext, i32, i32, i32, i32, i32, i32, i16 zeroext, i8 signext)
6declare float @stack_callee_float(float, float, float, float, float, float, float, float, float, float)
7declare void @test(i64)
8
9define i32 @sample_call() {
10; CHECK-LABEL: sample_call:
11; CHECK:       .LBB{{[0-9]+}}_2:
12; CHECK-NEXT:    lea %s0, sample_add@lo
13; CHECK-NEXT:    and %s0, %s0, (32)0
14; CHECK-NEXT:    lea.sl %s12, sample_add@hi(, %s0)
15; CHECK-NEXT:    or %s0, 1, (0)1
16; CHECK-NEXT:    or %s1, 2, (0)1
17; CHECK-NEXT:    bsic %s10, (, %s12)
18; CHECK-NEXT:    or %s11, 0, %s9
19  %r = tail call i32 @sample_add(i32 1, i32 2)
20  ret i32 %r
21}
22
23define i32 @stack_call_int() {
24; CHECK-LABEL: stack_call_int:
25; CHECK:       .LBB{{[0-9]+}}_2:
26; CHECK-NEXT:    or %s0, 10, (0)1
27; CHECK-NEXT:    st %s0, 248(, %s11)
28; CHECK-NEXT:    or %s34, 9, (0)1
29; CHECK-NEXT:    lea %s0, stack_callee_int@lo
30; CHECK-NEXT:    and %s0, %s0, (32)0
31; CHECK-NEXT:    lea.sl %s12, stack_callee_int@hi(, %s0)
32; CHECK-NEXT:    or %s0, 1, (0)1
33; CHECK-NEXT:    or %s1, 2, (0)1
34; CHECK-NEXT:    or %s2, 3, (0)1
35; CHECK-NEXT:    or %s3, 4, (0)1
36; CHECK-NEXT:    or %s4, 5, (0)1
37; CHECK-NEXT:    or %s5, 6, (0)1
38; CHECK-NEXT:    or %s6, 7, (0)1
39; CHECK-NEXT:    or %s7, 8, (0)1
40; CHECK-NEXT:    st %s34, 240(, %s11)
41; CHECK-NEXT:    bsic %s10, (, %s12)
42; CHECK-NEXT:    or %s11, 0, %s9
43  %r = tail call i32 @stack_callee_int(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10)
44  ret i32 %r
45}
46
47define i32 @stack_call_int_szext() {
48; CHECK-LABEL: stack_call_int_szext:
49; CHECK:       .LBB{{[0-9]+}}_2:
50; CHECK-NEXT:    or %s0, -1, (0)1
51; CHECK-NEXT:    st %s0, 248(, %s11)
52; CHECK-NEXT:    lea %s34, 65535
53; CHECK-NEXT:    lea %s0, stack_callee_int_szext@lo
54; CHECK-NEXT:    and %s0, %s0, (32)0
55; CHECK-NEXT:    lea.sl %s12, stack_callee_int_szext@hi(, %s0)
56; CHECK-NEXT:    or %s0, -1, (0)1
57; CHECK-NEXT:    lea %s1, 255
58; CHECK-NEXT:    or %s2, 3, (0)1
59; CHECK-NEXT:    or %s3, 4, (0)1
60; CHECK-NEXT:    or %s4, 5, (0)1
61; CHECK-NEXT:    or %s5, 6, (0)1
62; CHECK-NEXT:    or %s6, 7, (0)1
63; CHECK-NEXT:    or %s7, 8, (0)1
64; CHECK-NEXT:    st %s34, 240(, %s11)
65; CHECK-NEXT:    bsic %s10, (, %s12)
66; CHECK-NEXT:    or %s11, 0, %s9
67  %r = tail call i32 @stack_callee_int_szext(i1 -1, i8 -1, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i16 -1, i8 -1)
68  ret i32 %r
69}
70
71define float @stack_call_float() {
72; CHECK-LABEL: stack_call_float:
73; CHECK:       .LBB{{[0-9]+}}_2:
74; CHECK-NEXT:    lea.sl %s0, 1092616192
75; CHECK-NEXT:    st %s0, 248(, %s11)
76; CHECK-NEXT:    lea.sl %s34, 1091567616
77; CHECK-NEXT:    lea %s0, stack_callee_float@lo
78; CHECK-NEXT:    and %s0, %s0, (32)0
79; CHECK-NEXT:    lea.sl %s12, stack_callee_float@hi(, %s0)
80; CHECK-NEXT:    lea.sl %s0, 1065353216
81; CHECK-NEXT:    lea.sl %s1, 1073741824
82; CHECK-NEXT:    lea.sl %s2, 1077936128
83; CHECK-NEXT:    lea.sl %s3, 1082130432
84; CHECK-NEXT:    lea.sl %s4, 1084227584
85; CHECK-NEXT:    lea.sl %s5, 1086324736
86; CHECK-NEXT:    lea.sl %s6, 1088421888
87; CHECK-NEXT:    lea.sl %s7, 1090519040
88; CHECK-NEXT:    st %s34, 240(, %s11)
89; CHECK-NEXT:    bsic %s10, (, %s12)
90; CHECK-NEXT:    or %s11, 0, %s9
91  %r = tail call float @stack_callee_float(float 1.0, float 2.0, float 3.0, float 4.0, float 5.0, float 6.0, float 7.0, float 8.0, float 9.0, float 10.0)
92  ret float %r
93}
94
95define float @stack_call_float2(float %p0) {
96; CHECK-LABEL: stack_call_float2:
97; CHECK:       .LBB{{[0-9]+}}_2:
98; CHECK-NEXT:    st %s0, 248(, %s11)
99; CHECK-NEXT:    lea %s1, stack_callee_float@lo
100; CHECK-NEXT:    and %s1, %s1, (32)0
101; CHECK-NEXT:    lea.sl %s12, stack_callee_float@hi(, %s1)
102; CHECK-NEXT:    st %s0, 240(, %s11)
103; CHECK-NEXT:    or %s1, 0, %s0
104; CHECK-NEXT:    or %s2, 0, %s0
105; CHECK-NEXT:    or %s3, 0, %s0
106; CHECK-NEXT:    or %s4, 0, %s0
107; CHECK-NEXT:    or %s5, 0, %s0
108; CHECK-NEXT:    or %s6, 0, %s0
109; CHECK-NEXT:    or %s7, 0, %s0
110; CHECK-NEXT:    bsic %s10, (, %s12)
111; CHECK-NEXT:    or %s11, 0, %s9
112  %r = tail call float @stack_callee_float(float %p0, float %p0, float %p0, float %p0, float %p0, float %p0, float %p0, float %p0, float %p0, float %p0)
113  ret float %r
114}
115