]>
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 | ||
4f49fa1b BE |
26 | #include <assert.h> |
27 | ||
7a292a7a SS |
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 | |
34 | ||
c906108c SS |
35 | /* Semantic operations. |
36 | At one point this file was machine generated. Maybe it will be again. */ | |
37 | ||
43ff13b4 JM |
38 | /* TODO: Lazy encoding/decoding of fp values. */ |
39 | ||
c906108c SS |
40 | /* These don't really have a mode. */ |
41 | #define ANDIF(x, y) ((x) && (y)) | |
42 | #define ORIF(x, y) ((x) || (y)) | |
43 | ||
4f49fa1b | 44 | #define SUBBI(x, y) ((x) - (y)) |
c906108c SS |
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)) | |
43ff13b4 | 61 | \f |
c906108c SS |
62 | #define ADDQI(x, y) ((x) + (y)) |
63 | #define SUBQI(x, y) ((x) - (y)) | |
64 | #define MULQI(x, y) ((x) * (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)) | |
43ff13b4 JM |
72 | extern QI RORQI (QI, int); |
73 | extern QI ROLQI (QI, int); | |
c906108c SS |
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) (- (x)) | |
78 | #define NOTQI(x) (! (QI) (x)) | |
79 | #define INVQI(x) (~ (x)) | |
0fda6bd2 | 80 | #define ABSQI(x) ((x) < 0 ? -(x) : (x)) |
c906108c SS |
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)) | |
43ff13b4 | 91 | \f |
c906108c SS |
92 | #define ADDHI(x, y) ((x) + (y)) |
93 | #define SUBHI(x, y) ((x) - (y)) | |
94 | #define MULHI(x, y) ((x) * (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)) | |
43ff13b4 JM |
102 | extern HI RORHI (HI, int); |
103 | extern HI ROLHI (HI, int); | |
c906108c SS |
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) (- (x)) | |
108 | #define NOTHI(x) (! (HI) (x)) | |
109 | #define INVHI(x) (~ (x)) | |
0fda6bd2 | 110 | #define ABSHI(x) ((x) < 0 ? -(x) : (x)) |
c906108c SS |
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)) | |
43ff13b4 | 121 | \f |
c906108c SS |
122 | #define ADDSI(x, y) ((x) + (y)) |
123 | #define SUBSI(x, y) ((x) - (y)) | |
124 | #define MULSI(x, y) ((x) * (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)) | |
43ff13b4 JM |
132 | extern SI RORSI (SI, int); |
133 | extern SI ROLSI (SI, int); | |
c906108c SS |
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) (- (x)) | |
138 | #define NOTSI(x) (! (SI) (x)) | |
139 | #define INVSI(x) (~ (x)) | |
0fda6bd2 | 140 | #define ABSSI(x) ((x) < 0 ? -(x) : (x)) |
c906108c SS |
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)) | |
43ff13b4 | 151 | \f |
c906108c | 152 | #ifdef DI_FN_SUPPORT |
43ff13b4 JM |
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); | |
c906108c SS |
181 | #else /* ! DI_FN_SUPPORT */ |
182 | #define ADDDI(x, y) ((x) + (y)) | |
183 | #define SUBDI(x, y) ((x) - (y)) | |
184 | #define MULDI(x, y) ((x) * (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)) | |
43ff13b4 JM |
192 | extern DI RORDI (DI, int); |
193 | extern DI ROLDI (DI, int); | |
c906108c SS |
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) (- (x)) | |
198 | #define NOTDI(x) (! (DI) (x)) | |
199 | #define INVDI(x) (~ (x)) | |
0fda6bd2 | 200 | #define ABSDI(x) ((x) < 0 ? -(x) : (x)) |
c906108c SS |
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 */ | |
43ff13b4 | 212 | \f |
c906108c SS |
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) | |
43ff13b4 | 217 | extern DI EXTBIDI (BI); |
c906108c SS |
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) | |
43ff13b4 | 224 | extern DI EXTQIDI (QI); |
c906108c SS |
225 | #else |
226 | #define EXTQIDI(x) ((DI) (QI) (x)) | |
227 | #endif | |
f743149e | 228 | #define EXTHIHI(x) ((HI) (HI) (x)) |
c906108c | 229 | #define EXTHISI(x) ((SI) (HI) (x)) |
0fda6bd2 | 230 | #define EXTSISI(x) ((SI) (SI) (x)) |
c906108c | 231 | #if defined (DI_FN_SUPPORT) |
43ff13b4 | 232 | extern DI EXTHIDI (HI); |
c906108c SS |
233 | #else |
234 | #define EXTHIDI(x) ((DI) (HI) (x)) | |
235 | #endif | |
236 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 237 | extern DI EXTSIDI (SI); |
c906108c SS |
238 | #else |
239 | #define EXTSIDI(x) ((DI) (SI) (x)) | |
240 | #endif | |
43ff13b4 | 241 | \f |
c906108c SS |
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) | |
43ff13b4 | 246 | extern DI ZEXTBIDI (BI); |
c906108c SS |
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) | |
43ff13b4 | 253 | extern DI ZEXTQIDI (QI); |
c906108c SS |
254 | #else |
255 | #define ZEXTQIDI(x) ((DI) (UQI) (x)) | |
256 | #endif | |
257 | #define ZEXTHISI(x) ((SI) (UHI) (x)) | |
0fda6bd2 JM |
258 | #define ZEXTHIHI(x) ((HI) (UHI) (x)) |
259 | #define ZEXTSISI(x) ((SI) (USI) (x)) | |
c906108c | 260 | #if defined (DI_FN_SUPPORT) |
43ff13b4 | 261 | extern DI ZEXTHIDI (HI); |
c906108c SS |
262 | #else |
263 | #define ZEXTHIDI(x) ((DI) (UHI) (x)) | |
264 | #endif | |
265 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 266 | extern DI ZEXTSIDI (SI); |
c906108c SS |
267 | #else |
268 | #define ZEXTSIDI(x) ((DI) (USI) (x)) | |
269 | #endif | |
43ff13b4 | 270 | \f |
c906108c SS |
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)) | |
0f831eb3 | 277 | #define TRUNCSISI(x) ((SI) (SI) (x)) |
c906108c | 278 | #if defined (DI_FN_SUPPORT) |
43ff13b4 | 279 | extern BI TRUNCDIBI (DI); |
c906108c SS |
280 | #else |
281 | #define TRUNCDIBI(x) ((BI) (DI) (x)) | |
282 | #endif | |
283 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 284 | extern QI TRUNCDIQI (DI); |
c906108c SS |
285 | #else |
286 | #define TRUNCDIQI(x) ((QI) (DI) (x)) | |
287 | #endif | |
288 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 289 | extern HI TRUNCDIHI (DI); |
c906108c SS |
290 | #else |
291 | #define TRUNCDIHI(x) ((HI) (DI) (x)) | |
292 | #endif | |
293 | #if defined (DI_FN_SUPPORT) | |
43ff13b4 | 294 | extern SI TRUNCDISI (DI); |
c906108c SS |
295 | #else |
296 | #define TRUNCDISI(x) ((SI) (DI) (x)) | |
297 | #endif | |
c906108c | 298 | \f |
6426a772 JM |
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. */ | |
43ff13b4 | 303 | |
c906108c | 304 | #ifdef SEMOPS_DEFINE_INLINE |
7a292a7a SS |
305 | |
306 | SEMOPS_INLINE SF | |
6426a772 | 307 | SUBWORDSISF (SI in) |
7a292a7a SS |
308 | { |
309 | union { SI in; SF out; } x; | |
310 | x.in = in; | |
311 | return x.out; | |
312 | } | |
313 | ||
4f49fa1b BE |
314 | SEMOPS_INLINE DF |
315 | SUBWORDDIDF (DI in) | |
316 | { | |
317 | union { DI in; DF out; } x; | |
318 | x.in = in; | |
319 | return x.out; | |
320 | } | |
321 | ||
322 | SEMOPS_INLINE QI | |
323 | SUBWORDSIQI (SI in, int byte) | |
324 | { | |
325 | assert (byte >= 0 && byte <= 3); | |
326 | return (UQI) (in >> (8 * (3 - byte))); | |
327 | } | |
328 | ||
329 | SEMOPS_INLINE UQI | |
330 | SUBWORDSIUQI (SI in, int byte) | |
331 | { | |
332 | assert (byte >= 0 && byte <= 3); | |
333 | return (UQI) (in >> (8 * (3 - byte))); | |
334 | } | |
335 | ||
336 | SEMOPS_INLINE HI | |
337 | SUBWORDDIHI (DI in, int word) | |
338 | { | |
339 | assert (word >= 0 && word <= 3); | |
340 | return (UHI) (in >> (16 * (3 - word))); | |
341 | } | |
342 | ||
343 | SEMOPS_INLINE HI | |
344 | SUBWORDSIHI (SI in, int word) | |
345 | { | |
346 | if (word == 0) | |
347 | return (USI) in >> 16; | |
348 | else | |
349 | return in; | |
350 | } | |
351 | ||
7a292a7a | 352 | SEMOPS_INLINE SI |
6426a772 | 353 | SUBWORDSFSI (SF in) |
7a292a7a SS |
354 | { |
355 | union { SF in; SI out; } x; | |
356 | x.in = in; | |
357 | return x.out; | |
358 | } | |
359 | ||
4f49fa1b BE |
360 | SEMOPS_INLINE UQI |
361 | SUBWORDDIUQI (DI in, int byte) | |
362 | { | |
363 | assert (byte >= 0 && byte <= 7); | |
364 | return (UQI) (in >> (8 * (7 - byte))); | |
365 | } | |
366 | ||
7a292a7a | 367 | SEMOPS_INLINE SI |
6426a772 | 368 | SUBWORDDISI (DI in, int word) |
7a292a7a | 369 | { |
6426a772 JM |
370 | if (word == 0) |
371 | return (UDI) in >> 32; | |
7a292a7a | 372 | else |
6426a772 | 373 | return in; |
7a292a7a SS |
374 | } |
375 | ||
376 | SEMOPS_INLINE SI | |
6426a772 | 377 | SUBWORDDFSI (DF in, int word) |
7a292a7a | 378 | { |
6426a772 JM |
379 | /* Note: typedef UDI DF; */ |
380 | if (word == 0) | |
381 | return (UDI) in >> 32; | |
7a292a7a | 382 | else |
6426a772 | 383 | return in; |
7a292a7a SS |
384 | } |
385 | ||
43ff13b4 | 386 | SEMOPS_INLINE SI |
6426a772 | 387 | SUBWORDXFSI (XF in, int word) |
43ff13b4 | 388 | { |
6426a772 | 389 | /* Note: typedef struct { SI parts[3]; } XF; */ |
43ff13b4 JM |
390 | union { XF in; SI out[3]; } x; |
391 | x.in = in; | |
6426a772 | 392 | return x.out[word]; |
43ff13b4 JM |
393 | } |
394 | ||
7a292a7a | 395 | SEMOPS_INLINE SI |
6426a772 | 396 | SUBWORDTFSI (TF in, int word) |
7a292a7a | 397 | { |
6426a772 | 398 | /* Note: typedef struct { SI parts[4]; } TF; */ |
7a292a7a SS |
399 | union { TF in; SI out[4]; } x; |
400 | x.in = in; | |
6426a772 | 401 | return x.out[word]; |
7a292a7a SS |
402 | } |
403 | ||
404 | SEMOPS_INLINE DI | |
6426a772 | 405 | JOINSIDI (SI x0, SI x1) |
7a292a7a SS |
406 | { |
407 | if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN) | |
408 | return MAKEDI (x0, x1); | |
409 | else | |
410 | return MAKEDI (x1, x0); | |
411 | } | |
412 | ||
413 | SEMOPS_INLINE DF | |
6426a772 | 414 | JOINSIDF (SI x0, SI x1) |
7a292a7a SS |
415 | { |
416 | union { SI in[2]; DF out; } x; | |
417 | if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN) | |
418 | x.in[0] = x0, x.in[1] = x1; | |
419 | else | |
420 | x.in[1] = x0, x.in[0] = x1; | |
421 | return x.out; | |
422 | } | |
423 | ||
43ff13b4 | 424 | SEMOPS_INLINE XF |
6426a772 | 425 | JOINSIXF (SI x0, SI x1, SI x2) |
43ff13b4 JM |
426 | { |
427 | union { SI in[3]; XF out; } x; | |
428 | if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN) | |
429 | x.in[0] = x0, x.in[1] = x1, x.in[2] = x2; | |
430 | else | |
431 | x.in[2] = x0, x.in[1] = x1, x.in[0] = x2; | |
432 | return x.out; | |
433 | } | |
434 | ||
7a292a7a | 435 | SEMOPS_INLINE TF |
6426a772 | 436 | JOINSITF (SI x0, SI x1, SI x2, SI x3) |
7a292a7a SS |
437 | { |
438 | union { SI in[4]; TF out; } x; | |
439 | if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN) | |
440 | x.in[0] = x0, x.in[1] = x1, x.in[2] = x2, x.in[3] = x3; | |
441 | else | |
442 | x.in[3] = x0, x.in[2] = x1, x.in[1] = x2, x.in[0] = x3; | |
443 | return x.out; | |
444 | } | |
445 | ||
c906108c | 446 | #else |
7a292a7a | 447 | |
4f49fa1b BE |
448 | QI SUBWORDSIQI (SI); |
449 | HI SUBWORDSIHI (HI); | |
6426a772 | 450 | SI SUBWORDSFSI (SF); |
4f49fa1b BE |
451 | SF SUBWORDSISF (SI); |
452 | DF SUBWORDDIDF (DI); | |
453 | HI SUBWORDDIHI (DI, int); | |
6426a772 JM |
454 | SI SUBWORDDISI (DI, int); |
455 | SI SUBWORDDFSI (DF, int); | |
456 | SI SUBWORDXFSI (XF, int); | |
457 | SI SUBWORDTFSI (TF, int); | |
7a292a7a | 458 | |
4f49fa1b BE |
459 | UQI SUBWORDSIUQI (SI); |
460 | UQI SUBWORDDIUQI (DI); | |
461 | ||
6426a772 JM |
462 | DI JOINSIDI (SI, SI); |
463 | DF JOINSIDF (SI, SI); | |
464 | XF JOINSIXF (SI, SI, SI); | |
465 | TF JOINSITF (SI, SI, SI, SI); | |
7a292a7a SS |
466 | |
467 | #endif /* SUBWORD,JOIN */ | |
468 | \f | |
469 | /* Semantic support utilities. */ | |
470 | ||
471 | #ifdef SEMOPS_DEFINE_INLINE | |
c906108c SS |
472 | |
473 | SEMOPS_INLINE SI | |
474 | ADDCSI (SI a, SI b, BI c) | |
475 | { | |
476 | SI res = ADDSI (a, ADDSI (b, c)); | |
477 | return res; | |
478 | } | |
479 | ||
480 | SEMOPS_INLINE BI | |
481 | ADDCFSI (SI a, SI b, BI c) | |
482 | { | |
483 | SI tmp = ADDSI (a, ADDSI (b, c)); | |
484 | BI res = ((USI) tmp < (USI) a) || (c && tmp == a); | |
485 | return res; | |
486 | } | |
487 | ||
488 | SEMOPS_INLINE BI | |
489 | ADDOFSI (SI a, SI b, BI c) | |
490 | { | |
491 | SI tmp = ADDSI (a, ADDSI (b, c)); | |
492 | BI res = (((a < 0) == (b < 0)) | |
493 | && ((a < 0) != (tmp < 0))); | |
494 | return res; | |
495 | } | |
496 | ||
497 | SEMOPS_INLINE SI | |
498 | SUBCSI (SI a, SI b, BI c) | |
499 | { | |
500 | SI res = SUBSI (a, ADDSI (b, c)); | |
501 | return res; | |
502 | } | |
503 | ||
504 | SEMOPS_INLINE BI | |
505 | SUBCFSI (SI a, SI b, BI c) | |
506 | { | |
507 | BI res = ((USI) a < (USI) b) || (c && a == b); | |
508 | return res; | |
509 | } | |
510 | ||
511 | SEMOPS_INLINE BI | |
512 | SUBOFSI (SI a, SI b, BI c) | |
513 | { | |
514 | SI tmp = SUBSI (a, ADDSI (b, c)); | |
515 | BI res = (((a < 0) != (b < 0)) | |
516 | && ((a < 0) != (tmp < 0))); | |
517 | return res; | |
518 | } | |
519 | ||
0fda6bd2 JM |
520 | SEMOPS_INLINE HI |
521 | ADDCHI (HI a, HI b, BI c) | |
522 | { | |
523 | HI res = ADDHI (a, ADDHI (b, c)); | |
524 | return res; | |
525 | } | |
526 | ||
527 | SEMOPS_INLINE BI | |
528 | ADDCFHI (HI a, HI b, BI c) | |
529 | { | |
530 | HI tmp = ADDHI (a, ADDHI (b, c)); | |
531 | BI res = ((UHI) tmp < (UHI) a) || (c && tmp == a); | |
532 | return res; | |
533 | } | |
534 | ||
535 | SEMOPS_INLINE BI | |
536 | ADDOFHI (HI a, HI b, BI c) | |
537 | { | |
538 | HI tmp = ADDHI (a, ADDHI (b, c)); | |
539 | BI res = (((a < 0) == (b < 0)) | |
540 | && ((a < 0) != (tmp < 0))); | |
541 | return res; | |
542 | } | |
543 | ||
544 | SEMOPS_INLINE HI | |
545 | SUBCHI (HI a, HI b, BI c) | |
546 | { | |
547 | HI res = SUBHI (a, ADDHI (b, c)); | |
548 | return res; | |
549 | } | |
550 | ||
551 | SEMOPS_INLINE BI | |
552 | SUBCFHI (HI a, HI b, BI c) | |
553 | { | |
554 | BI res = ((UHI) a < (UHI) b) || (c && a == b); | |
555 | return res; | |
556 | } | |
557 | ||
558 | SEMOPS_INLINE BI | |
559 | SUBOFHI (HI a, HI b, BI c) | |
560 | { | |
561 | HI tmp = SUBHI (a, ADDHI (b, c)); | |
562 | BI res = (((a < 0) != (b < 0)) | |
563 | && ((a < 0) != (tmp < 0))); | |
564 | return res; | |
565 | } | |
566 | ||
c906108c SS |
567 | #else |
568 | ||
569 | SI ADDCSI (SI, SI, BI); | |
570 | UBI ADDCFSI (SI, SI, BI); | |
571 | UBI ADDOFSI (SI, SI, BI); | |
572 | SI SUBCSI (SI, SI, BI); | |
573 | UBI SUBCFSI (SI, SI, BI); | |
574 | UBI SUBOFSI (SI, SI, BI); | |
0fda6bd2 JM |
575 | HI ADDCHI (HI, HI, BI); |
576 | UBI ADDCFHI (HI, HI, BI); | |
577 | UBI ADDOFHI (HI, HI, BI); | |
578 | HI SUBCHI (HI, HI, BI); | |
579 | UBI SUBCFHI (HI, HI, BI); | |
580 | UBI SUBOFHI (HI, HI, BI); | |
c906108c SS |
581 | |
582 | #endif | |
c906108c SS |
583 | |
584 | #endif /* CGEN_SEM_OPS_H */ |