Fixup C++ style comments are not allowed in ISO C90 to classic C style.

llvm-svn: 78152
This commit is contained in:
Edward O'Callaghan 2009-08-05 04:02:56 +00:00
parent 379429200e
commit 4856eef437
33 changed files with 720 additions and 646 deletions

View File

@ -1,23 +1,24 @@
//===-- ashrti3.c - Implement __ashrti3 -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __ashrti3 for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- ashrti3.c - Implement __ashrti3 -----------------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __ashrti3 for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#if __x86_64
#include "int_lib.h"
// Returns: arithmetic a >> b
/* Returns: arithmetic a >> b */
// Precondition: 0 <= b < bits_in_tword
/* Precondition: 0 <= b < bits_in_tword */
ti_int
__ashrti3(ti_int a, si_int b)
@ -26,13 +27,13 @@ __ashrti3(ti_int a, si_int b)
twords input;
twords result;
input.all = a;
if (b & bits_in_dword) // bits_in_dword <= b < bits_in_tword
if (b & bits_in_dword) /* bits_in_dword <= b < bits_in_tword */
{
// result.high = input.high < 0 ? -1 : 0
/* result.high = input.high < 0 ? -1 : 0 */
result.high = input.high >> (bits_in_dword - 1);
result.low = input.high >> (b - bits_in_dword);
}
else // 0 <= b < bits_in_dword
else /* 0 <= b < bits_in_dword */
{
if (b == 0)
return a;

View File

@ -1,11 +1,12 @@
//===-- clear_cache.c - Implement __clear_cache ---------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/* ===-- clear_cache.c - Implement __clear_cache ---------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*/
#include <stdlib.h>
@ -13,22 +14,23 @@
#include <libkern/OSCacheControl.h>
#endif
//
// The compiler generates calls to __clear_cache() when creating
// trampoline functions on the stack for use with nested functions.
// It is expected to invalidate the instruction cache for the
// specified range.
//
/*
* The compiler generates calls to __clear_cache() when creating
* trampoline functions on the stack for use with nested functions.
* It is expected to invalidate the instruction cache for the
* specified range.
*/
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
//
/*
* Intel processors have a unified instruction and data cache
* so there is nothing to do
*/
#else
#if __APPLE__
// On Darwin, sys_icache_invalidate() provides this functionality
/* On Darwin, sys_icache_invalidate() provides this functionality */
sys_icache_invalidate(start, end-start);
#else
abort();

View File

@ -1,21 +1,22 @@
//===-- clzdi2.c - Implement __clzdi2 -------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __clzdi2 for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- clzdi2.c - Implement __clzdi2 -------------------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __clzdi2 for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#include "int_lib.h"
// Returns: the number of leading 0-bits
/* Returns: the number of leading 0-bits */
// Precondition: a != 0
/* Precondition: a != 0 */
si_int
__clzdi2(di_int a)

View File

@ -1,51 +1,53 @@
//===-- clzsi2.c - Implement __clzsi2 -------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __clzsi2 for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- clzsi2.c - Implement __clzsi2 -------------------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __clzsi2 for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#include "int_lib.h"
// Returns: the number of leading 0-bits
/* Returns: the number of leading 0-bits */
// Precondition: a != 0
/* Precondition: a != 0 */
si_int
__clzsi2(si_int a)
{
su_int x = (su_int)a;
si_int t = ((x & 0xFFFF0000) == 0) << 4; // if (x is small) t = 16 else 0
x >>= 16 - t; // x = [0 - 0xFFFF]
su_int r = t; // r = [0, 16]
// return r + clz(x)
si_int t = ((x & 0xFFFF0000) == 0) << 4; /* if (x is small) t = 16 else 0 */
x >>= 16 - t; /* x = [0 - 0xFFFF] */
su_int r = t; /* r = [0, 16] */
/* return r + clz(x) */
t = ((x & 0xFF00) == 0) << 3;
x >>= 8 - t; // x = [0 - 0xFF]
r += t; // r = [0, 8, 16, 24]
// return r + clz(x)
x >>= 8 - t; /* x = [0 - 0xFF] */
r += t; /* r = [0, 8, 16, 24] */
/* return r + clz(x) */
t = ((x & 0xF0) == 0) << 2;
x >>= 4 - t; // x = [0 - 0xF]
r += t; // r = [0, 4, 8, 12, 16, 20, 24, 28]
// return r + clz(x)
x >>= 4 - t; /* x = [0 - 0xF] */
r += t; /* r = [0, 4, 8, 12, 16, 20, 24, 28] */
/* return r + clz(x) */
t = ((x & 0xC) == 0) << 1;
x >>= 2 - t; // x = [0 - 3]
r += t; // r = [0 - 30] and is even
// return r + clz(x)
// switch (x)
// {
// case 0:
// return r + 2;
// case 1:
// return r + 1;
// case 2:
// case 3:
// return r;
// }
x >>= 2 - t; /* x = [0 - 3] */
r += t; /* r = [0 - 30] and is even */
/* return r + clz(x) */
/* switch (x)
* {
* case 0:
* return r + 2;
* case 1:
* return r + 1;
* case 2:
* case 3:
* return r;
* }
*/
return r + ((2 - x) & -((x & 2) == 0));
}

View File

@ -1,23 +1,24 @@
//===-- clzti2.c - Implement __clzti2 -------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __clzti2 for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- clzti2.c - Implement __clzti2 -------------------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __clzti2 for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#if __x86_64
#include "int_lib.h"
// Returns: the number of leading 0-bits
/* Returns: the number of leading 0-bits */
// Precondition: a != 0
/* Precondition: a != 0 */
si_int
__clzti2(ti_int a)

View File

@ -1,15 +1,16 @@
//===-- divti3.c - Implement __divti3 -------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __divti3 for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- divti3.c - Implement __divti3 -------------------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __divti3 for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#if __x86_64
@ -17,18 +18,18 @@
tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem);
// Returns: a / b
/* Returns: a / b */
ti_int
__divti3(ti_int a, ti_int b)
{
const int bits_in_tword_m1 = (int)(sizeof(ti_int) * CHAR_BIT) - 1;
ti_int s_a = a >> bits_in_tword_m1; // s_a = a < 0 ? -1 : 0
ti_int s_b = b >> bits_in_tword_m1; // s_b = b < 0 ? -1 : 0
a = (a ^ s_a) - s_a; // negate if s_a == -1
b = (b ^ s_b) - s_b; // negate if s_b == -1
s_a ^= s_b; // sign of quotient
return (__udivmodti4(a, b, (tu_int*)0) ^ s_a) - s_a; // negate if s_a == -1
ti_int s_a = a >> bits_in_tword_m1; /* s_a = a < 0 ? -1 : 0 */
ti_int s_b = b >> bits_in_tword_m1; /* s_b = b < 0 ? -1 : 0 */
a = (a ^ s_a) - s_a; /* negate if s_a == -1 */
b = (b ^ s_b) - s_b; /* negate if s_b == -1 */
s_a ^= s_b; /* sign of quotient */
return (__udivmodti4(a, b, (tu_int*)0) ^ s_a) - s_a; /* negate if s_a == -1 */
}
#endif

