aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>1997-09-08 17:21:13 +0000
committerAndrew Cagney <cagney@redhat.com>1997-09-08 17:21:13 +0000
commit75b3697d5f175e7121f792ca5ab9e36eeaaf5fc1 (patch)
tree4e7447096bd0de7d200944000c407dff04b7c22f
parent986cb931ca73badb93a5a392a0775458a040384e (diff)
downloadfsf-binutils-gdb-75b3697d5f175e7121f792ca5ab9e36eeaaf5fc1.zip
fsf-binutils-gdb-75b3697d5f175e7121f792ca5ab9e36eeaaf5fc1.tar.gz
fsf-binutils-gdb-75b3697d5f175e7121f792ca5ab9e36eeaaf5fc1.tar.bz2
Add/use LSEXTRACTED, MSEXTRACTED macros.
Add CPU_CIA macro to extract the PC.
-rw-r--r--sim/common/ChangeLog24
-rw-r--r--sim/common/sim-bits.c110
-rw-r--r--sim/common/sim-bits.h234
-rw-r--r--sim/common/sim-n-bits.h44
4 files changed, 228 insertions, 184 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index 72f6a78..6959325 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,3 +1,27 @@
+Tue Sep 9 02:10:36 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * sim-fpu.c (DP_FRACHIGH2): Define LL using SIGNED64.
+
+Mon Sep 8 12:22:20 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * sim-bits.c (MASKED): Delete.
+ (EXTRACTED): Delete.
+ (LSEXTRACTED, MSEXTRACTED): New functions.
+
+ * sim-n-bits.h (MASKEDn): Delete, define as MSMASKED or LSMASKED.
+ (MSMASKEDn, LSMASKEDn): Add last argument.
+ (MSMASK*): Ditto.
+
+ * sim-bits.h (EXTEND8, EXTEND16): Define.
+ (EXTRACTED64): Define as 64 bit extract, not 32 bit.
+
+ * sim-run.c (sim_engine_run): Use CPU_CIA macro.
+
+ * sim-engine.h (SIM_ENGINE_HALT_HOOK): Use CPU_CIA to get at
+ current instruction address.
+
+ * sim-inline.h (*_ENGINE): Define.
+
Fri Sep 5 08:39:02 1997 Andrew Cagney <cagney@b1.cygnus.com>
* sim-core.c (sim_core_attach): Fix checks of modulo/mask.
diff --git a/sim/common/sim-bits.c b/sim/common/sim-bits.c
index 1c08c4d..9187cf5 100644
--- a/sim/common/sim-bits.c
+++ b/sim/common/sim-bits.c
@@ -24,71 +24,131 @@
#include "sim-basics.h"
#include "sim-assert.h"
+#include "sim-io.h"
+
INLINE_SIM_BITS\
(unsigned_word)
-MASKED(unsigned_word val,
- unsigned start,
- unsigned stop)
+LSMASKED (unsigned_word val,
+ int start,
+ int stop)
{
- return ((val) & MASK(start, stop));
+ /* NOTE - start, stop can wrap */
+ val &= LSMASK (start, stop);
+ return val;
}
-
INLINE_SIM_BITS\
(unsigned_word)
-LSMASKED(unsigned_word val,
- unsigned nr_bits)
+MSMASKED (unsigned_word val,
+ int start,
+ int stop)
{
- return MASKED(val,
- WITH_TARGET_WORD_BITSIZE - nr_bits,
- WITH_TARGET_WORD_BITSIZE - 1);
+ /* NOTE - start, stop can wrap */
+ val &= MSMASK (start, stop);
+ return val;
}
+INLINE_SIM_BITS\
+(unsigned_word)
+LSEXTRACTED (unsigned_word val,
+ int start,
+ int stop)
+{
+ ASSERT (start >= stop);
+#if (WITH_TARGET_WORD_BITSIZE == 64)
+ return LSEXTRACTED64 (val, start, stop);
+#endif
+#if (WITH_TARGET_WORD_BITSIZE == 32)
+ if (stop >= 32)
+ return 0;
+ else
+ {
+ if (start < 32)
+ val &= LSMASK (start, 0);
+ val >>= stop;
+ return val;
+ }
+#endif
+}
+
INLINE_SIM_BITS\
(unsigned_word)
-EXTRACTED(unsigned_word val,
- unsigned start,
- unsigned stop)
+MSEXTRACTED (unsigned_word val,
+ int start,
+ int stop)
{
- ASSERT(start <= stop);
+ ASSERT (start <= stop);
#if (WITH_TARGET_WORD_BITSIZE == 64)
- return EXTRACTED64(val, start, stop);
+ return MSEXTRACTED64 (val, start, stop);
#endif
#if (WITH_TARGET_WORD_BITSIZE == 32)
if (stop < 32)
return 0;
else
- return ((val >> (63 - stop))
- & MASK(start+(63-stop), 63));
+ {
+ if (start >= 32)
+ val &= MSMASK (start, 64 - 1);
+ val >>= (64 - stop - 1);
+ return val;
+ }
#endif
}
INLINE_SIM_BITS\
(unsigned_word)
-INSERTED(unsigned_word val,
- unsigned start,
- unsigned stop)
+INSERTED (unsigned_word val,
+ int start,
+ int stop)
{
- ASSERT(start <= stop);
+ ASSERT ((WITH_TARGET_WORD_MSB == 0 && start <= stop)
+ || (WITH_TARGET_WORD_MSB != 0 && start >= stop));
#if (WITH_TARGET_WORD_BITSIZE == 64)
- return INSERTED64(val, start, stop);
+ return INSERTED64 (val, start, stop);
#endif
#if (WITH_TARGET_WORD_BITSIZE == 32)
- if (stop < 32)
+ /* Bit numbers are 0..63, even for 32 bit targets.
+ On 32 bit targets we ignore 0..31. */
+ if (_LSB_SHIFT (64, stop) >= 32)
return 0;
else
- return ((val & MASK(start+(63-stop), 63))
- << (63 - stop));
+ {
+ val &= LSMASK (_MAKE_WIDTH (start, stop), 0);
+ val <<= _LSB_SHIFT (64, stop);
+ return val;
+ }
#endif
}
+INLINE_SIM_BITS\
+(unsigned_word)
+SEXT (signed_word val,
+ int sign_bit)
+{
+ /* make the sign-bit most significant and then smear it back into
+ position */
+ ASSERT (sign_bit < 64);
+#if (WITH_TARGET_WORD_BITSIZE == 64)
+ return SEXT64 (val, sign_bit);
+#endif
+#if (WITH_TARGET_WORD_BITSIZE == 32)
+ if (_MSB_SHIFT (64, sign_bit) < 32)
+ return val;
+ else {
+ val <<= (_MSB_SHIFT (64, sign_bit) - 32);
+ val >>= (_MSB_SHIFT (64, sign_bit) - 32);
+ return val;
+ }
+#endif
+}
+
+
#define N 16
#include "sim-n-bits.h"
diff --git a/sim/common/sim-bits.h b/sim/common/sim-bits.h
index b3458ee..a638c1f 100644
--- a/sim/common/sim-bits.h
+++ b/sim/common/sim-bits.h
@@ -52,18 +52,16 @@
<MACRO> (no size) version permits FIRST >= LAST and generates a
wrapped bit mask vis ([0..LAST] | [FIRST..LSB]).
- LSMASK*(NR_BITS): Like MASK only NR least significant bits are set.
+ LSMASK*(FIRST, LAST): Like MASK - LS bit is zero.
- MSMASK*(NR_BITS): Like MASK only NR most significant bits are set.
+ MSMASK*(FIRST, LAST): Like MASK - LS bit is zero.
MASKED*(VALUE, FIRST, LAST): Masks out all but bits [FIRST
.. LAST].
- LSMASKED*(VALUE, NR_BITS): Mask out all but the least significant
- NR_BITS of the value.
+ LSMASKED*(VALUE, FIRST, LAST): Like MASKED - LS bit is zero.
- MSMASKED*(VALUE, NR_BITS): Mask out all but the most significant
- NR_BITS of the value.
+ MSMASKED*(VALUE, FIRST, LAST): Like MASKED - MS bit is zero.
EXTRACTED*(VALUE, FIRST, LAST): Masks out bits [FIRST .. LAST] but
also right shifts the masked value so that bit LAST becomes the
@@ -89,8 +87,8 @@
IEA_MASKED(SHOULD_MASK, ADDR): Convert the address to the targets
natural size. If in 32bit mode, discard the high 32bits.
- EXTENDED(VALUE): Convert VALUE (32bits of it) to the targets
- natural size. If in 64bit mode, sign extend the value.
+ EXTENDED*(VALUE): Convert the `*' bit value to the targets natural
+ word size. Sign extned the value if needed.
ALIGN_*(VALUE): Round upwards the value so that it is aligned.
@@ -187,6 +185,21 @@
#endif
+/* LS/MS Bit operations */
+
+#define LSBIT8(POS) ((unsigned8)1 << (POS))
+#define LSBIT16(POS) ((unsigned16)1 << (POS))
+#define LSBIT32(POS) ((unsigned32)1 << (POS))
+#define LSBIT64(POS) ((unsigned64)1 << (POS))
+#define LSBIT(POS) ((unsigned_word)1 << (POS))
+
+#define MSBIT8(POS) ((unsigned8)1 << (8 - 1 - (POS)))
+#define MSBIT16(POS) ((unsigned16)1 << (16 - 1 - (POS)))
+#define MSBIT32(POS) ((unsigned32)1 << (32 - 1 - (POS)))
+#define MSBIT64(POS) ((unsigned64)1 << (64 - 1 - (POS)))
+#define MSBIT(POS) ((unsigned_word)1 << (WITH_TARGET_WORD_BITSIZE - 1 - (POS)))
+
+
/* Bit operations */
#define _BITn(WIDTH, POS) ((natural##WIDTH)1 \
@@ -219,22 +232,6 @@
#endif
-/* LS/MS Bit operations */
-
-#define LSBIT8(POS) ((unsigned8)1 << (POS))
-#define LSBIT16(POS) ((unsigned16)1 << (POS))
-#define LSBIT32(POS) ((unsigned32)1 << (POS))
-#define LSBIT64(POS) ((unsigned64)1 << (POS))
-#define LSBIT(POS) ((unsigned_word)1 << (POS))
-
-#define MSBIT8(POS) ((unsigned8)1 << (8 - 1 - (POS)))
-#define MSBIT16(POS) ((unsigned16)1 << (16 - 1 - (POS)))
-#define MSBIT32(POS) ((unsigned32)1 << (32 - 1 - (POS)))
-#define MSBIT64(POS) ((unsigned64)1 << (64 - 1 - (POS)))
-#define MSBIT(POS) ((unsigned_word)1 << (WITH_TARGET_WORD_BITSIZE - 1 - (POS)))
-
-
-
/* multi bit mask */
/* 111111 -> mmll11 -> mm11ll */
@@ -243,10 +240,6 @@
+ _LSB_SHIFT (WIDTH, STOP))) \
<< _LSB_SHIFT (WIDTH, STOP))
-#define MASK16(START, STOP) _MASKn(16, (START), (STOP))
-#define MASK32(START, STOP) _MASKn(32, (START), (STOP))
-#define MASK64(START, STOP) _MASKn(64, (START), (STOP))
-
#if (WITH_TARGET_WORD_MSB == 0)
#define _POS_LE(START, STOP) (START <= STOP)
#else
@@ -284,133 +277,101 @@
#endif
-
/* Multi-bit mask on least significant bits */
-#if (WITH_TARGET_WORD_MSB == 0)
-#define _LSMASKn(WIDTH, NR_BITS) _MASKn(WIDTH, (WIDTH - NR_BITS), (WIDTH - 1))
-#else
-#define _LSMASKn(WIDTH, NR_BITS) _MASKn(WIDTH, (NR_BITS - 1), 0)
-#endif
+#define _LSMASKn(WIDTH, FIRST, LAST) _MASKn (WIDTH, \
+ _LSB_POS (WIDTH, FIRST), \
+ _LSB_POS (WIDTH, LAST))
-#define LSMASK16(NR_BITS) _LSMASKn (16, (NR_BITS))
-#define LSMASK32(NR_BITS) _LSMASKn (32, (NR_BITS))
-#define LSMASK64(NR_BITS) _LSMASKn (64, (NR_BITS))
+#define LSMASK16(FIRST, LAST) _LSMASKn (16, (FIRST), (LAST))
+#define LSMASK32(FIRST, LAST) _LSMASKn (32, (FIRST), (LAST))
+#define LSMASK64(FIRST, LAST) _LSMASKn (64, (FIRST), (LAST))
-#if (WITH_TARGET_WORD_BITSIZE == 64)
-#define LSMASK(NR_BITS) ((NR_BITS) < 1 \
- ? 0 \
- : _MASKn (64, \
- _LSB_POS (64, \
- ((NR_BITS) < 1 ? 0 \
- : (NR_BITS) - 1)), \
- _LSB_POS (64, 0)))
-#endif
-#if (WITH_TARGET_WORD_BITSIZE == 32)
-#define LSMASK(NR_BITS) ((NR_BITS) < 1 \
- ? 0 \
- : _MASKn (32, \
- _LSB_POS (32, \
- ((NR_BITS) > 32 ? 31 \
- : (NR_BITS) < 1 ? 0 \
- : ((NR_BITS) - 1))), \
- _LSB_POS (32, 0)))
-#endif
-#if !defined (LSMASK)
-#error "LSMASK never defined"
-#endif
+#define LSMASK(FIRST, LAST) (MASK (_LSB_POS (64, FIRST), _LSB_POS (64, LAST)))
/* Multi-bit mask on most significant bits */
-#if (WITH_TARGET_WORD_MSB == 0)
-#define _MSMASKn(WIDTH, NR_BITS) _MASKn (WIDTH, 0, (NR_BITS - 1))
-#else
-#define _MSMASKn(WIDTH, NR_BITS) _MASKn (WIDTH, (WIDTH - 1), (WIDTH - NR_BITS))
-#endif
-
-#define MSMASK16(NR_BITS) _MSMASKn (16, (NR_BITS))
-#define MSMASK32(NR_BITS) _MSMASKn (32, (NR_BITS))
-#define MSMASK64(NR_BITS) _MSMASKn (64, (NR_BITS))
+#define _MSMASKn(WIDTH, FIRST, LAST) _MASKn (WIDTH, \
+ _MSB_POS (WIDTH, FIRST), \
+ _MSB_POS (WIDTH, LAST))
-#if (WITH_TARGET_WORD_BITSIZE == 64)
-#define MSMASK(NR_BITS) (NR_BITS < 1 \
- ? 0 \
- : _MASKn (64, \
- _MSB_POS (64, 0), \
- _MSB_POS (64, \
- ((NR_BITS) < 1 ? 0 \
- : (NR_BITS) - 1))))
-#endif
-#if (WITH_TARGET_WORD_BITSIZE == 32)
-#define MSMASK(NR_BITS) (NR_BITS <= 32 \
- ? 0 \
- : _MASKn (32, \
- _MSB_POS (32, 0), \
- _MSB_POS (32, \
- ((NR_BITS) <= 32 ? 0 \
- : (NR_BITS) - 33))))
-#endif
-#if !defined (MSMASK)
-#error "MSMASK never defined"
-#endif
+#define MSMASK16(FIRST, LAST) _MSMASKn (16, (FIRST), (LAST))
+#define MSMASK32(FIRST, LAST) _MSMASKn (32, (FIRST), (LAST))
+#define MSMASK64(FIRST, LAST) _MSMASKn (64, (FIRST), (LAST))
+#define MSMASK(FIRST, LAST) (MASK (_MSB_POS (64, FIRST), _MSB_POS (64, LAST)))
-/* mask the required bits, leaving them in place */
-INLINE_SIM_BITS(unsigned16) MASKED16 (unsigned16 word, unsigned start, unsigned stop);
-INLINE_SIM_BITS(unsigned32) MASKED32 (unsigned32 word, unsigned start, unsigned stop);
-INLINE_SIM_BITS(unsigned64) MASKED64 (unsigned64 word, unsigned start, unsigned stop);
-INLINE_SIM_BITS(unsigned_word) MASKED (unsigned_word word, unsigned start, unsigned stop);
+#if (WITH_TARGET_WORD_MSB == 0)
+#define MASK16 MSMASK16
+#define MASK32 MSMASK32
+#define MASK64 MSMASK64
+#else
+#define MASK16 LSMASK16
+#define MASK32 LSMASK32
+#define MASK64 LSMASK64
+#endif
-/* Ditto but nr of ls-bits specified */
-INLINE_SIM_BITS(unsigned16) LSMASKED16 (unsigned16 word, unsigned nr_bits);
-INLINE_SIM_BITS(unsigned32) LSMASKED32 (unsigned32 word, unsigned nr_bits);
-INLINE_SIM_BITS(unsigned64) LSMASKED64 (unsigned64 word, unsigned nr_bits);
+/* mask the required bits, leaving them in place */
-INLINE_SIM_BITS(unsigned_word) LSMASKED (unsigned_word word, unsigned nr_bits);
+INLINE_SIM_BITS(unsigned16) LSMASKED16 (unsigned16 word, int first, int last);
+INLINE_SIM_BITS(unsigned32) LSMASKED32 (unsigned32 word, int first, int last);
+INLINE_SIM_BITS(unsigned64) LSMASKED64 (unsigned64 word, int first, int last);
+INLINE_SIM_BITS(unsigned_word) LSMASKED (unsigned_word word, int first, int last);
-/* Ditto but nr of ms-bits specified */
+INLINE_SIM_BITS(unsigned16) MSMASKED16 (unsigned16 word, int first, int last);
+INLINE_SIM_BITS(unsigned32) MSMASKED32 (unsigned32 word, int first, int last);
+INLINE_SIM_BITS(unsigned64) MSMASKED64 (unsigned64 word, int first, int last);
-INLINE_SIM_BITS(unsigned16) MSMASKED16 (unsigned16 word, unsigned nr_bits);
-INLINE_SIM_BITS(unsigned32) MSMASKED32 (unsigned32 word, unsigned nr_bits);
-INLINE_SIM_BITS(unsigned64) MSMASKED64 (unsigned64 word, unsigned nr_bits);
+INLINE_SIM_BITS(unsigned_word) MSMASKED (unsigned_word word, int first, int last);
-INLINE_SIM_BITS(unsigned_word) MSMASKED (unsigned_word word, unsigned nr_bits);
+#if (WITH_TARGET_WORD_MSB == 0)
+#define MASKED16 MSMASKED16
+#define MASKED32 MSMASKED32
+#define MASKED64 MSMASKED64
+#define MASKED MSMASKED
+#else
+#define MASKED16 LSMASKED16
+#define MASKED32 LSMASKED32
+#define MASKED64 LSMASKED64
+#define MASKED LSMASKED
+#endif
/* extract the required bits aligning them with the lsb */
-INLINE_SIM_BITS(unsigned16) LSEXTRACTED16 (unsigned16 val, unsigned start, unsigned stop);
-INLINE_SIM_BITS(unsigned32) LSEXTRACTED32 (unsigned32 val, unsigned start, unsigned stop);
-INLINE_SIM_BITS(unsigned64) LSEXTRACTED64 (unsigned64 val, unsigned start, unsigned stop);
+INLINE_SIM_BITS(unsigned16) LSEXTRACTED16 (unsigned16 val, int start, int stop);
+INLINE_SIM_BITS(unsigned32) LSEXTRACTED32 (unsigned32 val, int start, int stop);
+INLINE_SIM_BITS(unsigned64) LSEXTRACTED64 (unsigned64 val, int start, int stop);
+
+INLINE_SIM_BITS(unsigned_word) LSEXTRACTED (unsigned_word val, int start, int stop);
-INLINE_SIM_BITS(unsigned16) MSEXTRACTED16 (unsigned16 val, unsigned start, unsigned stop);
-INLINE_SIM_BITS(unsigned32) MSEXTRACTED32 (unsigned32 val, unsigned start, unsigned stop);
-INLINE_SIM_BITS(unsigned64) MSEXTRACTED64 (unsigned64 val, unsigned start, unsigned stop);
+INLINE_SIM_BITS(unsigned16) MSEXTRACTED16 (unsigned16 val, int start, int stop);
+INLINE_SIM_BITS(unsigned32) MSEXTRACTED32 (unsigned32 val, int start, int stop);
+INLINE_SIM_BITS(unsigned64) MSEXTRACTED64 (unsigned64 val, int start, int stop);
+
+INLINE_SIM_BITS(unsigned_word) MSEXTRACTED (unsigned_word val, int start, int stop);
#if (WITH_TARGET_WORD_MSB == 0)
-#define EXTRACTED16 MSEXTRACTED32
+#define EXTRACTED16 MSEXTRACTED16
#define EXTRACTED32 MSEXTRACTED32
-#define EXTRACTED64 MSEXTRACTED32
+#define EXTRACTED64 MSEXTRACTED64
+#define EXTRACTED MSEXTRACTED
#else
-#define EXTRACTED16 LSEXTRACTED32
+#define EXTRACTED16 LSEXTRACTED16
#define EXTRACTED32 LSEXTRACTED32
-#define EXTRACTED64 LSEXTRACTED32
+#define EXTRACTED64 LSEXTRACTED64
+#define EXTRACTED LSEXTRACTED
#endif
-
-INLINE_SIM_BITS(unsigned_word) EXTRACTED (unsigned_word val, unsigned start, unsigned stop);
-
-
-
/* move a single bit around */
/* NB: the wierdness (N>O?N-O:0) is to stop a warning from GCC */
#define _SHUFFLEDn(N, WORD, OLD, NEW) \
@@ -430,13 +391,20 @@ INLINE_SIM_BITS(unsigned_word) EXTRACTED (unsigned_word val, unsigned start, uns
/* move a group of bits around */
-INLINE_SIM_BITS(unsigned16) INSERTED16 (unsigned16 val, unsigned start, unsigned stop);
-INLINE_SIM_BITS(unsigned32) INSERTED32 (unsigned32 val, unsigned start, unsigned stop);
-INLINE_SIM_BITS(unsigned64) INSERTED64 (unsigned64 val, unsigned start, unsigned stop);
+INLINE_SIM_BITS(unsigned16) INSERTED16 (unsigned16 val, int start, int stop);
+INLINE_SIM_BITS(unsigned32) INSERTED32 (unsigned32 val, int start, int stop);
+INLINE_SIM_BITS(unsigned64) INSERTED64 (unsigned64 val, int start, int stop);
+
+INLINE_SIM_BITS(unsigned_word) INSERTED (unsigned_word val, int start, int stop);
+
-INLINE_SIM_BITS(unsigned_word) INSERTED (unsigned_word val, unsigned start, unsigned stop);
+/* Sign extend the quantity to the targets natural word size */
+#define EXTEND8(X) ((signed_word)(signed8)(X))
+#define EXTEND16(X) ((signed_word)(signed16)(X))
+#define EXTEND32(X) ((signed_word)(signed32)(X))
+#define EXTEND64(X) ((signed_word)(signed64)(X))
/* depending on MODE return a 64bit or 32bit (sign extended) value */
#if (WITH_TARGET_WORD_BITSIZE == 64)
@@ -483,24 +451,24 @@ INLINE_SIM_BITS(unsigned32) ROT32 (unsigned32 val, int shift);
INLINE_SIM_BITS(unsigned64) ROT64 (unsigned64 val, int shift);
-INLINE_SIM_BITS(unsigned16) ROTL16 (unsigned16 val, unsigned shift);
-INLINE_SIM_BITS(unsigned32) ROTL32 (unsigned32 val, unsigned shift);
-INLINE_SIM_BITS(unsigned64) ROTL64 (unsigned64 val, unsigned shift);
+INLINE_SIM_BITS(unsigned16) ROTL16 (unsigned16 val, int shift);
+INLINE_SIM_BITS(unsigned32) ROTL32 (unsigned32 val, int shift);
+INLINE_SIM_BITS(unsigned64) ROTL64 (unsigned64 val, int shift);
-INLINE_SIM_BITS(unsigned16) ROTR16 (unsigned16 val, unsigned shift);
-INLINE_SIM_BITS(unsigned32) ROTR32 (unsigned32 val, unsigned shift);
-INLINE_SIM_BITS(unsigned64) ROTR64 (unsigned64 val, unsigned shift);
+INLINE_SIM_BITS(unsigned16) ROTR16 (unsigned16 val, int shift);
+INLINE_SIM_BITS(unsigned32) ROTR32 (unsigned32 val, int shift);
+INLINE_SIM_BITS(unsigned64) ROTR64 (unsigned64 val, int shift);
/* Sign extension operations */
-INLINE_SIM_BITS(unsigned16) SEXT16 (signed16 val, unsigned sign_bit);
-INLINE_SIM_BITS(unsigned32) SEXT32 (signed32 val, unsigned sign_bit);
-INLINE_SIM_BITS(unsigned64) SEXT64 (signed64 val, unsigned sign_bit);
+INLINE_SIM_BITS(unsigned16) SEXT16 (signed16 val, int sign_bit);
+INLINE_SIM_BITS(unsigned32) SEXT32 (signed32 val, int sign_bit);
+INLINE_SIM_BITS(unsigned64) SEXT64 (signed64 val, int sign_bit);
-INLINE_SIM_BITS(unsigned_word) SEXT (signed_word val, unsigned sign_bit);
+INLINE_SIM_BITS(unsigned_word) SEXT (signed_word val, int sign_bit);
diff --git a/sim/common/sim-n-bits.h b/sim/common/sim-n-bits.h
index 5c0aa55..996095a 100644
--- a/sim/common/sim-n-bits.h
+++ b/sim/common/sim-n-bits.h
@@ -36,7 +36,6 @@
/* NOTE: See end of file for #undef */
#define unsignedN XCONCAT2(unsigned,N)
#define signedN XCONCAT2(signed,N)
-#define MASKEDn XCONCAT2(MASKED,N)
#define MASKn XCONCAT2(MASK,N)
#define LSMASKEDn XCONCAT2(LSMASKED,N)
#define LSMASKn XCONCAT2(LSMASK,N)
@@ -50,25 +49,16 @@
#define ROTRn XCONCAT2(ROTR,N)
#define SEXTn XCONCAT2(SEXT,N)
-/* TAGS: MASKED16 MASKED32 MASKED64 */
-
-INLINE_SIM_BITS\
-(unsignedN)
-MASKEDn (unsignedN word,
- unsigned start,
- unsigned stop)
-{
- return (word & MASKn (start, stop));
-}
-
/* TAGS: LSMASKED16 LSMASKED32 LSMASKED64 */
INLINE_SIM_BITS\
(unsignedN)
LSMASKEDn (unsignedN word,
- unsigned nr_bits)
+ int start,
+ int stop)
{
- return (word & LSMASKn (nr_bits));
+ word &= LSMASKn (start, stop);
+ return word;
}
/* TAGS: MSMASKED16 MSMASKED32 MSMASKED64 */
@@ -76,9 +66,11 @@ LSMASKEDn (unsignedN word,
INLINE_SIM_BITS\
(unsignedN)
MSMASKEDn (unsignedN word,
- unsigned nr_bits)
+ int start,
+ int stop)
{
- return (word & MSMASKn (nr_bits));
+ word &= MSMASKn (start, stop);
+ return word;
}
/* TAGS: LSEXTRACTED16 LSEXTRACTED32 LSEXTRACTED64 */
@@ -86,8 +78,8 @@ MSMASKEDn (unsignedN word,
INLINE_SIM_BITS\
(unsignedN)
LSEXTRACTEDn (unsignedN val,
- unsigned start,
- unsigned stop)
+ int start,
+ int stop)
{
val <<= (N - 1 - start); /* drop high bits */
val >>= (N - 1 - start) + (stop); /* drop low bits */
@@ -99,8 +91,8 @@ LSEXTRACTEDn (unsignedN val,
INLINE_SIM_BITS\
(unsignedN)
MSEXTRACTEDn (unsignedN val,
- unsigned start,
- unsigned stop)
+ int start,
+ int stop)
{
val <<= (start); /* drop high bits */
val >>= (start) + (N - 1 - stop); /* drop low bits */
@@ -112,11 +104,11 @@ MSEXTRACTEDn (unsignedN val,
INLINE_SIM_BITS\
(unsignedN)
INSERTEDn (unsignedN val,
- unsigned start,
- unsigned stop)
+ int start,
+ int stop)
{
- val &= LSMASKn (_MAKE_WIDTH (start, stop));
val <<= _LSB_SHIFT (N, stop);
+ val &= MASKn (start, stop);
return val;
}
@@ -140,7 +132,7 @@ ROTn (unsignedN val,
INLINE_SIM_BITS\
(unsignedN)
ROTLn (unsignedN val,
- unsigned shift)
+ int shift)
{
unsignedN result;
ASSERT (shift <= N);
@@ -153,7 +145,7 @@ ROTLn (unsignedN val,
INLINE_SIM_BITS\
(unsignedN)
ROTRn (unsignedN val,
- unsigned shift)
+ int shift)
{
unsignedN result;
ASSERT (shift <= N);
@@ -166,7 +158,7 @@ ROTRn (unsignedN val,
INLINE_SIM_BITS\
(unsignedN)
SEXTn (signedN val,
- unsigned sign_bit)
+ int sign_bit)
{
/* make the sign-bit most significant and then smear it back into
position */