[x86] Remove some windows line endings that snuck into the tests here.
[oota-llvm.git] / test / CodeGen / X86 / movtopush.ll
1 ; RUN: llc < %s -mtriple=i686-windows | FileCheck %s -check-prefix=NORMAL
2 ; RUN: llc < %s -mtriple=i686-windows -force-align-stack -stack-alignment=32 | FileCheck %s -check-prefix=ALIGNED 
3 declare void @good(i32 %a, i32 %b, i32 %c, i32 %d)
4 declare void @inreg(i32 %a, i32 inreg %b, i32 %c, i32 %d)
5
6 ; Here, we should have a reserved frame, so we don't expect pushes
7 ; NORMAL-LABEL: test1
8 ; NORMAL: subl    $16, %esp
9 ; NORMAL-NEXT: movl    $4, 12(%esp)
10 ; NORMAL-NEXT: movl    $3, 8(%esp)
11 ; NORMAL-NEXT: movl    $2, 4(%esp)
12 ; NORMAL-NEXT: movl    $1, (%esp)
13 ; NORMAL-NEXT: call
14 define void @test1() {
15 entry:
16   call void @good(i32 1, i32 2, i32 3, i32 4)
17   ret void
18 }
19
20 ; Here, we expect a sequence of 4 immediate pushes
21 ; NORMAL-LABEL: test2
22 ; NORMAL-NOT: subl {{.*}} %esp
23 ; NORMAL: pushl   $4
24 ; NORMAL-NEXT: pushl   $3
25 ; NORMAL-NEXT: pushl   $2
26 ; NORMAL-NEXT: pushl   $1
27 ; NORMAL-NEXT: call
28 define void @test2(i32 %k) {
29 entry:
30   %a = alloca i32, i32 %k
31   call void @good(i32 1, i32 2, i32 3, i32 4)
32   ret void
33 }
34
35 ; Again, we expect a sequence of 4 immediate pushes
36 ; Checks that we generate the right pushes for >8bit immediates
37 ; NORMAL-LABEL: test2b
38 ; NORMAL-NOT: subl {{.*}} %esp
39 ; NORMAL: pushl   $4096
40 ; NORMAL-NEXT: pushl   $3072
41 ; NORMAL-NEXT: pushl   $2048
42 ; NORMAL-NEXT: pushl   $1024
43 ; NORMAL-NEXT: call
44 define void @test2b(i32 %k) {
45 entry:
46   %a = alloca i32, i32 %k
47   call void @good(i32 1024, i32 2048, i32 3072, i32 4096)
48   ret void
49 }
50
51 ; The first push should push a register
52 ; NORMAL-LABEL: test3
53 ; NORMAL-NOT: subl {{.*}} %esp
54 ; NORMAL: pushl   $4
55 ; NORMAL-NEXT: pushl   $3
56 ; NORMAL-NEXT: pushl   $2
57 ; NORMAL-NEXT: pushl   %e{{..}}
58 ; NORMAL-NEXT: call
59 define void @test3(i32 %k) {
60 entry:
61   %a = alloca i32, i32 %k
62   call void @good(i32 %k, i32 2, i32 3, i32 4)
63   ret void
64 }
65
66 ; We don't support weird calling conventions
67 ; NORMAL-LABEL: test4
68 ; NORMAL: subl    $12, %esp
69 ; NORMAL-NEXT: movl    $4, 8(%esp)
70 ; NORMAL-NEXT: movl    $3, 4(%esp)
71 ; NORMAL-NEXT: movl    $1, (%esp)
72 ; NORMAL-NEXT: movl    $2, %eax
73 ; NORMAL-NEXT: call
74 define void @test4(i32 %k) {
75 entry:
76   %a = alloca i32, i32 %k
77   call void @inreg(i32 1, i32 2, i32 3, i32 4)
78   ret void
79 }
80
81 ; Check that additional alignment is added when the pushes
82 ; don't add up to the required alignment.
83 ; ALIGNED-LABEL: test5
84 ; ALIGNED: subl    $16, %esp
85 ; ALIGNED-NEXT: pushl   $4
86 ; ALIGNED-NEXT: pushl   $3
87 ; ALIGNED-NEXT: pushl   $2
88 ; ALIGNED-NEXT: pushl   $1
89 ; ALIGNED-NEXT: call
90 define void @test5(i32 %k) {
91 entry:
92   %a = alloca i32, i32 %k
93   call void @good(i32 1, i32 2, i32 3, i32 4)
94   ret void
95 }
96
97 ; Check that pushing the addresses of globals (Or generally, things that 
98 ; aren't exactly immediates) isn't broken.
99 ; Fixes PR21878.
100 ; NORMAL-LABEL: test6
101 ; NORMAL: pushl    $_ext
102 ; NORMAL-NEXT: call
103 declare void @f(i8*)
104 @ext = external constant i8
105
106 define void @test6() {
107   call void @f(i8* @ext)
108   br label %bb
109 bb:
110   alloca i32
111   ret void
112 }