1 /* Copyright (C) 2007-2020 Free Software Foundation, Inc. 2 3 This file is part of GCC. 4 5 GCC is free software; you can redistribute it and/or modify it under 6 the terms of the GNU General Public License as published by the Free 7 Software Foundation; either version 3, or (at your option) any later 8 version. 9 10 GCC is distributed in the hope that it will be useful, but WITHOUT ANY 11 WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 for more details. 14 15 Under Section 7 of GPL version 3, you are granted additional 16 permissions described in the GCC Runtime Library Exception, version 17 3.1, as published by the Free Software Foundation. 18 19 You should have received a copy of the GNU General Public License and 20 a copy of the GCC Runtime Library Exception along with this program; 21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 22 <http://www.gnu.org/licenses/>. */ 23 24 #ifndef _BID_GCC_INTRINSICS_H 25 #define _BID_GCC_INTRINSICS_H 26 27 #ifdef IN_LIBGCC2 28 29 #include "tconfig.h" 30 #include "coretypes.h" 31 #include "tm.h" 32 #include "libgcc_tm.h" 33 34 #ifdef __LIBGCC_HAS_XF_MODE__ 35 #define LIBGCC2_HAS_XF_MODE 1 36 #else 37 #define LIBGCC2_HAS_XF_MODE 0 38 #endif 39 40 #ifdef __LIBGCC_HAS_TF_MODE__ 41 #define LIBGCC2_HAS_TF_MODE 1 42 #else 43 #define LIBGCC2_HAS_TF_MODE 0 44 #endif 45 46 #ifndef BID_HAS_XF_MODE 47 #define BID_HAS_XF_MODE LIBGCC2_HAS_XF_MODE 48 #endif 49 50 #ifndef BID_HAS_TF_MODE 51 #define BID_HAS_TF_MODE LIBGCC2_HAS_TF_MODE 52 #endif 53 54 /* Some handy typedefs. */ 55 56 typedef float SFtype __attribute__ ((mode (SF))); 57 typedef float DFtype __attribute__ ((mode (DF))); 58 #if LIBGCC2_HAS_XF_MODE 59 typedef float XFtype __attribute__ ((mode (XF))); 60 #endif /* LIBGCC2_HAS_XF_MODE */ 61 #if LIBGCC2_HAS_TF_MODE 62 typedef float TFtype __attribute__ ((mode (TF))); 63 #endif /* LIBGCC2_HAS_XF_MODE */ 64 65 typedef int SItype __attribute__ ((mode (SI))); 66 typedef int DItype __attribute__ ((mode (DI))); 67 typedef unsigned int USItype __attribute__ ((mode (SI))); 68 typedef unsigned int UDItype __attribute__ ((mode (DI))); 69 70 /* The type of the result of a decimal float comparison. This must 71 match `word_mode' in GCC for the target. */ 72 73 typedef int CMPtype __attribute__ ((mode (word))); 74 75 typedef int SINT8 __attribute__ ((mode (QI))); 76 typedef unsigned int UINT8 __attribute__ ((mode (QI))); 77 typedef USItype UINT32; 78 typedef SItype SINT32; 79 typedef UDItype UINT64; 80 typedef DItype SINT64; 81 82 /* It has to be identical to the one defined in bid_functions.h. */ 83 typedef __attribute__ ((aligned(16))) struct 84 { 85 UINT64 w[2]; 86 } UINT128; 87 #else /* if not IN_LIBGCC2 */ 88 89 #ifndef BID_HAS_XF_MODE 90 #define BID_HAS_XF_MODE 1 91 #endif 92 93 #ifndef BID_HAS_TF_MODE 94 #if defined __i386__ 95 #define BID_HAS_TF_MODE 0 96 #else 97 #define BID_HAS_TF_MODE 1 98 #endif 99 #endif 100 101 #ifndef SFtype 102 #define SFtype float 103 #endif 104 105 #ifndef DFtype 106 #define DFtype double 107 #endif 108 109 #if BID_HAS_XF_MODE 110 #ifndef XFtype 111 #define XFtype long double 112 #endif 113 114 #endif /* IN_LIBGCC2 */ 115 116 #if BID_HAS_TF_MODE 117 #ifndef TFtype 118 #define TFtype __float128 119 #endif 120 #endif 121 122 #ifndef SItype 123 #define SItype SINT32 124 #endif 125 126 #ifndef DItype 127 #define DItype SINT64 128 #endif 129 130 #ifndef USItype 131 #define USItype UINT32 132 #endif 133 134 #ifndef UDItype 135 #define UDItype UINT64 136 #endif 137 138 #ifndef CMPtype 139 #define CMPtype long 140 #endif 141 #endif /* IN_LIBGCC2 */ 142 143 #if BID_HAS_GCC_DECIMAL_INTRINSICS 144 /* Prototypes for gcc instrinsics */ 145 146 extern _Decimal64 __bid_adddd3 (_Decimal64, _Decimal64); 147 extern _Decimal64 __bid_subdd3 (_Decimal64, _Decimal64); 148 extern _Decimal32 __bid_addsd3 (_Decimal32, _Decimal32); 149 extern _Decimal32 __bid_subsd3 (_Decimal32, _Decimal32); 150 extern _Decimal128 __bid_addtd3 (_Decimal128, _Decimal128); 151 extern _Decimal128 __bid_subtd3 (_Decimal128, _Decimal128); 152 extern DFtype __bid_truncdddf (_Decimal64); 153 extern DItype __bid_fixdddi (_Decimal64); 154 extern _Decimal32 __bid_truncddsd2 (_Decimal64); 155 extern SFtype __bid_truncddsf (_Decimal64); 156 extern SItype __bid_fixddsi (_Decimal64); 157 extern _Decimal128 __bid_extendddtd2 (_Decimal64); 158 #if BID_HAS_TF_MODE 159 extern TFtype __bid_extendddtf (_Decimal64); 160 #endif 161 extern UDItype __bid_fixunsdddi (_Decimal64); 162 extern USItype __bid_fixunsddsi (_Decimal64); 163 #if BID_HAS_XF_MODE 164 extern XFtype __bid_extendddxf (_Decimal64); 165 #endif 166 extern _Decimal64 __bid_extenddfdd (DFtype); 167 extern _Decimal32 __bid_truncdfsd (DFtype); 168 extern _Decimal128 __bid_extenddftd (DFtype); 169 extern _Decimal64 __bid_floatdidd (DItype); 170 extern _Decimal32 __bid_floatdisd (DItype); 171 extern _Decimal128 __bid_floatditd (DItype); 172 extern _Decimal64 __bid_divdd3 (_Decimal64, _Decimal64); 173 extern _Decimal32 __bid_divsd3 (_Decimal32, _Decimal32); 174 extern _Decimal128 __bid_divtd3 (_Decimal128, _Decimal128); 175 extern CMPtype __bid_eqdd2 (_Decimal64, _Decimal64); 176 extern CMPtype __bid_eqsd2 (_Decimal32, _Decimal32); 177 extern CMPtype __bid_eqtd2 (_Decimal128, _Decimal128); 178 extern CMPtype __bid_gedd2 (_Decimal64, _Decimal64); 179 extern CMPtype __bid_gesd2 (_Decimal32, _Decimal32); 180 extern CMPtype __bid_getd2 (_Decimal128, _Decimal128); 181 extern CMPtype __bid_gtdd2 (_Decimal64, _Decimal64); 182 extern CMPtype __bid_gtsd2 (_Decimal32, _Decimal32); 183 extern CMPtype __bid_gttd2 (_Decimal128, _Decimal128); 184 extern CMPtype __bid_ledd2 (_Decimal64, _Decimal64); 185 extern CMPtype __bid_lesd2 (_Decimal32, _Decimal32); 186 extern CMPtype __bid_letd2 (_Decimal128, _Decimal128); 187 extern CMPtype __bid_ltdd2 (_Decimal64, _Decimal64); 188 extern CMPtype __bid_ltsd2 (_Decimal32, _Decimal32); 189 extern CMPtype __bid_lttd2 (_Decimal128, _Decimal128); 190 extern CMPtype __bid_nedd2 (_Decimal64, _Decimal64); 191 extern CMPtype __bid_nesd2 (_Decimal32, _Decimal32); 192 extern CMPtype __bid_netd2 (_Decimal128, _Decimal128); 193 extern CMPtype __bid_unorddd2 (_Decimal64, _Decimal64); 194 extern CMPtype __bid_unordsd2 (_Decimal32, _Decimal32); 195 extern CMPtype __bid_unordtd2 (_Decimal128, _Decimal128); 196 extern _Decimal64 __bid_muldd3 (_Decimal64, _Decimal64); 197 extern _Decimal32 __bid_mulsd3 (_Decimal32, _Decimal32); 198 extern _Decimal128 __bid_multd3 (_Decimal128, _Decimal128); 199 extern _Decimal64 __bid_extendsddd2 (_Decimal32); 200 extern DFtype __bid_extendsddf (_Decimal32); 201 extern DItype __bid_fixsddi (_Decimal32); 202 extern SFtype __bid_truncsdsf (_Decimal32); 203 extern SItype __bid_fixsdsi (_Decimal32); 204 extern _Decimal128 __bid_extendsdtd2 (_Decimal32); 205 #if BID_HAS_TF_MODE 206 extern TFtype __bid_extendsdtf (_Decimal32); 207 #endif 208 extern UDItype __bid_fixunssddi (_Decimal32); 209 extern USItype __bid_fixunssdsi (_Decimal32); 210 #if BID_HAS_XF_MODE 211 extern XFtype __bid_extendsdxf (_Decimal32); 212 #endif 213 extern _Decimal64 __bid_extendsfdd (SFtype); 214 extern _Decimal32 __bid_extendsfsd (SFtype); 215 extern _Decimal128 __bid_extendsftd (SFtype); 216 extern _Decimal64 __bid_floatsidd (SItype); 217 extern _Decimal32 __bid_floatsisd (SItype); 218 extern _Decimal128 __bid_floatsitd (SItype); 219 extern _Decimal64 __bid_trunctddd2 (_Decimal128); 220 extern DFtype __bid_trunctddf (_Decimal128); 221 extern DItype __bid_fixtddi (_Decimal128); 222 extern _Decimal32 __bid_trunctdsd2 (_Decimal128); 223 extern SFtype __bid_trunctdsf (_Decimal128); 224 extern SItype __bid_fixtdsi (_Decimal128); 225 #if BID_HAS_TF_MODE 226 extern TFtype __bid_trunctdtf (_Decimal128); 227 #endif 228 extern UDItype __bid_fixunstddi (_Decimal128); 229 extern USItype __bid_fixunstdsi (_Decimal128); 230 #if BID_HAS_XF_MODE 231 extern XFtype __bid_trunctdxf (_Decimal128); 232 #endif 233 #if BID_HAS_TF_MODE 234 extern _Decimal64 __bid_trunctfdd (TFtype); 235 extern _Decimal32 __bid_trunctfsd (TFtype); 236 extern _Decimal128 __bid_extendtftd (TFtype); 237 #endif 238 extern _Decimal64 __bid_floatunsdidd (UDItype); 239 extern _Decimal32 __bid_floatunsdisd (UDItype); 240 extern _Decimal128 __bid_floatunsditd (UDItype); 241 extern _Decimal64 __bid_floatunssidd (USItype); 242 extern _Decimal32 __bid_floatunssisd (USItype); 243 extern _Decimal128 __bid_floatunssitd (USItype); 244 #if BID_HAS_XF_MODE 245 extern _Decimal64 __bid_truncxfdd (XFtype); 246 extern _Decimal32 __bid_truncxfsd (XFtype); 247 extern _Decimal128 __bid_extendxftd (XFtype); 248 #endif 249 extern int isinfd32 (_Decimal32); 250 extern int isinfd64 (_Decimal64); 251 extern int isinfd128 (_Decimal128); 252 #endif /* BID_HAS_GCC_DECIMAL_INTRINSICS */ 253 254 extern void __dfp_set_round (int); 255 extern int __dfp_get_round (void); 256 extern void __dfp_clear_except (void); 257 extern int __dfp_test_except (int); 258 extern void __dfp_raise_except (int); 259 260 #if BID_HAS_GCC_DECIMAL_INTRINSICS 261 /* Used by gcc intrinsics. We have to define them after UINT128 262 is defined. */ 263 union decimal32 { 264 _Decimal32 d; 265 UINT32 i; 266 }; 267 268 union decimal64 { 269 _Decimal64 d; 270 UINT64 i; 271 }; 272 273 union decimal128 { 274 _Decimal128 d; 275 UINT128 i; 276 }; 277 278 #if BID_HAS_TF_MODE 279 union float128 { 280 TFtype f; 281 UINT128 i; 282 }; 283 #endif 284 #endif /* BID_HAS_GCC_DECIMAL_INTRINSICS */ 285 286 #endif /* _BID_GCC_INTRINSICS_H */ 287