Commit | Line | Data |
---|---|---|
f2de7dfd AC |
1 | /* This file is part of the program psim. |
2 | ||
3 | Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au> | |
4 | ||
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. | |
9 | ||
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. | |
14 | ||
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. | |
18 | ||
19 | */ | |
20 | ||
21 | ||
22 | #ifndef _SIM_BITS_C_ | |
23 | #define _SIM_BITS_C_ | |
24 | ||
25 | #include "sim-basics.h" | |
26 | ||
27 | ||
28 | INLINE_SIM_BITS\ | |
29 | (unsigned_word) | |
30 | MASKED(unsigned_word val, | |
31 | unsigned start, | |
32 | unsigned stop) | |
33 | { | |
34 | return ((val) & MASK(start, stop)); | |
35 | } | |
36 | ||
37 | ||
38 | ||
39 | INLINE_SIM_BITS\ | |
40 | (unsigned_word) | |
41 | LSMASKED(unsigned_word val, | |
42 | unsigned nr_bits) | |
43 | { | |
44 | return MASKED(val, | |
45 | WITH_TARGET_WORD_BITSIZE - nr_bits, | |
46 | WITH_TARGET_WORD_BITSIZE - 1); | |
47 | } | |
48 | ||
49 | ||
50 | ||
51 | INLINE_SIM_BITS\ | |
52 | (unsigned_word) | |
53 | EXTRACTED(unsigned_word val, | |
54 | unsigned start, | |
55 | unsigned stop) | |
56 | { | |
57 | ASSERT(start <= stop); | |
58 | #if (WITH_TARGET_WORD_BITSIZE == 64) | |
59 | return EXTRACTED64(val, start, stop); | |
60 | #endif | |
61 | #if (WITH_TARGET_WORD_BITSIZE == 32) | |
62 | if (stop < 32) | |
63 | return 0; | |
64 | else | |
65 | return ((val >> (63 - stop)) | |
66 | & MASK(start+(63-stop), 63)); | |
67 | #endif | |
68 | } | |
69 | ||
70 | ||
71 | INLINE_SIM_BITS\ | |
72 | (unsigned_word) | |
73 | INSERTED(unsigned_word val, | |
74 | unsigned start, | |
75 | unsigned stop) | |
76 | { | |
77 | ASSERT(start <= stop); | |
78 | #if (WITH_TARGET_WORD_BITSIZE == 64) | |
79 | return INSERTED64(val, start, stop); | |
80 | #endif | |
81 | #if (WITH_TARGET_WORD_BITSIZE == 32) | |
82 | if (stop < 32) | |
83 | return 0; | |
84 | else | |
85 | return ((val & MASK(start+(63-stop), 63)) | |
86 | << (63 - stop)); | |
87 | #endif | |
88 | } | |
89 | ||
90 | ||
91 | ||
92 | ||
93 | #define N 16 | |
94 | #include "sim-n-bits.h" | |
95 | #undef N | |
96 | ||
97 | #define N 32 | |
98 | #include "sim-n-bits.h" | |
99 | #undef N | |
100 | ||
101 | #define N 64 | |
102 | #include "sim-n-bits.h" | |
103 | #undef N | |
104 | ||
105 | #endif /* _SIM_BITS_C_ */ |