| 1 |
/* Copyright (C) 2007-2025 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_HF_MODE__ |
| 35 |
#define LIBGCC2_HAS_HF_MODE 1 |
| 36 |
#else |
| 37 |
#define LIBGCC2_HAS_HF_MODE 0 |
| 38 |
#endif |
| 39 |
|
| 40 |
#ifdef __LIBGCC_HAS_XF_MODE__ |
| 41 |
#define LIBGCC2_HAS_XF_MODE 1 |
| 42 |
#else |
| 43 |
#define LIBGCC2_HAS_XF_MODE 0 |
| 44 |
#endif |
| 45 |
|
| 46 |
#ifdef __LIBGCC_HAS_TF_MODE__ |
| 47 |
#define LIBGCC2_HAS_TF_MODE 1 |
| 48 |
#else |
| 49 |
#define LIBGCC2_HAS_TF_MODE 0 |
| 50 |
#endif |
| 51 |
|
| 52 |
#ifndef BID_HAS_HF_MODE |
| 53 |
#define BID_HAS_HF_MODE LIBGCC2_HAS_HF_MODE |
| 54 |
#endif |
| 55 |
|
| 56 |
#ifndef BID_HAS_XF_MODE |
| 57 |
#define BID_HAS_XF_MODE LIBGCC2_HAS_XF_MODE |
| 58 |
#endif |
| 59 |
|
| 60 |
#ifndef BID_HAS_TF_MODE |
| 61 |
#define BID_HAS_TF_MODE LIBGCC2_HAS_TF_MODE |
| 62 |
#endif |
| 63 |
|
| 64 |
/* Some handy typedefs. */ |
| 65 |
|
| 66 |
#if LIBGCC2_HAS_HF_MODE |
| 67 |
typedef float HFtype __attribute__ ((mode (HF))); |
| 68 |
#endif /* LIBGCC2_HAS_HF_MODE */ |
| 69 |
typedef float SFtype __attribute__ ((mode (SF))); |
| 70 |
typedef float DFtype __attribute__ ((mode (DF))); |
| 71 |
#if LIBGCC2_HAS_XF_MODE |
| 72 |
typedef float XFtype __attribute__ ((mode (XF))); |
| 73 |
#endif /* LIBGCC2_HAS_XF_MODE */ |
| 74 |
#if LIBGCC2_HAS_TF_MODE |
| 75 |
typedef float TFtype __attribute__ ((mode (TF))); |
| 76 |
#endif /* LIBGCC2_HAS_XF_MODE */ |
| 77 |
|
| 78 |
typedef int SItype __attribute__ ((mode (SI))); |
| 79 |
typedef int DItype __attribute__ ((mode (DI))); |
| 80 |
typedef unsigned int USItype __attribute__ ((mode (SI))); |
| 81 |
typedef unsigned int UDItype __attribute__ ((mode (DI))); |
| 82 |
|
| 83 |
/* The type of the result of a decimal float comparison. This must |
| 84 |
match `word_mode' in GCC for the target. */ |
| 85 |
|
| 86 |
typedef int CMPtype __attribute__ ((mode (word))); |
| 87 |
|
| 88 |
typedef int SINT8 __attribute__ ((mode (QI))); |
| 89 |
typedef unsigned int UINT8 __attribute__ ((mode (QI))); |
| 90 |
typedef USItype UINT32; |
| 91 |
typedef SItype SINT32; |
| 92 |
typedef UDItype UINT64; |
| 93 |
typedef DItype SINT64; |
| 94 |
|
| 95 |
/* It has to be identical to the one defined in bid_functions.h. */ |
| 96 |
typedef __attribute__ ((aligned(16))) struct |
| 97 |
{ |
| 98 |
UINT64 w[2]; |
| 99 |
} UINT128; |
| 100 |
#else /* if not IN_LIBGCC2 */ |
| 101 |
|
| 102 |
#ifndef BID_HAS_XF_MODE |
| 103 |
#define BID_HAS_XF_MODE 1 |
| 104 |
#endif |
| 105 |
|
| 106 |
#ifndef BID_HAS_TF_MODE |
| 107 |
#if defined __i386__ |
| 108 |
#define BID_HAS_TF_MODE 0 |
| 109 |
#else |
| 110 |
#define BID_HAS_TF_MODE 1 |
| 111 |
#endif |
| 112 |
#endif |
| 113 |
|
| 114 |
#if BID_HAS_HF_MODE |
| 115 |
#ifndef HFtype |
| 116 |
#define HFtype _Float16 |
| 117 |
#endif |
| 118 |
#endif |
| 119 |
|
| 120 |
#ifndef SFtype |
| 121 |
#define SFtype float |
| 122 |
#endif |
| 123 |
|
| 124 |
#ifndef DFtype |
| 125 |
#define DFtype double |
| 126 |
#endif |
| 127 |
|
| 128 |
#if BID_HAS_XF_MODE |
| 129 |
#ifndef XFtype |
| 130 |
#define XFtype long double |
| 131 |
#endif |
| 132 |
#endif |
| 133 |
|
| 134 |
#if BID_HAS_TF_MODE |
| 135 |
#ifndef TFtype |
| 136 |
#define TFtype __float128 |
| 137 |
#endif |
| 138 |
#endif |
| 139 |
|
| 140 |
#ifndef SItype |
| 141 |
#define SItype SINT32 |
| 142 |
#endif |
| 143 |
|
| 144 |
#ifndef DItype |
| 145 |
#define DItype SINT64 |
| 146 |
#endif |
| 147 |
|
| 148 |
#ifndef USItype |
| 149 |
#define USItype UINT32 |
| 150 |
#endif |
| 151 |
|
| 152 |
#ifndef UDItype |
| 153 |
#define UDItype UINT64 |
| 154 |
#endif |
| 155 |
|
| 156 |
#ifndef CMPtype |
| 157 |
#define CMPtype long |
| 158 |
#endif |
| 159 |
#endif /* IN_LIBGCC2 */ |
| 160 |
|
| 161 |
#if BID_HAS_GCC_DECIMAL_INTRINSICS |
| 162 |
/* Prototypes for gcc instrinsics */ |
| 163 |
|
| 164 |
extern _Decimal64 __bid_adddd3 (_Decimal64, _Decimal64); |
| 165 |
extern _Decimal64 __bid_subdd3 (_Decimal64, _Decimal64); |
| 166 |
extern _Decimal32 __bid_addsd3 (_Decimal32, _Decimal32); |
| 167 |
extern _Decimal32 __bid_subsd3 (_Decimal32, _Decimal32); |
| 168 |
extern _Decimal128 __bid_addtd3 (_Decimal128, _Decimal128); |
| 169 |
extern _Decimal128 __bid_subtd3 (_Decimal128, _Decimal128); |
| 170 |
extern DFtype __bid_truncdddf (_Decimal64); |
| 171 |
extern DItype __bid_fixdddi (_Decimal64); |
| 172 |
extern _Decimal32 __bid_truncddsd2 (_Decimal64); |
| 173 |
extern SFtype __bid_truncddsf (_Decimal64); |
| 174 |
extern SItype __bid_fixddsi (_Decimal64); |
| 175 |
extern _Decimal128 __bid_extendddtd2 (_Decimal64); |
| 176 |
#if BID_HAS_TF_MODE |
| 177 |
extern TFtype __bid_extendddtf (_Decimal64); |
| 178 |
#endif |
| 179 |
extern UDItype __bid_fixunsdddi (_Decimal64); |
| 180 |
extern USItype __bid_fixunsddsi (_Decimal64); |
| 181 |
#if BID_HAS_XF_MODE |
| 182 |
extern XFtype __bid_extendddxf (_Decimal64); |
| 183 |
#endif |
| 184 |
extern _Decimal64 __bid_extenddfdd (DFtype); |
| 185 |
extern _Decimal32 __bid_truncdfsd (DFtype); |
| 186 |
extern _Decimal128 __bid_extenddftd (DFtype); |
| 187 |
extern _Decimal64 __bid_floatdidd (DItype); |
| 188 |
extern _Decimal32 __bid_floatdisd (DItype); |
| 189 |
extern _Decimal128 __bid_floatditd (DItype); |
| 190 |
extern _Decimal64 __bid_divdd3 (_Decimal64, _Decimal64); |
| 191 |
extern _Decimal32 __bid_divsd3 (_Decimal32, _Decimal32); |
| 192 |
extern _Decimal128 __bid_divtd3 (_Decimal128, _Decimal128); |
| 193 |
extern CMPtype __bid_eqdd2 (_Decimal64, _Decimal64); |
| 194 |
extern CMPtype __bid_eqsd2 (_Decimal32, _Decimal32); |
| 195 |
extern CMPtype __bid_eqtd2 (_Decimal128, _Decimal128); |
| 196 |
extern CMPtype __bid_gedd2 (_Decimal64, _Decimal64); |
| 197 |
extern CMPtype __bid_gesd2 (_Decimal32, _Decimal32); |
| 198 |
extern CMPtype __bid_getd2 (_Decimal128, _Decimal128); |
| 199 |
extern CMPtype __bid_gtdd2 (_Decimal64, _Decimal64); |
| 200 |
extern CMPtype __bid_gtsd2 (_Decimal32, _Decimal32); |
| 201 |
extern CMPtype __bid_gttd2 (_Decimal128, _Decimal128); |
| 202 |
extern CMPtype __bid_ledd2 (_Decimal64, _Decimal64); |
| 203 |
extern CMPtype __bid_lesd2 (_Decimal32, _Decimal32); |
| 204 |
extern CMPtype __bid_letd2 (_Decimal128, _Decimal128); |
| 205 |
extern CMPtype __bid_ltdd2 (_Decimal64, _Decimal64); |
| 206 |
extern CMPtype __bid_ltsd2 (_Decimal32, _Decimal32); |
| 207 |
extern CMPtype __bid_lttd2 (_Decimal128, _Decimal128); |
| 208 |
extern CMPtype __bid_nedd2 (_Decimal64, _Decimal64); |
| 209 |
extern CMPtype __bid_nesd2 (_Decimal32, _Decimal32); |
| 210 |
extern CMPtype __bid_netd2 (_Decimal128, _Decimal128); |
| 211 |
extern CMPtype __bid_unorddd2 (_Decimal64, _Decimal64); |
| 212 |
extern CMPtype __bid_unordsd2 (_Decimal32, _Decimal32); |
| 213 |
extern CMPtype __bid_unordtd2 (_Decimal128, _Decimal128); |
| 214 |
extern _Decimal64 __bid_muldd3 (_Decimal64, _Decimal64); |
| 215 |
extern _Decimal32 __bid_mulsd3 (_Decimal32, _Decimal32); |
| 216 |
extern _Decimal128 __bid_multd3 (_Decimal128, _Decimal128); |
| 217 |
extern _Decimal64 __bid_extendsddd2 (_Decimal32); |
| 218 |
extern DFtype __bid_extendsddf (_Decimal32); |
| 219 |
extern DItype __bid_fixsddi (_Decimal32); |
| 220 |
extern SFtype __bid_truncsdsf (_Decimal32); |
| 221 |
extern SItype __bid_fixsdsi (_Decimal32); |
| 222 |
extern _Decimal128 __bid_extendsdtd2 (_Decimal32); |
| 223 |
#if BID_HAS_TF_MODE |
| 224 |
extern TFtype __bid_extendsdtf (_Decimal32); |
| 225 |
#endif |
| 226 |
extern UDItype __bid_fixunssddi (_Decimal32); |
| 227 |
extern USItype __bid_fixunssdsi (_Decimal32); |
| 228 |
#if BID_HAS_XF_MODE |
| 229 |
extern XFtype __bid_extendsdxf (_Decimal32); |
| 230 |
#endif |
| 231 |
extern _Decimal64 __bid_extendsfdd (SFtype); |
| 232 |
extern _Decimal32 __bid_extendsfsd (SFtype); |
| 233 |
extern _Decimal128 __bid_extendsftd (SFtype); |
| 234 |
extern _Decimal64 __bid_floatsidd (SItype); |
| 235 |
extern _Decimal32 __bid_floatsisd (SItype); |
| 236 |
extern _Decimal128 __bid_floatsitd (SItype); |
| 237 |
extern _Decimal64 __bid_trunctddd2 (_Decimal128); |
| 238 |
extern DFtype __bid_trunctddf (_Decimal128); |
| 239 |
extern DItype __bid_fixtddi (_Decimal128); |
| 240 |
extern _Decimal32 __bid_trunctdsd2 (_Decimal128); |
| 241 |
extern SFtype __bid_trunctdsf (_Decimal128); |
| 242 |
extern SItype __bid_fixtdsi (_Decimal128); |
| 243 |
#if BID_HAS_TF_MODE |
| 244 |
extern TFtype __bid_trunctdtf (_Decimal128); |
| 245 |
#endif |
| 246 |
extern UDItype __bid_fixunstddi (_Decimal128); |
| 247 |
extern USItype __bid_fixunstdsi (_Decimal128); |
| 248 |
#if BID_HAS_XF_MODE |
| 249 |
extern XFtype __bid_trunctdxf (_Decimal128); |
| 250 |
#endif |
| 251 |
#if BID_HAS_TF_MODE |
| 252 |
extern _Decimal64 __bid_trunctfdd (TFtype); |
| 253 |
extern _Decimal32 __bid_trunctfsd (TFtype); |
| 254 |
extern _Decimal128 __bid_extendtftd (TFtype); |
| 255 |
#endif |
| 256 |
extern _Decimal64 __bid_floatunsdidd (UDItype); |
| 257 |
extern _Decimal32 __bid_floatunsdisd (UDItype); |
| 258 |
extern _Decimal128 __bid_floatunsditd (UDItype); |
| 259 |
extern _Decimal64 __bid_floatunssidd (USItype); |
| 260 |
extern _Decimal32 __bid_floatunssisd (USItype); |
| 261 |
extern _Decimal128 __bid_floatunssitd (USItype); |
| 262 |
#if BID_HAS_XF_MODE |
| 263 |
extern _Decimal64 __bid_truncxfdd (XFtype); |
| 264 |
extern _Decimal32 __bid_truncxfsd (XFtype); |
| 265 |
extern _Decimal128 __bid_extendxftd (XFtype); |
| 266 |
#endif |
| 267 |
extern int isinfd32 (_Decimal32); |
| 268 |
extern int isinfd64 (_Decimal64); |
| 269 |
extern int isinfd128 (_Decimal128); |
| 270 |
#if BID_HAS_HF_MODE |
| 271 |
extern _Decimal32 __bid_extendhfsd (HFtype); |
| 272 |
extern _Decimal64 __bid_extendhfdd (HFtype); |
| 273 |
extern _Decimal128 __bid_extendhftd (HFtype); |
| 274 |
extern HFtype __bid_truncsdhf (_Decimal32); |
| 275 |
extern HFtype __bid_truncddhf (_Decimal64); |
| 276 |
extern HFtype __bid_trunctdhf (_Decimal128); |
| 277 |
#endif |
| 278 |
#endif /* BID_HAS_GCC_DECIMAL_INTRINSICS */ |
| 279 |
|
| 280 |
extern void __dfp_set_round (int); |
| 281 |
extern int __dfp_get_round (void); |
| 282 |
extern void __dfp_clear_except (void); |
| 283 |
extern int __dfp_test_except (int); |
| 284 |
extern void __dfp_raise_except (int); |
| 285 |
|
| 286 |
#if BID_HAS_GCC_DECIMAL_INTRINSICS |
| 287 |
/* Used by gcc intrinsics. We have to define them after UINT128 |
| 288 |
is defined. */ |
| 289 |
union decimal32 { |
| 290 |
_Decimal32 d; |
| 291 |
UINT32 i; |
| 292 |
}; |
| 293 |
|
| 294 |
union decimal64 { |
| 295 |
_Decimal64 d; |
| 296 |
UINT64 i; |
| 297 |
}; |
| 298 |
|
| 299 |
union decimal128 { |
| 300 |
_Decimal128 d; |
| 301 |
UINT128 i; |
| 302 |
}; |
| 303 |
|
| 304 |
#if BID_HAS_TF_MODE |
| 305 |
union float128 { |
| 306 |
TFtype f; |
| 307 |
UINT128 i; |
| 308 |
}; |
| 309 |
#endif |
| 310 |
#endif /* BID_HAS_GCC_DECIMAL_INTRINSICS */ |
| 311 |
|
| 312 |
#endif /* _BID_GCC_INTRINSICS_H */ |