[libcompiler-rt] add bswapdi2/bswapsi2

This is required for mips gcc 6.3 userland to build/run.

Reviewed by:	emaste, dim
Approved by:	emaste
Differential Revision:	https://reviews.freebsd.org/D10838
This commit is contained in:
Adrian Chadd 2017-05-21 23:15:32 +00:00
parent 4d16f068f2
commit 66ed774149
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=318601
4 changed files with 62 additions and 2 deletions

View file

@ -57,8 +57,8 @@ si_int __popcountsi2(si_int a); // bit population
si_int __popcountdi2(di_int a); // bit population
si_int __popcountti2(ti_int a); // bit population
uint32_t __bswapsi2(uint32_t a); // a byteswapped, arm only
uint64_t __bswapdi2(uint64_t a); // a byteswapped, arm only
uint32_t __bswapsi2(uint32_t a); // a byteswapped, arm/mips only
uint64_t __bswapdi2(uint64_t a); // a byteswapped, arm/mips only
// Integral arithmetic

View file

@ -0,0 +1,28 @@
/* ===-- bswapdi2.c - Implement __bswapdi2 ---------------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is dual licensed under the MIT and the University of Illinois Open
* Source Licenses. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __bswapdi2 for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#include "int_lib.h"
COMPILER_RT_ABI uint64_t
__bswapdi2 (uint64_t u)
{
return ((((u) & 0xff00000000000000ULL) >> 56)
| (((u) & 0x00ff000000000000ULL) >> 40)
| (((u) & 0x0000ff0000000000ULL) >> 24)
| (((u) & 0x000000ff00000000ULL) >> 8)
| (((u) & 0x00000000ff000000ULL) << 8)
| (((u) & 0x0000000000ff0000ULL) << 24)
| (((u) & 0x000000000000ff00ULL) << 40)
| (((u) & 0x00000000000000ffULL) << 56));
}

View file

@ -0,0 +1,25 @@
/* ===-- bswapsi2.c - Implement __bswapsi2 ---------------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is dual licensed under the MIT and the University of Illinois Open
* Source Licenses. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __bswapsi2 for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#include "int_lib.h"
COMPILER_RT_ABI uint32_t
__bswapsi2 (uint32_t u)
{
return ((((u) & 0xff000000) >> 24)
| (((u) & 0x00ff0000) >> 8)
| (((u) & 0x0000ff00) << 8)
| (((u) & 0x000000ff) << 24));
}

View file

@ -224,3 +224,10 @@ SRCS+= switch8.S
SRCS+= switchu8.S
SRCS+= sync_synchronize.S
.endif
# GCC-6.3 on mips32 requires bswap32 built-in.
.if ${MACHINE_CPUARCH} == "mips"
SRCS+= bswapdi2.c
SRCS+= bswapsi2.c
.endif