1 /* The common simulator framework for GDB, the GNU Debugger.
3 Copyright 2002-2023 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/>. */
26 /* This must come before any other includes. */
29 #include "sim-basics.h"
30 #include "sim-assert.h"
36 LSMASKED (unsigned_word val
,
40 /* NOTE - start, stop can wrap */
41 val
&= LSMASK (start
, stop
);
48 MSMASKED (unsigned_word val
,
52 /* NOTE - start, stop can wrap */
53 val
&= MSMASK (start
, stop
);
60 LSEXTRACTED (unsigned_word val
,
64 ASSERT (start
>= stop
);
65 #if (WITH_TARGET_WORD_BITSIZE == 64)
66 return LSEXTRACTED64 (val
, start
, stop
);
68 #if (WITH_TARGET_WORD_BITSIZE == 32)
74 val
&= LSMASK (start
, 0);
79 #if (WITH_TARGET_WORD_BITSIZE == 16)
85 val
&= LSMASK (start
, 0);
95 MSEXTRACTED (unsigned_word val
,
99 ASSERT (start
<= stop
);
100 #if (WITH_TARGET_WORD_BITSIZE == 64)
101 return MSEXTRACTED64 (val
, start
, stop
);
103 #if (WITH_TARGET_WORD_BITSIZE == 32)
109 val
&= MSMASK (start
, 64 - 1);
110 val
>>= (64 - stop
- 1);
114 #if (WITH_TARGET_WORD_BITSIZE == 16)
120 val
&= MSMASK (start
, 64 - 1);
121 val
>>= (64 - stop
- 1);
130 LSINSERTED (unsigned_word val
,
134 ASSERT (start
>= stop
);
135 #if (WITH_TARGET_WORD_BITSIZE == 64)
136 return LSINSERTED64 (val
, start
, stop
);
138 #if (WITH_TARGET_WORD_BITSIZE == 32)
139 /* Bit numbers are 63..0, even for 32 bit targets.
140 On 32 bit targets we ignore 63..32 */
146 val
&= LSMASK (start
, stop
);
150 #if (WITH_TARGET_WORD_BITSIZE == 16)
151 /* Bit numbers are 63..0, even for 16 bit targets.
152 On 16 bit targets we ignore 63..16 */
158 val
&= LSMASK (start
, stop
);
166 MSINSERTED (unsigned_word val
,
170 ASSERT (start
<= stop
);
171 #if (WITH_TARGET_WORD_BITSIZE == 64)
172 return MSINSERTED64 (val
, start
, stop
);
174 #if (WITH_TARGET_WORD_BITSIZE == 32)
175 /* Bit numbers are 0..63, even for 32 bit targets.
176 On 32 bit targets we ignore 0..31. */
181 val
<<= ((64 - 1) - stop
);
182 val
&= MSMASK (start
, stop
);
186 #if (WITH_TARGET_WORD_BITSIZE == 16)
187 /* Bit numbers are 0..63, even for 16 bit targets.
188 On 16 bit targets we ignore 0..47. */
193 val
<<= ((64 - 1) - stop
);
194 val
&= MSMASK (start
, stop
);
204 LSSEXT (signed_word val
,
207 ASSERT (sign_bit
< 64);
208 #if (WITH_TARGET_WORD_BITSIZE == 64)
209 return LSSEXT64 (val
, sign_bit
);
211 #if (WITH_TARGET_WORD_BITSIZE == 32)
215 val
= LSSEXT32 (val
, sign_bit
);
219 #if (WITH_TARGET_WORD_BITSIZE == 16)
223 val
= LSSEXT16 (val
, sign_bit
);
231 MSSEXT (signed_word val
,
234 ASSERT (sign_bit
< 64);
235 #if (WITH_TARGET_WORD_BITSIZE == 64)
236 return MSSEXT64 (val
, sign_bit
);
238 #if (WITH_TARGET_WORD_BITSIZE == 32)
242 val
= MSSEXT32 (val
, sign_bit
- 32);
246 #if (WITH_TARGET_WORD_BITSIZE == 16)
247 if (sign_bit
< 32 + 16)
250 val
= MSSEXT16 (val
, sign_bit
- 32 - 16);
259 #include "sim-n-bits.h"
263 #include "sim-n-bits.h"
267 #include "sim-n-bits.h"
271 #include "sim-n-bits.h"
274 #endif /* _SIM_BITS_C_ */