]>
Commit | Line | Data |
---|---|---|
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 | ||
6 | This file is part of the GNU Simulators. | |
7 | ||
8 | This program is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 2, or (at your option) | |
11 | any later version. | |
12 | ||
13 | This program is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License along | |
19 | with this program; if not, write to the Free Software Foundation, Inc., | |
20 | 59 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 |
73 | extern QI RORQI (QI, int); |
74 | extern 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 |
103 | extern HI RORHI (HI, int); |
104 | extern 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 |
133 | extern SI RORSI (SI, int); |
134 | extern 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 |
154 | extern DI ADDDI (DI, DI); |
155 | extern DI SUBDI (DI, DI); | |
156 | extern DI MULDI (DI, DI); | |
157 | extern DI DIVDI (DI, DI); | |
158 | extern DI UDIVDI (DI, DI); | |
159 | extern DI MODDI (DI, DI); | |
160 | extern DI UMODDI (DI, DI); | |
161 | extern DI SRADI (DI, int); | |
162 | extern UDI SRLDI (UDI, int); | |
163 | extern UDI SLLDI (UDI, int); | |
164 | extern DI RORDI (DI, int); | |
165 | extern DI ROLDI (DI, int); | |
166 | extern DI ANDDI (DI, DI); | |
167 | extern DI ORDI (DI, DI); | |
168 | extern DI XORDI (DI, DI); | |
169 | extern DI NEGDI (DI); | |
170 | extern int NOTDI (DI); | |
171 | extern DI INVDI (DI); | |
172 | extern int EQDI (DI, DI); | |
173 | extern int NEDI (DI, DI); | |
174 | extern int LTDI (DI, DI); | |
175 | extern int LEDI (DI, DI); | |
176 | extern int GTDI (DI, DI); | |
177 | extern int GEDI (DI, DI); | |
178 | extern int LTUDI (UDI, UDI); | |
179 | extern int LEUDI (UDI, UDI); | |
180 | extern int GTUDI (UDI, UDI); | |
181 | extern 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 |
193 | extern DI RORDI (DI, int); |
194 | extern 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 | 218 | extern 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 | 225 | extern 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 | 233 | extern DI EXTHIDI (HI); |
c906108c SS |
234 | #else |
235 | #define EXTHIDI(x) ((DI) (HI) (x)) | |
236 | #endif | |
237 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 238 | extern 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 | 247 | extern 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 | 254 | extern 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 | 262 | extern DI ZEXTHIDI (HI); |
c906108c SS |
263 | #else |
264 | #define ZEXTHIDI(x) ((DI) (UHI) (x)) | |
265 | #endif | |
266 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 267 | extern 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 | 280 | extern BI TRUNCDIBI (DI); |
c906108c SS |
281 | #else |
282 | #define TRUNCDIBI(x) ((BI) (DI) (x)) | |
283 | #endif | |
284 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 285 | extern QI TRUNCDIQI (DI); |
c906108c SS |
286 | #else |
287 | #define TRUNCDIQI(x) ((QI) (DI) (x)) | |
288 | #endif | |
289 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 290 | extern HI TRUNCDIHI (DI); |
c906108c SS |
291 | #else |
292 | #define TRUNCDIHI(x) ((HI) (DI) (x)) | |
293 | #endif | |
294 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 295 | extern 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 | |
307 | SEMOPS_INLINE SF | |
6426a772 | 308 | SUBWORDSISF (SI in) |
7a292a7a SS |
309 | { |
310 | union { SI in; SF out; } x; | |
311 | x.in = in; | |
312 | return x.out; | |
313 | } | |
314 | ||
4f49fa1b BE |
315 | SEMOPS_INLINE DF |
316 | SUBWORDDIDF (DI in) | |
317 | { | |
318 | union { DI in; DF out; } x; | |
319 | x.in = in; | |
320 | return x.out; | |
321 | } | |
322 | ||
323 | SEMOPS_INLINE QI | |
324 | SUBWORDSIQI (SI in, int byte) | |
325 | { | |
326 | assert (byte >= 0 && byte <= 3); | |
6227bc85 | 327 | return (UQI) (in >> (8 * (3 - byte))) & 0xFF; |
4f49fa1b BE |
328 | } |
329 | ||
330 | SEMOPS_INLINE UQI | |
331 | SUBWORDSIUQI (SI in, int byte) | |
332 | { | |
333 | assert (byte >= 0 && byte <= 3); | |
6227bc85 BE |
334 | return (UQI) (in >> (8 * (3 - byte))) & 0xFF; |
335 | } | |
336 | ||
337 | SEMOPS_INLINE QI | |
338 | SUBWORDDIQI (DI in, int byte) | |
339 | { | |
340 | assert (byte >= 0 && byte <= 7); | |
341 | return (UQI) (in >> (8 * (7 - byte))) & 0xFF; | |
4f49fa1b BE |
342 | } |
343 | ||
344 | SEMOPS_INLINE HI | |
345 | SUBWORDDIHI (DI in, int word) | |
346 | { | |
347 | assert (word >= 0 && word <= 3); | |
6227bc85 | 348 | return (UHI) (in >> (16 * (3 - word))) & 0xFFFF; |
4f49fa1b BE |
349 | } |
350 | ||
351 | SEMOPS_INLINE HI | |
352 | SUBWORDSIHI (SI in, int word) | |
353 | { | |
354 | if (word == 0) | |
355 | return (USI) in >> 16; | |
356 | else | |
357 | return in; | |
358 | } | |
359 | ||
7a292a7a | 360 | SEMOPS_INLINE SI |
6426a772 | 361 | SUBWORDSFSI (SF in) |
7a292a7a SS |
362 | { |
363 | union { SF in; SI out; } x; | |
364 | x.in = in; | |
365 | return x.out; | |
366 | } | |
367 | ||
0d277f51 BE |
368 | SEMOPS_INLINE DI |
369 | SUBWORDDFDI (DF in) | |
370 | { | |
371 | union { DF in; DI out; } x; | |
372 | x.in = in; | |
373 | return x.out; | |
374 | } | |
375 | ||
4f49fa1b BE |
376 | SEMOPS_INLINE UQI |
377 | SUBWORDDIUQI (DI in, int byte) | |
378 | { | |
379 | assert (byte >= 0 && byte <= 7); | |
380 | return (UQI) (in >> (8 * (7 - byte))); | |
381 | } | |
382 | ||
7a292a7a | 383 | SEMOPS_INLINE SI |
6426a772 | 384 | SUBWORDDISI (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 | ||
392 | SEMOPS_INLINE SI | |
6426a772 | 393 | SUBWORDDFSI (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 | 402 | SEMOPS_INLINE SI |
6426a772 | 403 | SUBWORDXFSI (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 | 411 | SEMOPS_INLINE SI |
6426a772 | 412 | SUBWORDTFSI (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 | ||
420 | SEMOPS_INLINE DI | |
6426a772 | 421 | JOINSIDI (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 | ||
429 | SEMOPS_INLINE DF | |
6426a772 | 430 | JOINSIDF (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 | 440 | SEMOPS_INLINE XF |
6426a772 | 441 | JOINSIXF (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 | 451 | SEMOPS_INLINE TF |
6426a772 | 452 | JOINSITF (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 |
464 | QI SUBWORDSIQI (SI); |
465 | HI SUBWORDSIHI (HI); | |
6426a772 | 466 | SI SUBWORDSFSI (SF); |
4f49fa1b | 467 | SF SUBWORDSISF (SI); |
0d277f51 | 468 | DI SUBWORDDFDI (DF); |
4f49fa1b | 469 | DF SUBWORDDIDF (DI); |
6227bc85 | 470 | QI SUBWORDDIQI (DI, int); |
4f49fa1b | 471 | HI SUBWORDDIHI (DI, int); |
6426a772 JM |
472 | SI SUBWORDDISI (DI, int); |
473 | SI SUBWORDDFSI (DF, int); | |
474 | SI SUBWORDXFSI (XF, int); | |
475 | SI SUBWORDTFSI (TF, int); | |
7a292a7a | 476 | |
4f49fa1b BE |
477 | UQI SUBWORDSIUQI (SI); |
478 | UQI SUBWORDDIUQI (DI); | |
479 | ||
6426a772 JM |
480 | DI JOINSIDI (SI, SI); |
481 | DF JOINSIDF (SI, SI); | |
482 | XF JOINSIXF (SI, SI, SI); | |
483 | TF 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 | |
491 | SEMOPS_INLINE SI | |
492 | ADDCSI (SI a, SI b, BI c) | |
493 | { | |
494 | SI res = ADDSI (a, ADDSI (b, c)); | |
495 | return res; | |
496 | } | |
497 | ||
498 | SEMOPS_INLINE BI | |
499 | ADDCFSI (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 | ||
506 | SEMOPS_INLINE BI | |
507 | ADDOFSI (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 | ||
515 | SEMOPS_INLINE SI | |
516 | SUBCSI (SI a, SI b, BI c) | |
517 | { | |
518 | SI res = SUBSI (a, ADDSI (b, c)); | |
519 | return res; | |
520 | } | |
521 | ||
522 | SEMOPS_INLINE BI | |
523 | SUBCFSI (SI a, SI b, BI c) | |
524 | { | |
525 | BI res = ((USI) a < (USI) b) || (c && a == b); | |
526 | return res; | |
527 | } | |
528 | ||
529 | SEMOPS_INLINE BI | |
530 | SUBOFSI (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 |
538 | SEMOPS_INLINE HI |
539 | ADDCHI (HI a, HI b, BI c) | |
540 | { | |
541 | HI res = ADDHI (a, ADDHI (b, c)); | |
542 | return res; | |
543 | } | |
544 | ||
545 | SEMOPS_INLINE BI | |
546 | ADDCFHI (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 | ||
553 | SEMOPS_INLINE BI | |
554 | ADDOFHI (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 | ||
562 | SEMOPS_INLINE HI | |
563 | SUBCHI (HI a, HI b, BI c) | |
564 | { | |
565 | HI res = SUBHI (a, ADDHI (b, c)); | |
566 | return res; | |
567 | } | |
568 | ||
569 | SEMOPS_INLINE BI | |
570 | SUBCFHI (HI a, HI b, BI c) | |
571 | { | |
572 | BI res = ((UHI) a < (UHI) b) || (c && a == b); | |
573 | return res; | |
574 | } | |
575 | ||
576 | SEMOPS_INLINE BI | |
577 | SUBOFHI (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 |
585 | SEMOPS_INLINE QI |
586 | ADDCQI (QI a, QI b, BI c) | |
587 | { | |
588 | QI res = ADDQI (a, ADDQI (b, c)); | |
589 | return res; | |
590 | } | |
591 | ||
592 | SEMOPS_INLINE BI | |
593 | ADDCFQI (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 | ||
600 | SEMOPS_INLINE BI | |
601 | ADDOFQI (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 | ||
609 | SEMOPS_INLINE QI | |
610 | SUBCQI (QI a, QI b, BI c) | |
611 | { | |
612 | QI res = SUBQI (a, ADDQI (b, c)); | |
613 | return res; | |
614 | } | |
615 | ||
616 | SEMOPS_INLINE BI | |
617 | SUBCFQI (QI a, QI b, BI c) | |
618 | { | |
619 | BI res = ((UQI) a < (UQI) b) || (c && a == b); | |
620 | return res; | |
621 | } | |
622 | ||
623 | SEMOPS_INLINE BI | |
624 | SUBOFQI (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 | ||
634 | SI ADDCSI (SI, SI, BI); | |
635 | UBI ADDCFSI (SI, SI, BI); | |
636 | UBI ADDOFSI (SI, SI, BI); | |
637 | SI SUBCSI (SI, SI, BI); | |
638 | UBI SUBCFSI (SI, SI, BI); | |
639 | UBI SUBOFSI (SI, SI, BI); | |
0fda6bd2 JM |
640 | HI ADDCHI (HI, HI, BI); |
641 | UBI ADDCFHI (HI, HI, BI); | |
642 | UBI ADDOFHI (HI, HI, BI); | |
643 | HI SUBCHI (HI, HI, BI); | |
644 | UBI SUBCFHI (HI, HI, BI); | |
645 | UBI SUBOFHI (HI, HI, BI); | |
dea03d4e HPN |
646 | QI ADDCQI (QI, QI, BI); |
647 | UBI ADDCFQI (QI, QI, BI); | |
648 | UBI ADDOFQI (QI, QI, BI); | |
649 | QI SUBCQI (QI, QI, BI); | |
650 | UBI SUBCFQI (QI, QI, BI); | |
651 | UBI SUBOFQI (QI, QI, BI); | |
c906108c SS |
652 | |
653 | #endif | |
c906108c SS |
654 | |
655 | #endif /* CGEN_SEM_OPS_H */ |