• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
10define i32 @test_ints(i32 %a, i32 %b, i32 %c, i32 %d) #0 {
11entry:
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
23define i32 @test_floats(i32 %a, i32 %b, float %c, float %d) #0 {
24entry:
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
37define double @test_doubles(double %d1, double %d2) #0 {
38entry:
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
50define double @test_mixed_doubles(double %d2, i32 %i) #0 {
51entry:
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
69define void @ret_large_struct(%struct.st12_t* noalias nocapture sret %agg.result, %struct.st12_t* byval nocapture readonly align 4 %r) #0 {
70entry:
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, i1 false)
74  ret void
75}
76
77; CHECK-LABEL: var_args:
78; CHECK: movl    4(%esp), %eax
79; CHECK-NEXT: retl
80define i32 @var_args(i32 %i1, ...) #0 {
81entry:
82  ret i32 %i1
83}
84
85%struct.S = type { i8 }
86
87; CHECK-LABEL: test_lib_args:
88; CHECK: movl %edx, %eax
89; CHECK: calll __fixsfsi
90define i32 @test_lib_args(float %a, float %b) #0 {
91  %ret = fptosi float %b to i32
92  ret i32 %ret
93}
94
95; CHECK-LABEL: test_fp128:
96; CHECK:      pushl   12(%eax)
97; CHECK-NEXT: pushl   8(%eax)
98; CHECK-NEXT: pushl   4(%eax)
99; CHECK-NEXT: pushl   (%eax)
100; CHECK-NEXT: calll   __fixtfsi
101define i32 @test_fp128(fp128* %ptr) #0 {
102  %v = load fp128, fp128* %ptr
103  %ret = fptosi fp128 %v to i32
104  ret i32 %ret
105}
106
107declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i1) #1
108
109; CHECK-LABEL: test_alignment_d:
110; CHECK-NOT: andl  {{.+}}, %esp
111define void @test_alignment_d() #0 {
112entry:
113  %d = alloca double
114  store double 2.000000e+00, double* %d
115  call void @food(double* inreg %d)
116  ret void
117}
118
119; CHECK-LABEL: test_alignment_i:
120; CHECK-NOT: andl  {{.+}}, %esp
121define void @test_alignment_i() #0 {
122entry:
123  %i = alloca i64
124  store i64 2, i64* %i
125  call void @fooi(i64* inreg %i)
126  ret void
127}
128
129
130; CHECK-LABEL: test_alignment_s:
131; CHECK-NOT: andl  {{.+}}, %esp
132define void @test_alignment_s() #0 {
133  %s = alloca %struct.S, align 4
134  call void @foos(%struct.S* inreg %s)
135  ret void
136}
137
138
139; CHECK-LABEL: test_alignment_fp:
140; CHECK-NOT: andl  {{.+}}, %esp
141define void @test_alignment_fp() #0 {
142entry:
143  %f = alloca fp128
144  store fp128 0xL00000000000000004000000000000000, fp128* %f
145  call void @foofp(fp128* inreg %f)
146  ret void
147}
148
149declare void @food(double* inreg)
150declare void @fooi(i64* inreg)
151declare void @foos(%struct.S* inreg)
152declare void @foofp(fp128* inreg)
153
154attributes #0 = { nounwind "use-soft-float"="true"}
155attributes #1 = { nounwind argmemonly }
156