2011-12-20 23:58:36 +00:00
|
|
|
; RUN: llc < %s -march=mipsel -mcpu=mips32r2 | FileCheck %s -check-prefix=MIPS32
|
|
|
|
; RUN: llc < %s -march=mips64el -mcpu=mips64r2 | FileCheck %s -check-prefix=MIPS64
|
2014-03-31 11:00:04 +00:00
|
|
|
; RUN: llc < %s -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips32r2 -mattr=+mips16 | FileCheck %s -check-prefix=MIPS16
|
2011-12-20 23:58:36 +00:00
|
|
|
|
|
|
|
define i32 @bswap32(i32 %x) nounwind readnone {
|
|
|
|
entry:
|
2013-07-14 06:24:09 +00:00
|
|
|
; MIPS32-LABEL: bswap32:
|
2011-12-20 23:58:36 +00:00
|
|
|
; MIPS32: wsbh $[[R0:[0-9]+]]
|
|
|
|
; MIPS32: rotr ${{[0-9]+}}, $[[R0]], 16
|
2014-03-31 11:00:04 +00:00
|
|
|
|
|
|
|
; MIPS64-LABEL: bswap32:
|
|
|
|
; MIPS64: wsbh $[[R0:[0-9]+]]
|
|
|
|
; MIPS64: rotr ${{[0-9]+}}, $[[R0]], 16
|
|
|
|
|
|
|
|
; MIPS16-LABEL: bswap32:
|
|
|
|
; MIPS16-DAG: srl $[[R0:[0-9]+]], $4, 8
|
|
|
|
; MIPS16-DAG: srl $[[R1:[0-9]+]], $4, 24
|
|
|
|
; MIPS16-DAG: sll $[[R2:[0-9]+]], $4, 8
|
|
|
|
; MIPS16-DAG: sll $[[R3:[0-9]+]], $4, 24
|
|
|
|
; MIPS16-DAG: li $[[R4:[0-9]+]], 65280
|
|
|
|
; MIPS16-DAG: and $[[R4]], $[[R0]]
|
|
|
|
; MIPS16-DAG: or $[[R1]], $[[R4]]
|
|
|
|
; MIPS16-DAG: lw $[[R7:[0-9]+]], $CPI
|
|
|
|
; MIPS16-DAG: and $[[R7]], $[[R2]]
|
|
|
|
; MIPS16-DAG: or $[[R3]], $[[R7]]
|
|
|
|
; MIPS16-DAG: or $[[R3]], $[[R1]]
|
|
|
|
|
2011-12-20 23:58:36 +00:00
|
|
|
%or.3 = call i32 @llvm.bswap.i32(i32 %x)
|
|
|
|
ret i32 %or.3
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @bswap64(i64 %x) nounwind readnone {
|
|
|
|
entry:
|
2014-03-31 11:00:04 +00:00
|
|
|
; MIPS32-LABEL: bswap64:
|
|
|
|
; MIPS32: wsbh $[[R0:[0-9]+]]
|
|
|
|
; MIPS32: rotr ${{[0-9]+}}, $[[R0]], 16
|
|
|
|
; MIPS32: wsbh $[[R0:[0-9]+]]
|
|
|
|
; MIPS32: rotr ${{[0-9]+}}, $[[R0]], 16
|
|
|
|
|
2013-07-14 06:24:09 +00:00
|
|
|
; MIPS64-LABEL: bswap64:
|
2011-12-20 23:58:36 +00:00
|
|
|
; MIPS64: dsbh $[[R0:[0-9]+]]
|
|
|
|
; MIPS64: dshd ${{[0-9]+}}, $[[R0]]
|
2014-03-31 11:00:04 +00:00
|
|
|
|
|
|
|
; MIPS16-LABEL: bswap64:
|
|
|
|
; MIPS16-DAG: srl $[[R0:[0-9]+]], $5, 8
|
|
|
|
; MIPS16-DAG: srl $[[R1:[0-9]+]], $5, 24
|
|
|
|
; MIPS16-DAG: sll $[[R2:[0-9]+]], $5, 8
|
|
|
|
; MIPS16-DAG: sll $[[R3:[0-9]+]], $5, 24
|
|
|
|
; MIPS16-DAG: li $[[R4:[0-9]+]], 65280
|
|
|
|
; MIPS16-DAG: and $[[R0]], $[[R4]]
|
|
|
|
; MIPS16-DAG: or $[[R1]], $[[R0]]
|
|
|
|
; MIPS16-DAG: lw $[[R7:[0-9]+]], 1f
|
|
|
|
; MIPS16-DAG: and $[[R2]], $[[R7]]
|
|
|
|
; MIPS16-DAG: or $[[R3]], $[[R2]]
|
|
|
|
; MIPS16-DAG: or $[[R3]], $[[R1]]
|
|
|
|
; MIPS16-DAG: srl $[[R0:[0-9]+]], $4, 8
|
|
|
|
; MIPS16-DAG: srl $[[R1:[0-9]+]], $4, 24
|
|
|
|
; MIPS16-DAG: sll $[[R2:[0-9]+]], $4, 8
|
|
|
|
; MIPS16-DAG: sll $[[R3:[0-9]+]], $4, 24
|
|
|
|
; MIPS16-DAG: li $[[R4:[0-9]+]], 65280
|
|
|
|
; MIPS16-DAG: and $[[R0]], $[[R4]]
|
|
|
|
; MIPS16-DAG: or $[[R1]], $[[R0]]
|
|
|
|
; MIPS16-DAG: lw $[[R7:[0-9]+]], 1f
|
|
|
|
; MIPS16-DAG: and $[[R2]], $[[R7]]
|
|
|
|
; MIPS16-DAG: or $[[R3]], $[[R2]]
|
|
|
|
; MIPS16-DAG: or $[[R3]], $[[R1]]
|
|
|
|
|
2011-12-20 23:58:36 +00:00
|
|
|
%or.7 = call i64 @llvm.bswap.i64(i64 %x)
|
|
|
|
ret i64 %or.7
|
|
|
|
}
|
|
|
|
|
2014-03-18 17:49:12 +00:00
|
|
|
define <4 x i32> @bswapv4i32(<4 x i32> %x) nounwind readnone {
|
|
|
|
entry:
|
|
|
|
; MIPS32-LABEL: bswapv4i32:
|
|
|
|
; MIPS32: wsbh $[[R0:[0-9]+]]
|
|
|
|
; MIPS32: rotr ${{[0-9]+}}, $[[R0]], 16
|
|
|
|
; MIPS32: wsbh $[[R0:[0-9]+]]
|
|
|
|
; MIPS32: rotr ${{[0-9]+}}, $[[R0]], 16
|
|
|
|
; MIPS32: wsbh $[[R0:[0-9]+]]
|
|
|
|
; MIPS32: rotr ${{[0-9]+}}, $[[R0]], 16
|
|
|
|
; MIPS32: wsbh $[[R0:[0-9]+]]
|
|
|
|
; MIPS32: rotr ${{[0-9]+}}, $[[R0]], 16
|
2014-03-31 11:00:04 +00:00
|
|
|
|
|
|
|
; MIPS64-LABEL: bswapv4i32:
|
|
|
|
; MIPS64: wsbh $[[R0:[0-9]+]]
|
|
|
|
; MIPS64: rotr ${{[0-9]+}}, $[[R0]], 16
|
|
|
|
; MIPS64: wsbh $[[R0:[0-9]+]]
|
|
|
|
; MIPS64: rotr ${{[0-9]+}}, $[[R0]], 16
|
|
|
|
; MIPS64: wsbh $[[R0:[0-9]+]]
|
|
|
|
; MIPS64: rotr ${{[0-9]+}}, $[[R0]], 16
|
|
|
|
; MIPS64: wsbh $[[R0:[0-9]+]]
|
|
|
|
; MIPS64: rotr ${{[0-9]+}}, $[[R0]], 16
|
|
|
|
|
|
|
|
; Don't bother with a MIPS16 version. It's just bswap32 repeated four times and
|
|
|
|
; would be very long
|
|
|
|
|
2014-03-18 17:49:12 +00:00
|
|
|
%ret = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %x)
|
|
|
|
ret <4 x i32> %ret
|
|
|
|
}
|
|
|
|
|
2011-12-20 23:58:36 +00:00
|
|
|
declare i32 @llvm.bswap.i32(i32) nounwind readnone
|
|
|
|
|
|
|
|
declare i64 @llvm.bswap.i64(i64) nounwind readnone
|
|
|
|
|
2014-03-18 17:49:12 +00:00
|
|
|
declare <4 x i32> @llvm.bswap.v4i32(<4 x i32>) nounwind readnone
|