Skip to content
This repository was archived by the owner on Mar 31, 2025. It is now read-only.

Commit 38942e9

Browse files
committed
Initial commit
0 parents  commit 38942e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+3400
-0
lines changed

CREDITS.TXT

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
This file is a partial list of people who have contributed to the LLVM/CompilerRT
2+
project. If you have contributed a patch or made some other contribution to
3+
LLVM/CompilerRT, please submit a patch to this file to add yourself, and it will be
4+
done!
5+
6+
The list is sorted by surname and formatted to allow easy grepping and
7+
beautification by scripts. The fields are: name (N), email (E), web-address
8+
(W), PGP key ID and fingerprint (P), description (D), and snail-mail address
9+
(S).
10+
11+
N: Craig van Vliet
12+
13+
W: http://www.auroraux.org
14+
D: Code style and Readability fixes.
15+
16+
N: Edward O'Callaghan
17+
18+
W: http://www.auroraux.org
19+
D: CMake'ify Compiler-RT build system
20+
D: Maintain Solaris & AuroraUX ports of Compiler-RT
21+
22+
N: Howard Hinnant
23+
24+
D: Architect and primary author of compiler-rt
25+
26+
N: Guan-Hong Liu
27+
28+
D: IEEE Quad-precision functions
29+
30+
N: Joerg Sonnenberger
31+
32+
D: Maintains NetBSD port.
33+
34+
N: Matt Thomas
35+
36+
D: ARM improvements.

LICENSE.TXT

Lines changed: 311 additions & 0 deletions
Large diffs are not rendered by default.

README

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cc-runtime
2+
==========
3+
4+
cc-runtime is a freestanding, integer-only, easy to integrate subset of LLVM's
5+
compiler-rt libgcc-compatibility functions.
6+
7+
Relevant licenses apply: see license headers in source files and LICENSE.TXT.

absvdi2.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//===-- absvdi2.c - Implement __absvdi2 -----------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file implements __absvdi2 for the compiler_rt library.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "int_lib.h"
14+
15+
// Returns: absolute value
16+
17+
// Effects: aborts if abs(x) < 0
18+
19+
COMPILER_RT_ABI di_int __absvdi2(di_int a) {
20+
const int N = (int)(sizeof(di_int) * CHAR_BIT);
21+
if (a == ((di_int)((du_int)1 << (N - 1))))
22+
compilerrt_abort();
23+
const di_int t = a >> (N - 1);
24+
return (a ^ t) - t;
25+
}

absvsi2.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//===-- absvsi2.c - Implement __absvsi2 -----------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file implements __absvsi2 for the compiler_rt library.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "int_lib.h"
14+
15+
// Returns: absolute value
16+
17+
// Effects: aborts if abs(x) < 0
18+
19+
COMPILER_RT_ABI si_int __absvsi2(si_int a) {
20+
const int N = (int)(sizeof(si_int) * CHAR_BIT);
21+
if (a == ((si_int)((su_int)1 << (N - 1))))
22+
compilerrt_abort();
23+
const si_int t = a >> (N - 1);
24+
return (a ^ t) - t;
25+
}

absvti2.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//===-- absvti2.c - Implement __absvdi2 -----------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file implements __absvti2 for the compiler_rt library.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "int_lib.h"
14+
15+
#ifdef CRT_HAS_128BIT
16+
17+
// Returns: absolute value
18+
19+
// Effects: aborts if abs(x) < 0
20+
21+
COMPILER_RT_ABI ti_int __absvti2(ti_int a) {
22+
const int N = (int)(sizeof(ti_int) * CHAR_BIT);
23+
if (a == (ti_int)((tu_int)1 << (N - 1)))
24+
compilerrt_abort();
25+
const ti_int s = a >> (N - 1);
26+
return (a ^ s) - s;
27+
}
28+
29+
#endif // CRT_HAS_128BIT

addvdi3.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//===-- addvdi3.c - Implement __addvdi3 -----------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file implements __addvdi3 for the compiler_rt library.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "int_lib.h"
14+
15+
// Returns: a + b
16+
17+
// Effects: aborts if a + b overflows
18+
19+
COMPILER_RT_ABI di_int __addvdi3(di_int a, di_int b) {
20+
di_int s = (du_int)a + (du_int)b;
21+
if (b >= 0) {
22+
if (s < a)
23+
compilerrt_abort();
24+
} else {
25+
if (s >= a)
26+
compilerrt_abort();
27+
}
28+
return s;
29+
}

addvsi3.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//===-- addvsi3.c - Implement __addvsi3 -----------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file implements __addvsi3 for the compiler_rt library.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "int_lib.h"
14+
15+
// Returns: a + b
16+
17+
// Effects: aborts if a + b overflows
18+
19+
COMPILER_RT_ABI si_int __addvsi3(si_int a, si_int b) {
20+
si_int s = (su_int)a + (su_int)b;
21+
if (b >= 0) {
22+
if (s < a)
23+
compilerrt_abort();
24+
} else {
25+
if (s >= a)
26+
compilerrt_abort();
27+
}
28+
return s;
29+
}

