1 /* The common simulator framework for GDB, the GNU Debugger.
3 Copyright 2002, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
5 Contributed by Andrew Cagney and Red Hat.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 #error "N must be #defined"
29 #if defined(__STDC__) && defined(signed)
30 /* If signed were defined to be say __signed (ie, some versions of Linux),
31 then the signedN macro would not work correctly. If we have a standard
32 compiler, we have signed. */
36 /* NOTE: See end of file for #undef */
37 #define unsignedN XCONCAT2(unsigned,N)
38 #define signedN XCONCAT2(signed,N)
39 #define LSMASKn XCONCAT2(LSMASK,N)
40 #define MSMASKn XCONCAT2(MSMASK,N)
41 #define LSMASKEDn XCONCAT2(LSMASKED,N)
42 #define MSMASKEDn XCONCAT2(MSMASKED,N)
43 #define LSEXTRACTEDn XCONCAT2(LSEXTRACTED,N)
44 #define MSEXTRACTEDn XCONCAT2(MSEXTRACTED,N)
45 #define LSINSERTEDn XCONCAT2(LSINSERTED,N)
46 #define MSINSERTEDn XCONCAT2(MSINSERTED,N)
47 #define ROTn XCONCAT2(ROT,N)
48 #define ROTLn XCONCAT2(ROTL,N)
49 #define ROTRn XCONCAT2(ROTR,N)
50 #define MSSEXTn XCONCAT2(MSSEXT,N)
51 #define LSSEXTn XCONCAT2(LSSEXT,N)
53 /* TAGS: LSMASKED16 LSMASKED32 LSMASKED64 */
57 LSMASKEDn (unsignedN word
,
61 word
&= LSMASKn (start
, stop
);
65 /* TAGS: MSMASKED16 MSMASKED32 MSMASKED64 */
69 MSMASKEDn (unsignedN word
,
73 word
&= MSMASKn (start
, stop
);
77 /* TAGS: LSEXTRACTED16 LSEXTRACTED32 LSEXTRACTED64 */
81 LSEXTRACTEDn (unsignedN val
,
85 val
<<= (N
- 1 - start
); /* drop high bits */
86 val
>>= (N
- 1 - start
) + (stop
); /* drop low bits */
90 /* TAGS: MSEXTRACTED16 MSEXTRACTED32 MSEXTRACTED64 */
94 MSEXTRACTEDn (unsignedN val
,
98 val
<<= (start
); /* drop high bits */
99 val
>>= (start
) + (N
- 1 - stop
); /* drop low bits */
103 /* TAGS: LSINSERTED16 LSINSERTED32 LSINSERTED64 */
107 LSINSERTEDn (unsignedN val
,
112 val
&= LSMASKn (start
, stop
);
116 /* TAGS: MSINSERTED16 MSINSERTED32 MSINSERTED64 */
120 MSINSERTEDn (unsignedN val
,
124 val
<<= ((N
- 1) - stop
);
125 val
&= MSMASKn (start
, stop
);
129 /* TAGS: ROT16 ROT32 ROT64 */
137 return ROTRn (val
, shift
);
139 return ROTLn (val
, -shift
);
144 /* TAGS: ROTL16 ROTL32 ROTL64 */
148 ROTLn (unsignedN val
,
153 result
= (((val
) << (shift
)) | ((val
) >> ((N
)-(shift
))));
157 /* TAGS: ROTR16 ROTR32 ROTR64 */
161 ROTRn (unsignedN val
,
166 result
= (((val
) >> (shift
)) | ((val
) << ((N
)-(shift
))));
170 /* TAGS: LSSEXT16 LSSEXT32 LSSEXT64 */
174 LSSEXTn (signedN val
,
178 /* make the sign-bit most significant and then smear it back into
180 ASSERT (sign_bit
< N
);
181 shift
= ((N
- 1) - sign_bit
);
187 /* TAGS: MSSEXT16 MSSEXT32 MSSEXT64 */
191 MSSEXTn (signedN val
,
194 /* make the sign-bit most significant and then smear it back into
196 ASSERT (sign_bit
< N
);
203 /* NOTE: See start of file for #define */
This page took 0.035285 seconds and 4 git commands to generate.