Do top level sim-hw module for device tree.
[deliverable/binutils-gdb.git] / sim / common / sim-bits.h
CommitLineData
d6fea803
AC
1/* This file is part of the program psim.
2
3 Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>
4 Copyright (C) 1997, Free Software Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 */
21
22
23#ifndef _SIM_BITS_H_
24#define _SIM_BITS_H_
25
26
27/* bit manipulation routines:
28
29 Bit numbering: The bits are numbered according to the target ISA's
30 convention. That being controlled by WITH_TARGET_WORD_MSB. For
31 the PowerPC (WITH_TARGET_WORD_MSB == 0) the numbering is 0..31
32 while for the MIPS (WITH_TARGET_WORD_MSB == 31) it is 31..0.
33
34 Size convention: Each macro is in three forms - <MACRO>32 which
35 operates in 32bit quantity (bits are numbered 0..31); <MACRO>64
36 which operates using 64bit quantites (and bits are numbered 0..63);
37 and <MACRO> which operates using the bit size of the target
38 architecture (bits are still numbered 0..63), with 32bit
39 architectures ignoring the first 32bits leaving bit 32 as the most
40 significant.
41
30efae3a
AC
42 NB: Use EXTRACTED, MSEXTRACTED and LSEXTRACTED as a guideline for
43 naming. LSMASK and LSMASKED are wrong.
44
d6fea803
AC
45 BIT*(POS): Constant with just 1 bit set.
46
47 LSBIT*(OFFSET): Constant with just 1 bit set - LS bit is zero.
48
49 MSBIT*(OFFSET): Constant with just 1 bit set - MS bit is zero.
50
51 MASK*(FIRST, LAST): Constant with bits [FIRST .. LAST] set. The
52 <MACRO> (no size) version permits FIRST >= LAST and generates a
53 wrapped bit mask vis ([0..LAST] | [FIRST..LSB]).
54
75b3697d 55 LSMASK*(FIRST, LAST): Like MASK - LS bit is zero.
d6fea803 56
75b3697d 57 MSMASK*(FIRST, LAST): Like MASK - LS bit is zero.
d6fea803
AC
58
59 MASKED*(VALUE, FIRST, LAST): Masks out all but bits [FIRST
60 .. LAST].
61
75b3697d 62 LSMASKED*(VALUE, FIRST, LAST): Like MASKED - LS bit is zero.
d6fea803 63
75b3697d 64 MSMASKED*(VALUE, FIRST, LAST): Like MASKED - MS bit is zero.
d6fea803
AC
65
66 EXTRACTED*(VALUE, FIRST, LAST): Masks out bits [FIRST .. LAST] but
67 also right shifts the masked value so that bit LAST becomes the
68 least significant (right most).
69
30efae3a
AC
70 LSEXTRACTED*(VALUE, FIRST, LAST): Same as extracted - LS bit is
71 zero.
72
73 MSEXTRACTED*(VALUE, FIRST, LAST): Same as extracted - MS bit is
74 zero.
75
d6fea803
AC
76 SHUFFLED**(VALUE, OLD, NEW): Mask then move a single bit from OLD
77 new NEW.
78
79 MOVED**(VALUE, OLD_FIRST, OLD_LAST, NEW_FIRST, NEW_LAST): Moves
80 things around so that bits OLD_FIRST..OLD_LAST are masked then
81 moved to NEW_FIRST..NEW_LAST.
82
83 INSERTED*(VALUE, FIRST, LAST): Takes VALUE and `inserts' the (LAST
84 - FIRST + 1) least significant bits into bit positions [ FIRST
85 .. LAST ]. This is almost the complement to EXTRACTED.
86
87 IEA_MASKED(SHOULD_MASK, ADDR): Convert the address to the targets
88 natural size. If in 32bit mode, discard the high 32bits.
89
75b3697d
AC
90 EXTENDED*(VALUE): Convert the `*' bit value to the targets natural
91 word size. Sign extned the value if needed.
d6fea803
AC
92
93 ALIGN_*(VALUE): Round upwards the value so that it is aligned.
94
95 FLOOR_*(VALUE): Truncate the value so that it is aligned.
96
97 ROTL*(VALUE, NR_BITS): Return the value rotated by NR_BITS left.
98
99 ROTR*(VALUE, NR_BITS): Return the value rotated by NR_BITS right.
100
101 SEXT*(VAL, SIGN_BIT): Treat SIGN_BIT as the sign, extend it.
102
103 Note: Only the BIT* and MASK* macros return a constant that can be
104 used in variable declarations.
105
106 */
107
108
109/* compute the number of bits between START and STOP */
110
111#if (WITH_TARGET_WORD_MSB == 0)
112#define _MAKE_WIDTH(START, STOP) (STOP - START + 1)
113#else
114#define _MAKE_WIDTH(START, STOP) (START - STOP + 1)
115#endif
116
117
118
119/* compute the number shifts required to move a bit between LSB (MSB)
120 and POS */
121
122#if (WITH_TARGET_WORD_MSB == 0)
123#define _LSB_SHIFT(WIDTH, POS) (WIDTH - 1 - POS)
124#else
125#define _LSB_SHIFT(WIDTH, POS) (POS)
126#endif
127
128#if (WITH_TARGET_WORD_MSB == 0)
129#define _MSB_SHIFT(WIDTH, POS) (POS)
130#else
131#define _MSB_SHIFT(WIDTH, POS) (WIDTH - 1 - POS)
132#endif
133
134
135/* compute the absolute bit position given the OFFSET from the MSB(LSB)
136 NB: _MAKE_xxx_POS (WIDTH, _MAKE_xxx_SHIFT (WIDTH, POS)) == POS */
137
138#if (WITH_TARGET_WORD_MSB == 0)
139#define _MSB_POS(WIDTH, SHIFT) (SHIFT)
140#else
141#define _MSB_POS(WIDTH, SHIFT) (WIDTH - 1 - SHIFT)
142#endif
143
144#if (WITH_TARGET_WORD_MSB == 0)
145#define _LSB_POS(WIDTH, SHIFT) (WIDTH - 1 - SHIFT)
146#else
147#define _LSB_POS(WIDTH, SHIFT) (SHIFT)
148#endif
149
150
151/* convert a 64 bit position into a corresponding 32bit position. MSB
152 pos handles the posibility that the bit lies beyond the 32bit
153 boundary */
154
155#if (WITH_TARGET_WORD_MSB == 0)
156#define _MSB_32(START, STOP) (START <= STOP \
157 ? (START < 32 ? 0 : START - 32) \
158 : (STOP < 32 ? 0 : STOP - 32))
159#else
160#define _MSB_32(START, STOP) (START >= STOP \
161 ? (START >= 32 ? 31 : START) \
162 : (STOP >= 32 ? 31 : STOP))
163#endif
164
165#if (WITH_TARGET_WORD_MSB == 0)
166#define _LSB_32(START, STOP) (START <= STOP \
167 ? (STOP < 32 ? 0 : STOP - 32) \
168 : (START < 32 ? 0 : START - 32))
169#else
170#define _LSB_32(START, STOP) (START >= STOP \
171 ? (STOP >= 32 ? 31 : STOP) \
172 : (START >= 32 ? 31 : START))
173#endif
174
175#if (WITH_TARGET_WORD_MSB == 0)
176#define _MSB(START, STOP) (START <= STOP ? START : STOP)
177#else
178#define _MSB(START, STOP) (START >= STOP ? START : STOP)
179#endif
180
181#if (WITH_TARGET_WORD_MSB == 0)
182#define _LSB(START, STOP) (START <= STOP ? STOP : START)
183#else
184#define _LSB(START, STOP) (START >= STOP ? STOP : START)
185#endif
186
187
75b3697d
AC
188/* LS/MS Bit operations */
189
293a0876
AC
190#define LSBIT8(POS) ((unsigned8) 1 << (POS))
191#define LSBIT16(POS) ((unsigned16)1 << (POS))
192#define LSBIT32(POS) ((unsigned32)1 << (POS))
193#define LSBIT64(POS) ((unsigned64)1 << (POS))
75b3697d 194
b52e58c2
AC
195#if (WITH_TARGET_WORD_BITSIZE == 64)
196#define LSBIT(POS) LSBIT64 (POS)
197#else
293a0876
AC
198#define LSBIT(POS) ((unsigned32)((POS) >= 32 \
199 ? 0 \
200 : (1 << ((POS) >= 32 ? 0 : (POS)))))
b52e58c2 201#endif
75b3697d
AC
202
203
293a0876
AC
204#define MSBIT8(POS) ((unsigned8) 1 << ( 8 - 1 - (POS)))
205#define MSBIT16(POS) ((unsigned16)1 << (16 - 1 - (POS)))
206#define MSBIT32(POS) ((unsigned32)1 << (32 - 1 - (POS)))
207#define MSBIT64(POS) ((unsigned64)1 << (64 - 1 - (POS)))
b52e58c2
AC
208
209#if (WITH_TARGET_WORD_BITSIZE == 64)
210#define MSBIT(POS) MSBIT64 (POS)
211#else
293a0876
AC
212#define MSBIT(POS) ((unsigned32)((POS) < 32 \
213 ? 0 \
214 : (1 << ((POS) < 32 ? 0 : (64 - 1) - (POS)))))
b52e58c2 215#endif
d6fea803 216
b52e58c2
AC
217
218/* Bit operations */
d6fea803
AC
219
220#define BIT4(POS) (1 << _LSB_SHIFT (4, (POS)))
221#define BIT5(POS) (1 << _LSB_SHIFT (5, (POS)))
d6fea803 222#define BIT10(POS) (1 << _LSB_SHIFT (10, (POS)))
d6fea803 223
d6fea803 224#if (WITH_TARGET_WORD_MSB == 0)
b52e58c2
AC
225#define BIT8 MSBIT8
226#define BIT16 MSBIT16
227#define BIT32 MSBIT32
228#define BIT64 MSBIT64
229#define BIT MSBIT
d6fea803 230#else
b52e58c2
AC
231#define BIT8 LSBIT8
232#define BIT16 LSBIT16
233#define BIT32 LSBIT32
234#define BIT64 LSBIT64
235#define BIT LSBIT
d6fea803
AC
236#endif
237
238
b52e58c2 239
d6fea803
AC
240/* multi bit mask */
241
242/* 111111 -> mmll11 -> mm11ll */
243#define _MASKn(WIDTH, START, STOP) (((unsigned##WIDTH)(-1) \
244 >> (_MSB_SHIFT (WIDTH, START) \
245 + _LSB_SHIFT (WIDTH, STOP))) \
246 << _LSB_SHIFT (WIDTH, STOP))
247
d6fea803
AC
248#if (WITH_TARGET_WORD_MSB == 0)
249#define _POS_LE(START, STOP) (START <= STOP)
250#else
251#define _POS_LE(START, STOP) (STOP <= START)
252#endif
253
254#if (WITH_TARGET_WORD_BITSIZE == 64)
255#define MASK(START, STOP) \
256 (_POS_LE ((START), (STOP)) \
257 ? _MASKn(64, \
258 _MSB ((START), (STOP)), \
259 _LSB ((START), (STOP)) ) \
260 : (_MASKn(64, _MSB_POS (64, 0), (STOP)) \
261 | _MASKn(64, (START), _LSB_POS (64, 0))))
262#endif
263#if (WITH_TARGET_WORD_BITSIZE == 32)
264#define MASK(START, STOP) \
265 (_POS_LE ((START), (STOP)) \
266 ? (_POS_LE ((STOP), _MSB_POS (64, 31)) \
267 ? 0 \
268 : _MASKn (32, \
269 _MSB_32 ((START), (STOP)), \
270 _LSB_32 ((START), (STOP)))) \
271 : (_MASKn (32, \
272 _LSB_32 ((START), (STOP)), \
273 _LSB_POS (32, 0)) \
274 | (_POS_LE ((STOP), _MSB_POS (64, 31)) \
275 ? 0 \
276 : _MASKn (32, \
277 _MSB_POS (32, 0), \
278 _MSB_32 ((START), (STOP))))))
279#endif
280#if !defined (MASK)
281#error "MASK never undefined"
282#endif
283
284
d6fea803
AC
285/* Multi-bit mask on least significant bits */
286
75b3697d
AC
287#define _LSMASKn(WIDTH, FIRST, LAST) _MASKn (WIDTH, \
288 _LSB_POS (WIDTH, FIRST), \
289 _LSB_POS (WIDTH, LAST))
d6fea803 290
b52e58c2 291#define LSMASK8(FIRST, LAST) _LSMASKn ( 8, (FIRST), (LAST))
75b3697d
AC
292#define LSMASK16(FIRST, LAST) _LSMASKn (16, (FIRST), (LAST))
293#define LSMASK32(FIRST, LAST) _LSMASKn (32, (FIRST), (LAST))
294#define LSMASK64(FIRST, LAST) _LSMASKn (64, (FIRST), (LAST))
d6fea803 295
75b3697d 296#define LSMASK(FIRST, LAST) (MASK (_LSB_POS (64, FIRST), _LSB_POS (64, LAST)))
d6fea803
AC
297
298
299/* Multi-bit mask on most significant bits */
300
75b3697d
AC
301#define _MSMASKn(WIDTH, FIRST, LAST) _MASKn (WIDTH, \
302 _MSB_POS (WIDTH, FIRST), \
303 _MSB_POS (WIDTH, LAST))
d6fea803 304
b52e58c2 305#define MSMASK8(FIRST, LAST) _MSMASKn ( 8, (FIRST), (LAST))
75b3697d
AC
306#define MSMASK16(FIRST, LAST) _MSMASKn (16, (FIRST), (LAST))
307#define MSMASK32(FIRST, LAST) _MSMASKn (32, (FIRST), (LAST))
308#define MSMASK64(FIRST, LAST) _MSMASKn (64, (FIRST), (LAST))
d6fea803 309
75b3697d 310#define MSMASK(FIRST, LAST) (MASK (_MSB_POS (64, FIRST), _MSB_POS (64, LAST)))
d6fea803 311
d6fea803 312
d6fea803 313
75b3697d 314#if (WITH_TARGET_WORD_MSB == 0)
b52e58c2 315#define MASK8 MSMASK8
75b3697d
AC
316#define MASK16 MSMASK16
317#define MASK32 MSMASK32
318#define MASK64 MSMASK64
319#else
b52e58c2 320#define MASK8 LSMASK8
75b3697d
AC
321#define MASK16 LSMASK16
322#define MASK32 LSMASK32
323#define MASK64 LSMASK64
324#endif
d6fea803
AC
325
326
d6fea803 327
75b3697d 328/* mask the required bits, leaving them in place */
d6fea803 329
b52e58c2 330INLINE_SIM_BITS(unsigned8) LSMASKED8 (unsigned8 word, int first, int last);
75b3697d
AC
331INLINE_SIM_BITS(unsigned16) LSMASKED16 (unsigned16 word, int first, int last);
332INLINE_SIM_BITS(unsigned32) LSMASKED32 (unsigned32 word, int first, int last);
333INLINE_SIM_BITS(unsigned64) LSMASKED64 (unsigned64 word, int first, int last);
d6fea803 334
75b3697d 335INLINE_SIM_BITS(unsigned_word) LSMASKED (unsigned_word word, int first, int last);
d6fea803 336
b52e58c2 337INLINE_SIM_BITS(unsigned8) MSMASKED8 (unsigned8 word, int first, int last);
75b3697d
AC
338INLINE_SIM_BITS(unsigned16) MSMASKED16 (unsigned16 word, int first, int last);
339INLINE_SIM_BITS(unsigned32) MSMASKED32 (unsigned32 word, int first, int last);
340INLINE_SIM_BITS(unsigned64) MSMASKED64 (unsigned64 word, int first, int last);
d6fea803 341
75b3697d 342INLINE_SIM_BITS(unsigned_word) MSMASKED (unsigned_word word, int first, int last);
d6fea803 343
75b3697d 344#if (WITH_TARGET_WORD_MSB == 0)
b52e58c2 345#define MASKED8 MSMASKED8
75b3697d
AC
346#define MASKED16 MSMASKED16
347#define MASKED32 MSMASKED32
348#define MASKED64 MSMASKED64
b52e58c2 349#define MASKED MSMASKED
75b3697d 350#else
b52e58c2 351#define MASKED8 LSMASKED8
75b3697d
AC
352#define MASKED16 LSMASKED16
353#define MASKED32 LSMASKED32
354#define MASKED64 LSMASKED64
355#define MASKED LSMASKED
356#endif
d6fea803
AC
357
358
359
360/* extract the required bits aligning them with the lsb */
361
b52e58c2 362INLINE_SIM_BITS(unsigned8) LSEXTRACTED8 (unsigned8 val, int start, int stop);
75b3697d
AC
363INLINE_SIM_BITS(unsigned16) LSEXTRACTED16 (unsigned16 val, int start, int stop);
364INLINE_SIM_BITS(unsigned32) LSEXTRACTED32 (unsigned32 val, int start, int stop);
365INLINE_SIM_BITS(unsigned64) LSEXTRACTED64 (unsigned64 val, int start, int stop);
366
367INLINE_SIM_BITS(unsigned_word) LSEXTRACTED (unsigned_word val, int start, int stop);
30efae3a 368
b52e58c2 369INLINE_SIM_BITS(unsigned8) MSEXTRACTED8 (unsigned8 val, int start, int stop);
75b3697d
AC
370INLINE_SIM_BITS(unsigned16) MSEXTRACTED16 (unsigned16 val, int start, int stop);
371INLINE_SIM_BITS(unsigned32) MSEXTRACTED32 (unsigned32 val, int start, int stop);
372INLINE_SIM_BITS(unsigned64) MSEXTRACTED64 (unsigned64 val, int start, int stop);
373
374INLINE_SIM_BITS(unsigned_word) MSEXTRACTED (unsigned_word val, int start, int stop);
30efae3a
AC
375
376#if (WITH_TARGET_WORD_MSB == 0)
b52e58c2 377#define EXTRACTED8 MSEXTRACTED8
75b3697d 378#define EXTRACTED16 MSEXTRACTED16
30efae3a 379#define EXTRACTED32 MSEXTRACTED32
75b3697d
AC
380#define EXTRACTED64 MSEXTRACTED64
381#define EXTRACTED MSEXTRACTED
30efae3a 382#else
b52e58c2 383#define EXTRACTED8 LSEXTRACTED8
75b3697d 384#define EXTRACTED16 LSEXTRACTED16
30efae3a 385#define EXTRACTED32 LSEXTRACTED32
75b3697d
AC
386#define EXTRACTED64 LSEXTRACTED64
387#define EXTRACTED LSEXTRACTED
30efae3a
AC
388#endif
389
390
391
d6fea803
AC
392/* move a single bit around */
393/* NB: the wierdness (N>O?N-O:0) is to stop a warning from GCC */
394#define _SHUFFLEDn(N, WORD, OLD, NEW) \
395((OLD) < (NEW) \
396 ? (((unsigned##N)(WORD) \
397 >> (((NEW) > (OLD)) ? ((NEW) - (OLD)) : 0)) \
398 & MASK32((NEW), (NEW))) \
399 : (((unsigned##N)(WORD) \
400 << (((OLD) > (NEW)) ? ((OLD) - (NEW)) : 0)) \
401 & MASK32((NEW), (NEW))))
402
403#define SHUFFLED32(WORD, OLD, NEW) _SHUFFLEDn (32, WORD, OLD, NEW)
404#define SHUFFLED64(WORD, OLD, NEW) _SHUFFLEDn (64, WORD, OLD, NEW)
405
406#define SHUFFLED(WORD, OLD, NEW) _SHUFFLEDn (_word, WORD, OLD, NEW)
407
408
293a0876 409/* Insert a group of bits into a bit position */
d6fea803 410
b52e58c2 411INLINE_SIM_BITS(unsigned8) LSINSERTED8 (unsigned8 val, int start, int stop);
aa5e6a5a
AC
412INLINE_SIM_BITS(unsigned16) LSINSERTED16 (unsigned16 val, int start, int stop);
413INLINE_SIM_BITS(unsigned32) LSINSERTED32 (unsigned32 val, int start, int stop);
414INLINE_SIM_BITS(unsigned64) LSINSERTED64 (unsigned64 val, int start, int stop);
415INLINE_SIM_BITS(unsigned_word) LSINSERTED (unsigned_word val, int start, int stop);
75b3697d 416
b52e58c2 417INLINE_SIM_BITS(unsigned8) MSINSERTED8 (unsigned8 val, int start, int stop);
aa5e6a5a
AC
418INLINE_SIM_BITS(unsigned16) MSINSERTED16 (unsigned16 val, int start, int stop);
419INLINE_SIM_BITS(unsigned32) MSINSERTED32 (unsigned32 val, int start, int stop);
420INLINE_SIM_BITS(unsigned64) MSINSERTED64 (unsigned64 val, int start, int stop);
421INLINE_SIM_BITS(unsigned_word) MSINSERTED (unsigned_word val, int start, int stop);
422
423#if (WITH_TARGET_WORD_MSB == 0)
b52e58c2 424#define INSERTED8 MSINSERTED8
aa5e6a5a
AC
425#define INSERTED16 MSINSERTED16
426#define INSERTED32 MSINSERTED32
427#define INSERTED64 MSINSERTED64
428#define INSERTED MSINSERTED
429#else
b52e58c2 430#define INSERTED8 LSINSERTED8
aa5e6a5a
AC
431#define INSERTED16 LSINSERTED16
432#define INSERTED32 LSINSERTED32
433#define INSERTED64 LSINSERTED64
434#define INSERTED LSINSERTED
435#endif
75b3697d 436
d6fea803 437
d6fea803 438
293a0876
AC
439/* MOVE bits from one loc to another (combination of extract/insert) */
440
441#define MOVED8(VAL,OH,OL,NH,NL) INSERTED8 (EXTRACTED8 ((VAL), OH, OL), NH, NL)
442#define MOVED16(VAL,OH,OL,NH,NL) INSERTED16(EXTRACTED16((VAL), OH, OL), NH, NL)
443#define MOVED32(VAL,OH,OL,NH,NL) INSERTED32(EXTRACTED32((VAL), OH, OL), NH, NL)
444#define MOVED64(VAL,OH,OL,NH,NL) INSERTED64(EXTRACTED64((VAL), OH, OL), NH, NL)
445#define MOVED(VAL,OH,OL,NH,NL) INSERTED (EXTRACTED ((VAL), OH, OL), NH, NL)
446
447
448
75b3697d 449/* Sign extend the quantity to the targets natural word size */
d6fea803 450
293a0876 451#define EXTEND8(X) ((signed_word)(signed8)(X))
75b3697d
AC
452#define EXTEND16(X) ((signed_word)(signed16)(X))
453#define EXTEND32(X) ((signed_word)(signed32)(X))
454#define EXTEND64(X) ((signed_word)(signed64)(X))
d6fea803
AC
455
456/* depending on MODE return a 64bit or 32bit (sign extended) value */
457#if (WITH_TARGET_WORD_BITSIZE == 64)
458#define EXTENDED(X) ((signed64)(signed32)(X))
459#endif
460#if (WITH_TARGET_WORD_BITSIZE == 32)
461#define EXTENDED(X) (X)
462#endif
463
464
465/* memory alignment macro's */
466#define _ALIGNa(A,X) (((X) + ((A) - 1)) & ~((A) - 1))
467#define _FLOORa(A,X) ((X) & ~((A) - 1))
468
469#define ALIGN_8(X) _ALIGNa (8, X)
470#define ALIGN_16(X) _ALIGNa (16, X)
471
472#define ALIGN_PAGE(X) _ALIGNa (0x1000, X)
473#define FLOOR_PAGE(X) ((X) & ~(0x1000 - 1))
474
475
476/* bit bliting macro's */
477#define BLIT32(V, POS, BIT) \
478do { \
479 if (BIT) \
480 V |= BIT32 (POS); \
481 else \
482 V &= ~BIT32 (POS); \
483} while (0)
484#define MBLIT32(V, LO, HI, VAL) \
485do { \
486 (V) = (((V) & ~MASK32 ((LO), (HI))) \
487 | INSERTED32 (VAL, LO, HI)); \
488} while (0)
489
490
491
492/* some rotate functions. The generic macro's ROT, ROTL, ROTR are
493 intentionally omited. */
494
495
b52e58c2 496INLINE_SIM_BITS(unsigned8) ROT8 (unsigned8 val, int shift);
d6fea803
AC
497INLINE_SIM_BITS(unsigned16) ROT16 (unsigned16 val, int shift);
498INLINE_SIM_BITS(unsigned32) ROT32 (unsigned32 val, int shift);
499INLINE_SIM_BITS(unsigned64) ROT64 (unsigned64 val, int shift);
500
501
b52e58c2 502INLINE_SIM_BITS(unsigned8) ROTL8 (unsigned8 val, int shift);
75b3697d
AC
503INLINE_SIM_BITS(unsigned16) ROTL16 (unsigned16 val, int shift);
504INLINE_SIM_BITS(unsigned32) ROTL32 (unsigned32 val, int shift);
505INLINE_SIM_BITS(unsigned64) ROTL64 (unsigned64 val, int shift);
d6fea803
AC
506
507
b52e58c2 508INLINE_SIM_BITS(unsigned8) ROTR8 (unsigned8 val, int shift);
75b3697d
AC
509INLINE_SIM_BITS(unsigned16) ROTR16 (unsigned16 val, int shift);
510INLINE_SIM_BITS(unsigned32) ROTR32 (unsigned32 val, int shift);
511INLINE_SIM_BITS(unsigned64) ROTR64 (unsigned64 val, int shift);
d6fea803
AC
512
513
514
515/* Sign extension operations */
516
b52e58c2 517INLINE_SIM_BITS(unsigned8) LSSEXT8 (signed8 val, int sign_bit);
aa5e6a5a
AC
518INLINE_SIM_BITS(unsigned16) LSSEXT16 (signed16 val, int sign_bit);
519INLINE_SIM_BITS(unsigned32) LSSEXT32 (signed32 val, int sign_bit);
520INLINE_SIM_BITS(unsigned64) LSSEXT64 (signed64 val, int sign_bit);
521INLINE_SIM_BITS(unsigned_word) LSSEXT (signed_word val, int sign_bit);
d6fea803 522
b52e58c2 523INLINE_SIM_BITS(unsigned8) MSSEXT8 (signed8 val, int sign_bit);
aa5e6a5a
AC
524INLINE_SIM_BITS(unsigned16) MSSEXT16 (signed16 val, int sign_bit);
525INLINE_SIM_BITS(unsigned32) MSSEXT32 (signed32 val, int sign_bit);
526INLINE_SIM_BITS(unsigned64) MSSEXT64 (signed64 val, int sign_bit);
527INLINE_SIM_BITS(unsigned_word) MSSEXT (signed_word val, int sign_bit);
528
529#if (WITH_TARGET_WORD_MSB == 0)
b52e58c2 530#define SEXT8 MSSEXT8
aa5e6a5a
AC
531#define SEXT16 MSSEXT16
532#define SEXT32 MSSEXT32
533#define SEXT64 MSSEXT64
534#define SEXT MSSEXT
535#else
b52e58c2 536#define SEXT8 LSSEXT8
aa5e6a5a
AC
537#define SEXT16 LSSEXT16
538#define SEXT32 LSSEXT32
539#define SEXT64 LSSEXT64
540#define SEXT LSSEXT
541#endif
d6fea803
AC
542
543
544
545#if ((SIM_BITS_INLINE & INCLUDE_MODULE) && (SIM_BITS_INLINE & INCLUDED_BY_MODULE))
546#include "sim-bits.c"
547#endif
548
549#endif /* _SIM_BITS_H_ */
This page took 0.064538 seconds and 4 git commands to generate.