1 /* The common simulator framework for GDB, the GNU Debugger.
3 Copyright 2002-2019 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 #include "sim-basics.h"
27 #include "sim-assert.h"
33 LSMASKED (unsigned_word val,
37 /* NOTE - start, stop can wrap */
38 val &= LSMASK (start, stop);
45 MSMASKED (unsigned_word val,
49 /* NOTE - start, stop can wrap */
50 val &= MSMASK (start, stop);
57 LSEXTRACTED (unsigned_word val,
61 ASSERT (start >= stop);
62 #if (WITH_TARGET_WORD_BITSIZE == 64)
63 return LSEXTRACTED64 (val, start, stop);
65 #if (WITH_TARGET_WORD_BITSIZE == 32)
71 val &= LSMASK (start, 0);
76 #if (WITH_TARGET_WORD_BITSIZE == 16)
82 val &= LSMASK (start, 0);
92 MSEXTRACTED (unsigned_word val,
96 ASSERT (start <= stop);
97 #if (WITH_TARGET_WORD_BITSIZE == 64)
98 return MSEXTRACTED64 (val, start, stop);
100 #if (WITH_TARGET_WORD_BITSIZE == 32)
106 val &= MSMASK (start, 64 - 1);
107 val >>= (64 - stop - 1);
111 #if (WITH_TARGET_WORD_BITSIZE == 16)
117 val &= MSMASK (start, 64 - 1);
118 val >>= (64 - stop - 1);
127 LSINSERTED (unsigned_word val,
131 ASSERT (start >= stop);
132 #if (WITH_TARGET_WORD_BITSIZE == 64)
133 return LSINSERTED64 (val, start, stop);
135 #if (WITH_TARGET_WORD_BITSIZE == 32)
136 /* Bit numbers are 63..0, even for 32 bit targets.
137 On 32 bit targets we ignore 63..32 */
143 val &= LSMASK (start, stop);
147 #if (WITH_TARGET_WORD_BITSIZE == 16)
148 /* Bit numbers are 63..0, even for 16 bit targets.
149 On 16 bit targets we ignore 63..16 */
155 val &= LSMASK (start, stop);
163 MSINSERTED (unsigned_word val,
167 ASSERT (start <= stop);
168 #if (WITH_TARGET_WORD_BITSIZE == 64)
169 return MSINSERTED64 (val, start, stop);
171 #if (WITH_TARGET_WORD_BITSIZE == 32)
172 /* Bit numbers are 0..63, even for 32 bit targets.
173 On 32 bit targets we ignore 0..31. */
178 val <<= ((64 - 1) - stop);
179 val &= MSMASK (start, stop);
183 #if (WITH_TARGET_WORD_BITSIZE == 16)
184 /* Bit numbers are 0..63, even for 16 bit targets.
185 On 16 bit targets we ignore 0..47. */
190 val <<= ((64 - 1) - stop);
191 val &= MSMASK (start, stop);
201 LSSEXT (signed_word val,
204 ASSERT (sign_bit < 64);
205 #if (WITH_TARGET_WORD_BITSIZE == 64)
206 return LSSEXT64 (val, sign_bit);
208 #if (WITH_TARGET_WORD_BITSIZE == 32)
212 val = LSSEXT32 (val, sign_bit);
216 #if (WITH_TARGET_WORD_BITSIZE == 16)
220 val = LSSEXT16 (val, sign_bit);
228 MSSEXT (signed_word val,
231 ASSERT (sign_bit < 64);
232 #if (WITH_TARGET_WORD_BITSIZE == 64)
233 return MSSEXT64 (val, sign_bit);
235 #if (WITH_TARGET_WORD_BITSIZE == 32)
239 val = MSSEXT32 (val, sign_bit - 32);
243 #if (WITH_TARGET_WORD_BITSIZE == 16)
244 if (sign_bit < 32 + 16)
247 val = MSSEXT16 (val, sign_bit - 32 - 16);
256 #include "sim-n-bits.h"
260 #include "sim-n-bits.h"
264 #include "sim-n-bits.h"
268 #include "sim-n-bits.h"
271 #endif /* _SIM_BITS_C_ */