1 /* Header file for dfp-bit.c. 2 Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 3 Free Software Foundation, Inc. 4 5 This file is part of GCC. 6 7 GCC is free software; you can redistribute it and/or modify it under 8 the terms of the GNU General Public License as published by the Free 9 Software Foundation; either version 3, or (at your option) any later 10 version. 11 12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY 13 WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 for more details. 16 17 Under Section 7 of GPL version 3, you are granted additional 18 permissions described in the GCC Runtime Library Exception, version 19 3.1, as published by the Free Software Foundation. 20 21 You should have received a copy of the GNU General Public License and 22 a copy of the GCC Runtime Library Exception along with this program; 23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 24 <http://www.gnu.org/licenses/>. */ 25 26 #ifndef _DFPBIT_H 27 #define _DFPBIT_H 28 29 #include <float.h> 30 #include <fenv.h> 31 #include <decRound.h> 32 #include <decExcept.h> 33 #include "tconfig.h" 34 #include "coretypes.h" 35 #include "tm.h" 36 #include "libgcc_tm.h" 37 38 #ifndef LIBGCC2_LONG_DOUBLE_TYPE_SIZE 39 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE LONG_DOUBLE_TYPE_SIZE 40 #endif 41 42 /* We need to know the size of long double that the C library supports. 43 Don't use LIBGCC2_HAS_XF_MODE or LIBGCC2_HAS_TF_MODE here because 44 some targets set both of those. */ 45 46 #define LONG_DOUBLE_HAS_XF_MODE \ 47 (BITS_PER_UNIT == 8 && LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 80) 48 49 #define LONG_DOUBLE_HAS_TF_MODE \ 50 (BITS_PER_UNIT == 8 && LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128) 51 52 /* Depending on WIDTH, define a number of macros: 53 54 DFP_C_TYPE: type of the arguments to the libgcc functions; 55 (eg _Decimal32) 56 57 IEEE_TYPE: the corresponding (encoded) IEEE754 type; 58 (eg decimal32) 59 60 TO_INTERNAL: the name of the decNumber function to convert an 61 encoded value into the decNumber internal representation; 62 63 TO_ENCODED: the name of the decNumber function to convert an 64 internally represented decNumber into the encoded 65 representation. 66 67 FROM_STRING: the name of the decNumber function to read an 68 encoded value from a string. 69 70 TO_STRING: the name of the decNumber function to write an 71 encoded value to a string. */ 72 73 #if WIDTH == 32 74 #define DFP_C_TYPE _Decimal32 75 #define IEEE_TYPE decimal32 76 #define HOST_TO_IEEE __host_to_ieee_32 77 #define IEEE_TO_HOST __ieee_to_host_32 78 #define TO_INTERNAL __decimal32ToNumber 79 #define TO_ENCODED __decimal32FromNumber 80 #define FROM_STRING __decimal32FromString 81 #define TO_STRING __decimal32ToString 82 #elif WIDTH == 64 83 #define DFP_C_TYPE _Decimal64 84 #define IEEE_TYPE decimal64 85 #define HOST_TO_IEEE __host_to_ieee_64 86 #define IEEE_TO_HOST __ieee_to_host_64 87 #define TO_INTERNAL __decimal64ToNumber 88 #define TO_ENCODED __decimal64FromNumber 89 #define FROM_STRING __decimal64FromString 90 #define TO_STRING __decimal64ToString 91 #elif WIDTH == 128 92 #define DFP_C_TYPE _Decimal128 93 #define IEEE_TYPE decimal128 94 #define HOST_TO_IEEE __host_to_ieee_128 95 #define IEEE_TO_HOST __ieee_to_host_128 96 #define TO_INTERNAL __decimal128ToNumber 97 #define TO_ENCODED __decimal128FromNumber 98 #define FROM_STRING __decimal128FromString 99 #define TO_STRING __decimal128ToString 100 #else 101 #error invalid decimal float word width 102 #endif 103 104 /* We define __DEC_EVAL_METHOD__ to 2, saying that we evaluate all 105 operations and constants to the range and precision of the _Decimal128 106 type. Make it so. */ 107 #if WIDTH == 32 108 #define CONTEXT_INIT DEC_INIT_DECIMAL32 109 #elif WIDTH == 64 110 #define CONTEXT_INIT DEC_INIT_DECIMAL64 111 #elif WIDTH == 128 112 #define CONTEXT_INIT DEC_INIT_DECIMAL128 113 #endif 114 115 #ifndef DFP_INIT_ROUNDMODE 116 #define DFP_INIT_ROUNDMODE(A) A = DEC_ROUND_HALF_EVEN 117 #endif 118 119 #ifdef DFP_EXCEPTIONS_ENABLED 120 /* Return IEEE exception flags based on decNumber status flags. */ 121 #define DFP_IEEE_FLAGS(DEC_FLAGS) __extension__ \ 122 ({int _fe_flags = 0; \ 123 if ((dec_flags & DEC_IEEE_854_Division_by_zero) != 0) \ 124 _fe_flags |= FE_DIVBYZERO; \ 125 if ((dec_flags & DEC_IEEE_854_Inexact) != 0) \ 126 _fe_flags |= FE_INEXACT; \ 127 if ((dec_flags & DEC_IEEE_854_Invalid_operation) != 0) \ 128 _fe_flags |= FE_INVALID; \ 129 if ((dec_flags & DEC_IEEE_854_Overflow) != 0) \ 130 _fe_flags |= FE_OVERFLOW; \ 131 if ((dec_flags & DEC_IEEE_854_Underflow) != 0) \ 132 _fe_flags |= FE_UNDERFLOW; \ 133 _fe_flags; }) 134 #else 135 #define DFP_EXCEPTIONS_ENABLED 0 136 #define DFP_IEEE_FLAGS(A) 0 137 #define DFP_HANDLE_EXCEPTIONS(A) do {} while (0) 138 #endif 139 140 /* Conversions between different decimal float types use WIDTH_TO to 141 determine additional macros to define. */ 142 143 #if defined (L_dd_to_sd) || defined (L_td_to_sd) 144 #define WIDTH_TO 32 145 #elif defined (L_sd_to_dd) || defined (L_td_to_dd) 146 #define WIDTH_TO 64 147 #elif defined (L_sd_to_td) || defined (L_dd_to_td) 148 #define WIDTH_TO 128 149 #endif 150 151 /* If WIDTH_TO is defined, define additional macros: 152 153 DFP_C_TYPE_TO: type of the result of dfp to dfp conversion. 154 155 IEEE_TYPE_TO: the corresponding (encoded) IEEE754 type. 156 157 TO_ENCODED_TO: the name of the decNumber function to convert an 158 internally represented decNumber into the encoded representation 159 for the destination. */ 160 161 #if WIDTH_TO == 32 162 #define DFP_C_TYPE_TO _Decimal32 163 #define IEEE_TYPE_TO decimal32 164 #define TO_ENCODED_TO __decimal32FromNumber 165 #define IEEE_TO_HOST_TO __ieee_to_host_32 166 #elif WIDTH_TO == 64 167 #define DFP_C_TYPE_TO _Decimal64 168 #define IEEE_TYPE_TO decimal64 169 #define TO_ENCODED_TO __decimal64FromNumber 170 #define IEEE_TO_HOST_TO __ieee_to_host_64 171 #elif WIDTH_TO == 128 172 #define DFP_C_TYPE_TO _Decimal128 173 #define IEEE_TYPE_TO decimal128 174 #define TO_ENCODED_TO __decimal128FromNumber 175 #define IEEE_TO_HOST_TO __ieee_to_host_128 176 #endif 177 178 /* Conversions between decimal float types and integral types use INT_KIND 179 to determine the data type and C functions to use. */ 180 181 #if defined (L_sd_to_si) || defined (L_dd_to_si) || defined (L_td_to_si) \ 182 || defined (L_si_to_sd) || defined (L_si_to_dd) || defined (L_si_to_td) 183 #define INT_KIND 1 184 #elif defined (L_sd_to_di) || defined (L_dd_to_di) || defined (L_td_to_di) \ 185 || defined (L_di_to_sd) || defined (L_di_to_dd) || defined (L_di_to_td) 186 #define INT_KIND 2 187 #elif defined (L_sd_to_usi) || defined (L_dd_to_usi) || defined (L_td_to_usi) \ 188 || defined (L_usi_to_sd) || defined (L_usi_to_dd) || defined (L_usi_to_td) 189 #define INT_KIND 3 190 #elif defined (L_sd_to_udi) || defined (L_dd_to_udi) || defined (L_td_to_udi) \ 191 || defined (L_udi_to_sd) || defined (L_udi_to_dd) || defined (L_udi_to_td) 192 #define INT_KIND 4 193 #endif 194 195 /* If INT_KIND is defined, define additional macros: 196 197 INT_TYPE: The integer data type. 198 199 INT_FMT: The format string for writing the integer to a string. 200 201 CAST_FOR_FMT: Cast variable of INT_KIND to C type for sprintf. 202 This works for ILP32 and LP64, won't for other type size systems. 203 204 STR_TO_INT: The function to read the integer from a string. */ 205 206 #if INT_KIND == 1 207 #define INT_TYPE SItype 208 #define INT_FMT "%d" 209 #define CAST_FOR_FMT(A) (int)A 210 #define STR_TO_INT strtol 211 #elif INT_KIND == 2 212 #define INT_TYPE DItype 213 #define INT_FMT "%lld" 214 #define CAST_FOR_FMT(A) (long long)A 215 #define STR_TO_INT strtoll 216 #elif INT_KIND == 3 217 #define INT_TYPE USItype 218 #define INT_FMT "%u" 219 #define CAST_FOR_FMT(A) (unsigned int)A 220 #define STR_TO_INT strtoul 221 #elif INT_KIND == 4 222 #define INT_TYPE UDItype 223 #define INT_FMT "%llu" 224 #define CAST_FOR_FMT(A) (unsigned long long)A 225 #define STR_TO_INT strtoull 226 #endif 227 228 /* Conversions between decimal float types and binary float types use 229 BFP_KIND to determine the data type and C functions to use. */ 230 231 #if defined (L_sd_to_sf) || defined (L_dd_to_sf) || defined (L_td_to_sf) \ 232 || defined (L_sf_to_sd) || defined (L_sf_to_dd) || defined (L_sf_to_td) 233 #define BFP_KIND 1 234 #elif defined (L_sd_to_df) || defined (L_dd_to_df ) || defined (L_td_to_df) \ 235 || defined (L_df_to_sd) || defined (L_df_to_dd) || defined (L_df_to_td) 236 #define BFP_KIND 2 237 #elif defined (L_sd_to_xf) || defined (L_dd_to_xf ) || defined (L_td_to_xf) \ 238 || defined (L_xf_to_sd) || defined (L_xf_to_dd) || defined (L_xf_to_td) 239 #define BFP_KIND 3 240 #elif defined (L_sd_to_tf) || defined (L_dd_to_tf) || defined (L_td_to_tf) \ 241 || defined (L_tf_to_sd) || defined (L_tf_to_dd) || defined (L_tf_to_td) 242 #define BFP_KIND 4 243 #endif 244 245 /* If BFP_KIND is defined, define additional macros: 246 247 BFP_TYPE: The binary floating point data type. 248 249 BFP_FMT: The format string for writing the value to a string. 250 The number of decimal digits printed is 251 ceil (nbits / log2 (10.) + 1) 252 as described in David Matula's CACM 19(3) 716-723 June 1968 paper. 253 254 BFP_VIA_TYPE: Type to which to cast a variable of BPF_TYPE for a 255 call to sprintf. 256 257 STR_TO_BFP: The function to read the value from a string. */ 258 259 #if BFP_KIND == 1 260 #define BFP_TYPE SFtype 261 #define BFP_FMT "%.9e" 262 #define BFP_VIA_TYPE double 263 #define STR_TO_BFP strtof 264 265 #elif BFP_KIND == 2 266 #define BFP_TYPE DFtype 267 #define BFP_FMT "%.17e" 268 #define BFP_VIA_TYPE double 269 #define STR_TO_BFP strtod 270 271 #elif BFP_KIND == 3 272 #if LONG_DOUBLE_HAS_XF_MODE 273 #define BFP_TYPE XFtype 274 #define BFP_FMT "%.21Le" 275 #define BFP_VIA_TYPE long double 276 #define STR_TO_BFP strtold 277 #endif /* LONG_DOUBLE_HAS_XF_MODE */ 278 279 #elif BFP_KIND == 4 280 #if LONG_DOUBLE_HAS_TF_MODE 281 #define BFP_TYPE TFtype 282 #if LDBL_MANT_DIG == 106 283 #define BFP_FMT "%.33Le" 284 #elif LDBL_MANT_DIG == 113 285 #define BFP_FMT "%.36Le" 286 #else 287 #error "unknown long double size, cannot define BFP_FMT" 288 #endif /* LDBL_MANT_DIG */ 289 #define STR_TO_BFP strtold 290 #define BFP_VIA_TYPE long double 291 #endif /* LONG_DOUBLE_HAS_TF_MODE */ 292 293 #endif /* BFP_KIND */ 294 295 #if WIDTH == 128 || WIDTH_TO == 128 296 #include "decimal128.h" 297 #include "decQuad.h" 298 #endif 299 #if WIDTH == 64 || WIDTH_TO == 64 300 #include "decimal64.h" 301 #include "decDouble.h" 302 #endif 303 #if WIDTH == 32 || WIDTH_TO == 32 304 #include "decimal32.h" 305 #include "decSingle.h" 306 #endif 307 #include "decNumber.h" 308 309 /* Names of arithmetic functions. */ 310 311 #if ENABLE_DECIMAL_BID_FORMAT 312 #define DPD_BID_NAME(DPD,BID) BID 313 #else 314 #define DPD_BID_NAME(DPD,BID) DPD 315 #endif 316 317 #if WIDTH == 32 318 #define DFP_ADD DPD_BID_NAME(__dpd_addsd3,__bid_addsd3) 319 #define DFP_SUB DPD_BID_NAME(__dpd_subsd3,__bid_subsd3) 320 #define DFP_MULTIPLY DPD_BID_NAME(__dpd_mulsd3,__bid_mulsd3) 321 #define DFP_DIVIDE DPD_BID_NAME(__dpd_divsd3,__bid_divsd3) 322 #define DFP_EQ DPD_BID_NAME(__dpd_eqsd2,__bid_eqsd2) 323 #define DFP_NE DPD_BID_NAME(__dpd_nesd2,__bid_nesd2) 324 #define DFP_LT DPD_BID_NAME(__dpd_ltsd2,__bid_ltsd2) 325 #define DFP_GT DPD_BID_NAME(__dpd_gtsd2,__bid_gtsd2) 326 #define DFP_LE DPD_BID_NAME(__dpd_lesd2,__bid_lesd2) 327 #define DFP_GE DPD_BID_NAME(__dpd_gesd2,__bid_gesd2) 328 #define DFP_UNORD DPD_BID_NAME(__dpd_unordsd2,__bid_unordsd2) 329 #elif WIDTH == 64 330 #define DFP_ADD DPD_BID_NAME(__dpd_adddd3,__bid_adddd3) 331 #define DFP_SUB DPD_BID_NAME(__dpd_subdd3,__bid_subdd3) 332 #define DFP_MULTIPLY DPD_BID_NAME(__dpd_muldd3,__bid_muldd3) 333 #define DFP_DIVIDE DPD_BID_NAME(__dpd_divdd3,__bid_divdd3) 334 #define DFP_EQ DPD_BID_NAME(__dpd_eqdd2,__bid_eqdd2) 335 #define DFP_NE DPD_BID_NAME(__dpd_nedd2,__bid_nedd2) 336 #define DFP_LT DPD_BID_NAME(__dpd_ltdd2,__bid_ltdd2) 337 #define DFP_GT DPD_BID_NAME(__dpd_gtdd2,__bid_gtdd2) 338 #define DFP_LE DPD_BID_NAME(__dpd_ledd2,__bid_ledd2) 339 #define DFP_GE DPD_BID_NAME(__dpd_gedd2,__bid_gedd2) 340 #define DFP_UNORD DPD_BID_NAME(__dpd_unorddd2,__bid_unorddd2) 341 #elif WIDTH == 128 342 #define DFP_ADD DPD_BID_NAME(__dpd_addtd3,__bid_addtd3) 343 #define DFP_SUB DPD_BID_NAME(__dpd_subtd3,__bid_subtd3) 344 #define DFP_MULTIPLY DPD_BID_NAME(__dpd_multd3,__bid_multd3) 345 #define DFP_DIVIDE DPD_BID_NAME(__dpd_divtd3,__bid_divtd3) 346 #define DFP_EQ DPD_BID_NAME(__dpd_eqtd2,__bid_eqtd2) 347 #define DFP_NE DPD_BID_NAME(__dpd_netd2,__bid_netd2) 348 #define DFP_LT DPD_BID_NAME(__dpd_lttd2,__bid_lttd2) 349 #define DFP_GT DPD_BID_NAME(__dpd_gttd2,__bid_gttd2) 350 #define DFP_LE DPD_BID_NAME(__dpd_letd2,__bid_letd2) 351 #define DFP_GE DPD_BID_NAME(__dpd_getd2,__bid_getd2) 352 #define DFP_UNORD DPD_BID_NAME(__dpd_unordtd2,__bid_unordtd2) 353 #endif 354 355 /* Names of decNumber functions for DPD arithmetic. */ 356 357 #if WIDTH == 32 358 #define decFloat decDouble 359 #define DFP_BINARY_OP d32_binary_op 360 #define DFP_COMPARE_OP d32_compare_op 361 #define DEC_FLOAT_ADD decDoubleAdd 362 #define DEC_FLOAT_SUBTRACT decDoubleSubtract 363 #define DEC_FLOAT_MULTIPLY decDoubleMultiply 364 #define DEC_FLOAT_DIVIDE decDoubleDivide 365 #define DEC_FLOAT_COMPARE decDoubleCompare 366 #define DEC_FLOAT_IS_ZERO decDoubleIsZero 367 #define DEC_FLOAT_IS_NAN decDoubleIsNaN 368 #define DEC_FLOAT_IS_SIGNED decDoubleIsSigned 369 #elif WIDTH == 64 370 #define DFP_BINARY_OP dnn_binary_op 371 #define DFP_COMPARE_OP dnn_compare_op 372 #define decFloat decDouble 373 #define DEC_FLOAT_ADD decDoubleAdd 374 #define DEC_FLOAT_SUBTRACT decDoubleSubtract 375 #define DEC_FLOAT_MULTIPLY decDoubleMultiply 376 #define DEC_FLOAT_DIVIDE decDoubleDivide 377 #define DEC_FLOAT_COMPARE decDoubleCompare 378 #define DEC_FLOAT_IS_ZERO decDoubleIsZero 379 #define DEC_FLOAT_IS_NAN decDoubleIsNaN 380 #define DEC_FLOAT_IS_SIGNED decDoubleIsSigned 381 #elif WIDTH == 128 382 #define DFP_BINARY_OP dnn_binary_op 383 #define DFP_COMPARE_OP dnn_compare_op 384 #define decFloat decQuad 385 #define DEC_FLOAT_ADD decQuadAdd 386 #define DEC_FLOAT_SUBTRACT decQuadSubtract 387 #define DEC_FLOAT_MULTIPLY decQuadMultiply 388 #define DEC_FLOAT_DIVIDE decQuadDivide 389 #define DEC_FLOAT_COMPARE decQuadCompare 390 #define DEC_FLOAT_IS_ZERO decQuadIsZero 391 #define DEC_FLOAT_IS_NAN decQuadIsNaN 392 #define DEC_FLOAT_IS_SIGNED decQuadIsSigned 393 #endif 394 395 /* Names of functions to convert between different decimal float types. */ 396 397 #if WIDTH == 32 398 #if WIDTH_TO == 64 399 #define DFP_TO_DFP DPD_BID_NAME(__dpd_extendsddd2,__bid_extendsddd2) 400 #elif WIDTH_TO == 128 401 #define DFP_TO_DFP DPD_BID_NAME(__dpd_extendsdtd2,__bid_extendsdtd2) 402 #endif 403 #elif WIDTH == 64 404 #if WIDTH_TO == 32 405 #define DFP_TO_DFP DPD_BID_NAME(__dpd_truncddsd2,__bid_truncddsd2) 406 #elif WIDTH_TO == 128 407 #define DFP_TO_DFP DPD_BID_NAME(__dpd_extendddtd2,__bid_extendddtd2) 408 #endif 409 #elif WIDTH == 128 410 #if WIDTH_TO == 32 411 #define DFP_TO_DFP DPD_BID_NAME(__dpd_trunctdsd2,__bid_trunctdsd2) 412 #elif WIDTH_TO == 64 413 #define DFP_TO_DFP DPD_BID_NAME(__dpd_trunctddd2,__bid_trunctddd2) 414 #endif 415 #endif 416 417 /* Names of functions to convert between decimal float and integers. */ 418 419 #if WIDTH == 32 420 #if INT_KIND == 1 421 #define INT_TO_DFP DPD_BID_NAME(__dpd_floatsisd,__bid_floatsisd) 422 #define DFP_TO_INT DPD_BID_NAME(__dpd_fixsdsi,__bid_fixsdsi) 423 #define DEC_FLOAT_FROM_INT decDoubleFromInt32 424 #define DEC_FLOAT_TO_INT decDoubleToInt32 425 #elif INT_KIND == 2 426 #define INT_TO_DFP DPD_BID_NAME(__dpd_floatdisd,__bid_floatdisd) 427 #define DFP_TO_INT DPD_BID_NAME(__dpd_fixsddi,__bid_fixsddi) 428 #elif INT_KIND == 3 429 #define INT_TO_DFP DPD_BID_NAME(__dpd_floatunssisd,__bid_floatunssisd) 430 #define DFP_TO_INT DPD_BID_NAME(__dpd_fixunssdsi,__bid_fixunssdsi) 431 #define DEC_FLOAT_FROM_INT decDoubleFromUInt32 432 #define DEC_FLOAT_TO_INT decDoubleToUInt32 433 #elif INT_KIND == 4 434 #define INT_TO_DFP DPD_BID_NAME(__dpd_floatunsdisd,__bid_floatunsdisd) 435 #define DFP_TO_INT DPD_BID_NAME(__dpd_fixunssddi,__bid_fixunssddi) 436 #endif 437 #elif WIDTH == 64 438 #define decFloat decDouble 439 #if INT_KIND == 1 440 #define INT_TO_DFP DPD_BID_NAME(__dpd_floatsidd,__bid_floatsidd) 441 #define DFP_TO_INT DPD_BID_NAME(__dpd_fixddsi,__bid_fixddsi) 442 #define DEC_FLOAT_FROM_INT decDoubleFromInt32 443 #define DEC_FLOAT_TO_INT decDoubleToInt32 444 #elif INT_KIND == 2 445 #define INT_TO_DFP DPD_BID_NAME(__dpd_floatdidd,__bid_floatdidd) 446 #define DFP_TO_INT DPD_BID_NAME(__dpd_fixdddi,__bid_fixdddi) 447 #elif INT_KIND == 3 448 #define INT_TO_DFP DPD_BID_NAME(__dpd_floatunssidd,__bid_floatunssidd) 449 #define DFP_TO_INT DPD_BID_NAME(__dpd_fixunsddsi,__bid_fixunsddsi) 450 #define DEC_FLOAT_FROM_INT decDoubleFromUInt32 451 #define DEC_FLOAT_TO_INT decDoubleToUInt32 452 #elif INT_KIND == 4 453 #define INT_TO_DFP DPD_BID_NAME(__dpd_floatunsdidd,__bid_floatunsdidd) 454 #define DFP_TO_INT DPD_BID_NAME(__dpd_fixunsdddi,__bid_fixunsdddi) 455 #endif 456 #elif WIDTH == 128 457 #define decFloat decQuad 458 #if INT_KIND == 1 459 #define INT_TO_DFP DPD_BID_NAME(__dpd_floatsitd,__bid_floatsitd) 460 #define DFP_TO_INT DPD_BID_NAME(__dpd_fixtdsi,__bid_fixtdsi) 461 #define DEC_FLOAT_FROM_INT decQuadFromInt32 462 #define DEC_FLOAT_TO_INT decQuadToInt32 463 #elif INT_KIND == 2 464 #define INT_TO_DFP DPD_BID_NAME(__dpd_floatditd,__bid_floatditd) 465 #define DFP_TO_INT DPD_BID_NAME(__dpd_fixtddi,__bid_fixtddi) 466 #elif INT_KIND == 3 467 #define INT_TO_DFP DPD_BID_NAME(__dpd_floatunssitd,__bid_floatunssitd) 468 #define DFP_TO_INT DPD_BID_NAME(__dpd_fixunstdsi,__bid_fixunstdsi) 469 #define DEC_FLOAT_FROM_INT decQuadFromUInt32 470 #define DEC_FLOAT_TO_INT decQuadToUInt32 471 #elif INT_KIND == 4 472 #define INT_TO_DFP DPD_BID_NAME(__dpd_floatunsditd,__bid_floatunsditd) 473 #define DFP_TO_INT DPD_BID_NAME(__dpd_fixunstddi,__bid_fixunstddi) 474 #endif 475 #endif 476 477 /* Names of functions to convert between decimal float and binary float. */ 478 479 #if WIDTH == 32 480 #if BFP_KIND == 1 481 #define BFP_TO_DFP DPD_BID_NAME(__dpd_extendsfsd,__bid_extendsfsd) 482 #define DFP_TO_BFP DPD_BID_NAME(__dpd_truncsdsf,__bid_truncsdsf) 483 #elif BFP_KIND == 2 484 #define BFP_TO_DFP DPD_BID_NAME(__dpd_truncdfsd,__bid_truncdfsd) 485 #define DFP_TO_BFP DPD_BID_NAME(__dpd_extendsddf,__bid_extendsddf) 486 #elif BFP_KIND == 3 487 #define BFP_TO_DFP DPD_BID_NAME(__dpd_truncxfsd,__bid_truncxfsd) 488 #define DFP_TO_BFP DPD_BID_NAME(__dpd_extendsdxf,__bid_extendsdxf) 489 #elif BFP_KIND == 4 490 #define BFP_TO_DFP DPD_BID_NAME(__dpd_trunctfsd,__bid_trunctfsd) 491 #define DFP_TO_BFP DPD_BID_NAME(__dpd_extendsdtf,__bid_extendsdtf) 492 #endif /* BFP_KIND */ 493 494 #elif WIDTH == 64 495 #if BFP_KIND == 1 496 #define BFP_TO_DFP DPD_BID_NAME(__dpd_extendsfdd,__bid_extendsfdd) 497 #define DFP_TO_BFP DPD_BID_NAME(__dpd_truncddsf,__bid_truncddsf) 498 #elif BFP_KIND == 2 499 #define BFP_TO_DFP DPD_BID_NAME(__dpd_extenddfdd,__bid_extenddfdd) 500 #define DFP_TO_BFP DPD_BID_NAME(__dpd_truncdddf,__bid_truncdddf) 501 #elif BFP_KIND == 3 502 #define BFP_TO_DFP DPD_BID_NAME(__dpd_truncxfdd,__bid_truncxfdd) 503 #define DFP_TO_BFP DPD_BID_NAME(__dpd_extendddxf,__bid_extendddxf) 504 #elif BFP_KIND == 4 505 #define BFP_TO_DFP DPD_BID_NAME(__dpd_trunctfdd,__bid_trunctfdd) 506 #define DFP_TO_BFP DPD_BID_NAME(__dpd_extendddtf,__bid_extendddtf) 507 #endif /* BFP_KIND */ 508 509 #elif WIDTH == 128 510 #if BFP_KIND == 1 511 #define BFP_TO_DFP DPD_BID_NAME(__dpd_extendsftd,__bid_extendsftd) 512 #define DFP_TO_BFP DPD_BID_NAME(__dpd_trunctdsf,__bid_trunctdsf) 513 #elif BFP_KIND == 2 514 #define BFP_TO_DFP DPD_BID_NAME(__dpd_extenddftd,__bid_extenddftd) 515 #define DFP_TO_BFP DPD_BID_NAME(__dpd_trunctddf,__bid_trunctddf) 516 #elif BFP_KIND == 3 517 #define BFP_TO_DFP DPD_BID_NAME(__dpd_extendxftd,__bid_extendxftd) 518 #define DFP_TO_BFP DPD_BID_NAME(__dpd_trunctdxf,__bid_trunctdxf) 519 #elif BFP_KIND == 4 520 #define BFP_TO_DFP DPD_BID_NAME(__dpd_extendtftd,__bid_extendtftd) 521 #define DFP_TO_BFP DPD_BID_NAME(__dpd_trunctdtf,__bid_trunctdtf) 522 #endif /* BFP_KIND */ 523 524 #endif /* WIDTH */ 525 526 /* Some handy typedefs. */ 527 528 typedef float SFtype __attribute__ ((mode (SF))); 529 typedef float DFtype __attribute__ ((mode (DF))); 530 #if LONG_DOUBLE_HAS_XF_MODE 531 typedef float XFtype __attribute__ ((mode (XF))); 532 #endif /* LONG_DOUBLE_HAS_XF_MODE */ 533 #if LONG_DOUBLE_HAS_TF_MODE 534 typedef float TFtype __attribute__ ((mode (TF))); 535 #endif /* LONG_DOUBLE_HAS_TF_MODE */ 536 537 typedef int SItype __attribute__ ((mode (SI))); 538 typedef int DItype __attribute__ ((mode (DI))); 539 typedef unsigned int USItype __attribute__ ((mode (SI))); 540 typedef unsigned int UDItype __attribute__ ((mode (DI))); 541 542 /* The type of the result of a decimal float comparison. This must 543 match `__libgcc_cmp_return__' in GCC for the target. */ 544 545 typedef int CMPtype __attribute__ ((mode (__libgcc_cmp_return__))); 546 547 /* Prototypes. */ 548 549 #if defined (L_mul_sd) || defined (L_mul_dd) || defined (L_mul_td) 550 extern DFP_C_TYPE DFP_MULTIPLY (DFP_C_TYPE, DFP_C_TYPE); 551 #endif 552 553 #if defined (L_div_sd) || defined (L_div_dd) || defined (L_div_td) 554 extern DFP_C_TYPE DFP_DIVIDE (DFP_C_TYPE, DFP_C_TYPE); 555 #endif 556 557 #if defined (L_addsub_sd) || defined (L_addsub_dd) || defined (L_addsub_td) 558 extern DFP_C_TYPE DFP_ADD (DFP_C_TYPE, DFP_C_TYPE); 559 extern DFP_C_TYPE DFP_SUB (DFP_C_TYPE, DFP_C_TYPE); 560 #endif 561 562 #if defined (L_eq_sd) || defined (L_eq_dd) || defined (L_eq_td) 563 extern CMPtype DFP_EQ (DFP_C_TYPE, DFP_C_TYPE); 564 #endif 565 566 #if defined (L_ne_sd) || defined (L_ne_dd) || defined (L_ne_td) 567 extern CMPtype DFP_NE (DFP_C_TYPE, DFP_C_TYPE); 568 #endif 569 570 #if defined (L_lt_sd) || defined (L_lt_dd) || defined (L_lt_td) 571 extern CMPtype DFP_LT (DFP_C_TYPE, DFP_C_TYPE); 572 #endif 573 574 #if defined (L_gt_sd) || defined (L_gt_dd) || defined (L_gt_td) 575 extern CMPtype DFP_GT (DFP_C_TYPE, DFP_C_TYPE); 576 #endif 577 578 #if defined (L_le_sd) || defined (L_le_dd) || defined (L_le_td) 579 extern CMPtype DFP_LE (DFP_C_TYPE, DFP_C_TYPE); 580 #endif 581 582 #if defined (L_ge_sd) || defined (L_ge_dd) || defined (L_ge_td) 583 extern CMPtype DFP_GE (DFP_C_TYPE, DFP_C_TYPE); 584 #endif 585 586 #if defined (L_unord_sd) || defined (L_unord_dd) || defined (L_unord_td) 587 extern CMPtype DFP_UNORD (DFP_C_TYPE, DFP_C_TYPE); 588 #endif 589 590 #if defined (L_sd_to_dd) || defined (L_sd_to_td) || defined (L_dd_to_sd) \ 591 || defined (L_dd_to_td) || defined (L_td_to_sd) || defined (L_td_to_dd) 592 extern DFP_C_TYPE_TO DFP_TO_DFP (DFP_C_TYPE); 593 #endif 594 595 #if defined (L_sd_to_si) || defined (L_dd_to_si) || defined (L_td_to_si) \ 596 || defined (L_sd_to_di) || defined (L_dd_to_di) || defined (L_td_to_di) \ 597 || defined (L_sd_to_usi) || defined (L_dd_to_usi) || defined (L_td_to_usi) \ 598 || defined (L_sd_to_udi) || defined (L_dd_to_udi) || defined (L_td_to_udi) 599 extern INT_TYPE DFP_TO_INT (DFP_C_TYPE); 600 #endif 601 602 #if defined (L_si_to_sd) || defined (L_si_to_dd) || defined (L_si_to_td) \ 603 || defined (L_di_to_sd) || defined (L_di_to_dd) || defined (L_di_to_td) \ 604 || defined (L_usi_to_sd) || defined (L_usi_to_dd) || defined (L_usi_to_td) \ 605 || defined (L_udi_to_sd) || defined (L_udi_to_dd) || defined (L_udi_to_td) 606 extern DFP_C_TYPE INT_TO_DFP (INT_TYPE); 607 #endif 608 609 #if defined (L_sd_to_sf) || defined (L_dd_to_sf) || defined (L_td_to_sf) \ 610 || defined (L_sd_to_df) || defined (L_dd_to_df) || defined (L_td_to_df) \ 611 || ((defined (L_sd_to_xf) || defined (L_dd_to_xf) || defined (L_td_to_xf)) \ 612 && LONG_DOUBLE_HAS_XF_MODE) \ 613 || ((defined (L_sd_to_tf) || defined (L_dd_to_tf) || defined (L_td_to_tf)) \ 614 && LONG_DOUBLE_HAS_TF_MODE) 615 extern BFP_TYPE DFP_TO_BFP (DFP_C_TYPE); 616 #endif 617 618 #if defined (L_sf_to_sd) || defined (L_sf_to_dd) || defined (L_sf_to_td) \ 619 || defined (L_df_to_sd) || defined (L_df_to_dd) || defined (L_df_to_td) \ 620 || ((defined (L_xf_to_sd) || defined (L_xf_to_dd) || defined (L_xf_to_td)) \ 621 && LONG_DOUBLE_HAS_XF_MODE) \ 622 || ((defined (L_tf_to_sd) || defined (L_tf_to_dd) || defined (L_tf_to_td)) \ 623 && LONG_DOUBLE_HAS_TF_MODE) 624 extern DFP_C_TYPE BFP_TO_DFP (BFP_TYPE); 625 #endif 626 627 #endif /* _DFPBIT_H */ 628