cgen-ops.h revision 1.3
1/* Semantics ops support for CGEN-based simulators.
2   Copyright (C) 1996-2015 Free Software Foundation, Inc.
3   Contributed by Cygnus Solutions.
4
5This file is part of the GNU Simulators.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along 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#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
34/* Semantic operations.
35   At one point this file was machine generated.  Maybe it will be again.  */
36
37/* TODO: Lazy encoding/decoding of fp values.  */
38
39/* These don't really have a mode.  */
40#define ANDIF(x, y) ((x) && (y))
41#define ORIF(x, y) ((x) || (y))
42
43#define SUBBI(x, y) ((x) - (y))
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))
60
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)))
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))
71extern QI RORQI (QI, int);
72extern QI ROLQI (QI, int);
73#define ANDQI(x, y) ((x) & (y))
74#define ORQI(x, y) ((x) | (y))
75#define XORQI(x, y) ((x) ^ (y))
76#define NEGQI(x) ((QI) (- (UQI) (x)))
77#define NOTQI(x) (! (QI) (x))
78#define INVQI(x) (~ (x))
79#define ABSQI(x) ((QI) ((QI) (x) < 0 ? -(UQI) (x) : (UQI) (x)))
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))
90
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)))
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))
101extern HI RORHI (HI, int);
102extern HI ROLHI (HI, int);
103#define ANDHI(x, y) ((x) & (y))
104#define ORHI(x, y) ((x) | (y))
105#define XORHI(x, y) ((x) ^ (y))
106#define NEGHI(x) ((HI) (- (UHI) (x)))
107#define NOTHI(x) (! (HI) (x))
108#define INVHI(x) (~ (x))
109#define ABSHI(x) ((HI) ((HI) (x) < 0 ? -(UHI) (x) : (UHI) (x)))
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))
120
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)))
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))
131extern SI RORSI (SI, int);
132extern SI ROLSI (SI, int);
133#define ANDSI(x, y) ((x) & (y))
134#define ORSI(x, y) ((x) | (y))
135#define XORSI(x, y) ((x) ^ (y))
136#define NEGSI(x) ((SI) (- (USI) (x)))
137#define NOTSI(x) (! (SI) (x))
138#define INVSI(x) (~ (x))
139#define ABSSI(x) ((SI) ((SI) (x) < 0 ? -(USI) (x) : (USI) (x)))
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))
150
151#ifdef DI_FN_SUPPORT
152extern DI ADDDI (DI, DI);
153extern DI SUBDI (DI, DI);
154extern DI MULDI (DI, DI);
155extern DI DIVDI (DI, DI);
156extern DI UDIVDI (DI, DI);
157extern DI MODDI (DI, DI);
158extern DI UMODDI (DI, DI);
159extern DI SRADI (DI, int);
160extern UDI SRLDI (UDI, int);
161extern UDI SLLDI (UDI, int);
162extern DI RORDI (DI, int);
163extern DI ROLDI (DI, int);
164extern DI ANDDI (DI, DI);
165extern DI ORDI (DI, DI);
166extern DI XORDI (DI, DI);
167extern DI NEGDI (DI);
168extern int NOTDI (DI);
169extern DI INVDI (DI);
170extern int EQDI (DI, DI);
171extern int NEDI (DI, DI);
172extern int LTDI (DI, DI);
173extern int LEDI (DI, DI);
174extern int GTDI (DI, DI);
175extern int GEDI (DI, DI);
176extern int LTUDI (UDI, UDI);
177extern int LEUDI (UDI, UDI);
178extern int GTUDI (UDI, UDI);
179extern int GEUDI (UDI, UDI);
180#else /* ! DI_FN_SUPPORT */
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)))
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))
191extern DI RORDI (DI, int);
192extern DI ROLDI (DI, int);
193#define ANDDI(x, y) ((x) & (y))
194#define ORDI(x, y) ((x) | (y))
195#define XORDI(x, y) ((x) ^ (y))
196#define NEGDI(x) ((DI) (- (UDI) (x)))
197#define NOTDI(x) (! (DI) (x))
198#define INVDI(x) (~ (x))
199#define ABSDI(x) ((DI) ((DI) (x) < 0 ? -(UDI) (x) : (UDI) (x)))
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 */
211
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)
216extern DI EXTBIDI (BI);
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)
223extern DI EXTQIDI (QI);
224#else
225#define EXTQIDI(x) ((DI) (QI) (x))
226#endif
227#define EXTHIHI(x) ((HI) (HI) (x))
228#define EXTHISI(x) ((SI) (HI) (x))
229#define EXTSISI(x) ((SI) (SI) (x))
230#if defined (DI_FN_SUPPORT)
231extern DI EXTHIDI (HI);
232#else
233#define EXTHIDI(x) ((DI) (HI) (x))
234#endif
235#if defined (DI_FN_SUPPORT)
236extern DI EXTSIDI (SI);
237#else
238#define EXTSIDI(x) ((DI) (SI) (x))
239#endif
240
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)
245extern DI ZEXTBIDI (BI);
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)
252extern DI ZEXTQIDI (QI);
253#else
254#define ZEXTQIDI(x) ((DI) (UQI) (x))
255#endif
256#define ZEXTHISI(x) ((SI) (UHI) (x))
257#define ZEXTHIHI(x) ((HI) (UHI) (x))
258#define ZEXTSISI(x) ((SI) (USI) (x))
259#if defined (DI_FN_SUPPORT)
260extern DI ZEXTHIDI (HI);
261#else
262#define ZEXTHIDI(x) ((DI) (UHI) (x))
263#endif
264#if defined (DI_FN_SUPPORT)
265extern DI ZEXTSIDI (SI);
266#else
267#define ZEXTSIDI(x) ((DI) (USI) (x))
268#endif
269
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))
276#define TRUNCSISI(x) ((SI) (SI) (x))
277#if defined (DI_FN_SUPPORT)
278extern BI TRUNCDIBI (DI);
279#else
280#define TRUNCDIBI(x) ((BI) (DI) (x))
281#endif
282#if defined (DI_FN_SUPPORT)
283extern QI TRUNCDIQI (DI);
284#else
285#define TRUNCDIQI(x) ((QI) (DI) (x))
286#endif
287#if defined (DI_FN_SUPPORT)
288extern HI TRUNCDIHI (DI);
289#else
290#define TRUNCDIHI(x) ((HI) (DI) (x))
291#endif
292#if defined (DI_FN_SUPPORT)
293extern SI TRUNCDISI (DI);
294#else
295#define TRUNCDISI(x) ((SI) (DI) (x))
296#endif
297
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.  */
302
303#ifdef SEMOPS_DEFINE_INLINE
304
305SEMOPS_INLINE SF
306SUBWORDSISF (SI in)
307{
308  union { SI in; SF out; } x;
309  x.in = in;
310  return x.out;
311}
312
313SEMOPS_INLINE DF
314SUBWORDDIDF (DI in)
315{
316  union { DI in; DF out; } x;
317  x.in = in;
318  return x.out;
319}
320
321SEMOPS_INLINE QI
322SUBWORDSIQI (SI in, int byte)
323{
324  assert (byte >= 0 && byte <= 3);
325  return (UQI) (in >> (8 * (3 - byte))) & 0xFF;
326}
327
328SEMOPS_INLINE UQI
329SUBWORDSIUQI (SI in, int byte)
330{
331  assert (byte >= 0 && byte <= 3);
332  return (UQI) (in >> (8 * (3 - byte))) & 0xFF;
333}
334
335SEMOPS_INLINE QI
336SUBWORDDIQI (DI in, int byte)
337{
338  assert (byte >= 0 && byte <= 7);
339  return (UQI) (in >> (8 * (7 - byte))) & 0xFF;
340}
341
342SEMOPS_INLINE HI
343SUBWORDDIHI (DI in, int word)
344{
345  assert (word >= 0 && word <= 3);
346  return (UHI) (in >> (16 * (3 - word))) & 0xFFFF;
347}
348
349SEMOPS_INLINE HI
350SUBWORDSIHI (SI in, int word)
351{
352  if (word == 0)
353    return (USI) in >> 16;
354  else
355    return in;
356}
357
358SEMOPS_INLINE SI
359SUBWORDSFSI (SF in)
360{
361  union { SF in; SI out; } x;
362  x.in = in;
363  return x.out;
364}
365
366SEMOPS_INLINE DI
367SUBWORDDFDI (DF in)
368{
369  union { DF in; DI out; } x;
370  x.in = in;
371  return x.out;
372}
373
374SEMOPS_INLINE UQI
375SUBWORDDIUQI (DI in, int byte)
376{
377  assert (byte >= 0 && byte <= 7);
378  return (UQI) (in >> (8 * (7 - byte)));
379}
380
381SEMOPS_INLINE SI
382SUBWORDDISI (DI in, int word)
383{
384  if (word == 0)
385    return (UDI) in >> 32;
386  else
387    return in;
388}
389
390SEMOPS_INLINE SI
391SUBWORDDFSI (DF in, int word)
392{
393  /* Note: typedef UDI DF; */
394  if (word == 0)
395    return (UDI) in >> 32;
396  else
397    return in;
398}
399
400SEMOPS_INLINE SI
401SUBWORDXFSI (XF in, int word)
402{
403  /* Note: typedef struct { SI parts[3]; } XF; */
404  union { XF in; SI out[3]; } x;
405  x.in = in;
406  if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN)
407    return x.out[word];
408  else
409    return x.out[2 - word];
410}
411
412SEMOPS_INLINE SI
413SUBWORDTFSI (TF in, int word)
414{
415  /* Note: typedef struct { SI parts[4]; } TF; */
416  union { TF in; SI out[4]; } x;
417  x.in = in;
418  if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN)
419    return x.out[word];
420  else
421    return x.out[3 - word];
422}
423
424SEMOPS_INLINE DI
425JOINSIDI (SI x0, SI x1)
426{
427  return MAKEDI (x0, x1);
428}
429
430SEMOPS_INLINE DF
431JOINSIDF (SI x0, SI x1)
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
441SEMOPS_INLINE XF
442JOINSIXF (SI x0, SI x1, SI x2)
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
452SEMOPS_INLINE TF
453JOINSITF (SI x0, SI x1, SI x2, SI x3)
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
463#else
464
465QI SUBWORDSIQI (SI);
466HI SUBWORDSIHI (HI);
467SI SUBWORDSFSI (SF);
468SF SUBWORDSISF (SI);
469DI SUBWORDDFDI (DF);
470DF SUBWORDDIDF (DI);
471QI SUBWORDDIQI (DI, int);
472HI SUBWORDDIHI (DI, int);
473SI SUBWORDDISI (DI, int);
474SI SUBWORDDFSI (DF, int);
475SI SUBWORDXFSI (XF, int);
476SI SUBWORDTFSI (TF, int);
477
478UQI SUBWORDSIUQI (SI);
479UQI SUBWORDDIUQI (DI);
480
481DI JOINSIDI (SI, SI);
482DF JOINSIDF (SI, SI);
483XF JOINSIXF (SI, SI, SI);
484TF JOINSITF (SI, SI, SI, SI);
485
486#endif /* SUBWORD,JOIN */
487
488/* Semantic support utilities.  */
489
490#ifdef SEMOPS_DEFINE_INLINE
491
492SEMOPS_INLINE SI
493ADDCSI (SI a, SI b, BI c)
494{
495  SI res = ADDSI (a, ADDSI (b, c));
496  return res;
497}
498
499SEMOPS_INLINE BI
500ADDCFSI (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
507SEMOPS_INLINE BI
508ADDOFSI (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
516SEMOPS_INLINE SI
517SUBCSI (SI a, SI b, BI c)
518{
519  SI res = SUBSI (a, ADDSI (b, c));
520  return res;
521}
522
523SEMOPS_INLINE BI
524SUBCFSI (SI a, SI b, BI c)
525{
526  BI res = ((USI) a < (USI) b) || (c && a == b);
527  return res;
528}
529
530SEMOPS_INLINE BI
531SUBOFSI (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
539SEMOPS_INLINE HI
540ADDCHI (HI a, HI b, BI c)
541{
542  HI res = ADDHI (a, ADDHI (b, c));
543  return res;
544}
545
546SEMOPS_INLINE BI
547ADDCFHI (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
554SEMOPS_INLINE BI
555ADDOFHI (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
563SEMOPS_INLINE HI
564SUBCHI (HI a, HI b, BI c)
565{
566  HI res = SUBHI (a, ADDHI (b, c));
567  return res;
568}
569
570SEMOPS_INLINE BI
571SUBCFHI (HI a, HI b, BI c)
572{
573  BI res = ((UHI) a < (UHI) b) || (c && a == b);
574  return res;
575}
576
577SEMOPS_INLINE BI
578SUBOFHI (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
586SEMOPS_INLINE QI
587ADDCQI (QI a, QI b, BI c)
588{
589  QI res = ADDQI (a, ADDQI (b, c));
590  return res;
591}
592
593SEMOPS_INLINE BI
594ADDCFQI (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
601SEMOPS_INLINE BI
602ADDOFQI (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
610SEMOPS_INLINE QI
611SUBCQI (QI a, QI b, BI c)
612{
613  QI res = SUBQI (a, ADDQI (b, c));
614  return res;
615}
616
617SEMOPS_INLINE BI
618SUBCFQI (QI a, QI b, BI c)
619{
620  BI res = ((UQI) a < (UQI) b) || (c && a == b);
621  return res;
622}
623
624SEMOPS_INLINE BI
625SUBOFQI (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
633#else
634
635SI ADDCSI (SI, SI, BI);
636UBI ADDCFSI (SI, SI, BI);
637UBI ADDOFSI (SI, SI, BI);
638SI SUBCSI (SI, SI, BI);
639UBI SUBCFSI (SI, SI, BI);
640UBI SUBOFSI (SI, SI, BI);
641HI ADDCHI (HI, HI, BI);
642UBI ADDCFHI (HI, HI, BI);
643UBI ADDOFHI (HI, HI, BI);
644HI SUBCHI (HI, HI, BI);
645UBI SUBCFHI (HI, HI, BI);
646UBI SUBOFHI (HI, HI, BI);
647QI ADDCQI (QI, QI, BI);
648UBI ADDCFQI (QI, QI, BI);
649UBI ADDOFQI (QI, QI, BI);
650QI SUBCQI (QI, QI, BI);
651UBI SUBCFQI (QI, QI, BI);
652UBI SUBOFQI (QI, QI, BI);
653
654#endif
655
656#endif /* CGEN_SEM_OPS_H */
657