OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [binutils-2.20.1/] [opcodes/] [cgen-ops.h] - Blame information for rev 252

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 205 julius
/* Semantics ops support for CGEN-based opcode libraries.
2
   Copyright (C) 2005, 2007 Free Software Foundation, Inc.
3
   Contributed by Red Hat.
4
 
5
   This file is part of the GNU opcodes library.
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 3, or (at your option)
10
   any later version.
11
 
12
   It is distributed in the hope that it will be useful, but WITHOUT
13
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
15
   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
#ifndef CGEN_SEM_OPS_H
22
#define CGEN_SEM_OPS_H
23
 
24
#include <assert.h>
25
 
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
 
33
/* TODO: Lazy encoding/decoding of fp values.  */
34
 
35
/* These don't really have a mode.  */
36
#define ANDIF(x, y) ((x) && (y))
37
#define ORIF(x, y) ((x) || (y))
38
 
39
#define SUBBI(x, y) ((x) - (y))
40
#define ANDBI(x, y) ((x) & (y))
41
#define ORBI(x, y) ((x) | (y))
42
#define XORBI(x, y) ((x) ^ (y))
43
#define NEGBI(x) (- (x))
44
#define NOTBI(x) (! (BI) (x))
45
#define INVBI(x) (~ (x))
46
#define EQBI(x, y) ((BI) (x) == (BI) (y))
47
#define NEBI(x, y) ((BI) (x) != (BI) (y))
48
#define LTBI(x, y) ((BI) (x) < (BI) (y))
49
#define LEBI(x, y) ((BI) (x) <= (BI) (y))
50
#define GTBI(x, y) ((BI) (x) > (BI) (y))
51
#define GEBI(x, y) ((BI) (x) >= (BI) (y))
52
#define LTUBI(x, y) ((BI) (x) < (BI) (y))
53
#define LEUBI(x, y) ((BI) (x) <= (BI) (y))
54
#define GTUBI(x, y) ((BI) (x) > (BI) (y))
55
#define GEUBI(x, y) ((BI) (x) >= (BI) (y))
56
 
57
#define ADDQI(x, y) ((x) + (y))
58
#define SUBQI(x, y) ((x) - (y))
59
#define MULQI(x, y) ((x) * (y))
60
#define DIVQI(x, y) ((QI) (x) / (QI) (y))
61
#define UDIVQI(x, y) ((UQI) (x) / (UQI) (y))
62
#define MODQI(x, y) ((QI) (x) % (QI) (y))
63
#define UMODQI(x, y) ((UQI) (x) % (UQI) (y))
64
#define SRAQI(x, y) ((QI) (x) >> (y))
65
#define SRLQI(x, y) ((UQI) (x) >> (y))
66
#define SLLQI(x, y) ((UQI) (x) << (y))
67
extern QI RORQI (QI, int);
68
extern QI ROLQI (QI, int);
69
#define ANDQI(x, y) ((x) & (y))
70
#define ORQI(x, y) ((x) | (y))
71
#define XORQI(x, y) ((x) ^ (y))
72
#define NEGQI(x) (- (x))
73
#define NOTQI(x) (! (QI) (x))
74
#define INVQI(x) (~ (x))
75
#define ABSQI(x) ((x) < 0 ? -(x) : (x))
76
#define EQQI(x, y) ((QI) (x) == (QI) (y))
77
#define NEQI(x, y) ((QI) (x) != (QI) (y))
78
#define LTQI(x, y) ((QI) (x) < (QI) (y))
79
#define LEQI(x, y) ((QI) (x) <= (QI) (y))
80
#define GTQI(x, y) ((QI) (x) > (QI) (y))
81
#define GEQI(x, y) ((QI) (x) >= (QI) (y))
82
#define LTUQI(x, y) ((UQI) (x) < (UQI) (y))
83
#define LEUQI(x, y) ((UQI) (x) <= (UQI) (y))
84
#define GTUQI(x, y) ((UQI) (x) > (UQI) (y))
85
#define GEUQI(x, y) ((UQI) (x) >= (UQI) (y))
86
 
