blob: b34417ebf69bf99a18b7002cbdabf38f3446fbe3 [file] [log] [blame]
NAKAMURA Takumi0ff86ac2012-11-16 16:07:37 +00001; RUN: llc < %s -tailcallopt -code-model=medium -stack-alignment=4 -mtriple=i686-linux-gnu -mcpu=pentium | FileCheck %s
Duncan Sandsd71b4e42012-11-16 12:36:39 +00002
3; Check the HiPE calling convention works (x86-32)
4
5define void @zap(i32 %a, i32 %b) nounwind {
6entry:
7 ; CHECK: movl 40(%esp), %eax
8 ; CHECK-NEXT: movl 44(%esp), %edx
9 ; CHECK-NEXT: movl $8, %ecx
10 ; CHECK-NEXT: calll addfour
11 %0 = call cc 11 {i32, i32, i32} @addfour(i32 undef, i32 undef, i32 %a, i32 %b, i32 8)
12 %res = extractvalue {i32, i32, i32} %0, 2
13
14 ; CHECK: movl %eax, 16(%esp)
15 ; CHECK-NEXT: movl $2, 12(%esp)
16 ; CHECK-NEXT: movl $1, 8(%esp)
17 ; CHECK: calll foo
18 tail call void @foo(i32 undef, i32 undef, i32 1, i32 2, i32 %res) nounwind
19 ret void
20}
21
22define cc 11 {i32, i32, i32} @addfour(i32 %hp, i32 %p, i32 %x, i32 %y, i32 %z) nounwind {
23entry:
24 ; CHECK: addl %edx, %eax
25 ; CHECK-NEXT: addl %ecx, %eax
26 %0 = add i32 %x, %y
27 %1 = add i32 %0, %z
28
29 ; CHECK: ret
30 %res = insertvalue {i32, i32, i32} undef, i32 %1, 2
31 ret {i32, i32, i32} %res
32}
33
34define cc 11 void @foo(i32 %hp, i32 %p, i32 %arg0, i32 %arg1, i32 %arg2) nounwind {
35entry:
36 ; CHECK: movl %esi, 16(%esp)
37 ; CHECK-NEXT: movl %ebp, 12(%esp)
38 ; CHECK-NEXT: movl %eax, 8(%esp)
39 ; CHECK-NEXT: movl %edx, 4(%esp)
40 ; CHECK-NEXT: movl %ecx, (%esp)
41 %hp_var = alloca i32
42 %p_var = alloca i32
43 %arg0_var = alloca i32
44 %arg1_var = alloca i32
45 %arg2_var = alloca i32
46 store i32 %hp, i32* %hp_var
47 store i32 %p, i32* %p_var
48 store i32 %arg0, i32* %arg0_var
49 store i32 %arg1, i32* %arg1_var
50 store i32 %arg2, i32* %arg2_var
51
Andrew Tricke97d8d62013-10-15 23:33:07 +000052 ; CHECK: movl 16(%esp), %esi
Andrew Trick121124a2013-06-25 02:48:58 +000053 ; CHECK-NEXT: movl 12(%esp), %ebp
Andrew Tricke97d8d62013-10-15 23:33:07 +000054 ; CHECK-NEXT: movl 8(%esp), %eax
55 ; CHECK-NEXT: movl 4(%esp), %edx
Duncan Sandsd71b4e42012-11-16 12:36:39 +000056 %0 = load i32* %hp_var
57 %1 = load i32* %p_var
58 %2 = load i32* %arg0_var
59 %3 = load i32* %arg1_var
60 %4 = load i32* %arg2_var
61 ; CHECK: jmp bar
62 tail call cc 11 void @bar(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) nounwind
63 ret void
64}
65
66define cc 11 void @baz() nounwind {
67 %tmp_clos = load i32* @clos
68 %tmp_clos2 = inttoptr i32 %tmp_clos to i32*
69 %indirect_call = bitcast i32* %tmp_clos2 to void (i32, i32, i32)*
70 ; CHECK: movl $42, %eax
71 ; CHECK-NEXT: jmpl *clos
72 tail call cc 11 void %indirect_call(i32 undef, i32 undef, i32 42) nounwind
73 ret void
74}
75
76@clos = external constant i32
77declare cc 11 void @bar(i32, i32, i32, i32, i32)