X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=sim%2Fcommon%2Fsim-n-bits.h;h=7c77c83100c2791203355603634973897faf17ff;hb=7bb11558201af4020837abe67e84a0a6f547aad3;hp=996095a96e755bc60fadbeb65d49f529103f39f6;hpb=75b3697d5f175e7121f792ca5ab9e36eeaaf5fc1;p=deliverable%2Fbinutils-gdb.git diff --git a/sim/common/sim-n-bits.h b/sim/common/sim-n-bits.h index 996095a96e..7c77c83100 100644 --- a/sim/common/sim-n-bits.h +++ b/sim/common/sim-n-bits.h @@ -1,30 +1,32 @@ -/* 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 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 2 of the License, or + (at your option) any later version. + + 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. */ #ifndef N #error "N must be #defined" #endif -#include "sim-xcat.h" +#include "symcat.h" #if defined(__STDC__) && defined(signed) /* If signed were defined to be say __signed (ie, some versions of Linux), @@ -36,18 +38,19 @@ /* NOTE: See end of file for #undef */ #define unsignedN XCONCAT2(unsigned,N) #define signedN XCONCAT2(signed,N) -#define MASKn XCONCAT2(MASK,N) -#define LSMASKEDn XCONCAT2(LSMASKED,N) #define LSMASKn XCONCAT2(LSMASK,N) -#define MSMASKEDn XCONCAT2(MSMASKED,N) #define MSMASKn XCONCAT2(MSMASK,N) +#define LSMASKEDn XCONCAT2(LSMASKED,N) +#define MSMASKEDn XCONCAT2(MSMASKED,N) #define LSEXTRACTEDn XCONCAT2(LSEXTRACTED,N) #define MSEXTRACTEDn XCONCAT2(MSEXTRACTED,N) -#define INSERTEDn XCONCAT2(INSERTED,N) +#define LSINSERTEDn XCONCAT2(LSINSERTED,N) +#define MSINSERTEDn XCONCAT2(MSINSERTED,N) #define ROTn XCONCAT2(ROT,N) #define ROTLn XCONCAT2(ROTL,N) #define ROTRn XCONCAT2(ROTR,N) -#define SEXTn XCONCAT2(SEXT,N) +#define MSSEXTn XCONCAT2(MSSEXT,N) +#define LSSEXTn XCONCAT2(LSSEXT,N) /* TAGS: LSMASKED16 LSMASKED32 LSMASKED64 */ @@ -99,16 +102,29 @@ MSEXTRACTEDn (unsignedN val, return val; } -/* TAGS: INSERTED16 INSERTED32 INSERTED64 */ +/* TAGS: LSINSERTED16 LSINSERTED32 LSINSERTED64 */ INLINE_SIM_BITS\ (unsignedN) -INSERTEDn (unsignedN val, - int start, - int stop) +LSINSERTEDn (unsignedN val, + int start, + int stop) +{ + val <<= stop; + val &= LSMASKn (start, stop); + return val; +} + +/* TAGS: MSINSERTED16 MSINSERTED32 MSINSERTED64 */ + +INLINE_SIM_BITS\ +(unsignedN) +MSINSERTEDn (unsignedN val, + int start, + int stop) { - val <<= _LSB_SHIFT (N, stop); - val &= MASKn (start, stop); + val <<= ((N - 1) - stop); + val &= MSMASKn (start, stop); return val; } @@ -153,35 +169,52 @@ ROTRn (unsignedN val, return result; } -/* TAGS: SEXT16 SEXT32 SEXT64 */ +/* TAGS: LSSEXT16 LSSEXT32 LSSEXT64 */ + +INLINE_SIM_BITS\ +(unsignedN) +LSSEXTn (signedN val, + int sign_bit) +{ + int shift; + /* make the sign-bit most significant and then smear it back into + position */ + ASSERT (sign_bit < N); + shift = ((N - 1) - sign_bit); + val <<= shift; + val >>= shift; + return val; +} + +/* TAGS: MSSEXT16 MSSEXT32 MSSEXT64 */ INLINE_SIM_BITS\ (unsignedN) -SEXTn (signedN val, - int sign_bit) +MSSEXTn (signedN val, + int sign_bit) { /* make the sign-bit most significant and then smear it back into position */ ASSERT (sign_bit < N); - val <<= _MSB_SHIFT (N, sign_bit); - val >>= _MSB_SHIFT (N, sign_bit); + val <<= sign_bit; + val >>= sign_bit; return val; } /* NOTE: See start of file for #define */ -#undef SEXTn +#undef LSSEXTn +#undef MSSEXTn #undef ROTLn #undef ROTRn #undef ROTn -#undef INSERTEDn +#undef LSINSERTEDn +#undef MSINSERTEDn #undef LSEXTRACTEDn #undef MSEXTRACTEDn #undef LSMASKEDn #undef LSMASKn #undef MSMASKEDn #undef MSMASKn -#undef MASKn -#undef MASKEDn #undef signedN #undef unsignedN