View File

@ -1,11 +1,12 @@
//===-- enable_execute_stack.c - Implement __enable_execute_stack ---------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/* ===-- enable_execute_stack.c - Implement __enable_execute_stack ---------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*/
#include <stdint.h>
#include <sys/mman.h>
@ -14,20 +15,21 @@
#endif
//
// The compiler generates calls to __enable_execute_stack() when creating
// trampoline functions on the stack for use with nested functions.
// It is expected to mark the page(s) containing the address
// and the next 48 bytes as executable. Since the stack is normally rw-
// that means changing the protection on those page(s) to rwx.
//
/*
* The compiler generates calls to __enable_execute_stack() when creating
* trampoline functions on the stack for use with nested functions.
* It is expected to mark the page(s) containing the address
* and the next 48 bytes as executable. Since the stack is normally rw-
* that means changing the protection on those page(s) to rwx.
*/
void __enable_execute_stack(void* addr)
{
#if __APPLE__
// On Darwin, pagesize is always 4096 bytes
/* On Darwin, pagesize is always 4096 bytes */
const uintptr_t pageSize = 4096;
#else
// FIXME: We should have a configure check for this.
/* FIXME: We should have a configure check for this. */
const uintptr_t pageSize = getpagesize();
#endif
const uintptr_t pageAlignMask = ~(pageSize-1);

View File

@ -1,11 +1,12 @@
//===---------- eprintf.c - Implements __eprintf --------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/* ===---------- eprintf.c - Implements __eprintf --------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*/
@ -13,14 +14,14 @@
#include <stdlib.h>
//
// __eprintf() was used in an old version of <assert.h>.
// It can eventually go away, but it is needed when linking
// .o files built with the old <assert.h>.
//
// It should never be exported from a dylib, so it is marked
// visibility hidden.
//
/*
* __eprintf() was used in an old version of <assert.h>.
* It can eventually go away, but it is needed when linking
* .o files built with the old <assert.h>.
*
* It should never be exported from a dylib, so it is marked
* visibility hidden.
*/
__attribute__((visibility("hidden")))
void __eprintf(const char* format, const char* assertion_expression,
const char* line, const char* file)

View File

@ -1,20 +1,22 @@
//===-- ffsdi2.c - Implement __ffsdi2 -------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __ffsdi2 for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- ffsdi2.c - Implement __ffsdi2 -------------------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __ffsdi2 for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#include "int_lib.h"
// Returns: the index of the least significant 1-bit in a, or
// the value zero if a is zero. The least significant bit is index one.
/* Returns: the index of the least significant 1-bit in a, or
* the value zero if a is zero. The least significant bit is index one.
*/
si_int
__ffsdi2(di_int a)

View File

@ -1,22 +1,24 @@
//===-- ffsti2.c - Implement __ffsti2 -------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __ffsti2 for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- ffsti2.c - Implement __ffsti2 -------------------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __ffsti2 for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#if __x86_64
#include "int_lib.h"
// Returns: the index of the least significant 1-bit in a, or
// the value zero if a is zero. The least significant bit is index one.
/* Returns: the index of the least significant 1-bit in a, or
* the value zero if a is zero. The least significant bit is index one.
*/
si_int
__ffsti2(ti_int a)

View File

@ -1,27 +1,30 @@
//===-- fixunsdfdi.c - Implement __fixunsdfdi -----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __fixunsdfdi for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- fixunsdfdi.c - Implement __fixunsdfdi -----------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. 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.
/* 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)
/* 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
/* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */
du_int
__fixunsdfdi(double a)

View File

@ -1,27 +1,30 @@
//===-- fixunsdfsi.c - Implement __fixunsdfsi -----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __fixunsdfsi for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- fixunsdfsi.c - Implement __fixunsdfsi -----------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. 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.
/* 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)
/* 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
/* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */
su_int
__fixunsdfsi(double a)

View File

@ -1,29 +1,32 @@
//===-- fixunsdfti.c - Implement __fixunsdfti -----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __fixunsdfti for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- fixunsdfti.c - Implement __fixunsdfti -----------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __fixunsdfti for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#if __x86_64
#include "int_lib.h"
// Returns: convert a to a unsigned long long, rounding toward zero.
// Negative values all become zero.
/* 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)
/* 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
/* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */
tu_int
__fixunsdfti(double a)

View File

@ -1,27 +1,30 @@
//===-- fixunssfdi.c - Implement __fixunssfdi -----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __fixunssfdi for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- fixunssfdi.c - Implement __fixunssfdi -----------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. 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.
/* 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)
/* 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
/* seee eeee emmm mmmm mmmm mmmm mmmm mmmm */
du_int
__fixunssfdi(float a)

View File

@ -1,27 +1,30 @@
//===-- fixunssfsi.c - Implement __fixunssfsi -----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __fixunssfsi for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- fixunssfsi.c - Implement __fixunssfsi -----------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __fixunssfsi for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#include "int_lib.h"
// Returns: convert a to a unsigned int, rounding toward zero.
// Negative values all become zero.
/* Returns: convert a to a unsigned int, rounding toward zero.
* Negative values all become zero.
*/
// Assumption: 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)
/* 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
/* seee eeee emmm mmmm mmmm mmmm mmmm mmmm */
su_int
__fixunssfsi(float a)

View File

@ -1,29 +1,32 @@
//===-- fixunssfti.c - Implement __fixunssfti -----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __fixunssfti for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- fixunssfti.c - Implement __fixunssfti -----------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __fixunssfti for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#if __x86_64
#include "int_lib.h"
// Returns: convert a to a unsigned long long, rounding toward zero.
// Negative values all become zero.
/* 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)
/* 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
// seee eeee emmm mmmm mmmm mmmm mmmm mmmm */
tu_int
__fixunssfti(float a)

View File

@ -1,30 +1,34 @@
//===-- fixunsxfdi.c - Implement __fixunsxfdi -----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __fixunsxfdi for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- fixunsxfdi.c - Implement __fixunsxfdi -----------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __fixunsxfdi for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#if !_ARCH_PPC
#include "int_lib.h"
// Returns: convert a to a unsigned long long, rounding toward zero.
// Negative values all become zero.
/* Returns: convert a to a unsigned long long, rounding toward zero.
* Negative values all become zero.
*/
// Assumption: long double is an intel 80 bit floating point type padded with 6 bytes
// du_int is a 64 bit integral type
// value in long double is representable in du_int or is negative
// (no range checking performed)
/* Assumption: long double is an intel 80 bit floating point type padded with 6 bytes
* du_int is a 64 bit integral type
* value in long double is representable in du_int or is negative
* (no range checking performed)
*/
// gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
// 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
/* gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
* 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
*/
du_int
__fixunsxfdi(long double a)

View File

@ -1,30 +1,34 @@
//===-- fixunsxfti.c - Implement __fixunsxfti -----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __fixunsxfti for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- fixunsxfti.c - Implement __fixunsxfti -----------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __fixunsxfti for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#if __x86_64
#include "int_lib.h"
// Returns: convert a to a unsigned long long, rounding toward zero.
// Negative values all become zero.
/* Returns: convert a to a unsigned long long, rounding toward zero.
* Negative values all become zero.
*/
// Assumption: long double is an intel 80 bit floating point type padded with 6 bytes
// tu_int is a 64 bit integral type
// value in long double is representable in tu_int or is negative
// (no range checking performed)
/* Assumption: long double is an intel 80 bit floating point type padded with 6 bytes
* tu_int is a 64 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 |
// 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
/* gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
* 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
*/
tu_int
__fixunsxfti(long double a)

View File

@ -1,28 +1,31 @@
//===-- fixxfdi.c - Implement __fixxfdi -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __fixxfdi for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- fixxfdi.c - Implement __fixxfdi -----------------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __fixxfdi for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#if !_ARCH_PPC
#include "int_lib.h"
// Returns: convert a to a signed long long, rounding toward zero.
/* Returns: convert a to a signed long long, rounding toward zero. */
// Assumption: 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 di_int (no range checking performed)
/* Assumption: long double is an intel 80 bit floating point type padded with 6 bytes
* su_int is a 32 bit integral type
* value in long double is representable in di_int (no range checking performed)
*/
// gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
// 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
/* gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
* 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
*/
di_int
__fixxfdi(long double a)

View File

@ -1,28 +1,31 @@
//===-- fixxfti.c - Implement __fixxfti -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __fixxfti for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- fixxfti.c - Implement __fixxfti -----------------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __fixxfti for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#if __x86_64
#include "int_lib.h"
// Returns: convert a to a signed long long, rounding toward zero.
/* Returns: convert a to a signed long long, rounding toward zero. */
// Assumption: 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)
/* 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)
*/
// gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
// 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
/* gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
* 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
*/
ti_int
__fixxfti(long double a)

View File

@ -1,28 +1,31 @@
//===-- floattixf.c - Implement __floattixf -------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __floattixf for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- floattixf.c - Implement __floattixf -------------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __floattixf for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#if __x86_64
#include "int_lib.h"
#include <float.h>
// Returns: convert a to a long double, rounding toward even.
/* Returns: convert a to a long double, rounding toward even. */
// Assumption: long double is a IEEE 80 bit floating point type padded to 128 bits
// ti_int is a 128 bit integral type
/* Assumption: long double is a IEEE 80 bit floating point type padded to 128 bits
* ti_int is a 128 bit integral type
*/
// gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
// 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
/* gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
* 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
*/
si_int __clzti2(ti_int a);
@ -38,13 +41,14 @@ __floattixf(ti_int a)
int e = sd - 1; // exponent
if (sd > LDBL_MANT_DIG)
{
// start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx
// finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR
// 12345678901234567890123456
// 1 = msb 1 bit
// P = bit LDBL_MANT_DIG-1 bits to the right of 1
// Q = bit LDBL_MANT_DIG bits to the right of 1
// R = "or" of all bits to the right of Q
/* start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx
* finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR
* 12345678901234567890123456
* 1 = msb 1 bit
* P = bit LDBL_MANT_DIG-1 bits to the right of 1
* Q = bit LDBL_MANT_DIG bits to the right of 1
* R = "or" of all bits to the right of Q
*/
switch (sd)
{
case LDBL_MANT_DIG + 1:
@ -56,27 +60,27 @@ __floattixf(ti_int a)
a = ((tu_int)a >> (sd - (LDBL_MANT_DIG+2))) |
((a & ((tu_int)(-1) >> ((N + LDBL_MANT_DIG+2) - sd))) != 0);
};
// finish:
a |= (a & 4) != 0; // Or P into R
++a; // round - this step may add a significant bit
a >>= 2; // dump Q and R
// a is now rounded to LDBL_MANT_DIG or LDBL_MANT_DIG+1 bits
/* finish: */
a |= (a & 4) != 0; /* Or P into R */
++a; /* round - this step may add a significant bit */
a >>= 2; /* dump Q and R */
/* a is now rounded to LDBL_MANT_DIG or LDBL_MANT_DIG+1 bits */
if (a & ((tu_int)1 << LDBL_MANT_DIG))
{
a >>= 1;
++e;
}
// a is now rounded to LDBL_MANT_DIG bits
/* a is now rounded to LDBL_MANT_DIG bits */
}
else
{
a <<= (LDBL_MANT_DIG - sd);
// a is now rounded to LDBL_MANT_DIG bits
/* a is now rounded to LDBL_MANT_DIG bits */
}
long_double_bits fb;
fb.u.high.low = ((su_int)s & 0x8000) | // sign
(e + 16383); // exponent
fb.u.low.all = (du_int)a; // mantissa
fb.u.high.low = ((su_int)s & 0x8000) | /* sign */
(e + 16383); /* exponent */
fb.u.low.all = (du_int)a; /* mantissa */
return fb.f;
}

