1 /****************************************************************************** 2 Copyright (c) 2007-2011, Intel Corp. 3 All rights reserved. 4 5 Redistribution and use in source and binary forms, with or without 6 modification, are permitted provided that the following conditions are met: 7 8 * Redistributions of source code must retain the above copyright notice, 9 this list of conditions and the following disclaimer. 10 * Redistributions in binary form must reproduce the above copyright 11 notice, this list of conditions and the following disclaimer in the 12 documentation and/or other materials provided with the distribution. 13 * Neither the name of Intel Corporation nor the names of its contributors 14 may be used to endorse or promote products derived from this software 15 without specific prior written permission. 16 17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 27 THE POSSIBILITY OF SUCH DAMAGE. 28 ******************************************************************************/ 29 30 #ifndef _BID_GCC_INTRINSICS_H 31 #define _BID_GCC_INTRINSICS_H 32 33 #ifdef IN_LIBGCC2 34 35 #include "tconfig.h" 36 #include "coretypes.h" 37 #include "tm.h" 38 39 #ifndef LIBGCC2_WORDS_BIG_ENDIAN 40 #define LIBGCC2_WORDS_BIG_ENDIAN WORDS_BIG_ENDIAN 41 #endif 42 43 #ifndef LIBGCC2_FLOAT_WORDS_BIG_ENDIAN 44 #define LIBGCC2_FLOAT_WORDS_BIG_ENDIAN LIBGCC2_WORDS_BIG_ENDIAN 45 #endif 46 47 #ifndef LIBGCC2_LONG_DOUBLE_TYPE_SIZE 48 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE LONG_DOUBLE_TYPE_SIZE 49 #endif 50 51 #ifndef LIBGCC2_HAS_XF_MODE 52 #define LIBGCC2_HAS_XF_MODE \ 53 (BITS_PER_UNIT == 8 && LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 80) 54 #endif 55 56 #ifndef LIBGCC2_HAS_TF_MODE 57 #define LIBGCC2_HAS_TF_MODE \ 58 (BITS_PER_UNIT == 8 && LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128) 59 #endif 60 61 #ifndef BID_HAS_XF_MODE 62 #define BID_HAS_XF_MODE LIBGCC2_HAS_XF_MODE 63 #endif 64 65 #ifndef BID_HAS_TF_MODE 66 #define BID_HAS_TF_MODE LIBGCC2_HAS_TF_MODE 67 #endif 68 69 /* Some handy typedefs. */ 70 71 typedef float SFtype __attribute__ ((mode (SF))); 72 typedef float DFtype __attribute__ ((mode (DF))); 73 #if LIBGCC2_HAS_XF_MODE 74 typedef float XFtype __attribute__ ((mode (XF))); 75 #endif /* LIBGCC2_HAS_XF_MODE */ 76 #if LIBGCC2_HAS_TF_MODE 77 typedef float TFtype __attribute__ ((mode (TF))); 78 #endif /* LIBGCC2_HAS_XF_MODE */ 79 80 typedef int SItype __attribute__ ((mode (SI))); 81 typedef int DItype __attribute__ ((mode (DI))); 82 typedef unsigned int USItype __attribute__ ((mode (SI))); 83 typedef unsigned int UDItype __attribute__ ((mode (DI))); 84 85 /* The type of the result of a decimal float comparison. This must 86 match `word_mode' in GCC for the target. */ 87 88 typedef int CMPtype __attribute__ ((mode (word))); 89 90 typedef int BID_SINT8 __attribute__ ((mode (QI))); 91 typedef unsigned int BID_UINT8 __attribute__ ((mode (QI))); 92 typedef USItype BID_UINT32; 93 typedef SItype BID_SINT32; 94 typedef UDItype BID_UINT64; 95 typedef DItype BID_SINT64; 96 97 /* It has to be identical to the one defined in bid_functions.h. */ 98 typedef __attribute__ ((aligned(16))) struct 99 { 100 BID_UINT64 w[2]; 101 } BID_UINT128; 102 #else /* if not IN_LIBGCC2 */ 103 104 #ifndef BID_HAS_XF_MODE 105 #define BID_HAS_XF_MODE 1 106 #endif 107 108 #ifndef BID_HAS_TF_MODE 109 #if defined __i386__ 110 #define BID_HAS_TF_MODE 0 111 #else 112 #define BID_HAS_TF_MODE 1 113 #endif 114 #endif 115 116 #ifndef SFtype 117 #define SFtype float 118 #endif 119 120 #ifndef DFtype 121 #define DFtype double 122 #endif 123 124 #if BID_HAS_XF_MODE 125 #ifndef XFtype 126 #define XFtype long double 127 #endif 128 129 #endif /* IN_LIBGCC2 */ 130 131 #if BID_HAS_TF_MODE 132 #ifndef TFtype 133 #define TFtype __float128 134 #endif 135 #endif 136 137 #ifndef SItype 138 #define SItype BID_SINT32 139 #endif 140 141 #ifndef DItype 142 #define DItype BID_SINT64 143 #endif 144 145 #ifndef USItype 146 #define USItype BID_UINT32 147 #endif 148 149 #ifndef UDItype 150 #define UDItype BID_UINT64 151 #endif 152 153 #ifndef CMPtype 154 #define CMPtype long 155 #endif 156 #endif /* IN_LIBGCC2 */ 157 158 #if BID_HAS_GCC_DECIMAL_INTRINSICS 159 /* Prototypes for gcc instrinsics */ 160 161 BID_EXTERN_C _Decimal64 __bid_adddd3 (_Decimal64, _Decimal64); 162 BID_EXTERN_C _Decimal64 __bid_subdd3 (_Decimal64, _Decimal64); 163 BID_EXTERN_C _Decimal32 __bid_addsd3 (_Decimal32, _Decimal32); 164 BID_EXTERN_C _Decimal32 __bid_subsd3 (_Decimal32, _Decimal32); 165 BID_EXTERN_C _Decimal128 __bid_addtd3 (_Decimal128, _Decimal128); 166 BID_EXTERN_C _Decimal128 __bid_subtd3 (_Decimal128, _Decimal128); 167 BID_EXTERN_C DFtype __bid_truncdddf (_Decimal64); 168 BID_EXTERN_C DItype __bid_fixdddi (_Decimal64); 169 BID_EXTERN_C _Decimal32 __bid_truncddsd2 (_Decimal64); 170 BID_EXTERN_C SFtype __bid_truncddsf (_Decimal64); 171 BID_EXTERN_C SItype __bid_fixddsi (_Decimal64); 172 BID_EXTERN_C _Decimal128 __bid_extendddtd2 (_Decimal64); 173 #if BID_HAS_TF_MODE 174 BID_EXTERN_C TFtype __bid_extendddtf (_Decimal64); 175 #endif 176 BID_EXTERN_C UDItype __bid_fixunsdddi (_Decimal64); 177 BID_EXTERN_C USItype __bid_fixunsddsi (_Decimal64); 178 #if BID_HAS_XF_MODE 179 BID_EXTERN_C XFtype __bid_extendddxf (_Decimal64); 180 #endif 181 BID_EXTERN_C _Decimal64 __bid_extenddfdd (DFtype); 182 BID_EXTERN_C _Decimal32 __bid_truncdfsd (DFtype); 183 BID_EXTERN_C _Decimal128 __bid_extenddftd (DFtype); 184 BID_EXTERN_C _Decimal64 __bid_floatdidd (DItype); 185 BID_EXTERN_C _Decimal32 __bid_floatdisd (DItype); 186 BID_EXTERN_C _Decimal128 __bid_floatditd (DItype); 187 BID_EXTERN_C _Decimal64 __bid_divdd3 (_Decimal64, _Decimal64); 188 BID_EXTERN_C _Decimal32 __bid_divsd3 (_Decimal32, _Decimal32); 189 BID_EXTERN_C _Decimal128 __bid_divtd3 (_Decimal128, _Decimal128); 190 BID_EXTERN_C CMPtype __bid_eqdd2 (_Decimal64, _Decimal64); 191 BID_EXTERN_C CMPtype __bid_eqsd2 (_Decimal32, _Decimal32); 192 BID_EXTERN_C CMPtype __bid_eqtd2 (_Decimal128, _Decimal128); 193 BID_EXTERN_C CMPtype __bid_gedd2 (_Decimal64, _Decimal64); 194 BID_EXTERN_C CMPtype __bid_gesd2 (_Decimal32, _Decimal32); 195 BID_EXTERN_C CMPtype __bid_getd2 (_Decimal128, _Decimal128); 196 BID_EXTERN_C CMPtype __bid_gtdd2 (_Decimal64, _Decimal64); 197 BID_EXTERN_C CMPtype __bid_gtsd2 (_Decimal32, _Decimal32); 198 BID_EXTERN_C CMPtype __bid_gttd2 (_Decimal128, _Decimal128); 199 BID_EXTERN_C CMPtype __bid_ledd2 (_Decimal64, _Decimal64); 200 BID_EXTERN_C CMPtype __bid_lesd2 (_Decimal32, _Decimal32); 201 BID_EXTERN_C CMPtype __bid_letd2 (_Decimal128, _Decimal128); 202 BID_EXTERN_C CMPtype __bid_ltdd2 (_Decimal64, _Decimal64); 203 BID_EXTERN_C CMPtype __bid_ltsd2 (_Decimal32, _Decimal32); 204 BID_EXTERN_C CMPtype __bid_lttd2 (_Decimal128, _Decimal128); 205 BID_EXTERN_C CMPtype __bid_nedd2 (_Decimal64, _Decimal64); 206 BID_EXTERN_C CMPtype __bid_nesd2 (_Decimal32, _Decimal32); 207 BID_EXTERN_C CMPtype __bid_netd2 (_Decimal128, _Decimal128); 208 BID_EXTERN_C CMPtype __bid_unorddd2 (_Decimal64, _Decimal64); 209 BID_EXTERN_C CMPtype __bid_unordsd2 (_Decimal32, _Decimal32); 210 BID_EXTERN_C CMPtype __bid_unordtd2 (_Decimal128, _Decimal128); 211 BID_EXTERN_C _Decimal64 __bid_muldd3 (_Decimal64, _Decimal64); 212 BID_EXTERN_C _Decimal32 __bid_mulsd3 (_Decimal32, _Decimal32); 213 BID_EXTERN_C _Decimal128 __bid_multd3 (_Decimal128, _Decimal128); 214 BID_EXTERN_C _Decimal64 __bid_extendsddd2 (_Decimal32); 215 BID_EXTERN_C DFtype __bid_extendsddf (_Decimal32); 216 BID_EXTERN_C DItype __bid_fixsddi (_Decimal32); 217 BID_EXTERN_C SFtype __bid_truncsdsf (_Decimal32); 218 BID_EXTERN_C SItype __bid_fixsdsi (_Decimal32); 219 BID_EXTERN_C _Decimal128 __bid_extendsdtd2 (_Decimal32); 220 #if BID_HAS_TF_MODE 221 BID_EXTERN_C TFtype __bid_extendsdtf (_Decimal32); 222 #endif 223 BID_EXTERN_C UDItype __bid_fixunssddi (_Decimal32); 224 BID_EXTERN_C USItype __bid_fixunssdsi (_Decimal32); 225 #if BID_HAS_XF_MODE 226 BID_EXTERN_C XFtype __bid_extendsdxf (_Decimal32); 227 #endif 228 BID_EXTERN_C _Decimal64 __bid_extendsfdd (SFtype); 229 BID_EXTERN_C _Decimal32 __bid_extendsfsd (SFtype); 230 BID_EXTERN_C _Decimal128 __bid_extendsftd (SFtype); 231 BID_EXTERN_C _Decimal64 __bid_floatsidd (SItype); 232 BID_EXTERN_C _Decimal32 __bid_floatsisd (SItype); 233 BID_EXTERN_C _Decimal128 __bid_floatsitd (SItype); 234 BID_EXTERN_C _Decimal64 __bid_trunctddd2 (_Decimal128); 235 BID_EXTERN_C DFtype __bid_trunctddf (_Decimal128); 236 BID_EXTERN_C DItype __bid_fixtddi (_Decimal128); 237 BID_EXTERN_C _Decimal32 __bid_trunctdsd2 (_Decimal128); 238 BID_EXTERN_C SFtype __bid_trunctdsf (_Decimal128); 239 BID_EXTERN_C SItype __bid_fixtdsi (_Decimal128); 240 #if BID_HAS_TF_MODE 241 BID_EXTERN_C TFtype __bid_trunctdtf (_Decimal128); 242 #endif 243 BID_EXTERN_C UDItype __bid_fixunstddi (_Decimal128); 244 BID_EXTERN_C USItype __bid_fixunstdsi (_Decimal128); 245 #if BID_HAS_XF_MODE 246 BID_EXTERN_C XFtype __bid_trunctdxf (_Decimal128); 247 #endif 248 #if BID_HAS_TF_MODE 249 BID_EXTERN_C _Decimal64 __bid_trunctfdd (TFtype); 250 BID_EXTERN_C _Decimal32 __bid_trunctfsd (TFtype); 251 BID_EXTERN_C _Decimal128 __bid_extendtftd (TFtype); 252 #endif 253 BID_EXTERN_C _Decimal64 __bid_floatunsdidd (UDItype); 254 BID_EXTERN_C _Decimal32 __bid_floatunsdisd (UDItype); 255 BID_EXTERN_C _Decimal128 __bid_floatunsditd (UDItype); 256 BID_EXTERN_C _Decimal64 __bid_floatunssidd (USItype); 257 BID_EXTERN_C _Decimal32 __bid_floatunssisd (USItype); 258 BID_EXTERN_C _Decimal128 __bid_floatunssitd (USItype); 259 #if BID_HAS_XF_MODE 260 BID_EXTERN_C _Decimal64 __bid_truncxfdd (XFtype); 261 BID_EXTERN_C _Decimal32 __bid_truncxfsd (XFtype); 262 BID_EXTERN_C _Decimal128 __bid_extendxftd (XFtype); 263 #endif 264 BID_EXTERN_C int isinfd32 (_Decimal32); 265 BID_EXTERN_C int isinfd64 (_Decimal64); 266 BID_EXTERN_C int isinfd128 (_Decimal128); 267 #endif /* BID_HAS_GCC_DECIMAL_INTRINSICS */ 268 269 BID_EXTERN_C void __dfp_set_round (int); 270 BID_EXTERN_C int __dfp_get_round (void); 271 BID_EXTERN_C void __dfp_clear_except (void); 272 BID_EXTERN_C int __dfp_test_except (int); 273 BID_EXTERN_C void __dfp_raise_except (int); 274 275 #if BID_HAS_GCC_DECIMAL_INTRINSICS 276 /* Used by gcc intrinsics. We have to define them after BID_UINT128 277 is defined. */ 278 union decimal32 { 279 _Decimal32 d; 280 BID_UINT32 i; 281 }; 282 283 union decimal64 { 284 _Decimal64 d; 285 BID_UINT64 i; 286 }; 287 288 union decimal128 { 289 _Decimal128 d; 290 BID_UINT128 i; 291 }; 292 293 #if BID_HAS_TF_MODE 294 union float128 { 295 TFtype f; 296 BID_UINT128 i; 297 }; 298 #endif 299 #endif /* BID_HAS_GCC_DECIMAL_INTRINSICS */ 300 301 #endif /* _BID_GCC_INTRINSICS_H */ 302