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