* gx sim prototype tweaks
[binutils-gdb.git] / sim / common / sim-bits.h
blob8114f6b051227766192a07b5fda7ad35e836988e
1 /* This file is part of the program psim.
3 Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>
4 Copyright (C) 1997, Free Software Foundation, Inc.
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.
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.
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.
23 #ifndef _SIM_BITS_H_
24 #define _SIM_BITS_H_
27 /* Bit manipulation routines:
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.
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.
42 NB: Use EXTRACTED, MSEXTRACTED and LSEXTRACTED as a guideline for
43 naming. LSMASK and LSMASKED are wrong.
45 BIT*(POS): `*' bit constant with just 1 bit set.
47 LSBIT*(OFFSET): `*' bit constant with just 1 bit set - LS bit is
48 zero.
50 MSBIT*(OFFSET): `*' bit constant with just 1 bit set - MS bit is
51 zero.
53 MASK*(FIRST, LAST): `*' bit constant with bits [FIRST .. LAST]
54 set. The <MACRO> (no size) version permits FIRST >= LAST and
55 generates a wrapped bit mask vis ([0..LAST] | [FIRST..LSB]).
57 LSMASK*(FIRST, LAST): Like MASK - LS bit is zero.
59 MSMASK*(FIRST, LAST): Like MASK - LS bit is zero.
61 MASKED*(VALUE, FIRST, LAST): Masks out all but bits [FIRST
62 .. LAST].
64 LSMASKED*(VALUE, FIRST, LAST): Like MASKED - LS bit is zero.
66 MSMASKED*(VALUE, FIRST, LAST): Like MASKED - MS bit is zero.
68 EXTRACTED*(VALUE, FIRST, LAST): Masks out bits [FIRST .. LAST] but
69 also right shifts the masked value so that bit LAST becomes the
70 least significant (right most).
72 LSEXTRACTED*(VALUE, FIRST, LAST): Same as extracted - LS bit is
73 zero.
75 MSEXTRACTED*(VALUE, FIRST, LAST): Same as extracted - MS bit is
76 zero.
78 SHUFFLED**(VALUE, OLD, NEW): Mask then move a single bit from OLD
79 new NEW.
81 MOVED**(VALUE, OLD_FIRST, OLD_LAST, NEW_FIRST, NEW_LAST): Moves
82 things around so that bits OLD_FIRST..OLD_LAST are masked then
83 moved to NEW_FIRST..NEW_LAST.
85 INSERTED*(VALUE, FIRST, LAST): Takes VALUE and `inserts' the (LAST
86 - FIRST + 1) least significant bits into bit positions [ FIRST
87 .. LAST ]. This is almost the complement to EXTRACTED.
89 IEA_MASKED(SHOULD_MASK, ADDR): Convert the address to the targets
90 natural size. If in 32bit mode, discard the high 32bits.
92 EXTEND*(VALUE): Convert the `*' bit value to the targets natural
93 word size. Sign extend the value if needed.
95 ALIGN_*(VALUE): Round the value upwards so that it is aligned to a
96 `_*' byte boundary.
98 FLOOR_*(VALUE): Truncate the value so that it is aligned to a `_*'
99 byte boundary.
101 ROT*(VALUE, NR_BITS): Return the `*' bit VALUE rotated by NR_BITS
102 right (positive) or left (negative).
104 ROTL*(VALUE, NR_BITS): Return the `*' bit value rotated by NR_BITS
105 left. 0 <= NR_BITS <= `*'.
107 ROTR*(VALUE, NR_BITS): Return the `*' bit value rotated by NR_BITS
108 right. 0 <= NR_BITS <= N.
110 SEXT*(VALUE, SIGN_BIT): Treat SIGN_BIT as VALUEs sign, extend it ti
111 `*' bits.
113 Note: Only the BIT* and MASK* macros return a constant that can be
114 used in variable declarations.
119 /* compute the number of bits between START and STOP */
121 #if (WITH_TARGET_WORD_MSB == 0)
122 #define _MAKE_WIDTH(START, STOP) (STOP - START + 1)
123 #else
124 #define _MAKE_WIDTH(START, STOP) (START - STOP + 1)
125 #endif
129 /* compute the number shifts required to move a bit between LSB (MSB)
130 and POS */
132 #if (WITH_TARGET_WORD_MSB == 0)
133 #define _LSB_SHIFT(WIDTH, POS) (WIDTH - 1 - POS)
134 #else
135 #define _LSB_SHIFT(WIDTH, POS) (POS)
136 #endif
138 #if (WITH_TARGET_WORD_MSB == 0)
139 #define _MSB_SHIFT(WIDTH, POS) (POS)
140 #else
141 #define _MSB_SHIFT(WIDTH, POS) (WIDTH - 1 - POS)
142 #endif
145 /* compute the absolute bit position given the OFFSET from the MSB(LSB)
146 NB: _MAKE_xxx_POS (WIDTH, _MAKE_xxx_SHIFT (WIDTH, POS)) == POS */
148 #if (WITH_TARGET_WORD_MSB == 0)
149 #define _MSB_POS(WIDTH, SHIFT) (SHIFT)
150 #else
151 #define _MSB_POS(WIDTH, SHIFT) (WIDTH - 1 - SHIFT)
152 #endif
154 #if (WITH_TARGET_WORD_MSB == 0)
155 #define _LSB_POS(WIDTH, SHIFT) (WIDTH - 1 - SHIFT)
156 #else
157 #define _LSB_POS(WIDTH, SHIFT) (SHIFT)
158 #endif
161 /* convert a 64 bit position into a corresponding 32bit position. MSB
162 pos handles the posibility that the bit lies beyond the 32bit
163 boundary */
165 #if (WITH_TARGET_WORD_MSB == 0)
166 #define _MSB_32(START, STOP) (START <= STOP \
167 ? (START < 32 ? 0 : START - 32) \
168 : (STOP < 32 ? 0 : STOP - 32))
169 #else
170 #define _MSB_32(START, STOP) (START >= STOP \
171 ? (START >= 32 ? 31 : START) \
172 : (STOP >= 32 ? 31 : STOP))
173 #endif
175 #if (WITH_TARGET_WORD_MSB == 0)
176 #define _LSB_32(START, STOP) (START <= STOP \
177 ? (STOP < 32 ? 0 : STOP - 32) \
178 : (START < 32 ? 0 : START - 32))
179 #else
180 #define _LSB_32(START, STOP) (START >= STOP \
181 ? (STOP >= 32 ? 31 : STOP) \
182 : (START >= 32 ? 31 : START))
183 #endif
185 #if (WITH_TARGET_WORD_MSB == 0)
186 #define _MSB(START, STOP) (START <= STOP ? START : STOP)
187 #else
188 #define _MSB(START, STOP) (START >= STOP ? START : STOP)
189 #endif
191 #if (WITH_TARGET_WORD_MSB == 0)
192 #define _LSB(START, STOP) (START <= STOP ? STOP : START)
193 #else
194 #define _LSB(START, STOP) (START >= STOP ? STOP : START)
195 #endif
198 /* LS/MS Bit operations */
200 #define LSBIT8(POS) ((unsigned8) 1 << (POS))
201 #define LSBIT16(POS) ((unsigned16)1 << (POS))
202 #define LSBIT32(POS) ((unsigned32)1 << (POS))
203 #define LSBIT64(POS) ((unsigned64)1 << (POS))
205 #if (WITH_TARGET_WORD_BITSIZE == 64)
206 #define LSBIT(POS) LSBIT64 (POS)
207 #else
208 #define LSBIT(POS) ((unsigned32)((POS) >= 32 \
209 ? 0 \
210 : (1 << ((POS) >= 32 ? 0 : (POS)))))
211 #endif
214 #define MSBIT8(POS) ((unsigned8) 1 << ( 8 - 1 - (POS)))
215 #define MSBIT16(POS) ((unsigned16)1 << (16 - 1 - (POS)))
216 #define MSBIT32(POS) ((unsigned32)1 << (32 - 1 - (POS)))
217 #define MSBIT64(POS) ((unsigned64)1 << (64 - 1 - (POS)))
219 #if (WITH_TARGET_WORD_BITSIZE == 64)
220 #define MSBIT(POS) MSBIT64 (POS)
221 #else
222 #define MSBIT(POS) ((unsigned32)((POS) < 32 \
223 ? 0 \
224 : (1 << ((POS) < 32 ? 0 : (64 - 1) - (POS)))))
225 #endif
228 /* Bit operations */
230 #define BIT4(POS) (1 << _LSB_SHIFT (4, (POS)))
231 #define BIT5(POS) (1 << _LSB_SHIFT (5, (POS)))
232 #define BIT10(POS) (1 << _LSB_SHIFT (10, (POS)))
234 #if (WITH_TARGET_WORD_MSB == 0)
235 #define BIT8 MSBIT8
236 #define BIT16 MSBIT16
237 #define BIT32 MSBIT32
238 #define BIT64 MSBIT64
239 #define BIT MSBIT
240 #else
241 #define BIT8 LSBIT8
242 #define BIT16 LSBIT16
243 #define BIT32 LSBIT32
244 #define BIT64 LSBIT64
245 #define BIT LSBIT
246 #endif
250 /* multi bit mask */
252 /* 111111 -> mmll11 -> mm11ll */
253 #define _MASKn(WIDTH, START, STOP) (((unsigned##WIDTH)(-1) \
254 >> (_MSB_SHIFT (WIDTH, START) \
255 + _LSB_SHIFT (WIDTH, STOP))) \
256 << _LSB_SHIFT (WIDTH, STOP))
258 #if (WITH_TARGET_WORD_MSB == 0)
259 #define _POS_LE(START, STOP) (START <= STOP)
260 #else
261 #define _POS_LE(START, STOP) (STOP <= START)
262 #endif
264 #if (WITH_TARGET_WORD_BITSIZE == 64)
265 #define MASK(START, STOP) \
266 (_POS_LE ((START), (STOP)) \
267 ? _MASKn(64, \
268 _MSB ((START), (STOP)), \
269 _LSB ((START), (STOP)) ) \
270 : (_MASKn(64, _MSB_POS (64, 0), (STOP)) \
271 | _MASKn(64, (START), _LSB_POS (64, 0))))
272 #endif
273 #if (WITH_TARGET_WORD_BITSIZE == 32)
274 #define MASK(START, STOP) \
275 (_POS_LE ((START), (STOP)) \
276 ? (_POS_LE ((STOP), _MSB_POS (64, 31)) \
277 ? 0 \
278 : _MASKn (32, \
279 _MSB_32 ((START), (STOP)), \
280 _LSB_32 ((START), (STOP)))) \
281 : (_MASKn (32, \
282 _LSB_32 ((START), (STOP)), \
283 _LSB_POS (32, 0)) \
284 | (_POS_LE ((STOP), _MSB_POS (64, 31)) \
285 ? 0 \
286 : _MASKn (32, \
287 _MSB_POS (32, 0), \
288 _MSB_32 ((START), (STOP))))))
289 #endif
290 #if !defined (MASK)
291 #error "MASK never undefined"
292 #endif
295 /* Multi-bit mask on least significant bits */
297 #define _LSMASKn(WIDTH, FIRST, LAST) _MASKn (WIDTH, \
298 _LSB_POS (WIDTH, FIRST), \
299 _LSB_POS (WIDTH, LAST))
301 #define LSMASK8(FIRST, LAST) _LSMASKn ( 8, (FIRST), (LAST))
302 #define LSMASK16(FIRST, LAST) _LSMASKn (16, (FIRST), (LAST))
303 #define LSMASK32(FIRST, LAST) _LSMASKn (32, (FIRST), (LAST))
304 #define LSMASK64(FIRST, LAST) _LSMASKn (64, (FIRST), (LAST))
306 #define LSMASK(FIRST, LAST) (MASK (_LSB_POS (64, FIRST), _LSB_POS (64, LAST)))
309 /* Multi-bit mask on most significant bits */
311 #define _MSMASKn(WIDTH, FIRST, LAST) _MASKn (WIDTH, \
312 _MSB_POS (WIDTH, FIRST), \
313 _MSB_POS (WIDTH, LAST))
315 #define MSMASK8(FIRST, LAST) _MSMASKn ( 8, (FIRST), (LAST))
316 #define MSMASK16(FIRST, LAST) _MSMASKn (16, (FIRST), (LAST))
317 #define MSMASK32(FIRST, LAST) _MSMASKn (32, (FIRST), (LAST))
318 #define MSMASK64(FIRST, LAST) _MSMASKn (64, (FIRST), (LAST))
320 #define MSMASK(FIRST, LAST) (MASK (_MSB_POS (64, FIRST), _MSB_POS (64, LAST)))
324 #if (WITH_TARGET_WORD_MSB == 0)
325 #define MASK8 MSMASK8
326 #define MASK16 MSMASK16
327 #define MASK32 MSMASK32
328 #define MASK64 MSMASK64
329 #else
330 #define MASK8 LSMASK8
331 #define MASK16 LSMASK16
332 #define MASK32 LSMASK32
333 #define MASK64 LSMASK64
334 #endif
338 /* mask the required bits, leaving them in place */
340 INLINE_SIM_BITS(unsigned8) LSMASKED8 (unsigned8 word, int first, int last);
341 INLINE_SIM_BITS(unsigned16) LSMASKED16 (unsigned16 word, int first, int last);
342 INLINE_SIM_BITS(unsigned32) LSMASKED32 (unsigned32 word, int first, int last);
343 INLINE_SIM_BITS(unsigned64) LSMASKED64 (unsigned64 word, int first, int last);
345 INLINE_SIM_BITS(unsigned_word) LSMASKED (unsigned_word word, int first, int last);
347 INLINE_SIM_BITS(unsigned8) MSMASKED8 (unsigned8 word, int first, int last);
348 INLINE_SIM_BITS(unsigned16) MSMASKED16 (unsigned16 word, int first, int last);
349 INLINE_SIM_BITS(unsigned32) MSMASKED32 (unsigned32 word, int first, int last);
350 INLINE_SIM_BITS(unsigned64) MSMASKED64 (unsigned64 word, int first, int last);
352 INLINE_SIM_BITS(unsigned_word) MSMASKED (unsigned_word word, int first, int last);
354 #if (WITH_TARGET_WORD_MSB == 0)
355 #define MASKED8 MSMASKED8
356 #define MASKED16 MSMASKED16
357 #define MASKED32 MSMASKED32
358 #define MASKED64 MSMASKED64
359 #define MASKED MSMASKED
360 #else
361 #define MASKED8 LSMASKED8
362 #define MASKED16 LSMASKED16
363 #define MASKED32 LSMASKED32
364 #define MASKED64 LSMASKED64
365 #define MASKED LSMASKED
366 #endif
370 /* extract the required bits aligning them with the lsb */
372 INLINE_SIM_BITS(unsigned8) LSEXTRACTED8 (unsigned8 val, int start, int stop);
373 INLINE_SIM_BITS(unsigned16) LSEXTRACTED16 (unsigned16 val, int start, int stop);
374 INLINE_SIM_BITS(unsigned32) LSEXTRACTED32 (unsigned32 val, int start, int stop);
375 INLINE_SIM_BITS(unsigned64) LSEXTRACTED64 (unsigned64 val, int start, int stop);
377 INLINE_SIM_BITS(unsigned_word) LSEXTRACTED (unsigned_word val, int start, int stop);
379 INLINE_SIM_BITS(unsigned8) MSEXTRACTED8 (unsigned8 val, int start, int stop);
380 INLINE_SIM_BITS(unsigned16) MSEXTRACTED16 (unsigned16 val, int start, int stop);
381 INLINE_SIM_BITS(unsigned32) MSEXTRACTED32 (unsigned32 val, int start, int stop);
382 INLINE_SIM_BITS(unsigned64) MSEXTRACTED64 (unsigned64 val, int start, int stop);
384 INLINE_SIM_BITS(unsigned_word) MSEXTRACTED (unsigned_word val, int start, int stop);
386 #if (WITH_TARGET_WORD_MSB == 0)
387 #define EXTRACTED8 MSEXTRACTED8
388 #define EXTRACTED16 MSEXTRACTED16
389 #define EXTRACTED32 MSEXTRACTED32
390 #define EXTRACTED64 MSEXTRACTED64
391 #define EXTRACTED MSEXTRACTED
392 #else
393 #define EXTRACTED8 LSEXTRACTED8
394 #define EXTRACTED16 LSEXTRACTED16
395 #define EXTRACTED32 LSEXTRACTED32
396 #define EXTRACTED64 LSEXTRACTED64
397 #define EXTRACTED LSEXTRACTED
398 #endif
402 /* move a single bit around */
403 /* NB: the wierdness (N>O?N-O:0) is to stop a warning from GCC */
404 #define _SHUFFLEDn(N, WORD, OLD, NEW) \
405 ((OLD) < (NEW) \
406 ? (((unsigned##N)(WORD) \
407 >> (((NEW) > (OLD)) ? ((NEW) - (OLD)) : 0)) \
408 & MASK32((NEW), (NEW))) \
409 : (((unsigned##N)(WORD) \
410 << (((OLD) > (NEW)) ? ((OLD) - (NEW)) : 0)) \
411 & MASK32((NEW), (NEW))))
413 #define SHUFFLED32(WORD, OLD, NEW) _SHUFFLEDn (32, WORD, OLD, NEW)
414 #define SHUFFLED64(WORD, OLD, NEW) _SHUFFLEDn (64, WORD, OLD, NEW)
416 #define SHUFFLED(WORD, OLD, NEW) _SHUFFLEDn (_word, WORD, OLD, NEW)
419 /* Insert a group of bits into a bit position */
421 INLINE_SIM_BITS(unsigned8) LSINSERTED8 (unsigned8 val, int start, int stop);
422 INLINE_SIM_BITS(unsigned16) LSINSERTED16 (unsigned16 val, int start, int stop);
423 INLINE_SIM_BITS(unsigned32) LSINSERTED32 (unsigned32 val, int start, int stop);
424 INLINE_SIM_BITS(unsigned64) LSINSERTED64 (unsigned64 val, int start, int stop);
425 INLINE_SIM_BITS(unsigned_word) LSINSERTED (unsigned_word val, int start, int stop);
427 INLINE_SIM_BITS(unsigned8) MSINSERTED8 (unsigned8 val, int start, int stop);
428 INLINE_SIM_BITS(unsigned16) MSINSERTED16 (unsigned16 val, int start, int stop);
429 INLINE_SIM_BITS(unsigned32) MSINSERTED32 (unsigned32 val, int start, int stop);
430 INLINE_SIM_BITS(unsigned64) MSINSERTED64 (unsigned64 val, int start, int stop);
431 INLINE_SIM_BITS(unsigned_word) MSINSERTED (unsigned_word val, int start, int stop);
433 #if (WITH_TARGET_WORD_MSB == 0)
434 #define INSERTED8 MSINSERTED8
435 #define INSERTED16 MSINSERTED16
436 #define INSERTED32 MSINSERTED32
437 #define INSERTED64 MSINSERTED64
438 #define INSERTED MSINSERTED
439 #else
440 #define INSERTED8 LSINSERTED8
441 #define INSERTED16 LSINSERTED16
442 #define INSERTED32 LSINSERTED32
443 #define INSERTED64 LSINSERTED64
444 #define INSERTED LSINSERTED
445 #endif
449 /* MOVE bits from one loc to another (combination of extract/insert) */
451 #define MOVED8(VAL,OH,OL,NH,NL) INSERTED8 (EXTRACTED8 ((VAL), OH, OL), NH, NL)
452 #define MOVED16(VAL,OH,OL,NH,NL) INSERTED16(EXTRACTED16((VAL), OH, OL), NH, NL)
453 #define MOVED32(VAL,OH,OL,NH,NL) INSERTED32(EXTRACTED32((VAL), OH, OL), NH, NL)
454 #define MOVED64(VAL,OH,OL,NH,NL) INSERTED64(EXTRACTED64((VAL), OH, OL), NH, NL)
455 #define MOVED(VAL,OH,OL,NH,NL) INSERTED (EXTRACTED ((VAL), OH, OL), NH, NL)
459 /* Sign extend the quantity to the targets natural word size */
461 #define EXTEND4(X) (LSSEXT ((X), 3))
462 #define EXTEND5(X) (LSSEXT ((X), 4))
463 #define EXTEND8(X) ((signed_word)(signed8)(X))
464 #define EXTEND11(X) (LSSEXT ((X), 10))
465 #define EXTEND15(X) (LSSEXT ((X), 14))
466 #define EXTEND16(X) ((signed_word)(signed16)(X))
467 #define EXTEND24(X) (LSSEXT ((X), 24))
468 #define EXTEND32(X) ((signed_word)(signed32)(X))
469 #define EXTEND64(X) ((signed_word)(signed64)(X))
471 /* depending on MODE return a 64bit or 32bit (sign extended) value */
472 #if (WITH_TARGET_WORD_BITSIZE == 64)
473 #define EXTENDED(X) ((signed64)(signed32)(X))
474 #endif
475 #if (WITH_TARGET_WORD_BITSIZE == 32)
476 #define EXTENDED(X) (X)
477 #endif
480 /* memory alignment macro's */
481 #define _ALIGNa(A,X) (((X) + ((A) - 1)) & ~((A) - 1))
482 #define _FLOORa(A,X) ((X) & ~((A) - 1))
484 #define ALIGN_8(X) _ALIGNa (8, X)
485 #define ALIGN_16(X) _ALIGNa (16, X)
487 #define ALIGN_PAGE(X) _ALIGNa (0x1000, X)
488 #define FLOOR_PAGE(X) ((X) & ~(0x1000 - 1))
491 /* bit bliting macro's */
492 #define BLIT32(V, POS, BIT) \
493 do { \
494 if (BIT) \
495 V |= BIT32 (POS); \
496 else \
497 V &= ~BIT32 (POS); \
498 } while (0)
499 #define MBLIT32(V, LO, HI, VAL) \
500 do { \
501 (V) = (((V) & ~MASK32 ((LO), (HI))) \
502 | INSERTED32 (VAL, LO, HI)); \
503 } while (0)
507 /* some rotate functions. The generic macro's ROT, ROTL, ROTR are
508 intentionally omited. */
511 INLINE_SIM_BITS(unsigned8) ROT8 (unsigned8 val, int shift);
512 INLINE_SIM_BITS(unsigned16) ROT16 (unsigned16 val, int shift);
513 INLINE_SIM_BITS(unsigned32) ROT32 (unsigned32 val, int shift);
514 INLINE_SIM_BITS(unsigned64) ROT64 (unsigned64 val, int shift);
517 INLINE_SIM_BITS(unsigned8) ROTL8 (unsigned8 val, int shift);
518 INLINE_SIM_BITS(unsigned16) ROTL16 (unsigned16 val, int shift);
519 INLINE_SIM_BITS(unsigned32) ROTL32 (unsigned32 val, int shift);
520 INLINE_SIM_BITS(unsigned64) ROTL64 (unsigned64 val, int shift);
523 INLINE_SIM_BITS(unsigned8) ROTR8 (unsigned8 val, int shift);
524 INLINE_SIM_BITS(unsigned16) ROTR16 (unsigned16 val, int shift);
525 INLINE_SIM_BITS(unsigned32) ROTR32 (unsigned32 val, int shift);
526 INLINE_SIM_BITS(unsigned64) ROTR64 (unsigned64 val, int shift);
530 /* Sign extension operations */
532 INLINE_SIM_BITS(unsigned8) LSSEXT8 (signed8 val, int sign_bit);
533 INLINE_SIM_BITS(unsigned16) LSSEXT16 (signed16 val, int sign_bit);
534 INLINE_SIM_BITS(unsigned32) LSSEXT32 (signed32 val, int sign_bit);
535 INLINE_SIM_BITS(unsigned64) LSSEXT64 (signed64 val, int sign_bit);
536 INLINE_SIM_BITS(unsigned_word) LSSEXT (signed_word val, int sign_bit);
538 INLINE_SIM_BITS(unsigned8) MSSEXT8 (signed8 val, int sign_bit);
539 INLINE_SIM_BITS(unsigned16) MSSEXT16 (signed16 val, int sign_bit);
540 INLINE_SIM_BITS(unsigned32) MSSEXT32 (signed32 val, int sign_bit);
541 INLINE_SIM_BITS(unsigned64) MSSEXT64 (signed64 val, int sign_bit);
542 INLINE_SIM_BITS(unsigned_word) MSSEXT (signed_word val, int sign_bit);
544 #if (WITH_TARGET_WORD_MSB == 0)
545 #define SEXT8 MSSEXT8
546 #define SEXT16 MSSEXT16
547 #define SEXT32 MSSEXT32
548 #define SEXT64 MSSEXT64
549 #define SEXT MSSEXT
550 #else
551 #define SEXT8 LSSEXT8
552 #define SEXT16 LSSEXT16
553 #define SEXT32 LSSEXT32
554 #define SEXT64 LSSEXT64
555 #define SEXT LSSEXT
556 #endif
560 #if H_REVEALS_MODULE_P (SIM_BITS_INLINE)
561 #include "sim-bits.c"
562 #endif
564 #endif /* _SIM_BITS_H_ */