View File

@ -1,28 +1,31 @@
//===-- floatuntixf.c - Implement __floatuntixf ---------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __floatuntixf for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- floatuntixf.c - Implement __floatuntixf ---------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __floatuntixf for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#if __x86_64
#include "int_lib.h"
#include <float.h>
// Returns: convert a to a long double, rounding toward even.
/* Returns: convert a to a long double, rounding toward even. */
// Assumption: long double is a IEEE 80 bit floating point type padded to 128 bits
// tu_int is a 128 bit integral type
/* Assumption: long double is a IEEE 80 bit floating point type padded to 128 bits
* tu_int is a 128 bit integral type
*/
// gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
// 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
/* gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
* 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
*/
si_int __clzti2(ti_int a);
@ -32,17 +35,18 @@ __floatuntixf(tu_int a)
if (a == 0)
return 0.0;
const unsigned N = sizeof(tu_int) * CHAR_BIT;
int sd = N - __clzti2(a); // number of significant digits
int e = sd - 1; // exponent
int sd = N - __clzti2(a); /* number of significant digits */
int e = sd - 1; /* exponent */
if (sd > LDBL_MANT_DIG)
{
// start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx
// finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR
// 12345678901234567890123456
// 1 = msb 1 bit
// P = bit LDBL_MANT_DIG-1 bits to the right of 1
// Q = bit LDBL_MANT_DIG bits to the right of 1
// R = "or" of all bits to the right of Q
/* start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx
* finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR
* 12345678901234567890123456
* 1 = msb 1 bit
* P = bit LDBL_MANT_DIG-1 bits to the right of 1
* Q = bit LDBL_MANT_DIG bits to the right of 1
* R = "or" of all bits to the right of Q
*/
switch (sd)
{
case LDBL_MANT_DIG + 1:
@ -54,26 +58,26 @@ __floatuntixf(tu_int a)
a = (a >> (sd - (LDBL_MANT_DIG+2))) |
((a & ((tu_int)(-1) >> ((N + LDBL_MANT_DIG+2) - sd))) != 0);
};
// finish:
a |= (a & 4) != 0; // Or P into R
++a; // round - this step may add a significant bit
a >>= 2; // dump Q and R
// a is now rounded to LDBL_MANT_DIG or LDBL_MANT_DIG+1 bits
/* finish: */
a |= (a & 4) != 0; /* Or P into R */
++a; /* round - this step may add a significant bit */
a >>= 2; /* dump Q and R */
/* a is now rounded to LDBL_MANT_DIG or LDBL_MANT_DIG+1 bits */
if (a & ((tu_int)1 << LDBL_MANT_DIG))
{
a >>= 1;
++e;
}
// a is now rounded to LDBL_MANT_DIG bits
/* a is now rounded to LDBL_MANT_DIG bits */
}
else
{
a <<= (LDBL_MANT_DIG - sd);
// a is now rounded to LDBL_MANT_DIG bits
/* a is now rounded to LDBL_MANT_DIG bits */
}
long_double_bits fb;
fb.u.high.low = (e + 16383); // exponent
fb.u.low.all = (du_int)a; // mantissa
fb.u.high.low = (e + 16383); /* exponent */
fb.u.low.all = (du_int)a; /* mantissa */
return fb.f;
}

