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