aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sim/common/ChangeLog11
-rw-r--r--sim/common/sim-bits.c73
-rw-r--r--sim/common/sim-bits.h48
3 files changed, 107 insertions, 25 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index 62f8fc4..21c1718 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,3 +1,14 @@
+Tue Sep 16 16:15:16 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * sim-bits.c (LSSEXT, MSSEXT): Replace SEXT.
+ (LSINSERTED, MSINSERTED): Ditto for INSERTED.
+
+ * sim-n-bits.h (MSSEXTn, LSSEXTn): Replace SEXTn.
+ (LSINSERTDn, MSINSERTEDN): Ditto for INSERTEDn.
+
+ * sim-bits.h (SEXT*): Define as MSEXT/LSEXT.
+ (INSERTED*): Ditto for LSINSERTED/MSINSERTED.
+
Mon Sep 15 17:36:15 1997 Andrew Cagney <cagney@b1.cygnus.com>
* aclocal.m4 (SIM_AC_COMMON): Add optional config.h file argument.
diff --git a/sim/common/sim-bits.c b/sim/common/sim-bits.c
index 9187cf5..a200fa5 100644
--- a/sim/common/sim-bits.c
+++ b/sim/common/sim-bits.c
@@ -101,24 +101,47 @@ MSEXTRACTED (unsigned_word val,
INLINE_SIM_BITS\
(unsigned_word)
-INSERTED (unsigned_word val,
- int start,
- int stop)
+LSINSERTED (unsigned_word val,
+ int start,
+ int stop)
+{
+ ASSERT (start >= stop);
+#if (WITH_TARGET_WORD_BITSIZE == 64)
+ return LSINSERTED64 (val, start, stop);
+#endif
+#if (WITH_TARGET_WORD_BITSIZE == 32)
+ /* Bit numbers are 63..0, even for 32 bit targets.
+ On 32 bit targets we ignore 63..32 */
+ if (stop >= 32)
+ return 0;
+ else
+ {
+ val <<= stop;
+ val &= LSMASK (start, stop);
+ return val;
+ }
+#endif
+}
+
+INLINE_SIM_BITS\
+(unsigned_word)
+MSINSERTED (unsigned_word val,
+ int start,
+ int stop)
{
- ASSERT ((WITH_TARGET_WORD_MSB == 0 && start <= stop)
- || (WITH_TARGET_WORD_MSB != 0 && start >= stop));
+ ASSERT (start <= stop);
#if (WITH_TARGET_WORD_BITSIZE == 64)
- return INSERTED64 (val, start, stop);
+ return MSINSERTED64 (val, start, stop);
#endif
#if (WITH_TARGET_WORD_BITSIZE == 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)
+ if (stop < 32)
return 0;
else
{
- val &= LSMASK (_MAKE_WIDTH (start, stop), 0);
- val <<= _LSB_SHIFT (64, stop);
+ val <<= ((64 - 1) - stop);
+ val &= MSMASK (start, stop);
return val;
}
#endif
@@ -128,21 +151,37 @@ INSERTED (unsigned_word val,
INLINE_SIM_BITS\
(unsigned_word)
-SEXT (signed_word val,
- int sign_bit)
+LSSEXT (signed_word val,
+ int sign_bit)
+{
+ ASSERT (sign_bit < 64);
+#if (WITH_TARGET_WORD_BITSIZE == 64)
+ return LSSEXT64 (val, sign_bit);
+#endif
+#if (WITH_TARGET_WORD_BITSIZE == 32)
+ if (sign_bit >= 32)
+ return val;
+ else {
+ val = LSSEXT32 (val, sign_bit);
+ return val;
+ }
+#endif
+}
+
+INLINE_SIM_BITS\
+(unsigned_word)
+MSSEXT (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);
+ return MSSEXT64 (val, sign_bit);
#endif
#if (WITH_TARGET_WORD_BITSIZE == 32)
- if (_MSB_SHIFT (64, sign_bit) < 32)
+ if (sign_bit < 32)
return val;
else {
- val <<= (_MSB_SHIFT (64, sign_bit) - 32);
- val >>= (_MSB_SHIFT (64, sign_bit) - 32);
+ val = MSSEXT32 (val, sign_bit - 32);
return val;
}
#endif
diff --git a/sim/common/sim-bits.h b/sim/common/sim-bits.h
index a638c1f..bd8f10b 100644
--- a/sim/common/sim-bits.h
+++ b/sim/common/sim-bits.h
@@ -391,11 +391,27 @@ INLINE_SIM_BITS(unsigned_word) MSEXTRACTED (unsigned_word val, int start, int st
/* move a group of bits around */
-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(unsigned16) LSINSERTED16 (unsigned16 val, int start, int stop);
+INLINE_SIM_BITS(unsigned32) LSINSERTED32 (unsigned32 val, int start, int stop);
+INLINE_SIM_BITS(unsigned64) LSINSERTED64 (unsigned64 val, int start, int stop);
+INLINE_SIM_BITS(unsigned_word) LSINSERTED (unsigned_word val, int start, int stop);
-INLINE_SIM_BITS(unsigned_word) INSERTED (unsigned_word val, int start, int stop);
+INLINE_SIM_BITS(unsigned16) MSINSERTED16 (unsigned16 val, int start, int stop);
+INLINE_SIM_BITS(unsigned32) MSINSERTED32 (unsigned32 val, int start, int stop);
+INLINE_SIM_BITS(unsigned64) MSINSERTED64 (unsigned64 val, int start, int stop);
+INLINE_SIM_BITS(unsigned_word) MSINSERTED (unsigned_word val, int start, int stop);
+
+#if (WITH_TARGET_WORD_MSB == 0)
+#define INSERTED16 MSINSERTED16
+#define INSERTED32 MSINSERTED32
+#define INSERTED64 MSINSERTED64
+#define INSERTED MSINSERTED
+#else
+#define INSERTED16 LSINSERTED16
+#define INSERTED32 LSINSERTED32
+#define INSERTED64 LSINSERTED64
+#define INSERTED LSINSERTED
+#endif
@@ -464,11 +480,27 @@ INLINE_SIM_BITS(unsigned64) ROTR64 (unsigned64 val, int shift);
/* Sign extension operations */
-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(unsigned16) LSSEXT16 (signed16 val, int sign_bit);
+INLINE_SIM_BITS(unsigned32) LSSEXT32 (signed32 val, int sign_bit);
+INLINE_SIM_BITS(unsigned64) LSSEXT64 (signed64 val, int sign_bit);
+INLINE_SIM_BITS(unsigned_word) LSSEXT (signed_word val, int sign_bit);
-INLINE_SIM_BITS(unsigned_word) SEXT (signed_word val, int sign_bit);
+INLINE_SIM_BITS(unsigned16) MSSEXT16 (signed16 val, int sign_bit);
+INLINE_SIM_BITS(unsigned32) MSSEXT32 (signed32 val, int sign_bit);
+INLINE_SIM_BITS(unsigned64) MSSEXT64 (signed64 val, int sign_bit);
+INLINE_SIM_BITS(unsigned_word) MSSEXT (signed_word val, int sign_bit);
+
+#if (WITH_TARGET_WORD_MSB == 0)
+#define SEXT16 MSSEXT16
+#define SEXT32 MSSEXT32
+#define SEXT64 MSSEXT64
+#define SEXT MSSEXT
+#else
+#define SEXT16 LSSEXT16
+#define SEXT32 LSSEXT32
+#define SEXT64 LSSEXT64
+#define SEXT LSSEXT
+#endif