1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=i386-linux-gnu                       -global-isel -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=ALL --check-prefix=SSE --check-prefix=SSE_FAST
3; RUN: llc -mtriple=i386-linux-gnu -regbankselect-greedy -global-isel -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=ALL --check-prefix=SSE --check-prefix=SSE_GREEDY
4
5;TODO merge with x86-64 tests (many operations not suppored yet)
6
7define i1 @test_load_i1(i1 * %p1) {
8; ALL-LABEL: test_load_i1:
9; ALL:       # %bb.0:
10; ALL-NEXT:    movl 4(%esp), %eax
11; ALL-NEXT:    movb (%eax), %al
12; ALL-NEXT:    retl
13  %r = load i1, i1* %p1
14  ret i1 %r
15}
16
17define i8 @test_load_i8(i8 * %p1) {
18; ALL-LABEL: test_load_i8:
19; ALL:       # %bb.0:
20; ALL-NEXT:    movl 4(%esp), %eax
21; ALL-NEXT:    movb (%eax), %al
22; ALL-NEXT:    retl
23  %r = load i8, i8* %p1
24  ret i8 %r
25}
26
27define i16 @test_load_i16(i16 * %p1) {
28; ALL-LABEL: test_load_i16:
29; ALL:       # %bb.0:
30; ALL-NEXT:    movl 4(%esp), %eax
31; ALL-NEXT:    movzwl (%eax), %eax
32; ALL-NEXT:    retl
33  %r = load i16, i16* %p1
34  ret i16 %r
35}
36
37define i32 @test_load_i32(i32 * %p1) {
38; ALL-LABEL: test_load_i32:
39; ALL:       # %bb.0:
40; ALL-NEXT:    movl 4(%esp), %eax
41; ALL-NEXT:    movl (%eax), %eax
42; ALL-NEXT:    retl
43  %r = load i32, i32* %p1
44  ret i32 %r
45}
46
47define i1 * @test_store_i1(i1 %val, i1 * %p1) {
48; ALL-LABEL: test_store_i1:
49; ALL:       # %bb.0:
50; ALL-NEXT:    movb 4(%esp), %cl
51; ALL-NEXT:    movl 8(%esp), %eax
52; ALL-NEXT:    andb $1, %cl
53; ALL-NEXT:    movb %cl, (%eax)
54; ALL-NEXT:    retl
55  store i1 %val, i1* %p1
56  ret i1 * %p1;
57}
58
59define i8 * @test_store_i8(i8 %val, i8 * %p1) {
60; ALL-LABEL: test_store_i8:
61; ALL:       # %bb.0:
62; ALL-NEXT:    movb 4(%esp), %cl
63; ALL-NEXT:    movl 8(%esp), %eax
64; ALL-NEXT:    movb %cl, (%eax)
65; ALL-NEXT:    retl
66  store i8 %val, i8* %p1
67  ret i8 * %p1;
68}
69
70define i16 * @test_store_i16(i16 %val, i16 * %p1) {
71; ALL-LABEL: test_store_i16:
72; ALL:       # %bb.0:
73; ALL-NEXT:    movzwl 4(%esp), %ecx
74; ALL-NEXT:    movl 8(%esp), %eax
75; ALL-NEXT:    movw %cx, (%eax)
76; ALL-NEXT:    retl
77  store i16 %val, i16* %p1
78  ret i16 * %p1;
79}
80
81define i32 * @test_store_i32(i32 %val, i32 * %p1) {
82; ALL-LABEL: test_store_i32:
83; ALL:       # %bb.0:
84; ALL-NEXT:    movl 4(%esp), %ecx
85; ALL-NEXT:    movl 8(%esp), %eax
86; ALL-NEXT:    movl %ecx, (%eax)
87; ALL-NEXT:    retl
88  store i32 %val, i32* %p1
89  ret i32 * %p1;
90}
91
92define i32* @test_load_ptr(i32** %ptr1) {
93; ALL-LABEL: test_load_ptr:
94; ALL:       # %bb.0:
95; ALL-NEXT:    movl 4(%esp), %eax
96; ALL-NEXT:    movl (%eax), %eax
97; ALL-NEXT:    retl
98  %p = load i32*, i32** %ptr1
99  ret i32* %p
100}
101
102define void @test_store_ptr(i32** %ptr1, i32* %a) {
103; ALL-LABEL: test_store_ptr:
104; ALL:       # %bb.0:
105; ALL-NEXT:    movl 4(%esp), %eax
106; ALL-NEXT:    movl 8(%esp), %ecx
107; ALL-NEXT:    movl %ecx, (%eax)
108; ALL-NEXT:    retl
109  store i32* %a, i32** %ptr1
110  ret void
111}
112