bid_gcc_intrinsics.h 8.4 KB

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