View File

@ -1,20 +1,23 @@
//===-- gcc_personality_v0.c - Implement __gcc_personality_v0 -------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/* ===-- gcc_personality_v0.c - Implement __gcc_personality_v0 -------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
*/
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
//
// _Unwind_* stuff based on C++ ABI public documentation
// http://refspecs.freestandards.org/abi-eh-1.21.html
//
/*
* _Unwind_* stuff based on C++ ABI public documentation
* http://refspecs.freestandards.org/abi-eh-1.21.html
*/
typedef enum {
_URC_NO_REASON = 0,
_URC_FOREIGN_EXCEPTION_CAUGHT = 1,
@ -52,11 +55,12 @@ extern uintptr_t _Unwind_GetIP(_Unwind_Context_t context);
extern uintptr_t _Unwind_GetRegionStart(_Unwind_Context_t context);
//
// Pointer encodings documented at:
// http://refspecs.freestandards.org/LSB_1.3.0/gLSB/gLSB/ehframehdr.html
//
#define DW_EH_PE_omit 0xff // no data follows
/*
* Pointer encodings documented at:
* http://refspecs.freestandards.org/LSB_1.3.0/gLSB/gLSB/ehframehdr.html
*/
#define DW_EH_PE_omit 0xff /* no data follows */
#define DW_EH_PE_absptr 0x00
#define DW_EH_PE_uleb128 0x01
@ -73,11 +77,11 @@ extern uintptr_t _Unwind_GetRegionStart(_Unwind_Context_t context);
#define DW_EH_PE_datarel 0x30
#define DW_EH_PE_funcrel 0x40
#define DW_EH_PE_aligned 0x50
#define DW_EH_PE_indirect 0x80 // gcc extension
#define DW_EH_PE_indirect 0x80 /* gcc extension */
// read a uleb128 encoded value and advance pointer
/* read a uleb128 encoded value and advance pointer */
static uintptr_t readULEB128(const uint8_t** data)
{
uintptr_t result = 0;
@ -93,7 +97,7 @@ static uintptr_t readULEB128(const uint8_t** data)
return result;
}
// read a pointer encoded value and advance pointer
/* read a pointer encoded value and advance pointer */
static uintptr_t readEncodedPointer(const uint8_t** data, uint8_t encoding)
{
const uint8_t* p = *data;
@ -102,7 +106,7 @@ static uintptr_t readEncodedPointer(const uint8_t** data, uint8_t encoding)
if ( encoding == DW_EH_PE_omit )
return 0;
// first get value
/* first get value */
switch (encoding & 0x0F) {
case DW_EH_PE_absptr:
result = *((uintptr_t*)p);
@ -137,15 +141,15 @@ static uintptr_t readEncodedPointer(const uint8_t** data, uint8_t encoding)
break;
case DW_EH_PE_sleb128:
default:
// not supported
/* not supported */
abort();
break;
}
// then add relative offset
/* then add relative offset */
switch ( encoding & 0x70 ) {
case DW_EH_PE_absptr:
// do nothing
/* do nothing */
break;
case DW_EH_PE_pcrel:
result += (uintptr_t)(*data);
@ -155,12 +159,12 @@ static uintptr_t readEncodedPointer(const uint8_t** data, uint8_t encoding)
case DW_EH_PE_funcrel:
case DW_EH_PE_aligned:
default:
// not supported
/* not supported */
abort();
break;
}
// then apply indirection
/* then apply indirection */
if (encoding & DW_EH_PE_indirect) {
result = *((uintptr_t*)result);
}
@ -170,24 +174,25 @@ static uintptr_t readEncodedPointer(const uint8_t** data, uint8_t encoding)
}
//
// The C compiler makes references to __gcc_personality_v0 in
// the dwarf unwind information for translation units that use
// __attribute__((cleanup(xx))) on local variables.
// This personality routine is called by the system unwinder
// on each frame as the stack is unwound during a C++ exception
// throw through a C function compiled with -fexceptions.
//
/*
* The C compiler makes references to __gcc_personality_v0 in
* the dwarf unwind information for translation units that use
* __attribute__((cleanup(xx))) on local variables.
* This personality routine is called by the system unwinder
* on each frame as the stack is unwound during a C++ exception
* throw through a C function compiled with -fexceptions.
*/
_Unwind_Reason_Code __gcc_personality_v0(int version, _Unwind_Action actions,
uint64_t exceptionClass, struct _Unwind_Exception* exceptionObject,
_Unwind_Context_t context)
{
// Since C does not have catch clauses, there is nothing to do during
// phase 1 (the search phase).
/* Since C does not have catch clauses, there is nothing to do during */
/* phase 1 (the search phase). */
if ( actions & _UA_SEARCH_PHASE )
return _URC_CONTINUE_UNWIND;
// There is nothing to do if there is no LSDA for this frame.
/* There is nothing to do if there is no LSDA for this frame. */
const uint8_t* lsda = _Unwind_GetLanguageSpecificData(context);
if ( lsda == NULL )
return _URC_CONTINUE_UNWIND;
@ -196,7 +201,7 @@ _Unwind_Reason_Code __gcc_personality_v0(int version, _Unwind_Action actions,
uintptr_t funcStart = _Unwind_GetRegionStart(context);
uintptr_t pcOffset = pc - funcStart;
// Parse LSDA header.
/* Parse LSDA header. */
uint8_t lpStartEncoding = *lsda++;
if (lpStartEncoding != DW_EH_PE_omit) {
readEncodedPointer(&lsda, lpStartEncoding);
@ -205,7 +210,7 @@ _Unwind_Reason_Code __gcc_personality_v0(int version, _Unwind_Action actions,
if (ttypeEncoding != DW_EH_PE_omit) {
readULEB128(&lsda);
}
// Walk call-site table looking for range that includes current PC.
/* Walk call-site table looking for range that includes current PC. */
uint8_t callSiteEncoding = *lsda++;
uint32_t callSiteTableLength = readULEB128(&lsda);
const uint8_t* callSiteTableStart = lsda;
@ -215,14 +220,15 @@ _Unwind_Reason_Code __gcc_personality_v0(int version, _Unwind_Action actions,
uintptr_t start = readEncodedPointer(&p, callSiteEncoding);
uintptr_t length = readEncodedPointer(&p, callSiteEncoding);
uintptr_t landingPad = readEncodedPointer(&p, callSiteEncoding);
readULEB128(&p); // action value not used for C code
readULEB128(&p); /* action value not used for C code */
if ( landingPad == 0 )
continue; // no landing pad for this entry
continue; /* no landing pad for this entry */
if ( (start <= pcOffset) && (pcOffset < (start+length)) ) {
// Found landing pad for the PC.
// Set Instruction Pointer to so we re-enter function
// at landing pad. The landing pad is created by the compiler
// to take two parameters in registers.
/* Found landing pad for the PC.
* Set Instruction Pointer to so we re-enter function
* at landing pad. The landing pad is created by the compiler
* to take two parameters in registers.
*/
_Unwind_SetGR(context, __builtin_eh_return_data_regno(0),
(uintptr_t)exceptionObject);
_Unwind_SetGR(context, __builtin_eh_return_data_regno(1), 0);
@ -231,7 +237,7 @@ _Unwind_Reason_Code __gcc_personality_v0(int version, _Unwind_Action actions,
}
}
// No landing pad found, continue unwinding.
/* No landing pad found, continue unwinding. */
return _URC_CONTINUE_UNWIND;
}

View File

@ -1,21 +1,22 @@
//===-- lshrdi3.c - Implement __lshrdi3 -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __lshrdi3 for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- lshrdi3.c - Implement __lshrdi3 -----------------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __lshrdi3 for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#include "int_lib.h"
// Returns: logical a >> b
/* Returns: logical a >> b */
// Precondition: 0 <= b < bits_in_dword
/* Precondition: 0 <= b < bits_in_dword */
di_int
__lshrdi3(di_int a, si_int b)
@ -24,12 +25,12 @@ __lshrdi3(di_int a, si_int b)
udwords input;
udwords result;
input.all = a;
if (b & bits_in_word) // bits_in_word <= b < bits_in_dword
if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */
{
result.high = 0;
result.low = input.high >> (b - bits_in_word);
}
else // 0 <= b < bits_in_word
else /* 0 <= b < bits_in_word */
{
if (b == 0)
return a;

View File

@ -1,23 +1,24 @@
//===-- lshrti3.c - Implement __lshrti3 -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __lshrti3 for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- lshrti3.c - Implement __lshrti3 -----------------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __lshrti3 for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#if __x86_64
#include "int_lib.h"
// Returns: logical a >> b
/* Returns: logical a >> b */
// Precondition: 0 <= b < bits_in_tword
/* Precondition: 0 <= b < bits_in_tword */
ti_int
__lshrti3(ti_int a, si_int b)
@ -26,12 +27,12 @@ __lshrti3(ti_int a, si_int b)
utwords input;
utwords result;
input.all = a;
if (b & bits_in_dword) // bits_in_dword <= b < bits_in_tword
if (b & bits_in_dword) /* bits_in_dword <= b < bits_in_tword */
{
result.high = 0;
result.low = input.high >> (b - bits_in_dword);
}
else // 0 <= b < bits_in_dword
else /* 0 <= b < bits_in_dword */
{
if (b == 0)
return a;

View File

@ -1,24 +1,26 @@
//===-- negdi2.c - Implement __negdi2 -------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __negdi2 for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- negdi2.c - Implement __negdi2 -------------------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __negdi2 for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#include "int_lib.h"
// Returns: -a
/* Returns: -a */
di_int
__negdi2(di_int a)
{
// Note: this routine is here for API compatibility; any sane compiler
// should expand it inline.
/* Note: this routine is here for API compatibility; any sane compiler
* should expand it inline.
*/
return -a;
}

View File

@ -1,27 +1,29 @@
//===-- negti2.c - Implement __negti2 -------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __negti2 for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- negti2.c - Implement __negti2 -------------------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __negti2 for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#if __x86_64
#include "int_lib.h"
// Returns: -a
/* Returns: -a */
ti_int
__negti2(ti_int a)
{
// Note: this routine is here for API compatibility; any sane compiler
// should expand it inline.
/* Note: this routine is here for API compatibility; any sane compiler
* should expand it inline.
*/
return -a;
}

View File

@ -1,22 +1,23 @@
//===-- negvdi2.c - Implement __negvdi2 -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __negvdi2 for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- negvdi2.c - Implement __negvdi2 -----------------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __negvdi2 for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#include "int_lib.h"
#include <stdlib.h>
// Returns: -a
/* Returns: -a */
// Effects: aborts if -a overflows
/* Effects: aborts if -a overflows */
di_int
__negvdi2(di_int a)

View File

@ -1,22 +1,23 @@
//===-- negvsi2.c - Implement __negvsi2 -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __negvsi2 for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- negvsi2.c - Implement __negvsi2 -----------------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __negvsi2 for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#include "int_lib.h"
#include <stdlib.h>
// Returns: -a
/* Returns: -a */
// Effects: aborts if -a overflows
/* Effects: aborts if -a overflows */
si_int
__negvsi2(si_int a)

View File

@ -1,22 +1,23 @@
//===-- subvdi3.c - Implement __subvdi3 -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __subvdi3 for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- subvdi3.c - Implement __subvdi3 -----------------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __subvdi3 for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#include "int_lib.h"
#include <stdlib.h>
// Returns: a - b
/* Returns: a - b */
// Effects: aborts if a - b overflows
/* Effects: aborts if a - b overflows */
di_int
__subvdi3(di_int a, di_int b)

View File

@ -1,22 +1,23 @@
//===-- subvsi3.c - Implement __subvsi3 -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __subvsi3 for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- subvsi3.c - Implement __subvsi3 -----------------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __subvsi3 for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#include "int_lib.h"
#include <stdlib.h>
// Returns: a - b
/* Returns: a - b */
// Effects: aborts if a - b overflows
/* Effects: aborts if a - b overflows */
si_int
__subvsi3(si_int a, si_int b)

View File

@ -1,24 +1,25 @@
//===-- subvti3.c - Implement __subvti3 -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements __subvti3 for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
/* ===-- subvti3.c - Implement __subvti3 -----------------------------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*
* This file implements __subvti3 for the compiler_rt library.
*
* ===----------------------------------------------------------------------===
*/
#if __x86_64
#include "int_lib.h"
#include <stdlib.h>
// Returns: a - b
/* Returns: a - b */
// Effects: aborts if a - b overflows
/* Effects: aborts if a - b overflows */
ti_int
__subvti3(ti_int a, ti_int b)

View File

@ -1,46 +1,48 @@
//===----- trampoline_setup.c - Implement __trampoline_setup -------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/* ===----- trampoline_setup.c - Implement __trampoline_setup -------------===
*
* The LLVM Compiler Infrastructure
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
* ===----------------------------------------------------------------------===
*/
#include <stdint.h>
#include <stdlib.h>
extern void __clear_cache(void* start, void* end);
//
// The ppc compiler generates calls to __trampoline_setup() when creating
// trampoline functions on the stack for use with nested functions.
// This function creates a custom 40-byte trampoline function on the stack
// which loads r11 with a pointer to the outer function's locals
// and then jumps to the target nested function.
//
/*
* The ppc compiler generates calls to __trampoline_setup() when creating
* trampoline functions on the stack for use with nested functions.
* This function creates a custom 40-byte trampoline function on the stack
* which loads r11 with a pointer to the outer function's locals
* and then jumps to the target nested function.
*/
#if __ppc__
void __trampoline_setup(uint32_t* trampOnStack, int trampSizeAllocated,
const void* realFunc, void* localsPtr)
{
// should never happen, but if compiler did not allocate
// enough space on stack for the trampoline, abort
/* should never happen, but if compiler did not allocate */
/* enough space on stack for the trampoline, abort */
if ( trampSizeAllocated < 40 )
abort();
// create trampoline
trampOnStack[0] = 0x7c0802a6; // mflr r0
trampOnStack[1] = 0x4800000d; // bl Lbase
/* create trampoline */
trampOnStack[0] = 0x7c0802a6; /* mflr r0 */
trampOnStack[1] = 0x4800000d; /* bl Lbase */
trampOnStack[2] = (uint32_t)realFunc;
trampOnStack[3] = (uint32_t)localsPtr;
trampOnStack[4] = 0x7d6802a6; // Lbase: mflr r11
trampOnStack[5] = 0x818b0000; // lwz r12,0(r11)
trampOnStack[6] = 0x7c0803a6; // mtlr r0
trampOnStack[7] = 0x7d8903a6; // mtctr r12
trampOnStack[8] = 0x816b0004; // lwz r11,4(r11)
trampOnStack[9] = 0x4e800420; // bctr
trampOnStack[4] = 0x7d6802a6; /* Lbase: mflr r11 */
trampOnStack[5] = 0x818b0000; /* lwz r12,0(r11) */
trampOnStack[6] = 0x7c0803a6; /* mtlr r0 */
trampOnStack[7] = 0x7d8903a6; /* mtctr r12 */
trampOnStack[8] = 0x816b0004; /* lwz r11,4(r11) */
trampOnStack[9] = 0x4e800420; /* bctr */
// clear instruction cache
/* clear instruction cache */
__clear_cache(trampOnStack, &trampOnStack[10]);
}
#endif // __ppc__
#endif /* __ppc__ */