]> git.ipfire.org Git - thirdparty/gcc.git/blob - libgcc/config/libbid/bid128_2_str_macros.h
Merged with libbbid branch at revision 126349.
[thirdparty/gcc.git] / libgcc / config / libbid / bid128_2_str_macros.h
1 /* Copyright (C) 2007 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 2, or (at your option) any later
8 version.
9
10 In addition to the permissions in the GNU General Public License, the
11 Free Software Foundation gives you unlimited permission to link the
12 compiled version of this file into combinations with other programs,
13 and to distribute those combinations without any restriction coming
14 from the use of this file. (The General Public License restrictions
15 do apply in other respects; for example, they cover modification of
16 the file, and distribution when not linked into a combine
17 executable.)
18
19 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
20 WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with GCC; see the file COPYING. If not, write to the Free
26 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
27 02110-1301, USA. */
28
29 #define __L0_Normalize_10to18( X_hi, X_lo ) \
30 { \
31 UINT64 L0_tmp; \
32 L0_tmp = (X_lo) + __bid_Twoto60_m_10to18; \
33 if (L0_tmp & __bid_Twoto60) \
34 {(X_hi)=(X_hi)+1;(X_lo)=((L0_tmp<<4)>>4);} \
35 }
36
37
38 #define __L0_Normalize_10to9( X_hi, X_lo ) \
39 { \
40 UINT32 L0_tmp; \
41 L0_tmp = (X_lo) + __bid_Twoto30_m_10to9; \
42 if (L0_tmp & 0x40000000) \
43 {(X_hi)=(X_hi)+1;(X_lo)=((L0_tmp<<2)>>2);} \
44 }
45
46
47 #define __L0_Split_MiDi_2( X, ptr ) \
48 { \
49 UINT32 L0_head, L0_tail, L0_tmp; \
50 L0_head = (X) >> 10; \
51 L0_tail = ((X)&(0x03FF))+(L0_head<<5)-(L0_head<<3); \
52 L0_tmp = (L0_tail)>>10; L0_head += L0_tmp; \
53 L0_tail = (L0_tail&(0x03FF))+(L0_tmp<<5)-(L0_tmp<<3); \
54 if (L0_tail > 999){L0_tail -= 1000; L0_head += 1;} \
55 *((ptr)++) = L0_head; *((ptr)++) = L0_tail; \
56 }
57
58
59 #define __L0_Split_MiDi_3( X, ptr ) \
60 { \
61 UINT32 L0_X, L0_head, L0_mid, L0_tail, L0_tmp; \
62 L0_X = (UINT32)((X)); \
63 L0_head = ((L0_X>>17)*34359)>>18; \
64 L0_X -= L0_head*1000000; \
65 if (L0_X >= 1000000){L0_X -= 1000000;L0_head+=1;} \
66 L0_mid = L0_X >> 10; \
67 L0_tail = (L0_X & (0x03FF))+(L0_mid<<5)-(L0_mid<<3); \
68 L0_tmp = (L0_tail)>>10; L0_mid += L0_tmp; \
69 L0_tail = (L0_tail&(0x3FF))+(L0_tmp<<5)-(L0_tmp<<3); \
70 if (L0_tail>999){L0_tail-=1000;L0_mid+=1;} \
71 *((ptr)++)=L0_head;*((ptr)++)=L0_mid; \
72 *((ptr)++)=L0_tail; \
73 }
74
75 #define __L1_Split_MiDi_6( X, ptr ) \
76 { \
77 UINT32 L1_X_hi, L1_X_lo; \
78 UINT64 L1_Xhi_64, L1_Xlo_64; \
79 L1_Xhi_64 = ( ((X)>>28)*__bid_Inv_Tento9 ) >> 33; \
80 L1_Xlo_64 = (X) - L1_Xhi_64*(UINT64)__bid_Tento9; \
81 if (L1_Xlo_64 >= (UINT64)__bid_Tento9) \
82 {L1_Xlo_64-=(UINT64)__bid_Tento9;L1_Xhi_64+=1;} \
83 L1_X_hi=(UINT32)L1_Xhi_64; L1_X_lo=(UINT32)L1_Xlo_64; \
84 __L0_Split_MiDi_3(L1_X_hi,(ptr)); \
85 __L0_Split_MiDi_3(L1_X_lo,(ptr)); \
86 }
87
88 #define __L1_Split_MiDi_6_Lead( X, ptr ) \
89 { \
90 UINT32 L1_X_hi, L1_X_lo; \
91 UINT64 L1_Xhi_64, L1_Xlo_64; \
92 if ((X)>=(UINT64)__bid_Tento9){ \
93 L1_Xhi_64 = ( ((X)>>28)*__bid_Inv_Tento9 ) >> 33; \
94 L1_Xlo_64 = (X) - L1_Xhi_64*(UINT64)__bid_Tento9; \
95 if (L1_Xlo_64 >= (UINT64)__bid_Tento9) \
96 {L1_Xlo_64-=(UINT64)__bid_Tento9;L1_Xhi_64+=1;} \
97 L1_X_hi=(UINT32)L1_Xhi_64; \
98 L1_X_lo=(UINT32)L1_Xlo_64; \
99 if (L1_X_hi>=__bid_Tento6){ \
100 __L0_Split_MiDi_3(L1_X_hi,(ptr)); \
101 __L0_Split_MiDi_3(L1_X_lo,(ptr)); \
102 } \
103 else if (L1_X_hi>=__bid_Tento3){ \
104 __L0_Split_MiDi_2(L1_X_hi,(ptr)); \
105 __L0_Split_MiDi_3(L1_X_lo,(ptr)); \
106 } \
107 else { \
108 *((ptr)++) = L1_X_hi; \
109 __L0_Split_MiDi_3(L1_X_lo,(ptr)); \
110 } \
111 } \
112 else { \
113 L1_X_lo = (UINT32)(X); \
114 if (L1_X_lo>=__bid_Tento6){ \
115 __L0_Split_MiDi_3(L1_X_lo,(ptr)); \
116 } \
117 else if (L1_X_lo>=__bid_Tento3){ \
118 __L0_Split_MiDi_2(L1_X_lo,(ptr)); \
119 } \
120 else { \
121 *((ptr)++) = L1_X_lo; \
122 } \
123 } \
124 }
125
126
127 #define __L0_MiDi2Str( X, c_ptr ) \
128 { \
129 char *L0_src; \
130 L0_src = __bid_midi_tbl[(X)]; \
131 *((c_ptr)++) = *(L0_src++); \
132 *((c_ptr)++) = *(L0_src++); \
133 *((c_ptr)++) = *(L0_src); \
134 }
135
136 #define __L0_MiDi2Str_Lead( X, c_ptr ) \
137 { \
138 char *L0_src; \
139 L0_src = __bid_midi_tbl[(X)]; \
140 if ((X)>=100){ \
141 *((c_ptr)++) = *(L0_src++); \
142 *((c_ptr)++) = *(L0_src++); \
143 *((c_ptr)++) = *(L0_src); \
144 } \
145 else if ((X)>=10){ \
146 L0_src++; \
147 *((c_ptr)++) = *(L0_src++); \
148 *((c_ptr)++) = *(L0_src); \
149 } \
150 else { \
151 L0_src++;L0_src++; \
152 *((c_ptr)++) = *(L0_src); \
153 } \
154 }