Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Semantics ops support for CGEN-based simulators. |
ecd75fc8 | 2 | Copyright (C) 1996-2014 Free Software Foundation, Inc. |
c906108c SS |
3 | Contributed by Cygnus Solutions. |
4 | ||
5 | This file is part of the GNU Simulators. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
4744ac1b JB |
9 | the Free Software Foundation; either version 3 of the License, or |
10 | (at your option) any later version. | |
c906108c SS |
11 | |
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
4744ac1b JB |
17 | You should have received a copy of the GNU General Public License |
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
c906108c SS |
19 | |
20 | */ | |
21 | ||
22 | #ifndef CGEN_SEM_OPS_H | |
23 | #define CGEN_SEM_OPS_H | |
24 | ||
4f49fa1b BE |
25 | #include <assert.h> |
26 | ||
7a292a7a SS |
27 | #if defined (__GNUC__) && ! defined (SEMOPS_DEFINE_INLINE) |
28 | #define SEMOPS_DEFINE_INLINE | |
29 | #define SEMOPS_INLINE extern inline | |
30 | #else | |
31 | #define SEMOPS_INLINE | |
32 | #endif | |
33 | ||
c906108c SS |
34 | /* Semantic operations. |
35 | At one point this file was machine generated. Maybe it will be again. */ | |
36 | ||
43ff13b4 JM |
37 | /* TODO: Lazy encoding/decoding of fp values. */ |
38 | ||
c906108c SS |
39 | /* These don't really have a mode. */ |
40 | #define ANDIF(x, y) ((x) && (y)) | |
41 | #define ORIF(x, y) ((x) || (y)) | |
42 | ||
4f49fa1b | 43 | #define SUBBI(x, y) ((x) - (y)) |
c906108c SS |
44 | #define ANDBI(x, y) ((x) & (y)) |
45 | #define ORBI(x, y) ((x) | (y)) | |
46 | #define XORBI(x, y) ((x) ^ (y)) | |
47 | #define NEGBI(x) (- (x)) | |
48 | #define NOTBI(x) (! (BI) (x)) | |
49 | #define INVBI(x) (~ (x)) | |
50 | #define EQBI(x, y) ((BI) (x) == (BI) (y)) | |
51 | #define NEBI(x, y) ((BI) (x) != (BI) (y)) | |
52 | #define LTBI(x, y) ((BI) (x) < (BI) (y)) | |
53 | #define LEBI(x, y) ((BI) (x) <= (BI) (y)) | |
54 | #define GTBI(x, y) ((BI) (x) > (BI) (y)) | |
55 | #define GEBI(x, y) ((BI) (x) >= (BI) (y)) | |
56 | #define LTUBI(x, y) ((BI) (x) < (BI) (y)) | |
57 | #define LEUBI(x, y) ((BI) (x) <= (BI) (y)) | |
58 | #define GTUBI(x, y) ((BI) (x) > (BI) (y)) | |
59 | #define GEUBI(x, y) ((BI) (x) >= (BI) (y)) | |
43ff13b4 | 60 | \f |
2225d5bd HPN |
61 | #define ADDQI(x, y) ((QI) ((UQI) (x) + (UQI) (y))) |
62 | #define SUBQI(x, y) ((QI) ((UQI) (x) - (UQI) (y))) | |
63 | #define MULQI(x, y) ((QI) ((UQI) (x) * (UQI) (y))) | |
c906108c SS |
64 | #define DIVQI(x, y) ((QI) (x) / (QI) (y)) |
65 | #define UDIVQI(x, y) ((UQI) (x) / (UQI) (y)) | |
66 | #define MODQI(x, y) ((QI) (x) % (QI) (y)) | |
67 | #define UMODQI(x, y) ((UQI) (x) % (UQI) (y)) | |
68 | #define SRAQI(x, y) ((QI) (x) >> (y)) | |
69 | #define SRLQI(x, y) ((UQI) (x) >> (y)) | |
70 | #define SLLQI(x, y) ((UQI) (x) << (y)) | |
43ff13b4 JM |
71 | extern QI RORQI (QI, int); |
72 | extern QI ROLQI (QI, int); | |
c906108c SS |
73 | #define ANDQI(x, y) ((x) & (y)) |
74 | #define ORQI(x, y) ((x) | (y)) | |
75 | #define XORQI(x, y) ((x) ^ (y)) | |
2225d5bd | 76 | #define NEGQI(x) ((QI) (- (UQI) (x))) |
c906108c SS |
77 | #define NOTQI(x) (! (QI) (x)) |
78 | #define INVQI(x) (~ (x)) | |
2225d5bd | 79 | #define ABSQI(x) ((QI) ((QI) (x) < 0 ? -(UQI) (x) : (UQI) (x))) |
c906108c SS |
80 | #define EQQI(x, y) ((QI) (x) == (QI) (y)) |
81 | #define NEQI(x, y) ((QI) (x) != (QI) (y)) | |
82 | #define LTQI(x, y) ((QI) (x) < (QI) (y)) | |
83 | #define LEQI(x, y) ((QI) (x) <= (QI) (y)) | |
84 | #define GTQI(x, y) ((QI) (x) > (QI) (y)) | |
85 | #define GEQI(x, y) ((QI) (x) >= (QI) (y)) | |
86 | #define LTUQI(x, y) ((UQI) (x) < (UQI) (y)) | |
87 | #define LEUQI(x, y) ((UQI) (x) <= (UQI) (y)) | |
88 | #define GTUQI(x, y) ((UQI) (x) > (UQI) (y)) | |
89 | #define GEUQI(x, y) ((UQI) (x) >= (UQI) (y)) | |
43ff13b4 | 90 | \f |
2225d5bd HPN |
91 | #define ADDHI(x, y) ((HI) ((UHI) (x) + (UHI) (y))) |
92 | #define SUBHI(x, y) ((HI) ((UHI) (x) - (UHI) (y))) | |
93 | #define MULHI(x, y) ((HI) ((UHI) (x) * (UHI) (y))) | |
c906108c SS |
94 | #define DIVHI(x, y) ((HI) (x) / (HI) (y)) |
95 | #define UDIVHI(x, y) ((UHI) (x) / (UHI) (y)) | |
96 | #define MODHI(x, y) ((HI) (x) % (HI) (y)) | |
97 | #define UMODHI(x, y) ((UHI) (x) % (UHI) (y)) | |
98 | #define SRAHI(x, y) ((HI) (x) >> (y)) | |
99 | #define SRLHI(x, y) ((UHI) (x) >> (y)) | |
100 | #define SLLHI(x, y) ((UHI) (x) << (y)) | |
43ff13b4 JM |
101 | extern HI RORHI (HI, int); |
102 | extern HI ROLHI (HI, int); | |
c906108c SS |
103 | #define ANDHI(x, y) ((x) & (y)) |
104 | #define ORHI(x, y) ((x) | (y)) | |
105 | #define XORHI(x, y) ((x) ^ (y)) | |
2225d5bd | 106 | #define NEGHI(x) ((HI) (- (UHI) (x))) |
c906108c SS |
107 | #define NOTHI(x) (! (HI) (x)) |
108 | #define INVHI(x) (~ (x)) | |
2225d5bd | 109 | #define ABSHI(x) ((HI) ((HI) (x) < 0 ? -(UHI) (x) : (UHI) (x))) |
c906108c SS |
110 | #define EQHI(x, y) ((HI) (x) == (HI) (y)) |
111 | #define NEHI(x, y) ((HI) (x) != (HI) (y)) | |
112 | #define LTHI(x, y) ((HI) (x) < (HI) (y)) | |
113 | #define LEHI(x, y) ((HI) (x) <= (HI) (y)) | |
114 | #define GTHI(x, y) ((HI) (x) > (HI) (y)) | |
115 | #define GEHI(x, y) ((HI) (x) >= (HI) (y)) | |
116 | #define LTUHI(x, y) ((UHI) (x) < (UHI) (y)) | |
117 | #define LEUHI(x, y) ((UHI) (x) <= (UHI) (y)) | |
118 | #define GTUHI(x, y) ((UHI) (x) > (UHI) (y)) | |
119 | #define GEUHI(x, y) ((UHI) (x) >= (UHI) (y)) | |
43ff13b4 | 120 | \f |
2225d5bd HPN |
121 | #define ADDSI(x, y) ((SI) ((USI) (x) + (USI) (y))) |
122 | #define SUBSI(x, y) ((SI) ((USI) (x) - (USI) (y))) | |
123 | #define MULSI(x, y) ((SI) ((USI) (x) * (USI) (y))) | |
c906108c SS |
124 | #define DIVSI(x, y) ((SI) (x) / (SI) (y)) |
125 | #define UDIVSI(x, y) ((USI) (x) / (USI) (y)) | |
126 | #define MODSI(x, y) ((SI) (x) % (SI) (y)) | |
127 | #define UMODSI(x, y) ((USI) (x) % (USI) (y)) | |
128 | #define SRASI(x, y) ((SI) (x) >> (y)) | |
129 | #define SRLSI(x, y) ((USI) (x) >> (y)) | |
130 | #define SLLSI(x, y) ((USI) (x) << (y)) | |
43ff13b4 JM |
131 | extern SI RORSI (SI, int); |
132 | extern SI ROLSI (SI, int); | |
c906108c SS |
133 | #define ANDSI(x, y) ((x) & (y)) |
134 | #define ORSI(x, y) ((x) | (y)) | |
135 | #define XORSI(x, y) ((x) ^ (y)) | |
2225d5bd | 136 | #define NEGSI(x) ((SI) (- (USI) (x))) |
c906108c SS |
137 | #define NOTSI(x) (! (SI) (x)) |
138 | #define INVSI(x) (~ (x)) | |
2225d5bd | 139 | #define ABSSI(x) ((SI) ((SI) (x) < 0 ? -(USI) (x) : (USI) (x))) |
c906108c SS |
140 | #define EQSI(x, y) ((SI) (x) == (SI) (y)) |
141 | #define NESI(x, y) ((SI) (x) != (SI) (y)) | |
142 | #define LTSI(x, y) ((SI) (x) < (SI) (y)) | |
143 | #define LESI(x, y) ((SI) (x) <= (SI) (y)) | |
144 | #define GTSI(x, y) ((SI) (x) > (SI) (y)) | |
145 | #define GESI(x, y) ((SI) (x) >= (SI) (y)) | |
146 | #define LTUSI(x, y) ((USI) (x) < (USI) (y)) | |
147 | #define LEUSI(x, y) ((USI) (x) <= (USI) (y)) | |
148 | #define GTUSI(x, y) ((USI) (x) > (USI) (y)) | |
149 | #define GEUSI(x, y) ((USI) (x) >= (USI) (y)) | |
43ff13b4 | 150 | \f |
c906108c | 151 | #ifdef DI_FN_SUPPORT |
43ff13b4 JM |
152 | extern DI ADDDI (DI, DI); |
153 | extern DI SUBDI (DI, DI); | |
154 | extern DI MULDI (DI, DI); | |
155 | extern DI DIVDI (DI, DI); | |
156 | extern DI UDIVDI (DI, DI); | |
157 | extern DI MODDI (DI, DI); | |
158 | extern DI UMODDI (DI, DI); | |
159 | extern DI SRADI (DI, int); | |
160 | extern UDI SRLDI (UDI, int); | |
161 | extern UDI SLLDI (UDI, int); | |
162 | extern DI RORDI (DI, int); | |
163 | extern DI ROLDI (DI, int); | |
164 | extern DI ANDDI (DI, DI); | |
165 | extern DI ORDI (DI, DI); | |
166 | extern DI XORDI (DI, DI); | |
167 | extern DI NEGDI (DI); | |
168 | extern int NOTDI (DI); | |
169 | extern DI INVDI (DI); | |
170 | extern int EQDI (DI, DI); | |
171 | extern int NEDI (DI, DI); | |
172 | extern int LTDI (DI, DI); | |
173 | extern int LEDI (DI, DI); | |
174 | extern int GTDI (DI, DI); | |
175 | extern int GEDI (DI, DI); | |
176 | extern int LTUDI (UDI, UDI); | |
177 | extern int LEUDI (UDI, UDI); | |
178 | extern int GTUDI (UDI, UDI); | |
179 | extern int GEUDI (UDI, UDI); | |
c906108c | 180 | #else /* ! DI_FN_SUPPORT */ |
2225d5bd HPN |
181 | #define ADDDI(x, y) ((DI) ((UDI) (x) + (UDI) (y))) |
182 | #define SUBDI(x, y) ((DI) ((UDI) (x) - (UDI) (y))) | |
183 | #define MULDI(x, y) ((DI) ((UDI) (x) * (UDI) (y))) | |
c906108c SS |
184 | #define DIVDI(x, y) ((DI) (x) / (DI) (y)) |
185 | #define UDIVDI(x, y) ((UDI) (x) / (UDI) (y)) | |
186 | #define MODDI(x, y) ((DI) (x) % (DI) (y)) | |
187 | #define UMODDI(x, y) ((UDI) (x) % (UDI) (y)) | |
188 | #define SRADI(x, y) ((DI) (x) >> (y)) | |
189 | #define SRLDI(x, y) ((UDI) (x) >> (y)) | |
190 | #define SLLDI(x, y) ((UDI) (x) << (y)) | |
43ff13b4 JM |
191 | extern DI RORDI (DI, int); |
192 | extern DI ROLDI (DI, int); | |
c906108c SS |
193 | #define ANDDI(x, y) ((x) & (y)) |
194 | #define ORDI(x, y) ((x) | (y)) | |
195 | #define XORDI(x, y) ((x) ^ (y)) | |
2225d5bd | 196 | #define NEGDI(x) ((DI) (- (UDI) (x))) |
c906108c SS |
197 | #define NOTDI(x) (! (DI) (x)) |
198 | #define INVDI(x) (~ (x)) | |
2225d5bd | 199 | #define ABSDI(x) ((DI) ((DI) (x) < 0 ? -(UDI) (x) : (UDI) (x))) |
c906108c SS |
200 | #define EQDI(x, y) ((DI) (x) == (DI) (y)) |
201 | #define NEDI(x, y) ((DI) (x) != (DI) (y)) | |
202 | #define LTDI(x, y) ((DI) (x) < (DI) (y)) | |
203 | #define LEDI(x, y) ((DI) (x) <= (DI) (y)) | |
204 | #define GTDI(x, y) ((DI) (x) > (DI) (y)) | |
205 | #define GEDI(x, y) ((DI) (x) >= (DI) (y)) | |
206 | #define LTUDI(x, y) ((UDI) (x) < (UDI) (y)) | |
207 | #define LEUDI(x, y) ((UDI) (x) <= (UDI) (y)) | |
208 | #define GTUDI(x, y) ((UDI) (x) > (UDI) (y)) | |
209 | #define GEUDI(x, y) ((UDI) (x) >= (UDI) (y)) | |
210 | #endif /* DI_FN_SUPPORT */ | |
43ff13b4 | 211 | \f |
c906108c SS |
212 | #define EXTBIQI(x) ((QI) (BI) (x)) |
213 | #define EXTBIHI(x) ((HI) (BI) (x)) | |
214 | #define EXTBISI(x) ((SI) (BI) (x)) | |
215 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 216 | extern DI EXTBIDI (BI); |
c906108c SS |
217 | #else |
218 | #define EXTBIDI(x) ((DI) (BI) (x)) | |
219 | #endif | |
220 | #define EXTQIHI(x) ((HI) (QI) (x)) | |
221 | #define EXTQISI(x) ((SI) (QI) (x)) | |
222 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 223 | extern DI EXTQIDI (QI); |
c906108c SS |
224 | #else |
225 | #define EXTQIDI(x) ((DI) (QI) (x)) | |
226 | #endif | |
f743149e | 227 | #define EXTHIHI(x) ((HI) (HI) (x)) |
c906108c | 228 | #define EXTHISI(x) ((SI) (HI) (x)) |
0fda6bd2 | 229 | #define EXTSISI(x) ((SI) (SI) (x)) |
c906108c | 230 | #if defined (DI_FN_SUPPORT) |
43ff13b4 | 231 | extern DI EXTHIDI (HI); |
c906108c SS |
232 | #else |
233 | #define EXTHIDI(x) ((DI) (HI) (x)) | |
234 | #endif | |
235 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 236 | extern DI EXTSIDI (SI); |
c906108c SS |
237 | #else |
238 | #define EXTSIDI(x) ((DI) (SI) (x)) | |
239 | #endif | |
43ff13b4 | 240 | \f |
c906108c SS |
241 | #define ZEXTBIQI(x) ((QI) (BI) (x)) |
242 | #define ZEXTBIHI(x) ((HI) (BI) (x)) | |
243 | #define ZEXTBISI(x) ((SI) (BI) (x)) | |
244 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 245 | extern DI ZEXTBIDI (BI); |
c906108c SS |
246 | #else |
247 | #define ZEXTBIDI(x) ((DI) (BI) (x)) | |
248 | #endif | |
249 | #define ZEXTQIHI(x) ((HI) (UQI) (x)) | |
250 | #define ZEXTQISI(x) ((SI) (UQI) (x)) | |
251 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 252 | extern DI ZEXTQIDI (QI); |
c906108c SS |
253 | #else |
254 | #define ZEXTQIDI(x) ((DI) (UQI) (x)) | |
255 | #endif | |
256 | #define ZEXTHISI(x) ((SI) (UHI) (x)) | |
0fda6bd2 JM |
257 | #define ZEXTHIHI(x) ((HI) (UHI) (x)) |
258 | #define ZEXTSISI(x) ((SI) (USI) (x)) | |
c906108c | 259 | #if defined (DI_FN_SUPPORT) |
43ff13b4 | 260 | extern DI ZEXTHIDI (HI); |
c906108c SS |
261 | #else |
262 | #define ZEXTHIDI(x) ((DI) (UHI) (x)) | |
263 | #endif | |
264 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 265 | extern DI ZEXTSIDI (SI); |
c906108c SS |
266 | #else |
267 | #define ZEXTSIDI(x) ((DI) (USI) (x)) | |
268 | #endif | |
43ff13b4 | 269 | \f |
c906108c SS |
270 | #define TRUNCQIBI(x) ((BI) (QI) (x)) |
271 | #define TRUNCHIBI(x) ((BI) (HI) (x)) | |
272 | #define TRUNCHIQI(x) ((QI) (HI) (x)) | |
273 | #define TRUNCSIBI(x) ((BI) (SI) (x)) | |
274 | #define TRUNCSIQI(x) ((QI) (SI) (x)) | |
275 | #define TRUNCSIHI(x) ((HI) (SI) (x)) | |
0f831eb3 | 276 | #define TRUNCSISI(x) ((SI) (SI) (x)) |
c906108c | 277 | #if defined (DI_FN_SUPPORT) |
43ff13b4 | 278 | extern BI TRUNCDIBI (DI); |
c906108c SS |
279 | #else |
280 | #define TRUNCDIBI(x) ((BI) (DI) (x)) | |
281 | #endif | |
282 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 283 | extern QI TRUNCDIQI (DI); |
c906108c SS |
284 | #else |
285 | #define TRUNCDIQI(x) ((QI) (DI) (x)) | |
286 | #endif | |
287 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 288 | extern HI TRUNCDIHI (DI); |
c906108c SS |
289 | #else |
290 | #define TRUNCDIHI(x) ((HI) (DI) (x)) | |
291 | #endif | |
292 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 293 | extern SI TRUNCDISI (DI); |
c906108c SS |
294 | #else |
295 | #define TRUNCDISI(x) ((SI) (DI) (x)) | |
296 | #endif | |
c906108c | 297 | \f |
6426a772 JM |
298 | /* Composing/decomposing the various types. |
299 | Word ordering is endian-independent. Words are specified most to least | |
300 | significant and word number 0 is the most significant word. | |
301 | ??? May also wish an endian-dependent version. Later. */ | |
43ff13b4 | 302 | |
c906108c | 303 | #ifdef SEMOPS_DEFINE_INLINE |
7a292a7a SS |
304 | |
305 | SEMOPS_INLINE SF | |
6426a772 | 306 | SUBWORDSISF (SI in) |
7a292a7a SS |
307 | { |
308 | union { SI in; SF out; } x; | |
309 | x.in = in; | |
310 | return x.out; | |
311 | } | |
312 | ||
4f49fa1b BE |
313 | SEMOPS_INLINE DF |
314 | SUBWORDDIDF (DI in) | |
315 | { | |
316 | union { DI in; DF out; } x; | |
317 | x.in = in; | |
318 | return x.out; | |
319 | } | |
320 | ||
321 | SEMOPS_INLINE QI | |
322 | SUBWORDSIQI (SI in, int byte) | |
323 | { | |
324 | assert (byte >= 0 && byte <= 3); | |
6227bc85 | 325 | return (UQI) (in >> (8 * (3 - byte))) & 0xFF; |
4f49fa1b BE |
326 | } |
327 | ||
328 | SEMOPS_INLINE UQI | |
329 | SUBWORDSIUQI (SI in, int byte) | |
330 | { | |
331 | assert (byte >= 0 && byte <= 3); | |
6227bc85 BE |
332 | return (UQI) (in >> (8 * (3 - byte))) & 0xFF; |
333 | } | |
334 | ||
335 | SEMOPS_INLINE QI | |
336 | SUBWORDDIQI (DI in, int byte) | |
337 | { | |
338 | assert (byte >= 0 && byte <= 7); | |
339 | return (UQI) (in >> (8 * (7 - byte))) & 0xFF; | |
4f49fa1b BE |
340 | } |
341 | ||
342 | SEMOPS_INLINE HI | |
343 | SUBWORDDIHI (DI in, int word) | |
344 | { | |
345 | assert (word >= 0 && word <= 3); | |
6227bc85 | 346 | return (UHI) (in >> (16 * (3 - word))) & 0xFFFF; |
4f49fa1b BE |
347 | } |
348 | ||
349 | SEMOPS_INLINE HI | |
350 | SUBWORDSIHI (SI in, int word) | |
351 | { | |
352 | if (word == 0) | |
353 | return (USI) in >> 16; | |
354 | else | |
355 | return in; | |
356 | } | |
357 | ||
7a292a7a | 358 | SEMOPS_INLINE SI |
6426a772 | 359 | SUBWORDSFSI (SF in) |
7a292a7a SS |
360 | { |
361 | union { SF in; SI out; } x; | |
362 | x.in = in; | |
363 | return x.out; | |
364 | } | |
365 | ||
0d277f51 BE |
366 | SEMOPS_INLINE DI |
367 | SUBWORDDFDI (DF in) | |
368 | { | |
369 | union { DF in; DI out; } x; | |
370 | x.in = in; | |
371 | return x.out; | |
372 | } | |
373 | ||
4f49fa1b BE |
374 | SEMOPS_INLINE UQI |
375 | SUBWORDDIUQI (DI in, int byte) | |
376 | { | |
377 | assert (byte >= 0 && byte <= 7); | |
378 | return (UQI) (in >> (8 * (7 - byte))); | |
379 | } | |
380 | ||
7a292a7a | 381 | SEMOPS_INLINE SI |
6426a772 | 382 | SUBWORDDISI (DI in, int word) |
7a292a7a | 383 | { |
6426a772 JM |
384 | if (word == 0) |
385 | return (UDI) in >> 32; | |
7a292a7a | 386 | else |
6426a772 | 387 | return in; |
7a292a7a SS |
388 | } |
389 | ||
390 | SEMOPS_INLINE SI | |
6426a772 | 391 | SUBWORDDFSI (DF in, int word) |
7a292a7a | 392 | { |
6426a772 JM |
393 | /* Note: typedef UDI DF; */ |
394 | if (word == 0) | |
395 | return (UDI) in >> 32; | |
7a292a7a | 396 | else |
6426a772 | 397 | return in; |
7a292a7a SS |
398 | } |
399 | ||
43ff13b4 | 400 | SEMOPS_INLINE SI |
6426a772 | 401 | SUBWORDXFSI (XF in, int word) |
43ff13b4 | 402 | { |
6426a772 | 403 | /* Note: typedef struct { SI parts[3]; } XF; */ |
43ff13b4 JM |
404 | union { XF in; SI out[3]; } x; |
405 | x.in = in; | |
1377e154 DE |
406 | if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN) |
407 | return x.out[word]; | |
408 | else | |
409 | return x.out[2 - word]; | |
43ff13b4 JM |
410 | } |
411 | ||
7a292a7a | 412 | SEMOPS_INLINE SI |
6426a772 | 413 | SUBWORDTFSI (TF in, int word) |
7a292a7a | 414 | { |
6426a772 | 415 | /* Note: typedef struct { SI parts[4]; } TF; */ |
7a292a7a SS |
416 | union { TF in; SI out[4]; } x; |
417 | x.in = in; | |
1377e154 DE |
418 | if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN) |
419 | return x.out[word]; | |
420 | else | |
421 | return x.out[3 - word]; | |
7a292a7a SS |
422 | } |
423 | ||
424 | SEMOPS_INLINE DI | |
6426a772 | 425 | JOINSIDI (SI x0, SI x1) |
7a292a7a | 426 | { |
1377e154 | 427 | return MAKEDI (x0, x1); |
7a292a7a SS |
428 | } |
429 | ||
430 | SEMOPS_INLINE DF | |
6426a772 | 431 | JOINSIDF (SI x0, SI x1) |
7a292a7a SS |
432 | { |
433 | union { SI in[2]; DF out; } x; | |
434 | if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN) | |
435 | x.in[0] = x0, x.in[1] = x1; | |
436 | else | |
437 | x.in[1] = x0, x.in[0] = x1; | |
438 | return x.out; | |
439 | } | |
440 | ||
43ff13b4 | 441 | SEMOPS_INLINE XF |
6426a772 | 442 | JOINSIXF (SI x0, SI x1, SI x2) |
43ff13b4 JM |
443 | { |
444 | union { SI in[3]; XF out; } x; | |
445 | if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN) | |
446 | x.in[0] = x0, x.in[1] = x1, x.in[2] = x2; | |
447 | else | |
448 | x.in[2] = x0, x.in[1] = x1, x.in[0] = x2; | |
449 | return x.out; | |
450 | } | |
451 | ||
7a292a7a | 452 | SEMOPS_INLINE TF |
6426a772 | 453 | JOINSITF (SI x0, SI x1, SI x2, SI x3) |
7a292a7a SS |
454 | { |
455 | union { SI in[4]; TF out; } x; | |
456 | if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN) | |
457 | x.in[0] = x0, x.in[1] = x1, x.in[2] = x2, x.in[3] = x3; | |
458 | else | |
459 | x.in[3] = x0, x.in[2] = x1, x.in[1] = x2, x.in[0] = x3; | |
460 | return x.out; | |
461 | } | |
462 | ||
c906108c | 463 | #else |
7a292a7a | 464 | |
4f49fa1b BE |
465 | QI SUBWORDSIQI (SI); |
466 | HI SUBWORDSIHI (HI); | |
6426a772 | 467 | SI SUBWORDSFSI (SF); |
4f49fa1b | 468 | SF SUBWORDSISF (SI); |
0d277f51 | 469 | DI SUBWORDDFDI (DF); |
4f49fa1b | 470 | DF SUBWORDDIDF (DI); |
6227bc85 | 471 | QI SUBWORDDIQI (DI, int); |
4f49fa1b | 472 | HI SUBWORDDIHI (DI, int); |
6426a772 JM |
473 | SI SUBWORDDISI (DI, int); |
474 | SI SUBWORDDFSI (DF, int); | |
475 | SI SUBWORDXFSI (XF, int); | |
476 | SI SUBWORDTFSI (TF, int); | |
7a292a7a | 477 | |
4f49fa1b BE |
478 | UQI SUBWORDSIUQI (SI); |
479 | UQI SUBWORDDIUQI (DI); | |
480 | ||
6426a772 JM |
481 | DI JOINSIDI (SI, SI); |
482 | DF JOINSIDF (SI, SI); | |
483 | XF JOINSIXF (SI, SI, SI); | |
484 | TF JOINSITF (SI, SI, SI, SI); | |
7a292a7a SS |
485 | |
486 | #endif /* SUBWORD,JOIN */ | |
487 | \f | |
488 | /* Semantic support utilities. */ | |
489 | ||
490 | #ifdef SEMOPS_DEFINE_INLINE | |
c906108c SS |
491 | |
492 | SEMOPS_INLINE SI | |
493 | ADDCSI (SI a, SI b, BI c) | |
494 | { | |
495 | SI res = ADDSI (a, ADDSI (b, c)); | |
496 | return res; | |
497 | } | |
498 | ||
499 | SEMOPS_INLINE BI | |
500 | ADDCFSI (SI a, SI b, BI c) | |
501 | { | |
502 | SI tmp = ADDSI (a, ADDSI (b, c)); | |
503 | BI res = ((USI) tmp < (USI) a) || (c && tmp == a); | |
504 | return res; | |
505 | } | |
506 | ||
507 | SEMOPS_INLINE BI | |
508 | ADDOFSI (SI a, SI b, BI c) | |
509 | { | |
510 | SI tmp = ADDSI (a, ADDSI (b, c)); | |
511 | BI res = (((a < 0) == (b < 0)) | |
512 | && ((a < 0) != (tmp < 0))); | |
513 | return res; | |
514 | } | |
515 | ||
516 | SEMOPS_INLINE SI | |
517 | SUBCSI (SI a, SI b, BI c) | |
518 | { | |
519 | SI res = SUBSI (a, ADDSI (b, c)); | |
520 | return res; | |
521 | } | |
522 | ||
523 | SEMOPS_INLINE BI | |
524 | SUBCFSI (SI a, SI b, BI c) | |
525 | { | |
526 | BI res = ((USI) a < (USI) b) || (c && a == b); | |
527 | return res; | |
528 | } | |
529 | ||
530 | SEMOPS_INLINE BI | |
531 | SUBOFSI (SI a, SI b, BI c) | |
532 | { | |
533 | SI tmp = SUBSI (a, ADDSI (b, c)); | |
534 | BI res = (((a < 0) != (b < 0)) | |
535 | && ((a < 0) != (tmp < 0))); | |
536 | return res; | |
537 | } | |
538 | ||
0fda6bd2 JM |
539 | SEMOPS_INLINE HI |
540 | ADDCHI (HI a, HI b, BI c) | |
541 | { | |
542 | HI res = ADDHI (a, ADDHI (b, c)); | |
543 | return res; | |
544 | } | |
545 | ||
546 | SEMOPS_INLINE BI | |
547 | ADDCFHI (HI a, HI b, BI c) | |
548 | { | |
549 | HI tmp = ADDHI (a, ADDHI (b, c)); | |
550 | BI res = ((UHI) tmp < (UHI) a) || (c && tmp == a); | |
551 | return res; | |
552 | } | |
553 | ||
554 | SEMOPS_INLINE BI | |
555 | ADDOFHI (HI a, HI b, BI c) | |
556 | { | |
557 | HI tmp = ADDHI (a, ADDHI (b, c)); | |
558 | BI res = (((a < 0) == (b < 0)) | |
559 | && ((a < 0) != (tmp < 0))); | |
560 | return res; | |
561 | } | |
562 | ||
563 | SEMOPS_INLINE HI | |
564 | SUBCHI (HI a, HI b, BI c) | |
565 | { | |
566 | HI res = SUBHI (a, ADDHI (b, c)); | |
567 | return res; | |
568 | } | |
569 | ||
570 | SEMOPS_INLINE BI | |
571 | SUBCFHI (HI a, HI b, BI c) | |
572 | { | |
573 | BI res = ((UHI) a < (UHI) b) || (c && a == b); | |
574 | return res; | |
575 | } | |
576 | ||
577 | SEMOPS_INLINE BI | |
578 | SUBOFHI (HI a, HI b, BI c) | |
579 | { | |
580 | HI tmp = SUBHI (a, ADDHI (b, c)); | |
581 | BI res = (((a < 0) != (b < 0)) | |
582 | && ((a < 0) != (tmp < 0))); | |
583 | return res; | |
584 | } | |
585 | ||
dea03d4e HPN |
586 | SEMOPS_INLINE QI |
587 | ADDCQI (QI a, QI b, BI c) | |
588 | { | |
589 | QI res = ADDQI (a, ADDQI (b, c)); | |
590 | return res; | |
591 | } | |
592 | ||
593 | SEMOPS_INLINE BI | |
594 | ADDCFQI (QI a, QI b, BI c) | |
595 | { | |
596 | QI tmp = ADDQI (a, ADDQI (b, c)); | |
597 | BI res = ((UQI) tmp < (UQI) a) || (c && tmp == a); | |
598 | return res; | |
599 | } | |
600 | ||
601 | SEMOPS_INLINE BI | |
602 | ADDOFQI (QI a, QI b, BI c) | |
603 | { | |
604 | QI tmp = ADDQI (a, ADDQI (b, c)); | |
605 | BI res = (((a < 0) == (b < 0)) | |
606 | && ((a < 0) != (tmp < 0))); | |
607 | return res; | |
608 | } | |
609 | ||
610 | SEMOPS_INLINE QI | |
611 | SUBCQI (QI a, QI b, BI c) | |
612 | { | |
613 | QI res = SUBQI (a, ADDQI (b, c)); | |
614 | return res; | |
615 | } | |
616 | ||
617 | SEMOPS_INLINE BI | |
618 | SUBCFQI (QI a, QI b, BI c) | |
619 | { | |
620 | BI res = ((UQI) a < (UQI) b) || (c && a == b); | |
621 | return res; | |
622 | } | |
623 | ||
624 | SEMOPS_INLINE BI | |
625 | SUBOFQI (QI a, QI b, BI c) | |
626 | { | |
627 | QI tmp = SUBQI (a, ADDQI (b, c)); | |
628 | BI res = (((a < 0) != (b < 0)) | |
629 | && ((a < 0) != (tmp < 0))); | |
630 | return res; | |
631 | } | |
632 | ||
c906108c SS |
633 | #else |
634 | ||
635 | SI ADDCSI (SI, SI, BI); | |
636 | UBI ADDCFSI (SI, SI, BI); | |
637 | UBI ADDOFSI (SI, SI, BI); | |
638 | SI SUBCSI (SI, SI, BI); | |
639 | UBI SUBCFSI (SI, SI, BI); | |
640 | UBI SUBOFSI (SI, SI, BI); | |
0fda6bd2 JM |
641 | HI ADDCHI (HI, HI, BI); |
642 | UBI ADDCFHI (HI, HI, BI); | |
643 | UBI ADDOFHI (HI, HI, BI); | |
644 | HI SUBCHI (HI, HI, BI); | |
645 | UBI SUBCFHI (HI, HI, BI); | |
646 | UBI SUBOFHI (HI, HI, BI); | |
dea03d4e HPN |
647 | QI ADDCQI (QI, QI, BI); |
648 | UBI ADDCFQI (QI, QI, BI); | |
649 | UBI ADDOFQI (QI, QI, BI); | |
650 | QI SUBCQI (QI, QI, BI); | |
651 | UBI SUBCFQI (QI, QI, BI); | |
652 | UBI SUBOFQI (QI, QI, BI); | |
c906108c SS |
653 | |
654 | #endif | |
c906108c SS |
655 | |
656 | #endif /* CGEN_SEM_OPS_H */ |