bid128_2_str_macros.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. #define __L0_Normalize_10to18( X_hi, X_lo ) \
  19. { \
  20. UINT64 L0_tmp; \
  21. L0_tmp = (X_lo) + Twoto60_m_10to18; \
  22. if (L0_tmp & Twoto60) \
  23. {(X_hi)=(X_hi)+1;(X_lo)=((L0_tmp<<4)>>4);} \
  24. }
  25. #define __L0_Normalize_10to9( X_hi, X_lo ) \
  26. { \
  27. UINT32 L0_tmp; \
  28. L0_tmp = (X_lo) + Twoto30_m_10to9; \
  29. if (L0_tmp & 0x40000000) \
  30. {(X_hi)=(X_hi)+1;(X_lo)=((L0_tmp<<2)>>2);} \
  31. }
  32. #define __L0_Split_MiDi_2( X, ptr ) \
  33. { \
  34. UINT32 L0_head, L0_tail, L0_tmp; \
  35. L0_head = (X) >> 10; \
  36. L0_tail = ((X)&(0x03FF))+(L0_head<<5)-(L0_head<<3); \
  37. L0_tmp = (L0_tail)>>10; L0_head += L0_tmp; \
  38. L0_tail = (L0_tail&(0x03FF))+(L0_tmp<<5)-(L0_tmp<<3); \
  39. if (L0_tail > 999){L0_tail -= 1000; L0_head += 1;} \
  40. *((ptr)++) = L0_head; *((ptr)++) = L0_tail; \
  41. }
  42. #define __L0_Split_MiDi_3( X, ptr ) \
  43. { \
  44. UINT32 L0_X, L0_head, L0_mid, L0_tail, L0_tmp; \
  45. L0_X = (UINT32)((X)); \
  46. L0_head = ((L0_X>>17)*34359)>>18; \
  47. L0_X -= L0_head*1000000; \
  48. if (L0_X >= 1000000){L0_X -= 1000000;L0_head+=1;} \
  49. L0_mid = L0_X >> 10; \
  50. L0_tail = (L0_X & (0x03FF))+(L0_mid<<5)-(L0_mid<<3); \
  51. L0_tmp = (L0_tail)>>10; L0_mid += L0_tmp; \
  52. L0_tail = (L0_tail&(0x3FF))+(L0_tmp<<5)-(L0_tmp<<3); \
  53. if (L0_tail>999){L0_tail-=1000;L0_mid+=1;} \
  54. *((ptr)++)=L0_head;*((ptr)++)=L0_mid; \
  55. *((ptr)++)=L0_tail; \
  56. }
  57. #define __L1_Split_MiDi_6( X, ptr ) \
  58. { \
  59. UINT32 L1_X_hi, L1_X_lo; \
  60. UINT64 L1_Xhi_64, L1_Xlo_64; \
  61. L1_Xhi_64 = ( ((X)>>28)*Inv_Tento9 ) >> 33; \
  62. L1_Xlo_64 = (X) - L1_Xhi_64*(UINT64)Tento9; \
  63. if (L1_Xlo_64 >= (UINT64)Tento9) \
  64. {L1_Xlo_64-=(UINT64)Tento9;L1_Xhi_64+=1;} \
  65. L1_X_hi=(UINT32)L1_Xhi_64; L1_X_lo=(UINT32)L1_Xlo_64; \
  66. __L0_Split_MiDi_3(L1_X_hi,(ptr)); \
  67. __L0_Split_MiDi_3(L1_X_lo,(ptr)); \
  68. }
  69. #define __L1_Split_MiDi_6_Lead( X, ptr ) \
  70. { \
  71. UINT32 L1_X_hi, L1_X_lo; \
  72. UINT64 L1_Xhi_64, L1_Xlo_64; \
  73. if ((X)>=(UINT64)Tento9){ \
  74. L1_Xhi_64 = ( ((X)>>28)*Inv_Tento9 ) >> 33; \
  75. L1_Xlo_64 = (X) - L1_Xhi_64*(UINT64)Tento9; \
  76. if (L1_Xlo_64 >= (UINT64)Tento9) \
  77. {L1_Xlo_64-=(UINT64)Tento9;L1_Xhi_64+=1;} \
  78. L1_X_hi=(UINT32)L1_Xhi_64; \
  79. L1_X_lo=(UINT32)L1_Xlo_64; \
  80. if (L1_X_hi>=Tento6){ \
  81. __L0_Split_MiDi_3(L1_X_hi,(ptr)); \
  82. __L0_Split_MiDi_3(L1_X_lo,(ptr)); \
  83. } \
  84. else if (L1_X_hi>=Tento3){ \
  85. __L0_Split_MiDi_2(L1_X_hi,(ptr)); \
  86. __L0_Split_MiDi_3(L1_X_lo,(ptr)); \
  87. } \
  88. else { \
  89. *((ptr)++) = L1_X_hi; \
  90. __L0_Split_MiDi_3(L1_X_lo,(ptr)); \
  91. } \
  92. } \
  93. else { \
  94. L1_X_lo = (UINT32)(X); \
  95. if (L1_X_lo>=Tento6){ \
  96. __L0_Split_MiDi_3(L1_X_lo,(ptr)); \
  97. } \
  98. else if (L1_X_lo>=Tento3){ \
  99. __L0_Split_MiDi_2(L1_X_lo,(ptr)); \
  100. } \
  101. else { \
  102. *((ptr)++) = L1_X_lo; \
  103. } \
  104. } \
  105. }
  106. #define __L0_MiDi2Str( X, c_ptr ) \
  107. { \
  108. char *L0_src; \
  109. L0_src = midi_tbl[(X)]; \
  110. *((c_ptr)++) = *(L0_src++); \
  111. *((c_ptr)++) = *(L0_src++); \
  112. *((c_ptr)++) = *(L0_src); \
  113. }
  114. #define __L0_MiDi2Str_Lead( X, c_ptr ) \
  115. { \
  116. char *L0_src; \
  117. L0_src = midi_tbl[(X)]; \
  118. if ((X)>=100){ \
  119. *((c_ptr)++) = *(L0_src++); \
  120. *((c_ptr)++) = *(L0_src++); \
  121. *((c_ptr)++) = *(L0_src); \
  122. } \
  123. else if ((X)>=10){ \
  124. L0_src++; \
  125. *((c_ptr)++) = *(L0_src++); \
  126. *((c_ptr)++) = *(L0_src); \
  127. } \
  128. else { \
  129. L0_src++;L0_src++; \
  130. *((c_ptr)++) = *(L0_src); \
  131. } \
  132. }