87
#define ADDHI(x, y) ((x) + (y))
88
#define SUBHI(x, y) ((x) - (y))
89
#define MULHI(x, y) ((x) * (y))
90
#define DIVHI(x, y) ((HI) (x) / (HI) (y))
91
#define UDIVHI(x, y) ((UHI) (x) / (UHI) (y))
92
#define MODHI(x, y) ((HI) (x) % (HI) (y))
93
#define UMODHI(x, y) ((UHI) (x) % (UHI) (y))
94
#define SRAHI(x, y) ((HI) (x) >> (y))
95
#define SRLHI(x, y) ((UHI) (x) >> (y))
96
#define SLLHI(x, y) ((UHI) (x) << (y))
97
extern HI RORHI (HI, int);
98
extern HI ROLHI (HI, int);
99
#define ANDHI(x, y) ((x) & (y))
100
#define ORHI(x, y) ((x) | (y))
101
#define XORHI(x, y) ((x) ^ (y))
102
#define NEGHI(x) (- (x))
103
#define NOTHI(x) (! (HI) (x))
104
#define INVHI(x) (~ (x))
105
#define ABSHI(x) ((x) < 0 ? -(x) : (x))
106
#define EQHI(x, y) ((HI) (x) == (HI) (y))
107
#define NEHI(x, y) ((HI) (x) != (HI) (y))
108
#define LTHI(x, y) ((HI) (x) < (HI) (y))
109
#define LEHI(x, y) ((HI) (x) <= (HI) (y))
110
#define GTHI(x, y) ((HI) (x) > (HI) (y))
111
#define GEHI(x, y) ((HI) (x) >= (HI) (y))
112
#define LTUHI(x, y) ((UHI) (x) < (UHI) (y))
113
#define LEUHI(x, y) ((UHI) (x) <= (UHI) (y))
114
#define GTUHI(x, y) ((UHI) (x) > (UHI) (y))
115
#define GEUHI(x, y) ((UHI) (x) >= (UHI) (y))
116
 
117
#define ADDSI(x, y) ((x) + (y))
118
#define SUBSI(x, y) ((x) - (y))
119
#define MULSI(x, y) ((x) * (y))
120
#define DIVSI(x, y) ((SI) (x) / (SI) (y))
121
#define UDIVSI(x, y) ((USI) (x) / (USI) (y))
122
#define MODSI(x, y) ((SI) (x) % (SI) (y))
123
#define UMODSI(x, y) ((USI) (x) % (USI) (y))
124
#define SRASI(x, y) ((SI) (x) >> (y))
125
#define SRLSI(x, y) ((USI) (x) >> (y))
126
#define SLLSI(x, y) ((USI) (x) << (y))
127
extern SI RORSI (SI, int);
128
extern SI ROLSI (SI, int);
129
#define ANDSI(x, y) ((x) & (y))
130
#define ORSI(x, y) ((x) | (y))
131
#define XORSI(x, y) ((x) ^ (y))
132
#define NEGSI(x) (- (x))
133
#define NOTSI(x) (! (SI) (x))
134
#define INVSI(x) (~ (x))
135
#define ABSSI(x) ((x) < 0 ? -(x) : (x))
136
#define EQSI(x, y) ((SI) (x) == (SI) (y))
137
#define NESI(x, y) ((SI) (x) != (SI) (y))
138
#define LTSI(x, y) ((SI) (x) < (SI) (y))
139
#define LESI(x, y) ((SI) (x) <= (SI) (y))
140
#define GTSI(x, y) ((SI) (x) > (SI) (y))
141
#define GESI(x, y) ((SI) (x) >= (SI) (y))
142
#define LTUSI(x, y) ((USI) (x) < (USI) (y))
143
#define LEUSI(x, y) ((USI) (x) <= (USI) (y))
144
#define GTUSI(x, y) ((USI) (x) > (USI) (y))
145
#define GEUSI(x, y) ((USI) (x) >= (USI) (y))
146
 
