Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Semantics ops support for CGEN-based simulators. |
7a292a7a | 2 | Copyright (C) 1996, 1997, 1998, 1999 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 | |
9 | the Free Software Foundation; either version 2, or (at your option) | |
10 | 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 along | |
18 | with this program; if not, write to the Free Software Foundation, Inc., | |
19 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
20 | ||
21 | */ | |
22 | ||
23 | #ifndef CGEN_SEM_OPS_H | |
24 | #define CGEN_SEM_OPS_H | |
25 | ||
7a292a7a SS |
26 | #if defined (__GNUC__) && ! defined (SEMOPS_DEFINE_INLINE) |
27 | #define SEMOPS_DEFINE_INLINE | |
28 | #define SEMOPS_INLINE extern inline | |
29 | #else | |
30 | #define SEMOPS_INLINE | |
31 | #endif | |
32 | ||
c906108c SS |
33 | /* Semantic operations. |
34 | At one point this file was machine generated. Maybe it will be again. */ | |
35 | ||
43ff13b4 JM |
36 | /* TODO: Lazy encoding/decoding of fp values. */ |
37 | ||
c906108c SS |
38 | /* These don't really have a mode. */ |
39 | #define ANDIF(x, y) ((x) && (y)) | |
40 | #define ORIF(x, y) ((x) || (y)) | |
41 | ||
42 | #define ANDBI(x, y) ((x) & (y)) | |
43 | #define ORBI(x, y) ((x) | (y)) | |
44 | #define XORBI(x, y) ((x) ^ (y)) | |
45 | #define NEGBI(x) (- (x)) | |
46 | #define NOTBI(x) (! (BI) (x)) | |
47 | #define INVBI(x) (~ (x)) | |
48 | #define EQBI(x, y) ((BI) (x) == (BI) (y)) | |
49 | #define NEBI(x, y) ((BI) (x) != (BI) (y)) | |
50 | #define LTBI(x, y) ((BI) (x) < (BI) (y)) | |
51 | #define LEBI(x, y) ((BI) (x) <= (BI) (y)) | |
52 | #define GTBI(x, y) ((BI) (x) > (BI) (y)) | |
53 | #define GEBI(x, y) ((BI) (x) >= (BI) (y)) | |
54 | #define LTUBI(x, y) ((BI) (x) < (BI) (y)) | |
55 | #define LEUBI(x, y) ((BI) (x) <= (BI) (y)) | |
56 | #define GTUBI(x, y) ((BI) (x) > (BI) (y)) | |
57 | #define GEUBI(x, y) ((BI) (x) >= (BI) (y)) | |
43ff13b4 | 58 | \f |
c906108c SS |
59 | #define ADDQI(x, y) ((x) + (y)) |
60 | #define SUBQI(x, y) ((x) - (y)) | |
61 | #define MULQI(x, y) ((x) * (y)) | |
62 | #define DIVQI(x, y) ((QI) (x) / (QI) (y)) | |
63 | #define UDIVQI(x, y) ((UQI) (x) / (UQI) (y)) | |
64 | #define MODQI(x, y) ((QI) (x) % (QI) (y)) | |
65 | #define UMODQI(x, y) ((UQI) (x) % (UQI) (y)) | |
66 | #define SRAQI(x, y) ((QI) (x) >> (y)) | |
67 | #define SRLQI(x, y) ((UQI) (x) >> (y)) | |
68 | #define SLLQI(x, y) ((UQI) (x) << (y)) | |
43ff13b4 JM |
69 | extern QI RORQI (QI, int); |
70 | extern QI ROLQI (QI, int); | |
c906108c SS |
71 | #define ANDQI(x, y) ((x) & (y)) |
72 | #define ORQI(x, y) ((x) | (y)) | |
73 | #define XORQI(x, y) ((x) ^ (y)) | |
74 | #define NEGQI(x) (- (x)) | |
75 | #define NOTQI(x) (! (QI) (x)) | |
76 | #define INVQI(x) (~ (x)) | |
0fda6bd2 | 77 | #define ABSQI(x) ((x) < 0 ? -(x) : (x)) |
c906108c SS |
78 | #define EQQI(x, y) ((QI) (x) == (QI) (y)) |
79 | #define NEQI(x, y) ((QI) (x) != (QI) (y)) | |
80 | #define LTQI(x, y) ((QI) (x) < (QI) (y)) | |
81 | #define LEQI(x, y) ((QI) (x) <= (QI) (y)) | |
82 | #define GTQI(x, y) ((QI) (x) > (QI) (y)) | |
83 | #define GEQI(x, y) ((QI) (x) >= (QI) (y)) | |
84 | #define LTUQI(x, y) ((UQI) (x) < (UQI) (y)) | |
85 | #define LEUQI(x, y) ((UQI) (x) <= (UQI) (y)) | |
86 | #define GTUQI(x, y) ((UQI) (x) > (UQI) (y)) | |
87 | #define GEUQI(x, y) ((UQI) (x) >= (UQI) (y)) | |
43ff13b4 | 88 | \f |
c906108c SS |
89 | #define ADDHI(x, y) ((x) + (y)) |
90 | #define SUBHI(x, y) ((x) - (y)) | |
91 | #define MULHI(x, y) ((x) * (y)) | |
92 | #define DIVHI(x, y) ((HI) (x) / (HI) (y)) | |
93 | #define UDIVHI(x, y) ((UHI) (x) / (UHI) (y)) | |
94 | #define MODHI(x, y) ((HI) (x) % (HI) (y)) | |
95 | #define UMODHI(x, y) ((UHI) (x) % (UHI) (y)) | |
96 | #define SRAHI(x, y) ((HI) (x) >> (y)) | |
97 | #define SRLHI(x, y) ((UHI) (x) >> (y)) | |
98 | #define SLLHI(x, y) ((UHI) (x) << (y)) | |
43ff13b4 JM |
99 | extern HI RORHI (HI, int); |
100 | extern HI ROLHI (HI, int); | |
c906108c SS |
101 | #define ANDHI(x, y) ((x) & (y)) |
102 | #define ORHI(x, y) ((x) | (y)) | |
103 | #define XORHI(x, y) ((x) ^ (y)) | |
104 | #define NEGHI(x) (- (x)) | |
105 | #define NOTHI(x) (! (HI) (x)) | |
106 | #define INVHI(x) (~ (x)) | |
0fda6bd2 | 107 | #define ABSHI(x) ((x) < 0 ? -(x) : (x)) |
c906108c SS |
108 | #define EQHI(x, y) ((HI) (x) == (HI) (y)) |
109 | #define NEHI(x, y) ((HI) (x) != (HI) (y)) | |
110 | #define LTHI(x, y) ((HI) (x) < (HI) (y)) | |
111 | #define LEHI(x, y) ((HI) (x) <= (HI) (y)) | |
112 | #define GTHI(x, y) ((HI) (x) > (HI) (y)) | |
113 | #define GEHI(x, y) ((HI) (x) >= (HI) (y)) | |
114 | #define LTUHI(x, y) ((UHI) (x) < (UHI) (y)) | |
115 | #define LEUHI(x, y) ((UHI) (x) <= (UHI) (y)) | |
116 | #define GTUHI(x, y) ((UHI) (x) > (UHI) (y)) | |
117 | #define GEUHI(x, y) ((UHI) (x) >= (UHI) (y)) | |
43ff13b4 | 118 | \f |
c906108c SS |
119 | #define ADDSI(x, y) ((x) + (y)) |
120 | #define SUBSI(x, y) ((x) - (y)) | |
121 | #define MULSI(x, y) ((x) * (y)) | |
122 | #define DIVSI(x, y) ((SI) (x) / (SI) (y)) | |
123 | #define UDIVSI(x, y) ((USI) (x) / (USI) (y)) | |
124 | #define MODSI(x, y) ((SI) (x) % (SI) (y)) | |
125 | #define UMODSI(x, y) ((USI) (x) % (USI) (y)) | |
126 | #define SRASI(x, y) ((SI) (x) >> (y)) | |
127 | #define SRLSI(x, y) ((USI) (x) >> (y)) | |
128 | #define SLLSI(x, y) ((USI) (x) << (y)) | |
43ff13b4 JM |
129 | extern SI RORSI (SI, int); |
130 | extern SI ROLSI (SI, int); | |
c906108c SS |
131 | #define ANDSI(x, y) ((x) & (y)) |
132 | #define ORSI(x, y) ((x) | (y)) | |
133 | #define XORSI(x, y) ((x) ^ (y)) | |
134 | #define NEGSI(x) (- (x)) | |
135 | #define NOTSI(x) (! (SI) (x)) | |
136 | #define INVSI(x) (~ (x)) | |
0fda6bd2 | 137 | #define ABSSI(x) ((x) < 0 ? -(x) : (x)) |
c906108c SS |
138 | #define EQSI(x, y) ((SI) (x) == (SI) (y)) |
139 | #define NESI(x, y) ((SI) (x) != (SI) (y)) | |
140 | #define LTSI(x, y) ((SI) (x) < (SI) (y)) | |
141 | #define LESI(x, y) ((SI) (x) <= (SI) (y)) | |
142 | #define GTSI(x, y) ((SI) (x) > (SI) (y)) | |
143 | #define GESI(x, y) ((SI) (x) >= (SI) (y)) | |
144 | #define LTUSI(x, y) ((USI) (x) < (USI) (y)) | |
145 | #define LEUSI(x, y) ((USI) (x) <= (USI) (y)) | |
146 | #define GTUSI(x, y) ((USI) (x) > (USI) (y)) | |
147 | #define GEUSI(x, y) ((USI) (x) >= (USI) (y)) | |
43ff13b4 | 148 | \f |
c906108c | 149 | #ifdef DI_FN_SUPPORT |
43ff13b4 JM |
150 | extern DI ADDDI (DI, DI); |
151 | extern DI SUBDI (DI, DI); | |
152 | extern DI MULDI (DI, DI); | |
153 | extern DI DIVDI (DI, DI); | |
154 | extern DI UDIVDI (DI, DI); | |
155 | extern DI MODDI (DI, DI); | |
156 | extern DI UMODDI (DI, DI); | |
157 | extern DI SRADI (DI, int); | |
158 | extern UDI SRLDI (UDI, int); | |
159 | extern UDI SLLDI (UDI, int); | |
160 | extern DI RORDI (DI, int); | |
161 | extern DI ROLDI (DI, int); | |
162 | extern DI ANDDI (DI, DI); | |
163 | extern DI ORDI (DI, DI); | |
164 | extern DI XORDI (DI, DI); | |
165 | extern DI NEGDI (DI); | |
166 | extern int NOTDI (DI); | |
167 | extern DI INVDI (DI); | |
168 | extern int EQDI (DI, DI); | |
169 | extern int NEDI (DI, DI); | |
170 | extern int LTDI (DI, DI); | |
171 | extern int LEDI (DI, DI); | |
172 | extern int GTDI (DI, DI); | |
173 | extern int GEDI (DI, DI); | |
174 | extern int LTUDI (UDI, UDI); | |
175 | extern int LEUDI (UDI, UDI); | |
176 | extern int GTUDI (UDI, UDI); | |
177 | extern int GEUDI (UDI, UDI); | |
c906108c SS |
178 | #else /* ! DI_FN_SUPPORT */ |
179 | #define ADDDI(x, y) ((x) + (y)) | |
180 | #define SUBDI(x, y) ((x) - (y)) | |
181 | #define MULDI(x, y) ((x) * (y)) | |
182 | #define DIVDI(x, y) ((DI) (x) / (DI) (y)) | |
183 | #define UDIVDI(x, y) ((UDI) (x) / (UDI) (y)) | |
184 | #define MODDI(x, y) ((DI) (x) % (DI) (y)) | |
185 | #define UMODDI(x, y) ((UDI) (x) % (UDI) (y)) | |
186 | #define SRADI(x, y) ((DI) (x) >> (y)) | |
187 | #define SRLDI(x, y) ((UDI) (x) >> (y)) | |
188 | #define SLLDI(x, y) ((UDI) (x) << (y)) | |
43ff13b4 JM |
189 | extern DI RORDI (DI, int); |
190 | extern DI ROLDI (DI, int); | |
c906108c SS |
191 | #define ANDDI(x, y) ((x) & (y)) |
192 | #define ORDI(x, y) ((x) | (y)) | |
193 | #define XORDI(x, y) ((x) ^ (y)) | |
194 | #define NEGDI(x) (- (x)) | |
195 | #define NOTDI(x) (! (DI) (x)) | |
196 | #define INVDI(x) (~ (x)) | |
0fda6bd2 | 197 | #define ABSDI(x) ((x) < 0 ? -(x) : (x)) |
c906108c SS |
198 | #define EQDI(x, y) ((DI) (x) == (DI) (y)) |
199 | #define NEDI(x, y) ((DI) (x) != (DI) (y)) | |
200 | #define LTDI(x, y) ((DI) (x) < (DI) (y)) | |
201 | #define LEDI(x, y) ((DI) (x) <= (DI) (y)) | |
202 | #define GTDI(x, y) ((DI) (x) > (DI) (y)) | |
203 | #define GEDI(x, y) ((DI) (x) >= (DI) (y)) | |
204 | #define LTUDI(x, y) ((UDI) (x) < (UDI) (y)) | |
205 | #define LEUDI(x, y) ((UDI) (x) <= (UDI) (y)) | |
206 | #define GTUDI(x, y) ((UDI) (x) > (UDI) (y)) | |
207 | #define GEUDI(x, y) ((UDI) (x) >= (UDI) (y)) | |
208 | #endif /* DI_FN_SUPPORT */ | |
43ff13b4 | 209 | \f |
c906108c SS |
210 | #define EXTBIQI(x) ((QI) (BI) (x)) |
211 | #define EXTBIHI(x) ((HI) (BI) (x)) | |
212 | #define EXTBISI(x) ((SI) (BI) (x)) | |
213 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 214 | extern DI EXTBIDI (BI); |
c906108c SS |
215 | #else |
216 | #define EXTBIDI(x) ((DI) (BI) (x)) | |
217 | #endif | |
218 | #define EXTQIHI(x) ((HI) (QI) (x)) | |
219 | #define EXTQISI(x) ((SI) (QI) (x)) | |
220 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 221 | extern DI EXTQIDI (QI); |
c906108c SS |
222 | #else |
223 | #define EXTQIDI(x) ((DI) (QI) (x)) | |
224 | #endif | |
f743149e | 225 | #define EXTHIHI(x) ((HI) (HI) (x)) |
c906108c | 226 | #define EXTHISI(x) ((SI) (HI) (x)) |
0fda6bd2 | 227 | #define EXTSISI(x) ((SI) (SI) (x)) |
c906108c | 228 | #if defined (DI_FN_SUPPORT) |
43ff13b4 | 229 | extern DI EXTHIDI (HI); |
c906108c SS |
230 | #else |
231 | #define EXTHIDI(x) ((DI) (HI) (x)) | |
232 | #endif | |
233 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 234 | extern DI EXTSIDI (SI); |
c906108c SS |
235 | #else |
236 | #define EXTSIDI(x) ((DI) (SI) (x)) | |
237 | #endif | |
43ff13b4 | 238 | \f |
c906108c SS |
239 | #define ZEXTBIQI(x) ((QI) (BI) (x)) |
240 | #define ZEXTBIHI(x) ((HI) (BI) (x)) | |
241 | #define ZEXTBISI(x) ((SI) (BI) (x)) | |
242 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 243 | extern DI ZEXTBIDI (BI); |
c906108c SS |
244 | #else |
245 | #define ZEXTBIDI(x) ((DI) (BI) (x)) | |
246 | #endif | |
247 | #define ZEXTQIHI(x) ((HI) (UQI) (x)) | |
248 | #define ZEXTQISI(x) ((SI) (UQI) (x)) | |
249 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 250 | extern DI ZEXTQIDI (QI); |
c906108c SS |
251 | #else |
252 | #define ZEXTQIDI(x) ((DI) (UQI) (x)) | |
253 | #endif | |
254 | #define ZEXTHISI(x) ((SI) (UHI) (x)) | |
0fda6bd2 JM |
255 | #define ZEXTHIHI(x) ((HI) (UHI) (x)) |
256 | #define ZEXTSISI(x) ((SI) (USI) (x)) | |
c906108c | 257 | #if defined (DI_FN_SUPPORT) |
43ff13b4 | 258 | extern DI ZEXTHIDI (HI); |
c906108c SS |
259 | #else |
260 | #define ZEXTHIDI(x) ((DI) (UHI) (x)) | |
261 | #endif | |
262 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 263 | extern DI ZEXTSIDI (SI); |
c906108c SS |
264 | #else |
265 | #define ZEXTSIDI(x) ((DI) (USI) (x)) | |
266 | #endif | |
43ff13b4 | 267 | \f |
c906108c SS |
268 | #define TRUNCQIBI(x) ((BI) (QI) (x)) |
269 | #define TRUNCHIBI(x) ((BI) (HI) (x)) | |
270 | #define TRUNCHIQI(x) ((QI) (HI) (x)) | |
271 | #define TRUNCSIBI(x) ((BI) (SI) (x)) | |
272 | #define TRUNCSIQI(x) ((QI) (SI) (x)) | |
273 | #define TRUNCSIHI(x) ((HI) (SI) (x)) | |
274 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 275 | extern BI TRUNCDIBI (DI); |
c906108c SS |
276 | #else |
277 | #define TRUNCDIBI(x) ((BI) (DI) (x)) | |
278 | #endif | |
279 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 280 | extern QI TRUNCDIQI (DI); |
c906108c SS |
281 | #else |
282 | #define TRUNCDIQI(x) ((QI) (DI) (x)) | |
283 | #endif | |
284 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 285 | extern HI TRUNCDIHI (DI); |
c906108c SS |
286 | #else |
287 | #define TRUNCDIHI(x) ((HI) (DI) (x)) | |
288 | #endif | |
289 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 290 | extern SI TRUNCDISI (DI); |
c906108c SS |
291 | #else |
292 | #define TRUNCDISI(x) ((SI) (DI) (x)) | |
293 | #endif | |
c906108c | 294 | \f |
6426a772 JM |
295 | /* Composing/decomposing the various types. |
296 | Word ordering is endian-independent. Words are specified most to least | |
297 | significant and word number 0 is the most significant word. | |
298 | ??? May also wish an endian-dependent version. Later. */ | |
43ff13b4 | 299 | |
c906108c | 300 | #ifdef SEMOPS_DEFINE_INLINE |
7a292a7a SS |
301 | |
302 | SEMOPS_INLINE SF | |
6426a772 | 303 | SUBWORDSISF (SI in) |
7a292a7a SS |
304 | { |
305 | union { SI in; SF out; } x; | |
306 | x.in = in; | |
307 | return x.out; | |
308 | } | |
309 | ||
310 | SEMOPS_INLINE SI | |
6426a772 | 311 | SUBWORDSFSI (SF in) |
7a292a7a SS |
312 | { |
313 | union { SF in; SI out; } x; | |
314 | x.in = in; | |
315 | return x.out; | |
316 | } | |
317 | ||
318 | SEMOPS_INLINE SI | |
6426a772 | 319 | SUBWORDDISI (DI in, int word) |
7a292a7a | 320 | { |
6426a772 JM |
321 | if (word == 0) |
322 | return (UDI) in >> 32; | |
7a292a7a | 323 | else |
6426a772 | 324 | return in; |
7a292a7a SS |
325 | } |
326 | ||
327 | SEMOPS_INLINE SI | |
6426a772 | 328 | SUBWORDDFSI (DF in, int word) |
7a292a7a | 329 | { |
6426a772 JM |
330 | /* Note: typedef UDI DF; */ |
331 | if (word == 0) | |
332 | return (UDI) in >> 32; | |
7a292a7a | 333 | else |
6426a772 | 334 | return in; |
7a292a7a SS |
335 | } |
336 | ||
43ff13b4 | 337 | SEMOPS_INLINE SI |
6426a772 | 338 | SUBWORDXFSI (XF in, int word) |
43ff13b4 | 339 | { |
6426a772 | 340 | /* Note: typedef struct { SI parts[3]; } XF; */ |
43ff13b4 JM |
341 | union { XF in; SI out[3]; } x; |
342 | x.in = in; | |
6426a772 | 343 | return x.out[word]; |
43ff13b4 JM |
344 | } |
345 | ||
7a292a7a | 346 | SEMOPS_INLINE SI |
6426a772 | 347 | SUBWORDTFSI (TF in, int word) |
7a292a7a | 348 | { |
6426a772 | 349 | /* Note: typedef struct { SI parts[4]; } TF; */ |
7a292a7a SS |
350 | union { TF in; SI out[4]; } x; |
351 | x.in = in; | |
6426a772 | 352 | return x.out[word]; |
7a292a7a SS |
353 | } |
354 | ||
355 | SEMOPS_INLINE DI | |
6426a772 | 356 | JOINSIDI (SI x0, SI x1) |
7a292a7a SS |
357 | { |
358 | if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN) | |
359 | return MAKEDI (x0, x1); | |
360 | else | |
361 | return MAKEDI (x1, x0); | |
362 | } | |
363 | ||
364 | SEMOPS_INLINE DF | |
6426a772 | 365 | JOINSIDF (SI x0, SI x1) |
7a292a7a SS |
366 | { |
367 | union { SI in[2]; DF out; } x; | |
368 | if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN) | |
369 | x.in[0] = x0, x.in[1] = x1; | |
370 | else | |
371 | x.in[1] = x0, x.in[0] = x1; | |
372 | return x.out; | |
373 | } | |
374 | ||
43ff13b4 | 375 | SEMOPS_INLINE XF |
6426a772 | 376 | JOINSIXF (SI x0, SI x1, SI x2) |
43ff13b4 JM |
377 | { |
378 | union { SI in[3]; XF out; } x; | |
379 | if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN) | |
380 | x.in[0] = x0, x.in[1] = x1, x.in[2] = x2; | |
381 | else | |
382 | x.in[2] = x0, x.in[1] = x1, x.in[0] = x2; | |
383 | return x.out; | |
384 | } | |
385 | ||
7a292a7a | 386 | SEMOPS_INLINE TF |
6426a772 | 387 | JOINSITF (SI x0, SI x1, SI x2, SI x3) |
7a292a7a SS |
388 | { |
389 | union { SI in[4]; TF out; } x; | |
390 | if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN) | |
391 | x.in[0] = x0, x.in[1] = x1, x.in[2] = x2, x.in[3] = x3; | |
392 | else | |
393 | x.in[3] = x0, x.in[2] = x1, x.in[1] = x2, x.in[0] = x3; | |
394 | return x.out; | |
395 | } | |
396 | ||
c906108c | 397 | #else |
7a292a7a | 398 | |
6426a772 JM |
399 | SF SUBWORDSISF (SI); |
400 | SI SUBWORDSFSI (SF); | |
401 | SI SUBWORDDISI (DI, int); | |
402 | SI SUBWORDDFSI (DF, int); | |
403 | SI SUBWORDXFSI (XF, int); | |
404 | SI SUBWORDTFSI (TF, int); | |
7a292a7a | 405 | |
6426a772 JM |
406 | DI JOINSIDI (SI, SI); |
407 | DF JOINSIDF (SI, SI); | |
408 | XF JOINSIXF (SI, SI, SI); | |
409 | TF JOINSITF (SI, SI, SI, SI); | |
7a292a7a SS |
410 | |
411 | #endif /* SUBWORD,JOIN */ | |
412 | \f | |
413 | /* Semantic support utilities. */ | |
414 | ||
415 | #ifdef SEMOPS_DEFINE_INLINE | |
c906108c SS |
416 | |
417 | SEMOPS_INLINE SI | |
418 | ADDCSI (SI a, SI b, BI c) | |
419 | { | |
420 | SI res = ADDSI (a, ADDSI (b, c)); | |
421 | return res; | |
422 | } | |
423 | ||
424 | SEMOPS_INLINE BI | |
425 | ADDCFSI (SI a, SI b, BI c) | |
426 | { | |
427 | SI tmp = ADDSI (a, ADDSI (b, c)); | |
428 | BI res = ((USI) tmp < (USI) a) || (c && tmp == a); | |
429 | return res; | |
430 | } | |
431 | ||
432 | SEMOPS_INLINE BI | |
433 | ADDOFSI (SI a, SI b, BI c) | |
434 | { | |
435 | SI tmp = ADDSI (a, ADDSI (b, c)); | |
436 | BI res = (((a < 0) == (b < 0)) | |
437 | && ((a < 0) != (tmp < 0))); | |
438 | return res; | |
439 | } | |
440 | ||
441 | SEMOPS_INLINE SI | |
442 | SUBCSI (SI a, SI b, BI c) | |
443 | { | |
444 | SI res = SUBSI (a, ADDSI (b, c)); | |
445 | return res; | |
446 | } | |
447 | ||
448 | SEMOPS_INLINE BI | |
449 | SUBCFSI (SI a, SI b, BI c) | |
450 | { | |
451 | BI res = ((USI) a < (USI) b) || (c && a == b); | |
452 | return res; | |
453 | } | |
454 | ||
455 | SEMOPS_INLINE BI | |
456 | SUBOFSI (SI a, SI b, BI c) | |
457 | { | |
458 | SI tmp = SUBSI (a, ADDSI (b, c)); | |
459 | BI res = (((a < 0) != (b < 0)) | |
460 | && ((a < 0) != (tmp < 0))); | |
461 | return res; | |
462 | } | |
463 | ||
0fda6bd2 JM |
464 | SEMOPS_INLINE HI |
465 | ADDCHI (HI a, HI b, BI c) | |
466 | { | |
467 | HI res = ADDHI (a, ADDHI (b, c)); | |
468 | return res; | |
469 | } | |
470 | ||
471 | SEMOPS_INLINE BI | |
472 | ADDCFHI (HI a, HI b, BI c) | |
473 | { | |
474 | HI tmp = ADDHI (a, ADDHI (b, c)); | |
475 | BI res = ((UHI) tmp < (UHI) a) || (c && tmp == a); | |
476 | return res; | |
477 | } | |
478 | ||
479 | SEMOPS_INLINE BI | |
480 | ADDOFHI (HI a, HI b, BI c) | |
481 | { | |
482 | HI tmp = ADDHI (a, ADDHI (b, c)); | |
483 | BI res = (((a < 0) == (b < 0)) | |
484 | && ((a < 0) != (tmp < 0))); | |
485 | return res; | |
486 | } | |
487 | ||
488 | SEMOPS_INLINE HI | |
489 | SUBCHI (HI a, HI b, BI c) | |
490 | { | |
491 | HI res = SUBHI (a, ADDHI (b, c)); | |
492 | return res; | |
493 | } | |
494 | ||
495 | SEMOPS_INLINE BI | |
496 | SUBCFHI (HI a, HI b, BI c) | |
497 | { | |
498 | BI res = ((UHI) a < (UHI) b) || (c && a == b); | |
499 | return res; | |
500 | } | |
501 | ||
502 | SEMOPS_INLINE BI | |
503 | SUBOFHI (HI a, HI b, BI c) | |
504 | { | |
505 | HI tmp = SUBHI (a, ADDHI (b, c)); | |
506 | BI res = (((a < 0) != (b < 0)) | |
507 | && ((a < 0) != (tmp < 0))); | |
508 | return res; | |
509 | } | |
510 | ||
c906108c SS |
511 | #else |
512 | ||
513 | SI ADDCSI (SI, SI, BI); | |
514 | UBI ADDCFSI (SI, SI, BI); | |
515 | UBI ADDOFSI (SI, SI, BI); | |
516 | SI SUBCSI (SI, SI, BI); | |
517 | UBI SUBCFSI (SI, SI, BI); | |
518 | UBI SUBOFSI (SI, SI, BI); | |
0fda6bd2 JM |
519 | HI ADDCHI (HI, HI, BI); |
520 | UBI ADDCFHI (HI, HI, BI); | |
521 | UBI ADDOFHI (HI, HI, BI); | |
522 | HI SUBCHI (HI, HI, BI); | |
523 | UBI SUBCFHI (HI, HI, BI); | |
524 | UBI SUBOFHI (HI, HI, BI); | |
c906108c SS |
525 | |
526 | #endif | |
c906108c SS |
527 | |
528 | #endif /* CGEN_SEM_OPS_H */ |