mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-10-13 19:06:54 +08:00
* 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.
This commit is contained in:
@ -1,3 +1,14 @@
|
|||||||
|
2002-01-04 matthew green <mrg@redhat.com>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2001-12-16 Andrew Cagney <ac131313@redhat.com>
|
2001-12-16 Andrew Cagney <ac131313@redhat.com>
|
||||||
|
|
||||||
* configure.in (sim_fpu): Don't add sim-bits.o.
|
* configure.in (sim_fpu): Don't add sim-bits.o.
|
||||||
|
@ -429,9 +429,6 @@ targ-map.o: targ-map.c targ-vals.h
|
|||||||
sim-fpu.o: $(srcdir)/../common/sim-fpu.c config.h tconfig.h
|
sim-fpu.o: $(srcdir)/../common/sim-fpu.c config.h tconfig.h
|
||||||
$(CC) -c $(STD_CFLAGS) -DHAVE_CONFIG_H $(srcdir)/../common/sim-fpu.c
|
$(CC) -c $(STD_CFLAGS) -DHAVE_CONFIG_H $(srcdir)/../common/sim-fpu.c
|
||||||
|
|
||||||
sim-bits.o: $(srcdir)/../common/sim-bits.c config.h tconfig.h
|
|
||||||
$(CC) -c $(STD_CFLAGS) -DHAVE_CONFIG_H $(srcdir)/../common/sim-bits.c
|
|
||||||
|
|
||||||
tconfig.h:
|
tconfig.h:
|
||||||
rm -f tconfig.h
|
rm -f tconfig.h
|
||||||
echo > tconfig.h
|
echo > tconfig.h
|
||||||
|
@ -24,6 +24,26 @@
|
|||||||
|
|
||||||
#include "basics.h"
|
#include "basics.h"
|
||||||
|
|
||||||
|
INLINE_BITS\
|
||||||
|
(unsigned64)
|
||||||
|
LSMASKED64 (unsigned64 word,
|
||||||
|
int start,
|
||||||
|
int stop)
|
||||||
|
{
|
||||||
|
word &= LSMASK64 (start, stop);
|
||||||
|
return word;
|
||||||
|
}
|
||||||
|
|
||||||
|
INLINE_BITS\
|
||||||
|
(unsigned64)
|
||||||
|
LSEXTRACTED64 (unsigned64 val,
|
||||||
|
int start,
|
||||||
|
int stop)
|
||||||
|
{
|
||||||
|
val <<= (64 - 1 - start); /* drop high bits */
|
||||||
|
val >>= (64 - 1 - start) + (stop); /* drop low bits */
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
INLINE_BITS\
|
INLINE_BITS\
|
||||||
(unsigned32)
|
(unsigned32)
|
||||||
|
@ -45,10 +45,15 @@
|
|||||||
MASKED*(VALUE, FIRST, LAST): Masks out all but bits [FIRST
|
MASKED*(VALUE, FIRST, LAST): Masks out all but bits [FIRST
|
||||||
.. LAST].
|
.. LAST].
|
||||||
|
|
||||||
|
LSMASKED*(VALUE, FIRST, LAST): Like MASKED - LS bit is zero.
|
||||||
|
|
||||||
EXTRACTED*(VALUE, FIRST, LAST): Masks out bits [FIRST .. LAST] but
|
EXTRACTED*(VALUE, FIRST, LAST): Masks out bits [FIRST .. LAST] but
|
||||||
also right shifts the masked value so that bit LAST becomes the
|
also right shifts the masked value so that bit LAST becomes the
|
||||||
least significant (right most).
|
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
|
SHUFFLED**(VALUE, OLD, NEW): Mask then move a single bit from OLD
|
||||||
new NEW.
|
new NEW.
|
||||||
|
|
||||||
@ -77,6 +82,13 @@
|
|||||||
#define _MAKE_SHIFT(WIDTH, pos) ((WIDTH) - 1 - (pos))
|
#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 */
|
/* MakeBit */
|
||||||
#define _BITn(WIDTH, pos) (((natural##WIDTH)(1)) \
|
#define _BITn(WIDTH, pos) (((natural##WIDTH)(1)) \
|
||||||
<< _MAKE_SHIFT(WIDTH, pos))
|
<< _MAKE_SHIFT(WIDTH, pos))
|
||||||
@ -104,6 +116,14 @@
|
|||||||
#define MASK32(START, STOP) _MASKn(32, START, STOP)
|
#define MASK32(START, STOP) _MASKn(32, START, STOP)
|
||||||
#define MASK64(START, STOP) _MASKn(64, 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)
|
#if (WITH_TARGET_WORD_BITSIZE == 64)
|
||||||
#define MASK(START, STOP) \
|
#define MASK(START, STOP) \
|
||||||
(((START) <= (STOP)) \
|
(((START) <= (STOP)) \
|
||||||
@ -149,6 +169,12 @@ INLINE_BITS\
|
|||||||
unsigned start,
|
unsigned start,
|
||||||
unsigned stop);
|
unsigned stop);
|
||||||
|
|
||||||
|
INLINE_BITS\
|
||||||
|
(unsigned64) LSMASKED64
|
||||||
|
(unsigned64 word,
|
||||||
|
int first,
|
||||||
|
int last);
|
||||||
|
|
||||||
|
|
||||||
/* extract the required bits aligning them with the lsb */
|
/* extract the required bits aligning them with the lsb */
|
||||||
#define _EXTRACTEDn(WIDTH, WORD, START, STOP) \
|
#define _EXTRACTEDn(WIDTH, WORD, START, STOP) \
|
||||||
@ -165,6 +191,11 @@ INLINE_BITS\
|
|||||||
unsigned start,
|
unsigned start,
|
||||||
unsigned stop);
|
unsigned stop);
|
||||||
|
|
||||||
|
INLINE_BITS\
|
||||||
|
(unsigned64) LSEXTRACTED64
|
||||||
|
(unsigned64 val,
|
||||||
|
int start,
|
||||||
|
int stop);
|
||||||
|
|
||||||
/* move a single bit around */
|
/* move a single bit around */
|
||||||
/* NB: the wierdness (N>O?N-O:0) is to stop a warning from GCC */
|
/* NB: the wierdness (N>O?N-O:0) is to stop a warning from GCC */
|
||||||
|
@ -248,7 +248,7 @@ zalloc(long size)
|
|||||||
{
|
{
|
||||||
void *memory = malloc(size);
|
void *memory = malloc(size);
|
||||||
if (memory == NULL)
|
if (memory == NULL)
|
||||||
error("zmalloc failed\n");
|
error("zalloc failed\n");
|
||||||
memset(memory, 0, size);
|
memset(memory, 0, size);
|
||||||
return memory;
|
return memory;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user