147
#ifdef DI_FN_SUPPORT
148
extern DI ADDDI (DI, DI);
149
extern DI SUBDI (DI, DI);
150
extern DI MULDI (DI, DI);
151
extern DI DIVDI (DI, DI);
152
extern DI UDIVDI (DI, DI);
153
extern DI MODDI (DI, DI);
154
extern DI UMODDI (DI, DI);
155
extern DI SRADI (DI, int);
156
extern UDI SRLDI (UDI, int);
157
extern UDI SLLDI (UDI, int);
158
extern DI RORDI (DI, int);
159
extern DI ROLDI (DI, int);
160
extern DI ANDDI (DI, DI);
161
extern DI ORDI (DI, DI);
162
extern DI XORDI (DI, DI);
163
extern DI NEGDI (DI);
164
extern int NOTDI (DI);
165
extern DI INVDI (DI);
166
extern int EQDI (DI, DI);
167
extern int NEDI (DI, DI);
168
extern int LTDI (DI, DI);
169
extern int LEDI (DI, DI);
170
extern int GTDI (DI, DI);
171
extern int GEDI (DI, DI);
172
extern int LTUDI (UDI, UDI);
173
extern int LEUDI (UDI, UDI);
174
extern int GTUDI (UDI, UDI);
175
extern int GEUDI (UDI, UDI);
176
#else /* ! DI_FN_SUPPORT */
177
#define ADDDI(x, y) ((x) + (y))
178
#define SUBDI(x, y) ((x) - (y))
179
#define MULDI(x, y) ((x) * (y))
180
#define DIVDI(x, y) ((DI) (x) / (DI) (y))
181
#define UDIVDI(x, y) ((UDI) (x) / (UDI) (y))
182
#define MODDI(x, y) ((DI) (x) % (DI) (y))
183
#define UMODDI(x, y) ((UDI) (x) % (UDI) (y))
184
#define SRADI(x, y) ((DI) (x) >> (y))
185
#define SRLDI(x, y) ((UDI) (x) >> (y))
186
#define SLLDI(x, y) ((UDI) (x) << (y))
187
extern DI RORDI (DI, int);
188
extern DI ROLDI (DI, int);
189
#define ANDDI(x, y) ((x) & (y))
190
#define ORDI(x, y) ((x) | (y))
191
#define XORDI(x, y) ((x) ^ (y))
192
#define NEGDI(x) (- (x))
193
#define NOTDI(x) (! (DI) (x))
194
#define INVDI(x) (~ (x))
195
#define ABSDI(x) ((x) < 0 ? -(x) : (x))
196
#define EQDI(x, y) ((DI) (x) == (DI) (y))
197
#define NEDI(x, y) ((DI) (x) != (DI) (y))
198
#define LTDI(x, y) ((DI) (x) < (DI) (y))
199
#define LEDI(x, y) ((DI) (x) <= (DI) (y))
200
#define GTDI(x, y) ((DI) (x) > (DI) (y))
201
#define GEDI(x, y) ((DI) (x) >= (DI) (y))
202
#define LTUDI(x, y) ((UDI) (x) < (UDI) (y))
203
#define LEUDI(x, y) ((UDI) (x) <= (UDI) (y))
204
#define GTUDI(x, y) ((UDI) (x) > (UDI) (y))
205
#define GEUDI(x, y) ((UDI) (x) >= (UDI) (y))
206
#endif /* DI_FN_SUPPORT */
207
 
