X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=sim%2Fcommon%2Fsim-bits.h;h=4b9de3796359c17e6e3da8dd97e5d519835f2efe;hb=873657b9e824943ae44c12966c29cbbcd21c986f;hp=d111bcd4569b57cc4afdecf7757ebd5fa46fda60;hpb=30727aa6d12fb866494020c0b62ab265a2bdcdfe;p=deliverable%2Fbinutils-gdb.git diff --git a/sim/common/sim-bits.h b/sim/common/sim-bits.h index d111bcd456..4b9de37963 100644 --- a/sim/common/sim-bits.h +++ b/sim/common/sim-bits.h @@ -1,27 +1,27 @@ -/* This file is part of the program psim. +/* The common simulator framework for GDB, the GNU Debugger. - Copyright (C) 1994-1996, Andrew Cagney - Copyright (C) 1997, Free Software Foundation, Inc. + Copyright 2002-2020 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + Contributed by Andrew Cagney and Red Hat. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - */ + This file is part of GDB. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. -#ifndef _SIM_BITS_H_ -#define _SIM_BITS_H_ + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + +#ifndef SIM_BITS_H +#define SIM_BITS_H /* Bit manipulation routines: @@ -166,20 +166,32 @@ #define _MSB_32(START, STOP) (START <= STOP \ ? (START < 32 ? 0 : START - 32) \ : (STOP < 32 ? 0 : STOP - 32)) +#define _MSB_16(START, STOP) (START <= STOP \ + ? (START < 48 ? 0 : START - 48) \ + : (STOP < 48 ? 0 : STOP - 48)) #else #define _MSB_32(START, STOP) (START >= STOP \ ? (START >= 32 ? 31 : START) \ : (STOP >= 32 ? 31 : STOP)) +#define _MSB_16(START, STOP) (START >= STOP \ + ? (START >= 16 ? 15 : START) \ + : (STOP >= 16 ? 15 : STOP)) #endif #if (WITH_TARGET_WORD_MSB == 0) #define _LSB_32(START, STOP) (START <= STOP \ ? (STOP < 32 ? 0 : STOP - 32) \ : (START < 32 ? 0 : START - 32)) +#define _LSB_16(START, STOP) (START <= STOP \ + ? (STOP < 48 ? 0 : STOP - 48) \ + : (START < 48 ? 0 : START - 48)) #else #define _LSB_32(START, STOP) (START >= STOP \ ? (STOP >= 32 ? 31 : STOP) \ : (START >= 32 ? 31 : START)) +#define _LSB_16(START, STOP) (START >= STOP \ + ? (STOP >= 16 ? 15 : STOP) \ + : (START >= 16 ? 15 : START)) #endif #if (WITH_TARGET_WORD_MSB == 0) @@ -204,11 +216,17 @@ #if (WITH_TARGET_WORD_BITSIZE == 64) #define LSBIT(POS) LSBIT64 (POS) -#else +#endif +#if (WITH_TARGET_WORD_BITSIZE == 32) #define LSBIT(POS) ((unsigned32)((POS) >= 32 \ ? 0 \ : (1 << ((POS) >= 32 ? 0 : (POS))))) #endif +#if (WITH_TARGET_WORD_BITSIZE == 16) +#define LSBIT(POS) ((unsigned16)((POS) >= 16 \ + ? 0 \ + : (1 << ((POS) >= 16 ? 0 : (POS))))) +#endif #define MSBIT8(POS) ((unsigned8) 1 << ( 8 - 1 - (POS))) @@ -218,11 +236,17 @@ #if (WITH_TARGET_WORD_BITSIZE == 64) #define MSBIT(POS) MSBIT64 (POS) -#else +#endif +#if (WITH_TARGET_WORD_BITSIZE == 32) #define MSBIT(POS) ((unsigned32)((POS) < 32 \ ? 0 \ : (1 << ((POS) < 32 ? 0 : (64 - 1) - (POS))))) #endif +#if (WITH_TARGET_WORD_BITSIZE == 16) +#define MSBIT(POS) ((unsigned16)((POS) < 48 \ + ? 0 \ + : (1 << ((POS) < 48 ? 0 : (64 - 1) - (POS))))) +#endif /* Bit operations */ @@ -287,6 +311,23 @@ _MSB_POS (32, 0), \ _MSB_32 ((START), (STOP)))))) #endif +#if (WITH_TARGET_WORD_BITSIZE == 16) +#define MASK(START, STOP) \ + (_POS_LE ((START), (STOP)) \ + ? (_POS_LE ((STOP), _MSB_POS (64, 15)) \ + ? 0 \ + : _MASKn (16, \ + _MSB_16 ((START), (STOP)), \ + _LSB_16 ((START), (STOP)))) \ + : (_MASKn (16, \ + _LSB_16 ((START), (STOP)), \ + _LSB_POS (16, 0)) \ + | (_POS_LE ((STOP), _MSB_POS (64, 15)) \ + ? 0 \ + : _MASKn (16, \ + _MSB_POS (16, 0), \ + _MSB_16 ((START), (STOP)))))) +#endif #if !defined (MASK) #error "MASK never undefined" #endif @@ -460,11 +501,14 @@ INLINE_SIM_BITS(unsigned_word) MSINSERTED (unsigned_word val, int start, int sto #define EXTEND4(X) (LSSEXT ((X), 3)) #define EXTEND5(X) (LSSEXT ((X), 4)) +#define EXTEND6(X) (LSSEXT ((X), 5)) #define EXTEND8(X) ((signed_word)(signed8)(X)) #define EXTEND11(X) (LSSEXT ((X), 10)) +#define EXTEND12(X) (LSSEXT ((X), 11)) #define EXTEND15(X) (LSSEXT ((X), 14)) #define EXTEND16(X) ((signed_word)(signed16)(X)) #define EXTEND24(X) (LSSEXT ((X), 23)) +#define EXTEND25(X) (LSSEXT ((X), 24)) #define EXTEND32(X) ((signed_word)(signed32)(X)) #define EXTEND64(X) ((signed_word)(signed64)(X)) @@ -475,6 +519,9 @@ INLINE_SIM_BITS(unsigned_word) MSINSERTED (unsigned_word val, int start, int sto #if (WITH_TARGET_WORD_BITSIZE == 32) #define EXTENDED(X) (X) #endif +#if (WITH_TARGET_WORD_BITSIZE == 16) +#define EXTENDED(X) (X) +#endif /* memory alignment macro's */ @@ -561,4 +608,4 @@ INLINE_SIM_BITS(unsigned_word) MSSEXT (signed_word val, int sign_bit); #include "sim-bits.c" #endif -#endif /* _SIM_BITS_H_ */ +#endif /* SIM_BITS_H */