Commit | Line | Data |
---|---|---|
886a2506 | 1 | /* Insert/extract functions for the ARC opcodes. |
6f2750fe | 2 | Copyright (C) 2015-2016 Free Software Foundation, Inc. |
886a2506 NC |
3 | |
4 | Contributed by Claudiu Zissulescu (claziss@synopsys.com) | |
5 | ||
6 | This file is part of libopcodes. | |
7 | ||
8 | This library is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 3, or (at your option) | |
11 | any later version. | |
12 | ||
13 | It is distributed in the hope that it will be useful, but WITHOUT | |
14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public | |
16 | License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with this program; if not, write to the Free Software Foundation, | |
20 | Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ | |
21 | ||
22 | #ifndef INSERT_LIMM | |
23 | #define INSERT_LIMM | |
24 | /* mask = 00000000000000000000000000000000 | |
25 | insn = 00100bbb00101111FBBB111110001001. */ | |
bdfe53e3 AB |
26 | static unsigned long long |
27 | insert_limm (unsigned long long insn ATTRIBUTE_UNUSED, | |
28 | long long int value ATTRIBUTE_UNUSED, const char **errmsg ATTRIBUTE_UNUSED) | |
886a2506 NC |
29 | { |
30 | ||
31 | return insn; | |
32 | } | |
33 | #endif /* INSERT_LIMM */ | |
34 | ||
35 | #ifndef EXTRACT_LIMM | |
36 | #define EXTRACT_LIMM | |
37 | /* mask = 00000000000000000000000000000000. */ | |
38 | static ATTRIBUTE_UNUSED int | |
bdfe53e3 | 39 | extract_limm (unsigned long long insn ATTRIBUTE_UNUSED, bfd_boolean * invalid ATTRIBUTE_UNUSED) |
886a2506 NC |
40 | { |
41 | unsigned value = 0; | |
42 | ||
43 | return value; | |
44 | } | |
45 | #endif /* EXTRACT_LIMM */ | |
46 | ||
47 | #ifndef INSERT_UIMM6_20 | |
48 | #define INSERT_UIMM6_20 | |
49 | /* mask = 00000000000000000000111111000000 | |
50 | insn = 00100bbb01101111FBBBuuuuuu001001. */ | |
bdfe53e3 AB |
51 | static unsigned long long |
52 | insert_uimm6_20 (unsigned long long insn ATTRIBUTE_UNUSED, | |
53 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
54 | const char **errmsg ATTRIBUTE_UNUSED) |
55 | { | |
56 | ||
57 | insn |= ((value >> 0) & 0x003f) << 6; | |
58 | ||
59 | return insn; | |
60 | } | |
61 | #endif /* INSERT_UIMM6_20 */ | |
62 | ||
63 | #ifndef EXTRACT_UIMM6_20 | |
64 | #define EXTRACT_UIMM6_20 | |
65 | /* mask = 00000000000000000000111111000000. */ | |
bdfe53e3 AB |
66 | static long long int |
67 | extract_uimm6_20 (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
68 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
69 | { | |
70 | unsigned value = 0; | |
71 | ||
72 | value |= ((insn >> 6) & 0x003f) << 0; | |
73 | ||
74 | return value; | |
75 | } | |
76 | #endif /* EXTRACT_UIMM6_20 */ | |
77 | ||
78 | #ifndef INSERT_SIMM12_20 | |
79 | #define INSERT_SIMM12_20 | |
80 | /* mask = 00000000000000000000111111222222 | |
81 | insn = 00110bbb10101000FBBBssssssSSSSSS. */ | |
bdfe53e3 AB |
82 | static unsigned long long |
83 | insert_simm12_20 (unsigned long long insn ATTRIBUTE_UNUSED, | |
84 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
85 | const char **errmsg ATTRIBUTE_UNUSED) |
86 | { | |
87 | ||
88 | insn |= ((value >> 0) & 0x003f) << 6; | |
89 | insn |= ((value >> 6) & 0x003f) << 0; | |
90 | ||
91 | return insn; | |
92 | } | |
93 | #endif /* INSERT_SIMM12_20 */ | |
94 | ||
95 | #ifndef EXTRACT_SIMM12_20 | |
96 | #define EXTRACT_SIMM12_20 | |
97 | /* mask = 00000000000000000000111111222222. */ | |
bdfe53e3 AB |
98 | static long long int |
99 | extract_simm12_20 (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
100 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
101 | { | |
102 | int value = 0; | |
103 | ||
104 | value |= ((insn >> 6) & 0x003f) << 0; | |
105 | value |= ((insn >> 0) & 0x003f) << 6; | |
106 | ||
107 | /* Extend the sign. */ | |
108 | int signbit = 1 << (12 - 1); | |
109 | value = (value ^ signbit) - signbit; | |
110 | ||
111 | return value; | |
112 | } | |
113 | #endif /* EXTRACT_SIMM12_20 */ | |
114 | ||
115 | #ifndef INSERT_SIMM3_5_S | |
116 | #define INSERT_SIMM3_5_S | |
117 | /* mask = 0000011100000000 | |
118 | insn = 01110ssshhh001HH. */ | |
119 | static ATTRIBUTE_UNUSED unsigned | |
bdfe53e3 AB |
120 | insert_simm3_5_s (unsigned long long insn ATTRIBUTE_UNUSED, |
121 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
122 | const char **errmsg ATTRIBUTE_UNUSED) |
123 | { | |
124 | ||
125 | insn |= ((value >> 0) & 0x0007) << 8; | |
126 | ||
127 | return insn; | |
128 | } | |
129 | #endif /* INSERT_SIMM3_5_S */ | |
130 | ||
131 | #ifndef EXTRACT_SIMM3_5_S | |
132 | #define EXTRACT_SIMM3_5_S | |
133 | /* mask = 0000011100000000. */ | |
134 | static ATTRIBUTE_UNUSED int | |
bdfe53e3 | 135 | extract_simm3_5_s (unsigned long long insn ATTRIBUTE_UNUSED, |
886a2506 NC |
136 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
137 | { | |
138 | int value = 0; | |
139 | ||
140 | value |= ((insn >> 8) & 0x0007) << 0; | |
141 | ||
142 | /* Extend the sign. */ | |
143 | int signbit = 1 << (3 - 1); | |
144 | value = (value ^ signbit) - signbit; | |
145 | ||
146 | return value; | |
147 | } | |
148 | #endif /* EXTRACT_SIMM3_5_S */ | |
149 | ||
150 | #ifndef INSERT_LIMM_S | |
151 | #define INSERT_LIMM_S | |
152 | /* mask = 0000000000000000 | |
153 | insn = 01110sss11000111. */ | |
154 | static ATTRIBUTE_UNUSED unsigned | |
bdfe53e3 AB |
155 | insert_limm_s (unsigned long long insn ATTRIBUTE_UNUSED, |
156 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
157 | const char **errmsg ATTRIBUTE_UNUSED) |
158 | { | |
159 | ||
160 | return insn; | |
161 | } | |
162 | #endif /* INSERT_LIMM_S */ | |
163 | ||
164 | #ifndef EXTRACT_LIMM_S | |
165 | #define EXTRACT_LIMM_S | |
166 | /* mask = 0000000000000000. */ | |
167 | static ATTRIBUTE_UNUSED int | |
bdfe53e3 | 168 | extract_limm_s (unsigned long long insn ATTRIBUTE_UNUSED, bfd_boolean * invalid ATTRIBUTE_UNUSED) |
886a2506 NC |
169 | { |
170 | unsigned value = 0; | |
171 | ||
172 | return value; | |
173 | } | |
174 | #endif /* EXTRACT_LIMM_S */ | |
175 | ||
176 | #ifndef INSERT_UIMM7_A32_11_S | |
177 | #define INSERT_UIMM7_A32_11_S | |
178 | /* mask = 0000000000011111 | |
179 | insn = 11000bbb100uuuuu. */ | |
bdfe53e3 AB |
180 | static unsigned long long |
181 | insert_uimm7_a32_11_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
182 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
183 | const char **errmsg ATTRIBUTE_UNUSED) |
184 | { | |
185 | if (value & 0x03) | |
186 | *errmsg = _("Target address is not 32bit aligned."); | |
187 | ||
188 | insn |= ((value >> 2) & 0x001f) << 0; | |
189 | ||
190 | return insn; | |
191 | } | |
192 | #endif /* INSERT_UIMM7_A32_11_S */ | |
193 | ||
194 | #ifndef EXTRACT_UIMM7_A32_11_S | |
195 | #define EXTRACT_UIMM7_A32_11_S | |
196 | /* mask = 0000000000011111. */ | |
bdfe53e3 AB |
197 | static long long int |
198 | extract_uimm7_a32_11_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
199 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
200 | { | |
201 | unsigned value = 0; | |
202 | ||
203 | value |= ((insn >> 0) & 0x001f) << 2; | |
204 | ||
205 | return value; | |
206 | } | |
207 | #endif /* EXTRACT_UIMM7_A32_11_S */ | |
208 | ||
209 | #ifndef INSERT_UIMM7_9_S | |
210 | #define INSERT_UIMM7_9_S | |
211 | /* mask = 0000000001111111 | |
212 | insn = 11100bbb0uuuuuuu. */ | |
bdfe53e3 AB |
213 | static unsigned long long |
214 | insert_uimm7_9_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
215 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
216 | const char **errmsg ATTRIBUTE_UNUSED) |
217 | { | |
218 | ||
219 | insn |= ((value >> 0) & 0x007f) << 0; | |
220 | ||
221 | return insn; | |
222 | } | |
223 | #endif /* INSERT_UIMM7_9_S */ | |
224 | ||
225 | #ifndef EXTRACT_UIMM7_9_S | |
226 | #define EXTRACT_UIMM7_9_S | |
227 | /* mask = 0000000001111111. */ | |
bdfe53e3 AB |
228 | static long long int |
229 | extract_uimm7_9_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
230 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
231 | { | |
232 | unsigned value = 0; | |
233 | ||
234 | value |= ((insn >> 0) & 0x007f) << 0; | |
235 | ||
236 | return value; | |
237 | } | |
238 | #endif /* EXTRACT_UIMM7_9_S */ | |
239 | ||
240 | #ifndef INSERT_UIMM3_13_S | |
241 | #define INSERT_UIMM3_13_S | |
242 | /* mask = 0000000000000111 | |
243 | insn = 01101bbbccc00uuu. */ | |
bdfe53e3 AB |
244 | static unsigned long long |
245 | insert_uimm3_13_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
246 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
247 | const char **errmsg ATTRIBUTE_UNUSED) |
248 | { | |
249 | ||
250 | insn |= ((value >> 0) & 0x0007) << 0; | |
251 | ||
252 | return insn; | |
253 | } | |
254 | #endif /* INSERT_UIMM3_13_S */ | |
255 | ||
256 | #ifndef EXTRACT_UIMM3_13_S | |
257 | #define EXTRACT_UIMM3_13_S | |
258 | /* mask = 0000000000000111. */ | |
bdfe53e3 AB |
259 | static long long int |
260 | extract_uimm3_13_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
261 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
262 | { | |
263 | unsigned value = 0; | |
264 | ||
265 | value |= ((insn >> 0) & 0x0007) << 0; | |
266 | ||
267 | return value; | |
268 | } | |
269 | #endif /* EXTRACT_UIMM3_13_S */ | |
270 | ||
271 | #ifndef INSERT_SIMM11_A32_7_S | |
272 | #define INSERT_SIMM11_A32_7_S | |
273 | /* mask = 0000000111111111 | |
274 | insn = 1100111sssssssss. */ | |
bdfe53e3 AB |
275 | static unsigned long long |
276 | insert_simm11_a32_7_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
277 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
278 | const char **errmsg ATTRIBUTE_UNUSED) |
279 | { | |
280 | if (value & 0x03) | |
281 | *errmsg = _("Target address is not 32bit aligned."); | |
282 | ||
283 | insn |= ((value >> 2) & 0x01ff) << 0; | |
284 | ||
285 | return insn; | |
286 | } | |
287 | #endif /* INSERT_SIMM11_A32_7_S */ | |
288 | ||
289 | #ifndef EXTRACT_SIMM11_A32_7_S | |
290 | #define EXTRACT_SIMM11_A32_7_S | |
291 | /* mask = 0000000111111111. */ | |
bdfe53e3 AB |
292 | static long long int |
293 | extract_simm11_a32_7_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
294 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
295 | { | |
296 | int value = 0; | |
297 | ||
298 | value |= ((insn >> 0) & 0x01ff) << 2; | |
299 | ||
300 | /* Extend the sign. */ | |
301 | int signbit = 1 << (11 - 1); | |
302 | value = (value ^ signbit) - signbit; | |
303 | ||
304 | return value; | |
305 | } | |
306 | #endif /* EXTRACT_SIMM11_A32_7_S */ | |
307 | ||
308 | #ifndef INSERT_UIMM6_13_S | |
309 | #define INSERT_UIMM6_13_S | |
310 | /* mask = 0000000002220111 | |
311 | insn = 01001bbb0UUU1uuu. */ | |
bdfe53e3 AB |
312 | static unsigned long long |
313 | insert_uimm6_13_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
314 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
315 | const char **errmsg ATTRIBUTE_UNUSED) |
316 | { | |
317 | ||
318 | insn |= ((value >> 0) & 0x0007) << 0; | |
319 | insn |= ((value >> 3) & 0x0007) << 4; | |
320 | ||
321 | return insn; | |
322 | } | |
323 | #endif /* INSERT_UIMM6_13_S */ | |
324 | ||
325 | #ifndef EXTRACT_UIMM6_13_S | |
326 | #define EXTRACT_UIMM6_13_S | |
327 | /* mask = 0000000002220111. */ | |
bdfe53e3 AB |
328 | static long long int |
329 | extract_uimm6_13_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
330 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
331 | { | |
332 | unsigned value = 0; | |
333 | ||
334 | value |= ((insn >> 0) & 0x0007) << 0; | |
335 | value |= ((insn >> 4) & 0x0007) << 3; | |
336 | ||
337 | return value; | |
338 | } | |
339 | #endif /* EXTRACT_UIMM6_13_S */ | |
340 | ||
341 | #ifndef INSERT_UIMM5_11_S | |
342 | #define INSERT_UIMM5_11_S | |
343 | /* mask = 0000000000011111 | |
344 | insn = 10111bbb000uuuuu. */ | |
bdfe53e3 AB |
345 | static unsigned long long |
346 | insert_uimm5_11_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
347 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
348 | const char **errmsg ATTRIBUTE_UNUSED) |
349 | { | |
350 | ||
351 | insn |= ((value >> 0) & 0x001f) << 0; | |
352 | ||
353 | return insn; | |
354 | } | |
355 | #endif /* INSERT_UIMM5_11_S */ | |
356 | ||
357 | #ifndef EXTRACT_UIMM5_11_S | |
358 | #define EXTRACT_UIMM5_11_S | |
359 | /* mask = 0000000000011111. */ | |
bdfe53e3 AB |
360 | static long long int |
361 | extract_uimm5_11_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
362 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
363 | { | |
364 | unsigned value = 0; | |
365 | ||
366 | value |= ((insn >> 0) & 0x001f) << 0; | |
367 | ||
368 | return value; | |
369 | } | |
370 | #endif /* EXTRACT_UIMM5_11_S */ | |
371 | ||
372 | #ifndef INSERT_SIMM9_A16_8 | |
373 | #define INSERT_SIMM9_A16_8 | |
374 | /* mask = 00000000111111102000000000000000 | |
375 | insn = 00001bbbsssssss1SBBBCCCCCCN01110. */ | |
bdfe53e3 AB |
376 | static unsigned long long |
377 | insert_simm9_a16_8 (unsigned long long insn ATTRIBUTE_UNUSED, | |
378 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
379 | const char **errmsg ATTRIBUTE_UNUSED) |
380 | { | |
381 | if (value & 0x01) | |
382 | *errmsg = _("Target address is not 16bit aligned."); | |
383 | ||
384 | insn |= ((value >> 1) & 0x007f) << 17; | |
385 | insn |= ((value >> 8) & 0x0001) << 15; | |
386 | ||
387 | return insn; | |
388 | } | |
389 | #endif /* INSERT_SIMM9_A16_8 */ | |
390 | ||
391 | #ifndef EXTRACT_SIMM9_A16_8 | |
392 | #define EXTRACT_SIMM9_A16_8 | |
393 | /* mask = 00000000111111102000000000000000. */ | |
bdfe53e3 AB |
394 | static long long int |
395 | extract_simm9_a16_8 (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
396 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
397 | { | |
398 | int value = 0; | |
399 | ||
400 | value |= ((insn >> 17) & 0x007f) << 1; | |
401 | value |= ((insn >> 15) & 0x0001) << 8; | |
402 | ||
403 | /* Extend the sign. */ | |
404 | int signbit = 1 << (9 - 1); | |
405 | value = (value ^ signbit) - signbit; | |
406 | ||
407 | return value; | |
408 | } | |
409 | #endif /* EXTRACT_SIMM9_A16_8 */ | |
410 | ||
411 | #ifndef INSERT_UIMM6_8 | |
412 | #define INSERT_UIMM6_8 | |
413 | /* mask = 00000000000000000000111111000000 | |
414 | insn = 00001bbbsssssss1SBBBuuuuuuN11110. */ | |
bdfe53e3 AB |
415 | static unsigned long long |
416 | insert_uimm6_8 (unsigned long long insn ATTRIBUTE_UNUSED, | |
417 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
418 | const char **errmsg ATTRIBUTE_UNUSED) |
419 | { | |
420 | ||
421 | insn |= ((value >> 0) & 0x003f) << 6; | |
422 | ||
423 | return insn; | |
424 | } | |
425 | #endif /* INSERT_UIMM6_8 */ | |
426 | ||
427 | #ifndef EXTRACT_UIMM6_8 | |
428 | #define EXTRACT_UIMM6_8 | |
429 | /* mask = 00000000000000000000111111000000. */ | |
bdfe53e3 AB |
430 | static long long int |
431 | extract_uimm6_8 (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
432 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
433 | { | |
434 | unsigned value = 0; | |
435 | ||
436 | value |= ((insn >> 6) & 0x003f) << 0; | |
437 | ||
438 | return value; | |
439 | } | |
440 | #endif /* EXTRACT_UIMM6_8 */ | |
441 | ||
442 | #ifndef INSERT_SIMM21_A16_5 | |
443 | #define INSERT_SIMM21_A16_5 | |
444 | /* mask = 00000111111111102222222222000000 | |
445 | insn = 00000ssssssssss0SSSSSSSSSSNQQQQQ. */ | |
bdfe53e3 AB |
446 | static unsigned long long |
447 | insert_simm21_a16_5 (unsigned long long insn ATTRIBUTE_UNUSED, | |
448 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
449 | const char **errmsg ATTRIBUTE_UNUSED) |
450 | { | |
451 | if (value & 0x01) | |
452 | *errmsg = _("Target address is not 16bit aligned."); | |
453 | ||
454 | insn |= ((value >> 1) & 0x03ff) << 17; | |
455 | insn |= ((value >> 11) & 0x03ff) << 6; | |
456 | ||
457 | return insn; | |
458 | } | |
459 | #endif /* INSERT_SIMM21_A16_5 */ | |
460 | ||
461 | #ifndef EXTRACT_SIMM21_A16_5 | |
462 | #define EXTRACT_SIMM21_A16_5 | |
463 | /* mask = 00000111111111102222222222000000. */ | |
bdfe53e3 AB |
464 | static long long int |
465 | extract_simm21_a16_5 (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
466 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
467 | { | |
468 | int value = 0; | |
469 | ||
470 | value |= ((insn >> 17) & 0x03ff) << 1; | |
471 | value |= ((insn >> 6) & 0x03ff) << 11; | |
472 | ||
473 | /* Extend the sign. */ | |
474 | int signbit = 1 << (21 - 1); | |
475 | value = (value ^ signbit) - signbit; | |
476 | ||
477 | return value; | |
478 | } | |
479 | #endif /* EXTRACT_SIMM21_A16_5 */ | |
480 | ||
481 | #ifndef INSERT_SIMM25_A16_5 | |
482 | #define INSERT_SIMM25_A16_5 | |
483 | /* mask = 00000111111111102222222222003333 | |
484 | insn = 00000ssssssssss1SSSSSSSSSSNRtttt. */ | |
bdfe53e3 AB |
485 | static unsigned long long |
486 | insert_simm25_a16_5 (unsigned long long insn ATTRIBUTE_UNUSED, | |
487 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
488 | const char **errmsg ATTRIBUTE_UNUSED) |
489 | { | |
490 | if (value & 0x01) | |
491 | *errmsg = _("Target address is not 16bit aligned."); | |
492 | ||
493 | insn |= ((value >> 1) & 0x03ff) << 17; | |
494 | insn |= ((value >> 11) & 0x03ff) << 6; | |
495 | insn |= ((value >> 21) & 0x000f) << 0; | |
496 | ||
497 | return insn; | |
498 | } | |
499 | #endif /* INSERT_SIMM25_A16_5 */ | |
500 | ||
501 | #ifndef EXTRACT_SIMM25_A16_5 | |
502 | #define EXTRACT_SIMM25_A16_5 | |
503 | /* mask = 00000111111111102222222222003333. */ | |
bdfe53e3 AB |
504 | static long long int |
505 | extract_simm25_a16_5 (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
506 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
507 | { | |
508 | int value = 0; | |
509 | ||
510 | value |= ((insn >> 17) & 0x03ff) << 1; | |
511 | value |= ((insn >> 6) & 0x03ff) << 11; | |
512 | value |= ((insn >> 0) & 0x000f) << 21; | |
513 | ||
514 | /* Extend the sign. */ | |
515 | int signbit = 1 << (25 - 1); | |
516 | value = (value ^ signbit) - signbit; | |
517 | ||
518 | return value; | |
519 | } | |
520 | #endif /* EXTRACT_SIMM25_A16_5 */ | |
521 | ||
522 | #ifndef INSERT_SIMM10_A16_7_S | |
523 | #define INSERT_SIMM10_A16_7_S | |
524 | /* mask = 0000000111111111 | |
525 | insn = 1111001sssssssss. */ | |
bdfe53e3 AB |
526 | static unsigned long long |
527 | insert_simm10_a16_7_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
528 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
529 | const char **errmsg ATTRIBUTE_UNUSED) |
530 | { | |
531 | if (value & 0x01) | |
532 | *errmsg = _("Target address is not 16bit aligned."); | |
533 | ||
534 | insn |= ((value >> 1) & 0x01ff) << 0; | |
535 | ||
536 | return insn; | |
537 | } | |
538 | #endif /* INSERT_SIMM10_A16_7_S */ | |
539 | ||
540 | #ifndef EXTRACT_SIMM10_A16_7_S | |
541 | #define EXTRACT_SIMM10_A16_7_S | |
542 | /* mask = 0000000111111111. */ | |
bdfe53e3 AB |
543 | static long long int |
544 | extract_simm10_a16_7_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
545 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
546 | { | |
547 | int value = 0; | |
548 | ||
549 | value |= ((insn >> 0) & 0x01ff) << 1; | |
550 | ||
551 | /* Extend the sign. */ | |
552 | int signbit = 1 << (10 - 1); | |
553 | value = (value ^ signbit) - signbit; | |
554 | ||
555 | return value; | |
556 | } | |
557 | #endif /* EXTRACT_SIMM10_A16_7_S */ | |
558 | ||
559 | #ifndef INSERT_SIMM7_A16_10_S | |
560 | #define INSERT_SIMM7_A16_10_S | |
561 | /* mask = 0000000000111111 | |
562 | insn = 1111011000ssssss. */ | |
bdfe53e3 AB |
563 | static unsigned long long |
564 | insert_simm7_a16_10_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
565 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
566 | const char **errmsg ATTRIBUTE_UNUSED) |
567 | { | |
568 | if (value & 0x01) | |
569 | *errmsg = _("Target address is not 16bit aligned."); | |
570 | ||
571 | insn |= ((value >> 1) & 0x003f) << 0; | |
572 | ||
573 | return insn; | |
574 | } | |
575 | #endif /* INSERT_SIMM7_A16_10_S */ | |
576 | ||
577 | #ifndef EXTRACT_SIMM7_A16_10_S | |
578 | #define EXTRACT_SIMM7_A16_10_S | |
579 | /* mask = 0000000000111111. */ | |
bdfe53e3 AB |
580 | static long long int |
581 | extract_simm7_a16_10_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
582 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
583 | { | |
584 | int value = 0; | |
585 | ||
586 | value |= ((insn >> 0) & 0x003f) << 1; | |
587 | ||
588 | /* Extend the sign. */ | |
589 | int signbit = 1 << (7 - 1); | |
590 | value = (value ^ signbit) - signbit; | |
591 | ||
592 | return value; | |
593 | } | |
594 | #endif /* EXTRACT_SIMM7_A16_10_S */ | |
595 | ||
596 | #ifndef INSERT_SIMM21_A32_5 | |
597 | #define INSERT_SIMM21_A32_5 | |
598 | /* mask = 00000111111111002222222222000000 | |
599 | insn = 00001sssssssss00SSSSSSSSSSNQQQQQ. */ | |
bdfe53e3 AB |
600 | static unsigned long long |
601 | insert_simm21_a32_5 (unsigned long long insn ATTRIBUTE_UNUSED, | |
602 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
603 | const char **errmsg ATTRIBUTE_UNUSED) |
604 | { | |
605 | if (value & 0x03) | |
606 | *errmsg = _("Target address is not 32bit aligned."); | |
607 | ||
608 | insn |= ((value >> 2) & 0x01ff) << 18; | |
609 | insn |= ((value >> 11) & 0x03ff) << 6; | |
610 | ||
611 | return insn; | |
612 | } | |
613 | #endif /* INSERT_SIMM21_A32_5 */ | |
614 | ||
615 | #ifndef EXTRACT_SIMM21_A32_5 | |
616 | #define EXTRACT_SIMM21_A32_5 | |
617 | /* mask = 00000111111111002222222222000000. */ | |
bdfe53e3 AB |
618 | static long long int |
619 | extract_simm21_a32_5 (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
620 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
621 | { | |
622 | int value = 0; | |
623 | ||
624 | value |= ((insn >> 18) & 0x01ff) << 2; | |
625 | value |= ((insn >> 6) & 0x03ff) << 11; | |
626 | ||
627 | /* Extend the sign. */ | |
628 | int signbit = 1 << (21 - 1); | |
629 | value = (value ^ signbit) - signbit; | |
630 | ||
631 | return value; | |
632 | } | |
633 | #endif /* EXTRACT_SIMM21_A32_5 */ | |
634 | ||
635 | #ifndef INSERT_SIMM25_A32_5 | |
636 | #define INSERT_SIMM25_A32_5 | |
637 | /* mask = 00000111111111002222222222003333 | |
638 | insn = 00001sssssssss10SSSSSSSSSSNRtttt. */ | |
bdfe53e3 AB |
639 | static unsigned long long |
640 | insert_simm25_a32_5 (unsigned long long insn ATTRIBUTE_UNUSED, | |
641 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
642 | const char **errmsg ATTRIBUTE_UNUSED) |
643 | { | |
644 | if (value & 0x03) | |
645 | *errmsg = _("Target address is not 32bit aligned."); | |
646 | ||
647 | insn |= ((value >> 2) & 0x01ff) << 18; | |
648 | insn |= ((value >> 11) & 0x03ff) << 6; | |
649 | insn |= ((value >> 21) & 0x000f) << 0; | |
650 | ||
651 | return insn; | |
652 | } | |
653 | #endif /* INSERT_SIMM25_A32_5 */ | |
654 | ||
655 | #ifndef EXTRACT_SIMM25_A32_5 | |
656 | #define EXTRACT_SIMM25_A32_5 | |
657 | /* mask = 00000111111111002222222222003333. */ | |
bdfe53e3 AB |
658 | static long long int |
659 | extract_simm25_a32_5 (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
660 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
661 | { | |
662 | int value = 0; | |
663 | ||
664 | value |= ((insn >> 18) & 0x01ff) << 2; | |
665 | value |= ((insn >> 6) & 0x03ff) << 11; | |
666 | value |= ((insn >> 0) & 0x000f) << 21; | |
667 | ||
668 | /* Extend the sign. */ | |
669 | int signbit = 1 << (25 - 1); | |
670 | value = (value ^ signbit) - signbit; | |
671 | ||
672 | return value; | |
673 | } | |
674 | #endif /* EXTRACT_SIMM25_A32_5 */ | |
675 | ||
676 | #ifndef INSERT_SIMM13_A32_5_S | |
677 | #define INSERT_SIMM13_A32_5_S | |
678 | /* mask = 0000011111111111 | |
679 | insn = 11111sssssssssss. */ | |
bdfe53e3 AB |
680 | static unsigned long long |
681 | insert_simm13_a32_5_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
682 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
683 | const char **errmsg ATTRIBUTE_UNUSED) |
684 | { | |
685 | if (value & 0x03) | |
686 | *errmsg = _("Target address is not 32bit aligned."); | |
687 | ||
688 | insn |= ((value >> 2) & 0x07ff) << 0; | |
689 | ||
690 | return insn; | |
691 | } | |
692 | #endif /* INSERT_SIMM13_A32_5_S */ | |
693 | ||
694 | #ifndef EXTRACT_SIMM13_A32_5_S | |
695 | #define EXTRACT_SIMM13_A32_5_S | |
696 | /* mask = 0000011111111111. */ | |
bdfe53e3 AB |
697 | static long long int |
698 | extract_simm13_a32_5_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
699 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
700 | { | |
701 | int value = 0; | |
702 | ||
703 | value |= ((insn >> 0) & 0x07ff) << 2; | |
704 | ||
705 | /* Extend the sign. */ | |
706 | int signbit = 1 << (13 - 1); | |
707 | value = (value ^ signbit) - signbit; | |
708 | ||
709 | return value; | |
710 | } | |
711 | #endif /* EXTRACT_SIMM13_A32_5_S */ | |
712 | ||
713 | #ifndef INSERT_SIMM8_A16_9_S | |
714 | #define INSERT_SIMM8_A16_9_S | |
715 | /* mask = 0000000001111111 | |
716 | insn = 11101bbb1sssssss. */ | |
bdfe53e3 AB |
717 | static unsigned long long |
718 | insert_simm8_a16_9_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
719 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
720 | const char **errmsg ATTRIBUTE_UNUSED) |
721 | { | |
722 | if (value & 0x01) | |
723 | *errmsg = _("Target address is not 16bit aligned."); | |
724 | ||
725 | insn |= ((value >> 1) & 0x007f) << 0; | |
726 | ||
727 | return insn; | |
728 | } | |
729 | #endif /* INSERT_SIMM8_A16_9_S */ | |
730 | ||
731 | #ifndef EXTRACT_SIMM8_A16_9_S | |
732 | #define EXTRACT_SIMM8_A16_9_S | |
733 | /* mask = 0000000001111111. */ | |
bdfe53e3 AB |
734 | static long long int |
735 | extract_simm8_a16_9_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
736 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
737 | { | |
738 | int value = 0; | |
739 | ||
740 | value |= ((insn >> 0) & 0x007f) << 1; | |
741 | ||
742 | /* Extend the sign. */ | |
743 | int signbit = 1 << (8 - 1); | |
744 | value = (value ^ signbit) - signbit; | |
745 | ||
746 | return value; | |
747 | } | |
748 | #endif /* EXTRACT_SIMM8_A16_9_S */ | |
749 | ||
750 | #ifndef INSERT_UIMM3_23 | |
751 | #define INSERT_UIMM3_23 | |
752 | /* mask = 00000000000000000000000111000000 | |
753 | insn = 00100011011011110001RRRuuu111111. */ | |
bdfe53e3 AB |
754 | static unsigned long long |
755 | insert_uimm3_23 (unsigned long long insn ATTRIBUTE_UNUSED, | |
756 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
757 | const char **errmsg ATTRIBUTE_UNUSED) |
758 | { | |
759 | ||
760 | insn |= ((value >> 0) & 0x0007) << 6; | |
761 | ||
762 | return insn; | |
763 | } | |
764 | #endif /* INSERT_UIMM3_23 */ | |
765 | ||
766 | #ifndef EXTRACT_UIMM3_23 | |
767 | #define EXTRACT_UIMM3_23 | |
768 | /* mask = 00000000000000000000000111000000. */ | |
bdfe53e3 AB |
769 | static long long int |
770 | extract_uimm3_23 (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
771 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
772 | { | |
773 | unsigned value = 0; | |
774 | ||
775 | value |= ((insn >> 6) & 0x0007) << 0; | |
776 | ||
777 | return value; | |
778 | } | |
779 | #endif /* EXTRACT_UIMM3_23 */ | |
780 | ||
781 | #ifndef INSERT_UIMM10_6_S | |
782 | #define INSERT_UIMM10_6_S | |
783 | /* mask = 0000001111111111 | |
784 | insn = 010111uuuuuuuuuu. */ | |
bdfe53e3 AB |
785 | static unsigned long long |
786 | insert_uimm10_6_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
787 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
788 | const char **errmsg ATTRIBUTE_UNUSED) |
789 | { | |
790 | ||
791 | insn |= ((value >> 0) & 0x03ff) << 0; | |
792 | ||
793 | return insn; | |
794 | } | |
795 | #endif /* INSERT_UIMM10_6_S */ | |
796 | ||
797 | #ifndef EXTRACT_UIMM10_6_S | |
798 | #define EXTRACT_UIMM10_6_S | |
799 | /* mask = 0000001111111111. */ | |
bdfe53e3 AB |
800 | static long long int |
801 | extract_uimm10_6_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
802 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
803 | { | |
804 | unsigned value = 0; | |
805 | ||
806 | value |= ((insn >> 0) & 0x03ff) << 0; | |
807 | ||
808 | return value; | |
809 | } | |
810 | #endif /* EXTRACT_UIMM10_6_S */ | |
811 | ||
812 | #ifndef INSERT_UIMM6_11_S | |
813 | #define INSERT_UIMM6_11_S | |
814 | /* mask = 0000002200011110 | |
815 | insn = 110000UU111uuuu0. */ | |
bdfe53e3 AB |
816 | static unsigned long long |
817 | insert_uimm6_11_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
818 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
819 | const char **errmsg ATTRIBUTE_UNUSED) |
820 | { | |
821 | ||
822 | insn |= ((value >> 0) & 0x000f) << 1; | |
823 | insn |= ((value >> 4) & 0x0003) << 8; | |
824 | ||
825 | return insn; | |
826 | } | |
827 | #endif /* INSERT_UIMM6_11_S */ | |
828 | ||
829 | #ifndef EXTRACT_UIMM6_11_S | |
830 | #define EXTRACT_UIMM6_11_S | |
831 | /* mask = 0000002200011110. */ | |
bdfe53e3 AB |
832 | static long long int |
833 | extract_uimm6_11_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
834 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
835 | { | |
836 | unsigned value = 0; | |
837 | ||
838 | value |= ((insn >> 1) & 0x000f) << 0; | |
839 | value |= ((insn >> 8) & 0x0003) << 4; | |
840 | ||
841 | return value; | |
842 | } | |
843 | #endif /* EXTRACT_UIMM6_11_S */ | |
844 | ||
845 | #ifndef INSERT_SIMM9_8 | |
846 | #define INSERT_SIMM9_8 | |
847 | /* mask = 00000000111111112000000000000000 | |
848 | insn = 00010bbbssssssssSBBBDaaZZXAAAAAA. */ | |
bdfe53e3 AB |
849 | static unsigned long long |
850 | insert_simm9_8 (unsigned long long insn ATTRIBUTE_UNUSED, | |
851 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
852 | const char **errmsg ATTRIBUTE_UNUSED) |
853 | { | |
854 | ||
855 | insn |= ((value >> 0) & 0x00ff) << 16; | |
856 | insn |= ((value >> 8) & 0x0001) << 15; | |
857 | ||
858 | return insn; | |
859 | } | |
860 | #endif /* INSERT_SIMM9_8 */ | |
861 | ||
862 | #ifndef EXTRACT_SIMM9_8 | |
863 | #define EXTRACT_SIMM9_8 | |
864 | /* mask = 00000000111111112000000000000000. */ | |
bdfe53e3 AB |
865 | static long long int |
866 | extract_simm9_8 (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
867 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
868 | { | |
869 | int value = 0; | |
870 | ||
871 | value |= ((insn >> 16) & 0x00ff) << 0; | |
872 | value |= ((insn >> 15) & 0x0001) << 8; | |
873 | ||
874 | /* Extend the sign. */ | |
875 | int signbit = 1 << (9 - 1); | |
876 | value = (value ^ signbit) - signbit; | |
877 | ||
878 | return value; | |
879 | } | |
880 | #endif /* EXTRACT_SIMM9_8 */ | |
881 | ||
882 | #ifndef INSERT_UIMM10_A32_8_S | |
883 | #define INSERT_UIMM10_A32_8_S | |
884 | /* mask = 0000000011111111 | |
885 | insn = 11010bbbuuuuuuuu. */ | |
bdfe53e3 AB |
886 | static unsigned long long |
887 | insert_uimm10_a32_8_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
888 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
889 | const char **errmsg ATTRIBUTE_UNUSED) |
890 | { | |
891 | if (value & 0x03) | |
892 | *errmsg = _("Target address is not 32bit aligned."); | |
893 | ||
894 | insn |= ((value >> 2) & 0x00ff) << 0; | |
895 | ||
896 | return insn; | |
897 | } | |
898 | #endif /* INSERT_UIMM10_A32_8_S */ | |
899 | ||
900 | #ifndef EXTRACT_UIMM10_A32_8_S | |
901 | #define EXTRACT_UIMM10_A32_8_S | |
902 | /* mask = 0000000011111111. */ | |
bdfe53e3 AB |
903 | static long long int |
904 | extract_uimm10_a32_8_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
905 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
906 | { | |
907 | unsigned value = 0; | |
908 | ||
909 | value |= ((insn >> 0) & 0x00ff) << 2; | |
910 | ||
911 | return value; | |
912 | } | |
913 | #endif /* EXTRACT_UIMM10_A32_8_S */ | |
914 | ||
915 | #ifndef INSERT_SIMM9_7_S | |
916 | #define INSERT_SIMM9_7_S | |
917 | /* mask = 0000000111111111 | |
918 | insn = 1100101sssssssss. */ | |
bdfe53e3 AB |
919 | static unsigned long long |
920 | insert_simm9_7_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
921 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
922 | const char **errmsg ATTRIBUTE_UNUSED) |
923 | { | |
924 | ||
925 | insn |= ((value >> 0) & 0x01ff) << 0; | |
926 | ||
927 | return insn; | |
928 | } | |
929 | #endif /* INSERT_SIMM9_7_S */ | |
930 | ||
931 | #ifndef EXTRACT_SIMM9_7_S | |
932 | #define EXTRACT_SIMM9_7_S | |
933 | /* mask = 0000000111111111. */ | |
bdfe53e3 AB |
934 | static long long int |
935 | extract_simm9_7_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
936 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
937 | { | |
938 | int value = 0; | |
939 | ||
940 | value |= ((insn >> 0) & 0x01ff) << 0; | |
941 | ||
942 | /* Extend the sign. */ | |
943 | int signbit = 1 << (9 - 1); | |
944 | value = (value ^ signbit) - signbit; | |
945 | ||
946 | return value; | |
947 | } | |
948 | #endif /* EXTRACT_SIMM9_7_S */ | |
949 | ||
950 | #ifndef INSERT_UIMM6_A16_11_S | |
951 | #define INSERT_UIMM6_A16_11_S | |
952 | /* mask = 0000000000011111 | |
953 | insn = 10010bbbcccuuuuu. */ | |
bdfe53e3 AB |
954 | static unsigned long long |
955 | insert_uimm6_a16_11_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
956 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
957 | const char **errmsg ATTRIBUTE_UNUSED) |
958 | { | |
959 | if (value & 0x01) | |
960 | *errmsg = _("Target address is not 16bit aligned."); | |
961 | ||
962 | insn |= ((value >> 1) & 0x001f) << 0; | |
963 | ||
964 | return insn; | |
965 | } | |
966 | #endif /* INSERT_UIMM6_A16_11_S */ | |
967 | ||
968 | #ifndef EXTRACT_UIMM6_A16_11_S | |
969 | #define EXTRACT_UIMM6_A16_11_S | |
970 | /* mask = 0000000000011111. */ | |
bdfe53e3 AB |
971 | static long long int |
972 | extract_uimm6_a16_11_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
973 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
974 | { | |
975 | unsigned value = 0; | |
976 | ||
977 | value |= ((insn >> 0) & 0x001f) << 1; | |
978 | ||
979 | return value; | |
980 | } | |
981 | #endif /* EXTRACT_UIMM6_A16_11_S */ | |
982 | ||
983 | #ifndef INSERT_UIMM5_A32_11_S | |
984 | #define INSERT_UIMM5_A32_11_S | |
985 | /* mask = 0000020000011000 | |
986 | insn = 01000U00hhhuu1HH. */ | |
bdfe53e3 AB |
987 | static unsigned long long |
988 | insert_uimm5_a32_11_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
989 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
990 | const char **errmsg ATTRIBUTE_UNUSED) |
991 | { | |
992 | if (value & 0x03) | |
993 | *errmsg = _("Target address is not 32bit aligned."); | |
994 | ||
995 | insn |= ((value >> 2) & 0x0003) << 3; | |
996 | insn |= ((value >> 4) & 0x0001) << 10; | |
997 | ||
998 | return insn; | |
999 | } | |
1000 | #endif /* INSERT_UIMM5_A32_11_S */ | |
1001 | ||
1002 | #ifndef EXTRACT_UIMM5_A32_11_S | |
1003 | #define EXTRACT_UIMM5_A32_11_S | |
1004 | /* mask = 0000020000011000. */ | |
bdfe53e3 AB |
1005 | static long long int |
1006 | extract_uimm5_a32_11_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
1007 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
1008 | { | |
1009 | unsigned value = 0; | |
1010 | ||
1011 | value |= ((insn >> 3) & 0x0003) << 2; | |
1012 | value |= ((insn >> 10) & 0x0001) << 4; | |
1013 | ||
1014 | return value; | |
1015 | } | |
1016 | #endif /* EXTRACT_UIMM5_A32_11_S */ | |
1017 | ||
1018 | #ifndef INSERT_SIMM11_A32_13_S | |
1019 | #define INSERT_SIMM11_A32_13_S | |
1020 | /* mask = 0000022222200111 | |
1021 | insn = 01010SSSSSS00sss. */ | |
bdfe53e3 AB |
1022 | static unsigned long long |
1023 | insert_simm11_a32_13_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
1024 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
1025 | const char **errmsg ATTRIBUTE_UNUSED) |
1026 | { | |
1027 | if (value & 0x03) | |
1028 | *errmsg = _("Target address is not 32bit aligned."); | |
1029 | ||
1030 | insn |= ((value >> 2) & 0x0007) << 0; | |
1031 | insn |= ((value >> 5) & 0x003f) << 5; | |
1032 | ||
1033 | return insn; | |
1034 | } | |
1035 | #endif /* INSERT_SIMM11_A32_13_S */ | |
1036 | ||
1037 | #ifndef EXTRACT_SIMM11_A32_13_S | |
1038 | #define EXTRACT_SIMM11_A32_13_S | |
1039 | /* mask = 0000022222200111. */ | |
bdfe53e3 AB |
1040 | static long long int |
1041 | extract_simm11_a32_13_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
1042 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
1043 | { | |
1044 | int value = 0; | |
1045 | ||
1046 | value |= ((insn >> 0) & 0x0007) << 2; | |
1047 | value |= ((insn >> 5) & 0x003f) << 5; | |
1048 | ||
1049 | /* Extend the sign. */ | |
1050 | int signbit = 1 << (11 - 1); | |
1051 | value = (value ^ signbit) - signbit; | |
1052 | ||
1053 | return value; | |
1054 | } | |
1055 | #endif /* EXTRACT_SIMM11_A32_13_S */ | |
1056 | ||
1057 | #ifndef INSERT_UIMM7_13_S | |
1058 | #define INSERT_UIMM7_13_S | |
1059 | /* mask = 0000000022220111 | |
1060 | insn = 01010bbbUUUU1uuu. */ | |
bdfe53e3 AB |
1061 | static unsigned long long |
1062 | insert_uimm7_13_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
1063 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
1064 | const char **errmsg ATTRIBUTE_UNUSED) |
1065 | { | |
1066 | ||
1067 | insn |= ((value >> 0) & 0x0007) << 0; | |
1068 | insn |= ((value >> 3) & 0x000f) << 4; | |
1069 | ||
1070 | return insn; | |
1071 | } | |
1072 | #endif /* INSERT_UIMM7_13_S */ | |
1073 | ||
1074 | #ifndef EXTRACT_UIMM7_13_S | |
1075 | #define EXTRACT_UIMM7_13_S | |
1076 | /* mask = 0000000022220111. */ | |
bdfe53e3 AB |
1077 | static long long int |
1078 | extract_uimm7_13_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
1079 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
1080 | { | |
1081 | unsigned value = 0; | |
1082 | ||
1083 | value |= ((insn >> 0) & 0x0007) << 0; | |
1084 | value |= ((insn >> 4) & 0x000f) << 3; | |
1085 | ||
1086 | return value; | |
1087 | } | |
1088 | #endif /* EXTRACT_UIMM7_13_S */ | |
1089 | ||
1090 | #ifndef INSERT_UIMM6_A16_21 | |
1091 | #define INSERT_UIMM6_A16_21 | |
1092 | /* mask = 00000000000000000000011111000000 | |
1093 | insn = 00101bbb01001100RBBBRuuuuuAAAAAA. */ | |
bdfe53e3 AB |
1094 | static unsigned long long |
1095 | insert_uimm6_a16_21 (unsigned long long insn ATTRIBUTE_UNUSED, | |
1096 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
1097 | const char **errmsg ATTRIBUTE_UNUSED) |
1098 | { | |
1099 | if (value & 0x01) | |
1100 | *errmsg = _("Target address is not 16bit aligned."); | |
1101 | ||
1102 | insn |= ((value >> 1) & 0x001f) << 6; | |
1103 | ||
1104 | return insn; | |
1105 | } | |
1106 | #endif /* INSERT_UIMM6_A16_21 */ | |
1107 | ||
1108 | #ifndef EXTRACT_UIMM6_A16_21 | |
1109 | #define EXTRACT_UIMM6_A16_21 | |
1110 | /* mask = 00000000000000000000011111000000. */ | |
bdfe53e3 AB |
1111 | static long long int |
1112 | extract_uimm6_a16_21 (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
1113 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
1114 | { | |
1115 | unsigned value = 0; | |
1116 | ||
1117 | value |= ((insn >> 6) & 0x001f) << 1; | |
1118 | ||
1119 | return value; | |
1120 | } | |
1121 | #endif /* EXTRACT_UIMM6_A16_21 */ | |
1122 | ||
1123 | #ifndef INSERT_UIMM7_11_S | |
1124 | #define INSERT_UIMM7_11_S | |
1125 | /* mask = 0000022200011110 | |
1126 | insn = 11000UUU110uuuu0. */ | |
bdfe53e3 AB |
1127 | static unsigned long long |
1128 | insert_uimm7_11_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
1129 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
1130 | const char **errmsg ATTRIBUTE_UNUSED) |
1131 | { | |
1132 | ||
1133 | insn |= ((value >> 0) & 0x000f) << 1; | |
1134 | insn |= ((value >> 4) & 0x0007) << 8; | |
1135 | ||
1136 | return insn; | |
1137 | } | |
1138 | #endif /* INSERT_UIMM7_11_S */ | |
1139 | ||
1140 | #ifndef EXTRACT_UIMM7_11_S | |
1141 | #define EXTRACT_UIMM7_11_S | |
1142 | /* mask = 0000022200011110. */ | |
bdfe53e3 AB |
1143 | static long long int |
1144 | extract_uimm7_11_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
1145 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
1146 | { | |
1147 | unsigned value = 0; | |
1148 | ||
1149 | value |= ((insn >> 1) & 0x000f) << 0; | |
1150 | value |= ((insn >> 8) & 0x0007) << 4; | |
1151 | ||
1152 | return value; | |
1153 | } | |
1154 | #endif /* EXTRACT_UIMM7_11_S */ | |
1155 | ||
1156 | #ifndef INSERT_UIMM7_A16_20 | |
1157 | #define INSERT_UIMM7_A16_20 | |
1158 | /* mask = 00000000000000000000111111000000 | |
1159 | insn = 00100RRR111010000RRRuuuuuu1QQQQQ. */ | |
bdfe53e3 AB |
1160 | static unsigned long long |
1161 | insert_uimm7_a16_20 (unsigned long long insn ATTRIBUTE_UNUSED, | |
1162 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
1163 | const char **errmsg ATTRIBUTE_UNUSED) |
1164 | { | |
1165 | if (value & 0x01) | |
1166 | *errmsg = _("Target address is not 16bit aligned."); | |
1167 | ||
1168 | insn |= ((value >> 1) & 0x003f) << 6; | |
1169 | ||
1170 | return insn; | |
1171 | } | |
1172 | #endif /* INSERT_UIMM7_A16_20 */ | |
1173 | ||
1174 | #ifndef EXTRACT_UIMM7_A16_20 | |
1175 | #define EXTRACT_UIMM7_A16_20 | |
1176 | /* mask = 00000000000000000000111111000000. */ | |
bdfe53e3 AB |
1177 | static long long int |
1178 | extract_uimm7_a16_20 (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
1179 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
1180 | { | |
1181 | unsigned value = 0; | |
1182 | ||
1183 | value |= ((insn >> 6) & 0x003f) << 1; | |
1184 | ||
1185 | return value; | |
1186 | } | |
1187 | #endif /* EXTRACT_UIMM7_A16_20 */ | |
1188 | ||
1189 | #ifndef INSERT_SIMM13_A16_20 | |
1190 | #define INSERT_SIMM13_A16_20 | |
1191 | /* mask = 00000000000000000000111111222222 | |
1192 | insn = 00100RRR101010000RRRssssssSSSSSS. */ | |
bdfe53e3 AB |
1193 | static unsigned long long |
1194 | insert_simm13_a16_20 (unsigned long long insn ATTRIBUTE_UNUSED, | |
1195 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
1196 | const char **errmsg ATTRIBUTE_UNUSED) |
1197 | { | |
1198 | if (value & 0x01) | |
1199 | *errmsg = _("Target address is not 16bit aligned."); | |
1200 | ||
1201 | insn |= ((value >> 1) & 0x003f) << 6; | |
1202 | insn |= ((value >> 7) & 0x003f) << 0; | |
1203 | ||
1204 | return insn; | |
1205 | } | |
1206 | #endif /* INSERT_SIMM13_A16_20 */ | |
1207 | ||
1208 | #ifndef EXTRACT_SIMM13_A16_20 | |
1209 | #define EXTRACT_SIMM13_A16_20 | |
1210 | /* mask = 00000000000000000000111111222222. */ | |
bdfe53e3 AB |
1211 | static long long int |
1212 | extract_simm13_a16_20 (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
1213 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
1214 | { | |
1215 | int value = 0; | |
1216 | ||
1217 | value |= ((insn >> 6) & 0x003f) << 1; | |
1218 | value |= ((insn >> 0) & 0x003f) << 7; | |
1219 | ||
1220 | /* Extend the sign. */ | |
1221 | int signbit = 1 << (13 - 1); | |
1222 | value = (value ^ signbit) - signbit; | |
1223 | ||
1224 | return value; | |
1225 | } | |
1226 | #endif /* EXTRACT_SIMM13_A16_20 */ | |
1227 | ||
1228 | #ifndef INSERT_UIMM8_8_S | |
1229 | #define INSERT_UIMM8_8_S | |
1230 | /* mask = 0000000011111111 | |
1231 | insn = 11011bbbuuuuuuuu. */ | |
bdfe53e3 AB |
1232 | static unsigned long long |
1233 | insert_uimm8_8_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
1234 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
1235 | const char **errmsg ATTRIBUTE_UNUSED) |
1236 | { | |
1237 | ||
1238 | insn |= ((value >> 0) & 0x00ff) << 0; | |
1239 | ||
1240 | return insn; | |
1241 | } | |
1242 | #endif /* INSERT_UIMM8_8_S */ | |
1243 | ||
1244 | #ifndef EXTRACT_UIMM8_8_S | |
1245 | #define EXTRACT_UIMM8_8_S | |
1246 | /* mask = 0000000011111111. */ | |
bdfe53e3 AB |
1247 | static long long int |
1248 | extract_uimm8_8_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
1249 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
1250 | { | |
1251 | unsigned value = 0; | |
1252 | ||
1253 | value |= ((insn >> 0) & 0x00ff) << 0; | |
1254 | ||
1255 | return value; | |
1256 | } | |
1257 | #endif /* EXTRACT_UIMM8_8_S */ | |
1258 | ||
1259 | #ifndef INSERT_UIMM6_5_S | |
1260 | #define INSERT_UIMM6_5_S | |
1261 | /* mask = 0000011111100000 | |
1262 | insn = 01111uuuuuu11111. */ | |
bdfe53e3 AB |
1263 | static unsigned long long |
1264 | insert_uimm6_5_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
1265 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
1266 | const char **errmsg ATTRIBUTE_UNUSED) |
1267 | { | |
1268 | ||
1269 | insn |= ((value >> 0) & 0x003f) << 5; | |
1270 | ||
1271 | return insn; | |
1272 | } | |
1273 | #endif /* INSERT_UIMM6_5_S */ | |
1274 | ||
1275 | #ifndef EXTRACT_UIMM6_5_S | |
1276 | #define EXTRACT_UIMM6_5_S | |
1277 | /* mask = 0000011111100000. */ | |
bdfe53e3 AB |
1278 | static long long int |
1279 | extract_uimm6_5_s (unsigned long long insn ATTRIBUTE_UNUSED, | |
886a2506 NC |
1280 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
1281 | { | |
1282 | unsigned value = 0; | |
1283 | ||
1284 | value |= ((insn >> 5) & 0x003f) << 0; | |
1285 | ||
1286 | return value; | |
1287 | } | |
1288 | #endif /* EXTRACT_UIMM6_5_S */ | |
1289 | ||
1290 | #ifndef INSERT_UIMM6_AXX_ | |
1291 | #define INSERT_UIMM6_AXX_ | |
1292 | /* mask = 00000000000000000000000000000000 | |
1293 | insn = 00110bbb11100001100001100001QQQQ. */ | |
1294 | static ATTRIBUTE_UNUSED unsigned | |
bdfe53e3 AB |
1295 | insert_uimm6_axx_ (unsigned long long insn ATTRIBUTE_UNUSED, |
1296 | long long int value ATTRIBUTE_UNUSED, | |
886a2506 NC |
1297 | const char **errmsg ATTRIBUTE_UNUSED) |
1298 | { | |
1299 | if (value & 0x3f) | |
1300 | *errmsg = _("Target address is not 512bit aligned."); | |
1301 | ||
1302 | return insn; | |
1303 | } | |
1304 | #endif /* INSERT_UIMM6_AXX_ */ | |
1305 | ||
1306 | #ifndef EXTRACT_UIMM6_AXX_ | |
1307 | #define EXTRACT_UIMM6_AXX_ | |
1308 | /* mask = 00000000000000000000000000000000. */ | |
1309 | static ATTRIBUTE_UNUSED int | |
bdfe53e3 | 1310 | extract_uimm6_axx_ (unsigned long long insn ATTRIBUTE_UNUSED, |
886a2506 NC |
1311 | bfd_boolean * invalid ATTRIBUTE_UNUSED) |
1312 | { | |
1313 | unsigned value = 0; | |
1314 | ||
1315 | return value; | |
1316 | } | |
1317 | #endif /* EXTRACT_UIMM6_AXX_ */ |