int_lib.h (2667B)
1 //===-- int_lib.h - LLP64 little-endian ----------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 // kit-tailored: LLP64 (long == 32, pointer == 64), little-endian, 8 // freestanding. Targets: Win64 x86_64. 9 //===----------------------------------------------------------------------===// 10 11 #ifndef INT_LIB_H 12 #define INT_LIB_H 13 14 #define COMPILER_RT_ABI 15 16 #define ALWAYS_INLINE __attribute__((always_inline)) 17 #define NOINLINE __attribute__((noinline)) 18 #define NORETURN __attribute__((noreturn)) 19 #define UNUSED __attribute__((unused)) 20 21 #include <float.h> 22 #include <limits.h> 23 #include <stdbool.h> 24 #include <stdint.h> 25 26 // ---- int_types.h (merged) ---- 27 #ifndef INT_TYPES_H 28 #define INT_TYPES_H 29 30 // (was int_endianness.h — only defined the markers below) 31 #define _YUGA_LITTLE_ENDIAN 1 32 #define _YUGA_BIG_ENDIAN 0 33 34 #ifdef si_int 35 #undef si_int 36 #endif 37 typedef int32_t si_int; 38 typedef uint32_t su_int; 39 #define clzsi __builtin_clz 40 #define ctzsi __builtin_ctz 41 42 typedef int64_t di_int; 43 typedef uint64_t du_int; 44 45 typedef union { 46 di_int all; 47 struct { 48 su_int low; 49 si_int high; 50 } s; 51 } dwords; 52 53 typedef union { 54 du_int all; 55 struct { 56 su_int low; 57 su_int high; 58 } s; 59 } udwords; 60 61 #define CRT_HAS_128BIT 62 typedef int ti_int __attribute__((mode(TI))); 63 typedef unsigned tu_int __attribute__((mode(TI))); 64 65 typedef union { 66 ti_int all; 67 struct { 68 du_int low; 69 di_int high; 70 } s; 71 } twords; 72 73 typedef union { 74 tu_int all; 75 struct { 76 du_int low; 77 du_int high; 78 } s; 79 } utwords; 80 81 static inline ti_int make_ti(di_int h, di_int l) { 82 twords r; 83 r.s.high = h; 84 r.s.low = l; 85 return r.all; 86 } 87 static inline tu_int make_tu(du_int h, du_int l) { 88 utwords r; 89 r.s.high = h; 90 r.s.low = l; 91 return r.all; 92 } 93 94 #define CRT_HAS_FLOATING_POINT 1 95 96 typedef union { 97 su_int u; 98 float f; 99 } float_bits; 100 typedef union { 101 udwords u; 102 double f; 103 } double_bits; 104 typedef struct { 105 udwords low; 106 udwords high; 107 } uqwords; 108 109 #endif // INT_TYPES_H 110 #include "int_util.h" 111 112 COMPILER_RT_ABI int __paritysi2(si_int a); 113 COMPILER_RT_ABI int __paritydi2(di_int a); 114 COMPILER_RT_ABI di_int __divdi3(di_int a, di_int b); 115 COMPILER_RT_ABI si_int __divsi3(si_int a, si_int b); 116 COMPILER_RT_ABI su_int __udivsi3(su_int n, su_int d); 117 COMPILER_RT_ABI su_int __udivmodsi4(su_int a, su_int b, su_int* rem); 118 COMPILER_RT_ABI du_int __udivmoddi4(du_int a, du_int b, du_int* rem); 119 COMPILER_RT_ABI int __clzti2(ti_int a); 120 COMPILER_RT_ABI tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem); 121 122 #endif // INT_LIB_H