Fix pattern for LD16S_3r, add basic tests to check load / store instructions
[oota-llvm.git] / test / CodeGen / XCore / load.ll
1 ; RUN: llvm-as < %s | llc -march=xcore > %t1.s
2 ; RUN: not grep add %t1.s
3 ; RUN: not grep ldaw %t1.s
4 ; RUN: not grep lda16 %t1.s
5 ; RUN: not grep zext %t1.s
6 ; RUN: not grep sext %t1.s
7 ; RUN: grep "ldw" %t1.s | count 2
8 ; RUN: grep "ld16s" %t1.s | count 1
9 ; RUN: grep "ld8u" %t1.s | count 1
10
11 define i32 @load32(i32* %p, i32 %offset) nounwind {
12 entry:
13         %0 = getelementptr i32* %p, i32 %offset
14         %1 = load i32* %0, align 4
15         ret i32 %1
16 }
17
18 define i32 @load32_imm(i32* %p) nounwind {
19 entry:
20         %0 = getelementptr i32* %p, i32 11
21         %1 = load i32* %0, align 4
22         ret i32 %1
23 }
24
25 define i32 @load16(i16* %p, i32 %offset) nounwind {
26 entry:
27         %0 = getelementptr i16* %p, i32 %offset
28         %1 = load i16* %0, align 2
29         %2 = sext i16 %1 to i32
30         ret i32 %2
31 }
32
33 define i32 @load8(i8* %p, i32 %offset) nounwind {
34 entry:
35         %0 = getelementptr i8* %p, i32 %offset
36         %1 = load i8* %0, align 1
37         %2 = zext i8 %1 to i32
38         ret i32 %2
39 }