aboutsummaryrefslogtreecommitdiff
path: root/sim/ppc/bits.h
diff options
context:
space:
mode:
authorMatthew Green <mrg@redhat.com>2002-01-04 00:00:54 +0000
committerMatthew Green <mrg@redhat.com>2002-01-04 00:00:54 +0000
commit5c8844646d88eaf4ec6b9c682fc1a32757fd0c07 (patch)
treefd12b44aa3102091dcc32740922b69ceab85a16c /sim/ppc/bits.h
parentc7b3d5aa454d080ad760b8915e5f1eee0d452861 (diff)
downloadbinutils-5c8844646d88eaf4ec6b9c682fc1a32757fd0c07.zip
binutils-5c8844646d88eaf4ec6b9c682fc1a32757fd0c07.tar.gz
binutils-5c8844646d88eaf4ec6b9c682fc1a32757fd0c07.tar.bz2
* bits.c (LSMASKED64): New inline function.
(LSEXTRACTED64): Likewise. * bits.h (_LSB_POS, _LSMASKn, LSMASK64): New macros from sim/common/sim-bits.h (LSMASKED64, LSEXTRACTED64): New functions definitions. * Makefile.in (sim-bits.o): Remove target. * main.c (zalloc): Fix typo in error message.
Diffstat (limited to 'sim/ppc/bits.h')
-rw-r--r--sim/ppc/bits.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/sim/ppc/bits.h b/sim/ppc/bits.h
index 06898e0..35e4322 100644
--- a/sim/ppc/bits.h
+++ b/sim/ppc/bits.h
@@ -45,10 +45,15 @@
MASKED*(VALUE, FIRST, LAST): Masks out all but bits [FIRST
.. LAST].
+ LSMASKED*(VALUE, FIRST, LAST): Like MASKED - LS 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
least significant (right most).
+ LSEXTRACTED*(VALUE, FIRST, LAST): Same as extracted - LS bit is
+ zero.
+
SHUFFLED**(VALUE, OLD, NEW): Mask then move a single bit from OLD
new NEW.
@@ -77,6 +82,13 @@
#define _MAKE_SHIFT(WIDTH, pos) ((WIDTH) - 1 - (pos))
+#if (WITH_TARGET_WORD_MSB == 0)
+#define _LSB_POS(WIDTH, SHIFT) (WIDTH - 1 - SHIFT)
+#else
+#define _LSB_POS(WIDTH, SHIFT) (SHIFT)
+#endif
+
+
/* MakeBit */
#define _BITn(WIDTH, pos) (((natural##WIDTH)(1)) \
<< _MAKE_SHIFT(WIDTH, pos))
@@ -104,6 +116,14 @@
#define MASK32(START, STOP) _MASKn(32, START, STOP)
#define MASK64(START, STOP) _MASKn(64, START, STOP)
+/* Multi-bit mask on least significant bits */
+
+#define _LSMASKn(WIDTH, FIRST, LAST) _MASKn (WIDTH, \
+ _LSB_POS (WIDTH, FIRST), \
+ _LSB_POS (WIDTH, LAST))
+
+#define LSMASK64(FIRST, LAST) _LSMASKn (64, (FIRST), (LAST))
+
#if (WITH_TARGET_WORD_BITSIZE == 64)
#define MASK(START, STOP) \
(((START) <= (STOP)) \
@@ -149,6 +169,12 @@ INLINE_BITS\
unsigned start,
unsigned stop);
+INLINE_BITS\
+(unsigned64) LSMASKED64
+(unsigned64 word,
+ int first,
+ int last);
+
/* extract the required bits aligning them with the lsb */
#define _EXTRACTEDn(WIDTH, WORD, START, STOP) \
@@ -165,6 +191,11 @@ INLINE_BITS\
unsigned start,
unsigned stop);
+INLINE_BITS\
+(unsigned64) LSEXTRACTED64
+(unsigned64 val,
+ int start,
+ int stop);
/* move a single bit around */
/* NB: the wierdness (N>O?N-O:0) is to stop a warning from GCC */