Main/Ipf/FpuRmode.s\r
\r
[Sources.ARM]\r
+ Main/Arm/fixunsdfsi.c\r
+ Main/Arm/floatunsidf.c\r
Main/Arm/flt_rounds.c\r
\r
[Binaries.IA32]\r
--- /dev/null
+/**\r
+University of Illinois/NCSA\r
+Open Source License\r
+\r
+Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT\r
+\r
+All rights reserved.\r
+\r
+Developed by:\r
+\r
+ LLVM Team\r
+\r
+ University of Illinois at Urbana-Champaign\r
+\r
+ http://llvm.org\r
+\r
+Permission is hereby granted, free of charge, to any person obtaining a copy of\r
+this software and associated documentation files (the "Software"), to deal with\r
+the Software without restriction, including without limitation the rights to\r
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\r
+of the Software, and to permit persons to whom the Software is furnished to do\r
+so, subject to the following conditions:\r
+\r
+ * Redistributions of source code must retain the above copyright notice,\r
+ this list of conditions and the following disclaimers.\r
+\r
+ * Redistributions in binary form must reproduce the above copyright notice,\r
+ this list of conditions and the following disclaimers in the\r
+ documentation and/or other materials provided with the distribution.\r
+\r
+ * Neither the names of the LLVM Team, University of Illinois at\r
+ Urbana-Champaign, nor the names of its contributors may be used to\r
+ endorse or promote products derived from this Software without specific\r
+ prior written permission.\r
+\r
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE\r
+SOFTWARE.\r
+**/\r
+\r
+#include "int_lib.h"\r
+\r
+/* Returns: convert a to a unsigned int, rounding toward zero.\r
+ * Negative values all become zero.\r
+ */\r
+\r
+/* Assumption: double is a IEEE 64 bit floating point type\r
+ * su_int is a 32 bit integral type\r
+ * value in double is representable in su_int or is negative\r
+ * (no range checking performed)\r
+ */\r
+\r
+/* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */\r
+\r
+ARM_EABI_FNALIAS(d2uiz, fixunsdfsi)\r
+\r
+COMPILER_RT_ABI su_int\r
+__fixunsdfsi(double a)\r
+{\r
+ double_bits fb;\r
+ fb.f = a;\r
+ int e = ((fb.u.s.high & 0x7FF00000) >> 20) - 1023;\r
+ if (e < 0 || (fb.u.s.high & 0x80000000))\r
+ return 0;\r
+ return (\r
+ 0x80000000u |\r
+ ((fb.u.s.high & 0x000FFFFF) << 11) |\r
+ (fb.u.s.low >> 21)\r
+ ) >> (31 - e);\r
+}\r
--- /dev/null
+/**\r
+University of Illinois/NCSA\r
+Open Source License\r
+\r
+Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT\r
+\r
+All rights reserved.\r
+\r
+Developed by:\r
+\r
+ LLVM Team\r
+\r
+ University of Illinois at Urbana-Champaign\r
+\r
+ http://llvm.org\r
+\r
+Permission is hereby granted, free of charge, to any person obtaining a copy of\r
+this software and associated documentation files (the "Software"), to deal with\r
+the Software without restriction, including without limitation the rights to\r
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\r
+of the Software, and to permit persons to whom the Software is furnished to do\r
+so, subject to the following conditions:\r
+\r
+ * Redistributions of source code must retain the above copyright notice,\r
+ this list of conditions and the following disclaimers.\r
+\r
+ * Redistributions in binary form must reproduce the above copyright notice,\r
+ this list of conditions and the following disclaimers in the\r
+ documentation and/or other materials provided with the distribution.\r
+\r
+ * Neither the names of the LLVM Team, University of Illinois at\r
+ Urbana-Champaign, nor the names of its contributors may be used to\r
+ endorse or promote products derived from this Software without specific\r
+ prior written permission.\r
+\r
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE\r
+SOFTWARE.\r
+**/\r
+\r
+#define DOUBLE_PRECISION\r
+#include "fp_lib.h"\r
+\r
+#include "int_lib.h"\r
+\r
+ARM_EABI_FNALIAS(ui2d, floatunsidf)\r
+\r
+COMPILER_RT_ABI fp_t\r
+__floatunsidf(unsigned int a) {\r
+\r
+ const int aWidth = sizeof a * CHAR_BIT;\r
+\r
+ // Handle zero as a special case to protect clz\r
+ if (a == 0) return fromRep(0);\r
+\r
+ // Exponent of (fp_t)a is the width of abs(a).\r
+ const int exponent = (aWidth - 1) - __builtin_clz(a);\r
+ rep_t result;\r
+\r
+ // Shift a into the significand field and clear the implicit bit.\r
+ const int shift = significandBits - exponent;\r
+ result = (rep_t)a << shift ^ implicitBit;\r
+\r
+ // Insert the exponent\r
+ result += (rep_t)(exponent + exponentBias) << significandBits;\r
+ return fromRep(result);\r
+}\r
--- /dev/null
+/**\r
+University of Illinois/NCSA\r
+Open Source License\r
+\r
+Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT\r
+\r
+All rights reserved.\r
+\r
+Developed by:\r
+\r
+ LLVM Team\r
+\r
+ University of Illinois at Urbana-Champaign\r
+\r
+ http://llvm.org\r
+\r
+Permission is hereby granted, free of charge, to any person obtaining a copy of\r
+this software and associated documentation files (the "Software"), to deal with\r
+the Software without restriction, including without limitation the rights to\r
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\r
+of the Software, and to permit persons to whom the Software is furnished to do\r
+so, subject to the following conditions:\r
+\r
+ * Redistributions of source code must retain the above copyright notice,\r
+ this list of conditions and the following disclaimers.\r
+\r
+ * Redistributions in binary form must reproduce the above copyright notice,\r
+ this list of conditions and the following disclaimers in the\r
+ documentation and/or other materials provided with the distribution.\r
+\r
+ * Neither the names of the LLVM Team, University of Illinois at\r
+ Urbana-Champaign, nor the names of its contributors may be used to\r
+ endorse or promote products derived from this Software without specific\r
+ prior written permission.\r
+\r
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE\r
+SOFTWARE.\r
+**/\r
+\r
+#ifndef FP_LIB_HEADER\r
+#define FP_LIB_HEADER\r
+\r
+#include <stdint.h>\r
+#include <stdbool.h>\r
+#include <limits.h>\r
+#include "int_lib.h"\r
+\r
+#if defined SINGLE_PRECISION\r
+\r
+typedef uint32_t rep_t;\r
+typedef int32_t srep_t;\r
+typedef float fp_t;\r
+#define REP_C UINT32_C\r
+#define significandBits 23\r
+\r
+static inline int rep_clz(rep_t a) {\r
+ return __builtin_clz(a);\r
+}\r
+\r
+// 32x32 --> 64 bit multiply\r
+static inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) {\r
+ const uint64_t product = (uint64_t)a*b;\r
+ *hi = product >> 32;\r
+ *lo = product;\r
+}\r
+COMPILER_RT_ABI fp_t __addsf3(fp_t a, fp_t b);\r
+\r
+#elif defined DOUBLE_PRECISION\r
+\r
+typedef uint64_t rep_t;\r
+typedef int64_t srep_t;\r
+typedef double fp_t;\r
+#define REP_C UINT64_C\r
+#define significandBits 52\r
+\r
+static inline int rep_clz(rep_t a) {\r
+#if defined __LP64__\r
+ return __builtin_clzl(a);\r
+#else\r
+ if (a & REP_C(0xffffffff00000000))\r
+ return __builtin_clz(a >> 32);\r
+ else\r
+ return 32 + __builtin_clz(a & REP_C(0xffffffff));\r
+#endif\r
+}\r
+\r
+#define loWord(a) (a & 0xffffffffU)\r
+#define hiWord(a) (a >> 32)\r
+\r
+// 64x64 -> 128 wide multiply for platforms that don't have such an operation;\r
+// many 64-bit platforms have this operation, but they tend to have hardware\r
+// floating-point, so we don't bother with a special case for them here.\r
+static inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) {\r
+ // Each of the component 32x32 -> 64 products\r
+ const uint64_t plolo = loWord(a) * loWord(b);\r
+ const uint64_t plohi = loWord(a) * hiWord(b);\r
+ const uint64_t philo = hiWord(a) * loWord(b);\r
+ const uint64_t phihi = hiWord(a) * hiWord(b);\r
+ // Sum terms that contribute to lo in a way that allows us to get the carry\r
+ const uint64_t r0 = loWord(plolo);\r
+ const uint64_t r1 = hiWord(plolo) + loWord(plohi) + loWord(philo);\r
+ *lo = r0 + (r1 << 32);\r
+ // Sum terms contributing to hi with the carry from lo\r
+ *hi = hiWord(plohi) + hiWord(philo) + hiWord(r1) + phihi;\r
+}\r
+#undef loWord\r
+#undef hiWord\r
+\r
+COMPILER_RT_ABI fp_t __adddf3(fp_t a, fp_t b);\r
+\r
+#elif defined QUAD_PRECISION\r
+#if __LDBL_MANT_DIG__ == 113\r
+#define CRT_LDBL_128BIT\r
+typedef __uint128_t rep_t;\r
+typedef __int128_t srep_t;\r
+typedef long double fp_t;\r
+#define REP_C (__uint128_t)\r
+// Note: Since there is no explicit way to tell compiler the constant is a\r
+// 128-bit integer, we let the constant be casted to 128-bit integer\r
+#define significandBits 112\r
+\r
+static inline int rep_clz(rep_t a) {\r
+ const union\r
+ {\r
+ __uint128_t ll;\r
+#if _YUGA_BIG_ENDIAN\r
+ struct { uint64_t high, low; } s;\r
+#else\r
+ struct { uint64_t low, high; } s;\r
+#endif\r
+ } uu = { .ll = a };\r
+\r
+ uint64_t word;\r
+ uint64_t add;\r
+\r
+ if (uu.s.high){\r
+ word = uu.s.high;\r
+ add = 0;\r
+ }\r
+ else{\r
+ word = uu.s.low;\r
+ add = 64;\r
+ }\r
+ return __builtin_clzll(word) + add;\r
+}\r
+\r
+#define Word_LoMask UINT64_C(0x00000000ffffffff)\r
+#define Word_HiMask UINT64_C(0xffffffff00000000)\r
+#define Word_FullMask UINT64_C(0xffffffffffffffff)\r
+#define Word_1(a) (uint64_t)((a >> 96) & Word_LoMask)\r
+#define Word_2(a) (uint64_t)((a >> 64) & Word_LoMask)\r
+#define Word_3(a) (uint64_t)((a >> 32) & Word_LoMask)\r
+#define Word_4(a) (uint64_t)(a & Word_LoMask)\r
+\r
+// 128x128 -> 256 wide multiply for platforms that don't have such an operation;\r
+// many 64-bit platforms have this operation, but they tend to have hardware\r
+// floating-point, so we don't bother with a special case for them here.\r
+static inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) {\r
+\r
+ const uint64_t product11 = Word_1(a) * Word_1(b);\r
+ const uint64_t product12 = Word_1(a) * Word_2(b);\r
+ const uint64_t product13 = Word_1(a) * Word_3(b);\r
+ const uint64_t product14 = Word_1(a) * Word_4(b);\r
+ const uint64_t product21 = Word_2(a) * Word_1(b);\r
+ const uint64_t product22 = Word_2(a) * Word_2(b);\r
+ const uint64_t product23 = Word_2(a) * Word_3(b);\r
+ const uint64_t product24 = Word_2(a) * Word_4(b);\r
+ const uint64_t product31 = Word_3(a) * Word_1(b);\r
+ const uint64_t product32 = Word_3(a) * Word_2(b);\r
+ const uint64_t product33 = Word_3(a) * Word_3(b);\r
+ const uint64_t product34 = Word_3(a) * Word_4(b);\r
+ const uint64_t product41 = Word_4(a) * Word_1(b);\r
+ const uint64_t product42 = Word_4(a) * Word_2(b);\r
+ const uint64_t product43 = Word_4(a) * Word_3(b);\r
+ const uint64_t product44 = Word_4(a) * Word_4(b);\r
+\r
+ const __uint128_t sum0 = (__uint128_t)product44;\r
+ const __uint128_t sum1 = (__uint128_t)product34 +\r
+ (__uint128_t)product43;\r
+ const __uint128_t sum2 = (__uint128_t)product24 +\r
+ (__uint128_t)product33 +\r
+ (__uint128_t)product42;\r
+ const __uint128_t sum3 = (__uint128_t)product14 +\r
+ (__uint128_t)product23 +\r
+ (__uint128_t)product32 +\r
+ (__uint128_t)product41;\r
+ const __uint128_t sum4 = (__uint128_t)product13 +\r
+ (__uint128_t)product22 +\r
+ (__uint128_t)product31;\r
+ const __uint128_t sum5 = (__uint128_t)product12 +\r
+ (__uint128_t)product21;\r
+ const __uint128_t sum6 = (__uint128_t)product11;\r
+\r
+ const __uint128_t r0 = (sum0 & Word_FullMask) +\r
+ ((sum1 & Word_LoMask) << 32);\r
+ const __uint128_t r1 = (sum0 >> 64) +\r
+ ((sum1 >> 32) & Word_FullMask) +\r
+ (sum2 & Word_FullMask) +\r
+ ((sum3 << 32) & Word_HiMask);\r
+\r
+ *lo = r0 + (r1 << 64);\r
+ *hi = (r1 >> 64) +\r
+ (sum1 >> 96) +\r
+ (sum2 >> 64) +\r
+ (sum3 >> 32) +\r
+ sum4 +\r
+ (sum5 << 32) +\r
+ (sum6 << 64);\r
+}\r
+#undef Word_1\r
+#undef Word_2\r
+#undef Word_3\r
+#undef Word_4\r
+#undef Word_HiMask\r
+#undef Word_LoMask\r
+#undef Word_FullMask\r
+#endif // __LDBL_MANT_DIG__ == 113\r
+#else\r
+#error SINGLE_PRECISION, DOUBLE_PRECISION or QUAD_PRECISION must be defined.\r
+#endif\r
+\r
+#if defined(SINGLE_PRECISION) || defined(DOUBLE_PRECISION) || defined(CRT_LDBL_128BIT)\r
+#define typeWidth (sizeof(rep_t)*CHAR_BIT)\r
+#define exponentBits (typeWidth - significandBits - 1)\r
+#define maxExponent ((1 << exponentBits) - 1)\r
+#define exponentBias (maxExponent >> 1)\r
+\r
+#define implicitBit (REP_C(1) << significandBits)\r
+#define significandMask (implicitBit - 1U)\r
+#define signBit (REP_C(1) << (significandBits + exponentBits))\r
+#define absMask (signBit - 1U)\r
+#define exponentMask (absMask ^ significandMask)\r
+#define oneRep ((rep_t)exponentBias << significandBits)\r
+#define infRep exponentMask\r
+#define quietBit (implicitBit >> 1)\r
+#define qnanRep (exponentMask | quietBit)\r
+\r
+static inline rep_t toRep(fp_t x) {\r
+ const union { fp_t f; rep_t i; } rep = {.f = x};\r
+ return rep.i;\r
+}\r
+\r
+static inline fp_t fromRep(rep_t x) {\r
+ const union { fp_t f; rep_t i; } rep = {.i = x};\r
+ return rep.f;\r
+}\r
+\r
+static inline int normalize(rep_t *significand) {\r
+ const int shift = rep_clz(*significand) - rep_clz(implicitBit);\r
+ *significand <<= shift;\r
+ return 1 - shift;\r
+}\r
+\r
+static inline void wideLeftShift(rep_t *hi, rep_t *lo, int count) {\r
+ *hi = *hi << count | *lo >> (typeWidth - count);\r
+ *lo = *lo << count;\r
+}\r
+\r
+static inline void wideRightShiftWithSticky(rep_t *hi, rep_t *lo, unsigned int count) {\r
+ if (count < typeWidth) {\r
+ const bool sticky = *lo << (typeWidth - count);\r
+ *lo = *hi << (typeWidth - count) | *lo >> count | sticky;\r
+ *hi = *hi >> count;\r
+ }\r
+ else if (count < 2*typeWidth) {\r
+ const bool sticky = *hi << (2*typeWidth - count) | *lo;\r
+ *lo = *hi >> (count - typeWidth) | sticky;\r
+ *hi = 0;\r
+ } else {\r
+ const bool sticky = *hi | *lo;\r
+ *lo = sticky;\r
+ *hi = 0;\r
+ }\r
+}\r
+#endif\r
+\r
+#endif // FP_LIB_HEADER\r
--- /dev/null
+/** @file\r
+*\r
+* Copyright (c) 2013 - 2014, ARM Limited. All rights reserved.\r
+*\r
+* This program and the accompanying materials\r
+* are licensed and made available under the terms and conditions of the BSD License\r
+* which accompanies this distribution. The full text of the license may be found at\r
+* http://opensource.org/licenses/bsd-license.php\r
+*\r
+* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+*\r
+**/\r
+/**\r
+University of Illinois/NCSA\r
+Open Source License\r
+\r
+Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT\r
+\r
+All rights reserved.\r
+\r
+Developed by:\r
+\r
+ LLVM Team\r
+\r
+ University of Illinois at Urbana-Champaign\r
+\r
+ http://llvm.org\r
+\r
+Permission is hereby granted, free of charge, to any person obtaining a copy of\r
+this software and associated documentation files (the "Software"), to deal with\r
+the Software without restriction, including without limitation the rights to\r
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\r
+of the Software, and to permit persons to whom the Software is furnished to do\r
+so, subject to the following conditions:\r
+\r
+ * Redistributions of source code must retain the above copyright notice,\r
+ this list of conditions and the following disclaimers.\r
+\r
+ * Redistributions in binary form must reproduce the above copyright notice,\r
+ this list of conditions and the following disclaimers in the\r
+ documentation and/or other materials provided with the distribution.\r
+\r
+ * Neither the names of the LLVM Team, University of Illinois at\r
+ Urbana-Champaign, nor the names of its contributors may be used to\r
+ endorse or promote products derived from this Software without specific\r
+ prior written permission.\r
+\r
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE\r
+SOFTWARE.\r
+**/\r
+\r
+#ifndef INT_ENDIANNESS_H\r
+#define INT_ENDIANNESS_H\r
+\r
+#include <sys/endian.h>\r
+\r
+#if _BYTE_ORDER == _BIG_ENDIAN\r
+#define _YUGA_LITTLE_ENDIAN 0\r
+#define _YUGA_BIG_ENDIAN 1\r
+#elif _BYTE_ORDER == _LITTLE_ENDIAN\r
+#define _YUGA_LITTLE_ENDIAN 1\r
+#define _YUGA_BIG_ENDIAN 0\r
+#endif /* _BYTE_ORDER */\r
+\r
+#endif /* INT_ENDIANNESS_H */\r
--- /dev/null
+/**\r
+University of Illinois/NCSA\r
+Open Source License\r
+\r
+Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT\r
+\r
+All rights reserved.\r
+\r
+Developed by:\r
+\r
+ LLVM Team\r
+\r
+ University of Illinois at Urbana-Champaign\r
+\r
+ http://llvm.org\r
+\r
+Permission is hereby granted, free of charge, to any person obtaining a copy of\r
+this software and associated documentation files (the "Software"), to deal with\r
+the Software without restriction, including without limitation the rights to\r
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\r
+of the Software, and to permit persons to whom the Software is furnished to do\r
+so, subject to the following conditions:\r
+\r
+ * Redistributions of source code must retain the above copyright notice,\r
+ this list of conditions and the following disclaimers.\r
+\r
+ * Redistributions in binary form must reproduce the above copyright notice,\r
+ this list of conditions and the following disclaimers in the\r
+ documentation and/or other materials provided with the distribution.\r
+\r
+ * Neither the names of the LLVM Team, University of Illinois at\r
+ Urbana-Champaign, nor the names of its contributors may be used to\r
+ endorse or promote products derived from this Software without specific\r
+ prior written permission.\r
+\r
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE\r
+SOFTWARE.\r
+**/\r
+\r
+#ifndef INT_LIB_H\r
+#define INT_LIB_H\r
+\r
+/* Assumption: Signed integral is 2's complement. */\r
+/* Assumption: Right shift of signed negative is arithmetic shift. */\r
+/* Assumption: Endianness is little or big (not mixed). */\r
+\r
+/* ABI macro definitions */\r
+\r
+/*\r
+ * TODO define this appropriately for targets that require explicit export\r
+ * declarations (i.e. Windows)\r
+ */\r
+#define COMPILER_RT_EXPORT\r
+\r
+#if __ARM_EABI__\r
+# define ARM_EABI_FNALIAS(aeabi_name, name) \\r
+ void __aeabi_##aeabi_name() __attribute__((alias("__" #name)));\r
+# define COMPILER_RT_ABI COMPILER_RT_EXPORT __attribute__((pcs("aapcs")))\r
+#else\r
+# define ARM_EABI_FNALIAS(aeabi_name, name)\r
+# define COMPILER_RT_ABI COMPILER_RT_EXPORT\r
+#endif\r
+\r
+#if defined(__NetBSD__) && (defined(_KERNEL) || defined(_STANDALONE))\r
+/*\r
+ * Kernel and boot environment can't use normal headers,\r
+ * so use the equivalent system headers.\r
+ */\r
+# include <machine/limits.h>\r
+# include <sys/stdint.h>\r
+# include <sys/types.h>\r
+#else\r
+/* Include the standard compiler builtin headers we use functionality from. */\r
+# include <limits.h>\r
+# include <stdint.h>\r
+# include <stdbool.h>\r
+# include <float.h>\r
+#endif\r
+\r
+/* Include the commonly used internal type definitions. */\r
+#include "int_types.h"\r
+\r
+/* Include internal utility function declarations. */\r
+#include "int_util.h"\r
+\r
+COMPILER_RT_ABI si_int __paritysi2(si_int a);\r
+COMPILER_RT_ABI si_int __paritydi2(di_int a);\r
+\r
+COMPILER_RT_ABI di_int __divdi3(di_int a, di_int b);\r
+COMPILER_RT_ABI si_int __divsi3(si_int a, si_int b);\r
+COMPILER_RT_ABI su_int __udivsi3(su_int n, su_int d);\r
+\r
+COMPILER_RT_ABI su_int __udivmodsi4(su_int a, su_int b, su_int* rem);\r
+COMPILER_RT_ABI du_int __udivmoddi4(du_int a, du_int b, du_int* rem);\r
+#ifdef CRT_HAS_128BIT\r
+COMPILER_RT_ABI si_int __clzti2(ti_int a);\r
+COMPILER_RT_ABI tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem);\r
+#endif\r
+\r
+#endif /* INT_LIB_H */\r
--- /dev/null
+/**\r
+University of Illinois/NCSA\r
+Open Source License\r
+\r
+Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT\r
+\r
+All rights reserved.\r
+\r
+Developed by:\r
+\r
+ LLVM Team\r
+\r
+ University of Illinois at Urbana-Champaign\r
+\r
+ http://llvm.org\r
+\r
+Permission is hereby granted, free of charge, to any person obtaining a copy of\r
+this software and associated documentation files (the "Software"), to deal with\r
+the Software without restriction, including without limitation the rights to\r
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\r
+of the Software, and to permit persons to whom the Software is furnished to do\r
+so, subject to the following conditions:\r
+\r
+ * Redistributions of source code must retain the above copyright notice,\r
+ this list of conditions and the following disclaimers.\r
+\r
+ * Redistributions in binary form must reproduce the above copyright notice,\r
+ this list of conditions and the following disclaimers in the\r
+ documentation and/or other materials provided with the distribution.\r
+\r
+ * Neither the names of the LLVM Team, University of Illinois at\r
+ Urbana-Champaign, nor the names of its contributors may be used to\r
+ endorse or promote products derived from this Software without specific\r
+ prior written permission.\r
+\r
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE\r
+SOFTWARE.\r
+**/\r
+\r
+#ifndef INT_TYPES_H\r
+#define INT_TYPES_H\r
+\r
+#include "int_endianness.h"\r
+\r
+typedef int si_int;\r
+typedef unsigned su_int;\r
+\r
+typedef long long di_int;\r
+typedef unsigned long long du_int;\r
+\r
+typedef union\r
+{\r
+ di_int all;\r
+ struct\r
+ {\r
+#if _YUGA_LITTLE_ENDIAN\r
+ su_int low;\r
+ si_int high;\r
+#else\r
+ si_int high;\r
+ su_int low;\r
+#endif /* _YUGA_LITTLE_ENDIAN */\r
+ }s;\r
+} dwords;\r
+\r
+typedef union\r
+{\r
+ du_int all;\r
+ struct\r
+ {\r
+#if _YUGA_LITTLE_ENDIAN\r
+ su_int low;\r
+ su_int high;\r
+#else\r
+ su_int high;\r
+ su_int low;\r
+#endif /* _YUGA_LITTLE_ENDIAN */\r
+ }s;\r
+} udwords;\r
+\r
+#if __LP64__\r
+#define CRT_HAS_128BIT\r
+#endif\r
+\r
+#ifdef CRT_HAS_128BIT\r
+typedef int ti_int __attribute__ ((mode (TI)));\r
+typedef unsigned tu_int __attribute__ ((mode (TI)));\r
+\r
+typedef union\r
+{\r
+ ti_int all;\r
+ struct\r
+ {\r
+#if _YUGA_LITTLE_ENDIAN\r
+ du_int low;\r
+ di_int high;\r
+#else\r
+ di_int high;\r
+ du_int low;\r
+#endif /* _YUGA_LITTLE_ENDIAN */\r
+ }s;\r
+} twords;\r
+\r
+typedef union\r
+{\r
+ tu_int all;\r
+ struct\r
+ {\r
+#if _YUGA_LITTLE_ENDIAN\r
+ du_int low;\r
+ du_int high;\r
+#else\r
+ du_int high;\r
+ du_int low;\r
+#endif /* _YUGA_LITTLE_ENDIAN */\r
+ }s;\r
+} utwords;\r
+\r
+static inline ti_int make_ti(di_int h, di_int l) {\r
+ twords r;\r
+ r.s.high = h;\r
+ r.s.low = l;\r
+ return r.all;\r
+}\r
+\r
+static inline tu_int make_tu(du_int h, du_int l) {\r
+ utwords r;\r
+ r.s.high = h;\r
+ r.s.low = l;\r
+ return r.all;\r
+}\r
+\r
+#endif /* CRT_HAS_128BIT */\r
+\r
+typedef union\r
+{\r
+ su_int u;\r
+ float f;\r
+} float_bits;\r
+\r
+typedef union\r
+{\r
+ udwords u;\r
+ double f;\r
+} double_bits;\r
+\r
+typedef struct\r
+{\r
+#if _YUGA_LITTLE_ENDIAN\r
+ udwords low;\r
+ udwords high;\r
+#else\r
+ udwords high;\r
+ udwords low;\r
+#endif /* _YUGA_LITTLE_ENDIAN */\r
+} uqwords;\r
+\r
+typedef union\r
+{\r
+ uqwords u;\r
+ long double f;\r
+} long_double_bits;\r
+\r
+#endif /* INT_TYPES_H */\r
+\r
--- /dev/null
+/** @file\r
+\r
+ Copyright (c) 2014, ARM Limited. All rights reserved.\r
+\r
+ This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+/**\r
+University of Illinois/NCSA\r
+Open Source License\r
+\r
+Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT\r
+\r
+All rights reserved.\r
+\r
+Developed by:\r
+\r
+ LLVM Team\r
+\r
+ University of Illinois at Urbana-Champaign\r
+\r
+ http://llvm.org\r
+\r
+Permission is hereby granted, free of charge, to any person obtaining a copy of\r
+this software and associated documentation files (the "Software"), to deal with\r
+the Software without restriction, including without limitation the rights to\r
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\r
+of the Software, and to permit persons to whom the Software is furnished to do\r
+so, subject to the following conditions:\r
+\r
+ * Redistributions of source code must retain the above copyright notice,\r
+ this list of conditions and the following disclaimers.\r
+\r
+ * Redistributions in binary form must reproduce the above copyright notice,\r
+ this list of conditions and the following disclaimers in the\r
+ documentation and/or other materials provided with the distribution.\r
+\r
+ * Neither the names of the LLVM Team, University of Illinois at\r
+ Urbana-Champaign, nor the names of its contributors may be used to\r
+ endorse or promote products derived from this Software without specific\r
+ prior written permission.\r
+\r
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE\r
+SOFTWARE.\r
+**/\r
+\r
+#ifndef INT_UTIL_H\r
+#define INT_UTIL_H\r
+\r
+/** \brief Trigger a program abort (or panic for kernel code). */\r
+#define compilerrt_abort() compilerrt_abort_impl(__FILE__, __LINE__, \\r
+ __func__)\r
+\r
+void compilerrt_abort_impl(const char *file, int line,\r
+ const char *function) __attribute__((noreturn));\r
+\r
+#endif /* INT_UTIL_H */\r