blob: 4824388da1092342cdfc3e4068345c9f58751841 [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
25declare i32 @llvm.bswap.i32(i32) nounwind readnone
26
27declare i64 @llvm.bswap.i64(i64) nounwind readnone
28