testsuite, threads: fix LD_LIBRARY_PATH in 'tls-sepdebug.exp'
[binutils-gdb.git] / sim / common / cgen-ops.h
blob396a77ebf44b13d42d5c21ce2234b4b2d640ad85
1 /* Semantics ops support for CGEN-based simulators.
2 Copyright (C) 1996-2024 Free Software Foundation, Inc.
3 Contributed by Cygnus Solutions.
5 This file is part of the GNU Simulators.
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.
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.
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/>.
22 #ifndef CGEN_SEM_OPS_H
23 #define CGEN_SEM_OPS_H
25 #include <assert.h>
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
35 /* Semantic operations.
36 At one point this file was machine generated. Maybe it will be again. */
38 /* TODO: Lazy encoding/decoding of fp values. */
40 /* These don't really have a mode. */
41 #define ANDIF(x, y) ((x) && (y))
42 #define ORIF(x, y) ((x) || (y))
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))
62 #define ADDQI(x, y) ((QI) ((UQI) (x) + (UQI) (y)))
63 #define SUBQI(x, y) ((QI) ((UQI) (x) - (UQI) (y)))
64 #define MULQI(x, y) ((QI) ((UQI) (x) * (UQI) (y)))
65 #define DIVQI(x, y) ((QI) (x) / (QI) (y))
66 #define UDIVQI(x, y) ((UQI) (x) / (UQI) (y))
67 #define MODQI(x, y) ((QI) (x) % (QI) (y))
68 #define UMODQI(x, y) ((UQI) (x) % (UQI) (y))
69 #define SRAQI(x, y) ((QI) (x) >> (y))
70 #define SRLQI(x, y) ((UQI) (x) >> (y))
71 #define SLLQI(x, y) ((UQI) (x) << (y))
72 extern QI RORQI (QI, int);
73 extern QI ROLQI (QI, int);
74 #define ANDQI(x, y) ((x) & (y))
75 #define ORQI(x, y) ((x) | (y))
76 #define XORQI(x, y) ((x) ^ (y))
77 #define NEGQI(x) ((QI) (- (UQI) (x)))
78 #define NOTQI(x) (! (QI) (x))
79 #define INVQI(x) (~ (x))
80 #define ABSQI(x) ((QI) ((QI) (x) < 0 ? -(UQI) (x) : (UQI) (x)))
81 #define EQQI(x, y) ((QI) (x) == (QI) (y))
82 #define NEQI(x, y) ((QI) (x) != (QI) (y))
83 #define LTQI(x, y) ((QI) (x) < (QI) (y))
84 #define LEQI(x, y) ((QI) (x) <= (QI) (y))
85 #define GTQI(x, y) ((QI) (x) > (QI) (y))
86 #define GEQI(x, y) ((QI) (x) >= (QI) (y))
87 #define LTUQI(x, y) ((UQI) (x) < (UQI) (y))
88 #define LEUQI(x, y) ((UQI) (x) <= (UQI) (y))
89 #define GTUQI(x, y) ((UQI) (x) > (UQI) (y))
90 #define GEUQI(x, y) ((UQI) (x) >= (UQI) (y))
92 #define ADDHI(x, y) ((HI) ((UHI) (x) + (UHI) (y)))
93 #define SUBHI(x, y) ((HI) ((UHI) (x) - (UHI) (y)))
94 #define MULHI(x, y) ((HI) ((UHI) (x) * (UHI) (y)))
95 #define DIVHI(x, y) ((HI) (x) / (HI) (y))
96 #define UDIVHI(x, y) ((UHI) (x) / (UHI) (y))
97 #define MODHI(x, y) ((HI) (x) % (HI) (y))
98 #define UMODHI(x, y) ((UHI) (x) % (UHI) (y))
99 #define SRAHI(x, y) ((HI) (x) >> (y))
100 #define SRLHI(x, y) ((UHI) (x) >> (y))
101 #define SLLHI(x, y) ((UHI) (x) << (y))
102 extern HI RORHI (HI, int);
103 extern HI ROLHI (HI, int);
104 #define ANDHI(x, y) ((x) & (y))
105 #define ORHI(x, y) ((x) | (y))
106 #define XORHI(x, y) ((x) ^ (y))
107 #define NEGHI(x) ((HI) (- (UHI) (x)))
108 #define NOTHI(x) (! (HI) (x))
109 #define INVHI(x) (~ (x))
110 #define ABSHI(x) ((HI) ((HI) (x) < 0 ? -(UHI) (x) : (UHI) (x)))
111 #define EQHI(x, y) ((HI) (x) == (HI) (y))
112 #define NEHI(x, y) ((HI) (x) != (HI) (y))
113 #define LTHI(x, y) ((HI) (x) < (HI) (y))
114 #define LEHI(x, y) ((HI) (x) <= (HI) (y))
115 #define GTHI(x, y) ((HI) (x) > (HI) (y))
116 #define GEHI(x, y) ((HI) (x) >= (HI) (y))
117 #define LTUHI(x, y) ((UHI) (x) < (UHI) (y))
118 #define LEUHI(x, y) ((UHI) (x) <= (UHI) (y))
119 #define GTUHI(x, y) ((UHI) (x) > (UHI) (y))
120 #define GEUHI(x, y) ((UHI) (x) >= (UHI) (y))
122 #define ADDSI(x, y) ((SI) ((USI) (x) + (USI) (y)))
123 #define SUBSI(x, y) ((SI) ((USI) (x) - (USI) (y)))
124 #define MULSI(x, y) ((SI) ((USI) (x) * (USI) (y)))
125 #define DIVSI(x, y) ((SI) (x) / (SI) (y))
126 #define UDIVSI(x, y) ((USI) (x) / (USI) (y))
127 #define MODSI(x, y) ((SI) (x) % (SI) (y))
128 #define UMODSI(x, y) ((USI) (x) % (USI) (y))
129 #define SRASI(x, y) ((SI) (x) >> (y))
130 #define SRLSI(x, y) ((USI) (x) >> (y))
131 #define SLLSI(x, y) ((USI) (x) << (y))
132 extern SI RORSI (SI, int);
133 extern SI ROLSI (SI, int);
134 #define ANDSI(x, y) ((x) & (y))
135 #define ORSI(x, y) ((x) | (y))
136 #define XORSI(x, y) ((x) ^ (y))
137 #define NEGSI(x) ((SI) (- (USI) (x)))
138 #define NOTSI(x) (! (SI) (x))
139 #define INVSI(x) (~ (x))
140 #define ABSSI(x) ((SI) ((SI) (x) < 0 ? -(USI) (x) : (USI) (x)))
141 #define EQSI(x, y) ((SI) (x) == (SI) (y))
142 #define NESI(x, y) ((SI) (x) != (SI) (y))
143 #define LTSI(x, y) ((SI) (x) < (SI) (y))
144 #define LESI(x, y) ((SI) (x) <= (SI) (y))
145 #define GTSI(x, y) ((SI) (x) > (SI) (y))
146 #define GESI(x, y) ((SI) (x) >= (SI) (y))
147 #define LTUSI(x, y) ((USI) (x) < (USI) (y))
148 #define LEUSI(x, y) ((USI) (x) <= (USI) (y))
149 #define GTUSI(x, y) ((USI) (x) > (USI) (y))
150 #define GEUSI(x, y) ((USI) (x) >= (USI) (y))
152 #ifdef DI_FN_SUPPORT
153 extern DI ADDDI (DI, DI);
154 extern DI SUBDI (DI, DI);
155 extern DI MULDI (DI, DI);
156 extern DI DIVDI (DI, DI);
157 extern DI UDIVDI (DI, DI);
158 extern DI MODDI (DI, DI);
159 extern DI UMODDI (DI, DI);
160 extern DI SRADI (DI, int);
161 extern UDI SRLDI (UDI, int);
162 extern UDI SLLDI (UDI, int);
163 extern DI RORDI (DI, int);
164 extern DI ROLDI (DI, int);
165 extern DI ANDDI (DI, DI);
166 extern DI ORDI (DI, DI);
167 extern DI XORDI (DI, DI);
168 extern DI NEGDI (DI);
169 extern int NOTDI (DI);
170 extern DI INVDI (DI);
171 extern int EQDI (DI, DI);
172 extern int NEDI (DI, DI);
173 extern int LTDI (DI, DI);
174 extern int LEDI (DI, DI);
175 extern int GTDI (DI, DI);
176 extern int GEDI (DI, DI);
177 extern int LTUDI (UDI, UDI);
178 extern int LEUDI (UDI, UDI);
179 extern int GTUDI (UDI, UDI);
180 extern int GEUDI (UDI, UDI);
181 #else /* ! DI_FN_SUPPORT */
182 #define ADDDI(x, y) ((DI) ((UDI) (x) + (UDI) (y)))
183 #define SUBDI(x, y) ((DI) ((UDI) (x) - (UDI) (y)))
184 #define MULDI(x, y) ((DI) ((UDI) (x) * (UDI) (y)))
185 #define DIVDI(x, y) ((DI) (x) / (DI) (y))
186 #define UDIVDI(x, y) ((UDI) (x) / (UDI) (y))
187 #define MODDI(x, y) ((DI) (x) % (DI) (y))
188 #define UMODDI(x, y) ((UDI) (x) % (UDI) (y))
189 #define SRADI(x, y) ((DI) (x) >> (y))
190 #define SRLDI(x, y) ((UDI) (x) >> (y))
191 #define SLLDI(x, y) ((UDI) (x) << (y))
192 extern DI RORDI (DI, int);
193 extern DI ROLDI (DI, int);
194 #define ANDDI(x, y) ((x) & (y))
195 #define ORDI(x, y) ((x) | (y))
196 #define XORDI(x, y) ((x) ^ (y))
197 #define NEGDI(x) ((DI) (- (UDI) (x)))
198 #define NOTDI(x) (! (DI) (x))
199 #define INVDI(x) (~ (x))
200 #define ABSDI(x) ((DI) ((DI) (x) < 0 ? -(UDI) (x) : (UDI) (x)))
201 #define EQDI(x, y) ((DI) (x) == (DI) (y))
202 #define NEDI(x, y) ((DI) (x) != (DI) (y))
203 #define LTDI(x, y) ((DI) (x) < (DI) (y))
204 #define LEDI(x, y) ((DI) (x) <= (DI) (y))
205 #define GTDI(x, y) ((DI) (x) > (DI) (y))
206 #define GEDI(x, y) ((DI) (x) >= (DI) (y))
207 #define LTUDI(x, y) ((UDI) (x) < (UDI) (y))
208 #define LEUDI(x, y) ((UDI) (x) <= (UDI) (y))
209 #define GTUDI(x, y) ((UDI) (x) > (UDI) (y))
210 #define GEUDI(x, y) ((UDI) (x) >= (UDI) (y))
211 #endif /* DI_FN_SUPPORT */
213 #define EXTBIQI(x) ((QI) (BI) (x))
214 #define EXTBIHI(x) ((HI) (BI) (x))
215 #define EXTBISI(x) ((SI) (BI) (x))
216 #if defined (DI_FN_SUPPORT)
217 extern DI EXTBIDI (BI);
218 #else
219 #define EXTBIDI(x) ((DI) (BI) (x))
220 #endif
221 #define EXTQIHI(x) ((HI) (QI) (x))
222 #define EXTQISI(x) ((SI) (QI) (x))
223 #if defined (DI_FN_SUPPORT)
224 extern DI EXTQIDI (QI);
225 #else
226 #define EXTQIDI(x) ((DI) (QI) (x))
227 #endif
228 #define EXTHIHI(x) ((HI) (HI) (x))
229 #define EXTHISI(x) ((SI) (HI) (x))
230 #define EXTSISI(x) ((SI) (SI) (x))
231 #if defined (DI_FN_SUPPORT)
232 extern DI EXTHIDI (HI);
233 #else
234 #define EXTHIDI(x) ((DI) (HI) (x))
235 #endif
236 #if defined (DI_FN_SUPPORT)
237 extern DI EXTSIDI (SI);
238 #else
239 #define EXTSIDI(x) ((DI) (SI) (x))
240 #endif
242 #define ZEXTBIQI(x) ((QI) (BI) (x))
243 #define ZEXTBIHI(x) ((HI) (BI) (x))
244 #define ZEXTBISI(x) ((SI) (BI) (x))
245 #if defined (DI_FN_SUPPORT)
246 extern DI ZEXTBIDI (BI);
247 #else
248 #define ZEXTBIDI(x) ((DI) (BI) (x))
249 #endif
250 #define ZEXTQIHI(x) ((HI) (UQI) (x))
251 #define ZEXTQISI(x) ((SI) (UQI) (x))
252 #if defined (DI_FN_SUPPORT)
253 extern DI ZEXTQIDI (QI);
254 #else
255 #define ZEXTQIDI(x) ((DI) (UQI) (x))
256 #endif
257 #define ZEXTHISI(x) ((SI) (UHI) (x))
258 #define ZEXTHIHI(x) ((HI) (UHI) (x))
259 #define ZEXTSISI(x) ((SI) (USI) (x))
260 #if defined (DI_FN_SUPPORT)
261 extern DI ZEXTHIDI (HI);
262 #else
263 #define ZEXTHIDI(x) ((DI) (UHI) (x))
264 #endif
265 #if defined (DI_FN_SUPPORT)
266 extern DI ZEXTSIDI (SI);
267 #else
268 #define ZEXTSIDI(x) ((DI) (USI) (x))
269 #endif
271 #define TRUNCQIBI(x) ((BI) (QI) (x))
272 #define TRUNCHIBI(x) ((BI) (HI) (x))
273 #define TRUNCHIQI(x) ((QI) (HI) (x))
274 #define TRUNCSIBI(x) ((BI) (SI) (x))
275 #define TRUNCSIQI(x) ((QI) (SI) (x))
276 #define TRUNCSIHI(x) ((HI) (SI) (x))
277 #define TRUNCSISI(x) ((SI) (SI) (x))
278 #if defined (DI_FN_SUPPORT)
279 extern BI TRUNCDIBI (DI);
280 #else
281 #define TRUNCDIBI(x) ((BI) (DI) (x))
282 #endif
283 #if defined (DI_FN_SUPPORT)
284 extern QI TRUNCDIQI (DI);
285 #else
286 #define TRUNCDIQI(x) ((QI) (DI) (x))
287 #endif
288 #if defined (DI_FN_SUPPORT)
289 extern HI TRUNCDIHI (DI);
290 #else
291 #define TRUNCDIHI(x) ((HI) (DI) (x))
292 #endif
293 #if defined (DI_FN_SUPPORT)
294 extern SI TRUNCDISI (DI);
295 #else
296 #define TRUNCDISI(x) ((SI) (DI) (x))
297 #endif
299 /* Composing/decomposing the various types.
300 Word ordering is endian-independent. Words are specified most to least
301 significant and word number 0 is the most significant word.
302 ??? May also wish an endian-dependent version. Later. */
304 QI SUBWORDSIQI (SI, int);
305 HI SUBWORDSIHI (SI, int);
306 SI SUBWORDSFSI (SF);
307 SF SUBWORDSISF (SI);
308 DI SUBWORDDFDI (DF);
309 DF SUBWORDDIDF (DI);
310 QI SUBWORDDIQI (DI, int);
311 HI SUBWORDDIHI (DI, int);
312 SI SUBWORDDISI (DI, int);
313 SI SUBWORDDFSI (DF, int);
314 SI SUBWORDXFSI (XF, int);
315 SI SUBWORDTFSI (TF, int);
317 UQI SUBWORDSIUQI (SI, int);
318 UQI SUBWORDDIUQI (DI, int);
320 DI JOINSIDI (SI, SI);
321 DF JOINSIDF (SI, SI);
322 XF JOINSIXF (SI, SI, SI);
323 TF JOINSITF (SI, SI, SI, SI);
325 #ifdef SEMOPS_DEFINE_INLINE
327 SEMOPS_INLINE SF
328 SUBWORDSISF (SI in)
330 union { SI in; SF out; } x;
331 x.in = in;
332 return x.out;
335 SEMOPS_INLINE DF
336 SUBWORDDIDF (DI in)
338 union { DI in; DF out; } x;
339 x.in = in;
340 return x.out;
343 SEMOPS_INLINE QI
344 SUBWORDSIQI (SI in, int byte)
346 assert (byte >= 0 && byte <= 3);
347 return (UQI) (in >> (8 * (3 - byte))) & 0xFF;
350 SEMOPS_INLINE UQI
351 SUBWORDSIUQI (SI in, int byte)
353 assert (byte >= 0 && byte <= 3);
354 return (UQI) (in >> (8 * (3 - byte))) & 0xFF;
357 SEMOPS_INLINE QI
358 SUBWORDDIQI (DI in, int byte)
360 assert (byte >= 0 && byte <= 7);
361 return (UQI) (in >> (8 * (7 - byte))) & 0xFF;
364 SEMOPS_INLINE HI
365 SUBWORDDIHI (DI in, int word)
367 assert (word >= 0 && word <= 3);
368 return (UHI) (in >> (16 * (3 - word))) & 0xFFFF;
371 SEMOPS_INLINE HI
372 SUBWORDSIHI (SI in, int word)
374 if (word == 0)
375 return (USI) in >> 16;
376 else
377 return in;
380 SEMOPS_INLINE SI
381 SUBWORDSFSI (SF in)
383 union { SF in; SI out; } x;
384 x.in = in;
385 return x.out;
388 SEMOPS_INLINE DI
389 SUBWORDDFDI (DF in)
391 union { DF in; DI out; } x;
392 x.in = in;
393 return x.out;
396 SEMOPS_INLINE UQI
397 SUBWORDDIUQI (DI in, int byte)
399 assert (byte >= 0 && byte <= 7);
400 return (UQI) (in >> (8 * (7 - byte)));
403 SEMOPS_INLINE SI
404 SUBWORDDISI (DI in, int word)
406 if (word == 0)
407 return (UDI) in >> 32;
408 else
409 return in;
412 SEMOPS_INLINE SI
413 SUBWORDDFSI (DF in, int word)
415 /* Note: typedef UDI DF; */
416 if (word == 0)
417 return (UDI) in >> 32;
418 else
419 return in;
422 SEMOPS_INLINE SI
423 SUBWORDXFSI (XF in, int word)
425 /* Note: typedef struct { SI parts[3]; } XF; */
426 union { XF in; SI out[3]; } x;
427 x.in = in;
428 if (HOST_BYTE_ORDER == BFD_ENDIAN_BIG)
429 return x.out[word];
430 else
431 return x.out[2 - word];
434 SEMOPS_INLINE SI
435 SUBWORDTFSI (TF in, int word)
437 /* Note: typedef struct { SI parts[4]; } TF; */
438 union { TF in; SI out[4]; } x;
439 x.in = in;
440 if (HOST_BYTE_ORDER == BFD_ENDIAN_BIG)
441 return x.out[word];
442 else
443 return x.out[3 - word];
446 SEMOPS_INLINE DI
447 JOINSIDI (SI x0, SI x1)
449 return MAKEDI (x0, x1);
452 SEMOPS_INLINE DF
453 JOINSIDF (SI x0, SI x1)
455 union { SI in[2]; DF out; } x;
456 if (HOST_BYTE_ORDER == BFD_ENDIAN_BIG)
457 x.in[0] = x0, x.in[1] = x1;
458 else
459 x.in[1] = x0, x.in[0] = x1;
460 return x.out;
463 SEMOPS_INLINE XF
464 JOINSIXF (SI x0, SI x1, SI x2)
466 union { SI in[3]; XF out; } x;
467 if (HOST_BYTE_ORDER == BFD_ENDIAN_BIG)
468 x.in[0] = x0, x.in[1] = x1, x.in[2] = x2;
469 else
470 x.in[2] = x0, x.in[1] = x1, x.in[0] = x2;
471 return x.out;
474 SEMOPS_INLINE TF
475 JOINSITF (SI x0, SI x1, SI x2, SI x3)
477 union { SI in[4]; TF out; } x;
478 if (HOST_BYTE_ORDER == BFD_ENDIAN_BIG)
479 x.in[0] = x0, x.in[1] = x1, x.in[2] = x2, x.in[3] = x3;
480 else
481 x.in[3] = x0, x.in[2] = x1, x.in[1] = x2, x.in[0] = x3;
482 return x.out;
485 #endif /* SUBWORD,JOIN */
487 /* Semantic support utilities. */
489 SI ADDCSI (SI, SI, BI);
490 BI ADDCFSI (SI, SI, BI);
491 BI ADDOFSI (SI, SI, BI);
492 SI SUBCSI (SI, SI, BI);
493 BI SUBCFSI (SI, SI, BI);
494 BI SUBOFSI (SI, SI, BI);
495 HI ADDCHI (HI, HI, BI);
496 BI ADDCFHI (HI, HI, BI);
497 BI ADDOFHI (HI, HI, BI);
498 HI SUBCHI (HI, HI, BI);
499 BI SUBCFHI (HI, HI, BI);
500 BI SUBOFHI (HI, HI, BI);
501 QI ADDCQI (QI, QI, BI);
502 BI ADDCFQI (QI, QI, BI);
503 BI ADDOFQI (QI, QI, BI);
504 QI SUBCQI (QI, QI, BI);
505 BI SUBCFQI (QI, QI, BI);
506 BI SUBOFQI (QI, QI, BI);
507 BI MUL1OFSI (USI a, USI b);
508 BI MUL2OFSI (SI a, SI b);
509 BI ADDCFDI (DI a, DI b, BI c);
510 BI ADDOFDI (DI a, DI b, BI c);
511 BI SUBCFDI (DI a, DI b, BI c);
512 BI SUBOFDI (DI a, DI b, BI c);
514 #ifdef SEMOPS_DEFINE_INLINE
516 SEMOPS_INLINE SI
517 ADDCSI (SI a, SI b, BI c)
519 SI res = ADDSI (a, ADDSI (b, c));
520 return res;
523 SEMOPS_INLINE BI
524 ADDCFSI (SI a, SI b, BI c)
526 SI tmp = ADDSI (a, ADDSI (b, c));
527 BI res = ((USI) tmp < (USI) a) || (c && tmp == a);
528 return res;
531 SEMOPS_INLINE BI
532 ADDOFSI (SI a, SI b, BI c)
534 SI tmp = ADDSI (a, ADDSI (b, c));
535 BI res = (((a < 0) == (b < 0))
536 && ((a < 0) != (tmp < 0)));
537 return res;
540 SEMOPS_INLINE SI
541 SUBCSI (SI a, SI b, BI c)
543 SI res = SUBSI (a, ADDSI (b, c));
544 return res;
547 SEMOPS_INLINE BI
548 SUBCFSI (SI a, SI b, BI c)
550 BI res = ((USI) a < (USI) b) || (c && a == b);
551 return res;
554 SEMOPS_INLINE BI
555 SUBOFSI (SI a, SI b, BI c)
557 SI tmp = SUBSI (a, ADDSI (b, c));
558 BI res = (((a < 0) != (b < 0))
559 && ((a < 0) != (tmp < 0)));
560 return res;
563 SEMOPS_INLINE HI
564 ADDCHI (HI a, HI b, BI c)
566 HI res = ADDHI (a, ADDHI (b, c));
567 return res;
570 SEMOPS_INLINE BI
571 ADDCFHI (HI a, HI b, BI c)
573 HI tmp = ADDHI (a, ADDHI (b, c));
574 BI res = ((UHI) tmp < (UHI) a) || (c && tmp == a);
575 return res;
578 SEMOPS_INLINE BI
579 ADDOFHI (HI a, HI b, BI c)
581 HI tmp = ADDHI (a, ADDHI (b, c));
582 BI res = (((a < 0) == (b < 0))
583 && ((a < 0) != (tmp < 0)));
584 return res;
587 SEMOPS_INLINE HI
588 SUBCHI (HI a, HI b, BI c)
590 HI res = SUBHI (a, ADDHI (b, c));
591 return res;
594 SEMOPS_INLINE BI
595 SUBCFHI (HI a, HI b, BI c)
597 BI res = ((UHI) a < (UHI) b) || (c && a == b);
598 return res;
601 SEMOPS_INLINE BI
602 SUBOFHI (HI a, HI b, BI c)
604 HI tmp = SUBHI (a, ADDHI (b, c));
605 BI res = (((a < 0) != (b < 0))
606 && ((a < 0) != (tmp < 0)));
607 return res;
610 SEMOPS_INLINE QI
611 ADDCQI (QI a, QI b, BI c)
613 QI res = ADDQI (a, ADDQI (b, c));
614 return res;
617 SEMOPS_INLINE BI
618 ADDCFQI (QI a, QI b, BI c)
620 QI tmp = ADDQI (a, ADDQI (b, c));
621 BI res = ((UQI) tmp < (UQI) a) || (c && tmp == a);
622 return res;
625 SEMOPS_INLINE BI
626 ADDOFQI (QI a, QI b, BI c)
628 QI tmp = ADDQI (a, ADDQI (b, c));
629 BI res = (((a < 0) == (b < 0))
630 && ((a < 0) != (tmp < 0)));
631 return res;
634 SEMOPS_INLINE QI
635 SUBCQI (QI a, QI b, BI c)
637 QI res = SUBQI (a, ADDQI (b, c));
638 return res;
641 SEMOPS_INLINE BI
642 SUBCFQI (QI a, QI b, BI c)
644 BI res = ((UQI) a < (UQI) b) || (c && a == b);
645 return res;
648 SEMOPS_INLINE BI
649 SUBOFQI (QI a, QI b, BI c)
651 QI tmp = SUBQI (a, ADDQI (b, c));
652 BI res = (((a < 0) != (b < 0))
653 && ((a < 0) != (tmp < 0)));
654 return res;
657 SEMOPS_INLINE BI
658 MUL2OFSI (SI a, SI b)
660 DI tmp = MULDI (EXTSIDI (a), EXTSIDI (b));
661 BI res = tmp < -0x80000000LL || tmp > 0x7fffffffLL;
662 return res;
665 SEMOPS_INLINE BI
666 MUL1OFSI (USI a, USI b)
668 UDI tmp = MULDI (ZEXTSIDI (a), ZEXTSIDI (b));
669 BI res = (tmp > 0xFFFFFFFFULL);
670 return res;
673 SEMOPS_INLINE BI
674 ADDCFDI (DI a, DI b, BI c)
676 DI tmp = ADDDI (a, ADDDI (b, c));
677 BI res = ((UDI) tmp < (UDI) a) || (c && tmp == a);
678 return res;
681 SEMOPS_INLINE BI
682 ADDOFDI (DI a, DI b, BI c)
684 DI tmp = ADDDI (a, ADDDI (b, c));
685 BI res = (((a < 0) == (b < 0))
686 && ((a < 0) != (tmp < 0)));
687 return res;
690 SEMOPS_INLINE BI
691 SUBCFDI (DI a, DI b, BI c)
693 BI res = ((UDI) a < (UDI) b) || (c && a == b);
694 return res;
697 SEMOPS_INLINE BI
698 SUBOFDI (DI a, DI b, BI c)
700 DI tmp = SUBDI (a, ADDSI (b, c));
701 BI res = (((a < 0) != (b < 0))
702 && ((a < 0) != (tmp < 0)));
703 return res;
706 #endif
708 extern void cgen_rtx_error (SIM_CPU *, const char *) ATTRIBUTE_NORETURN;
710 #endif /* CGEN_SEM_OPS_H */