Merging r261039:
[oota-llvm.git] / test / CodeGen / X86 / mcu-abi.ll
1 ; RUN: llc < %s -mtriple=i686-pc-elfiamcu | FileCheck %s
2
3 %struct.st12_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
4
5 ; CHECK-LABEL: test_ints:
6 ; CHECK: addl    %edx, %eax
7 ; CHECK-NEXT: imull   %ecx, %eax
8 ; CHECK-NEXT: addl    4(%esp), %eax
9 ; CHECK-NEXT: retl
10 define i32 @test_ints(i32 %a, i32 %b, i32 %c, i32 %d) #0 {
11 entry:
12   %r1 = add i32 %b, %a
13   %r2 = mul i32 %c, %r1
14   %r3 = add i32 %d, %r2
15   ret i32 %r3
16 }
17
18 ; CHECK-LABEL: test_floats:
19 ; CHECK: addl    %edx, %eax
20 ; CHECK-NEXT: imull   %ecx, %eax
21 ; CHECK-NEXT: addl    4(%esp), %eax
22 ; CHECK-NEXT: retl
23 define i32 @test_floats(i32 %a, i32 %b, float %c, float %d) #0 {
24 entry:
25   %ci = bitcast float %c to i32
26   %di = bitcast float %d to i32
27   %r1 = add i32 %b, %a
28   %r2 = mul i32 %ci, %r1
29   %r3 = add i32 %di, %r2
30   ret i32 %r3
31 }
32
33 ; CHECK-LABEL: test_doubles:
34 ; CHECK: addl    4(%esp), %eax
35 ; CHECK-NEXT: adcl    8(%esp), %edx
36 ; CHECK-NEXT: retl
37 define double @test_doubles(double %d1, double %d2) #0 {
38 entry:
39     %d1i = bitcast double %d1 to i64
40     %d2i = bitcast double %d2 to i64
41     %r = add i64 %d1i, %d2i
42     %rd = bitcast i64 %r to double
43     ret double %rd
44 }
45
46 ; CHECK-LABEL: test_mixed_doubles:
47 ; CHECK: addl    %ecx, %eax
48 ; CHECK-NEXT: adcl    $0, %edx
49 ; CHECK-NEXT: retl
50 define double @test_mixed_doubles(double %d2, i32 %i) #0 {
51 entry:
52     %iext = zext i32 %i to i64
53     %d2i = bitcast double %d2 to i64
54     %r = add i64 %iext, %d2i
55     %rd = bitcast i64 %r to double
56     ret double %rd
57 }
58
59 ; CHECK-LABEL: ret_large_struct:
60 ; CHECK: pushl   %esi
61 ; CHECK-NEXT: movl    %eax, %esi
62 ; CHECK-NEXT: leal    8(%esp), %edx
63 ; CHECK-NEXT: movl    $48, %ecx
64 ; CHECK-NEXT: calll   memcpy
65 ; CHECK-NEXT: movl    %esi, %eax
66 ; CHECK-NEXT: popl    %esi
67 ; CHECK-NOT:  retl $4
68 ; CHECK-NEXT: retl
69 define void @ret_large_struct(%struct.st12_t* noalias nocapture sret %agg.result, %struct.st12_t* byval nocapture readonly align 4 %r) #0 {
70 entry:
71   %0 = bitcast %struct.st12_t* %agg.result to i8*
72   %1 = bitcast %struct.st12_t* %r to i8*
73   call void @llvm.memcpy.p0i8.p0i8.i32(i8* %0, i8* %1, i32 48, i32 1, i1 false)
74   ret void
75 }
76
77 ; CHECK-LABEL: var_args:
78 ; CHECK: movl    4(%esp), %eax
79 ; CHECK-NEXT: retl
80 define i32 @var_args(i32 %i1, ...) #0 {
81 entry:
82   ret i32 %i1
83 }
84
85 ; CHECK-LABEL: test_lib_args:
86 ; CHECK: movl %edx, %eax
87 ; CHECK: calll __fixsfsi
88 define i32 @test_lib_args(float %a, float %b) #0 {
89   %ret = fptosi float %b to i32
90   ret i32 %ret
91 }
92
93 ; CHECK-LABEL: test_fp128:
94 ; CHECK: movl    (%eax), %e[[CX:..]]
95 ; CHECK-NEXT: movl    4(%eax), %e[[DX:..]]
96 ; CHECK-NEXT: movl    8(%eax), %e[[SI:..]]
97 ; CHECK-NEXT: movl    12(%eax), %e[[AX:..]]
98 ; CHECK-NEXT: movl    %e[[AX]], 12(%esp)
99 ; CHECK-NEXT: movl    %e[[SI]], 8(%esp)
100 ; CHECK-NEXT: movl    %e[[DX]], 4(%esp)
101 ; CHECK-NEXT: movl    %e[[CX]], (%esp)
102 ; CHECK-NEXT: calll   __fixtfsi
103 define i32 @test_fp128(fp128* %ptr) #0 {
104   %v = load fp128, fp128* %ptr
105   %ret = fptosi fp128 %v to i32
106   ret i32 %ret
107 }
108
109 declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i32, i1) #1
110
111 attributes #0 = { nounwind "use-soft-float"="true"}
112 attributes #1 = { nounwind argmemonly }