blob: 4f6bfc7299136f9d1cdfeb83d0db323cbeb2bbcc [file] [log] [blame]
Edward O'Callaghanbebe1812009-11-22 11:45:44 +00001; RUN: llc < %s -march=ppc32 | FileCheck %s -check-prefix=X32
2; RUN: llc < %s -march=ppc64 | FileCheck %s -check-prefix=X64
3
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004
Tanya Lattner348c6182008-03-25 04:26:08 +00005define void @STWBRX(i32 %i, i8* %ptr, i32 %off) {
6 %tmp1 = getelementptr i8* %ptr, i32 %off ; <i8*> [#uses=1]
7 %tmp1.upgrd.1 = bitcast i8* %tmp1 to i32* ; <i32*> [#uses=1]
8 %tmp13 = tail call i32 @llvm.bswap.i32( i32 %i ) ; <i32> [#uses=1]
9 store i32 %tmp13, i32* %tmp1.upgrd.1
10 ret void
Dan Gohmanf17a25c2007-07-18 16:29:46 +000011}
12
Tanya Lattner348c6182008-03-25 04:26:08 +000013define i32 @LWBRX(i8* %ptr, i32 %off) {
14 %tmp1 = getelementptr i8* %ptr, i32 %off ; <i8*> [#uses=1]
15 %tmp1.upgrd.2 = bitcast i8* %tmp1 to i32* ; <i32*> [#uses=1]
16 %tmp = load i32* %tmp1.upgrd.2 ; <i32> [#uses=1]
17 %tmp14 = tail call i32 @llvm.bswap.i32( i32 %tmp ) ; <i32> [#uses=1]
18 ret i32 %tmp14
Dan Gohmanf17a25c2007-07-18 16:29:46 +000019}
20
Tanya Lattner348c6182008-03-25 04:26:08 +000021define void @STHBRX(i16 %s, i8* %ptr, i32 %off) {
22 %tmp1 = getelementptr i8* %ptr, i32 %off ; <i8*> [#uses=1]
23 %tmp1.upgrd.3 = bitcast i8* %tmp1 to i16* ; <i16*> [#uses=1]
24 %tmp5 = call i16 @llvm.bswap.i16( i16 %s ) ; <i16> [#uses=1]
25 store i16 %tmp5, i16* %tmp1.upgrd.3
26 ret void
Dan Gohmanf17a25c2007-07-18 16:29:46 +000027}
28
Tanya Lattner348c6182008-03-25 04:26:08 +000029define i16 @LHBRX(i8* %ptr, i32 %off) {
30 %tmp1 = getelementptr i8* %ptr, i32 %off ; <i8*> [#uses=1]
31 %tmp1.upgrd.4 = bitcast i8* %tmp1 to i16* ; <i16*> [#uses=1]
32 %tmp = load i16* %tmp1.upgrd.4 ; <i16> [#uses=1]
33 %tmp6 = call i16 @llvm.bswap.i16( i16 %tmp ) ; <i16> [#uses=1]
34 ret i16 %tmp6
Dan Gohmanf17a25c2007-07-18 16:29:46 +000035}
36
Tanya Lattner348c6182008-03-25 04:26:08 +000037declare i32 @llvm.bswap.i32(i32)
Dan Gohmanf17a25c2007-07-18 16:29:46 +000038
Tanya Lattner348c6182008-03-25 04:26:08 +000039declare i16 @llvm.bswap.i16(i16)
40
Edward O'Callaghanbebe1812009-11-22 11:45:44 +000041
Edward O'Callaghanba92a652009-11-22 12:50:05 +000042; X32: stwbrx
43; X32: lwbrx
44; X32: sthbrx
45; X32: lhbrx
Edward O'Callaghanbebe1812009-11-22 11:45:44 +000046
Edward O'Callaghanba92a652009-11-22 12:50:05 +000047; X64: stwbrx
48; X64: lwbrx
49; X64: sthbrx
50; X64: lhbrx
Edward O'Callaghanbebe1812009-11-22 11:45:44 +000051