208
#define EXTBIQI(x) ((QI) (BI) (x))
209
#define EXTBIHI(x) ((HI) (BI) (x))
210
#define EXTBISI(x) ((SI) (BI) (x))
211
#if defined (DI_FN_SUPPORT)
212
extern DI EXTBIDI (BI);
213
#else
214
#define EXTBIDI(x) ((DI) (BI) (x))
215
#endif
216
#define EXTQIHI(x) ((HI) (QI) (x))
217
#define EXTQISI(x) ((SI) (QI) (x))
218
#if defined (DI_FN_SUPPORT)
219
extern DI EXTQIDI (QI);
220
#else
221
#define EXTQIDI(x) ((DI) (QI) (x))
222
#endif
223
#define EXTHIHI(x) ((HI) (HI) (x))
224
#define EXTHISI(x) ((SI) (HI) (x))
225
#define EXTSISI(x) ((SI) (SI) (x))
226
#if defined (DI_FN_SUPPORT)
227
extern DI EXTHIDI (HI);
228
#else
229
#define EXTHIDI(x) ((DI) (HI) (x))
230
#endif
231
#if defined (DI_FN_SUPPORT)
232
extern DI EXTSIDI (SI);
233
#else
234
#define EXTSIDI(x) ((DI) (SI) (x))
235
#endif
236
 
237
#define ZEXTBIQI(x) ((QI) (BI) (x))
238
#define ZEXTBIHI(x) ((HI) (BI) (x))
239
#define ZEXTBISI(x) ((SI) (BI) (x))
240
#if defined (DI_FN_SUPPORT)
241
extern DI ZEXTBIDI (BI);
242
#else
243
#define ZEXTBIDI(x) ((DI) (BI) (x))
244
#endif
245
#define ZEXTQIHI(x) ((HI) (UQI) (x))
246
#define ZEXTQISI(x) ((SI) (UQI) (x))
247
#if defined (DI_FN_SUPPORT)
248
extern DI ZEXTQIDI (QI);
249
#else
250
#define ZEXTQIDI(x) ((DI) (UQI) (x))
251
#endif
252
#define ZEXTHISI(x) ((SI) (UHI) (x))
253
#define ZEXTHIHI(x) ((HI) (UHI) (x))
254
#define ZEXTSISI(x) ((SI) (USI) (x))
255
#if defined (DI_FN_SUPPORT)
256
extern DI ZEXTHIDI (HI);
257
#else
258
#define ZEXTHIDI(x) ((DI) (UHI) (x))
259
#endif
260
#if defined (DI_FN_SUPPORT)
261
extern DI ZEXTSIDI (SI);
262
#else
263
#define ZEXTSIDI(x) ((DI) (USI) (x))
264
#endif
265
 
266
#define TRUNCQIBI(x) ((BI) (QI) (x))
267
#define TRUNCHIBI(x) ((BI) (HI) (x))
268
#define TRUNCHIQI(x) ((QI) (HI) (x))
269
#define TRUNCSIBI(x) ((BI) (SI) (x))
270
#define TRUNCSIQI(x) ((QI) (SI) (x))
271
#define TRUNCSIHI(x) ((HI) (SI) (x))
272
#define TRUNCSISI(x) ((SI) (SI) (x))
273
#if defined (DI_FN_SUPPORT)
274
extern BI TRUNCDIBI (DI);
275
#else
276
#define TRUNCDIBI(x) ((BI) (DI) (x))
277
#endif
278
#if defined (DI_FN_SUPPORT)
279
extern QI TRUNCDIQI (DI);
280
#else
281
#define TRUNCDIQI(x) ((QI) (DI) (x))
282
#endif
283
#if defined (DI_FN_SUPPORT)
284
extern HI TRUNCDIHI (DI);
285
#else
286
#define TRUNCDIHI(x) ((HI) (DI) (x))
287
#endif
288
#if defined (DI_FN_SUPPORT)
289
extern SI TRUNCDISI (DI);
290
#else
291
#define TRUNCDISI(x) ((SI) (DI) (x))
292
#endif
293
 
294
/* Composing/decomposing the various types.
295
   Word ordering is endian-independent.  Words are specified most to least
296
   significant and word number 0 is the most significant word.
297
   ??? May also wish an endian-dependent version.  Later.  */
298
 
299
QI SUBWORDSIQI (SI, int);
300
HI SUBWORDSIHI (SI, int);
301
SI SUBWORDSFSI (SF);
302
SF SUBWORDSISF (SI);
303
DI SUBWORDDFDI (DF);
304
DF SUBWORDDIDF (DI);
305
QI SUBWORDDIQI (DI, int);
306
HI SUBWORDDIHI (DI, int);
307
SI SUBWORDDISI (DI, int);
308
SI SUBWORDDFSI (DF, int);
309
SI SUBWORDXFSI (XF, int);
310
SI SUBWORDTFSI (TF, int);
311
 