addvti3.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//===-- addvti3.c - Implement __addvti3 -----------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file implements __addvti3 for the compiler_rt library.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "int_lib.h"
14+
15+
#ifdef CRT_HAS_128BIT
16+
17+
// Returns: a + b
18+
19+
// Effects: aborts if a + b overflows
20+
21+
COMPILER_RT_ABI ti_int __addvti3(ti_int a, ti_int b) {
22+
ti_int s = (tu_int)a + (tu_int)b;
23+
if (b >= 0) {
24+
if (s < a)
25+
compilerrt_abort();
26+
} else {
27+
if (s >= a)
28+
compilerrt_abort();
29+
}
30+
return s;
31+
}
32+
33+
#endif // CRT_HAS_128BIT

ashldi3.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// ====-- ashldi3.c - Implement __ashldi3 ---------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file implements __ashldi3 for the compiler_rt library.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "int_lib.h"
14+
15+
// Returns: a << b
16+
17+
// Precondition: 0 <= b < bits_in_dword
18+
19+
COMPILER_RT_ABI di_int __ashldi3(di_int a, int b) {
20+
const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT);
21+
dwords input;
22+
dwords result;
23+
input.all = a;
24+
if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */ {
25+
result.s.low = 0;
26+
result.s.high = input.s.low << (b - bits_in_word);
27+
} else /* 0 <= b < bits_in_word */ {
28+
if (b == 0)
29+
return a;
30+
result.s.low = input.s.low << b;
31+
result.s.high =
32+
((su_int)input.s.high << b) | (input.s.low >> (bits_in_word - b));
33+
}
34+
return result.all;
35+
}
36+
37+
#if defined(__ARM_EABI__)
38+
COMPILER_RT_ALIAS(__ashldi3, __aeabi_llsl)
39+
#endif

ashlti3.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//===-- ashlti3.c - Implement __ashlti3 -----------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file implements __ashlti3 for the compiler_rt library.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "int_lib.h"
14+
15+
#ifdef CRT_HAS_128BIT
16+
17+
// Returns: a << b
18+
19+
// Precondition: 0 <= b < bits_in_tword
20+
21+
COMPILER_RT_ABI ti_int __ashlti3(ti_int a, int b) {
22+
const int bits_in_dword = (int)(sizeof(di_int) * CHAR_BIT);
23+
twords input;
24+
twords result;
25+
input.all = a;
26+
if (b & bits_in_dword) /* bits_in_dword <= b < bits_in_tword */ {
27+
result.s.low = 0;
28+
result.s.high = input.s.low << (b - bits_in_dword);
29+
} else /* 0 <= b < bits_in_dword */ {
30+
if (b == 0)
31+
return a;
32+
result.s.low = input.s.low << b;
33+
result.s.high =
34+
((du_int)input.s.high << b) | (input.s.low >> (bits_in_dword - b));
35+
}
36+
return result.all;
37+
}
38+
39+
#endif // CRT_HAS_128BIT

ashrdi3.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//===-- ashrdi3.c - Implement __ashrdi3 -----------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file implements __ashrdi3 for the compiler_rt library.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "int_lib.h"
14+
15+
// Returns: arithmetic a >> b
16+
17+
// Precondition: 0 <= b < bits_in_dword
18+
19+
COMPILER_RT_ABI di_int __ashrdi3(di_int a, int b) {
20+
const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT);
21+
dwords input;
22+
dwords result;
23+
input.all = a;
24+
if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */ {
25+
// result.s.high = input.s.high < 0 ? -1 : 0
26+
result.s.high = input.s.high >> (bits_in_word - 1);
27+
result.s.low = input.s.high >> (b - bits_in_word);
28+
} else /* 0 <= b < bits_in_word */ {
29+
if (b == 0)
30+
return a;
31+
result.s.high = input.s.high >> b;
32+
result.s.low =
33+
((su_int)input.s.high << (bits_in_word - b)) | (input.s.low >> b);
34+
}
35+
return result.all;
36+
}
37+
38+
#if defined(__ARM_EABI__)
39+
COMPILER_RT_ALIAS(__ashrdi3, __aeabi_lasr)
40+
#endif

ashrti3.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//===-- ashrti3.c - Implement __ashrti3 -----------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file implements __ashrti3 for the compiler_rt library.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "int_lib.h"
14+
15+
#ifdef CRT_HAS_128BIT
16+
17+
// Returns: arithmetic a >> b
18+
19+
// Precondition: 0 <= b < bits_in_tword
20+
21+
COMPILER_RT_ABI ti_int __ashrti3(ti_int a, int b) {
22+
const int bits_in_dword = (int)(sizeof(di_int) * CHAR_BIT);
23+
twords input;
24+
twords result;
25+
input.all = a;
26+
if (b & bits_in_dword) /* bits_in_dword <= b < bits_in_tword */ {
27+
// result.s.high = input.s.high < 0 ? -1 : 0
28+
result.s.high = input.s.high >> (bits_in_dword - 1);
29+
result.s.low = input.s.high >> (b - bits_in_dword);
30+
} else /* 0 <= b < bits_in_dword */ {
31+
if (b == 0)
32+
return a;
33+
result.s.high = input.s.high >> b;
34+
result.s.low =
35+
((du_int)input.s.high << (bits_in_dword - b)) | (input.s.low >> b);
36+
}
37+
return result.all;
38+
}
39+
40+
#endif // CRT_HAS_128BIT

0 commit comments

Comments
 (0)