forked from OSchip/llvm-project
Next batch of C++ to C comment style changes. Also improve and factor out endianness pre-processor code.
llvm-svn: 78226
This commit is contained in:
parent
22ef75155e
commit
dabf71f171
|
|
@ -1,24 +1,25 @@
|
|||
//===-- addvti3.c - Implement __addvti3 -----------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements __addvti3 for the compiler_rt library.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
/* ===-- addvti3.c - Implement __addvti3 -----------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __addvti3 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if __x86_64
|
||||
|
||||
#include "int_lib.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
// Returns: a + b
|
||||
/* Returns: a + b */
|
||||
|
||||
// Effects: aborts if a + b overflows
|
||||
/* Effects: aborts if a + b overflows */
|
||||
|
||||
ti_int
|
||||
__addvti3(ti_int a, ti_int b)
|
||||
|
|
|
|||
|
|
@ -1,23 +1,24 @@
|
|||
//===-- ctzti2.c - Implement __ctzti2 -------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements __ctzti2 for the compiler_rt library.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
/* ===-- ctzti2.c - Implement __ctzti2 -------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __ctzti2 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if __x86_64
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
// Returns: the number of trailing 0-bits
|
||||
/* Returns: the number of trailing 0-bits */
|
||||
|
||||
// Precondition: a != 0
|
||||
/* Precondition: a != 0 */
|
||||
|
||||
si_int
|
||||
__ctzti2(ti_int a)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,65 @@
|
|||
/* ===-- endianness.h - configuration header for libgcc replacement --------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file is a configuration header for libgcc replacement.
|
||||
* This file is not part of the interface of this library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#ifndef ENDIANNESS_H
|
||||
#define ENDIANNESS_H
|
||||
|
||||
/* TODO: Improve this to minimal pre-processor hackish'ness. */
|
||||
/* config.h build via CMake. */
|
||||
/* #include <config.h> */
|
||||
/* Solaris header for endian and byte swap */
|
||||
/* #if defined HAVE_SYS_BYTEORDER_H */
|
||||
|
||||
#if defined (__SVR4) && defined (__sun)
|
||||
#include <sys/byteorder.h>
|
||||
#if _BYTE_ORDER == _BIG_ENDIAN
|
||||
#define __BIG_ENDIAN__ 1
|
||||
#define __LITTLE_ENDIAN__ 0
|
||||
#else /* _BYTE_ORDER == _LITTLE_ENDIAN */
|
||||
#define __BIG_ENDIAN__ 0
|
||||
#define __LITTLE_ENDIAN__ 1
|
||||
#endif /* _BYTE_ORDER */
|
||||
#endif /* Solaris and AuroraUX. */
|
||||
|
||||
#if defined (__FreeBSD__)
|
||||
#include <sys/endian.h>
|
||||
#if _BYTE_ORDER == _BIG_ENDIAN
|
||||
#define __BIG_ENDIAN__ 1
|
||||
#define __LITTLE_ENDIAN__ 0
|
||||
#else /* _BYTE_ORDER == _LITTLE_ENDIAN */
|
||||
#define __BIG_ENDIAN__ 0
|
||||
#define __LITTLE_ENDIAN__ 1
|
||||
#endif /* _BYTE_ORDER */
|
||||
#endif /* FreeBSD */
|
||||
|
||||
#ifdef __LITTLE_ENDIAN__
|
||||
#if __LITTLE_ENDIAN__
|
||||
#define _YUGA_LITTLE_ENDIAN 1
|
||||
#define _YUGA_BIG_ENDIAN 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __BIG_ENDIAN__
|
||||
#if __BIG_ENDIAN__
|
||||
#define _YUGA_LITTLE_ENDIAN 0
|
||||
#define _YUGA_BIG_ENDIAN 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(_YUGA_LITTLE_ENDIAN) || !defined(_YUGA_BIG_ENDIAN)
|
||||
#error unable to determine endian
|
||||
#endif
|
||||
|
||||
#endif /* ENDIANNESS_H */
|
||||
|
|
@ -1,27 +1,29 @@
|
|||
//===-- fixsfti.c - Implement __fixsfti -----------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements __fixsfti for the compiler_rt library.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
/* ===-- fixsfti.c - Implement __fixsfti -----------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __fixsfti for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if __x86_64
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
// Returns: convert a to a signed long long, rounding toward zero.
|
||||
/* Returns: convert a to a signed long long, rounding toward zero. */
|
||||
|
||||
// Assumption: float is a IEEE 32 bit floating point type
|
||||
// su_int is a 32 bit integral type
|
||||
// value in float is representable in ti_int (no range checking performed)
|
||||
/* Assumption: float is a IEEE 32 bit floating point type
|
||||
* su_int is a 32 bit integral type
|
||||
* value in float is representable in ti_int (no range checking performed)
|
||||
*/
|
||||
|
||||
// seee eeee emmm mmmm mmmm mmmm mmmm mmmm
|
||||
/* seee eeee emmm mmmm mmmm mmmm mmmm mmmm */
|
||||
|
||||
ti_int
|
||||
__fixsfti(float a)
|
||||
|
|
|
|||
|
|
@ -1,30 +1,34 @@
|
|||
//===-- fixunsxfsi.c - Implement __fixunsxfsi -----------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements __fixunsxfsi for the compiler_rt library.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
/* ===-- fixunsxfsi.c - Implement __fixunsxfsi -----------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __fixunsxfsi for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if !_ARCH_PPC
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
// Returns: convert a to a unsigned int, rounding toward zero.
|
||||
// Negative values all become zero.
|
||||
/* Returns: convert a to a unsigned int, rounding toward zero.
|
||||
* Negative values all become zero.
|
||||
*/
|
||||
|
||||
// Assumption: long double is an intel 80 bit floating point type padded with 6 bytes
|
||||
// su_int is a 32 bit integral type
|
||||
// value in long double is representable in su_int or is negative
|
||||
// (no range checking performed)
|
||||
/* Assumption: long double is an intel 80 bit floating point type padded with 6 bytes
|
||||
* su_int is a 32 bit integral type
|
||||
* value in long double is representable in su_int or is negative
|
||||
* (no range checking performed)
|
||||
*/
|
||||
|
||||
// gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
|
||||
// 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
|
||||
/* gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
|
||||
* 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
|
||||
*/
|
||||
|
||||
su_int
|
||||
__fixunsxfsi(long double a)
|
||||
|
|
|
|||
|
|
@ -1,27 +1,29 @@
|
|||
//===-- floatuntidf.c - Implement __floatuntidf ---------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements __floatuntidf for the compiler_rt library.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
/* ===-- floatuntidf.c - Implement __floatuntidf ---------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __floatuntidf for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if __x86_64
|
||||
|
||||
#include "int_lib.h"
|
||||
#include <float.h>
|
||||
|
||||
// Returns: convert a to a double, rounding toward even.
|
||||
/* Returns: convert a to a double, rounding toward even. */
|
||||
|
||||
// Assumption: double is a IEEE 64 bit floating point type
|
||||
// tu_int is a 128 bit integral type
|
||||
/* Assumption: double is a IEEE 64 bit floating point type
|
||||
* tu_int is a 128 bit integral type
|
||||
*/
|
||||
|
||||
// seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
|
||||
/* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */
|
||||
|
||||
si_int __clzti2(ti_int a);
|
||||
|
||||
|
|
@ -31,17 +33,18 @@ __floatuntidf(tu_int a)
|
|||
if (a == 0)
|
||||
return 0.0;
|
||||
const unsigned N = sizeof(tu_int) * CHAR_BIT;
|
||||
int sd = N - __clzti2(a); // number of significant digits
|
||||
int e = sd - 1; // exponent
|
||||
int sd = N - __clzti2(a); /* number of significant digits */
|
||||
int e = sd - 1; /* exponent */
|
||||
if (sd > DBL_MANT_DIG)
|
||||
{
|
||||
// start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx
|
||||
// finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR
|
||||
// 12345678901234567890123456
|
||||
// 1 = msb 1 bit
|
||||
// P = bit DBL_MANT_DIG-1 bits to the right of 1
|
||||
// Q = bit DBL_MANT_DIG bits to the right of 1
|
||||
// R = "or" of all bits to the right of Q
|
||||
/* start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx
|
||||
* finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR
|
||||
* 12345678901234567890123456
|
||||
* 1 = msb 1 bit
|
||||
* P = bit DBL_MANT_DIG-1 bits to the right of 1
|
||||
* Q = bit DBL_MANT_DIG bits to the right of 1
|
||||
* R = "or" of all bits to the right of Q
|
||||
*/
|
||||
switch (sd)
|
||||
{
|
||||
case DBL_MANT_DIG + 1:
|
||||
|
|
@ -53,27 +56,27 @@ __floatuntidf(tu_int a)
|
|||
a = (a >> (sd - (DBL_MANT_DIG+2))) |
|
||||
((a & ((tu_int)(-1) >> ((N + DBL_MANT_DIG+2) - sd))) != 0);
|
||||
};
|
||||
// finish:
|
||||
a |= (a & 4) != 0; // Or P into R
|
||||
++a; // round - this step may add a significant bit
|
||||
a >>= 2; // dump Q and R
|
||||
// a is now rounded to DBL_MANT_DIG or DBL_MANT_DIG+1 bits
|
||||
/* finish: */
|
||||
a |= (a & 4) != 0; /* Or P into R */
|
||||
++a; /* round - this step may add a significant bit */
|
||||
a >>= 2; /* dump Q and R */
|
||||
/* a is now rounded to DBL_MANT_DIG or DBL_MANT_DIG+1 bits */
|
||||
if (a & ((tu_int)1 << DBL_MANT_DIG))
|
||||
{
|
||||
a >>= 1;
|
||||
++e;
|
||||
}
|
||||
// a is now rounded to DBL_MANT_DIG bits
|
||||
/* a is now rounded to DBL_MANT_DIG bits */
|
||||
}
|
||||
else
|
||||
{
|
||||
a <<= (DBL_MANT_DIG - sd);
|
||||
// a is now rounded to DBL_MANT_DIG bits
|
||||
/* a is now rounded to DBL_MANT_DIG bits */
|
||||
}
|
||||
double_bits fb;
|
||||
fb.u.high = ((e + 1023) << 20) | // exponent
|
||||
((su_int)(a >> 32) & 0x000FFFFF); // mantissa-high
|
||||
fb.u.low = (su_int)a; // mantissa-low
|
||||
fb.u.high = ((e + 1023) << 20) | /* exponent */
|
||||
((su_int)(a >> 32) & 0x000FFFFF); /* mantissa-high */
|
||||
fb.u.low = (su_int)a; /* mantissa-low */
|
||||
return fb.f;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,27 +1,29 @@
|
|||
//===-- floatuntisf.c - Implement __floatuntisf ---------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements __floatuntisf for the compiler_rt library.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
/* ===-- floatuntisf.c - Implement __floatuntisf ---------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __floatuntisf for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if __x86_64
|
||||
|
||||
#include "int_lib.h"
|
||||
#include <float.h>
|
||||
|
||||
// Returns: convert a to a float, rounding toward even.
|
||||
/* Returns: convert a to a float, rounding toward even. */
|
||||
|
||||
// Assumption: float is a IEEE 32 bit floating point type
|
||||
// tu_int is a 128 bit integral type
|
||||
/* Assumption: float is a IEEE 32 bit floating point type
|
||||
* tu_int is a 128 bit integral type
|
||||
*/
|
||||
|
||||
// seee eeee emmm mmmm mmmm mmmm mmmm mmmm
|
||||
/* seee eeee emmm mmmm mmmm mmmm mmmm mmmm */
|
||||
|
||||
si_int __clzti2(ti_int a);
|
||||
|
||||
|
|
@ -31,17 +33,18 @@ __floatuntisf(tu_int a)
|
|||
if (a == 0)
|
||||
return 0.0F;
|
||||
const unsigned N = sizeof(tu_int) * CHAR_BIT;
|
||||
int sd = N - __clzti2(a); // number of significant digits
|
||||
int e = sd - 1; // exponent
|
||||
int sd = N - __clzti2(a); /* number of significant digits */
|
||||
int e = sd - 1; /* exponent */
|
||||
if (sd > FLT_MANT_DIG)
|
||||
{
|
||||
// start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx
|
||||
// finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR
|
||||
// 12345678901234567890123456
|
||||
// 1 = msb 1 bit
|
||||
// P = bit FLT_MANT_DIG-1 bits to the right of 1
|
||||
// Q = bit FLT_MANT_DIG bits to the right of 1
|
||||
// R = "or" of all bits to the right of Q
|
||||
/* start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx
|
||||
* finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR
|
||||
* 12345678901234567890123456
|
||||
* 1 = msb 1 bit
|
||||
* P = bit FLT_MANT_DIG-1 bits to the right of 1
|
||||
* Q = bit FLT_MANT_DIG bits to the right of 1
|
||||
* R = "or" of all bits to the right of Q
|
||||
*/
|
||||
switch (sd)
|
||||
{
|
||||
case FLT_MANT_DIG + 1:
|
||||
|
|
@ -53,26 +56,26 @@ __floatuntisf(tu_int a)
|
|||
a = (a >> (sd - (FLT_MANT_DIG+2))) |
|
||||
((a & ((tu_int)(-1) >> ((N + FLT_MANT_DIG+2) - sd))) != 0);
|
||||
};
|
||||
// finish:
|
||||
a |= (a & 4) != 0; // Or P into R
|
||||
++a; // round - this step may add a significant bit
|
||||
a >>= 2; // dump Q and R
|
||||
// a is now rounded to FLT_MANT_DIG or FLT_MANT_DIG+1 bits
|
||||
/* finish: */
|
||||
a |= (a & 4) != 0; /* Or P into R */
|
||||
++a; /* round - this step may add a significant bit */
|
||||
a >>= 2; /* dump Q and R */
|
||||
/* a is now rounded to FLT_MANT_DIG or FLT_MANT_DIG+1 bits */
|
||||
if (a & ((tu_int)1 << FLT_MANT_DIG))
|
||||
{
|
||||
a >>= 1;
|
||||
++e;
|
||||
}
|
||||
// a is now rounded to FLT_MANT_DIG bits
|
||||
/* a is now rounded to FLT_MANT_DIG bits */
|
||||
}
|
||||
else
|
||||
{
|
||||
a <<= (FLT_MANT_DIG - sd);
|
||||
// a is now rounded to FLT_MANT_DIG bits
|
||||
/* a is now rounded to FLT_MANT_DIG bits */
|
||||
}
|
||||
float_bits fb;
|
||||
fb.u = ((e + 127) << 23) | // exponent
|
||||
((su_int)a & 0x007FFFFF); // mantissa
|
||||
fb.u = ((e + 127) << 23) | /* exponent */
|
||||
((su_int)a & 0x007FFFFF); /* mantissa */
|
||||
return fb.f;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,58 +20,13 @@
|
|||
/* Assumption: right shift of signed negative is arithmetic shift */
|
||||
|
||||
#include <limits.h>
|
||||
#include "endianness.h"
|
||||
#include <math.h>
|
||||
|
||||
#if !defined(INFINITY) && defined(HUGE_VAL)
|
||||
#define INFINITY HUGE_VAL
|
||||
#endif
|
||||
|
||||
/* TODO: Improve this to minimal pre-processor hackish'ness. */
|
||||
#if defined (__SVR4) && defined (__sun)
|
||||
/* config.h build via CMake. */
|
||||
/* #include <config.h> */
|
||||
|
||||
/* Solaris header for endian and byte swap */
|
||||
/* #if defined HAVE_SYS_BYTEORDER_H */
|
||||
#include <sys/byteorder.h>
|
||||
|
||||
/* Solaris defines endian by setting _LITTLE_ENDIAN or _BIG_ENDIAN */
|
||||
#ifdef _BIG_ENDIAN
|
||||
# define IS_BIG_ENDIAN
|
||||
#endif
|
||||
#ifdef _LITTLE_ENDIAN
|
||||
# define IS_LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
#ifdef IS_BIG_ENDIAN
|
||||
#define __BIG_ENDIAN__ 1
|
||||
#define __LITTLE_ENDIAN__ 0
|
||||
#endif
|
||||
#ifdef IS_LITTLE_ENDIAN
|
||||
#define __BIG_ENDIAN__ 0
|
||||
#define __LITTLE_ENDIAN__ 1
|
||||
#endif
|
||||
|
||||
#endif /* End of Solaris ifdef. */
|
||||
|
||||
#ifdef __LITTLE_ENDIAN__
|
||||
#if __LITTLE_ENDIAN__
|
||||
#define _YUGA_LITTLE_ENDIAN 1
|
||||
#define _YUGA_BIG_ENDIAN 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __BIG_ENDIAN__
|
||||
#if __BIG_ENDIAN__
|
||||
#define _YUGA_LITTLE_ENDIAN 0
|
||||
#define _YUGA_BIG_ENDIAN 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(_YUGA_LITTLE_ENDIAN) || !defined(_YUGA_BIG_ENDIAN)
|
||||
#error unable to determine endian
|
||||
#endif
|
||||
|
||||
typedef int si_int;
|
||||
typedef unsigned su_int;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +1,23 @@
|
|||
//===-- mulvsi3.c - Implement __mulvsi3 -----------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements __mulvsi3 for the compiler_rt library.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
/* ===-- mulvsi3.c - Implement __mulvsi3 -----------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __mulvsi3 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
// Returns: a * b
|
||||
/* Returns: a * b */
|
||||
|
||||
// Effects: aborts if a * b overflows
|
||||
/* Effects: aborts if a * b overflows */
|
||||
|
||||
si_int
|
||||
__mulvsi3(si_int a, si_int b)
|
||||
|
|
|
|||
|
|
@ -1,24 +1,25 @@
|
|||
//===-- mulvti3.c - Implement __mulvti3 -----------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements __mulvti3 for the compiler_rt library.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
/* ===-- mulvti3.c - Implement __mulvti3 -----------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __mulvti3 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if __x86_64
|
||||
|
||||
#include "int_lib.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
// Returns: a * b
|
||||
/* Returns: a * b */
|
||||
|
||||
// Effects: aborts if a * b overflows
|
||||
/* Effects: aborts if a * b overflows */
|
||||
|
||||
ti_int
|
||||
__mulvti3(ti_int a, ti_int b)
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
//===-- mulxc3.c - Implement __mulxc3 -------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements __mulxc3 for the compiler_rt library.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
/* ===-- mulxc3.c - Implement __mulxc3 -------------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __mulxc3 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if !_ARCH_PPC
|
||||
|
||||
|
|
@ -17,7 +18,7 @@
|
|||
#include <math.h>
|
||||
#include <complex.h>
|
||||
|
||||
// Returns: the product of a + ib and c + id
|
||||
/* Returns: the product of a + ib and c + id */
|
||||
|
||||
long double _Complex
|
||||
__mulxc3(long double __a, long double __b, long double __c, long double __d)
|
||||
|
|
|
|||
|
|
@ -1,35 +1,36 @@
|
|||
//===-- popcountdi2.c - Implement __popcountdi2 ----------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements __popcountdi2 for the compiler_rt library.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
/* ===-- popcountdi2.c - Implement __popcountdi2 ----------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __popcountdi2 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
// Returns: count of 1 bits
|
||||
/* Returns: count of 1 bits */
|
||||
|
||||
si_int
|
||||
__popcountdi2(di_int a)
|
||||
{
|
||||
du_int x2 = (du_int)a;
|
||||
x2 = x2 - ((x2 >> 1) & 0x5555555555555555uLL);
|
||||
// Every 2 bits holds the sum of every pair of bits (32)
|
||||
/* Every 2 bits holds the sum of every pair of bits (32) */
|
||||
x2 = ((x2 >> 2) & 0x3333333333333333uLL) + (x2 & 0x3333333333333333uLL);
|
||||
// Every 4 bits holds the sum of every 4-set of bits (3 significant bits) (16)
|
||||
/* Every 4 bits holds the sum of every 4-set of bits (3 significant bits) (16) */
|
||||
x2 = (x2 + (x2 >> 4)) & 0x0F0F0F0F0F0F0F0FuLL;
|
||||
// Every 8 bits holds the sum of every 8-set of bits (4 significant bits) (8)
|
||||
/* Every 8 bits holds the sum of every 8-set of bits (4 significant bits) (8) */
|
||||
su_int x = (su_int)(x2 + (x2 >> 32));
|
||||
// The lower 32 bits hold four 16 bit sums (5 significant bits).
|
||||
// Upper 32 bits are garbage
|
||||
/* The lower 32 bits hold four 16 bit sums (5 significant bits). */
|
||||
/* Upper 32 bits are garbage */
|
||||
x = x + (x >> 16);
|
||||
// The lower 16 bits hold two 32 bit sums (6 significant bits).
|
||||
// Upper 16 bits are garbage
|
||||
return (x + (x >> 8)) & 0x0000007F; // (7 significant bits)
|
||||
/* The lower 16 bits hold two 32 bit sums (6 significant bits). */
|
||||
/* Upper 16 bits are garbage */
|
||||
return (x + (x >> 8)) & 0x0000007F; /* (7 significant bits) */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,22 @@
|
|||
//===-- powitf2.cpp - Implement __powitf2 ---------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements __powitf2 for the compiler_rt library.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
/* ===-- powitf2.cpp - Implement __powitf2 ---------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __powitf2 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if _ARCH_PPC
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
// Returns: a ^ b
|
||||
/* Returns: a ^ b */
|
||||
|
||||
long double
|
||||
__powitf2(long double a, si_int b)
|
||||
|
|
|
|||
|
|
@ -1,21 +1,22 @@
|
|||
//===-- powixf2.cpp - Implement __powixf2 ---------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements __powixf2 for the compiler_rt library.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
/* ===-- powixf2.cpp - Implement __powixf2 ---------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __powixf2 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if !_ARCH_PPC
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
// Returns: a ^ b
|
||||
/* Returns: a ^ b */
|
||||
|
||||
long double
|
||||
__powixf2(long double a, si_int b)
|
||||
|
|
|
|||
|
|
@ -1,23 +1,25 @@
|
|||
//===-- ucmpti2.c - Implement __ucmpti2 -----------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements __ucmpti2 for the compiler_rt library.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
/* ===-- ucmpti2.c - Implement __ucmpti2 -----------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __ucmpti2 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if __x86_64
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
// Returns: if (a < b) returns 0
|
||||
// if (a == b) returns 1
|
||||
// if (a > b) returns 2
|
||||
/* Returns: if (a < b) returns 0
|
||||
* if (a == b) returns 1
|
||||
* if (a > b) returns 2
|
||||
*/
|
||||
|
||||
si_int
|
||||
__ucmpti2(tu_int a, tu_int b)
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
//===-- umodti3.c - Implement __umodti3 -----------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements __umodti3 for the compiler_rt library.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
/* ===-- umodti3.c - Implement __umodti3 -----------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
*
|
||||
* This file is distributed under the University of Illinois Open Source
|
||||
* License. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __umodti3 for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#if __x86_64
|
||||
|
||||
|
|
@ -17,7 +18,7 @@
|
|||
|
||||
tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem);
|
||||
|
||||
// Returns: a % b
|
||||
/* Returns: a % b */
|
||||
|
||||
tu_int
|
||||
__umodti3(tu_int a, tu_int b)
|
||||
|
|
|
|||
Loading…
Reference in New Issue