1 /* This file is part of the program psim.
3 Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #include "sim-basics.h"
26 #include "sim-assert.h"
32 LSMASKED (unsigned_word val
,
36 /* NOTE - start, stop can wrap */
37 val
&= LSMASK (start
, stop
);
44 MSMASKED (unsigned_word val
,
48 /* NOTE - start, stop can wrap */
49 val
&= MSMASK (start
, stop
);
56 LSEXTRACTED (unsigned_word val
,
60 ASSERT (start
>= stop
);
61 #if (WITH_TARGET_WORD_BITSIZE == 64)
62 return LSEXTRACTED64 (val
, start
, stop
);
64 #if (WITH_TARGET_WORD_BITSIZE == 32)
70 val
&= LSMASK (start
, 0);
75 #if (WITH_TARGET_WORD_BITSIZE == 16)
81 val
&= LSMASK (start
, 0);
91 MSEXTRACTED (unsigned_word val
,
95 ASSERT (start
<= stop
);
96 #if (WITH_TARGET_WORD_BITSIZE == 64)
97 return MSEXTRACTED64 (val
, start
, stop
);
99 #if (WITH_TARGET_WORD_BITSIZE == 32)
105 val
&= MSMASK (start
, 64 - 1);
106 val
>>= (64 - stop
- 1);
110 #if (WITH_TARGET_WORD_BITSIZE == 16)
116 val
&= MSMASK (start
, 64 - 1);
117 val
>>= (64 - stop
- 1);
126 LSINSERTED (unsigned_word val
,
130 ASSERT (start
>= stop
);
131 #if (WITH_TARGET_WORD_BITSIZE == 64)
132 return LSINSERTED64 (val
, start
, stop
);
134 #if (WITH_TARGET_WORD_BITSIZE == 32)
135 /* Bit numbers are 63..0, even for 32 bit targets.
136 On 32 bit targets we ignore 63..32 */
142 val
&= LSMASK (start
, stop
);
146 #if (WITH_TARGET_WORD_BITSIZE == 16)
147 /* Bit numbers are 63..0, even for 16 bit targets.
148 On 16 bit targets we ignore 63..16 */
154 val
&= LSMASK (start
, stop
);
162 MSINSERTED (unsigned_word val
,
166 ASSERT (start
<= stop
);
167 #if (WITH_TARGET_WORD_BITSIZE == 64)
168 return MSINSERTED64 (val
, start
, stop
);
170 #if (WITH_TARGET_WORD_BITSIZE == 32)
171 /* Bit numbers are 0..63, even for 32 bit targets.
172 On 32 bit targets we ignore 0..31. */
177 val
<<= ((64 - 1) - stop
);
178 val
&= MSMASK (start
, stop
);
182 #if (WITH_TARGET_WORD_BITSIZE == 16)
183 /* Bit numbers are 0..63, even for 16 bit targets.
184 On 16 bit targets we ignore 0..47. */
189 val
<<= ((64 - 1) - stop
);
190 val
&= MSMASK (start
, stop
);
200 LSSEXT (signed_word val
,
203 ASSERT (sign_bit
< 64);
204 #if (WITH_TARGET_WORD_BITSIZE == 64)
205 return LSSEXT64 (val
, sign_bit
);
207 #if (WITH_TARGET_WORD_BITSIZE == 32)
211 val
= LSSEXT32 (val
, sign_bit
);
215 #if (WITH_TARGET_WORD_BITSIZE == 16)
219 val
= LSSEXT16 (val
, sign_bit
);
227 MSSEXT (signed_word val
,
230 ASSERT (sign_bit
< 64);
231 #if (WITH_TARGET_WORD_BITSIZE == 64)
232 return MSSEXT64 (val
, sign_bit
);
234 #if (WITH_TARGET_WORD_BITSIZE == 32)
238 val
= MSSEXT32 (val
, sign_bit
- 32);
242 #if (WITH_TARGET_WORD_BITSIZE == 16)
243 if (sign_bit
< 32 + 16)
246 val
= MSSEXT16 (val
, sign_bit
- 32 - 16);
255 #include "sim-n-bits.h"
259 #include "sim-n-bits.h"
263 #include "sim-n-bits.h"
267 #include "sim-n-bits.h"
270 #endif /* _SIM_BITS_C_ */
This page took 0.034814 seconds and 4 git commands to generate.