Import compiler-rt r259194. Primary changes are better support for
128bit long double and a number of refinements in the profiling backend.
This commit is contained in:
parent
17feded366
commit
ef84fd3bd8
|
@ -14,7 +14,7 @@ Full text of the relevant licenses is included below.
|
|||
University of Illinois/NCSA
|
||||
Open Source License
|
||||
|
||||
Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT
|
||||
Copyright (c) 2009-2015 by the contributors listed in CREDITS.TXT
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
@ -55,7 +55,7 @@ SOFTWARE.
|
|||
|
||||
==============================================================================
|
||||
|
||||
Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT
|
||||
Copyright (c) 2009-2015 by the contributors listed in CREDITS.TXT
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -220,7 +220,9 @@ _Unwind_Reason_Code __gcc_personality_v0(int version, _Unwind_Action actions,
|
|||
// for use with some implementations of assert() in <assert.h>
|
||||
void __eprintf(const char* format, const char* assertion_expression,
|
||||
const char* line, const char* file);
|
||||
|
||||
|
||||
// for systems with emulated thread local storage
|
||||
void* __emutls_get_address(struct __emutls_control*);
|
||||
|
||||
|
||||
// Power PC specific functions
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
COMPILER_RT_ABI di_int
|
||||
__addvdi3(di_int a, di_int b)
|
||||
{
|
||||
di_int s = a + b;
|
||||
di_int s = (du_int) a + (du_int) b;
|
||||
if (b >= 0)
|
||||
{
|
||||
if (s < a)
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
COMPILER_RT_ABI si_int
|
||||
__addvsi3(si_int a, si_int b)
|
||||
{
|
||||
si_int s = a + b;
|
||||
si_int s = (su_int) a + (su_int) b;
|
||||
if (b >= 0)
|
||||
{
|
||||
if (s < a)
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
COMPILER_RT_ABI ti_int
|
||||
__addvti3(ti_int a, ti_int b)
|
||||
{
|
||||
ti_int s = a + b;
|
||||
ti_int s = (tu_int) a + (tu_int) b;
|
||||
if (b >= 0)
|
||||
{
|
||||
if (s < a)
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
//===-- aeabi_cdcmp.S - EABI cdcmp* implementation ------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "../assembly.h"
|
||||
|
||||
#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__
|
||||
#error big endian support not implemented
|
||||
#endif
|
||||
|
||||
#define APSR_Z (1 << 30)
|
||||
#define APSR_C (1 << 29)
|
||||
|
||||
// void __aeabi_cdcmpeq(double a, double b) {
|
||||
// if (isnan(a) || isnan(b)) {
|
||||
// Z = 0; C = 1;
|
||||
// } else {
|
||||
// __aeabi_cdcmple(a, b);
|
||||
// }
|
||||
// }
|
||||
|
||||
.syntax unified
|
||||
.p2align 2
|
||||
DEFINE_COMPILERRT_FUNCTION(__aeabi_cdcmpeq)
|
||||
push {r0-r3, lr}
|
||||
bl __aeabi_cdcmpeq_check_nan
|
||||
cmp r0, #1
|
||||
pop {r0-r3, lr}
|
||||
|
||||
// NaN has been ruled out, so __aeabi_cdcmple can't trap
|
||||
bne __aeabi_cdcmple
|
||||
|
||||
msr CPSR_f, #APSR_C
|
||||
JMP(lr)
|
||||
END_COMPILERRT_FUNCTION(__aeabi_cdcmpeq)
|
||||
|
||||
|
||||
// void __aeabi_cdcmple(double a, double b) {
|
||||
// if (__aeabi_dcmplt(a, b)) {
|
||||
// Z = 0; C = 0;
|
||||
// } else if (__aeabi_dcmpeq(a, b)) {
|
||||
// Z = 1; C = 1;
|
||||
// } else {
|
||||
// Z = 0; C = 1;
|
||||
// }
|
||||
// }
|
||||
|
||||
.syntax unified
|
||||
.p2align 2
|
||||
DEFINE_COMPILERRT_FUNCTION(__aeabi_cdcmple)
|
||||
// Per the RTABI, this function must preserve r0-r11.
|
||||
// Save lr in the same instruction for compactness
|
||||
push {r0-r3, lr}
|
||||
|
||||
bl __aeabi_dcmplt
|
||||
cmp r0, #1
|
||||
moveq ip, #0
|
||||
beq 1f
|
||||
|
||||
ldm sp, {r0-r3}
|
||||
bl __aeabi_dcmpeq
|
||||
cmp r0, #1
|
||||
moveq ip, #(APSR_C | APSR_Z)
|
||||
movne ip, #(APSR_C)
|
||||
|
||||
1:
|
||||
msr CPSR_f, ip
|
||||
pop {r0-r3}
|
||||
POP_PC()
|
||||
END_COMPILERRT_FUNCTION(__aeabi_cdcmple)
|
||||
|
||||
// int __aeabi_cdrcmple(double a, double b) {
|
||||
// return __aeabi_cdcmple(b, a);
|
||||
// }
|
||||
|
||||
.syntax unified
|
||||
.p2align 2
|
||||
DEFINE_COMPILERRT_FUNCTION(__aeabi_cdrcmple)
|
||||
// Swap r0 and r2
|
||||
mov ip, r0
|
||||
mov r0, r2
|
||||
mov r2, ip
|
||||
|
||||
// Swap r1 and r3
|
||||
mov ip, r1
|
||||
mov r1, r3
|
||||
mov r3, ip
|
||||
|
||||
b __aeabi_cdcmple
|
||||
END_COMPILERRT_FUNCTION(__aeabi_cdrcmple)
|
||||
|
16
sys/external/bsd/compiler_rt/dist/lib/builtins/arm/aeabi_cdcmpeq_check_nan.c
vendored
Normal file
16
sys/external/bsd/compiler_rt/dist/lib/builtins/arm/aeabi_cdcmpeq_check_nan.c
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
//===-- lib/arm/aeabi_cdcmpeq_helper.c - Helper for cdcmpeq ---------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
__attribute__((pcs("aapcs")))
|
||||
__attribute__((visibility("hidden")))
|
||||
int __aeabi_cdcmpeq_check_nan(double a, double b) {
|
||||
return __builtin_isnan(a) || __builtin_isnan(b);
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
//===-- aeabi_cfcmp.S - EABI cfcmp* implementation ------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "../assembly.h"
|
||||
|
||||
#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__
|
||||
#error big endian support not implemented
|
||||
#endif
|
||||
|
||||
#define APSR_Z (1 << 30)
|
||||
#define APSR_C (1 << 29)
|
||||
|
||||
// void __aeabi_cfcmpeq(float a, float b) {
|
||||
// if (isnan(a) || isnan(b)) {
|
||||
// Z = 0; C = 1;
|
||||
// } else {
|
||||
// __aeabi_cfcmple(a, b);
|
||||
// }
|
||||
// }
|
||||
|
||||
.syntax unified
|
||||
.p2align 2
|
||||
DEFINE_COMPILERRT_FUNCTION(__aeabi_cfcmpeq)
|
||||
push {r0-r3, lr}
|
||||
bl __aeabi_cfcmpeq_check_nan
|
||||
cmp r0, #1
|
||||
pop {r0-r3, lr}
|
||||
|
||||
// NaN has been ruled out, so __aeabi_cfcmple can't trap
|
||||
bne __aeabi_cfcmple
|
||||
|
||||
msr CPSR_f, #APSR_C
|
||||
JMP(lr)
|
||||
END_COMPILERRT_FUNCTION(__aeabi_cfcmpeq)
|
||||
|
||||
|
||||
// void __aeabi_cfcmple(float a, float b) {
|
||||
// if (__aeabi_fcmplt(a, b)) {
|
||||
// Z = 0; C = 0;
|
||||
// } else if (__aeabi_fcmpeq(a, b)) {
|
||||
// Z = 1; C = 1;
|
||||
// } else {
|
||||
// Z = 0; C = 1;
|
||||
// }
|
||||
// }
|
||||
|
||||
.syntax unified
|
||||
.p2align 2
|
||||
DEFINE_COMPILERRT_FUNCTION(__aeabi_cfcmple)
|
||||
// Per the RTABI, this function must preserve r0-r11.
|
||||
// Save lr in the same instruction for compactness
|
||||
push {r0-r3, lr}
|
||||
|
||||
bl __aeabi_fcmplt
|
||||
cmp r0, #1
|
||||
moveq ip, #0
|
||||
beq 1f
|
||||
|
||||
ldm sp, {r0-r3}
|
||||
bl __aeabi_fcmpeq
|
||||
cmp r0, #1
|
||||
moveq ip, #(APSR_C | APSR_Z)
|
||||
movne ip, #(APSR_C)
|
||||
|
||||
1:
|
||||
msr CPSR_f, ip
|
||||
pop {r0-r3}
|
||||
POP_PC()
|
||||
END_COMPILERRT_FUNCTION(__aeabi_cfcmple)
|
||||
|
||||
// int __aeabi_cfrcmple(float a, float b) {
|
||||
// return __aeabi_cfcmple(b, a);
|
||||
// }
|
||||
|
||||
.syntax unified
|
||||
.p2align 2
|
||||
DEFINE_COMPILERRT_FUNCTION(__aeabi_cfrcmple)
|
||||
// Swap r0 and r1
|
||||
mov ip, r0
|
||||
mov r0, r1
|
||||
mov r1, ip
|
||||
|
||||
b __aeabi_cfcmple
|
||||
END_COMPILERRT_FUNCTION(__aeabi_cfrcmple)
|
||||
|
16
sys/external/bsd/compiler_rt/dist/lib/builtins/arm/aeabi_cfcmpeq_check_nan.c
vendored
Normal file
16
sys/external/bsd/compiler_rt/dist/lib/builtins/arm/aeabi_cfcmpeq_check_nan.c
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
//===-- lib/arm/aeabi_cfcmpeq_helper.c - Helper for cdcmpeq ---------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
__attribute__((pcs("aapcs")))
|
||||
__attribute__((visibility("hidden")))
|
||||
int __aeabi_cfcmpeq_check_nan(float a, float b) {
|
||||
return __builtin_isnan(a) || __builtin_isnan(b);
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
/* ===-- aeabi_div0.c - ARM Runtime ABI support routines for compiler-rt ---===
|
||||
*
|
||||
* 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 the division by zero helper routines as specified by the
|
||||
* Run-time ABI for the ARM Architecture.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
/*
|
||||
* RTABI 4.3.2 - Division by zero
|
||||
*
|
||||
* The *div0 functions:
|
||||
* - Return the value passed to them as a parameter
|
||||
* - Or, return a fixed value defined by the execution environment (such as 0)
|
||||
* - Or, raise a signal (often SIGFPE) or throw an exception, and do not return
|
||||
*
|
||||
* An application may provide its own implementations of the *div0 functions to
|
||||
* for a particular behaviour from the *div and *divmod functions called out of
|
||||
* line.
|
||||
*/
|
||||
|
||||
/* provide an unused declaration to pacify pendantic compilation */
|
||||
extern unsigned char declaration;
|
||||
|
||||
#if defined(__ARM_EABI__)
|
||||
int __attribute__((weak)) __attribute__((visibility("hidden")))
|
||||
__aeabi_idiv0(int return_value) {
|
||||
return return_value;
|
||||
}
|
||||
|
||||
long long __attribute__((weak)) __attribute__((visibility("hidden")))
|
||||
__aeabi_ldiv0(long long return_value) {
|
||||
return return_value;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
//===-- lib/arm/aeabi_drsub.c - Double-precision subtraction --------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#define DOUBLE_PRECISION
|
||||
#include "../fp_lib.h"
|
||||
|
||||
COMPILER_RT_ABI fp_t
|
||||
__aeabi_dsub(fp_t, fp_t);
|
||||
|
||||
COMPILER_RT_ABI fp_t
|
||||
__aeabi_drsub(fp_t a, fp_t b) {
|
||||
return __aeabi_dsub(b, a);
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
//===-- lib/arm/aeabi_frsub.c - Single-precision subtraction --------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#define SINGLE_PRECISION
|
||||
#include "../fp_lib.h"
|
||||
|
||||
COMPILER_RT_ABI fp_t
|
||||
__aeabi_fsub(fp_t, fp_t);
|
||||
|
||||
COMPILER_RT_ABI fp_t
|
||||
__aeabi_frsub(fp_t a, fp_t b) {
|
||||
return __aeabi_fsub(b, a);
|
||||
}
|
|
@ -21,7 +21,11 @@
|
|||
// Reverse all the bytes in a 64-bit integer.
|
||||
//
|
||||
.p2align 2
|
||||
#if __ARM_ARCH_ISA_THUMB == 2
|
||||
DEFINE_COMPILERRT_THUMB_FUNCTION(__bswapdi2)
|
||||
#else
|
||||
DEFINE_COMPILERRT_FUNCTION(__bswapdi2)
|
||||
#endif
|
||||
#if __ARM_ARCH < 6
|
||||
// before armv6 does not have "rev" instruction
|
||||
// r2 = rev(r0)
|
||||
|
|
|
@ -21,7 +21,11 @@
|
|||
// Reverse all the bytes in a 32-bit integer.
|
||||
//
|
||||
.p2align 2
|
||||
#if __ARM_ARCH_ISA_THUMB == 2
|
||||
DEFINE_COMPILERRT_THUMB_FUNCTION(__bswapsi2)
|
||||
#else
|
||||
DEFINE_COMPILERRT_FUNCTION(__bswapsi2)
|
||||
#endif
|
||||
#if __ARM_ARCH < 6
|
||||
// before armv6 does not have "rev" instruction
|
||||
eor r1, r0, r0, ror #16
|
||||
|
|
|
@ -21,7 +21,11 @@
|
|||
|
||||
|
||||
.p2align 2
|
||||
#if __ARM_ARCH_ISA_THUMB == 2
|
||||
DEFINE_COMPILERRT_THUMB_FUNCTION(__clzdi2)
|
||||
#else
|
||||
DEFINE_COMPILERRT_FUNCTION(__clzdi2)
|
||||
#endif
|
||||
#ifdef __ARM_FEATURE_CLZ
|
||||
#ifdef __ARMEB__
|
||||
cmp r0, 0
|
||||
|
|
|
@ -20,7 +20,11 @@
|
|||
#endif
|
||||
|
||||
.p2align 2
|
||||
#if __ARM_ARCH_ISA_THUMB == 2
|
||||
DEFINE_COMPILERRT_THUMB_FUNCTION(__clzsi2)
|
||||
#else
|
||||
DEFINE_COMPILERRT_FUNCTION(__clzsi2)
|
||||
#endif
|
||||
#ifdef __ARM_FEATURE_CLZ
|
||||
clz r0, r0
|
||||
JMP(lr)
|
||||
|
|
|
@ -32,7 +32,11 @@
|
|||
@ value is the quotient, the remainder is placed in the variable.
|
||||
|
||||
.p2align 3
|
||||
#if __ARM_ARCH_ISA_THUMB == 2
|
||||
DEFINE_COMPILERRT_THUMB_FUNCTION(__divmodsi4)
|
||||
#else
|
||||
DEFINE_COMPILERRT_FUNCTION(__divmodsi4)
|
||||
#endif
|
||||
#if __ARM_ARCH_EXT_IDIV__
|
||||
tst r1, r1
|
||||
beq LOCAL_LABEL(divzero)
|
||||
|
|
|
@ -33,7 +33,11 @@ DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_idiv, __divsi3)
|
|||
@ int __divsi3(int divident, int divisor)
|
||||
@ Calculate and return the quotient of the (signed) division.
|
||||
|
||||
#if __ARM_ARCH_ISA_THUMB == 2
|
||||
DEFINE_COMPILERRT_THUMB_FUNCTION(__divsi3)
|
||||
#else
|
||||
DEFINE_COMPILERRT_FUNCTION(__divsi3)
|
||||
#endif
|
||||
#if __ARM_ARCH_EXT_IDIV__
|
||||
tst r1,r1
|
||||
beq LOCAL_LABEL(divzero)
|
||||
|
|
|
@ -30,7 +30,11 @@
|
|||
@ Calculate and return the remainder of the (signed) division.
|
||||
|
||||
.p2align 3
|
||||
#if __ARM_ARCH_ISA_THUMB == 2
|
||||
DEFINE_COMPILERRT_THUMB_FUNCTION(__modsi3)
|
||||
#else
|
||||
DEFINE_COMPILERRT_FUNCTION(__modsi3)
|
||||
#endif
|
||||
#if __ARM_ARCH_EXT_IDIV__
|
||||
tst r1, r1
|
||||
beq LOCAL_LABEL(divzero)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
.p2align 2 ; \
|
||||
.thumb ; \
|
||||
.syntax unified ; \
|
||||
DEFINE_COMPILERRT_FUNCTION(__sync_fetch_and_ ## op) \
|
||||
DEFINE_COMPILERRT_THUMB_FUNCTION(__sync_fetch_and_ ## op) \
|
||||
dmb ; \
|
||||
mov r12, r0 ; \
|
||||
LOCAL_LABEL(tryatomic_ ## op): \
|
||||
|
@ -35,7 +35,7 @@
|
|||
.p2align 2 ; \
|
||||
.thumb ; \
|
||||
.syntax unified ; \
|
||||
DEFINE_COMPILERRT_FUNCTION(__sync_fetch_and_ ## op) \
|
||||
DEFINE_COMPILERRT_THUMB_FUNCTION(__sync_fetch_and_ ## op) \
|
||||
push {r4, r5, r6, lr} ; \
|
||||
dmb ; \
|
||||
mov r12, r0 ; \
|
||||
|
|
|
@ -14,9 +14,11 @@
|
|||
|
||||
#include "sync-ops.h"
|
||||
|
||||
#if __ARM_ARCH_PROFILE != 'M'
|
||||
#define add_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) \
|
||||
adds rD_LO, rN_LO, rM_LO ; \
|
||||
adc rD_HI, rN_HI, rM_HI
|
||||
|
||||
SYNC_OP_8(add_8)
|
||||
#endif
|
||||
|
||||
|
|
|
@ -14,8 +14,10 @@
|
|||
|
||||
#include "sync-ops.h"
|
||||
|
||||
#if __ARM_ARCH_PROFILE != 'M'
|
||||
#define and_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) \
|
||||
and rD_LO, rN_LO, rM_LO ; \
|
||||
and rD_HI, rN_HI, rM_HI
|
||||
|
||||
SYNC_OP_8(and_8)
|
||||
#endif
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include "sync-ops.h"
|
||||
|
||||
#if __ARM_ARCH_PROFILE != 'M'
|
||||
#define max_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) MINMAX_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI, gt)
|
||||
|
||||
SYNC_OP_8(max_8)
|
||||
#endif
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include "sync-ops.h"
|
||||
|
||||
#if __ARM_ARCH_PROFILE != 'M'
|
||||
#define min_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) MINMAX_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI, lt)
|
||||
|
||||
SYNC_OP_8(min_8)
|
||||
#endif
|
||||
|
|
|
@ -14,9 +14,11 @@
|
|||
|
||||
#include "sync-ops.h"
|
||||
|
||||
#if __ARM_ARCH_PROFILE != 'M'
|
||||
#define nand_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) \
|
||||
bic rD_LO, rN_LO, rM_LO ; \
|
||||
bic rD_HI, rN_HI, rM_HI
|
||||
|
||||
SYNC_OP_8(nand_8)
|
||||
#endif
|
||||
|
||||
|
|
|
@ -14,9 +14,11 @@
|
|||
|
||||
#include "sync-ops.h"
|
||||
|
||||
#if __ARM_ARCH_PROFILE != 'M'
|
||||
#define or_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) \
|
||||
orr rD_LO, rN_LO, rM_LO ; \
|
||||
orr rD_HI, rN_HI, rM_HI
|
||||
|
||||
SYNC_OP_8(or_8)
|
||||
#endif
|
||||
|
||||
|
|
|
@ -14,9 +14,11 @@
|
|||
|
||||
#include "sync-ops.h"
|
||||
|
||||
#if __ARM_ARCH_PROFILE != 'M'
|
||||
#define sub_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) \
|
||||
subs rD_LO, rN_LO, rM_LO ; \
|
||||
sbc rD_HI, rN_HI, rM_HI
|
||||
|
||||
SYNC_OP_8(sub_8)
|
||||
#endif
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include "sync-ops.h"
|
||||
|
||||
#if __ARM_ARCH_PROFILE != 'M'
|
||||
#define umax_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) MINMAX_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI, hi)
|
||||
|
||||
SYNC_OP_8(umax_8)
|
||||
#endif
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include "sync-ops.h"
|
||||
|
||||
#if __ARM_ARCH_PROFILE != 'M'
|
||||
#define umin_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) MINMAX_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI, lo)
|
||||
|
||||
SYNC_OP_8(umin_8)
|
||||
#endif
|
||||
|
|
|
@ -14,9 +14,11 @@
|
|||
|
||||
#include "sync-ops.h"
|
||||
|
||||
#if __ARM_ARCH_PROFILE != 'M'
|
||||
#define xor_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) \
|
||||
eor rD_LO, rN_LO, rM_LO ; \
|
||||
eor rD_HI, rN_HI, rM_HI
|
||||
|
||||
SYNC_OP_8(xor_8)
|
||||
#endif
|
||||
|
||||
|
|
|
@ -27,7 +27,11 @@
|
|||
@ value is the quotient, the remainder is placed in the variable.
|
||||
|
||||
.p2align 2
|
||||
#if __ARM_ARCH_ISA_THUMB == 2
|
||||
DEFINE_COMPILERRT_THUMB_FUNCTION(__udivmodsi4)
|
||||
#else
|
||||
DEFINE_COMPILERRT_FUNCTION(__udivmodsi4)
|
||||
#endif
|
||||
#if __ARM_ARCH_EXT_IDIV__
|
||||
tst r1, r1
|
||||
beq LOCAL_LABEL(divby0)
|
||||
|
|
|
@ -27,7 +27,11 @@ DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_uidiv, __udivsi3)
|
|||
@ unsigned int __udivsi3(unsigned int divident, unsigned int divisor)
|
||||
@ Calculate and return the quotient of the (unsigned) division.
|
||||
|
||||
#if __ARM_ARCH_ISA_THUMB == 2
|
||||
DEFINE_COMPILERRT_THUMB_FUNCTION(__udivsi3)
|
||||
#else
|
||||
DEFINE_COMPILERRT_FUNCTION(__udivsi3)
|
||||
#endif
|
||||
#if __ARM_ARCH_EXT_IDIV__
|
||||
tst r1, r1
|
||||
beq LOCAL_LABEL(divby0)
|
||||
|
|
|
@ -24,7 +24,11 @@
|
|||
@ Calculate and return the remainder of the (unsigned) division.
|
||||
|
||||
.p2align 2
|
||||
#if __ARM_ARCH_ISA_THUMB == 2
|
||||
DEFINE_COMPILERRT_THUMB_FUNCTION(__umodsi3)
|
||||
#else
|
||||
DEFINE_COMPILERRT_FUNCTION(__umodsi3)
|
||||
#endif
|
||||
#if __ARM_ARCH_EXT_IDIV__
|
||||
tst r1, r1
|
||||
beq LOCAL_LABEL(divby0)
|
||||
|
|
|
@ -28,7 +28,10 @@
|
|||
// tell linker it can break up file at label boundaries
|
||||
#define FILE_LEVEL_DIRECTIVE .subsections_via_symbols
|
||||
#define SYMBOL_IS_FUNC(name)
|
||||
#define CONST_SECTION .const
|
||||
|
||||
#elif defined(__ELF__)
|
||||
|
||||
#define HIDDEN(name) .hidden name
|
||||
#define LOCAL_LABEL(name) .L_##name
|
||||
#define FILE_LEVEL_DIRECTIVE
|
||||
|
@ -37,45 +40,23 @@
|
|||
#else
|
||||
#define SYMBOL_IS_FUNC(name) .type name,@function
|
||||
#endif
|
||||
#else
|
||||
#define HIDDEN_DIRECTIVE(name)
|
||||
#define CONST_SECTION .section .rodata
|
||||
|
||||
#else // !__APPLE__ && !__ELF__
|
||||
|
||||
#define HIDDEN(name)
|
||||
#define LOCAL_LABEL(name) .L ## name
|
||||
#define FILE_LEVEL_DIRECTIVE
|
||||
#define SYMBOL_IS_FUNC(name) \
|
||||
.def name SEPARATOR \
|
||||
.scl 2 SEPARATOR \
|
||||
.type 32 SEPARATOR \
|
||||
.endef
|
||||
#define FILE_LEVEL_DIRECTIVE
|
||||
#define CONST_SECTION .section .rdata,"rd"
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__arm__)
|
||||
#ifndef __ARM_ARCH
|
||||
#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \
|
||||
defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || \
|
||||
defined(__ARM_ARCH_7EM__)
|
||||
#define __ARM_ARCH 7
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __ARM_ARCH
|
||||
#if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \
|
||||
defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || \
|
||||
defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6ZM__)
|
||||
#define __ARM_ARCH 6
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __ARM_ARCH
|
||||
#if defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) || \
|
||||
defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__)
|
||||
#define __ARM_ARCH 5
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __ARM_ARCH
|
||||
#define __ARM_ARCH 4
|
||||
#endif
|
||||
|
||||
#if defined(__ARM_ARCH_4T__) || __ARM_ARCH >= 5
|
||||
#define ARM_HAS_BX
|
||||
#endif
|
||||
|
@ -92,6 +73,15 @@
|
|||
#define JMPc(r, c) mov##c pc, r
|
||||
#endif
|
||||
|
||||
// pop {pc} can't switch Thumb mode on ARMv4T
|
||||
#if __ARM_ARCH >= 5
|
||||
#define POP_PC() pop {pc}
|
||||
#else
|
||||
#define POP_PC() \
|
||||
pop {ip}; \
|
||||
JMP(ip)
|
||||
#endif
|
||||
|
||||
#if __ARM_ARCH_ISA_THUMB == 2
|
||||
#define IT(cond) it cond
|
||||
#define ITT(cond) itt cond
|
||||
|
@ -125,6 +115,14 @@
|
|||
DECLARE_SYMBOL_VISIBILITY(name) \
|
||||
SYMBOL_NAME(name):
|
||||
|
||||
#define DEFINE_COMPILERRT_THUMB_FUNCTION(name) \
|
||||
FILE_LEVEL_DIRECTIVE SEPARATOR \
|
||||
.globl SYMBOL_NAME(name) SEPARATOR \
|
||||
SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \
|
||||
DECLARE_SYMBOL_VISIBILITY(name) SEPARATOR \
|
||||
.thumb_func SEPARATOR \
|
||||
SYMBOL_NAME(name):
|
||||
|
||||
#define DEFINE_COMPILERRT_PRIVATE_FUNCTION(name) \
|
||||
FILE_LEVEL_DIRECTIVE SEPARATOR \
|
||||
.globl SYMBOL_NAME(name) SEPARATOR \
|
||||
|
|
|
@ -28,20 +28,14 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "assembly.h"
|
||||
|
||||
// Clang objects if you redefine a builtin. This little hack allows us to
|
||||
// define a function with the same name as an intrinsic.
|
||||
#if __APPLE__
|
||||
// mach-o has extra leading underscore
|
||||
#pragma redefine_extname __atomic_load_c ___atomic_load
|
||||
#pragma redefine_extname __atomic_store_c ___atomic_store
|
||||
#pragma redefine_extname __atomic_exchange_c ___atomic_exchange
|
||||
#pragma redefine_extname __atomic_compare_exchange_c ___atomic_compare_exchange
|
||||
#else
|
||||
#pragma redefine_extname __atomic_load_c __atomic_load
|
||||
#pragma redefine_extname __atomic_store_c __atomic_store
|
||||
#pragma redefine_extname __atomic_exchange_c __atomic_exchange
|
||||
#pragma redefine_extname __atomic_compare_exchange_c __atomic_compare_exchange
|
||||
#endif
|
||||
#pragma redefine_extname __atomic_load_c SYMBOL_NAME(__atomic_load)
|
||||
#pragma redefine_extname __atomic_store_c SYMBOL_NAME(__atomic_store)
|
||||
#pragma redefine_extname __atomic_exchange_c SYMBOL_NAME(__atomic_exchange)
|
||||
#pragma redefine_extname __atomic_compare_exchange_c SYMBOL_NAME(__atomic_compare_exchange)
|
||||
|
||||
/// Number of locks. This allocates one page on 32-bit platforms, two on
|
||||
/// 64-bit. This can be specified externally if a different trade between
|
||||
|
@ -62,13 +56,13 @@ static const long SPINLOCK_MASK = SPINLOCK_COUNT - 1;
|
|||
#include <machine/atomic.h>
|
||||
#include <sys/umtx.h>
|
||||
typedef struct _usem Lock;
|
||||
inline static void unlock(Lock *l) {
|
||||
__inline static void unlock(Lock *l) {
|
||||
__c11_atomic_store((_Atomic(uint32_t)*)&l->_count, 1, __ATOMIC_RELEASE);
|
||||
__c11_atomic_thread_fence(__ATOMIC_SEQ_CST);
|
||||
if (l->_has_waiters)
|
||||
_umtx_op(l, UMTX_OP_SEM_WAKE, 1, 0, 0);
|
||||
}
|
||||
inline static void lock(Lock *l) {
|
||||
__inline static void lock(Lock *l) {
|
||||
uint32_t old = 1;
|
||||
while (!__c11_atomic_compare_exchange_weak((_Atomic(uint32_t)*)&l->_count, &old,
|
||||
0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
|
||||
|
@ -82,12 +76,12 @@ static Lock locks[SPINLOCK_COUNT] = { [0 ... SPINLOCK_COUNT-1] = {0,1,0} };
|
|||
#elif defined(__APPLE__)
|
||||
#include <libkern/OSAtomic.h>
|
||||
typedef OSSpinLock Lock;
|
||||
inline static void unlock(Lock *l) {
|
||||
__inline static void unlock(Lock *l) {
|
||||
OSSpinLockUnlock(l);
|
||||
}
|
||||
/// Locks a lock. In the current implementation, this is potentially
|
||||
/// unbounded in the contended case.
|
||||
inline static void lock(Lock *l) {
|
||||
__inline static void lock(Lock *l) {
|
||||
OSSpinLockLock(l);
|
||||
}
|
||||
static Lock locks[SPINLOCK_COUNT]; // initialized to OS_SPINLOCK_INIT which is 0
|
||||
|
@ -95,12 +89,12 @@ static Lock locks[SPINLOCK_COUNT]; // initialized to OS_SPINLOCK_INIT which is 0
|
|||
#else
|
||||
typedef _Atomic(uintptr_t) Lock;
|
||||
/// Unlock a lock. This is a release operation.
|
||||
inline static void unlock(Lock *l) {
|
||||
__inline static void unlock(Lock *l) {
|
||||
__c11_atomic_store(l, 0, __ATOMIC_RELEASE);
|
||||
}
|
||||
/// Locks a lock. In the current implementation, this is potentially
|
||||
/// unbounded in the contended case.
|
||||
inline static void lock(Lock *l) {
|
||||
__inline static void lock(Lock *l) {
|
||||
uintptr_t old = 0;
|
||||
while (!__c11_atomic_compare_exchange_weak(l, &old, 1, __ATOMIC_ACQUIRE,
|
||||
__ATOMIC_RELAXED))
|
||||
|
@ -112,7 +106,7 @@ static Lock locks[SPINLOCK_COUNT];
|
|||
|
||||
|
||||
/// Returns a lock to use for a given pointer.
|
||||
static inline Lock *lock_for_pointer(void *ptr) {
|
||||
static __inline Lock *lock_for_pointer(void *ptr) {
|
||||
intptr_t hash = (intptr_t)ptr;
|
||||
// Disregard the lowest 4 bits. We want all values that may be part of the
|
||||
// same memory operation to hash to the same value and therefore use the same
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/*===-- atomic_flag_clear.c -------------------------------------------------===
|
||||
*
|
||||
* 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 atomic_flag_clear from C11's stdatomic.h.
|
||||
*
|
||||
*===------------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#ifndef __has_include
|
||||
#define __has_include(inc) 0
|
||||
#endif
|
||||
|
||||
#if __has_include(<stdatomic.h>)
|
||||
|
||||
#include <stdatomic.h>
|
||||
#undef atomic_flag_clear
|
||||
void atomic_flag_clear(volatile atomic_flag *object) {
|
||||
__c11_atomic_store(&(object)->_Value, 0, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,28 @@
|
|||
/*===-- atomic_flag_clear_explicit.c ----------------------------------------===
|
||||
*
|
||||
* 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 atomic_flag_clear_explicit from C11's stdatomic.h.
|
||||
*
|
||||
*===------------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#ifndef __has_include
|
||||
#define __has_include(inc) 0
|
||||
#endif
|
||||
|
||||
#if __has_include(<stdatomic.h>)
|
||||
|
||||
#include <stdatomic.h>
|
||||
#undef atomic_flag_clear_explicit
|
||||
void atomic_flag_clear_explicit(volatile atomic_flag *object,
|
||||
memory_order order) {
|
||||
__c11_atomic_store(&(object)->_Value, 0, order);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,27 @@
|
|||
/*===-- atomic_flag_test_and_set.c ------------------------------------------===
|
||||
*
|
||||
* 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 atomic_flag_test_and_set from C11's stdatomic.h.
|
||||
*
|
||||
*===------------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#ifndef __has_include
|
||||
#define __has_include(inc) 0
|
||||
#endif
|
||||
|
||||
#if __has_include(<stdatomic.h>)
|
||||
|
||||
#include <stdatomic.h>
|
||||
#undef atomic_flag_test_and_set
|
||||
_Bool atomic_flag_test_and_set(volatile atomic_flag *object) {
|
||||
return __c11_atomic_exchange(&(object)->_Value, 1, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
#endif
|
28
sys/external/bsd/compiler_rt/dist/lib/builtins/atomic_flag_test_and_set_explicit.c
vendored
Normal file
28
sys/external/bsd/compiler_rt/dist/lib/builtins/atomic_flag_test_and_set_explicit.c
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*===-- atomic_flag_test_and_set_explicit.c ---------------------------------===
|
||||
*
|
||||
* 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 atomic_flag_test_and_set_explicit from C11's stdatomic.h
|
||||
*
|
||||
*===------------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#ifndef __has_include
|
||||
#define __has_include(inc) 0
|
||||
#endif
|
||||
|
||||
#if __has_include(<stdatomic.h>)
|
||||
|
||||
#include <stdatomic.h>
|
||||
#undef atomic_flag_test_and_set_explicit
|
||||
_Bool atomic_flag_test_and_set_explicit(volatile atomic_flag *object,
|
||||
memory_order order) {
|
||||
return __c11_atomic_exchange(&(object)->_Value, 1, order);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,27 @@
|
|||
/*===-- atomic_signal_fence.c -----------------------------------------------===
|
||||
*
|
||||
* 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 atomic_signal_fence from C11's stdatomic.h.
|
||||
*
|
||||
*===------------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#ifndef __has_include
|
||||
#define __has_include(inc) 0
|
||||
#endif
|
||||
|
||||
#if __has_include(<stdatomic.h>)
|
||||
|
||||
#include <stdatomic.h>
|
||||
#undef atomic_signal_fence
|
||||
void atomic_signal_fence(memory_order order) {
|
||||
__c11_atomic_signal_fence(order);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,27 @@
|
|||
/*===-- atomic_thread_fence.c -----------------------------------------------===
|
||||
*
|
||||
* 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 atomic_thread_fence from C11's stdatomic.h.
|
||||
*
|
||||
*===------------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#ifndef __has_include
|
||||
#define __has_include(inc) 0
|
||||
#endif
|
||||
|
||||
#if __has_include(<stdatomic.h>)
|
||||
|
||||
#include <stdatomic.h>
|
||||
#undef atomic_thread_fence
|
||||
void atomic_thread_fence(memory_order order) {
|
||||
__c11_atomic_thread_fence(order);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -9,19 +9,71 @@
|
|||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
#include <stddef.h>
|
||||
|
||||
#if __APPLE__
|
||||
#include <libkern/OSCacheControl.h>
|
||||
#endif
|
||||
#if (defined(__FreeBSD__) || defined(__Bitrig__)) && defined(__arm__)
|
||||
#include <sys/types.h>
|
||||
#include <machine/sysarch.h>
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) && defined(__arm__)
|
||||
#include <machine/sysarch.h>
|
||||
#endif
|
||||
|
||||
#if defined(ANDROID) && defined(__mips__)
|
||||
#if defined(__mips__)
|
||||
#include <sys/cachectl.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
#if defined(__ANDROID__) && defined(__LP64__)
|
||||
/*
|
||||
* clear_mips_cache - Invalidates instruction cache for Mips.
|
||||
*/
|
||||
static void clear_mips_cache(const void* Addr, size_t Size) {
|
||||
asm volatile (
|
||||
".set push\n"
|
||||
".set noreorder\n"
|
||||
".set noat\n"
|
||||
"beq %[Size], $zero, 20f\n" /* If size == 0, branch around. */
|
||||
"nop\n"
|
||||
"daddu %[Size], %[Addr], %[Size]\n" /* Calculate end address + 1 */
|
||||
"rdhwr $v0, $1\n" /* Get step size for SYNCI.
|
||||
$1 is $HW_SYNCI_Step */
|
||||
"beq $v0, $zero, 20f\n" /* If no caches require
|
||||
synchronization, branch
|
||||
around. */
|
||||
"nop\n"
|
||||
"10:\n"
|
||||
"synci 0(%[Addr])\n" /* Synchronize all caches around
|
||||
address. */
|
||||
"daddu %[Addr], %[Addr], $v0\n" /* Add step size. */
|
||||
"sltu $at, %[Addr], %[Size]\n" /* Compare current with end
|
||||
address. */
|
||||
"bne $at, $zero, 10b\n" /* Branch if more to do. */
|
||||
"nop\n"
|
||||
"sync\n" /* Clear memory hazards. */
|
||||
"20:\n"
|
||||
"bal 30f\n"
|
||||
"nop\n"
|
||||
"30:\n"
|
||||
"daddiu $ra, $ra, 12\n" /* $ra has a value of $pc here.
|
||||
Add offset of 12 to point to the
|
||||
instruction after the last nop.
|
||||
*/
|
||||
"jr.hb $ra\n" /* Return, clearing instruction
|
||||
hazards. */
|
||||
"nop\n"
|
||||
".set pop\n"
|
||||
: [Addr] "+r"(Addr), [Size] "+r"(Size)
|
||||
:: "at", "ra", "v0", "memory"
|
||||
);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(ANDROID) && defined(__arm__)
|
||||
#if defined(__ANDROID__) && defined(__arm__)
|
||||
#include <asm/unistd.h>
|
||||
#endif
|
||||
|
||||
|
@ -32,24 +84,22 @@
|
|||
* specified range.
|
||||
*/
|
||||
|
||||
COMPILER_RT_EXPORT void
|
||||
__clear_cache(void* start, void* end)
|
||||
{
|
||||
void __clear_cache(void *start, void *end) {
|
||||
#if __i386__ || __x86_64__
|
||||
/*
|
||||
* Intel processors have a unified instruction and data cache
|
||||
* so there is nothing to do
|
||||
*/
|
||||
#elif defined(__arm__) && !defined(__APPLE__)
|
||||
#if defined(__NetBSD__)
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__Bitrig__)
|
||||
struct arm_sync_icache_args arg;
|
||||
|
||||
arg.addr = (uintptr_t)start;
|
||||
arg.len = (uintptr_t)end - (uintptr_t)start;
|
||||
|
||||
sysarch(ARM_SYNC_ICACHE, &arg);
|
||||
#elif defined(ANDROID)
|
||||
const register int start_reg __asm("r0") = (int) (intptr_t) start;
|
||||
#elif defined(__ANDROID__)
|
||||
register int start_reg __asm("r0") = (int) (intptr_t) start;
|
||||
const register int end_reg __asm("r1") = (int) (intptr_t) end;
|
||||
const register int flags __asm("r2") = 0;
|
||||
const register int syscall_nr __asm("r7") = __ARM_NR_cacheflush;
|
||||
|
@ -61,13 +111,24 @@ __clear_cache(void* start, void* end)
|
|||
#else
|
||||
compilerrt_abort();
|
||||
#endif
|
||||
#elif defined(ANDROID) && defined(__mips__)
|
||||
#elif defined(__mips__)
|
||||
const uintptr_t start_int = (uintptr_t) start;
|
||||
const uintptr_t end_int = (uintptr_t) end;
|
||||
_flush_cache(start, (end_int - start_int), BCACHE);
|
||||
#if defined(__ANDROID__) && defined(__LP64__)
|
||||
// Call synci implementation for short address range.
|
||||
const uintptr_t address_range_limit = 256;
|
||||
if ((end_int - start_int) <= address_range_limit) {
|
||||
clear_mips_cache(start, (end_int - start_int));
|
||||
} else {
|
||||
syscall(__NR_cacheflush, start, (end_int - start_int), BCACHE);
|
||||
}
|
||||
#else
|
||||
syscall(__NR_cacheflush, start, (end_int - start_int), BCACHE);
|
||||
#endif
|
||||
#elif defined(__aarch64__) && !defined(__APPLE__)
|
||||
uint64_t xstart = (uint64_t)(uintptr_t) start;
|
||||
uint64_t xend = (uint64_t)(uintptr_t) end;
|
||||
uint64_t addr;
|
||||
|
||||
// Get Cache Type Info
|
||||
uint64_t ctr_el0;
|
||||
|
@ -78,12 +139,12 @@ __clear_cache(void* start, void* end)
|
|||
* uintptr_t in case this runs in an IPL32 environment.
|
||||
*/
|
||||
const size_t dcache_line_size = 4 << ((ctr_el0 >> 16) & 15);
|
||||
for (uint64_t addr = xstart; addr < xend; addr += dcache_line_size)
|
||||
for (addr = xstart; addr < xend; addr += dcache_line_size)
|
||||
__asm __volatile("dc cvau, %0" :: "r"(addr));
|
||||
__asm __volatile("dsb ish");
|
||||
|
||||
const size_t icache_line_size = 4 << ((ctr_el0 >> 0) & 15);
|
||||
for (uint64_t addr = xstart; addr < xend; addr += icache_line_size)
|
||||
for (addr = xstart; addr < xend; addr += icache_line_size)
|
||||
__asm __volatile("ic ivau, %0" :: "r"(addr));
|
||||
__asm __volatile("isb sy");
|
||||
#else
|
||||
|
|
|
@ -80,6 +80,11 @@ __ledf2(fp_t a, fp_t b) {
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(__ELF__)
|
||||
// Alias for libgcc compatibility
|
||||
FNALIAS(__cmpdf2, __ledf2);
|
||||
#endif
|
||||
|
||||
enum GE_RESULT {
|
||||
GE_LESS = -1,
|
||||
GE_EQUAL = 0,
|
||||
|
|
|
@ -80,6 +80,11 @@ __lesf2(fp_t a, fp_t b) {
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(__ELF__)
|
||||
// Alias for libgcc compatibility
|
||||
FNALIAS(__cmpsf2, __lesf2);
|
||||
#endif
|
||||
|
||||
enum GE_RESULT {
|
||||
GE_LESS = -1,
|
||||
GE_EQUAL = 0,
|
||||
|
|
|
@ -79,6 +79,11 @@ COMPILER_RT_ABI enum LE_RESULT __letf2(fp_t a, fp_t b) {
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(__ELF__)
|
||||
// Alias for libgcc compatibility
|
||||
FNALIAS(__cmptf2, __letf2);
|
||||
#endif
|
||||
|
||||
enum GE_RESULT {
|
||||
GE_LESS = -1,
|
||||
GE_EQUAL = 0,
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
/* Returns: the quotient of (a + ib) / (c + id) */
|
||||
|
||||
COMPILER_RT_ABI double _Complex
|
||||
COMPILER_RT_ABI Dcomplex
|
||||
__divdc3(double __a, double __b, double __c, double __d)
|
||||
{
|
||||
int __ilogbw = 0;
|
||||
|
@ -29,31 +29,31 @@ __divdc3(double __a, double __b, double __c, double __d)
|
|||
__d = crt_scalbn(__d, -__ilogbw);
|
||||
}
|
||||
double __denom = __c * __c + __d * __d;
|
||||
double _Complex z;
|
||||
__real__ z = crt_scalbn((__a * __c + __b * __d) / __denom, -__ilogbw);
|
||||
__imag__ z = crt_scalbn((__b * __c - __a * __d) / __denom, -__ilogbw);
|
||||
if (crt_isnan(__real__ z) && crt_isnan(__imag__ z))
|
||||
Dcomplex z;
|
||||
COMPLEX_REAL(z) = crt_scalbn((__a * __c + __b * __d) / __denom, -__ilogbw);
|
||||
COMPLEX_IMAGINARY(z) = crt_scalbn((__b * __c - __a * __d) / __denom, -__ilogbw);
|
||||
if (crt_isnan(COMPLEX_REAL(z)) && crt_isnan(COMPLEX_IMAGINARY(z)))
|
||||
{
|
||||
if ((__denom == 0.0) && (!crt_isnan(__a) || !crt_isnan(__b)))
|
||||
{
|
||||
__real__ z = crt_copysign(CRT_INFINITY, __c) * __a;
|
||||
__imag__ z = crt_copysign(CRT_INFINITY, __c) * __b;
|
||||
COMPLEX_REAL(z) = crt_copysign(CRT_INFINITY, __c) * __a;
|
||||
COMPLEX_IMAGINARY(z) = crt_copysign(CRT_INFINITY, __c) * __b;
|
||||
}
|
||||
else if ((crt_isinf(__a) || crt_isinf(__b)) &&
|
||||
crt_isfinite(__c) && crt_isfinite(__d))
|
||||
{
|
||||
__a = crt_copysign(crt_isinf(__a) ? 1.0 : 0.0, __a);
|
||||
__b = crt_copysign(crt_isinf(__b) ? 1.0 : 0.0, __b);
|
||||
__real__ z = CRT_INFINITY * (__a * __c + __b * __d);
|
||||
__imag__ z = CRT_INFINITY * (__b * __c - __a * __d);
|
||||
COMPLEX_REAL(z) = CRT_INFINITY * (__a * __c + __b * __d);
|
||||
COMPLEX_IMAGINARY(z) = CRT_INFINITY * (__b * __c - __a * __d);
|
||||
}
|
||||
else if (crt_isinf(__logbw) && __logbw > 0.0 &&
|
||||
crt_isfinite(__a) && crt_isfinite(__b))
|
||||
{
|
||||
__c = crt_copysign(crt_isinf(__c) ? 1.0 : 0.0, __c);
|
||||
__d = crt_copysign(crt_isinf(__d) ? 1.0 : 0.0, __d);
|
||||
__real__ z = 0.0 * (__a * __c + __b * __d);
|
||||
__imag__ z = 0.0 * (__b * __c - __a * __d);
|
||||
COMPLEX_REAL(z) = 0.0 * (__a * __c + __b * __d);
|
||||
COMPLEX_IMAGINARY(z) = 0.0 * (__b * __c - __a * __d);
|
||||
}
|
||||
}
|
||||
return z;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
/* Returns: the quotient of (a + ib) / (c + id) */
|
||||
|
||||
COMPILER_RT_ABI float _Complex
|
||||
COMPILER_RT_ABI Fcomplex
|
||||
__divsc3(float __a, float __b, float __c, float __d)
|
||||
{
|
||||
int __ilogbw = 0;
|
||||
|
@ -29,31 +29,31 @@ __divsc3(float __a, float __b, float __c, float __d)
|
|||
__d = crt_scalbnf(__d, -__ilogbw);
|
||||
}
|
||||
float __denom = __c * __c + __d * __d;
|
||||
float _Complex z;
|
||||
__real__ z = crt_scalbnf((__a * __c + __b * __d) / __denom, -__ilogbw);
|
||||
__imag__ z = crt_scalbnf((__b * __c - __a * __d) / __denom, -__ilogbw);
|
||||
if (crt_isnan(__real__ z) && crt_isnan(__imag__ z))
|
||||
Fcomplex z;
|
||||
COMPLEX_REAL(z) = crt_scalbnf((__a * __c + __b * __d) / __denom, -__ilogbw);
|
||||
COMPLEX_IMAGINARY(z) = crt_scalbnf((__b * __c - __a * __d) / __denom, -__ilogbw);
|
||||
if (crt_isnan(COMPLEX_REAL(z)) && crt_isnan(COMPLEX_IMAGINARY(z)))
|
||||
{
|
||||
if ((__denom == 0) && (!crt_isnan(__a) || !crt_isnan(__b)))
|
||||
{
|
||||
__real__ z = crt_copysignf(CRT_INFINITY, __c) * __a;
|
||||
__imag__ z = crt_copysignf(CRT_INFINITY, __c) * __b;
|
||||
COMPLEX_REAL(z) = crt_copysignf(CRT_INFINITY, __c) * __a;
|
||||
COMPLEX_IMAGINARY(z) = crt_copysignf(CRT_INFINITY, __c) * __b;
|
||||
}
|
||||
else if ((crt_isinf(__a) || crt_isinf(__b)) &&
|
||||
crt_isfinite(__c) && crt_isfinite(__d))
|
||||
{
|
||||
__a = crt_copysignf(crt_isinf(__a) ? 1 : 0, __a);
|
||||
__b = crt_copysignf(crt_isinf(__b) ? 1 : 0, __b);
|
||||
__real__ z = CRT_INFINITY * (__a * __c + __b * __d);
|
||||
__imag__ z = CRT_INFINITY * (__b * __c - __a * __d);
|
||||
COMPLEX_REAL(z) = CRT_INFINITY * (__a * __c + __b * __d);
|
||||
COMPLEX_IMAGINARY(z) = CRT_INFINITY * (__b * __c - __a * __d);
|
||||
}
|
||||
else if (crt_isinf(__logbw) && __logbw > 0 &&
|
||||
crt_isfinite(__a) && crt_isfinite(__b))
|
||||
{
|
||||
__c = crt_copysignf(crt_isinf(__c) ? 1 : 0, __c);
|
||||
__d = crt_copysignf(crt_isinf(__d) ? 1 : 0, __d);
|
||||
__real__ z = 0 * (__a * __c + __b * __d);
|
||||
__imag__ z = 0 * (__b * __c - __a * __d);
|
||||
COMPLEX_REAL(z) = 0 * (__a * __c + __b * __d);
|
||||
COMPLEX_IMAGINARY(z) = 0 * (__b * __c - __a * __d);
|
||||
}
|
||||
}
|
||||
return z;
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/*===-- divtc3.c - Implement __divtc3 -------------------------------------===
|
||||
*
|
||||
* 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 __divtc3 for the compiler_rt library.
|
||||
*
|
||||
*===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
#include "int_math.h"
|
||||
|
||||
/* Returns: the quotient of (a + ib) / (c + id) */
|
||||
|
||||
COMPILER_RT_ABI long double _Complex
|
||||
__divtc3(long double __a, long double __b, long double __c, long double __d)
|
||||
{
|
||||
int __ilogbw = 0;
|
||||
long double __logbw = crt_logbl(crt_fmaxl(crt_fabsl(__c), crt_fabsl(__d)));
|
||||
if (crt_isfinite(__logbw))
|
||||
{
|
||||
__ilogbw = (int)__logbw;
|
||||
__c = crt_scalbnl(__c, -__ilogbw);
|
||||
__d = crt_scalbnl(__d, -__ilogbw);
|
||||
}
|
||||
long double __denom = __c * __c + __d * __d;
|
||||
long double _Complex z;
|
||||
__real__ z = crt_scalbnl((__a * __c + __b * __d) / __denom, -__ilogbw);
|
||||
__imag__ z = crt_scalbnl((__b * __c - __a * __d) / __denom, -__ilogbw);
|
||||
if (crt_isnan(__real__ z) && crt_isnan(__imag__ z))
|
||||
{
|
||||
if ((__denom == 0.0) && (!crt_isnan(__a) || !crt_isnan(__b)))
|
||||
{
|
||||
__real__ z = crt_copysignl(CRT_INFINITY, __c) * __a;
|
||||
__imag__ z = crt_copysignl(CRT_INFINITY, __c) * __b;
|
||||
}
|
||||
else if ((crt_isinf(__a) || crt_isinf(__b)) &&
|
||||
crt_isfinite(__c) && crt_isfinite(__d))
|
||||
{
|
||||
__a = crt_copysignl(crt_isinf(__a) ? 1.0 : 0.0, __a);
|
||||
__b = crt_copysignl(crt_isinf(__b) ? 1.0 : 0.0, __b);
|
||||
__real__ z = CRT_INFINITY * (__a * __c + __b * __d);
|
||||
__imag__ z = CRT_INFINITY * (__b * __c - __a * __d);
|
||||
}
|
||||
else if (crt_isinf(__logbw) && __logbw > 0.0 &&
|
||||
crt_isfinite(__a) && crt_isfinite(__b))
|
||||
{
|
||||
__c = crt_copysignl(crt_isinf(__c) ? 1.0 : 0.0, __c);
|
||||
__d = crt_copysignl(crt_isinf(__d) ? 1.0 : 0.0, __d);
|
||||
__real__ z = 0.0 * (__a * __c + __b * __d);
|
||||
__imag__ z = 0.0 * (__b * __c - __a * __d);
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
/* Returns: the quotient of (a + ib) / (c + id) */
|
||||
|
||||
COMPILER_RT_ABI long double _Complex
|
||||
COMPILER_RT_ABI Lcomplex
|
||||
__divxc3(long double __a, long double __b, long double __c, long double __d)
|
||||
{
|
||||
int __ilogbw = 0;
|
||||
|
@ -30,31 +30,31 @@ __divxc3(long double __a, long double __b, long double __c, long double __d)
|
|||
__d = crt_scalbnl(__d, -__ilogbw);
|
||||
}
|
||||
long double __denom = __c * __c + __d * __d;
|
||||
long double _Complex z;
|
||||
__real__ z = crt_scalbnl((__a * __c + __b * __d) / __denom, -__ilogbw);
|
||||
__imag__ z = crt_scalbnl((__b * __c - __a * __d) / __denom, -__ilogbw);
|
||||
if (crt_isnan(__real__ z) && crt_isnan(__imag__ z))
|
||||
Lcomplex z;
|
||||
COMPLEX_REAL(z) = crt_scalbnl((__a * __c + __b * __d) / __denom, -__ilogbw);
|
||||
COMPLEX_IMAGINARY(z) = crt_scalbnl((__b * __c - __a * __d) / __denom, -__ilogbw);
|
||||
if (crt_isnan(COMPLEX_REAL(z)) && crt_isnan(COMPLEX_IMAGINARY(z)))
|
||||
{
|
||||
if ((__denom == 0) && (!crt_isnan(__a) || !crt_isnan(__b)))
|
||||
{
|
||||
__real__ z = crt_copysignl(CRT_INFINITY, __c) * __a;
|
||||
__imag__ z = crt_copysignl(CRT_INFINITY, __c) * __b;
|
||||
COMPLEX_REAL(z) = crt_copysignl(CRT_INFINITY, __c) * __a;
|
||||
COMPLEX_IMAGINARY(z) = crt_copysignl(CRT_INFINITY, __c) * __b;
|
||||
}
|
||||
else if ((crt_isinf(__a) || crt_isinf(__b)) &&
|
||||
crt_isfinite(__c) && crt_isfinite(__d))
|
||||
{
|
||||
__a = crt_copysignl(crt_isinf(__a) ? 1 : 0, __a);
|
||||
__b = crt_copysignl(crt_isinf(__b) ? 1 : 0, __b);
|
||||
__real__ z = CRT_INFINITY * (__a * __c + __b * __d);
|
||||
__imag__ z = CRT_INFINITY * (__b * __c - __a * __d);
|
||||
COMPLEX_REAL(z) = CRT_INFINITY * (__a * __c + __b * __d);
|
||||
COMPLEX_IMAGINARY(z) = CRT_INFINITY * (__b * __c - __a * __d);
|
||||
}
|
||||
else if (crt_isinf(__logbw) && __logbw > 0 &&
|
||||
crt_isfinite(__a) && crt_isfinite(__b))
|
||||
{
|
||||
__c = crt_copysignl(crt_isinf(__c) ? 1 : 0, __c);
|
||||
__d = crt_copysignl(crt_isinf(__d) ? 1 : 0, __d);
|
||||
__real__ z = 0 * (__a * __c + __b * __d);
|
||||
__imag__ z = 0 * (__b * __c - __a * __d);
|
||||
COMPLEX_REAL(z) = 0 * (__a * __c + __b * __d);
|
||||
COMPLEX_IMAGINARY(z) = 0 * (__b * __c - __a * __d);
|
||||
}
|
||||
}
|
||||
return z;
|
||||
|
|
|
@ -0,0 +1,183 @@
|
|||
/* ===---------- emutls.c - Implements __emutls_get_address ---------------===
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "int_lib.h"
|
||||
#include "int_util.h"
|
||||
|
||||
/* Default is not to use posix_memalign, so systems like Android
|
||||
* can use thread local data without heavier POSIX memory allocators.
|
||||
*/
|
||||
#ifndef EMUTLS_USE_POSIX_MEMALIGN
|
||||
#define EMUTLS_USE_POSIX_MEMALIGN 0
|
||||
#endif
|
||||
|
||||
/* For every TLS variable xyz,
|
||||
* there is one __emutls_control variable named __emutls_v.xyz.
|
||||
* If xyz has non-zero initial value, __emutls_v.xyz's "value"
|
||||
* will point to __emutls_t.xyz, which has the initial value.
|
||||
*/
|
||||
typedef struct __emutls_control {
|
||||
size_t size; /* size of the object in bytes */
|
||||
size_t align; /* alignment of the object in bytes */
|
||||
union {
|
||||
uintptr_t index; /* data[index-1] is the object address */
|
||||
void* address; /* object address, when in single thread env */
|
||||
} object;
|
||||
void* value; /* null or non-zero initial value for the object */
|
||||
} __emutls_control;
|
||||
|
||||
static __inline void *emutls_memalign_alloc(size_t align, size_t size) {
|
||||
void *base;
|
||||
#if EMUTLS_USE_POSIX_MEMALIGN
|
||||
if (posix_memalign(&base, align, size) != 0)
|
||||
abort();
|
||||
#else
|
||||
#define EXTRA_ALIGN_PTR_BYTES (align - 1 + sizeof(void*))
|
||||
char* object;
|
||||
if ((object = malloc(EXTRA_ALIGN_PTR_BYTES + size)) == NULL)
|
||||
abort();
|
||||
base = (void*)(((uintptr_t)(object + EXTRA_ALIGN_PTR_BYTES))
|
||||
& ~(uintptr_t)(align - 1));
|
||||
|
||||
((void**)base)[-1] = object;
|
||||
#endif
|
||||
return base;
|
||||
}
|
||||
|
||||
static __inline void emutls_memalign_free(void *base) {
|
||||
#if EMUTLS_USE_POSIX_MEMALIGN
|
||||
free(base);
|
||||
#else
|
||||
/* The mallocated address is in ((void**)base)[-1] */
|
||||
free(((void**)base)[-1]);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Emulated TLS objects are always allocated at run-time. */
|
||||
static __inline void *emutls_allocate_object(__emutls_control *control) {
|
||||
/* Use standard C types, check with gcc's emutls.o. */
|
||||
typedef unsigned int gcc_word __attribute__((mode(word)));
|
||||
typedef unsigned int gcc_pointer __attribute__((mode(pointer)));
|
||||
COMPILE_TIME_ASSERT(sizeof(size_t) == sizeof(gcc_word));
|
||||
COMPILE_TIME_ASSERT(sizeof(uintptr_t) == sizeof(gcc_pointer));
|
||||
COMPILE_TIME_ASSERT(sizeof(uintptr_t) == sizeof(void*));
|
||||
|
||||
size_t size = control->size;
|
||||
size_t align = control->align;
|
||||
if (align < sizeof(void*))
|
||||
align = sizeof(void*);
|
||||
/* Make sure that align is power of 2. */
|
||||
if ((align & (align - 1)) != 0)
|
||||
abort();
|
||||
|
||||
void* base = emutls_memalign_alloc(align, size);
|
||||
if (control->value)
|
||||
memcpy(base, control->value, size);
|
||||
else
|
||||
memset(base, 0, size);
|
||||
return base;
|
||||
}
|
||||
|
||||
static pthread_mutex_t emutls_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static size_t emutls_num_object = 0; /* number of allocated TLS objects */
|
||||
|
||||
typedef struct emutls_address_array {
|
||||
uintptr_t size; /* number of elements in the 'data' array */
|
||||
void* data[];
|
||||
} emutls_address_array;
|
||||
|
||||
static pthread_key_t emutls_pthread_key;
|
||||
|
||||
static void emutls_key_destructor(void* ptr) {
|
||||
emutls_address_array* array = (emutls_address_array*)ptr;
|
||||
uintptr_t i;
|
||||
for (i = 0; i < array->size; ++i) {
|
||||
if (array->data[i])
|
||||
emutls_memalign_free(array->data[i]);
|
||||
}
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
static void emutls_init(void) {
|
||||
if (pthread_key_create(&emutls_pthread_key, emutls_key_destructor) != 0)
|
||||
abort();
|
||||
}
|
||||
|
||||
/* Returns control->object.index; set index if not allocated yet. */
|
||||
static __inline uintptr_t emutls_get_index(__emutls_control *control) {
|
||||
uintptr_t index = __atomic_load_n(&control->object.index, __ATOMIC_ACQUIRE);
|
||||
if (!index) {
|
||||
static pthread_once_t once = PTHREAD_ONCE_INIT;
|
||||
pthread_once(&once, emutls_init);
|
||||
pthread_mutex_lock(&emutls_mutex);
|
||||
index = control->object.index;
|
||||
if (!index) {
|
||||
index = ++emutls_num_object;
|
||||
__atomic_store_n(&control->object.index, index, __ATOMIC_RELEASE);
|
||||
}
|
||||
pthread_mutex_unlock(&emutls_mutex);
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
/* Updates newly allocated thread local emutls_address_array. */
|
||||
static __inline void emutls_check_array_set_size(emutls_address_array *array,
|
||||
uintptr_t size) {
|
||||
if (array == NULL)
|
||||
abort();
|
||||
array->size = size;
|
||||
pthread_setspecific(emutls_pthread_key, (void*)array);
|
||||
}
|
||||
|
||||
/* Returns the new 'data' array size, number of elements,
|
||||
* which must be no smaller than the given index.
|
||||
*/
|
||||
static __inline uintptr_t emutls_new_data_array_size(uintptr_t index) {
|
||||
/* Need to allocate emutls_address_array with one extra slot
|
||||
* to store the data array size.
|
||||
* Round up the emutls_address_array size to multiple of 16.
|
||||
*/
|
||||
return ((index + 1 + 15) & ~((uintptr_t)15)) - 1;
|
||||
}
|
||||
|
||||
/* Returns the thread local emutls_address_array.
|
||||
* Extends its size if necessary to hold address at index.
|
||||
*/
|
||||
static __inline emutls_address_array *
|
||||
emutls_get_address_array(uintptr_t index) {
|
||||
emutls_address_array* array = pthread_getspecific(emutls_pthread_key);
|
||||
if (array == NULL) {
|
||||
uintptr_t new_size = emutls_new_data_array_size(index);
|
||||
array = calloc(new_size + 1, sizeof(void*));
|
||||
emutls_check_array_set_size(array, new_size);
|
||||
} else if (index > array->size) {
|
||||
uintptr_t orig_size = array->size;
|
||||
uintptr_t new_size = emutls_new_data_array_size(index);
|
||||
array = realloc(array, (new_size + 1) * sizeof(void*));
|
||||
if (array)
|
||||
memset(array->data + orig_size, 0,
|
||||
(new_size - orig_size) * sizeof(void*));
|
||||
emutls_check_array_set_size(array, new_size);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
void* __emutls_get_address(__emutls_control* control) {
|
||||
uintptr_t index = emutls_get_index(control);
|
||||
emutls_address_array* array = emutls_get_address_array(index);
|
||||
if (array->data[index - 1] == NULL)
|
||||
array->data[index - 1] = emutls_allocate_object(control);
|
||||
return array->data[index - 1];
|
||||
}
|
|
@ -10,7 +10,9 @@
|
|||
|
||||
#include "int_lib.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
/* #include "config.h"
|
||||
* FIXME: CMake - include when cmake system is ready.
|
||||
|
@ -18,9 +20,14 @@
|
|||
*/
|
||||
#define HAVE_SYSCONF 1
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#ifndef __APPLE__
|
||||
#include <unistd.h>
|
||||
#endif /* __APPLE__ */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#if __LP64__
|
||||
#define TRAMPOLINE_SIZE 48
|
||||
|
@ -40,6 +47,12 @@ COMPILER_RT_ABI void
|
|||
__enable_execute_stack(void* addr)
|
||||
{
|
||||
|
||||
#if _WIN32
|
||||
MEMORY_BASIC_INFORMATION mbi;
|
||||
if (!VirtualQuery (addr, &mbi, sizeof(mbi)))
|
||||
return; /* We should probably assert here because there is no return value */
|
||||
VirtualProtect (mbi.BaseAddress, mbi.RegionSize, PAGE_EXECUTE_READWRITE, &mbi.Protect);
|
||||
#else
|
||||
#if __APPLE__
|
||||
/* On Darwin, pagesize is always 4096 bytes */
|
||||
const uintptr_t pageSize = 4096;
|
||||
|
@ -55,4 +68,5 @@ __enable_execute_stack(void* addr)
|
|||
unsigned char* endPage = (unsigned char*)((p+TRAMPOLINE_SIZE+pageSize) & pageAlignMask);
|
||||
size_t length = endPage - startPage;
|
||||
(void) mprotect((void *)startPage, length, PROT_READ | PROT_WRITE | PROT_EXEC);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
//===-- lib/extendhfsf2.c - half -> single conversion -------------*- C -*-===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
|
||||
#define SRC_HALF
|
||||
#define DST_SINGLE
|
||||
#include "fp_extend_impl.inc"
|
||||
|
||||
ARM_EABI_FNALIAS(h2f, extendhfsf2)
|
||||
|
||||
// Use a forwarding definition and noinline to implement a poor man's alias,
|
||||
// as there isn't a good cross-platform way of defining one.
|
||||
COMPILER_RT_ABI NOINLINE float __extendhfsf2(uint16_t a) {
|
||||
return __extendXfYf2__(a);
|
||||
}
|
||||
|
||||
COMPILER_RT_ABI float __gnu_h2f_ieee(uint16_t a) {
|
||||
return __extendhfsf2(a);
|
||||
}
|
|
@ -6,40 +6,41 @@
|
|||
* Source Licenses. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __fixdfdi for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: convert a to a signed long long, rounding toward zero. */
|
||||
|
||||
/* Assumption: double is a IEEE 64 bit floating point type
|
||||
* su_int is a 32 bit integral type
|
||||
* value in double is representable in di_int (no range checking performed)
|
||||
*/
|
||||
|
||||
/* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */
|
||||
|
||||
#define DOUBLE_PRECISION
|
||||
#include "fp_lib.h"
|
||||
ARM_EABI_FNALIAS(d2lz, fixdfdi)
|
||||
|
||||
#ifndef __SOFT_FP__
|
||||
/* Support for systems that have hardware floating-point; can set the invalid
|
||||
* flag as a side-effect of computation.
|
||||
*/
|
||||
|
||||
COMPILER_RT_ABI du_int __fixunsdfdi(double a);
|
||||
|
||||
COMPILER_RT_ABI di_int
|
||||
__fixdfdi(double a)
|
||||
{
|
||||
double_bits fb;
|
||||
fb.f = a;
|
||||
int e = ((fb.u.s.high & 0x7FF00000) >> 20) - 1023;
|
||||
if (e < 0)
|
||||
return 0;
|
||||
di_int s = (si_int)(fb.u.s.high & 0x80000000) >> 31;
|
||||
dwords r;
|
||||
r.s.high = (fb.u.s.high & 0x000FFFFF) | 0x00100000;
|
||||
r.s.low = fb.u.s.low;
|
||||
if (e > 52)
|
||||
r.all <<= (e - 52);
|
||||
else
|
||||
r.all >>= (52 - e);
|
||||
return (r.all ^ s) - s;
|
||||
}
|
||||
if (a < 0.0) {
|
||||
return -__fixunsdfdi(-a);
|
||||
}
|
||||
return __fixunsdfdi(a);
|
||||
}
|
||||
|
||||
#else
|
||||
/* Support for systems that don't have hardware floating-point; there are no
|
||||
* flags to set, and we don't want to code-gen to an unknown soft-float
|
||||
* implementation.
|
||||
*/
|
||||
|
||||
typedef di_int fixint_t;
|
||||
typedef du_int fixuint_t;
|
||||
#include "fp_fixint_impl.inc"
|
||||
|
||||
COMPILER_RT_ABI di_int
|
||||
__fixdfdi(fp_t a) {
|
||||
return __fixint(a);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,50 +1,22 @@
|
|||
//===-- lib/fixdfsi.c - Double-precision -> integer conversion ----*- C -*-===//
|
||||
//
|
||||
// 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 double-precision to integer conversion for the
|
||||
// compiler-rt library. No range checking is performed; the behavior of this
|
||||
// conversion is undefined for out of range values in the C standard.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
/* ===-- fixdfsi.c - Implement __fixdfsi -----------------------------------===
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#define DOUBLE_PRECISION
|
||||
#include "fp_lib.h"
|
||||
|
||||
#include "int_lib.h"
|
||||
typedef si_int fixint_t;
|
||||
typedef su_int fixuint_t;
|
||||
#include "fp_fixint_impl.inc"
|
||||
|
||||
ARM_EABI_FNALIAS(d2iz, fixdfsi)
|
||||
|
||||
COMPILER_RT_ABI int
|
||||
COMPILER_RT_ABI si_int
|
||||
__fixdfsi(fp_t a) {
|
||||
|
||||
// Break a into sign, exponent, significand
|
||||
const rep_t aRep = toRep(a);
|
||||
const rep_t aAbs = aRep & absMask;
|
||||
const int sign = aRep & signBit ? -1 : 1;
|
||||
const int exponent = (aAbs >> significandBits) - exponentBias;
|
||||
const rep_t significand = (aAbs & significandMask) | implicitBit;
|
||||
|
||||
// If 0 < exponent < significandBits, right shift to get the result.
|
||||
if ((unsigned int)exponent < significandBits) {
|
||||
return sign * (significand >> (significandBits - exponent));
|
||||
}
|
||||
|
||||
// If exponent is negative, the result is zero.
|
||||
else if (exponent < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// If significandBits < exponent, left shift to get the result. This shift
|
||||
// may end up being larger than the type width, which incurs undefined
|
||||
// behavior, but the conversion itself is undefined in that case, so
|
||||
// whatever the compiler decides to do is fine.
|
||||
else {
|
||||
return sign * (significand << (exponent - significandBits));
|
||||
}
|
||||
return __fixint(a);
|
||||
}
|
||||
|
|
|
@ -6,40 +6,21 @@
|
|||
* Source Licenses. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __fixdfti for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
#ifdef CRT_HAS_128BIT
|
||||
#define DOUBLE_PRECISION
|
||||
#include "fp_lib.h"
|
||||
|
||||
/* Returns: convert a to a signed long long, rounding toward zero. */
|
||||
|
||||
/* Assumption: double is a IEEE 64 bit floating point type
|
||||
* su_int is a 32 bit integral type
|
||||
* value in double is representable in ti_int (no range checking performed)
|
||||
*/
|
||||
|
||||
/* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */
|
||||
typedef ti_int fixint_t;
|
||||
typedef tu_int fixuint_t;
|
||||
#include "fp_fixint_impl.inc"
|
||||
|
||||
COMPILER_RT_ABI ti_int
|
||||
__fixdfti(double a)
|
||||
{
|
||||
double_bits fb;
|
||||
fb.f = a;
|
||||
int e = ((fb.u.s.high & 0x7FF00000) >> 20) - 1023;
|
||||
if (e < 0)
|
||||
return 0;
|
||||
ti_int s = (si_int)(fb.u.s.high & 0x80000000) >> 31;
|
||||
ti_int r = 0x0010000000000000uLL | (0x000FFFFFFFFFFFFFuLL & fb.u.all);
|
||||
if (e > 52)
|
||||
r <<= (e - 52);
|
||||
else
|
||||
r >>= (52 - e);
|
||||
return (r ^ s) - s;
|
||||
__fixdfti(fp_t a) {
|
||||
return __fixint(a);
|
||||
}
|
||||
|
||||
#endif /* CRT_HAS_128BIT */
|
||||
|
|
|
@ -1,43 +1,47 @@
|
|||
/* ===-- fixsfdi.c - Implement __fixsfdi -----------------------------------===
|
||||
*
|
||||
* The LLVM Compiler Infrastructure
|
||||
* 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 __fixsfdi for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* 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 di_int (no range checking performed)
|
||||
*/
|
||||
|
||||
/* seee eeee emmm mmmm mmmm mmmm mmmm mmmm */
|
||||
#define SINGLE_PRECISION
|
||||
#include "fp_lib.h"
|
||||
|
||||
ARM_EABI_FNALIAS(f2lz, fixsfdi)
|
||||
|
||||
#ifndef __SOFT_FP__
|
||||
/* Support for systems that have hardware floating-point; can set the invalid
|
||||
* flag as a side-effect of computation.
|
||||
*/
|
||||
|
||||
COMPILER_RT_ABI du_int __fixunssfdi(float a);
|
||||
|
||||
COMPILER_RT_ABI di_int
|
||||
__fixsfdi(float a)
|
||||
{
|
||||
float_bits fb;
|
||||
fb.f = a;
|
||||
int e = ((fb.u & 0x7F800000) >> 23) - 127;
|
||||
if (e < 0)
|
||||
return 0;
|
||||
di_int s = (si_int)(fb.u & 0x80000000) >> 31;
|
||||
di_int r = (fb.u & 0x007FFFFF) | 0x00800000;
|
||||
if (e > 23)
|
||||
r <<= (e - 23);
|
||||
else
|
||||
r >>= (23 - e);
|
||||
return (r ^ s) - s;
|
||||
if (a < 0.0f) {
|
||||
return -__fixunssfdi(-a);
|
||||
}
|
||||
return __fixunssfdi(a);
|
||||
}
|
||||
|
||||
#else
|
||||
/* Support for systems that don't have hardware floating-point; there are no
|
||||
* flags to set, and we don't want to code-gen to an unknown soft-float
|
||||
* implementation.
|
||||
*/
|
||||
|
||||
typedef di_int fixint_t;
|
||||
typedef du_int fixuint_t;
|
||||
#include "fp_fixint_impl.inc"
|
||||
|
||||
COMPILER_RT_ABI di_int
|
||||
__fixsfdi(fp_t a) {
|
||||
return __fixint(a);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,47 +1,22 @@
|
|||
//===-- lib/fixsfsi.c - Single-precision -> integer conversion ----*- C -*-===//
|
||||
//
|
||||
// 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 single-precision to integer conversion for the
|
||||
// compiler-rt library. No range checking is performed; the behavior of this
|
||||
// conversion is undefined for out of range values in the C standard.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
/* ===-- fixsfsi.c - Implement __fixsfsi -----------------------------------===
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#define SINGLE_PRECISION
|
||||
#include "fp_lib.h"
|
||||
typedef si_int fixint_t;
|
||||
typedef su_int fixuint_t;
|
||||
#include "fp_fixint_impl.inc"
|
||||
|
||||
ARM_EABI_FNALIAS(f2iz, fixsfsi)
|
||||
|
||||
COMPILER_RT_ABI int
|
||||
COMPILER_RT_ABI si_int
|
||||
__fixsfsi(fp_t a) {
|
||||
// Break a into sign, exponent, significand
|
||||
const rep_t aRep = toRep(a);
|
||||
const rep_t aAbs = aRep & absMask;
|
||||
const int sign = aRep & signBit ? -1 : 1;
|
||||
const int exponent = (aAbs >> significandBits) - exponentBias;
|
||||
const rep_t significand = (aAbs & significandMask) | implicitBit;
|
||||
|
||||
// If 0 < exponent < significandBits, right shift to get the result.
|
||||
if ((unsigned int)exponent < significandBits) {
|
||||
return sign * (significand >> (significandBits - exponent));
|
||||
}
|
||||
|
||||
// If exponent is negative, the result is zero.
|
||||
else if (exponent < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// If significandBits < exponent, left shift to get the result. This shift
|
||||
// may end up being larger than the type width, which incurs undefined
|
||||
// behavior, but the conversion itself is undefined in that case, so
|
||||
// whatever the compiler decides to do is fine.
|
||||
else {
|
||||
return sign * (significand << (exponent - significandBits));
|
||||
}
|
||||
return __fixint(a);
|
||||
}
|
||||
|
|
|
@ -6,40 +6,21 @@
|
|||
* Source Licenses. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __fixsfti for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
#ifdef CRT_HAS_128BIT
|
||||
#define SINGLE_PRECISION
|
||||
#include "fp_lib.h"
|
||||
|
||||
/* 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)
|
||||
*/
|
||||
|
||||
/* seee eeee emmm mmmm mmmm mmmm mmmm mmmm */
|
||||
typedef ti_int fixint_t;
|
||||
typedef tu_int fixuint_t;
|
||||
#include "fp_fixint_impl.inc"
|
||||
|
||||
COMPILER_RT_ABI ti_int
|
||||
__fixsfti(float a)
|
||||
{
|
||||
float_bits fb;
|
||||
fb.f = a;
|
||||
int e = ((fb.u & 0x7F800000) >> 23) - 127;
|
||||
if (e < 0)
|
||||
return 0;
|
||||
ti_int s = (si_int)(fb.u & 0x80000000) >> 31;
|
||||
ti_int r = (fb.u & 0x007FFFFF) | 0x00800000;
|
||||
if (e > 23)
|
||||
r <<= (e - 23);
|
||||
else
|
||||
r >>= (23 - e);
|
||||
return (r ^ s) - s;
|
||||
__fixsfti(fp_t a) {
|
||||
return __fixint(a);
|
||||
}
|
||||
|
||||
#endif /* CRT_HAS_128BIT */
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/* ===-- fixtfdi.c - Implement __fixtfdi -----------------------------------===
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#define QUAD_PRECISION
|
||||
#include "fp_lib.h"
|
||||
|
||||
#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
|
||||
typedef di_int fixint_t;
|
||||
typedef du_int fixuint_t;
|
||||
#include "fp_fixint_impl.inc"
|
||||
|
||||
COMPILER_RT_ABI di_int
|
||||
__fixtfdi(fp_t a) {
|
||||
return __fixint(a);
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,23 @@
|
|||
/* ===-- fixtfsi.c - Implement __fixtfsi -----------------------------------===
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#define QUAD_PRECISION
|
||||
#include "fp_lib.h"
|
||||
|
||||
#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
|
||||
typedef si_int fixint_t;
|
||||
typedef su_int fixuint_t;
|
||||
#include "fp_fixint_impl.inc"
|
||||
|
||||
COMPILER_RT_ABI si_int
|
||||
__fixtfsi(fp_t a) {
|
||||
return __fixint(a);
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,23 @@
|
|||
/* ===-- fixtfti.c - Implement __fixtfti -----------------------------------===
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#define QUAD_PRECISION
|
||||
#include "fp_lib.h"
|
||||
|
||||
#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
|
||||
typedef ti_int fixint_t;
|
||||
typedef tu_int fixuint_t;
|
||||
#include "fp_fixint_impl.inc"
|
||||
|
||||
COMPILER_RT_ABI ti_int
|
||||
__fixtfti(fp_t a) {
|
||||
return __fixint(a);
|
||||
}
|
||||
#endif
|
|
@ -6,42 +6,39 @@
|
|||
* Source Licenses. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __fixunsdfdi for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: convert a to a unsigned long long, rounding toward zero.
|
||||
* Negative values all become zero.
|
||||
*/
|
||||
|
||||
/* Assumption: double is a IEEE 64 bit floating point type
|
||||
* du_int is a 64 bit integral type
|
||||
* value in double is representable in du_int or is negative
|
||||
* (no range checking performed)
|
||||
*/
|
||||
|
||||
/* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */
|
||||
#define DOUBLE_PRECISION
|
||||
#include "fp_lib.h"
|
||||
|
||||
ARM_EABI_FNALIAS(d2ulz, fixunsdfdi)
|
||||
|
||||
#ifndef __SOFT_FP__
|
||||
/* Support for systems that have hardware floating-point; can set the invalid
|
||||
* flag as a side-effect of computation.
|
||||
*/
|
||||
|
||||
COMPILER_RT_ABI du_int
|
||||
__fixunsdfdi(double a)
|
||||
{
|
||||
double_bits fb;
|
||||
fb.f = a;
|
||||
int e = ((fb.u.s.high & 0x7FF00000) >> 20) - 1023;
|
||||
if (e < 0 || (fb.u.s.high & 0x80000000))
|
||||
return 0;
|
||||
udwords r;
|
||||
r.s.high = (fb.u.s.high & 0x000FFFFF) | 0x00100000;
|
||||
r.s.low = fb.u.s.low;
|
||||
if (e > 52)
|
||||
r.all <<= (e - 52);
|
||||
else
|
||||
r.all >>= (52 - e);
|
||||
return r.all;
|
||||
if (a <= 0.0) return 0;
|
||||
su_int high = a / 4294967296.f; /* a / 0x1p32f; */
|
||||
su_int low = a - (double)high * 4294967296.f; /* high * 0x1p32f; */
|
||||
return ((du_int)high << 32) | low;
|
||||
}
|
||||
|
||||
#else
|
||||
/* Support for systems that don't have hardware floating-point; there are no
|
||||
* flags to set, and we don't want to code-gen to an unknown soft-float
|
||||
* implementation.
|
||||
*/
|
||||
|
||||
typedef du_int fixuint_t;
|
||||
#include "fp_fixuint_impl.inc"
|
||||
|
||||
COMPILER_RT_ABI du_int
|
||||
__fixunsdfdi(fp_t a) {
|
||||
return __fixuint(a);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -6,39 +6,16 @@
|
|||
* Source Licenses. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __fixunsdfsi for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: convert a to a unsigned int, rounding toward zero.
|
||||
* Negative values all become zero.
|
||||
*/
|
||||
|
||||
/* Assumption: double is a IEEE 64 bit floating point type
|
||||
* su_int is a 32 bit integral type
|
||||
* value in double is representable in su_int or is negative
|
||||
* (no range checking performed)
|
||||
*/
|
||||
|
||||
/* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */
|
||||
#define DOUBLE_PRECISION
|
||||
#include "fp_lib.h"
|
||||
typedef su_int fixuint_t;
|
||||
#include "fp_fixuint_impl.inc"
|
||||
|
||||
ARM_EABI_FNALIAS(d2uiz, fixunsdfsi)
|
||||
|
||||
COMPILER_RT_ABI su_int
|
||||
__fixunsdfsi(double a)
|
||||
{
|
||||
double_bits fb;
|
||||
fb.f = a;
|
||||
int e = ((fb.u.s.high & 0x7FF00000) >> 20) - 1023;
|
||||
if (e < 0 || (fb.u.s.high & 0x80000000))
|
||||
return 0;
|
||||
return (
|
||||
0x80000000u |
|
||||
((fb.u.s.high & 0x000FFFFF) << 11) |
|
||||
(fb.u.s.low >> 21)
|
||||
) >> (31 - e);
|
||||
__fixunsdfsi(fp_t a) {
|
||||
return __fixuint(a);
|
||||
}
|
||||
|
|
|
@ -6,42 +6,18 @@
|
|||
* Source Licenses. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __fixunsdfti for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
#ifdef CRT_HAS_128BIT
|
||||
|
||||
/* Returns: convert a to a unsigned long long, rounding toward zero.
|
||||
* Negative values all become zero.
|
||||
*/
|
||||
|
||||
/* Assumption: double is a IEEE 64 bit floating point type
|
||||
* tu_int is a 64 bit integral type
|
||||
* value in double is representable in tu_int or is negative
|
||||
* (no range checking performed)
|
||||
*/
|
||||
|
||||
/* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */
|
||||
#define DOUBLE_PRECISION
|
||||
#include "fp_lib.h"
|
||||
typedef tu_int fixuint_t;
|
||||
#include "fp_fixuint_impl.inc"
|
||||
|
||||
COMPILER_RT_ABI tu_int
|
||||
__fixunsdfti(double a)
|
||||
{
|
||||
double_bits fb;
|
||||
fb.f = a;
|
||||
int e = ((fb.u.s.high & 0x7FF00000) >> 20) - 1023;
|
||||
if (e < 0 || (fb.u.s.high & 0x80000000))
|
||||
return 0;
|
||||
tu_int r = 0x0010000000000000uLL | (fb.u.all & 0x000FFFFFFFFFFFFFuLL);
|
||||
if (e > 52)
|
||||
r <<= (e - 52);
|
||||
else
|
||||
r >>= (52 - e);
|
||||
return r;
|
||||
__fixunsdfti(fp_t a) {
|
||||
return __fixuint(a);
|
||||
}
|
||||
|
||||
#endif /* CRT_HAS_128BIT */
|
||||
|
|
|
@ -6,39 +6,40 @@
|
|||
* Source Licenses. See LICENSE.TXT for details.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*
|
||||
* This file implements __fixunssfdi for the compiler_rt library.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
/* Returns: convert a to a unsigned long long, rounding toward zero.
|
||||
* Negative values all become zero.
|
||||
*/
|
||||
|
||||
/* Assumption: float is a IEEE 32 bit floating point type
|
||||
* du_int is a 64 bit integral type
|
||||
* value in float is representable in du_int or is negative
|
||||
* (no range checking performed)
|
||||
*/
|
||||
|
||||
/* seee eeee emmm mmmm mmmm mmmm mmmm mmmm */
|
||||
#define SINGLE_PRECISION
|
||||
#include "fp_lib.h"
|
||||
|
||||
ARM_EABI_FNALIAS(f2ulz, fixunssfdi)
|
||||
|
||||
#ifndef __SOFT_FP__
|
||||
/* Support for systems that have hardware floating-point; can set the invalid
|
||||
* flag as a side-effect of computation.
|
||||
*/
|
||||
|
||||
COMPILER_RT_ABI du_int
|
||||
__fixunssfdi(float a)
|
||||
{
|
||||
float_bits fb;
|
||||
fb.f = a;
|
||||
int e = ((fb.u & 0x7F800000) >> 23) - 127;
|
||||
if (e < 0 || (fb.u & 0x80000000))
|
||||
return 0;
|
||||
du_int r = (fb.u & 0x007FFFFF) | 0x00800000;
|
||||
if (e > 23)
|
||||
r <<= (e - 23);
|
||||
else
|
||||
r >>= (23 - e);
|
||||
return r;
|
||||
if (a <= 0.0f) return 0;
|
||||
double da = a;
|
||||
su_int high = da / 4294967296.f; /* da / 0x1p32f; */
|
||||
su_int low = da - (double)high * 4294967296.f; /* high * 0x1p32f; */
|
||||
return ((du_int)high << 32) | low;
|
||||
}
|
||||
|
||||
#else
|
||||
/* Support for systems that don't have hardware floating-point; there are no
|
||||
* flags to set, and we don't want to code-gen to an unknown soft-float
|
||||
* implementation.
|
||||
*/
|
||||
|
||||
typedef du_int fixuint_t;
|
||||
#include "fp_fixuint_impl.inc"
|
||||
|
||||
COMPILER_RT_ABI du_int
|
||||
__fixunssfdi(fp_t a) {
|
||||
return __fixuint(a);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -12,34 +12,14 @@
|
|||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: convert a to a unsigned int, rounding toward zero.
|
||||
* Negative values all become 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 su_int or is negative
|
||||
* (no range checking performed)
|
||||
*/
|
||||
|
||||
/* seee eeee emmm mmmm mmmm mmmm mmmm mmmm */
|
||||
#define SINGLE_PRECISION
|
||||
#include "fp_lib.h"
|
||||
typedef su_int fixuint_t;
|
||||
#include "fp_fixuint_impl.inc"
|
||||
|
||||
ARM_EABI_FNALIAS(f2uiz, fixunssfsi)
|
||||
|
||||
COMPILER_RT_ABI su_int
|
||||
__fixunssfsi(float a)
|
||||
{
|
||||
float_bits fb;
|
||||
fb.f = a;
|
||||
int e = ((fb.u & 0x7F800000) >> 23) - 127;
|
||||
if (e < 0 || (fb.u & 0x80000000))
|
||||
return 0;
|
||||
su_int r = (fb.u & 0x007FFFFF) | 0x00800000;
|
||||
if (e > 23)
|
||||
r <<= (e - 23);
|
||||
else
|
||||
r >>= (23 - e);
|
||||
return r;
|
||||
__fixunssfsi(fp_t a) {
|
||||
return __fixuint(a);
|
||||
}
|
||||
|
|
|
@ -12,36 +12,15 @@
|
|||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "int_lib.h"
|
||||
#define SINGLE_PRECISION
|
||||
#include "fp_lib.h"
|
||||
|
||||
#ifdef CRT_HAS_128BIT
|
||||
|
||||
/* Returns: convert a to a unsigned long long, rounding toward zero.
|
||||
* Negative values all become zero.
|
||||
*/
|
||||
|
||||
/* Assumption: float is a IEEE 32 bit floating point type
|
||||
* tu_int is a 64 bit integral type
|
||||
* value in float is representable in tu_int or is negative
|
||||
* (no range checking performed)
|
||||
*/
|
||||
|
||||
/* seee eeee emmm mmmm mmmm mmmm mmmm mmmm */
|
||||
#if defined(CRT_HAS_128BIT)
|
||||
typedef tu_int fixuint_t;
|
||||
#include "fp_fixuint_impl.inc"
|
||||
|
||||
COMPILER_RT_ABI tu_int
|
||||
__fixunssfti(float a)
|
||||
{
|
||||
float_bits fb;
|
||||
fb.f = a;
|
||||
int e = ((fb.u & 0x7F800000) >> 23) - 127;
|
||||
if (e < 0 || (fb.u & 0x80000000))
|
||||
return 0;
|
||||
tu_int r = (fb.u & 0x007FFFFF) | 0x00800000;
|
||||
if (e > 23)
|
||||
r <<= (e - 23);
|
||||
else
|
||||
r >>= (23 - e);
|
||||
return r;
|
||||
__fixunssfti(fp_t a) {
|
||||
return __fixuint(a);
|
||||
}
|
||||
|
||||
#endif /* CRT_HAS_128BIT */
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
/* ===-- fixunstfdi.c - Implement __fixunstfdi -----------------------------===
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#define QUAD_PRECISION
|
||||
#include "fp_lib.h"
|
||||
|
||||
#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
|
||||
typedef du_int fixuint_t;
|
||||
#include "fp_fixuint_impl.inc"
|
||||
|
||||
COMPILER_RT_ABI du_int
|
||||
__fixunstfdi(fp_t a) {
|
||||
return __fixuint(a);
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,22 @@
|
|||
/* ===-- fixunstfsi.c - Implement __fixunstfsi -----------------------------===
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#define QUAD_PRECISION
|
||||
#include "fp_lib.h"
|
||||
|
||||
#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
|
||||
typedef su_int fixuint_t;
|
||||
#include "fp_fixuint_impl.inc"
|
||||
|
||||
COMPILER_RT_ABI su_int
|
||||
__fixunstfsi(fp_t a) {
|
||||
return __fixuint(a);
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,22 @@
|
|||
/* ===-- fixunstfsi.c - Implement __fixunstfsi -----------------------------===
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* ===----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#define QUAD_PRECISION
|
||||
#include "fp_lib.h"
|
||||
|
||||
#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
|
||||
typedef tu_int fixuint_t;
|
||||
#include "fp_fixuint_impl.inc"
|
||||
|
||||
COMPILER_RT_ABI tu_int
|
||||
__fixunstfti(fp_t a) {
|
||||
return __fixuint(a);
|
||||
}
|
||||
#endif
|
|
@ -38,6 +38,8 @@ __fixunsxfdi(long double a)
|
|||
int e = (fb.u.high.s.low & 0x00007FFF) - 16383;
|
||||
if (e < 0 || (fb.u.high.s.low & 0x00008000))
|
||||
return 0;
|
||||
if ((unsigned)e > sizeof(du_int) * CHAR_BIT)
|
||||
return ~(du_int)0;
|
||||
return fb.u.low.all >> (63 - e);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
/* 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 |
|
||||
|
@ -38,6 +37,8 @@ __fixunsxfsi(long double a)
|
|||
int e = (fb.u.high.s.low & 0x00007FFF) - 16383;
|
||||
if (e < 0 || (fb.u.high.s.low & 0x00008000))
|
||||
return 0;
|
||||
if ((unsigned)e > sizeof(su_int) * CHAR_BIT)
|
||||
return ~(su_int)0;
|
||||
return fb.u.low.s.high >> (31 - e);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,9 +21,8 @@
|
|||
*/
|
||||
|
||||
/* Assumption: long double is an intel 80 bit floating point type padded with 6 bytes
|
||||
* tu_int is a 64 bit integral type
|
||||
* tu_int is a 128 bit integral type
|
||||
* value in long double is representable in tu_int or is negative
|
||||
* (no range checking performed)
|
||||
*/
|
||||
|
||||
/* gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
|
||||
|
@ -38,6 +37,8 @@ __fixunsxfti(long double a)
|
|||
int e = (fb.u.high.s.low & 0x00007FFF) - 16383;
|
||||
if (e < 0 || (fb.u.high.s.low & 0x00008000))
|
||||
return 0;
|
||||
if ((unsigned)e > sizeof(tu_int) * CHAR_BIT)
|
||||
return ~(tu_int)0;
|
||||
tu_int r = fb.u.low.all;
|
||||
if (e > 63)
|
||||
r <<= (e - 63);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
/* Returns: convert a to a signed long long, rounding toward zero. */
|
||||
|
||||
/* Assumption: long double is an intel 80 bit floating point type padded with 6 bytes
|
||||
* su_int is a 32 bit integral type
|
||||
* di_int is a 64 bit integral type
|
||||
* value in long double is representable in di_int (no range checking performed)
|
||||
*/
|
||||
|
||||
|
@ -30,11 +30,15 @@
|
|||
COMPILER_RT_ABI di_int
|
||||
__fixxfdi(long double a)
|
||||
{
|
||||
const di_int di_max = (di_int)((~(du_int)0) / 2);
|
||||
const di_int di_min = -di_max - 1;
|
||||
long_double_bits fb;
|
||||
fb.f = a;
|
||||
int e = (fb.u.high.s.low & 0x00007FFF) - 16383;
|
||||
if (e < 0)
|
||||
return 0;
|
||||
if ((unsigned)e >= sizeof(di_int) * CHAR_BIT)
|
||||
return a > 0 ? di_max : di_min;
|
||||
di_int s = -(si_int)((fb.u.high.s.low & 0x00008000) >> 15);
|
||||
di_int r = fb.u.low.all;
|
||||
r = (du_int)r >> (63 - e);
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
/* Returns: convert a to a signed long long, rounding toward 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 ti_int (no range checking performed)
|
||||
* ti_int is a 128 bit integral type
|
||||
* value in long double is representable in ti_int
|
||||
*/
|
||||
|
||||
/* gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
|
||||
|
@ -30,6 +30,8 @@
|
|||
COMPILER_RT_ABI ti_int
|
||||
__fixxfti(long double a)
|
||||
{
|
||||
const ti_int ti_max = (ti_int)((~(tu_int)0) / 2);
|
||||
const ti_int ti_min = -ti_max - 1;
|
||||
long_double_bits fb;
|
||||
fb.f = a;
|
||||
int e = (fb.u.high.s.low & 0x00007FFF) - 16383;
|
||||
|
@ -37,6 +39,8 @@ __fixxfti(long double a)
|
|||
return 0;
|
||||
ti_int s = -(si_int)((fb.u.high.s.low & 0x00008000) >> 15);
|
||||
ti_int r = fb.u.low.all;
|
||||
if ((unsigned)e >= sizeof(ti_int) * CHAR_BIT)
|
||||
return a > 0 ? ti_max : ti_min;
|
||||
if (e > 63)
|
||||
r <<= (e - 63);
|
||||
else
|
||||
|
|
|
@ -32,8 +32,8 @@ ARM_EABI_FNALIAS(l2d, floatdidf)
|
|||
COMPILER_RT_ABI double
|
||||
__floatdidf(di_int a)
|
||||
{
|
||||
static const double twop52 = 0x1.0p52;
|
||||
static const double twop32 = 0x1.0p32;
|
||||
static const double twop52 = 4503599627370496.0; // 0x1.0p52
|
||||
static const double twop32 = 4294967296.0; // 0x1.0p32
|
||||
|
||||
union { int64_t x; double d; } low = { .d = twop52 };
|
||||
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
//===-- lib/floatditf.c - integer -> quad-precision conversion ----*- C -*-===//
|
||||
//
|
||||
// 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 di_int to quad-precision conversion for the
|
||||
// compiler-rt library in the IEEE-754 default round-to-nearest, ties-to-even
|
||||
// mode.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#define QUAD_PRECISION
|
||||
#include "fp_lib.h"
|
||||
|
||||
#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
|
||||
COMPILER_RT_ABI fp_t __floatditf(di_int a) {
|
||||
|
||||
const int aWidth = sizeof a * CHAR_BIT;
|
||||
|
||||
// Handle zero as a special case to protect clz
|
||||
if (a == 0)
|
||||
return fromRep(0);
|
||||
|
||||
// All other cases begin by extracting the sign and absolute value of a
|
||||
rep_t sign = 0;
|
||||
du_int aAbs = (du_int)a;
|
||||
if (a < 0) {
|
||||
sign = signBit;
|
||||
aAbs = ~(du_int)a + 1U;
|
||||
}
|
||||
|
||||
// Exponent of (fp_t)a is the width of abs(a).
|
||||
const int exponent = (aWidth - 1) - __builtin_clzll(aAbs);
|
||||
rep_t result;
|
||||
|
||||
// Shift a into the significand field, rounding if it is a right-shift
|
||||
const int shift = significandBits - exponent;
|
||||
result = (rep_t)aAbs << shift ^ implicitBit;
|
||||
|
||||
// Insert the exponent
|
||||
result += (rep_t)(exponent + exponentBias) << significandBits;
|
||||
// Insert the sign bit and return
|
||||
return fromRep(result | sign);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,50 @@
|
|||
//===-- lib/floatsitf.c - integer -> quad-precision conversion ----*- C -*-===//
|
||||
//
|
||||
// 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 integer to quad-precision conversion for the
|
||||
// compiler-rt library in the IEEE-754 default round-to-nearest, ties-to-even
|
||||
// mode.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#define QUAD_PRECISION
|
||||
#include "fp_lib.h"
|
||||
|
||||
#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
|
||||
COMPILER_RT_ABI fp_t __floatsitf(int a) {
|
||||
|
||||
const int aWidth = sizeof a * CHAR_BIT;
|
||||
|
||||
// Handle zero as a special case to protect clz
|
||||
if (a == 0)
|
||||
return fromRep(0);
|
||||
|
||||
// All other cases begin by extracting the sign and absolute value of a
|
||||
rep_t sign = 0;
|
||||
unsigned aAbs = (unsigned)a;
|
||||
if (a < 0) {
|
||||
sign = signBit;
|
||||
aAbs = ~(unsigned)a + 1U;
|
||||
}
|
||||
|
||||
// Exponent of (fp_t)a is the width of abs(a).
|
||||
const int exponent = (aWidth - 1) - __builtin_clz(aAbs);
|
||||
rep_t result;
|
||||
|
||||
// Shift a into the significand field and clear the implicit bit.
|
||||
const int shift = significandBits - exponent;
|
||||
result = (rep_t)aAbs << shift ^ implicitBit;
|
||||
|
||||
// Insert the exponent
|
||||
result += (rep_t)(exponent + exponentBias) << significandBits;
|
||||
// Insert the sign bit and return
|
||||
return fromRep(result | sign);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -32,9 +32,9 @@ ARM_EABI_FNALIAS(ul2d, floatundidf)
|
|||
COMPILER_RT_ABI double
|
||||
__floatundidf(du_int a)
|
||||
{
|
||||
static const double twop52 = 0x1.0p52;
|
||||
static const double twop84 = 0x1.0p84;
|
||||
static const double twop84_plus_twop52 = 0x1.00000001p84;
|
||||
static const double twop52 = 4503599627370496.0; // 0x1.0p52
|
||||
static const double twop84 = 19342813113834066795298816.0; // 0x1.0p84
|
||||
static const double twop84_plus_twop52 = 19342813118337666422669312.0; // 0x1.00000001p84
|
||||
|
||||
union { uint64_t x; double d; } high = { .d = twop84 };
|
||||
union { uint64_t x; double d; } low = { .d = twop52 };
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
//===-- lib/floatunditf.c - uint -> quad-precision conversion -----*- C -*-===//
|
||||
//
|
||||
// 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 du_int to quad-precision conversion for the
|
||||
// compiler-rt library in the IEEE-754 default round-to-nearest, ties-to-even
|
||||
// mode.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#define QUAD_PRECISION
|
||||
#include "fp_lib.h"
|
||||
|
||||
#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
|
||||
COMPILER_RT_ABI fp_t __floatunditf(du_int a) {
|
||||
|
||||
const int aWidth = sizeof a * CHAR_BIT;
|
||||
|
||||
// Handle zero as a special case to protect clz
|
||||
if (a == 0) return fromRep(0);
|
||||
|
||||
// Exponent of (fp_t)a is the width of abs(a).
|
||||
const int exponent = (aWidth - 1) - __builtin_clzll(a);
|
||||
rep_t result;
|
||||
|
||||
// Shift a into the significand field and clear the implicit bit.
|
||||
const int shift = significandBits - exponent;
|
||||
result = (rep_t)a << shift ^ implicitBit;
|
||||
|
||||
// Insert the exponent
|
||||
result += (rep_t)(exponent + exponentBias) << significandBits;
|
||||
return fromRep(result);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,40 @@
|
|||
//===-- lib/floatunsitf.c - uint -> quad-precision conversion -----*- C -*-===//
|
||||
//
|
||||
// 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 unsigned integer to quad-precision conversion for the
|
||||
// compiler-rt library in the IEEE-754 default round-to-nearest, ties-to-even
|
||||
// mode.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#define QUAD_PRECISION
|
||||
#include "fp_lib.h"
|
||||
|
||||
#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
|
||||
COMPILER_RT_ABI fp_t __floatunsitf(unsigned int a) {
|
||||
|
||||
const int aWidth = sizeof a * CHAR_BIT;
|
||||
|
||||
// Handle zero as a special case to protect clz
|
||||
if (a == 0) return fromRep(0);
|
||||
|
||||
// Exponent of (fp_t)a is the width of abs(a).
|
||||
const int exponent = (aWidth - 1) - __builtin_clz(a);
|
||||
rep_t result;
|
||||
|
||||
// Shift a into the significand field and clear the implicit bit.
|
||||
const int shift = significandBits - exponent;
|
||||
result = (rep_t)a << shift ^ implicitBit;
|
||||
|
||||
// Insert the exponent
|
||||
result += (rep_t)(exponent + exponentBias) << significandBits;
|
||||
return fromRep(result);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#include "fp_lib.h"
|
||||
|
||||
static inline fp_t __addXf3__(fp_t a, fp_t b) {
|
||||
static __inline fp_t __addXf3__(fp_t a, fp_t b) {
|
||||
rep_t aRep = toRep(a);
|
||||
rep_t bRep = toRep(b);
|
||||
const rep_t aAbs = aRep & absMask;
|
||||
|
|
|
@ -28,7 +28,7 @@ typedef double src_t;
|
|||
typedef uint64_t src_rep_t;
|
||||
#define SRC_REP_C UINT64_C
|
||||
static const int srcSigBits = 52;
|
||||
static inline int src_rep_t_clz(src_rep_t a) {
|
||||
static __inline int src_rep_t_clz(src_rep_t a) {
|
||||
#if defined __LP64__
|
||||
return __builtin_clzl(a);
|
||||
#else
|
||||
|
@ -39,11 +39,24 @@ static inline int src_rep_t_clz(src_rep_t a) {
|
|||
#endif
|
||||
}
|
||||
|
||||
#elif defined SRC_HALF
|
||||
typedef uint16_t src_t;
|
||||
typedef uint16_t src_rep_t;
|
||||
#define SRC_REP_C UINT16_C
|
||||
static const int srcSigBits = 10;
|
||||
#define src_rep_t_clz __builtin_clz
|
||||
|
||||
#else
|
||||
#error Source should be single precision or double precision!
|
||||
#error Source should be half, single, or double precision!
|
||||
#endif //end source precision
|
||||
|
||||
#if defined DST_DOUBLE
|
||||
#if defined DST_SINGLE
|
||||
typedef float dst_t;
|
||||
typedef uint32_t dst_rep_t;
|
||||
#define DST_REP_C UINT32_C
|
||||
static const int dstSigBits = 23;
|
||||
|
||||
#elif defined DST_DOUBLE
|
||||
typedef double dst_t;
|
||||
typedef uint64_t dst_rep_t;
|
||||
#define DST_REP_C UINT64_C
|
||||
|
@ -56,18 +69,18 @@ typedef __uint128_t dst_rep_t;
|
|||
static const int dstSigBits = 112;
|
||||
|
||||
#else
|
||||
#error Destination should be double precision or quad precision!
|
||||
#error Destination should be single, double, or quad precision!
|
||||
#endif //end destination precision
|
||||
|
||||
// End of specialization parameters. Two helper routines for conversion to and
|
||||
// from the representation of floating-point data as integer values follow.
|
||||
|
||||
static inline src_rep_t srcToRep(src_t x) {
|
||||
static __inline src_rep_t srcToRep(src_t x) {
|
||||
const union { src_t f; src_rep_t i; } rep = {.f = x};
|
||||
return rep.i;
|
||||
}
|
||||
|
||||
static inline dst_t dstFromRep(dst_rep_t x) {
|
||||
static __inline dst_t dstFromRep(dst_rep_t x) {
|
||||
const union { dst_t f; dst_rep_t i; } rep = {.i = x};
|
||||
return rep.f;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
#include "fp_extend.h"
|
||||
|
||||
static inline dst_t __extendXfYf2__(src_t a) {
|
||||
static __inline dst_t __extendXfYf2__(src_t a) {
|
||||
// Various constants whose values follow from the type parameters.
|
||||
// Any reasonable optimizer will fold and propagate all of these.
|
||||
const int srcBits = sizeof(src_t)*CHAR_BIT;
|
||||
|
@ -66,7 +66,9 @@ static inline dst_t __extendXfYf2__(src_t a) {
|
|||
const src_rep_t sign = aRep & srcSignMask;
|
||||
dst_rep_t absResult;
|
||||
|
||||
if (aAbs - srcMinNormal < srcInfinity - srcMinNormal) {
|
||||
// If sizeof(src_rep_t) < sizeof(int), the subtraction result is promoted
|
||||
// to (signed) int. To avoid that, explicitly cast to src_rep_t.
|
||||
if ((src_rep_t)(aAbs - srcMinNormal) < srcInfinity - srcMinNormal) {
|
||||
// a is a normal number.
|
||||
// Extend to the destination type by shifting the significand and
|
||||
// exponent into the proper position and rebiasing the exponent.
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
//===-- lib/fixdfsi.c - Double-precision -> integer conversion ----*- C -*-===//
|
||||
//
|
||||
// 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 float to integer conversion for the
|
||||
// compiler-rt library.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "fp_lib.h"
|
||||
|
||||
static __inline fixint_t __fixint(fp_t a) {
|
||||
const fixint_t fixint_max = (fixint_t)((~(fixuint_t)0) / 2);
|
||||
const fixint_t fixint_min = -fixint_max - 1;
|
||||
// Break a into sign, exponent, significand
|
||||
const rep_t aRep = toRep(a);
|
||||
const rep_t aAbs = aRep & absMask;
|
||||
const fixint_t sign = aRep & signBit ? -1 : 1;
|
||||
const int exponent = (aAbs >> significandBits) - exponentBias;
|
||||
const rep_t significand = (aAbs & significandMask) | implicitBit;
|
||||
|
||||
// If exponent is negative, the result is zero.
|
||||
if (exponent < 0)
|
||||
return 0;
|
||||
|
||||
// If the value is too large for the integer type, saturate.
|
||||
if ((unsigned)exponent >= sizeof(fixint_t) * CHAR_BIT)
|
||||
return sign == 1 ? fixint_max : fixint_min;
|
||||
|
||||
// If 0 <= exponent < significandBits, right shift to get the result.
|
||||
// Otherwise, shift left.
|
||||
if (exponent < significandBits)
|
||||
return sign * (significand >> (significandBits - exponent));
|
||||
else
|
||||
return sign * ((fixint_t)significand << (exponent - significandBits));
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
//===-- lib/fixdfsi.c - Double-precision -> integer conversion ----*- C -*-===//
|
||||
//
|
||||
// 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 float to unsigned integer conversion for the
|
||||
// compiler-rt library.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "fp_lib.h"
|
||||
|
||||
static __inline fixuint_t __fixuint(fp_t a) {
|
||||
// Break a into sign, exponent, significand
|
||||
const rep_t aRep = toRep(a);
|
||||
const rep_t aAbs = aRep & absMask;
|
||||
const int sign = aRep & signBit ? -1 : 1;
|
||||
const int exponent = (aAbs >> significandBits) - exponentBias;
|
||||
const rep_t significand = (aAbs & significandMask) | implicitBit;
|
||||
|
||||
// If either the value or the exponent is negative, the result is zero.
|
||||
if (sign == -1 || exponent < 0)
|
||||
return 0;
|
||||
|
||||
// If the value is too large for the integer type, saturate.
|
||||
if ((unsigned)exponent >= sizeof(fixuint_t) * CHAR_BIT)
|
||||
return ~(fixuint_t)0;
|
||||
|
||||
// If 0 <= exponent < significandBits, right shift to get the result.
|
||||
// Otherwise, shift left.
|
||||
if (exponent < significandBits)
|
||||
return significand >> (significandBits - exponent);
|
||||
else
|
||||
return (fixuint_t)significand << (exponent - significandBits);
|
||||
}
|
|
@ -46,12 +46,12 @@ typedef float fp_t;
|
|||
#define REP_C UINT32_C
|
||||
#define significandBits 23
|
||||
|
||||
static inline int rep_clz(rep_t a) {
|
||||
static __inline int rep_clz(rep_t a) {
|
||||
return __builtin_clz(a);
|
||||
}
|
||||
|
||||
// 32x32 --> 64 bit multiply
|
||||
static inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) {
|
||||
static __inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) {
|
||||
const uint64_t product = (uint64_t)a*b;
|
||||
*hi = product >> 32;
|
||||
*lo = product;
|
||||
|
@ -66,7 +66,7 @@ typedef double fp_t;
|
|||
#define REP_C UINT64_C
|
||||
#define significandBits 52
|
||||
|
||||
static inline int rep_clz(rep_t a) {
|
||||
static __inline int rep_clz(rep_t a) {
|
||||
#if defined __LP64__
|
||||
return __builtin_clzl(a);
|
||||
#else
|
||||
|
@ -83,7 +83,7 @@ static inline int rep_clz(rep_t a) {
|
|||
// 64x64 -> 128 wide multiply for platforms that don't have such an operation;
|
||||
// many 64-bit platforms have this operation, but they tend to have hardware
|
||||
// floating-point, so we don't bother with a special case for them here.
|
||||
static inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) {
|
||||
static __inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) {
|
||||
// Each of the component 32x32 -> 64 products
|
||||
const uint64_t plolo = loWord(a) * loWord(b);
|
||||
const uint64_t plohi = loWord(a) * hiWord(b);
|
||||
|
@ -112,7 +112,7 @@ typedef long double fp_t;
|
|||
// 128-bit integer, we let the constant be casted to 128-bit integer
|
||||
#define significandBits 112
|
||||
|
||||
static inline int rep_clz(rep_t a) {
|
||||
static __inline int rep_clz(rep_t a) {
|
||||
const union
|
||||
{
|
||||
__uint128_t ll;
|
||||
|
@ -148,7 +148,7 @@ static inline int rep_clz(rep_t a) {
|
|||
// 128x128 -> 256 wide multiply for platforms that don't have such an operation;
|
||||
// many 64-bit platforms have this operation, but they tend to have hardware
|
||||
// floating-point, so we don't bother with a special case for them here.
|
||||
static inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) {
|
||||
static __inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) {
|
||||
|
||||
const uint64_t product11 = Word_1(a) * Word_1(b);
|
||||
const uint64_t product12 = Word_1(a) * Word_2(b);
|
||||
|
@ -228,28 +228,28 @@ static inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) {
|
|||
#define quietBit (implicitBit >> 1)
|
||||
#define qnanRep (exponentMask | quietBit)
|
||||
|
||||
static inline rep_t toRep(fp_t x) {
|
||||
static __inline rep_t toRep(fp_t x) {
|
||||
const union { fp_t f; rep_t i; } rep = {.f = x};
|
||||
return rep.i;
|
||||
}
|
||||
|
||||
static inline fp_t fromRep(rep_t x) {
|
||||
static __inline fp_t fromRep(rep_t x) {
|
||||
const union { fp_t f; rep_t i; } rep = {.i = x};
|
||||
return rep.f;
|
||||
}
|
||||
|
||||
static inline int normalize(rep_t *significand) {
|
||||
static __inline int normalize(rep_t *significand) {
|
||||
const int shift = rep_clz(*significand) - rep_clz(implicitBit);
|
||||
*significand <<= shift;
|
||||
return 1 - shift;
|
||||
}
|
||||
|
||||
static inline void wideLeftShift(rep_t *hi, rep_t *lo, int count) {
|
||||
static __inline void wideLeftShift(rep_t *hi, rep_t *lo, int count) {
|
||||
*hi = *hi << count | *lo >> (typeWidth - count);
|
||||
*lo = *lo << count;
|
||||
}
|
||||
|
||||
static inline void wideRightShiftWithSticky(rep_t *hi, rep_t *lo, unsigned int count) {
|
||||
static __inline void wideRightShiftWithSticky(rep_t *hi, rep_t *lo, unsigned int count) {
|
||||
if (count < typeWidth) {
|
||||
const bool sticky = *lo << (typeWidth - count);
|
||||
*lo = *hi << (typeWidth - count) | *lo >> count | sticky;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#include "fp_lib.h"
|
||||
|
||||
static inline fp_t __mulXf3__(fp_t a, fp_t b) {
|
||||
static __inline fp_t __mulXf3__(fp_t a, fp_t b) {
|
||||
const unsigned int aExponent = toRep(a) >> significandBits & maxExponent;
|
||||
const unsigned int bExponent = toRep(b) >> significandBits & maxExponent;
|
||||
const rep_t productSign = (toRep(a) ^ toRep(b)) & signBit;
|
||||
|
|
|
@ -16,7 +16,13 @@
|
|||
|
||||
#include "int_lib.h"
|
||||
|
||||
#if defined SRC_DOUBLE
|
||||
#if defined SRC_SINGLE
|
||||
typedef float src_t;
|
||||
typedef uint32_t src_rep_t;
|
||||
#define SRC_REP_C UINT32_C
|
||||
static const int srcSigBits = 23;
|
||||
|
||||
#elif defined SRC_DOUBLE
|
||||
typedef double src_t;
|
||||
typedef uint64_t src_rep_t;
|
||||
#define SRC_REP_C UINT64_C
|
||||
|
@ -44,6 +50,12 @@ typedef uint32_t dst_rep_t;
|
|||
#define DST_REP_C UINT32_C
|
||||
static const int dstSigBits = 23;
|
||||
|
||||
#elif defined DST_HALF
|
||||
typedef uint16_t dst_t;
|
||||
typedef uint16_t dst_rep_t;
|
||||
#define DST_REP_C UINT16_C
|
||||
static const int dstSigBits = 10;
|
||||
|
||||
#else
|
||||
#error Destination should be single precision or double precision!
|
||||
#endif //end destination precision
|
||||
|
@ -51,12 +63,12 @@ static const int dstSigBits = 23;
|
|||
// End of specialization parameters. Two helper routines for conversion to and
|
||||
// from the representation of floating-point data as integer values follow.
|
||||
|
||||
static inline src_rep_t srcToRep(src_t x) {
|
||||
static __inline src_rep_t srcToRep(src_t x) {
|
||||
const union { src_t f; src_rep_t i; } rep = {.f = x};
|
||||
return rep.i;
|
||||
}
|
||||
|
||||
static inline dst_t dstFromRep(dst_rep_t x) {
|
||||
static __inline dst_t dstFromRep(dst_rep_t x) {
|
||||
const union { dst_t f; dst_rep_t i; } rep = {.i = x};
|
||||
return rep.f;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
#include "fp_trunc.h"
|
||||
|
||||
static inline dst_t __truncXfYf2__(src_t a) {
|
||||
static __inline dst_t __truncXfYf2__(src_t a) {
|
||||
// Various constants whose values follow from the type parameters.
|
||||
// Any reasonable optimizer will fold and propagate all of these.
|
||||
const int srcBits = sizeof(src_t)*CHAR_BIT;
|
||||
|
@ -99,7 +99,7 @@ static inline dst_t __truncXfYf2__(src_t a) {
|
|||
absResult |= dstQNaN;
|
||||
absResult |= ((aAbs & srcNaNCode) >> (srcSigBits - dstSigBits)) & dstNaNCode;
|
||||
}
|
||||
else if (aAbs > overflow) {
|
||||
else if (aAbs >= overflow) {
|
||||
// a overflows to infinity.
|
||||
absResult = (dst_rep_t)dstInfExp << dstSigBits;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
|
||||
#include "../assembly.h"
|
||||
|
||||
// _chkstk routine
|
||||
// This routine is windows specific
|
||||
// http://msdn.microsoft.com/en-us/library/ms648426.aspx
|
||||
|
||||
#ifdef __i386__
|
||||
|
||||
.text
|
||||
.balign 4
|
||||
DEFINE_COMPILERRT_FUNCTION(__chkstk_ms)
|
||||
push %ecx
|
||||
push %eax
|
||||
cmp $0x1000,%eax
|
||||
lea 12(%esp),%ecx
|
||||
jb 1f
|
||||
2:
|
||||
sub $0x1000,%ecx
|
||||
test %ecx,(%ecx)
|
||||
sub $0x1000,%eax
|
||||
cmp $0x1000,%eax
|
||||
ja 2b
|
||||
1:
|
||||
sub %eax,%ecx
|
||||
test %ecx,(%ecx)
|
||||
pop %eax
|
||||
pop %ecx
|
||||
ret
|
||||
END_COMPILERRT_FUNCTION(__chkstk_ms)
|
||||
|
||||
#endif // __i386__
|
|
@ -0,0 +1,40 @@
|
|||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
|
||||
#include "../assembly.h"
|
||||
|
||||
#ifdef __i386__
|
||||
|
||||
// _chkstk (_alloca) routine - probe stack between %esp and (%esp-%eax) in 4k increments,
|
||||
// then decrement %esp by %eax. Preserves all registers except %esp and flags.
|
||||
// This routine is windows specific
|
||||
// http://msdn.microsoft.com/en-us/library/ms648426.aspx
|
||||
|
||||
.text
|
||||
.balign 4
|
||||
DEFINE_COMPILERRT_FUNCTION(_alloca) // _chkstk and _alloca are the same function
|
||||
DEFINE_COMPILERRT_FUNCTION(__chkstk)
|
||||
push %ecx
|
||||
cmp $0x1000,%eax
|
||||
lea 8(%esp),%ecx // esp before calling this routine -> ecx
|
||||
jb 1f
|
||||
2:
|
||||
sub $0x1000,%ecx
|
||||
test %ecx,(%ecx)
|
||||
sub $0x1000,%eax
|
||||
cmp $0x1000,%eax
|
||||
ja 2b
|
||||
1:
|
||||
sub %eax,%ecx
|
||||
test %ecx,(%ecx)
|
||||
|
||||
lea 4(%esp),%eax // load pointer to the return address into eax
|
||||
mov %ecx,%esp // install the new top of stack pointer into esp
|
||||
mov -4(%eax),%ecx // restore ecx
|
||||
push (%eax) // push return address onto the stack
|
||||
sub %esp,%eax // restore the original value in eax
|
||||
ret
|
||||
END_COMPILERRT_FUNCTION(__chkstk)
|
||||
END_COMPILERRT_FUNCTION(_alloca)
|
||||
|
||||
#endif // __i386__
|
|
@ -7,13 +7,7 @@
|
|||
|
||||
#ifdef __i386__
|
||||
|
||||
#if defined(__APPLE__)
|
||||
.const
|
||||
#elif defined(__ELF__)
|
||||
.section .rodata
|
||||
#else
|
||||
.section .rdata,"rd"
|
||||
#endif
|
||||
CONST_SECTION
|
||||
|
||||
.balign 16
|
||||
twop52:
|
||||
|
|
|
@ -17,13 +17,7 @@
|
|||
|
||||
#ifdef __i386__
|
||||
|
||||
#if defined(__APPLE__)
|
||||
.const
|
||||
#elif defined(__ELF__)
|
||||
.section .rodata
|
||||
#else
|
||||
.section .rdata,"rd"
|
||||
#endif
|
||||
CONST_SECTION
|
||||
|
||||
.balign 16
|
||||
twop52:
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#ifdef __i386__
|
||||
|
||||
.const
|
||||
CONST_SECTION
|
||||
.balign 3
|
||||
|
||||
.quad 0x43f0000000000000
|
||||
|
@ -52,13 +52,7 @@ END_COMPILERRT_FUNCTION(__floatundisf)
|
|||
|
||||
#ifdef __i386__
|
||||
|
||||
#if defined(__APPLE__)
|
||||
.const
|
||||
#elif defined(__ELF__)
|
||||
.section .rodata
|
||||
#else
|
||||
.section .rdata,"rd"
|
||||
#endif
|
||||
CONST_SECTION
|
||||
|
||||
.balign 16
|
||||
twop52:
|
||||
|
|
|
@ -7,13 +7,7 @@
|
|||
|
||||
#ifdef __i386__
|
||||
|
||||
#if defined(__APPLE__)
|
||||
.const
|
||||
#elif defined(__ELF__)
|
||||
.section .rodata
|
||||
#else
|
||||
.section .rdata,"rd"
|
||||
#endif
|
||||
CONST_SECTION
|
||||
|
||||
.balign 16
|
||||
twop52:
|
||||
|
|
|
@ -16,6 +16,20 @@
|
|||
#ifndef INT_ENDIANNESS_H
|
||||
#define INT_ENDIANNESS_H
|
||||
|
||||
#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
|
||||
defined(__ORDER_LITTLE_ENDIAN__)
|
||||
|
||||
/* Clang and GCC provide built-in endianness definitions. */
|
||||
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
#define _YUGA_LITTLE_ENDIAN 0
|
||||
#define _YUGA_BIG_ENDIAN 1
|
||||
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
#define _YUGA_LITTLE_ENDIAN 1
|
||||
#define _YUGA_BIG_ENDIAN 0
|
||||
#endif /* __BYTE_ORDER__ */
|
||||
|
||||
#else /* Compilers other than Clang or GCC. */
|
||||
|
||||
#if defined(__SVR4) && defined(__sun)
|
||||
#include <sys/byteorder.h>
|
||||
|
||||
|
@ -33,7 +47,8 @@
|
|||
|
||||
/* .. */
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__minix)
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \
|
||||
defined(__minix)
|
||||
#include <sys/endian.h>
|
||||
|
||||
#if _BYTE_ORDER == _BIG_ENDIAN
|
||||
|
@ -61,7 +76,8 @@
|
|||
|
||||
/* .. */
|
||||
|
||||
/* Mac OSX has __BIG_ENDIAN__ or __LITTLE_ENDIAN__ automatically set by the compiler (at least with GCC) */
|
||||
/* Mac OSX has __BIG_ENDIAN__ or __LITTLE_ENDIAN__ automatically set by the
|
||||
* compiler (at least with GCC) */
|
||||
#if defined(__APPLE__) || defined(__ellcc__ )
|
||||
|
||||
#ifdef __BIG_ENDIAN__
|
||||
|
@ -82,19 +98,6 @@
|
|||
|
||||
/* .. */
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <endian.h>
|
||||
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
#define _YUGA_LITTLE_ENDIAN 0
|
||||
#define _YUGA_BIG_ENDIAN 1
|
||||
#elif __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
#define _YUGA_LITTLE_ENDIAN 1
|
||||
#define _YUGA_BIG_ENDIAN 0
|
||||
#endif /* __BYTE_ORDER */
|
||||
|
||||
#endif /* GNU/Linux */
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
#define _YUGA_LITTLE_ENDIAN 1
|
||||
|
@ -102,6 +105,8 @@
|
|||
|
||||
#endif /* Windows */
|
||||
|
||||
#endif /* Clang or GCC. */
|
||||
|
||||
/* . */
|
||||
|
||||
#if !defined(_YUGA_LITTLE_ENDIAN) || !defined(_YUGA_BIG_ENDIAN)
|
||||
|
|
|
@ -20,21 +20,38 @@
|
|||
/* Assumption: Right shift of signed negative is arithmetic shift. */
|
||||
/* Assumption: Endianness is little or big (not mixed). */
|
||||
|
||||
/* ABI macro definitions */
|
||||
#if defined(__ELF__)
|
||||
#define FNALIAS(alias_name, original_name) \
|
||||
void alias_name() __attribute__((alias(#original_name)))
|
||||
#else
|
||||
#define FNALIAS(alias, name) _Pragma("GCC error(\"alias unsupported on this file format\")")
|
||||
#endif
|
||||
|
||||
/*
|
||||
* TODO define this appropriately for targets that require explicit export
|
||||
* declarations (i.e. Windows)
|
||||
*/
|
||||
#define COMPILER_RT_EXPORT
|
||||
/* ABI macro definitions */
|
||||
|
||||
#if __ARM_EABI__
|
||||
# define ARM_EABI_FNALIAS(aeabi_name, name) \
|
||||
void __aeabi_##aeabi_name() __attribute__((alias("__" #name)));
|
||||
# define COMPILER_RT_ABI COMPILER_RT_EXPORT __attribute__((pcs("aapcs")))
|
||||
# define COMPILER_RT_ABI __attribute__((pcs("aapcs")))
|
||||
#else
|
||||
# define ARM_EABI_FNALIAS(aeabi_name, name)
|
||||
# define COMPILER_RT_ABI COMPILER_RT_EXPORT
|
||||
# if defined(__arm__) && defined(_WIN32) && (!defined(_MSC_VER) || defined(__clang__))
|
||||
# define COMPILER_RT_ABI __attribute__((pcs("aapcs")))
|
||||
# else
|
||||
# define COMPILER_RT_ABI
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define ALWAYS_INLINE __forceinline
|
||||
#define NOINLINE __declspec(noinline)
|
||||
#define NORETURN __declspec(noreturn)
|
||||
#define UNUSED
|
||||
#else
|
||||
#define ALWAYS_INLINE __attribute__((always_inline))
|
||||
#define NOINLINE __attribute__((noinline))
|
||||
#define NORETURN __attribute__((noreturn))
|
||||
#define UNUSED __attribute__((unused))
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) && (defined(_KERNEL) || defined(_STANDALONE))
|
||||
|
@ -73,4 +90,44 @@ COMPILER_RT_ABI si_int __clzti2(ti_int a);
|
|||
COMPILER_RT_ABI tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem);
|
||||
#endif
|
||||
|
||||
/* Definitions for builtins unavailable on MSVC */
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#include <intrin.h>
|
||||
|
||||
uint32_t __inline __builtin_ctz(uint32_t value) {
|
||||
uint32_t trailing_zero = 0;
|
||||
if (_BitScanForward(&trailing_zero, value))
|
||||
return trailing_zero;
|
||||
return 32;
|
||||
}
|
||||
|
||||
uint32_t __inline __builtin_clz(uint32_t value) {
|
||||
uint32_t leading_zero = 0;
|
||||
if (_BitScanReverse(&leading_zero, value))
|
||||
return 31 - leading_zero;
|
||||
return 32;
|
||||
}
|
||||
|
||||
#if defined(_M_ARM) || defined(_M_X64)
|
||||
uint32_t __inline __builtin_clzll(uint64_t value) {
|
||||
uint32_t leading_zero = 0;
|
||||
if (_BitScanReverse64(&leading_zero, value))
|
||||
return 63 - leading_zero;
|
||||
return 64;
|
||||
}
|
||||
#else
|
||||
uint32_t __inline __builtin_clzll(uint64_t value) {
|
||||
if (value == 0)
|
||||
return 64;
|
||||
uint32_t msh = (uint32_t)(value >> 32);
|
||||
uint32_t lsh = (uint32_t)(value & 0xFFFFFFFF);
|
||||
if (msh != 0)
|
||||
return __builtin_clz(msh);
|
||||
return 32 + __builtin_clz(lsh);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define __builtin_clzl __builtin_clzll
|
||||
#endif /* defined(_MSC_VER) && !defined(__clang__) */
|
||||
|
||||
#endif /* INT_LIB_H */
|
||||
|
|
|
@ -25,43 +25,90 @@
|
|||
# define __has_builtin(x) 0
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <ymath.h>
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#define CRT_INFINITY INFINITY
|
||||
#else
|
||||
#define CRT_INFINITY __builtin_huge_valf()
|
||||
#endif
|
||||
|
||||
#define crt_isinf(x) __builtin_isinf((x))
|
||||
#define crt_isnan(x) __builtin_isnan((x))
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#define crt_isfinite(x) _finite((x))
|
||||
#define crt_isinf(x) !_finite((x))
|
||||
#define crt_isnan(x) _isnan((x))
|
||||
#else
|
||||
/* Define crt_isfinite in terms of the builtin if available, otherwise provide
|
||||
* an alternate version in terms of our other functions. This supports some
|
||||
* versions of GCC which didn't have __builtin_isfinite.
|
||||
*/
|
||||
#if __has_builtin(__builtin_isfinite)
|
||||
# define crt_isfinite(x) __builtin_isfinite((x))
|
||||
#else
|
||||
#elif defined(__GNUC__)
|
||||
# define crt_isfinite(x) \
|
||||
__extension__(({ \
|
||||
__typeof((x)) x_ = (x); \
|
||||
!crt_isinf(x_) && !crt_isnan(x_); \
|
||||
}))
|
||||
#endif
|
||||
#else
|
||||
# error "Do not know how to check for infinity"
|
||||
#endif /* __has_builtin(__builtin_isfinite) */
|
||||
#define crt_isinf(x) __builtin_isinf((x))
|
||||
#define crt_isnan(x) __builtin_isnan((x))
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#define crt_copysign(x, y) copysign((x), (y))
|
||||
#define crt_copysignf(x, y) copysignf((x), (y))
|
||||
#define crt_copysignl(x, y) copysignl((x), (y))
|
||||
#else
|
||||
#define crt_copysign(x, y) __builtin_copysign((x), (y))
|
||||
#define crt_copysignf(x, y) __builtin_copysignf((x), (y))
|
||||
#define crt_copysignl(x, y) __builtin_copysignl((x), (y))
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#define crt_fabs(x) fabs((x))
|
||||
#define crt_fabsf(x) fabsf((x))
|
||||
#define crt_fabsl(x) fabs((x))
|
||||
#else
|
||||
#define crt_fabs(x) __builtin_fabs((x))
|
||||
#define crt_fabsf(x) __builtin_fabsf((x))
|
||||
#define crt_fabsl(x) __builtin_fabsl((x))
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#define crt_fmax(x, y) __max((x), (y))
|
||||
#define crt_fmaxf(x, y) __max((x), (y))
|
||||
#define crt_fmaxl(x, y) __max((x), (y))
|
||||
#else
|
||||
#define crt_fmax(x, y) __builtin_fmax((x), (y))
|
||||
#define crt_fmaxf(x, y) __builtin_fmaxf((x), (y))
|
||||
#define crt_fmaxl(x, y) __builtin_fmaxl((x), (y))
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#define crt_logb(x) logb((x))
|
||||
#define crt_logbf(x) logbf((x))
|
||||
#define crt_logbl(x) logbl((x))
|
||||
#else
|
||||
#define crt_logb(x) __builtin_logb((x))
|
||||
#define crt_logbf(x) __builtin_logbf((x))
|
||||
#define crt_logbl(x) __builtin_logbl((x))
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#define crt_scalbn(x, y) scalbn((x), (y))
|
||||
#define crt_scalbnf(x, y) scalbnf((x), (y))
|
||||
#define crt_scalbnl(x, y) scalbnl((x), (y))
|
||||
#else
|
||||
#define crt_scalbn(x, y) __builtin_scalbn((x), (y))
|
||||
#define crt_scalbnf(x, y) __builtin_scalbnf((x), (y))
|
||||
#define crt_scalbnl(x, y) __builtin_scalbnl((x), (y))
|
||||
#endif
|
||||
|
||||
#endif /* INT_MATH_H */
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
|
||||
#include "int_endianness.h"
|
||||
|
||||
/* si_int is defined in Linux sysroot's asm-generic/siginfo.h */
|
||||
#ifdef si_int
|
||||
#undef si_int
|
||||
#endif
|
||||
typedef int si_int;
|
||||
typedef unsigned su_int;
|
||||
|
||||
|
@ -56,7 +60,9 @@ typedef union
|
|||
}s;
|
||||
} udwords;
|
||||
|
||||
#if __LP64__
|
||||
/* MIPS64 issue: PR 20098 */
|
||||
#if (defined(__LP64__) || defined(__wasm__)) && \
|
||||
!(defined(__mips__) && defined(__clang__))
|
||||
#define CRT_HAS_128BIT
|
||||
#endif
|
||||
|
||||
|
@ -94,14 +100,14 @@ typedef union
|
|||
}s;
|
||||
} utwords;
|
||||
|
||||
static inline ti_int make_ti(di_int h, di_int l) {
|
||||
static __inline ti_int make_ti(di_int h, di_int l) {
|
||||
twords r;
|
||||
r.s.high = h;
|
||||
r.s.low = l;
|
||||
return r.all;
|
||||
}
|
||||
|
||||
static inline tu_int make_tu(du_int h, du_int l) {
|
||||
static __inline tu_int make_tu(du_int h, du_int l) {
|
||||
utwords r;
|
||||
r.s.high = h;
|
||||
r.s.low = l;
|
||||
|
@ -139,5 +145,22 @@ typedef union
|
|||
long double f;
|
||||
} long_double_bits;
|
||||
|
||||
#if __STDC_VERSION__ >= 199901L
|
||||
typedef float _Complex Fcomplex;
|
||||
typedef double _Complex Dcomplex;
|
||||
typedef long double _Complex Lcomplex;
|
||||
|
||||
#define COMPLEX_REAL(x) __real__(x)
|
||||
#define COMPLEX_IMAGINARY(x) __imag__(x)
|
||||
#else
|
||||
typedef struct { float real, imaginary; } Fcomplex;
|
||||
|
||||
typedef struct { double real, imaginary; } Dcomplex;
|
||||
|
||||
typedef struct { long double real, imaginary; } Lcomplex;
|
||||
|
||||
#define COMPLEX_REAL(x) (x).real
|
||||
#define COMPLEX_IMAGINARY(x) (x).imaginary
|
||||
#endif
|
||||
#endif /* INT_TYPES_H */
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue