blob: 22b3db41a635050fb944a22ae8536e8203630f6c [file] [log] [blame]
Akira Hatanakabd952752011-12-20 23:58:36 +00001; RUN: llc < %s -march=mipsel -mcpu=mips32r2 | FileCheck %s -check-prefix=MIPS32
2; RUN: llc < %s -march=mips64el -mcpu=mips64r2 | FileCheck %s -check-prefix=MIPS64
Simon Atanasyan1093afe22013-11-19 12:20:17 +00003; RUN: llc < %s -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips32r2 -mattr=+mips16 | FileCheck %s -check-prefix=mips16
Akira Hatanakabd952752011-12-20 23:58:36 +00004
5define i32 @bswap32(i32 %x) nounwind readnone {
6entry:
Stephen Lind24ab202013-07-14 06:24:09 +00007; MIPS32-LABEL: bswap32:
Akira Hatanakabd952752011-12-20 23:58:36 +00008; MIPS32: wsbh $[[R0:[0-9]+]]
9; MIPS32: rotr ${{[0-9]+}}, $[[R0]], 16
Reed Kotler97309af2013-10-08 17:32:33 +000010; mips16: .ent bswap32
Akira Hatanakabd952752011-12-20 23:58:36 +000011 %or.3 = call i32 @llvm.bswap.i32(i32 %x)
12 ret i32 %or.3
13}
14
15define i64 @bswap64(i64 %x) nounwind readnone {
16entry:
Stephen Lind24ab202013-07-14 06:24:09 +000017; MIPS64-LABEL: bswap64:
Akira Hatanakabd952752011-12-20 23:58:36 +000018; MIPS64: dsbh $[[R0:[0-9]+]]
19; MIPS64: dshd ${{[0-9]+}}, $[[R0]]
Reed Kotler97309af2013-10-08 17:32:33 +000020; mips16: .ent bswap64
Akira Hatanakabd952752011-12-20 23:58:36 +000021 %or.7 = call i64 @llvm.bswap.i64(i64 %x)
22 ret i64 %or.7
23}
24
Raul E. Silveraa9dafe62014-03-18 17:49:12 +000025define <4 x i32> @bswapv4i32(<4 x i32> %x) nounwind readnone {
26entry:
27; MIPS32-LABEL: bswapv4i32:
28; MIPS32: wsbh $[[R0:[0-9]+]]
29; MIPS32: rotr ${{[0-9]+}}, $[[R0]], 16
30; MIPS32: wsbh $[[R0:[0-9]+]]
31; MIPS32: rotr ${{[0-9]+}}, $[[R0]], 16
32; MIPS32: wsbh $[[R0:[0-9]+]]
33; MIPS32: rotr ${{[0-9]+}}, $[[R0]], 16
34; MIPS32: wsbh $[[R0:[0-9]+]]
35; MIPS32: rotr ${{[0-9]+}}, $[[R0]], 16
36; mips16: .ent bswapv4i32
37 %ret = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %x)
38 ret <4 x i32> %ret
39}
40
41
42
Akira Hatanakabd952752011-12-20 23:58:36 +000043declare i32 @llvm.bswap.i32(i32) nounwind readnone
44
45declare i64 @llvm.bswap.i64(i64) nounwind readnone
46
Raul E. Silveraa9dafe62014-03-18 17:49:12 +000047declare <4 x i32> @llvm.bswap.v4i32(<4 x i32>) nounwind readnone