diff options
55 files changed, 1248 insertions, 1137 deletions
diff --git a/CREDITS.TXT b/CREDITS.TXT index c73c760d3..8b07b82bf 100644 --- a/CREDITS.TXT +++ b/CREDITS.TXT @@ -8,6 +8,11 @@ beautification by scripts. The fields are: name (N), email (E), web-address (W), PGP key ID and fingerprint (P), description (D), and snail-mail address (S). +N: Craig van Vliet +E: cvanvliet@auroraux.org +W: http://www.auroraux.org +D: Code style and Readability fixes. + N: Edward O'Callaghan E: eocallaghan@auroraux.org W: http://www.auroraux.org diff --git a/lib/absvdi2.c b/lib/absvdi2.c index b49554ecc..396802c5c 100644 --- a/lib/absvdi2.c +++ b/lib/absvdi2.c @@ -1,22 +1,23 @@ -//===-- absvdi2.c - Implement __absvdi2 -----------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __absvdi2 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/*===-- absvdi2.c - Implement __absvdi2 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + *===----------------------------------------------------------------------=== + * + * This file implements __absvdi2 for the compiler_rt library. + * + *===----------------------------------------------------------------------=== + */ #include "int_lib.h" #include <stdlib.h> -// Returns: absolute value +/* Returns: absolute value */ -// Effects: aborts if abs(x) < 0 +/* Effects: aborts if abs(x) < 0 */ di_int __absvdi2(di_int a) diff --git a/lib/absvsi2.c b/lib/absvsi2.c index 5b28da089..0c08bf045 100644 --- a/lib/absvsi2.c +++ b/lib/absvsi2.c @@ -1,22 +1,23 @@ -//===-- absvsi2.c - Implement __absvsi2 -----------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __absvsi2 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- absvsi2.c - Implement __absvsi2 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __absvsi2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" #include <stdlib.h> -// Returns: absolute value +/* Returns: absolute value */ -// Effects: aborts if abs(x) < 0 +/* Effects: aborts if abs(x) < 0 */ si_int __absvsi2(si_int a) diff --git a/lib/absvti2.c b/lib/absvti2.c index c0869719d..c71275ed4 100644 --- a/lib/absvti2.c +++ b/lib/absvti2.c @@ -1,24 +1,25 @@ -//===-- absvti2.c - Implement __absvdi2 -----------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __absvti2 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- absvti2.c - Implement __absvdi2 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __absvti2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #if __x86_64 #include "int_lib.h" #include <stdlib.h> -// Returns: absolute value +/* Returns: absolute value */ -// Effects: aborts if abs(x) < 0 +/* Effects: aborts if abs(x) < 0 */ ti_int __absvti2(ti_int a) diff --git a/lib/addvdi3.c b/lib/addvdi3.c index 88436e86c..8b885f53f 100644 --- a/lib/addvdi3.c +++ b/lib/addvdi3.c @@ -1,22 +1,23 @@ -//===-- addvdi3.c - Implement __addvdi3 -----------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __addvdi3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- addvdi3.c - Implement __addvdi3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __addvdi3 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 __addvdi3(di_int a, di_int b) diff --git a/lib/addvsi3.c b/lib/addvsi3.c index 0eb10c242..603c680c6 100644 --- a/lib/addvsi3.c +++ b/lib/addvsi3.c @@ -1,22 +1,23 @@ -//===-- addvsi3.c - Implement __addvsi3 -----------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __addvsi3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- addvsi3.c - Implement __addvsi3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __addvsi3 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 __addvsi3(si_int a, si_int b) diff --git a/lib/apple_versioning.c b/lib/apple_versioning.c index 44373f4d7..4db098a4e 100644 --- a/lib/apple_versioning.c +++ b/lib/apple_versioning.c @@ -1,12 +1,12 @@ -//===-- apple_versioning.c - Adds versioning symbols for ld ---------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - +/* ===-- apple_versioning.c - Adds versioning symbols for ld ---------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + */ @@ -28,10 +28,9 @@ #endif -// -// Symbols in libSystem.dylib in 10.6 and later, -// but are in libgcc_s.dylib in earlier versions -// +/* Symbols in libSystem.dylib in 10.6 and later, + * but are in libgcc_s.dylib in earlier versions + */ NOT_HERE_BEFORE_10_6(__absvdi2) NOT_HERE_BEFORE_10_6(__absvsi2) NOT_HERE_BEFORE_10_6(__absvti2) @@ -142,5 +141,5 @@ NOT_HERE_BEFORE_10_6(__trampoline_setup) #endif -#endif // __APPLE__ +#endif /* __APPLE__*/ diff --git a/lib/ashldi3.c b/lib/ashldi3.c index e9e24c31d..c818ee71a 100644 --- a/lib/ashldi3.c +++ b/lib/ashldi3.c @@ -1,21 +1,22 @@ -//===-- ashldi3.c - Implement __ashldi3 -----------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __ashldi3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ====-- ashldi3.c - Implement __ashldi3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __ashldi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" -// Returns: a << b +/* Returns: a << b */ -// Precondition: 0 <= b < bits_in_dword +/* Precondition: 0 <= b < bits_in_dword */ di_int __ashldi3(di_int a, si_int b) @@ -24,12 +25,12 @@ __ashldi3(di_int a, si_int b) dwords input; dwords 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.low = 0; result.high = input.low << (b - bits_in_word); } - else // 0 <= b < bits_in_word + else /* 0 <= b < bits_in_word */ { if (b == 0) return a; diff --git a/lib/ashlti3.c b/lib/ashlti3.c index 1b6968192..c1ab37163 100644 --- a/lib/ashlti3.c +++ b/lib/ashlti3.c @@ -1,23 +1,24 @@ -//===-- ashlti3.c - Implement __ashlti3 -----------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __ashlti3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- ashlti3.c - Implement __ashlti3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __ashlti3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #if __x86_64 #include "int_lib.h" -// Returns: a << b +/* Returns: a << b */ -// Precondition: 0 <= b < bits_in_tword +/* Precondition: 0 <= b < bits_in_tword */ ti_int __ashlti3(ti_int a, si_int b) @@ -26,12 +27,12 @@ __ashlti3(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.low = 0; result.high = input.low << (b - bits_in_dword); } - else // 0 <= b < bits_in_dword + else /* 0 <= b < bits_in_dword */ { if (b == 0) return a; @@ -41,4 +42,4 @@ __ashlti3(ti_int a, si_int b) return result.all; } -#endif +#endif /* __x86_64 */ diff --git a/lib/ashrdi3.c b/lib/ashrdi3.c index fc2e6d843..a8125a3c7 100644 --- a/lib/ashrdi3.c +++ b/lib/ashrdi3.c @@ -1,21 +1,22 @@ -//===-- ashrdi3.c - Implement __ashrdi3 -----------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __ashrdi3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/*===-- ashrdi3.c - Implement __ashrdi3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __ashrdi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" -// Returns: arithmetic a >> b +/* Returns: arithmetic a >> b */ -// Precondition: 0 <= b < bits_in_dword +/* Precondition: 0 <= b < bits_in_dword */ di_int __ashrdi3(di_int a, si_int b) @@ -24,13 +25,13 @@ __ashrdi3(di_int a, si_int b) dwords input; dwords 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 = input.high < 0 ? -1 : 0 + /* result.high = input.high < 0 ? -1 : 0 */ result.high = input.high >> (bits_in_word - 1); 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; diff --git a/lib/cmpdi2.c b/lib/cmpdi2.c index f398ea257..ece48ae9f 100644 --- a/lib/cmpdi2.c +++ b/lib/cmpdi2.c @@ -1,21 +1,23 @@ -//===-- cmpdi2.c - Implement __cmpdi2 -------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __cmpdi2 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- cmpdi2.c - Implement __cmpdi2 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __cmpdi2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" -// Returns: if (a < b) returns 0 -// if (a == b) returns 1 -// if (a > b) returns 2 +/* Returns: if (a < b) returns 0 +* if (a == b) returns 1 +* if (a > b) returns 2 +*/ si_int __cmpdi2(di_int a, di_int b) diff --git a/lib/cmpti2.c b/lib/cmpti2.c index 775977a74..b6b696d72 100644 --- a/lib/cmpti2.c +++ b/lib/cmpti2.c @@ -1,23 +1,25 @@ -//===-- cmpti2.c - Implement __cmpti2 -------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __cmpti2 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- cmpti2.c - Implement __cmpti2 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __cmpti2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #if __x86_64 #include "int_lib.h" -// Returns: if (a < b) returns 0 -// if (a == b) returns 1 -// if (a > b) returns 2 +/* Returns: if (a < b) returns 0 + * if (a == b) returns 1 + * if (a > b) returns 2 + */ si_int __cmpti2(ti_int a, ti_int b) diff --git a/lib/ctzdi2.c b/lib/ctzdi2.c index 8ea3ab319..471c93b44 100644 --- a/lib/ctzdi2.c +++ b/lib/ctzdi2.c @@ -1,21 +1,22 @@ -//===-- ctzdi2.c - Implement __ctzdi2 -------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __ctzdi2 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- ctzdi2.c - Implement __ctzdi2 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __ctzdi2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" -// Returns: the number of trailing 0-bits +/* Returns: the number of trailing 0-bits */ -// Precondition: a != 0 +/* Precondition: a != 0 */ si_int __ctzdi2(di_int a) diff --git a/lib/ctzsi2.c b/lib/ctzsi2.c index 1e6c2fe18..30d34c862 100644 --- a/lib/ctzsi2.c +++ b/lib/ctzsi2.c @@ -1,54 +1,57 @@ -//===-- ctzsi2.c - Implement __ctzsi2 -------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __ctzsi2 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- ctzsi2.c - Implement __ctzsi2 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __ctzsi2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" -// Returns: the number of trailing 0-bits +/* Returns: the number of trailing 0-bits */ -// Precondition: a != 0 +/* Precondition: a != 0 */ si_int __ctzsi2(si_int a) { su_int x = (su_int)a; - si_int t = ((x & 0x0000FFFF) == 0) << 4; // if (x has no small bits) t = 16 else 0 - x >>= t; // x = [0 - 0xFFFF] + higher garbage bits - su_int r = t; // r = [0, 16] - // return r + ctz(x) + si_int t = ((x & 0x0000FFFF) == 0) << 4; /* if (x has no small bits) t = 16 else 0 */ + x >>= t; /* x = [0 - 0xFFFF] + higher garbage bits */ + su_int r = t; /* r = [0, 16] */ + /* return r + ctz(x) */ t = ((x & 0x00FF) == 0) << 3; - x >>= t; // x = [0 - 0xFF] + higher garbage bits - r += t; // r = [0, 8, 16, 24] - // return r + ctz(x) + x >>= t; /* x = [0 - 0xFF] + higher garbage bits */ + r += t; /* r = [0, 8, 16, 24] */ + /* return r + ctz(x) */ t = ((x & 0x0F) == 0) << 2; - x >>= t; // x = [0 - 0xF] + higher garbage bits - r += t; // r = [0, 4, 8, 12, 16, 20, 24, 28] - // return r + ctz(x) + x >>= t; /* x = [0 - 0xF] + higher garbage bits */ + r += t; /* r = [0, 4, 8, 12, 16, 20, 24, 28] */ + /* return r + ctz(x) */ t = ((x & 0x3) == 0) << 1; x >>= t; - x &= 3; // x = [0 - 3] - r += t; // r = [0 - 30] and is even - // return r + ctz(x) -// The branch-less return statement below is equivalent -// to the following switch statement: -// switch (x) -// { -// case 0: -// return r + 2; -// case 2: -// return r + 1; -// case 1: -// case 3: -// return r; -// } + x &= 3; /* x = [0 - 3] */ + r += t; /* r = [0 - 30] and is even */ + /* return r + ctz(x) */ + +/* The branch-less return statement below is equivalent + * to the following switch statement: + * switch (x) + * { + * case 0: + * return r + 2; + * case 2: + * return r + 1; + * case 1: + * case 3: + * return r; + * } + */ return r + ((2 - (x >> 1)) & -((x & 1) == 0)); } diff --git a/lib/divdc3.c b/lib/divdc3.c index 1b19e665f..c96aefd0e 100644 --- a/lib/divdc3.c +++ b/lib/divdc3.c @@ -1,21 +1,22 @@ -//===-- divdc3.c - Implement __divdc3 -------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __divdc3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- divdc3.c - Implement __divdc3 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __divdc3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" #include <math.h> #include <complex.h> -// Returns: the quotient of (a + ib) / (c + id) +/* Returns: the quotient of (a + ib) / (c + id) */ double _Complex __divdc3(double __a, double __b, double __c, double __d) diff --git a/lib/divdi3.c b/lib/divdi3.c index 9580156b9..fccfb8b09 100644 --- a/lib/divdi3.c +++ b/lib/divdi3.c @@ -1,30 +1,31 @@ -//===-- divdi3.c - Implement __divdi3 -------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __divdi3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- divdi3.c - Implement __divdi3 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __divdi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" du_int __udivmoddi4(du_int a, du_int b, du_int* rem); -// Returns: a / b +/* Returns: a / b */ di_int __divdi3(di_int a, di_int b) { const int bits_in_dword_m1 = (int)(sizeof(di_int) * CHAR_BIT) - 1; - di_int s_a = a >> bits_in_dword_m1; // s_a = a < 0 ? -1 : 0 - di_int s_b = b >> bits_in_dword_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 (__udivmoddi4(a, b, (du_int*)0) ^ s_a) - s_a; // negate if s_a == -1 + di_int s_a = a >> bits_in_dword_m1; /* s_a = a < 0 ? -1 : 0 */ + di_int s_b = b >> bits_in_dword_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 (__udivmoddi4(a, b, (du_int*)0) ^ s_a) - s_a; /* negate if s_a == -1 */ } diff --git a/lib/divsc3.c b/lib/divsc3.c index bea15cdc4..c38c8638e 100644 --- a/lib/divsc3.c +++ b/lib/divsc3.c @@ -1,21 +1,22 @@ -//===-- divsc3.c - Implement __divsc3 -------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __divsc3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/*===-- divsc3.c - Implement __divsc3 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __divsc3 for the compiler_rt library. + * + *===----------------------------------------------------------------------=== + */ #include "int_lib.h" #include <math.h> #include <complex.h> -// Returns: the quotient of (a + ib) / (c + id) +/* Returns: the quotient of (a + ib) / (c + id) */ float _Complex __divsc3(float __a, float __b, float __c, float __d) diff --git a/lib/divsi3.c b/lib/divsi3.c index 8d720eb1d..0eff6ef0d 100644 --- a/lib/divsi3.c +++ b/lib/divsi3.c @@ -1,30 +1,31 @@ -//===-- divsi3.c - Implement __divsi3 -------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __divsi3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- divsi3.c - Implement __divsi3 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __divsi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" su_int __udivsi3(su_int n, su_int d); -// Returns: a / b +/* Returns: a / b */ si_int __divsi3(si_int a, si_int b) { const int bits_in_word_m1 = (int)(sizeof(si_int) * CHAR_BIT) - 1; - si_int s_a = a >> bits_in_word_m1; // s_a = a < 0 ? -1 : 0 - si_int s_b = b >> bits_in_word_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 (__udivsi3(a, b) ^ s_a) - s_a; // negate if s_a == -1 + si_int s_a = a >> bits_in_word_m1; /* s_a = a < 0 ? -1 : 0 */ + si_int s_b = b >> bits_in_word_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 (__udivsi3(a, b) ^ s_a) - s_a; /* negate if s_a == -1 */ } diff --git a/lib/divxc3.c b/lib/divxc3.c index 4ee09b9db..03357ae55 100644 --- a/lib/divxc3.c +++ b/lib/divxc3.c @@ -1,15 +1,15 @@ -//===-- divxc3.c - Implement __divxc3 -------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __divxc3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- divxc3.c - Implement __divxc3 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __divxc3 for the compiler_rt library. + * + */ #if !_ARCH_PPC @@ -17,7 +17,7 @@ #include <math.h> #include <complex.h> -// Returns: the quotient of (a + ib) / (c + id) +/* Returns: the quotient of (a + ib) / (c + id) */ long double _Complex __divxc3(long double __a, long double __b, long double __c, long double __d) diff --git a/lib/fixdfdi.c b/lib/fixdfdi.c index 87368b7e5..fa5dd8993 100644 --- a/lib/fixdfdi.c +++ b/lib/fixdfdi.c @@ -1,25 +1,27 @@ -//===-- fixdfdi.c - Implement __fixdfdi -----------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __fixdfdi for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- fixdfdi.c - Implement __fixdfdi -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. 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. +/* 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) +/* 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 +/* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */ di_int __fixdfdi(double a) @@ -38,4 +40,4 @@ __fixdfdi(double a) else r.all >>= (52 - e); return (r.all ^ s) - s; -} +} diff --git a/lib/fixdfti.c b/lib/fixdfti.c index 94fc8d3d1..00b6cfc5b 100644 --- a/lib/fixdfti.c +++ b/lib/fixdfti.c @@ -1,27 +1,29 @@ -//===-- fixdfti.c - Implement __fixdfti -----------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __fixdfti for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- fixdfti.c - Implement __fixdfti -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __fixdfti 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: 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) +/* 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 +/* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */ ti_int __fixdfti(double a) diff --git a/lib/fixsfdi.c b/lib/fixsfdi.c index 5458f0276..08f1524e1 100644 --- a/lib/fixsfdi.c +++ b/lib/fixsfdi.c @@ -1,25 +1,27 @@ -//===-- fixsfdi.c - Implement __fixsfdi -----------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __fixsfdi for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- fixsfdi.c - Implement __fixsfdi -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. 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. +/* 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) +/* 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 +/* seee eeee emmm mmmm mmmm mmmm mmmm mmmm */ di_int __fixsfdi(float a) diff --git a/lib/fixunssfti.c b/lib/fixunssfti.c index 61fe7bb03..20b7e7605 100644 --- a/lib/fixunssfti.c +++ b/lib/fixunssfti.c @@ -26,7 +26,7 @@ * (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) diff --git a/lib/floatdidf.c b/lib/floatdidf.c index f76d1b899..a0f501b60 100644 --- a/lib/floatdidf.c +++ b/lib/floatdidf.c @@ -1,29 +1,32 @@ -//===-- floatdidf.c - Implement __floatdidf -------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __floatdidf for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/*===-- floatdidf.c - Implement __floatdidf -------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + *===----------------------------------------------------------------------=== + * + * This file implements __floatdidf for the compiler_rt library. + * + *===----------------------------------------------------------------------=== + */ #include "int_lib.h" #include <float.h> -// Returns: convert a to a double, rounding toward even. +/* Returns: convert a to a double, rounding toward even. */ -// Assumption: double is a IEEE 64 bit floating point type -// di_int is a 64 bit integral type +/* Assumption: double is a IEEE 64 bit floating point type + * di_int is a 64 bit integral type + */ -// seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm +/* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */ #ifndef __SOFT_FP__ -// Support for systems that have hardware floating-point; we'll set the inexact flag -// as a side-effect of this computation. +/* Support for systems that have hardware floating-point; we'll set the inexact flag + * as a side-effect of this computation. + */ #include <stdint.h> double @@ -42,8 +45,9 @@ __floatdidf(di_int 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. +/* 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. + */ double __floatdidf(di_int a) @@ -53,17 +57,18 @@ __floatdidf(di_int a) const unsigned N = sizeof(di_int) * CHAR_BIT; const di_int s = a >> (N-1); a = (a ^ s) - s; - int sd = N - __builtin_clzll(a); // number of significant digits - int e = sd - 1; // exponent + int sd = N - __builtin_clzll(a); /* number of significant digits */ + int e = sd - 1; /* exponent */ if (sd > DBL_MANT_DIG) { - // start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx - // finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR - // 12345678901234567890123456 - // 1 = msb 1 bit - // P = bit DBL_MANT_DIG-1 bits to the right of 1 - // Q = bit DBL_MANT_DIG bits to the right of 1 - // R = "or" of all bits to the right of Q + /* start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx + * finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR + * 12345678901234567890123456 + * 1 = msb 1 bit + * P = bit DBL_MANT_DIG-1 bits to the right of 1 + * Q = bit DBL_MANT_DIG bits to the right of 1 + * R = "or" of all bits to the right of Q + */ switch (sd) { case DBL_MANT_DIG + 1: @@ -75,28 +80,28 @@ __floatdidf(di_int a) a = ((du_int)a >> (sd - (DBL_MANT_DIG+2))) | ((a & ((du_int)(-1) >> ((N + DBL_MANT_DIG+2) - sd))) != 0); }; - // finish: - a |= (a & 4) != 0; // Or P into R - ++a; // round - this step may add a significant bit - a >>= 2; // dump Q and R - // a is now rounded to DBL_MANT_DIG or DBL_MANT_DIG+1 bits + /* finish: */ + a |= (a & 4) != 0; /* Or P into R */ + ++a; /* round - this step may add a significant bit */ + a >>= 2; /* dump Q and R */ + /* a is now rounded to DBL_MANT_DIG or DBL_MANT_DIG+1 bits */ if (a & ((du_int)1 << DBL_MANT_DIG)) { a >>= 1; ++e; } - // a is now rounded to DBL_MANT_DIG bits + /* a is now rounded to DBL_MANT_DIG bits */ } else { a <<= (DBL_MANT_DIG - sd); - // a is now rounded to DBL_MANT_DIG bits + /* a is now rounded to DBL_MANT_DIG bits */ } double_bits fb; - fb.u.high = ((su_int)s & 0x80000000) | // sign - ((e + 1023) << 20) | // exponent - ((su_int)(a >> 32) & 0x000FFFFF); // mantissa-high - fb.u.low = (su_int)a; // mantissa-low + fb.u.high = ((su_int)s & 0x80000000) | /* sign */ + ((e + 1023) << 20) | /* exponent */ + ((su_int)(a >> 32) & 0x000FFFFF); /* mantissa-high */ + fb.u.low = (su_int)a; /* mantissa-low */ return fb.f; } #endif diff --git a/lib/floatdisf.c b/lib/floatdisf.c index 5a9284819..1925f1588 100644 --- a/lib/floatdisf.c +++ b/lib/floatdisf.c @@ -1,25 +1,27 @@ -//===-- floatdisf.c - Implement __floatdisf -------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __floatdisf for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/*===-- floatdisf.c - Implement __floatdisf -------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + *===----------------------------------------------------------------------=== + * + * This file implements __floatdisf for the compiler_rt library. + * + *===----------------------------------------------------------------------=== + */ #include "int_lib.h" #include <float.h> -// Returns: convert a to a float, rounding toward even. +/* Returns: convert a to a float, rounding toward even.*/ -// Assumption: float is a IEEE 32 bit floating point type -// di_int is a 64 bit integral type +/* Assumption: float is a IEEE 32 bit floating point type + * di_int is a 64 bit integral type + */ -// seee eeee emmm mmmm mmmm mmmm mmmm mmmm +/* seee eeee emmm mmmm mmmm mmmm mmmm mmmm */ float __floatdisf(di_int a) @@ -29,17 +31,18 @@ __floatdisf(di_int a) const unsigned N = sizeof(di_int) * CHAR_BIT; const di_int s = a >> (N-1); a = (a ^ s) - s; - int sd = N - __builtin_clzll(a); // number of significant digits - int e = sd - 1; // exponent + int sd = N - __builtin_clzll(a); /* number of significant digits */ + int e = sd - 1; /* exponent */ if (sd > FLT_MANT_DIG) { - // start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx - // finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR - // 12345678901234567890123456 - // 1 = msb 1 bit - // P = bit FLT_MANT_DIG-1 bits to the right of 1 - // Q = bit FLT_MANT_DIG bits to the right of 1 - // R = "or" of all bits to the right of Q + /* start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx + * finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR + * 12345678901234567890123456 + * 1 = msb 1 bit + * P = bit FLT_MANT_DIG-1 bits to the right of 1 + * Q = bit FLT_MANT_DIG bits to the right of 1 + * R = "or" of all bits to the right of Q + */ switch (sd) { case FLT_MANT_DIG + 1: @@ -51,26 +54,26 @@ __floatdisf(di_int a) a = ((du_int)a >> (sd - (FLT_MANT_DIG+2))) | ((a & ((du_int)(-1) >> ((N + FLT_MANT_DIG+2) - sd))) != 0); }; - // finish: - a |= (a & 4) != 0; // Or P into R - ++a; // round - this step may add a significant bit - a >>= 2; // dump Q and R - // a is now rounded to FLT_MANT_DIG or FLT_MANT_DIG+1 bits + /* finish: */ + a |= (a & 4) != 0; /* Or P into R */ + ++a; /* round - this step may add a significant bit */ + a >>= 2; /* dump Q and R */ + /* a is now rounded to FLT_MANT_DIG or FLT_MANT_DIG+1 bits */ if (a & ((du_int)1 << FLT_MANT_DIG)) { a >>= 1; ++e; } - // a is now rounded to FLT_MANT_DIG bits + /* a is now rounded to FLT_MANT_DIG bits */ } else { a <<= (FLT_MANT_DIG - sd); - // a is now rounded to FLT_MANT_DIG bits + /* a is now rounded to FLT_MANT_DIG bits */ } float_bits fb; - fb.u = ((su_int)s & 0x80000000) | // sign - ((e + 127) << 23) | // exponent - ((su_int)a & 0x007FFFFF); // mantissa + fb.u = ((su_int)s & 0x80000000) | /* sign */ + ((e + 127) << 23) | /* exponent */ + ((su_int)a & 0x007FFFFF); /* mantissa */ return fb.f; } diff --git a/lib/floatdixf.c b/lib/floatdixf.c index 8d6911ec0..6760ab32f 100644 --- a/lib/floatdixf.c +++ b/lib/floatdixf.c @@ -1,27 +1,30 @@ -//===-- floatdixf.c - Implement __floatdixf -------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __floatdixf for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- floatdixf.c - Implement __floatdixf -------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __floatdixf for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #if !_ARCH_PPC #include "int_lib.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 -// di_int is a 64 bit integral type +/* Assumption: long double is a IEEE 80 bit floating point type padded to 128 bits + * di_int is a 64 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 + */ long double __floatdixf(di_int a) @@ -32,11 +35,11 @@ __floatdixf(di_int a) const di_int s = a >> (N-1); a = (a ^ s) - s; int clz = __builtin_clzll(a); - int e = (N - 1) - clz ; // exponent + int e = (N - 1) - clz ; /* exponent */ long_double_bits fb; - fb.u.high.low = ((su_int)s & 0x00008000) | // sign - (e + 16383); // exponent - fb.u.low.all = a << clz; // mantissa + fb.u.high.low = ((su_int)s & 0x00008000) | /* sign */ + (e + 16383); /* exponent */ + fb.u.low.all = a << clz; /* mantissa */ return fb.f; } diff --git a/lib/floattidf.c b/lib/floattidf.c index 0f72b33f3..b74fa5ec8 100644 --- a/lib/floattidf.c +++ b/lib/floattidf.c @@ -1,27 +1,29 @@ -//===-- floattidf.c - Implement __floattidf -------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __floattidf for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- floattidf.c - Implement __floattidf -------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __floattidf for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #if __x86_64 #include "int_lib.h" #include <float.h> -// Returns: convert a to a double, rounding toward even. +/* Returns: convert a to a double, rounding toward even.*/ -// Assumption: double is a IEEE 64 bit floating point type -// ti_int is a 128 bit integral type +/* Assumption: double is a IEEE 64 bit floating point type + * ti_int is a 128 bit integral type + */ -// seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm +/* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */ si_int __clzti2(ti_int a); @@ -33,17 +35,18 @@ __floattidf(ti_int a) const unsigned N = sizeof(ti_int) * CHAR_BIT; const ti_int s = a >> (N-1); a = (a ^ s) - s; - int sd = N - __clzti2(a); // number of significant digits - int e = sd - 1; // exponent + int sd = N - __clzti2(a); /* number of significant digits */ + int e = sd - 1; /* exponent */ if (sd > DBL_MANT_DIG) { - // start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx - // finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR - // 12345678901234567890123456 - // 1 = msb 1 bit - // P = bit DBL_MANT_DIG-1 bits to the right of 1 - // Q = bit DBL_MANT_DIG bits to the right of 1 - // R = "or" of all bits to the right of Q + /* start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx + * finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR + * 12345678901234567890123456 + * 1 = msb 1 bit + * P = bit DBL_MANT_DIG-1 bits to the right of 1 + * Q = bit DBL_MANT_DIG bits to the right of 1 + * R = "or" of all bits to the right of Q + */ switch (sd) { case DBL_MANT_DIG + 1: @@ -55,28 +58,28 @@ __floattidf(ti_int a) a = ((tu_int)a >> (sd - (DBL_MANT_DIG+2))) | ((a & ((tu_int)(-1) >> ((N + DBL_MANT_DIG+2) - sd))) != 0); }; - // finish: - a |= (a & 4) != 0; // Or P into R - ++a; // round - this step may add a significant bit - a >>= 2; // dump Q and R - // a is now rounded to DBL_MANT_DIG or DBL_MANT_DIG+1 bits + /* finish: */ + a |= (a & 4) != 0; /* Or P into R */ + ++a; /* round - this step may add a significant bit */ + a >>= 2; /* dump Q and R */ + /* a is now rounded to DBL_MANT_DIG or DBL_MANT_DIG+1 bits */ if (a & ((tu_int)1 << DBL_MANT_DIG)) { a >>= 1; ++e; } - // a is now rounded to DBL_MANT_DIG bits + /* a is now rounded to DBL_MANT_DIG bits */ } else { a <<= (DBL_MANT_DIG - sd); - // a is now rounded to DBL_MANT_DIG bits + /* a is now rounded to DBL_MANT_DIG bits */ } double_bits fb; - fb.u.high = ((su_int)s & 0x80000000) | // sign - ((e + 1023) << 20) | // exponent - ((su_int)(a >> 32) & 0x000FFFFF); // mantissa-high - fb.u.low = (su_int)a; // mantissa-low + fb.u.high = ((su_int)s & 0x80000000) | /* sign */ + ((e + 1023) << 20) | /* exponent */ + ((su_int)(a >> 32) & 0x000FFFFF); /* mantissa-high */ + fb.u.low = (su_int)a; /* mantissa-low */ return fb.f; } diff --git a/lib/floattisf.c b/lib/floattisf.c index 25bda9759..72f37481b 100644 --- a/lib/floattisf.c +++ b/lib/floattisf.c @@ -1,27 +1,29 @@ -//===-- floattisf.c - Implement __floattisf -------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __floattisf for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- floattisf.c - Implement __floattisf -------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __floattisf for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #if __x86_64 #include "int_lib.h" #include <float.h> -// Returns: convert a to a float, rounding toward even. +/* Returns: convert a to a float, rounding toward even. */ -// Assumption: float is a IEEE 32 bit floating point type -// ti_int is a 128 bit integral type +/* Assumption: float is a IEEE 32 bit floating point type + * ti_int is a 128 bit integral type + */ -// seee eeee emmm mmmm mmmm mmmm mmmm mmmm +/* seee eeee emmm mmmm mmmm mmmm mmmm mmmm */ si_int __clzti2(ti_int a); @@ -33,17 +35,18 @@ __floattisf(ti_int a) const unsigned N = sizeof(ti_int) * CHAR_BIT; const ti_int s = a >> (N-1); a = (a ^ s) - s; - int sd = N - __clzti2(a); // number of significant digits - int e = sd - 1; // exponent + int sd = N - __clzti2(a); /* number of significant digits */ + int e = sd - 1; /* exponent */ if (sd > FLT_MANT_DIG) { - // start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx - // finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR - // 12345678901234567890123456 - // 1 = msb 1 bit - // P = bit FLT_MANT_DIG-1 bits to the right of 1 - // Q = bit FLT_MANT_DIG bits to the right of 1 - // R = "or" of all bits to the right of Q + /* start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx + * finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR + * 12345678901234567890123456 + * 1 = msb 1 bit + * P = bit FLT_MANT_DIG-1 bits to the right of 1 + * Q = bit FLT_MANT_DIG bits to the right of 1 + * R = "or" of all bits to the right of Q + */ switch (sd) { case FLT_MANT_DIG + 1: @@ -55,27 +58,27 @@ __floattisf(ti_int a) a = ((tu_int)a >> (sd - (FLT_MANT_DIG+2))) | ((a & ((tu_int)(-1) >> ((N + FLT_MANT_DIG+2) - sd))) != 0); }; - // finish: - a |= (a & 4) != 0; // Or P into R - ++a; // round - this step may add a significant bit - a >>= 2; // dump Q and R - // a is now rounded to FLT_MANT_DIG or FLT_MANT_DIG+1 bits + /* finish: */ + a |= (a & 4) != 0; /* Or P into R */ + ++a; /* round - this step may add a significant bit */ + a >>= 2; /* dump Q and R */ + /* a is now rounded to FLT_MANT_DIG or FLT_MANT_DIG+1 bits */ if (a & ((tu_int)1 << FLT_MANT_DIG)) { a >>= 1; ++e; } - // a is now rounded to FLT_MANT_DIG bits + /* a is now rounded to FLT_MANT_DIG bits */ } else { a <<= (FLT_MANT_DIG - sd); - // a is now rounded to FLT_MANT_DIG bits + /* a is now rounded to FLT_MANT_DIG bits */ } float_bits fb; - fb.u = ((su_int)s & 0x80000000) | // sign - ((e + 127) << 23) | // exponent - ((su_int)a & 0x007FFFFF); // mantissa + fb.u = ((su_int)s & 0x80000000) | /* sign */ + ((e + 127) << 23) | /* exponent */ + ((su_int)a & 0x007FFFFF); /* mantissa */ return fb.f; } diff --git a/lib/floattixf.c b/lib/floattixf.c index 48ad6bf50..d55029679 100644 --- a/lib/floattixf.c +++ b/lib/floattixf.c @@ -37,8 +37,8 @@ __floattixf(ti_int a) const unsigned N = sizeof(ti_int) * CHAR_BIT; const ti_int s = a >> (N-1); a = (a ^ s) - s; - 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 @@ -48,7 +48,7 @@ __floattixf(ti_int a) * 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: diff --git a/lib/floatundidf.c b/lib/floatundidf.c index 708d614ac..1f304c5c3 100644 --- a/lib/floatundidf.c +++ b/lib/floatundidf.c @@ -1,29 +1,33 @@ -//===-- floatundidf.c - Implement __floatundidf ---------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __floatundidf for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- floatundidf.c - Implement __floatundidf ---------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __floatundidf for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" #include <float.h> -// Returns: convert a to a double, rounding toward even. +/* Returns: convert a to a double, rounding toward even. */ -// Assumption: double is a IEEE 64 bit floating point type -// du_int is a 64 bit integral type +/* Assumption: double is a IEEE 64 bit floating point type + * du_int is a 64 bit integral type + */ -// seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm +/* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */ #ifndef __SOFT_FP__ -// Support for systems that have hardware floating-point; we'll set the inexact flag -// as a side-effect of this computation. +/* Support for systems that have hardware floating-point; we'll set the inexact flag + * as a side-effect of this computation. + */ + #include <stdint.h> double @@ -44,8 +48,9 @@ __floatundidf(du_int 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. +/* 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. + */ double __floatundidf(du_int a) @@ -53,17 +58,18 @@ __floatundidf(du_int a) if (a == 0) return 0.0; const unsigned N = sizeof(du_int) * CHAR_BIT; - int sd = N - __builtin_clzll(a); // number of significant digits - int e = sd - 1; // exponent + int sd = N - __builtin_clzll(a); /* number of significant digits */ + int e = sd - 1; /* exponent */ if (sd > DBL_MANT_DIG) { - // start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx - // finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR - // 12345678901234567890123456 - // 1 = msb 1 bit - // P = bit DBL_MANT_DIG-1 bits to the right of 1 - // Q = bit DBL_MANT_DIG bits to the right of 1 - // R = "or" of all bits to the right of Q + /* start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx + * finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR + * 12345678901234567890123456 + * 1 = msb 1 bit + * P = bit DBL_MANT_DIG-1 bits to the right of 1 + * Q = bit DBL_MANT_DIG bits to the right of 1 + * R = "or" of all bits to the right of Q + */ switch (sd) { case DBL_MANT_DIG + 1: @@ -75,27 +81,27 @@ __floatundidf(du_int a) a = (a >> (sd - (DBL_MANT_DIG+2))) | ((a & ((du_int)(-1) >> ((N + DBL_MANT_DIG+2) - sd))) != 0); }; - // finish: - a |= (a & 4) != 0; // Or P into R - ++a; // round - this step may add a significant bit - a >>= 2; // dump Q and R - // a is now rounded to DBL_MANT_DIG or DBL_MANT_DIG+1 bits + /* finish: */ + a |= (a & 4) != 0; /* Or P into R */ + ++a; /* round - this step may add a significant bit */ + a >>= 2; /* dump Q and R */ + /* a is now rounded to DBL_MANT_DIG or DBL_MANT_DIG+1 bits */ if (a & ((du_int)1 << DBL_MANT_DIG)) { a >>= 1; ++e; } - // a is now rounded to DBL_MANT_DIG bits + /* a is now rounded to DBL_MANT_DIG bits */ } else { a <<= (DBL_MANT_DIG - sd); - // a is now rounded to DBL_MANT_DIG bits + /* a is now rounded to DBL_MANT_DIG bits */ } double_bits fb; - fb.u.high = ((e + 1023) << 20) | // exponent - ((su_int)(a >> 32) & 0x000FFFFF); // mantissa-high - fb.u.low = (su_int)a; // mantissa-low + fb.u.high = ((e + 1023) << 20) | /* exponent */ + ((su_int)(a >> 32) & 0x000FFFFF); /* mantissa-high */ + fb.u.low = (su_int)a; /* mantissa-low */ return fb.f; } #endif diff --git a/lib/floatundisf.c b/lib/floatundisf.c index 66099e025..79b4b82e3 100644 --- a/lib/floatundisf.c +++ b/lib/floatundisf.c @@ -1,25 +1,27 @@ -//===-- floatundisf.c - Implement __floatundisf ---------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __floatundisf for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/*===-- floatundisf.c - Implement __floatundisf ---------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __floatundisf for the compiler_rt library. + * + *===----------------------------------------------------------------------=== + */ #include "int_lib.h" #include <float.h> -// Returns: convert a to a float, rounding toward even. +/* Returns: convert a to a float, rounding toward even. */ -// Assumption: float is a IEEE 32 bit floating point type -// du_int is a 64 bit integral type +/* Assumption: float is a IEEE 32 bit floating point type + * du_int is a 64 bit integral type + */ -// seee eeee emmm mmmm mmmm mmmm mmmm mmmm +/* seee eeee emmm mmmm mmmm mmmm mmmm mmmm */ float __floatundisf(du_int a) @@ -27,17 +29,18 @@ __floatundisf(du_int a) if (a == 0) return 0.0F; const unsigned N = sizeof(du_int) * CHAR_BIT; - int sd = N - __builtin_clzll(a); // number of significant digits - int e = sd - 1; // exponent + int sd = N - __builtin_clzll(a); /* number of significant digits */ + int e = sd - 1; /* 8 exponent */ if (sd > FLT_MANT_DIG) { - // start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx - // finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR - // 12345678901234567890123456 - // 1 = msb 1 bit - // P = bit FLT_MANT_DIG-1 bits to the right of 1 - // Q = bit FLT_MANT_DIG bits to the right of 1 - // R = "or" of all bits to the right of Q + /* start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx + * finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR + * 12345678901234567890123456 + * 1 = msb 1 bit + * P = bit FLT_MANT_DIG-1 bits to the right of 1 + * Q = bit FLT_MANT_DIG bits to the right of 1 + * R = "or" of all bits to the right of Q + */ switch (sd) { case FLT_MANT_DIG + 1: @@ -49,25 +52,25 @@ __floatundisf(du_int a) a = (a >> (sd - (FLT_MANT_DIG+2))) | ((a & ((du_int)(-1) >> ((N + FLT_MANT_DIG+2) - sd))) != 0); }; - // finish: - a |= (a & 4) != 0; // Or P into R - ++a; // round - this step may add a significant bit - a >>= 2; // dump Q and R - // a is now rounded to FLT_MANT_DIG or FLT_MANT_DIG+1 bits + /* finish: */ + a |= (a & 4) != 0; /* Or P into R */ + ++a; /* round - this step may add a significant bit */ + a >>= 2; /* dump Q and R */ + /* a is now rounded to FLT_MANT_DIG or FLT_MANT_DIG+1 bits */ if (a & ((du_int)1 << FLT_MANT_DIG)) { a >>= 1; ++e; } - // a is now rounded to FLT_MANT_DIG bits + /* a is now rounded to FLT_MANT_DIG bits */ } else { a <<= (FLT_MANT_DIG - sd); - // a is now rounded to FLT_MANT_DIG bits + /* a is now rounded to FLT_MANT_DIG bits */ } float_bits fb; - fb.u = ((e + 127) << 23) | // exponent - ((su_int)a & 0x007FFFFF); // mantissa + fb.u = ((e + 127) << 23) | /* exponent */ + ((su_int)a & 0x007FFFFF); /* mantissa */ return fb.f; } diff --git a/lib/floatundixf.c b/lib/floatundixf.c index 6e8c4839f..d87224f90 100644 --- a/lib/floatundixf.c +++ b/lib/floatundixf.c @@ -1,28 +1,30 @@ -//===-- floatundixf.c - Implement __floatundixf ---------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __floatundixf for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- floatundixf.c - Implement __floatundixf ---------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __floatundixf for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #if !_ARCH_PPC #include "int_lib.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 -// du_int is a 64 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 +/* Assumption: long double is a IEEE 80 bit floating point type padded to 128 bits + * du_int is a 64 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 + */ long double __floatundixf(du_int a) { @@ -30,11 +32,11 @@ __floatundixf(du_int a) return 0.0; const unsigned N = sizeof(du_int) * CHAR_BIT; int clz = __builtin_clzll(a); - int e = (N - 1) - clz ; // exponent + int e = (N - 1) - clz ; /* exponent */ long_double_bits fb; - fb.u.high.low = (e + 16383); // exponent - fb.u.low.all = a << clz; // mantissa + fb.u.high.low = (e + 16383); /* exponent */ + fb.u.low.all = a << clz; /* mantissa */ return fb.f; } -#endif +#endif /* _ARCH_PPC */ diff --git a/lib/moddi3.c b/lib/moddi3.c index 5e903914a..453355596 100644 --- a/lib/moddi3.c +++ b/lib/moddi3.c @@ -1,31 +1,32 @@ -//===-- moddi3.c - Implement __moddi3 -------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __moddi3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/*===-- moddi3.c - Implement __moddi3 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __moddi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" du_int __udivmoddi4(du_int a, du_int b, du_int* rem); -// Returns: a % b +/* Returns: a % b */ di_int __moddi3(di_int a, di_int b) { const int bits_in_dword_m1 = (int)(sizeof(di_int) * CHAR_BIT) - 1; - di_int s = b >> bits_in_dword_m1; // s = b < 0 ? -1 : 0 - b = (b ^ s) - s; // negate if s == -1 - s = a >> bits_in_dword_m1; // s = a < 0 ? -1 : 0 - a = (a ^ s) - s; // negate if s == -1 + di_int s = b >> bits_in_dword_m1; /* s = b < 0 ? -1 : 0 */ + b = (b ^ s) - s; /* negate if s == -1 */ + s = a >> bits_in_dword_m1; /* s = a < 0 ? -1 : 0 */ + a = (a ^ s) - s; /* negate if s == -1 */ di_int r; __udivmoddi4(a, b, (du_int*)&r); - return (r ^ s) - s; // negate if s == -1 + return (r ^ s) - s; /* negate if s == -1 */ } diff --git a/lib/modsi3.c b/lib/modsi3.c index d6dfe616d..c9214a24f 100644 --- a/lib/modsi3.c +++ b/lib/modsi3.c @@ -1,19 +1,20 @@ -//===-- modsi3.c - Implement __modsi3 -------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __modsi3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- modsi3.c - Implement __modsi3 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __modsi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" -// Returns: a % b +/* Returns: a % b */ si_int __modsi3(si_int a, si_int b) diff --git a/lib/modti3.c b/lib/modti3.c index 91ff8aa5d..75d688ef0 100644 --- a/lib/modti3.c +++ b/lib/modti3.c @@ -1,15 +1,16 @@ -//===-- modti3.c - Implement __modti3 -------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __modti3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- modti3.c - Implement __modti3 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __modti3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #if __x86_64 @@ -17,19 +18,19 @@ tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem); -// Returns: a % b +/*Returns: a % b */ ti_int __modti3(ti_int a, ti_int b) { const int bits_in_tword_m1 = (int)(sizeof(ti_int) * CHAR_BIT) - 1; - ti_int s = b >> bits_in_tword_m1; // s = b < 0 ? -1 : 0 - b = (b ^ s) - s; // negate if s == -1 - s = a >> bits_in_tword_m1; // s = a < 0 ? -1 : 0 - a = (a ^ s) - s; // negate if s == -1 + ti_int s = b >> bits_in_tword_m1; /* s = b < 0 ? -1 : 0 */ + b = (b ^ s) - s; /* negate if s == -1 */ + s = a >> bits_in_tword_m1; /* s = a < 0 ? -1 : 0 */ + a = (a ^ s) - s; /* negate if s == -1 */ ti_int r; __udivmodti4(a, b, (tu_int*)&r); - return (r ^ s) - s; // negate if s == -1 + return (r ^ s) - s; /* negate if s == -1 */ } #endif diff --git a/lib/muldc3.c b/lib/muldc3.c index b945e8e38..c048d84fa 100644 --- a/lib/muldc3.c +++ b/lib/muldc3.c @@ -1,21 +1,22 @@ -//===-- muldc3.c - Implement __muldc3 -------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __muldc3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- muldc3.c - Implement __muldc3 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __muldc3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" #include <math.h> #include <complex.h> -// Returns: the product of a + ib and c + id +/* Returns: the product of a + ib and c + id */ double _Complex __muldc3(double __a, double __b, double __c, double __d) diff --git a/lib/muldi3.c b/lib/muldi3.c index 98299e6f0..6ed5929da 100644 --- a/lib/muldi3.c +++ b/lib/muldi3.c @@ -1,19 +1,20 @@ -//===-- muldi3.c - Implement __muldi3 -------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __muldi3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- muldi3.c - Implement __muldi3 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __muldi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" -// Returns: a * b +/* Returns: a * b */ static di_int @@ -37,7 +38,7 @@ __muldsi3(su_int a, su_int b) return r.all; } -// Returns: a * b +/* Returns: a * b */ di_int __muldi3(di_int a, di_int b) diff --git a/lib/mulsc3.c b/lib/mulsc3.c index bc47a47ea..c7b9f6417 100644 --- a/lib/mulsc3.c +++ b/lib/mulsc3.c @@ -1,21 +1,22 @@ -//===-- mulsc3.c - Implement __mulsc3 -------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __mulsc3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- mulsc3.c - Implement __mulsc3 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __mulsc3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" #include <math.h> #include <complex.h> -// Returns: the product of a + ib and c + id +/* Returns: the product of a + ib and c + id */ float _Complex __mulsc3(float __a, float __b, float __c, float __d) diff --git a/lib/multi3.c b/lib/multi3.c index 8ba6550b6..849504913 100644 --- a/lib/multi3.c +++ b/lib/multi3.c @@ -1,21 +1,22 @@ -//===-- multi3.c - Implement __multi3 -------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __multi3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- multi3.c - Implement __multi3 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + + * This file implements __multi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #if __x86_64 #include "int_lib.h" -// Returns: a * b +/* Returns: a * b */ static ti_int @@ -39,7 +40,7 @@ __mulddi3(du_int a, du_int b) return r.all; } -// Returns: a * b +/* Returns: a * b */ ti_int __multi3(ti_int a, ti_int b) diff --git a/lib/mulvdi3.c b/lib/mulvdi3.c index 862a8c006..ebb776950 100644 --- a/lib/mulvdi3.c +++ b/lib/mulvdi3.c @@ -1,22 +1,23 @@ -//===-- mulvdi3.c - Implement __mulvdi3 -----------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __mulvdi3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/*===-- mulvdi3.c - Implement __mulvdi3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __mulvdi3 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 __mulvdi3(di_int a, di_int b) diff --git a/lib/negvti2.c b/lib/negvti2.c index ced05e885..df44935f1 100644 --- a/lib/negvti2.c +++ b/lib/negvti2.c @@ -1,24 +1,25 @@ -//===-- negvti2.c - Implement __negvti2 -----------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __negvti2 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/*===-- negvti2.c - Implement __negvti2 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + *===----------------------------------------------------------------------=== + * + *This file implements __negvti2 for the compiler_rt library. + * + *===----------------------------------------------------------------------=== + */ #if __x86_64 #include "int_lib.h" #include <stdlib.h> -// Returns: -a +/* Returns: -a */ -// Effects: aborts if -a overflows +/* Effects: aborts if -a overflows */ ti_int __negvti2(ti_int a) diff --git a/lib/paritydi2.c b/lib/paritydi2.c index ea7c56588..f77d4d728 100644 --- a/lib/paritydi2.c +++ b/lib/paritydi2.c @@ -1,19 +1,20 @@ -//===-- paritydi2.c - Implement __paritydi2 -------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __paritydi2 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- paritydi2.c - Implement __paritydi2 -------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __paritydi2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" -// Returns: 1 if number of bits is odd else returns 0 +/* Returns: 1 if number of bits is odd else returns 0 */ si_int __paritysi2(si_int a); diff --git a/lib/paritysi2.c b/lib/paritysi2.c index c38f9cf2a..ba05782a2 100644 --- a/lib/paritysi2.c +++ b/lib/paritysi2.c @@ -1,19 +1,20 @@ -//===-- paritysi2.c - Implement __paritysi2 -------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __paritysi2 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- paritysi2.c - Implement __paritysi2 -------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __paritysi2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" -// Returns: 1 if number of bits is odd else returns 0 +/* Returns: 1 if number of bits is odd else returns 0 */ si_int __paritysi2(si_int a) diff --git a/lib/parityti2.c b/lib/parityti2.c index 6842a5192..8ef536854 100644 --- a/lib/parityti2.c +++ b/lib/parityti2.c @@ -1,21 +1,22 @@ -//===-- parityti2.c - Implement __parityti2 -------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __parityti2 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- parityti2.c - Implement __parityti2 -------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __parityti2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #if __x86_64 #include "int_lib.h" -// Returns: 1 if number of bits is odd else returns 0 +/* Returns: 1 if number of bits is odd else returns 0 */ si_int __paritydi2(di_int a); diff --git a/lib/popcountsi2.c b/lib/popcountsi2.c index 68220aef9..4f092ee40 100644 --- a/lib/popcountsi2.c +++ b/lib/popcountsi2.c @@ -1,32 +1,33 @@ -//===-- popcountsi2.c - Implement __popcountsi2 ---------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __popcountsi2 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- popcountsi2.c - Implement __popcountsi2 ---------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __popcountsi2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" -// Returns: count of 1 bits +/* Returns: count of 1 bits */ si_int __popcountsi2(si_int a) { su_int x = (su_int)a; x = x - ((x >> 1) & 0x55555555); - // Every 2 bits holds the sum of every pair of bits + /* Every 2 bits holds the sum of every pair of bits */ x = ((x >> 2) & 0x33333333) + (x & 0x33333333); - // Every 4 bits holds the sum of every 4-set of bits (3 significant bits) + /* Every 4 bits holds the sum of every 4-set of bits (3 significant bits) */ x = (x + (x >> 4)) & 0x0F0F0F0F; - // Every 8 bits holds the sum of every 8-set of bits (4 significant bits) + /* Every 8 bits holds the sum of every 8-set of bits (4 significant bits) */ x = (x + (x >> 16)); - // The lower 16 bits hold two 8 bit sums (5 significant bits). - // Upper 16 bits are garbage - return (x + (x >> 8)) & 0x0000003F; // (6 significant bits) + /* The lower 16 bits hold two 8 bit sums (5 significant bits).*/ + /* Upper 16 bits are garbage */ + return (x + (x >> 8)) & 0x0000003F; /* (6 significant bits) */ } diff --git a/lib/popcountti2.c b/lib/popcountti2.c index 9ac052d91..16f89b7ab 100644 --- a/lib/popcountti2.c +++ b/lib/popcountti2.c @@ -1,21 +1,22 @@ -//===-- popcountti2.c - Implement __popcountti2 ----------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __popcountti2 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- popcountti2.c - Implement __popcountti2 ----------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __popcountti2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #if __x86_64 #include "int_lib.h" -// Returns: count of 1 bits +/* Returns: count of 1 bits */ si_int __popcountti2(ti_int a) @@ -23,21 +24,21 @@ __popcountti2(ti_int a) tu_int x3 = (tu_int)a; x3 = x3 - ((x3 >> 1) & (((tu_int)0x5555555555555555uLL << 64) | 0x5555555555555555uLL)); - // Every 2 bits holds the sum of every pair of bits (64) + /* Every 2 bits holds the sum of every pair of bits (64) */ x3 = ((x3 >> 2) & (((tu_int)0x3333333333333333uLL << 64) | 0x3333333333333333uLL)) + (x3 & (((tu_int)0x3333333333333333uLL << 64) | 0x3333333333333333uLL)); - // Every 4 bits holds the sum of every 4-set of bits (3 significant bits) (32) + /* Every 4 bits holds the sum of every 4-set of bits (3 significant bits) (32) */ x3 = (x3 + (x3 >> 4)) & (((tu_int)0x0F0F0F0F0F0F0F0FuLL << 64) | 0x0F0F0F0F0F0F0F0FuLL); - // Every 8 bits holds the sum of every 8-set of bits (4 significant bits) (16) + /* Every 8 bits holds the sum of every 8-set of bits (4 significant bits) (16) */ du_int x2 = (du_int)(x3 + (x3 >> 64)); - // Every 8 bits holds the sum of every 8-set of bits (5 significant bits) (8) + /* Every 8 bits holds the sum of every 8-set of bits (5 significant bits) (8) */ su_int x = (su_int)(x2 + (x2 >> 32)); - // Every 8 bits holds the sum of every 8-set of bits (6 significant bits) (4) + /* Every 8 bits holds the sum of every 8-set of bits (6 significant bits) (4) */ x = x + (x >> 16); - // Every 8 bits holds the sum of every 8-set of bits (7 significant bits) (2) - // Upper 16 bits are garbage - return (x + (x >> 8)) & 0xFF; // (8 significant bits) + /* Every 8 bits holds the sum of every 8-set of bits (7 significant bits) (2) */ + /* Upper 16 bits are garbage */ + return (x + (x >> 8)) & 0xFF; /* (8 significant bits) */ } #endif diff --git a/lib/powisf2.c b/lib/powisf2.c index fcaaa1f26..ace08c266 100644 --- a/lib/powisf2.c +++ b/lib/powisf2.c @@ -1,19 +1,20 @@ -//===-- powisf2.cpp - Implement __powisf2 ---------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __powisf2 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/*===-- powisf2.cpp - Implement __powisf2 ---------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __powisf2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" -// Returns: a ^ b +/* Returns: a ^ b */ float __powisf2(float a, si_int b) diff --git a/lib/ucmpdi2.c b/lib/ucmpdi2.c index dec476fac..4f0382d82 100644 --- a/lib/ucmpdi2.c +++ b/lib/ucmpdi2.c @@ -1,21 +1,23 @@ -//===-- ucmpdi2.c - Implement __ucmpdi2 -----------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __ucmpdi2 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- ucmpdi2.c - Implement __ucmpdi2 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __ucmpdi2 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" -// Returns: if (a < b) returns 0 -// if (a == b) returns 1 -// if (a > b) returns 2 +/* Returns: if (a < b) returns 0 + * if (a == b) returns 1 + * if (a > b) returns 2 + */ si_int __ucmpdi2(du_int a, du_int b) diff --git a/lib/udivdi3.c b/lib/udivdi3.c index 473be64fa..25d1df643 100644 --- a/lib/udivdi3.c +++ b/lib/udivdi3.c @@ -1,21 +1,22 @@ -//===-- udivdi3.c - Implement __udivdi3 -----------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __udivdi3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- udivdi3.c - Implement __udivdi3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __udivdi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" du_int __udivmoddi4(du_int a, du_int b, du_int* rem); -// Returns: a / b +/* Returns: a / b */ du_int __udivdi3(du_int a, du_int b) diff --git a/lib/udivmoddi4.c b/lib/udivmoddi4.c index ad4d2aa22..977a391e8 100644 --- a/lib/udivmoddi4.c +++ b/lib/udivmoddi4.c @@ -1,22 +1,24 @@ -//===-- udivmoddi4.c - Implement __udivmoddi4 -----------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __udivmoddi4 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- udivmoddi4.c - Implement __udivmoddi4 -----------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __udivmoddi4 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" -// Effects: if rem != 0, *rem = a % b -// Returns: a / b +/* Effects: if rem != 0, *rem = a % b + * Returns: a / b + */ -// Translated from Figure 3-40 of The PowerPC Compiler Writer's Guide +/* Translated from Figure 3-40 of The PowerPC Compiler Writer's Guide */ du_int __udivmoddi4(du_int a, du_int b, du_int* rem) @@ -30,43 +32,47 @@ __udivmoddi4(du_int a, du_int b, du_int* rem) udwords q; udwords r; unsigned sr; - // special cases, X is unknown, K != 0 + /* special cases, X is unknown, K != 0 */ if (n.high == 0) { if (d.high == 0) { - // 0 X - // --- - // 0 X + /* 0 X + * --- + * 0 X + */ if (rem) *rem = n.low % d.low; return n.low / d.low; } - // 0 X - // --- - // K X + /* 0 X + * --- + * K X + */ if (rem) *rem = n.low; return 0; } - // n.high != 0 + /* n.high != 0 */ if (d.low == 0) { if (d.high == 0) { - // K X - // --- - // 0 0 + /* K X + * --- + * 0 0 + */ if (rem) *rem = n.high % d.low; return n.high / d.low; } - // d.high != 0 + /* d.high != 0 */ if (n.low == 0) { - // K 0 - // --- - // K 0 + /* K 0 + * --- + * K 0 + */ if (rem) { r.high = n.high % d.high; @@ -75,10 +81,11 @@ __udivmoddi4(du_int a, du_int b, du_int* rem) } return n.high / d.high; } - // K K - // --- - // K 0 - if ((d.high & (d.high - 1)) == 0) // if d is a power of 2 + /* K K + * --- + * K 0 + */ + if ((d.high & (d.high - 1)) == 0) /* if d is a power of 2 */ { if (rem) { @@ -88,11 +95,12 @@ __udivmoddi4(du_int a, du_int b, du_int* rem) } return n.high >> __builtin_ctz(d.high); } - // K K - // --- - // K 0 + /* K K + * --- + * K 0 + */ sr = __builtin_clz(d.high) - __builtin_clz(n.high); - // 0 <= sr <= n_uword_bits - 2 or sr large + /* 0 <= sr <= n_uword_bits - 2 or sr large */ if (sr > n_uword_bits - 2) { if (rem) @@ -100,22 +108,23 @@ __udivmoddi4(du_int a, du_int b, du_int* rem) return 0; } ++sr; - // 1 <= sr <= n_uword_bits - 1 - // q.all = n.all << (n_udword_bits - sr); + /* 1 <= sr <= n_uword_bits - 1 */ + /* q.all = n.all << (n_udword_bits - sr); */ q.low = 0; q.high = n.low << (n_uword_bits - sr); - // r.all = n.all >> sr; + /* r.all = n.all >> sr; */ r.high = n.high >> sr; r.low = (n.high << (n_uword_bits - sr)) | (n.low >> sr); } - else // d.low != 0 + else /* d.low != 0 */ { if (d.high == 0) { - // K X - // --- - // 0 K - if ((d.low & (d.low - 1)) == 0) // if d is a power of 2 + /* K X + * --- + * 0 K + */ + if ((d.low & (d.low - 1)) == 0) /* if d is a power of 2 */ { if (rem) *rem = n.low & (d.low - 1); @@ -126,35 +135,37 @@ __udivmoddi4(du_int a, du_int b, du_int* rem) q.low = (n.high << (n_uword_bits - sr)) | (n.low >> sr); return q.all; } - // K X - // --- - // 0 K + /* K X + * --- + *0 K + */ sr = 1 + n_uword_bits + __builtin_clz(d.low) - __builtin_clz(n.high); - // 2 <= sr <= n_udword_bits - 1 - // q.all = n.all << (n_udword_bits - sr); - // r.all = n.all >> sr; - // if (sr == n_uword_bits) - // { - // q.low = 0; - // q.high = n.low; - // r.high = 0; - // r.low = n.high; - // } - // else if (sr < n_uword_bits) // 2 <= sr <= n_uword_bits - 1 - // { - // q.low = 0; - // q.high = n.low << (n_uword_bits - sr); - // r.high = n.high >> sr; - // r.low = (n.high << (n_uword_bits - sr)) | (n.low >> sr); - // } - // else // n_uword_bits + 1 <= sr <= n_udword_bits - 1 - // { - // q.low = n.low << (n_udword_bits - sr); - // q.high = (n.high << (n_udword_bits - sr)) | - // (n.low >> (sr - n_uword_bits)); - // r.high = 0; - // r.low = n.high >> (sr - n_uword_bits); - // } + /* 2 <= sr <= n_udword_bits - 1 + * q.all = n.all << (n_udword_bits - sr); + * r.all = n.all >> sr; + * if (sr == n_uword_bits) + * { + * q.low = 0; + * q.high = n.low; + * r.high = 0; + * r.low = n.high; + * } + * else if (sr < n_uword_bits) // 2 <= sr <= n_uword_bits - 1 + * { + * q.low = 0; + * q.high = n.low << (n_uword_bits - sr); + * r.high = n.high >> sr; + * r.low = (n.high << (n_uword_bits - sr)) | (n.low >> sr); + * } + * else // n_uword_bits + 1 <= sr <= n_udword_bits - 1 + * { + * q.low = n.low << (n_udword_bits - sr); + * q.high = (n.high << (n_udword_bits - sr)) | + * (n.low >> (sr - n_uword_bits)); + * r.high = 0; + * r.low = n.high >> (sr - n_uword_bits); + * } + */ q.low = (n.low << (n_udword_bits - sr)) & ((si_int)(n_uword_bits - sr) >> (n_uword_bits-1)); q.high = ((n.low << ( n_uword_bits - sr)) & @@ -172,11 +183,12 @@ __udivmoddi4(du_int a, du_int b, du_int* rem) } else { - // K X - // --- - // K K + /* K X + * --- + * K K + */ sr = __builtin_clz(d.high) - __builtin_clz(n.high); - // 0 <= sr <= n_uword_bits - 1 or sr large + /* 0 <= sr <= n_uword_bits - 1 or sr large */ if (sr > n_uword_bits - 1) { if (rem) @@ -184,21 +196,22 @@ __udivmoddi4(du_int a, du_int b, du_int* rem) return 0; } ++sr; - // 1 <= sr <= n_uword_bits - // q.all = n.all << (n_udword_bits - sr); + /* 1 <= sr <= n_uword_bits */ + /* q.all = n.all << (n_udword_bits - sr); */ q.low = 0; q.high = n.low << (n_uword_bits - sr); - // r.all = n.all >> sr; - // if (sr < n_uword_bits) - // { - // r.high = n.high >> sr; - // r.low = (n.high << (n_uword_bits - sr)) | (n.low >> sr); - // } - // else - // { - // r.high = 0; - // r.low = n.high; - // } + /* r.all = n.all >> sr; + * if (sr < n_uword_bits) + * { + * r.high = n.high >> sr; + * r.low = (n.high << (n_uword_bits - sr)) | (n.low >> sr); + * } + * else + * { + * r.high = 0; + * r.low = n.high; + * } + */ r.high = (n.high >> sr) & ((si_int)(sr - n_uword_bits) >> (n_uword_bits-1)); r.low = (n.high << (n_uword_bits - sr)) | @@ -206,25 +219,27 @@ __udivmoddi4(du_int a, du_int b, du_int* rem) ((si_int)(sr - n_uword_bits) >> (n_uword_bits-1))); } } - // Not a special case - // q and r are initialized with: - // q.all = n.all << (n_udword_bits - sr); - // r.all = n.all >> sr; - // 1 <= sr <= n_udword_bits - 1 + /* Not a special case + * q and r are initialized with: + * q.all = n.all << (n_udword_bits - sr); + * r.all = n.all >> sr; + * 1 <= sr <= n_udword_bits - 1 + */ su_int carry = 0; for (; sr > 0; --sr) { - // r:q = ((r:q) << 1) | carry + /* r:q = ((r:q) << 1) | carry */ r.high = (r.high << 1) | (r.low >> (n_uword_bits - 1)); r.low = (r.low << 1) | (q.high >> (n_uword_bits - 1)); q.high = (q.high << 1) | (q.low >> (n_uword_bits - 1)); q.low = (q.low << 1) | carry; - // carry = 0; - // if (r.all >= d.all) - // { - // r.all -= d.all; - // carry = 1; - // } + /* carry = 0; + * if (r.all >= d.all) + * { + * r.all -= d.all; + * carry = 1; + * } + */ const di_int s = (di_int)(d.all - r.all - 1) >> (n_udword_bits - 1); carry = s & 1; r.all -= d.all & s; diff --git a/lib/udivmodti4.c b/lib/udivmodti4.c index 79cf6f2fc..12fa49cda 100644 --- a/lib/udivmodti4.c +++ b/lib/udivmodti4.c @@ -1,24 +1,26 @@ -//===-- udivmodti4.c - Implement __udivmodti4 -----------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __udivmodti4 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- udivmodti4.c - Implement __udivmodti4 -----------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __udivmodti4 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #if __x86_64 #include "int_lib.h" -// Effects: if rem != 0, *rem = a % b -// Returns: a / b +/* Effects: if rem != 0, *rem = a % b + * Returns: a / b + */ -// Translated from Figure 3-40 of The PowerPC Compiler Writer's Guide +/* Translated from Figure 3-40 of The PowerPC Compiler Writer's Guide */ tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem) @@ -32,43 +34,47 @@ __udivmodti4(tu_int a, tu_int b, tu_int* rem) utwords q; utwords r; unsigned sr; - // special cases, X is unknown, K != 0 + /* special cases, X is unknown, K != 0 */ if (n.high == 0) { if (d.high == 0) { - // 0 X - // --- - // 0 X + /* 0 X + * --- + * 0 X + */ if (rem) *rem = n.low % d.low; return n.low / d.low; } - // 0 X - // --- - // K X + /* 0 X + * --- + * K X + */ if (rem) *rem = n.low; return 0; } - // n.high != 0 + /* n.high != 0 */ if (d.low == 0) { if (d.high == 0) { - // K X - // --- - // 0 0 + /* K X + * --- + * 0 0 + */ if (rem) *rem = n.high % d.low; return n.high / d.low; } - // d.high != 0 + /* d.high != 0 */ if (n.low == 0) { - // K 0 - // --- - // K 0 + /* K 0 + * --- + * K 0 + */ if (rem) { r.high = n.high % d.high; @@ -77,10 +83,11 @@ __udivmodti4(tu_int a, tu_int b, tu_int* rem) } return n.high / d.high; } - // K K - // --- - // K 0 - if ((d.high & (d.high - 1)) == 0) // if d is a power of 2 + /* K K + * --- + * K 0 + */ + if ((d.high & (d.high - 1)) == 0) /* if d is a power of 2 */ { if (rem) { @@ -90,11 +97,12 @@ __udivmodti4(tu_int a, tu_int b, tu_int* rem) } return n.high >> __builtin_ctzll(d.high); } - // K K - // --- - // K 0 + /* K K + * --- + * K 0 + */ sr = __builtin_clzll(d.high) - __builtin_clzll(n.high); - // 0 <= sr <= n_udword_bits - 2 or sr large + /* 0 <= sr <= n_udword_bits - 2 or sr large */ if (sr > n_udword_bits - 2) { if (rem) @@ -102,22 +110,23 @@ __udivmodti4(tu_int a, tu_int b, tu_int* rem) return 0; } ++sr; - // 1 <= sr <= n_udword_bits - 1 - // q.all = n.all << (n_utword_bits - sr); + /* 1 <= sr <= n_udword_bits - 1 */ + /* q.all = n.all << (n_utword_bits - sr); */ q.low = 0; q.high = n.low << (n_udword_bits - sr); - // r.all = n.all >> sr; + /* r.all = n.all >> sr; */ r.high = n.high >> sr; r.low = (n.high << (n_udword_bits - sr)) | (n.low >> sr); } - else // d.low != 0 + else /* d.low != 0 */ { if (d.high == 0) { - // K X - // --- - // 0 K - if ((d.low & (d.low - 1)) == 0) // if d is a power of 2 + /* K X + * --- + * 0 K + */ + if ((d.low & (d.low - 1)) == 0) /* if d is a power of 2 */ { if (rem) *rem = n.low & (d.low - 1); @@ -128,36 +137,38 @@ __udivmodti4(tu_int a, tu_int b, tu_int* rem) q.low = (n.high << (n_udword_bits - sr)) | (n.low >> sr); return q.all; } - // K X - // --- - // 0 K + /* K X + * --- + * 0 K + */ sr = 1 + n_udword_bits + __builtin_clzll(d.low) - __builtin_clzll(n.high); - // 2 <= sr <= n_utword_bits - 1 - // q.all = n.all << (n_utword_bits - sr); - // r.all = n.all >> sr; - // if (sr == n_udword_bits) - // { - // q.low = 0; - // q.high = n.low; - // r.high = 0; - // r.low = n.high; - // } - // else if (sr < n_udword_bits) // 2 <= sr <= n_udword_bits - 1 - // { - // q.low = 0; - // q.high = n.low << (n_udword_bits - sr); - // r.high = n.high >> sr; - // r.low = (n.high << (n_udword_bits - sr)) | (n.low >> sr); - // } - // else // n_udword_bits + 1 <= sr <= n_utword_bits - 1 - // { - // q.low = n.low << (n_utword_bits - sr); - // q.high = (n.high << (n_utword_bits - sr)) | - // (n.low >> (sr - n_udword_bits)); - // r.high = 0; - // r.low = n.high >> (sr - n_udword_bits); - // } + /* 2 <= sr <= n_utword_bits - 1 + * q.all = n.all << (n_utword_bits - sr); + * r.all = n.all >> sr; + * if (sr == n_udword_bits) + * { + * q.low = 0; + * q.high = n.low; + * r.high = 0; + * r.low = n.high; + * } + * else if (sr < n_udword_bits) // 2 <= sr <= n_udword_bits - 1 + * { + * q.low = 0; + * q.high = n.low << (n_udword_bits - sr); + * r.high = n.high >> sr; + * r.low = (n.high << (n_udword_bits - sr)) | (n.low >> sr); + * } + * else // n_udword_bits + 1 <= sr <= n_utword_bits - 1 + * { + * q.low = n.low << (n_utword_bits - sr); + * q.high = (n.high << (n_utword_bits - sr)) | + * (n.low >> (sr - n_udword_bits)); + * r.high = 0; + * r.low = n.high >> (sr - n_udword_bits); + * } + */ q.low = (n.low << (n_utword_bits - sr)) & ((di_int)(int)(n_udword_bits - sr) >> (n_udword_bits-1)); q.high = ((n.low << ( n_udword_bits - sr)) & @@ -175,11 +186,12 @@ __udivmodti4(tu_int a, tu_int b, tu_int* rem) } else { - // K X - // --- - // K K + /* K X + * --- + * K K + */ sr = __builtin_clzll(d.high) - __builtin_clzll(n.high); - // 0 <= sr <= n_udword_bits - 1 or sr large + /*0 <= sr <= n_udword_bits - 1 or sr large */ if (sr > n_udword_bits - 1) { if (rem) @@ -187,21 +199,22 @@ __udivmodti4(tu_int a, tu_int b, tu_int* rem) return 0; } ++sr; - // 1 <= sr <= n_udword_bits - // q.all = n.all << (n_utword_bits - sr); + /* 1 <= sr <= n_udword_bits */ + /* q.all = n.all << (n_utword_bits - sr); */ q.low = 0; q.high = n.low << (n_udword_bits - sr); - // r.all = n.all >> sr; - // if (sr < n_udword_bits) - // { - // r.high = n.high >> sr; - // r.low = (n.high << (n_udword_bits - sr)) | (n.low >> sr); - // } - // else - // { - // r.high = 0; - // r.low = n.high; - // } + /* r.all = n.all >> sr; + * if (sr < n_udword_bits) + * { + * r.high = n.high >> sr; + * r.low = (n.high << (n_udword_bits - sr)) | (n.low >> sr); + * } + * else + * { + * r.high = 0; + * r.low = n.high; + * } + */ r.high = (n.high >> sr) & ((di_int)(int)(sr - n_udword_bits) >> (n_udword_bits-1)); r.low = (n.high << (n_udword_bits - sr)) | @@ -209,25 +222,27 @@ __udivmodti4(tu_int a, tu_int b, tu_int* rem) ((di_int)(int)(sr - n_udword_bits) >> (n_udword_bits-1))); } } - // Not a special case - // q and r are initialized with: - // q.all = n.all << (n_utword_bits - sr); - // r.all = n.all >> sr; - // 1 <= sr <= n_utword_bits - 1 + /* Not a special case + * q and r are initialized with: + * q.all = n.all << (n_utword_bits - sr); + * r.all = n.all >> sr; + * 1 <= sr <= n_utword_bits - 1 + */ su_int carry = 0; for (; sr > 0; --sr) { - // r:q = ((r:q) << 1) | carry + /* r:q = ((r:q) << 1) | carry */ r.high = (r.high << 1) | (r.low >> (n_udword_bits - 1)); r.low = (r.low << 1) | (q.high >> (n_udword_bits - 1)); q.high = (q.high << 1) | (q.low >> (n_udword_bits - 1)); q.low = (q.low << 1) | carry; - // carry = 0; - // if (r.all >= d.all) - // { - // r.all -= d.all; - // carry = 1; - // } + /* carry = 0; + * if (r.all >= d.all) + * { + * r.all -= d.all; + * carry = 1; + * } + */ const ti_int s = (ti_int)(d.all - r.all - 1) >> (n_utword_bits - 1); carry = s & 1; r.all -= d.all & s; diff --git a/lib/udivsi3.c b/lib/udivsi3.c index 16af22858..70528b66e 100644 --- a/lib/udivsi3.c +++ b/lib/udivsi3.c @@ -1,21 +1,22 @@ -//===-- udivsi3.c - Implement __udivsi3 -----------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __udivsi3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- udivsi3.c - Implement __udivsi3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __udivsi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" -// Returns: a / b +/* Returns: a / b */ -// Translated from Figure 3-40 of The PowerPC Compiler Writer's Guide +/* Translated from Figure 3-40 of The PowerPC Compiler Writer's Guide */ su_int __udivsi3(su_int n, su_int d) @@ -24,34 +25,35 @@ __udivsi3(su_int n, su_int d) su_int q; su_int r; unsigned sr; - // special cases + /* special cases */ if (d == 0) - return 0; // ?! + return 0; /* ?! */ if (n == 0) return 0; sr = __builtin_clz(d) - __builtin_clz(n); - // 0 <= sr <= n_uword_bits - 1 or sr large - if (sr > n_uword_bits - 1) // d > r + /* 0 <= sr <= n_uword_bits - 1 or sr large */ + if (sr > n_uword_bits - 1) /* d > r */ return 0; - if (sr == n_uword_bits - 1) // d == 1 + if (sr == n_uword_bits - 1) /* d == 1 */ return n; ++sr; - // 1 <= sr <= n_uword_bits - 1 - // Not a special case + /* 1 <= sr <= n_uword_bits - 1 */ + /* Not a special case */ q = n << (n_uword_bits - sr); r = n >> sr; su_int carry = 0; for (; sr > 0; --sr) { - // r:q = ((r:q) << 1) | carry + /* r:q = ((r:q) << 1) | carry */ r = (r << 1) | (q >> (n_uword_bits - 1)); q = (q << 1) | carry; - // carry = 0; - // if (r.all >= d.all) - // { - // r.all -= d.all; - // carry = 1; - // } + /* carry = 0; + * if (r.all >= d.all) + * { + * r.all -= d.all; + * carry = 1; + * } + */ const si_int s = (si_int)(d - r - 1) >> (n_uword_bits - 1); carry = s & 1; r -= d & s; diff --git a/lib/udivti3.c b/lib/udivti3.c index 785da055c..fb810fda5 100644 --- a/lib/udivti3.c +++ b/lib/udivti3.c @@ -1,15 +1,16 @@ -//===-- udivti3.c - Implement __udivti3 -----------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __udivti3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- udivti3.c - Implement __udivti3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __udivti3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #if __x86_64 @@ -17,7 +18,7 @@ tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem); -// Returns: a / b +/* Returns: a / b */ tu_int __udivti3(tu_int a, tu_int b) @@ -25,4 +26,4 @@ __udivti3(tu_int a, tu_int b) return __udivmodti4(a, b, 0); } -#endif +#endif /* __x86_64 */ diff --git a/lib/umoddi3.c b/lib/umoddi3.c index 81994d5b9..807bb5cec 100644 --- a/lib/umoddi3.c +++ b/lib/umoddi3.c @@ -1,21 +1,22 @@ -//===-- umoddi3.c - Implement __umoddi3 -----------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __umoddi3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- umoddi3.c - Implement __umoddi3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __umoddi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" du_int __udivmoddi4(du_int a, du_int b, du_int* rem); -// Returns: a % b +/* Returns: a % b */ du_int __umoddi3(du_int a, du_int b) diff --git a/lib/umodsi3.c b/lib/umodsi3.c index 115dc743b..ead773758 100644 --- a/lib/umodsi3.c +++ b/lib/umodsi3.c @@ -1,19 +1,20 @@ -//===-- umodsi3.c - Implement __umodsi3 -----------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements __umodsi3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- umodsi3.c - Implement __umodsi3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __umodsi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" -// Returns: a % b +/* Returns: a % b */ su_int __udivsi3(su_int a, su_int b); |