908da3d11206f592e04e0b3a43d495d7b2787f34
[oota-llvm.git] / test / CodeGen / X86 / x86-32-intrcc.ll
1 ; RUN: llc -mtriple=i686-unknown-unknown < %s | FileCheck %s\r
2 ; RUN: llc -mtriple=i686-unknown-unknown -O0 < %s | FileCheck %s -check-prefix=CHECK0\r
3 \r
4 %struct.interrupt_frame = type { i32, i32, i32, i32, i32 }\r
5 \r
6 @llvm.used = appending global [3 x i8*] [i8* bitcast (void (%struct.interrupt_frame*)* @test_isr_no_ecode to i8*), i8* bitcast (void (%struct.interrupt_frame*, i32)* @test_isr_ecode to i8*), i8* bitcast (void (%struct.interrupt_frame*, i32)* @test_isr_clobbers to i8*)], section "llvm.metadata"\r
7 \r
8 ; Spills eax, putting original esp at +4.\r
9 ; No stack adjustment if declared with no error code\r
10 define x86_intrcc void @test_isr_no_ecode(%struct.interrupt_frame* %frame) {\r
11   ; CHECK-LABEL: test_isr_no_ecode:\r
12   ; CHECK: pushl %eax\r
13   ; CHECK: movl 12(%esp), %eax\r
14   ; CHECK: popl %eax\r
15   ; CHECK: iretl\r
16   ; CHECK0-LABEL: test_isr_no_ecode:\r
17   ; CHECK0: pushl %eax\r
18   ; CHECK0: leal 4(%esp), %eax\r
19   ; CHECK0: movl 8(%eax), %eax\r
20   ; CHECK0: popl %eax\r
21   ; CHECK0: iretl\r
22   %pflags = getelementptr inbounds %struct.interrupt_frame, %struct.interrupt_frame* %frame, i32 0, i32 2\r
23   %flags = load i32, i32* %pflags, align 4\r
24   call void asm sideeffect "", "r"(i32 %flags)\r
25   ret void\r
26 }\r
27 \r
28 ; Spills eax and ecx, putting original esp at +8. Stack is adjusted up another 4 bytes\r
29 ; before return, popping the error code.\r
30 define x86_intrcc void @test_isr_ecode(%struct.interrupt_frame* %frame, i32 %ecode) {\r
31   ; CHECK-LABEL: test_isr_ecode\r
32   ; CHECK: pushl %ecx\r
33   ; CHECK: pushl %eax\r
34   ; CHECK: movl 8(%esp), %eax\r
35   ; CHECK: movl 20(%esp), %ecx\r
36   ; CHECK: popl %eax\r
37   ; CHECK: popl %ecx\r
38   ; CHECK: addl $4, %esp\r
39   ; CHECK: iretl\r
40   ; CHECK0-LABEL: test_isr_ecode\r
41   ; CHECK0: pushl %ecx\r
42   ; CHECK0: pushl %eax\r
43   ; CHECK0: movl 8(%esp), %eax\r
44   ; CHECK0: leal 12(%esp), %ecx\r
45   ; CHECK0: movl 8(%ecx), %ecx\r
46   ; CHECK0: popl %eax\r
47   ; CHECK0: popl %ecx\r
48   ; CHECK0: addl $4, %esp\r
49   ; CHECK0: iretl\r
50   %pflags = getelementptr inbounds %struct.interrupt_frame, %struct.interrupt_frame* %frame, i32 0, i32 2\r
51   %flags = load i32, i32* %pflags, align 4\r
52   call x86_fastcallcc void asm sideeffect "", "r,r"(i32 %flags, i32 %ecode)\r
53   ret void\r
54 }\r
55 \r
56 ; All clobbered registers must be saved\r
57 define x86_intrcc void @test_isr_clobbers(%struct.interrupt_frame* %frame, i32 %ecode) {\r
58   call void asm sideeffect "", "~{eax},~{ebx},~{ebp}"()\r
59   ; CHECK-LABEL: test_isr_clobbers\r
60   ; CHECK-SSE-NEXT: pushl %ebp\r
61   ; CHECK-SSE-NEXT: pushl %ebx\r
62   ; CHECK-SSE-NEXT; pushl %eax\r
63   ; CHECK-SSE-NEXT: popl %eax\r
64   ; CHECK-SSE-NEXT: popl %ebx\r
65   ; CHECK-SSE-NEXT: popl %ebp\r
66   ; CHECK-SSE-NEXT: addl $4, %esp\r
67   ; CHECK-SSE-NEXT: iretl\r
68   ; CHECK0-LABEL: test_isr_clobbers\r
69   ; CHECK0-SSE-NEXT: pushl %ebp\r
70   ; CHECK0-SSE-NEXT: pushl %ebx\r
71   ; CHECK0-SSE-NEXT; pushl %eax\r
72   ; CHECK0-SSE-NEXT: popl %eax\r
73   ; CHECK0-SSE-NEXT: popl %ebx\r
74   ; CHECK0-SSE-NEXT: popl %ebp\r
75   ; CHECK0-SSE-NEXT: addl $4, %esp\r
76   ; CHECK0-SSE-NEXT: iretl\r
77   ret void\r
78 }\r
79 \r