312
UQI SUBWORDSIUQI (SI, int);
313
UQI SUBWORDDIUQI (DI, int);
314
 
315
#ifdef SEMOPS_DEFINE_INLINE
316
 
317
SEMOPS_INLINE SF
318
SUBWORDSISF (SI in)
319
{
320
  union { SI in; SF out; } x;
321
  x.in = in;
322
  return x.out;
323
}
324
 
325
SEMOPS_INLINE DF
326
SUBWORDDIDF (DI in)
327
{
328
  union { DI in; DF out; } x;
329
  x.in = in;
330
  return x.out;
331
}
332
 
333
SEMOPS_INLINE QI
334
SUBWORDSIQI (SI in, int byte)
335
{
336
  assert (byte >= 0 && byte <= 3);
337
  return (UQI) (in >> (8 * (3 - byte))) & 0xFF;
338
}
339
 
340
SEMOPS_INLINE UQI
341
SUBWORDSIUQI (SI in, int byte)
342
{
343
  assert (byte >= 0 && byte <= 3);
344
  return (UQI) (in >> (8 * (3 - byte))) & 0xFF;
345
}
346
 
347
SEMOPS_INLINE QI
348
SUBWORDDIQI (DI in, int byte)
349
{
350
  assert (byte >= 0 && byte <= 7);
351
  return (UQI) (in >> (8 * (7 - byte))) & 0xFF;
352
}
353
 
354
SEMOPS_INLINE HI
355
SUBWORDDIHI (DI in, int word)
356
{
357
  assert (word >= 0 && word <= 3);
358
  return (UHI) (in >> (16 * (3 - word))) & 0xFFFF;
359
}
360
 
361
SEMOPS_INLINE HI
362
SUBWORDSIHI (SI in, int word)
363
{
364
  if (word == 0)
365
    return (USI) in >> 16;
366
  else
367
    return in;
368
}
369
 
370
SEMOPS_INLINE SI
371
SUBWORDSFSI (SF in)
372
{
373
  union { SF in; SI out; } x;
374
  x.in = in;
375
  return x.out;
376
}
377
 
378
SEMOPS_INLINE DI
379
SUBWORDDFDI (DF in)
380
{
381
  union { DF in; DI out; } x;
382
  x.in = in;
383
  return x.out;
384
}
385
 
386
SEMOPS_INLINE UQI
387
SUBWORDDIUQI (DI in, int byte)
388
{
389
  assert (byte >= 0 && byte <= 7);
390
  return (UQI) (in >> (8 * (7 - byte)));
391
}
392
 
393
SEMOPS_INLINE SI
394
SUBWORDDISI (DI in, int word)
395
{
396
  if (word == 0)
397
    return (UDI) in >> 32;
398
  else
399
    return in;
400
}
401
 
402
SEMOPS_INLINE SI
403
SUBWORDDFSI (DF in, int word)
404
{
405
  /* Note: typedef UDI DF; */
406
  if (word == 0)
407
    return (UDI) in >> 32;
408
  else
409
    return in;
410
}
411
 
412
SEMOPS_INLINE SI
413
SUBWORDXFSI (XF in, int word)
414
{
415
  /* Note: typedef struct { SI parts[3]; } XF; */
416
  union { XF in; SI out[3]; } x;
417
  x.in = in;
418
  return x.out[word];
419
}
420
 
421
SEMOPS_INLINE SI
422
SUBWORDTFSI (TF in, int word)
423
{
424
  /* Note: typedef struct { SI parts[4]; } TF; */
425
  union { TF in; SI out[4]; } x;
426
  x.in = in;
427
  return x.out[word];
428
}
429
 
430
#endif /* SUBWORD,JOIN */
431
 
432
#endif /* CGEN_SEM_OPS_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.