1 |
106 |
markom |
/* This file is part of the program psim.
|
2 |
|
|
|
3 |
|
|
Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
|
4 |
|
|
Copyright (C) 1997, Free Software Foundation, Inc.
|
5 |
|
|
|
6 |
|
|
This program is free software; you can redistribute it and/or modify
|
7 |
|
|
it under the terms of the GNU General Public License as published by
|
8 |
|
|
the Free Software Foundation; either version 2 of the License, or
|
9 |
|
|
(at your option) any later version.
|
10 |
|
|
|
11 |
|
|
This program is distributed in the hope that it will be useful,
|
12 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
|
|
GNU General Public License for more details.
|
15 |
|
|
|
16 |
|
|
You should have received a copy of the GNU General Public License
|
17 |
|
|
along with this program; if not, write to the Free Software
|
18 |
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
19 |
|
|
|
20 |
|
|
*/
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
#ifndef _SIM_ENDIAN_H_
|
24 |
|
|
#define _SIM_ENDIAN_H_
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
/* C byte conversion functions */
|
28 |
|
|
|
29 |
|
|
INLINE_SIM_ENDIAN(unsigned_1) endian_h2t_1(unsigned_1 x);
|
30 |
|
|
INLINE_SIM_ENDIAN(unsigned_2) endian_h2t_2(unsigned_2 x);
|
31 |
|
|
INLINE_SIM_ENDIAN(unsigned_4) endian_h2t_4(unsigned_4 x);
|
32 |
|
|
INLINE_SIM_ENDIAN(unsigned_8) endian_h2t_8(unsigned_8 x);
|
33 |
|
|
INLINE_SIM_ENDIAN(unsigned_16) endian_h2t_16(unsigned_16 x);
|
34 |
|
|
|
35 |
|
|
INLINE_SIM_ENDIAN(unsigned_1) endian_t2h_1(unsigned_1 x);
|
36 |
|
|
INLINE_SIM_ENDIAN(unsigned_2) endian_t2h_2(unsigned_2 x);
|
37 |
|
|
INLINE_SIM_ENDIAN(unsigned_4) endian_t2h_4(unsigned_4 x);
|
38 |
|
|
INLINE_SIM_ENDIAN(unsigned_8) endian_t2h_8(unsigned_8 x);
|
39 |
|
|
INLINE_SIM_ENDIAN(unsigned_16) endian_t2h_16(unsigned_16 x);
|
40 |
|
|
|
41 |
|
|
INLINE_SIM_ENDIAN(unsigned_1) swap_1(unsigned_1 x);
|
42 |
|
|
INLINE_SIM_ENDIAN(unsigned_2) swap_2(unsigned_2 x);
|
43 |
|
|
INLINE_SIM_ENDIAN(unsigned_4) swap_4(unsigned_4 x);
|
44 |
|
|
INLINE_SIM_ENDIAN(unsigned_8) swap_8(unsigned_8 x);
|
45 |
|
|
INLINE_SIM_ENDIAN(unsigned_16) swap_16(unsigned_16 x);
|
46 |
|
|
|
47 |
|
|
INLINE_SIM_ENDIAN(unsigned_1) endian_h2be_1(unsigned_1 x);
|
48 |
|
|
INLINE_SIM_ENDIAN(unsigned_2) endian_h2be_2(unsigned_2 x);
|
49 |
|
|
INLINE_SIM_ENDIAN(unsigned_4) endian_h2be_4(unsigned_4 x);
|
50 |
|
|
INLINE_SIM_ENDIAN(unsigned_8) endian_h2be_8(unsigned_8 x);
|
51 |
|
|
INLINE_SIM_ENDIAN(unsigned_16) endian_h2be_16(unsigned_16 x);
|
52 |
|
|
|
53 |
|
|
INLINE_SIM_ENDIAN(unsigned_1) endian_be2h_1(unsigned_1 x);
|
54 |
|
|
INLINE_SIM_ENDIAN(unsigned_2) endian_be2h_2(unsigned_2 x);
|
55 |
|
|
INLINE_SIM_ENDIAN(unsigned_4) endian_be2h_4(unsigned_4 x);
|
56 |
|
|
INLINE_SIM_ENDIAN(unsigned_8) endian_be2h_8(unsigned_8 x);
|
57 |
|
|
INLINE_SIM_ENDIAN(unsigned_16) endian_be2h_16(unsigned_16 x);
|
58 |
|
|
|
59 |
|
|
INLINE_SIM_ENDIAN(unsigned_1) endian_h2le_1(unsigned_1 x);
|
60 |
|
|
INLINE_SIM_ENDIAN(unsigned_2) endian_h2le_2(unsigned_2 x);
|
61 |
|
|
INLINE_SIM_ENDIAN(unsigned_4) endian_h2le_4(unsigned_4 x);
|
62 |
|
|
INLINE_SIM_ENDIAN(unsigned_8) endian_h2le_8(unsigned_8 x);
|
63 |
|
|
INLINE_SIM_ENDIAN(unsigned_16) endian_h2le_16(unsigned_16 x);
|
64 |
|
|
|
65 |
|
|
INLINE_SIM_ENDIAN(unsigned_1) endian_le2h_1(unsigned_1 x);
|
66 |
|
|
INLINE_SIM_ENDIAN(unsigned_2) endian_le2h_2(unsigned_2 x);
|
67 |
|
|
INLINE_SIM_ENDIAN(unsigned_4) endian_le2h_4(unsigned_4 x);
|
68 |
|
|
INLINE_SIM_ENDIAN(unsigned_8) endian_le2h_8(unsigned_8 x);
|
69 |
|
|
INLINE_SIM_ENDIAN(unsigned_16) endian_le2h_16(unsigned_16 x);
|
70 |
|
|
|
71 |
|
|
INLINE_SIM_ENDIAN(void*) offset_1(unsigned_1 *x, unsigned ws, unsigned w);
|
72 |
|
|
INLINE_SIM_ENDIAN(void*) offset_2(unsigned_2 *x, unsigned ws, unsigned w);
|
73 |
|
|
INLINE_SIM_ENDIAN(void*) offset_4(unsigned_4 *x, unsigned ws, unsigned w);
|
74 |
|
|
INLINE_SIM_ENDIAN(void*) offset_8(unsigned_8 *x, unsigned ws, unsigned w);
|
75 |
|
|
INLINE_SIM_ENDIAN(void*) offset_16(unsigned_16 *x, unsigned ws, unsigned w);
|
76 |
|
|
|
77 |
|
|
INLINE_SIM_ENDIAN(unsigned_16) sim_endian_join_16 (unsigned_8 h, unsigned_8 l);
|
78 |
|
|
INLINE_SIM_ENDIAN(unsigned_8) sim_endian_split_16 (unsigned_16 word, int w);
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
/* SWAP */
|
82 |
|
|
|
83 |
|
|
#define SWAP_1(X) swap_1(X)
|
84 |
|
|
#define SWAP_2(X) swap_2(X)
|
85 |
|
|
#define SWAP_4(X) swap_4(X)
|
86 |
|
|
#define SWAP_8(X) swap_8(X)
|
87 |
|
|
#define SWAP_16(X) swap_16(X)
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
/* HOST to BE */
|
91 |
|
|
|
92 |
|
|
#define H2BE_1(X) endian_h2be_1(X)
|
93 |
|
|
#define H2BE_2(X) endian_h2be_2(X)
|
94 |
|
|
#define H2BE_4(X) endian_h2be_4(X)
|
95 |
|
|
#define H2BE_8(X) endian_h2be_8(X)
|
96 |
|
|
#define H2BE_16(X) endian_h2be_16(X)
|
97 |
|
|
#define BE2H_1(X) endian_be2h_1(X)
|
98 |
|
|
#define BE2H_2(X) endian_be2h_2(X)
|
99 |
|
|
#define BE2H_4(X) endian_be2h_4(X)
|
100 |
|
|
#define BE2H_8(X) endian_be2h_8(X)
|
101 |
|
|
#define BE2H_16(X) endian_be2h_16(X)
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
/* HOST to LE */
|
105 |
|
|
|
106 |
|
|
#define H2LE_1(X) endian_h2le_1(X)
|
107 |
|
|
#define H2LE_2(X) endian_h2le_2(X)
|
108 |
|
|
#define H2LE_4(X) endian_h2le_4(X)
|
109 |
|
|
#define H2LE_8(X) endian_h2le_8(X)
|
110 |
|
|
#define H2LE_16(X) endian_h2le_16(X)
|
111 |
|
|
#define LE2H_1(X) endian_le2h_1(X)
|
112 |
|
|
#define LE2H_2(X) endian_le2h_2(X)
|
113 |
|
|
#define LE2H_4(X) endian_le2h_4(X)
|
114 |
|
|
#define LE2H_8(X) endian_le2h_8(X)
|
115 |
|
|
#define LE2H_16(X) endian_le2h_16(X)
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
/* HOST to TARGET */
|
119 |
|
|
|
120 |
|
|
#define H2T_1(X) endian_h2t_1(X)
|
121 |
|
|
#define H2T_2(X) endian_h2t_2(X)
|
122 |
|
|
#define H2T_4(X) endian_h2t_4(X)
|
123 |
|
|
#define H2T_8(X) endian_h2t_8(X)
|
124 |
|
|
#define H2T_16(X) endian_h2t_16(X)
|
125 |
|
|
#define T2H_1(X) endian_t2h_1(X)
|
126 |
|
|
#define T2H_2(X) endian_t2h_2(X)
|
127 |
|
|
#define T2H_4(X) endian_t2h_4(X)
|
128 |
|
|
#define T2H_8(X) endian_t2h_8(X)
|
129 |
|
|
#define T2H_16(X) endian_t2h_16(X)
|
130 |
|
|
|
131 |
|
|
|
132 |
|
|
/* CONVERT IN PLACE
|
133 |
|
|
|
134 |
|
|
These macros, given an argument of unknown size, swap its value in
|
135 |
|
|
place if a host/target conversion is required. */
|
136 |
|
|
|
137 |
|
|
#define H2T(VARIABLE) \
|
138 |
|
|
do { \
|
139 |
|
|
void *vp = &(VARIABLE); \
|
140 |
|
|
switch (sizeof (VARIABLE)) { \
|
141 |
|
|
case 1: *(unsigned_1*)vp = H2T_1(*(unsigned_1*)vp); break; \
|
142 |
|
|
case 2: *(unsigned_2*)vp = H2T_2(*(unsigned_2*)vp); break; \
|
143 |
|
|
case 4: *(unsigned_4*)vp = H2T_4(*(unsigned_4*)vp); break; \
|
144 |
|
|
case 8: *(unsigned_8*)vp = H2T_8(*(unsigned_8*)vp); break; \
|
145 |
|
|
case 16: *(unsigned_16*)vp = H2T_16(*(unsigned_16*)vp); break; \
|
146 |
|
|
} \
|
147 |
|
|
} while (0)
|
148 |
|
|
|
149 |
|
|
#define T2H(VARIABLE) \
|
150 |
|
|
do { \
|
151 |
|
|
switch (sizeof(VARIABLE)) { \
|
152 |
|
|
case 1: VARIABLE = T2H_1(VARIABLE); break; \
|
153 |
|
|
case 2: VARIABLE = T2H_2(VARIABLE); break; \
|
154 |
|
|
case 4: VARIABLE = T2H_4(VARIABLE); break; \
|
155 |
|
|
case 8: VARIABLE = T2H_8(VARIABLE); break; \
|
156 |
|
|
/*case 16: VARIABLE = T2H_16(VARIABLE); break;*/ \
|
157 |
|
|
} \
|
158 |
|
|
} while (0)
|
159 |
|
|
|
160 |
|
|
#define SWAP(VARIABLE) \
|
161 |
|
|
do { \
|
162 |
|
|
switch (sizeof(VARIABLE)) { \
|
163 |
|
|
case 1: VARIABLE = SWAP_1(VARIABLE); break; \
|
164 |
|
|
case 2: VARIABLE = SWAP_2(VARIABLE); break; \
|
165 |
|
|
case 4: VARIABLE = SWAP_4(VARIABLE); break; \
|
166 |
|
|
case 8: VARIABLE = SWAP_8(VARIABLE); break; \
|
167 |
|
|
/*case 16: VARIABLE = SWAP_16(VARIABLE); break;*/ \
|
168 |
|
|
} \
|
169 |
|
|
} while (0)
|
170 |
|
|
|
171 |
|
|
#define H2BE(VARIABLE) \
|
172 |
|
|
do { \
|
173 |
|
|
switch (sizeof(VARIABLE)) { \
|
174 |
|
|
case 1: VARIABLE = H2BE_1(VARIABLE); break; \
|
175 |
|
|
case 2: VARIABLE = H2BE_2(VARIABLE); break; \
|
176 |
|
|
case 4: VARIABLE = H2BE_4(VARIABLE); break; \
|
177 |
|
|
case 8: VARIABLE = H2BE_8(VARIABLE); break; \
|
178 |
|
|
/*case 16: VARIABLE = H2BE_16(VARIABLE); break;*/ \
|
179 |
|
|
} \
|
180 |
|
|
} while (0)
|
181 |
|
|
|
182 |
|
|
#define BE2H(VARIABLE) \
|
183 |
|
|
do { \
|
184 |
|
|
switch (sizeof(VARIABLE)) { \
|
185 |
|
|
case 1: VARIABLE = BE2H_1(VARIABLE); break; \
|
186 |
|
|
case 2: VARIABLE = BE2H_2(VARIABLE); break; \
|
187 |
|
|
case 4: VARIABLE = BE2H_4(VARIABLE); break; \
|
188 |
|
|
case 8: VARIABLE = BE2H_8(VARIABLE); break; \
|
189 |
|
|
/*case 16: VARIABLE = BE2H_16(VARIABLE); break;*/ \
|
190 |
|
|
} \
|
191 |
|
|
} while (0)
|
192 |
|
|
|
193 |
|
|
#define H2LE(VARIABLE) \
|
194 |
|
|
do { \
|
195 |
|
|
switch (sizeof(VARIABLE)) { \
|
196 |
|
|
case 1: VARIABLE = H2LE_1(VARIABLE); break; \
|
197 |
|
|
case 2: VARIABLE = H2LE_2(VARIABLE); break; \
|
198 |
|
|
case 4: VARIABLE = H2LE_4(VARIABLE); break; \
|
199 |
|
|
case 8: VARIABLE = H2LE_8(VARIABLE); break; \
|
200 |
|
|
/*case 16: VARIABLE = H2LE_16(VARIABLE); break;*/ \
|
201 |
|
|
} \
|
202 |
|
|
} while (0)
|
203 |
|
|
|
204 |
|
|
#define LE2H(VARIABLE) \
|
205 |
|
|
do { \
|
206 |
|
|
switch (sizeof(VARIABLE)) { \
|
207 |
|
|
case 1: VARIABLE = LE2H_1(VARIABLE); break; \
|
208 |
|
|
case 2: VARIABLE = LE2H_2(VARIABLE); break; \
|
209 |
|
|
case 4: VARIABLE = LE2H_4(VARIABLE); break; \
|
210 |
|
|
case 8: VARIABLE = LE2H_8(VARIABLE); break; \
|
211 |
|
|
/*case 16: VARIABLE = LE2H_16(VARIABLE); break;*/ \
|
212 |
|
|
} \
|
213 |
|
|
} while (0)
|
214 |
|
|
|
215 |
|
|
|
216 |
|
|
|
217 |
|
|
/* TARGET WORD:
|
218 |
|
|
|
219 |
|
|
Byte swap a quantity the size of the targets word */
|
220 |
|
|
|
221 |
|
|
#if (WITH_TARGET_WORD_BITSIZE == 64)
|
222 |
|
|
#define H2T_word(X) H2T_8(X)
|
223 |
|
|
#define T2H_word(X) T2H_8(X)
|
224 |
|
|
#define H2BE_word(X) H2BE_8(X)
|
225 |
|
|
#define BE2H_word(X) BE2H_8(X)
|
226 |
|
|
#define H2LE_word(X) H2LE_8(X)
|
227 |
|
|
#define LE2H_word(X) LE2H_8(X)
|
228 |
|
|
#define SWAP_word(X) SWAP_8(X)
|
229 |
|
|
#endif
|
230 |
|
|
#if (WITH_TARGET_WORD_BITSIZE == 32)
|
231 |
|
|
#define H2T_word(X) H2T_4(X)
|
232 |
|
|
#define T2H_word(X) T2H_4(X)
|
233 |
|
|
#define H2BE_word(X) H2BE_4(X)
|
234 |
|
|
#define BE2H_word(X) BE2H_4(X)
|
235 |
|
|
#define H2LE_word(X) H2LE_4(X)
|
236 |
|
|
#define LE2H_word(X) LE2H_4(X)
|
237 |
|
|
#define SWAP_word(X) SWAP_4(X)
|
238 |
|
|
#endif
|
239 |
|
|
|
240 |
|
|
|
241 |
|
|
|
242 |
|
|
/* TARGET CELL:
|
243 |
|
|
|
244 |
|
|
Byte swap a quantity the size of the targets IEEE 1275 memory cell */
|
245 |
|
|
|
246 |
|
|
#define H2T_cell(X) H2T_4(X)
|
247 |
|
|
#define T2H_cell(X) T2H_4(X)
|
248 |
|
|
#define H2BE_cell(X) H2BE_4(X)
|
249 |
|
|
#define BE2H_cell(X) BE2H_4(X)
|
250 |
|
|
#define H2LE_cell(X) H2LE_4(X)
|
251 |
|
|
#define LE2H_cell(X) LE2H_4(X)
|
252 |
|
|
#define SWAP_cell(X) SWAP_4(X)
|
253 |
|
|
|
254 |
|
|
|
255 |
|
|
|
256 |
|
|
/* HOST Offsets:
|
257 |
|
|
|
258 |
|
|
Address of high/low sub-word within a host word quantity.
|
259 |
|
|
|
260 |
|
|
Address of sub-word N within a host word quantity. NOTE: Numbering
|
261 |
|
|
is BIG endian always. */
|
262 |
|
|
|
263 |
|
|
#define AH1_2(X) (unsigned_1*)offset_2((X), 1, 0)
|
264 |
|
|
#define AL1_2(X) (unsigned_1*)offset_2((X), 1, 1)
|
265 |
|
|
|
266 |
|
|
#define AH2_4(X) (unsigned_2*)offset_4((X), 2, 0)
|
267 |
|
|
#define AL2_4(X) (unsigned_2*)offset_4((X), 2, 1)
|
268 |
|
|
|
269 |
|
|
#define AH4_8(X) (unsigned_4*)offset_8((X), 4, 0)
|
270 |
|
|
#define AL4_8(X) (unsigned_4*)offset_8((X), 4, 1)
|
271 |
|
|
|
272 |
|
|
#define AH8_16(X) (unsigned_8*)offset_16((X), 8, 0)
|
273 |
|
|
#define AL8_16(X) (unsigned_8*)offset_16((X), 8, 1)
|
274 |
|
|
|
275 |
|
|
#if (WITH_TARGET_WORD_BITSIZE == 64)
|
276 |
|
|
#define AH_word(X) AH4_8(X)
|
277 |
|
|
#define AL_word(X) AL4_8(X)
|
278 |
|
|
#endif
|
279 |
|
|
#if (WITH_TARGET_WORD_BITSIZE == 32)
|
280 |
|
|
#define AH_word(X) AH2_4(X)
|
281 |
|
|
#define AL_word(X) AL2_4(X)
|
282 |
|
|
#endif
|
283 |
|
|
|
284 |
|
|
|
285 |
|
|
#define A1_2(X,N) (unsigned_1*)offset_2((X), 1, (N))
|
286 |
|
|
|
287 |
|
|
#define A1_4(X,N) (unsigned_1*)offset_4((X), 1, (N))
|
288 |
|
|
#define A2_4(X,N) (unsigned_2*)offset_4((X), 2, (N))
|
289 |
|
|
|
290 |
|
|
#define A1_8(X,N) (unsigned_1*)offset_8((X), 1, (N))
|
291 |
|
|
#define A2_8(X,N) (unsigned_2*)offset_8((X), 2, (N))
|
292 |
|
|
#define A4_8(X,N) (unsigned_4*)offset_8((X), 4, (N))
|
293 |
|
|
|
294 |
|
|
#define A1_16(X,N) (unsigned_1*)offset_16((X), 1, (N))
|
295 |
|
|
#define A2_16(X,N) (unsigned_2*)offset_16((X), 2, (N))
|
296 |
|
|
#define A4_16(X,N) (unsigned_4*)offset_16((X), 4, (N))
|
297 |
|
|
#define A8_16(X,N) (unsigned_8*)offset_16((X), 8, (N))
|
298 |
|
|
|
299 |
|
|
|
300 |
|
|
|
301 |
|
|
|
302 |
|
|
/* HOST Components:
|
303 |
|
|
|
304 |
|
|
Value of sub-word within a host word quantity */
|
305 |
|
|
|
306 |
|
|
#define VH1_2(X) ((unsigned_1)((unsigned_2)(X) >> 8))
|
307 |
|
|
#define VL1_2(X) (unsigned_1)(X)
|
308 |
|
|
|
309 |
|
|
#define VH2_4(X) ((unsigned_2)((unsigned_4)(X) >> 16))
|
310 |
|
|
#define VL2_4(X) ((unsigned_2)(X))
|
311 |
|
|
|
312 |
|
|
#define VH4_8(X) ((unsigned_4)((unsigned_8)(X) >> 32))
|
313 |
|
|
#define VL4_8(X) ((unsigned_4)(X))
|
314 |
|
|
|
315 |
|
|
#define VH8_16(X) (sim_endian_split_16 ((X), 0))
|
316 |
|
|
#define VL8_16(X) (sim_endian_split_16 ((X), 1))
|
317 |
|
|
|
318 |
|
|
#if (WITH_TARGET_WORD_BITSIZE == 64)
|
319 |
|
|
#define VH_word(X) VH4_8(X)
|
320 |
|
|
#define VL_word(X) VL4_8(X)
|
321 |
|
|
#endif
|
322 |
|
|
#if (WITH_TARGET_WORD_BITSIZE == 32)
|
323 |
|
|
#define VH_word(X) VH2_4(X)
|
324 |
|
|
#define VL_word(X) VL2_4(X)
|
325 |
|
|
#endif
|
326 |
|
|
|
327 |
|
|
|
328 |
|
|
#define V1_2(X,N) ((unsigned_1)((unsigned_2)(X) >> ( 8 * (1 - (N)))))
|
329 |
|
|
|
330 |
|
|
#define V1_4(X,N) ((unsigned_1)((unsigned_4)(X) >> ( 8 * (3 - (N)))))
|
331 |
|
|
#define V2_4(X,N) ((unsigned_2)((unsigned_4)(X) >> (16 * (1 - (N)))))
|
332 |
|
|
|
333 |
|
|
#define V1_8(X,N) ((unsigned_1)((unsigned_8)(X) >> ( 8 * (7 - (N)))))
|
334 |
|
|
#define V2_8(X,N) ((unsigned_2)((unsigned_8)(X) >> (16 * (3 - (N)))))
|
335 |
|
|
#define V4_8(X,N) ((unsigned_4)((unsigned_8)(X) >> (32 * (1 - (N)))))
|
336 |
|
|
|
337 |
|
|
#define V1_16(X,N) (*A1_16 (&(X),N))
|
338 |
|
|
#define V2_16(X,N) (*A2_16 (&(X),N))
|
339 |
|
|
#define V4_16(X,N) (*A4_16 (&(X),N))
|
340 |
|
|
#define V8_16(X,N) (*A8_16 (&(X),N))
|
341 |
|
|
|
342 |
|
|
|
343 |
|
|
/* Reverse - insert sub-word into word quantity */
|
344 |
|
|
|
345 |
|
|
#define V2_H1(X) ((unsigned_2)(unsigned_1)(X) << 8)
|
346 |
|
|
#define V2_L1(X) ((unsigned_2)(unsigned_1)(X))
|
347 |
|
|
|
348 |
|
|
#define V4_H2(X) ((unsigned_4)(unsigned_2)(X) << 16)
|
349 |
|
|
#define V4_L2(X) ((unsigned_4)(unsigned_2)(X))
|
350 |
|
|
|
351 |
|
|
#define V8_H4(X) ((unsigned_8)(unsigned_4)(X) << 32)
|
352 |
|
|
#define V8_L4(X) ((unsigned_8)(unsigned_4)(X))
|
353 |
|
|
|
354 |
|
|
#define V16_H8(X) ((unsigned_16)(unsigned_8)(X) << 64)
|
355 |
|
|
#define V16_L8(X) ((unsigned_16)(unsigned_8)(X))
|
356 |
|
|
|
357 |
|
|
|
358 |
|
|
#define V2_1(X,N) ((unsigned_2)(unsigned_1)(X) << ( 8 * (1 - (N))))
|
359 |
|
|
|
360 |
|
|
#define V4_1(X,N) ((unsigned_4)(unsigned_1)(X) << ( 8 * (3 - (N))))
|
361 |
|
|
#define V4_2(X,N) ((unsigned_4)(unsigned_2)(X) << (16 * (1 - (N))))
|
362 |
|
|
|
363 |
|
|
#define V8_1(X,N) ((unsigned_8)(unsigned_1)(X) << ( 8 * (7 - (N))))
|
364 |
|
|
#define V8_2(X,N) ((unsigned_8)(unsigned_2)(X) << (16 * (3 - (N))))
|
365 |
|
|
#define V8_4(X,N) ((unsigned_8)(unsigned_4)(X) << (32 * (1 - (N))))
|
366 |
|
|
|
367 |
|
|
#define V16_1(X,N) ((unsigned_16)(unsigned_1)(X) << ( 8 * (15 - (N))))
|
368 |
|
|
#define V16_2(X,N) ((unsigned_16)(unsigned_2)(X) << (16 * (7 - (N))))
|
369 |
|
|
#define V16_4(X,N) ((unsigned_16)(unsigned_4)(X) << (32 * (3 - (N))))
|
370 |
|
|
#define V16_8(X,N) ((unsigned_16)(unsigned_8)(X) << (64 * (1 - (N))))
|
371 |
|
|
|
372 |
|
|
|
373 |
|
|
/* Reverse - insert N sub-words into single word quantity */
|
374 |
|
|
|
375 |
|
|
#define U2_1(I0,I1) (V2_1(I0,0) | V2_1(I1,1))
|
376 |
|
|
#define U4_1(I0,I1,I2,I3) (V4_1(I0,0) | V4_1(I1,1) | V4_1(I2,2) | V4_1(I3,3))
|
377 |
|
|
#define U8_1(I0,I1,I2,I3,I4,I5,I6,I7) \
|
378 |
|
|
(V8_1(I0,0) | V8_1(I1,1) | V8_1(I2,2) | V8_1(I3,3) \
|
379 |
|
|
| V8_1(I4,4) | V8_1(I5,5) | V8_1(I6,6) | V8_1(I7,7))
|
380 |
|
|
#define U16_1(I0,I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11,I12,I13,I14,I15) \
|
381 |
|
|
(V16_1(I0,0) | V16_1(I1,1) | V16_1(I2,2) | V16_1(I3,3) \
|
382 |
|
|
| V16_1(I4,4) | V16_1(I5,5) | V16_1(I6,6) | V16_1(I7,7) \
|
383 |
|
|
| V16_1(I8,8) | V16_1(I9,9) | V16_1(I10,10) | V16_1(I11,11) \
|
384 |
|
|
| V16_1(I12,12) | V16_1(I13,13) | V16_1(I14,14) | V16_1(I15,15))
|
385 |
|
|
|
386 |
|
|
#define U4_2(I0,I1) (V4_2(I0,0) | V4_2(I1,1))
|
387 |
|
|
#define U8_2(I0,I1,I2,I3) (V8_2(I0,0) | V8_2(I1,1) | V8_2(I2,2) | V8_2(I3,3))
|
388 |
|
|
#define U16_2(I0,I1,I2,I3,I4,I5,I6,I7) \
|
389 |
|
|
(V16_2(I0,0) | V16_2(I1,1) | V16_2(I2,2) | V16_2(I3,3) \
|
390 |
|
|
| V16_2(I4,4) | V16_2(I5,5) | V16_2(I6,6) | V16_2(I7,7) )
|
391 |
|
|
|
392 |
|
|
#define U8_4(I0,I1) (V8_4(I0,0) | V8_4(I1,1))
|
393 |
|
|
#define U16_4(I0,I1,I2,I3) (V16_4(I0,0) | V16_4(I1,1) | V16_4(I2,2) | V16_4(I3,3))
|
394 |
|
|
|
395 |
|
|
#define U16_8(I0,I1) (sim_endian_join_16 (I0, I1))
|
396 |
|
|
|
397 |
|
|
|
398 |
|
|
#if (WITH_TARGET_WORD_BITSIZE == 64)
|
399 |
|
|
#define Vword_H(X) V8_H4(X)
|
400 |
|
|
#define Vword_L(X) V8_L4(X)
|
401 |
|
|
#endif
|
402 |
|
|
#if (WITH_TARGET_WORD_BITSIZE == 32)
|
403 |
|
|
#define Vword_H(X) V4_H2(X)
|
404 |
|
|
#define Vword_L(X) V4_L2(X)
|
405 |
|
|
#endif
|
406 |
|
|
|
407 |
|
|
|
408 |
|
|
|
409 |
|
|
|
410 |
|
|
#if H_REVEALS_MODULE_P (SIM_ENDIAN_INLINE)
|
411 |
|
|
#include "sim-endian.c"
|
412 |
|
|
#endif
|
413 |
|
|
|
414 |
|
|
#endif /* _SIM_ENDIAN_H_ */
|