Add the PPC64 ldbrx/stdbrx instructions
[oota-llvm.git] / test / CodeGen / PowerPC / bswap-load-store.ll
1 ; RUN: llc < %s -march=ppc32 | FileCheck %s -check-prefix=X32
2 ; RUN: llc < %s -march=ppc64 | FileCheck %s -check-prefix=X64
3 ; RUN: llc < %s -march=ppc64 -mcpu=pwr7 | FileCheck %s -check-prefix=PWR7
4
5
6 define void @STWBRX(i32 %i, i8* %ptr, i32 %off) {
7         %tmp1 = getelementptr i8* %ptr, i32 %off                ; <i8*> [#uses=1]
8         %tmp1.upgrd.1 = bitcast i8* %tmp1 to i32*               ; <i32*> [#uses=1]
9         %tmp13 = tail call i32 @llvm.bswap.i32( i32 %i )                ; <i32> [#uses=1]
10         store i32 %tmp13, i32* %tmp1.upgrd.1
11         ret void
12 }
13
14 define i32 @LWBRX(i8* %ptr, i32 %off) {
15         %tmp1 = getelementptr i8* %ptr, i32 %off                ; <i8*> [#uses=1]
16         %tmp1.upgrd.2 = bitcast i8* %tmp1 to i32*               ; <i32*> [#uses=1]
17         %tmp = load i32* %tmp1.upgrd.2          ; <i32> [#uses=1]
18         %tmp14 = tail call i32 @llvm.bswap.i32( i32 %tmp )              ; <i32> [#uses=1]
19         ret i32 %tmp14
20 }
21
22 define void @STHBRX(i16 %s, i8* %ptr, i32 %off) {
23         %tmp1 = getelementptr i8* %ptr, i32 %off                ; <i8*> [#uses=1]
24         %tmp1.upgrd.3 = bitcast i8* %tmp1 to i16*               ; <i16*> [#uses=1]
25         %tmp5 = call i16 @llvm.bswap.i16( i16 %s )              ; <i16> [#uses=1]
26         store i16 %tmp5, i16* %tmp1.upgrd.3
27         ret void
28 }
29
30 define i16 @LHBRX(i8* %ptr, i32 %off) {
31         %tmp1 = getelementptr i8* %ptr, i32 %off                ; <i8*> [#uses=1]
32         %tmp1.upgrd.4 = bitcast i8* %tmp1 to i16*               ; <i16*> [#uses=1]
33         %tmp = load i16* %tmp1.upgrd.4          ; <i16> [#uses=1]
34         %tmp6 = call i16 @llvm.bswap.i16( i16 %tmp )            ; <i16> [#uses=1]
35         ret i16 %tmp6
36 }
37
38 define void @STDBRX(i64 %i, i8* %ptr, i64 %off) {
39         %tmp1 = getelementptr i8* %ptr, i64 %off                ; <i8*> [#uses=1]
40         %tmp1.upgrd.1 = bitcast i8* %tmp1 to i64*               ; <i64*> [#uses=1]
41         %tmp13 = tail call i64 @llvm.bswap.i64( i64 %i )                ; <i64> [#uses=1]
42         store i64 %tmp13, i64* %tmp1.upgrd.1
43         ret void
44 }
45
46 define i64 @LDBRX(i8* %ptr, i64 %off) {
47         %tmp1 = getelementptr i8* %ptr, i64 %off                ; <i8*> [#uses=1]
48         %tmp1.upgrd.2 = bitcast i8* %tmp1 to i64*               ; <i64*> [#uses=1]
49         %tmp = load i64* %tmp1.upgrd.2          ; <i64> [#uses=1]
50         %tmp14 = tail call i64 @llvm.bswap.i64( i64 %tmp )              ; <i64> [#uses=1]
51         ret i64 %tmp14
52 }
53
54 declare i32 @llvm.bswap.i32(i32)
55
56 declare i16 @llvm.bswap.i16(i16)
57
58 declare i64 @llvm.bswap.i64(i64)
59
60
61 ; X32: stwbrx
62 ; X32: lwbrx
63 ; X32: sthbrx
64 ; X32: lhbrx
65 ; X32-NOT: ldbrx
66 ; X32-NOT: stdbrx
67
68 ; X64: stwbrx
69 ; X64: lwbrx
70 ; X64: sthbrx
71 ; X64: lhbrx
72 ; X64-NOT: ldbrx
73 ; X64-NOT: stdbrx
74
75 ; PWR7: stwbrx
76 ; PWR7: lwbrx
77 ; PWR7: sthbrx
78 ; PWR7: lhbrx
79 ; PWR7: stdbrx
80 ; PWR7: ldbrx
81