Automatic date update in version.in
[binutils-gdb.git] / opcodes / arc-fxi.h
blobbb61b9bd0e120a7d02baf6773074d94a63ade7b8
1 /* Insert/extract functions for the ARC opcodes.
2 Copyright (C) 2015-2024 Free Software Foundation, Inc.
4 Contributed by Claudiu Zissulescu (claziss@synopsys.com)
6 This file is part of libopcodes.
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.
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.
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. */
22 #ifndef INSERT_LIMM
23 #define INSERT_LIMM
24 /* mask = 00000000000000000000000000000000
25 insn = 00100bbb00101111FBBB111110001001. */
26 static unsigned long long
27 insert_limm (unsigned long long insn ATTRIBUTE_UNUSED,
28 long long int value ATTRIBUTE_UNUSED,
29 const char **errmsg ATTRIBUTE_UNUSED)
32 return insn;
34 #endif /* INSERT_LIMM */
36 #ifndef EXTRACT_LIMM
37 #define EXTRACT_LIMM
38 /* mask = 00000000000000000000000000000000. */
39 static ATTRIBUTE_UNUSED int
40 extract_limm (unsigned long long insn ATTRIBUTE_UNUSED,
41 bool *invalid ATTRIBUTE_UNUSED)
43 unsigned value = 0;
45 return value;
47 #endif /* EXTRACT_LIMM */
49 #ifndef INSERT_UIMM6_20
50 #define INSERT_UIMM6_20
51 /* mask = 00000000000000000000111111000000
52 insn = 00100bbb01101111FBBBuuuuuu001001. */
53 static unsigned long long
54 insert_uimm6_20 (unsigned long long insn ATTRIBUTE_UNUSED,
55 long long int value ATTRIBUTE_UNUSED,
56 const char **errmsg ATTRIBUTE_UNUSED)
59 insn |= ((value >> 0) & 0x003f) << 6;
61 return insn;
63 #endif /* INSERT_UIMM6_20 */
65 #ifndef EXTRACT_UIMM6_20
66 #define EXTRACT_UIMM6_20
67 /* mask = 00000000000000000000111111000000. */
68 static long long int
69 extract_uimm6_20 (unsigned long long insn ATTRIBUTE_UNUSED,
70 bool *invalid ATTRIBUTE_UNUSED)
72 unsigned value = 0;
74 value |= ((insn >> 6) & 0x003f) << 0;
76 return value;
78 #endif /* EXTRACT_UIMM6_20 */
80 #ifndef INSERT_SIMM12_20
81 #define INSERT_SIMM12_20
82 /* mask = 00000000000000000000111111222222
83 insn = 00110bbb10101000FBBBssssssSSSSSS. */
84 static unsigned long long
85 insert_simm12_20 (unsigned long long insn ATTRIBUTE_UNUSED,
86 long long int value ATTRIBUTE_UNUSED,
87 const char **errmsg ATTRIBUTE_UNUSED)
90 insn |= ((value >> 0) & 0x003f) << 6;
91 insn |= ((value >> 6) & 0x003f) << 0;
93 return insn;
95 #endif /* INSERT_SIMM12_20 */
97 #ifndef EXTRACT_SIMM12_20
98 #define EXTRACT_SIMM12_20
99 /* mask = 00000000000000000000111111222222. */
100 static long long int
101 extract_simm12_20 (unsigned long long insn ATTRIBUTE_UNUSED,
102 bool *invalid ATTRIBUTE_UNUSED)
104 int value = 0;
106 value |= ((insn >> 6) & 0x003f) << 0;
107 value |= ((insn >> 0) & 0x003f) << 6;
109 /* Extend the sign. */
110 int signbit = 1 << (12 - 1);
111 value = (value ^ signbit) - signbit;
113 return value;
115 #endif /* EXTRACT_SIMM12_20 */
117 #ifndef INSERT_SIMM3_5_S
118 #define INSERT_SIMM3_5_S
119 /* mask = 0000011100000000
120 insn = 01110ssshhh001HH. */
121 static ATTRIBUTE_UNUSED unsigned
122 insert_simm3_5_s (unsigned long long insn ATTRIBUTE_UNUSED,
123 long long int value ATTRIBUTE_UNUSED,
124 const char **errmsg ATTRIBUTE_UNUSED)
127 insn |= ((value >> 0) & 0x0007) << 8;
129 return insn;
131 #endif /* INSERT_SIMM3_5_S */
133 #ifndef EXTRACT_SIMM3_5_S
134 #define EXTRACT_SIMM3_5_S
135 /* mask = 0000011100000000. */
136 static ATTRIBUTE_UNUSED int
137 extract_simm3_5_s (unsigned long long insn ATTRIBUTE_UNUSED,
138 bool *invalid ATTRIBUTE_UNUSED)
140 int value = 0;
142 value |= ((insn >> 8) & 0x0007) << 0;
144 /* Extend the sign. */
145 int signbit = 1 << (3 - 1);
146 value = (value ^ signbit) - signbit;
148 return value;
150 #endif /* EXTRACT_SIMM3_5_S */
152 #ifndef INSERT_LIMM_S
153 #define INSERT_LIMM_S
154 /* mask = 0000000000000000
155 insn = 01110sss11000111. */
156 static ATTRIBUTE_UNUSED unsigned
157 insert_limm_s (unsigned long long insn ATTRIBUTE_UNUSED,
158 long long int value ATTRIBUTE_UNUSED,
159 const char **errmsg ATTRIBUTE_UNUSED)
162 return insn;
164 #endif /* INSERT_LIMM_S */
166 #ifndef EXTRACT_LIMM_S
167 #define EXTRACT_LIMM_S
168 /* mask = 0000000000000000. */
169 static ATTRIBUTE_UNUSED int
170 extract_limm_s (unsigned long long insn ATTRIBUTE_UNUSED,
171 bool *invalid ATTRIBUTE_UNUSED)
173 unsigned value = 0;
175 return value;
177 #endif /* EXTRACT_LIMM_S */
179 #ifndef INSERT_UIMM7_A32_11_S
180 #define INSERT_UIMM7_A32_11_S
181 /* mask = 0000000000011111
182 insn = 11000bbb100uuuuu. */
183 static unsigned long long
184 insert_uimm7_a32_11_s (unsigned long long insn ATTRIBUTE_UNUSED,
185 long long int value ATTRIBUTE_UNUSED,
186 const char **errmsg ATTRIBUTE_UNUSED)
188 if (value & 0x03)
189 *errmsg = _("Target address is not 32bit aligned.");
191 insn |= ((value >> 2) & 0x001f) << 0;
193 return insn;
195 #endif /* INSERT_UIMM7_A32_11_S */
197 #ifndef EXTRACT_UIMM7_A32_11_S
198 #define EXTRACT_UIMM7_A32_11_S
199 /* mask = 0000000000011111. */
200 static long long int
201 extract_uimm7_a32_11_s (unsigned long long insn ATTRIBUTE_UNUSED,
202 bool *invalid ATTRIBUTE_UNUSED)
204 unsigned value = 0;
206 value |= ((insn >> 0) & 0x001f) << 2;
208 return value;
210 #endif /* EXTRACT_UIMM7_A32_11_S */
212 #ifndef INSERT_UIMM7_9_S
213 #define INSERT_UIMM7_9_S
214 /* mask = 0000000001111111
215 insn = 11100bbb0uuuuuuu. */
216 static unsigned long long
217 insert_uimm7_9_s (unsigned long long insn ATTRIBUTE_UNUSED,
218 long long int value ATTRIBUTE_UNUSED,
219 const char **errmsg ATTRIBUTE_UNUSED)
222 insn |= ((value >> 0) & 0x007f) << 0;
224 return insn;
226 #endif /* INSERT_UIMM7_9_S */
228 #ifndef EXTRACT_UIMM7_9_S
229 #define EXTRACT_UIMM7_9_S
230 /* mask = 0000000001111111. */
231 static long long int
232 extract_uimm7_9_s (unsigned long long insn ATTRIBUTE_UNUSED,
233 bool *invalid ATTRIBUTE_UNUSED)
235 unsigned value = 0;
237 value |= ((insn >> 0) & 0x007f) << 0;
239 return value;
241 #endif /* EXTRACT_UIMM7_9_S */
243 #ifndef INSERT_UIMM3_13_S
244 #define INSERT_UIMM3_13_S
245 /* mask = 0000000000000111
246 insn = 01101bbbccc00uuu. */
247 static unsigned long long
248 insert_uimm3_13_s (unsigned long long insn ATTRIBUTE_UNUSED,
249 long long int value ATTRIBUTE_UNUSED,
250 const char **errmsg ATTRIBUTE_UNUSED)
253 insn |= ((value >> 0) & 0x0007) << 0;
255 return insn;
257 #endif /* INSERT_UIMM3_13_S */
259 #ifndef EXTRACT_UIMM3_13_S
260 #define EXTRACT_UIMM3_13_S
261 /* mask = 0000000000000111. */
262 static long long int
263 extract_uimm3_13_s (unsigned long long insn ATTRIBUTE_UNUSED,
264 bool *invalid ATTRIBUTE_UNUSED)
266 unsigned value = 0;
268 value |= ((insn >> 0) & 0x0007) << 0;
270 return value;
272 #endif /* EXTRACT_UIMM3_13_S */
274 #ifndef INSERT_SIMM11_A32_7_S
275 #define INSERT_SIMM11_A32_7_S
276 /* mask = 0000000111111111
277 insn = 1100111sssssssss. */
278 static unsigned long long
279 insert_simm11_a32_7_s (unsigned long long insn ATTRIBUTE_UNUSED,
280 long long int value ATTRIBUTE_UNUSED,
281 const char **errmsg ATTRIBUTE_UNUSED)
283 if (value & 0x03)
284 *errmsg = _("Target address is not 32bit aligned.");
286 insn |= ((value >> 2) & 0x01ff) << 0;
288 return insn;
290 #endif /* INSERT_SIMM11_A32_7_S */
292 #ifndef EXTRACT_SIMM11_A32_7_S
293 #define EXTRACT_SIMM11_A32_7_S
294 /* mask = 0000000111111111. */
295 static long long int
296 extract_simm11_a32_7_s (unsigned long long insn ATTRIBUTE_UNUSED,
297 bool *invalid ATTRIBUTE_UNUSED)
299 int value = 0;
301 value |= ((insn >> 0) & 0x01ff) << 2;
303 /* Extend the sign. */
304 int signbit = 1 << (11 - 1);
305 value = (value ^ signbit) - signbit;
307 return value;
309 #endif /* EXTRACT_SIMM11_A32_7_S */
311 #ifndef INSERT_UIMM6_13_S
312 #define INSERT_UIMM6_13_S
313 /* mask = 0000000002220111
314 insn = 01001bbb0UUU1uuu. */
315 static unsigned long long
316 insert_uimm6_13_s (unsigned long long insn ATTRIBUTE_UNUSED,
317 long long int value ATTRIBUTE_UNUSED,
318 const char **errmsg ATTRIBUTE_UNUSED)
321 insn |= ((value >> 0) & 0x0007) << 0;
322 insn |= ((value >> 3) & 0x0007) << 4;
324 return insn;
326 #endif /* INSERT_UIMM6_13_S */
328 #ifndef EXTRACT_UIMM6_13_S
329 #define EXTRACT_UIMM6_13_S
330 /* mask = 0000000002220111. */
331 static long long int
332 extract_uimm6_13_s (unsigned long long insn ATTRIBUTE_UNUSED,
333 bool *invalid ATTRIBUTE_UNUSED)
335 unsigned value = 0;
337 value |= ((insn >> 0) & 0x0007) << 0;
338 value |= ((insn >> 4) & 0x0007) << 3;
340 return value;
342 #endif /* EXTRACT_UIMM6_13_S */
344 #ifndef INSERT_UIMM5_11_S
345 #define INSERT_UIMM5_11_S
346 /* mask = 0000000000011111
347 insn = 10111bbb000uuuuu. */
348 static unsigned long long
349 insert_uimm5_11_s (unsigned long long insn ATTRIBUTE_UNUSED,
350 long long int value ATTRIBUTE_UNUSED,
351 const char **errmsg ATTRIBUTE_UNUSED)
354 insn |= ((value >> 0) & 0x001f) << 0;
356 return insn;
358 #endif /* INSERT_UIMM5_11_S */
360 #ifndef EXTRACT_UIMM5_11_S
361 #define EXTRACT_UIMM5_11_S
362 /* mask = 0000000000011111. */
363 static long long int
364 extract_uimm5_11_s (unsigned long long insn ATTRIBUTE_UNUSED,
365 bool *invalid ATTRIBUTE_UNUSED)
367 unsigned value = 0;
369 value |= ((insn >> 0) & 0x001f) << 0;
371 return value;
373 #endif /* EXTRACT_UIMM5_11_S */
375 #ifndef INSERT_SIMM9_A16_8
376 #define INSERT_SIMM9_A16_8
377 /* mask = 00000000111111102000000000000000
378 insn = 00001bbbsssssss1SBBBCCCCCCN01110. */
379 static unsigned long long
380 insert_simm9_a16_8 (unsigned long long insn ATTRIBUTE_UNUSED,
381 long long int value ATTRIBUTE_UNUSED,
382 const char **errmsg ATTRIBUTE_UNUSED)
384 if (value & 0x01)
385 *errmsg = _("Target address is not 16bit aligned.");
387 insn |= ((value >> 1) & 0x007f) << 17;
388 insn |= ((value >> 8) & 0x0001) << 15;
390 return insn;
392 #endif /* INSERT_SIMM9_A16_8 */
394 #ifndef EXTRACT_SIMM9_A16_8
395 #define EXTRACT_SIMM9_A16_8
396 /* mask = 00000000111111102000000000000000. */
397 static long long int
398 extract_simm9_a16_8 (unsigned long long insn ATTRIBUTE_UNUSED,
399 bool *invalid ATTRIBUTE_UNUSED)
401 int value = 0;
403 value |= ((insn >> 17) & 0x007f) << 1;
404 value |= ((insn >> 15) & 0x0001) << 8;
406 /* Extend the sign. */
407 int signbit = 1 << (9 - 1);
408 value = (value ^ signbit) - signbit;
410 return value;
412 #endif /* EXTRACT_SIMM9_A16_8 */
414 #ifndef INSERT_UIMM6_8
415 #define INSERT_UIMM6_8
416 /* mask = 00000000000000000000111111000000
417 insn = 00001bbbsssssss1SBBBuuuuuuN11110. */
418 static unsigned long long
419 insert_uimm6_8 (unsigned long long insn ATTRIBUTE_UNUSED,
420 long long int value ATTRIBUTE_UNUSED,
421 const char **errmsg ATTRIBUTE_UNUSED)
424 insn |= ((value >> 0) & 0x003f) << 6;
426 return insn;
428 #endif /* INSERT_UIMM6_8 */
430 #ifndef EXTRACT_UIMM6_8
431 #define EXTRACT_UIMM6_8
432 /* mask = 00000000000000000000111111000000. */
433 static long long int
434 extract_uimm6_8 (unsigned long long insn ATTRIBUTE_UNUSED,
435 bool *invalid ATTRIBUTE_UNUSED)
437 unsigned value = 0;
439 value |= ((insn >> 6) & 0x003f) << 0;
441 return value;
443 #endif /* EXTRACT_UIMM6_8 */
445 #ifndef INSERT_SIMM21_A16_5
446 #define INSERT_SIMM21_A16_5
447 /* mask = 00000111111111102222222222000000
448 insn = 00000ssssssssss0SSSSSSSSSSNQQQQQ. */
449 static unsigned long long
450 insert_simm21_a16_5 (unsigned long long insn ATTRIBUTE_UNUSED,
451 long long int value ATTRIBUTE_UNUSED,
452 const char **errmsg ATTRIBUTE_UNUSED)
454 if (value & 0x01)
455 *errmsg = _("Target address is not 16bit aligned.");
457 insn |= ((value >> 1) & 0x03ff) << 17;
458 insn |= ((value >> 11) & 0x03ff) << 6;
460 return insn;
462 #endif /* INSERT_SIMM21_A16_5 */
464 #ifndef EXTRACT_SIMM21_A16_5
465 #define EXTRACT_SIMM21_A16_5
466 /* mask = 00000111111111102222222222000000. */
467 static long long int
468 extract_simm21_a16_5 (unsigned long long insn ATTRIBUTE_UNUSED,
469 bool *invalid ATTRIBUTE_UNUSED)
471 int value = 0;
473 value |= ((insn >> 17) & 0x03ff) << 1;
474 value |= ((insn >> 6) & 0x03ff) << 11;
476 /* Extend the sign. */
477 int signbit = 1 << (21 - 1);
478 value = (value ^ signbit) - signbit;
480 return value;
482 #endif /* EXTRACT_SIMM21_A16_5 */
484 #ifndef INSERT_SIMM25_A16_5
485 #define INSERT_SIMM25_A16_5
486 /* mask = 00000111111111102222222222003333
487 insn = 00000ssssssssss1SSSSSSSSSSNRtttt. */
488 static unsigned long long
489 insert_simm25_a16_5 (unsigned long long insn ATTRIBUTE_UNUSED,
490 long long int value ATTRIBUTE_UNUSED,
491 const char **errmsg ATTRIBUTE_UNUSED)
493 if (value & 0x01)
494 *errmsg = _("Target address is not 16bit aligned.");
496 insn |= ((value >> 1) & 0x03ff) << 17;
497 insn |= ((value >> 11) & 0x03ff) << 6;
498 insn |= ((value >> 21) & 0x000f) << 0;
500 return insn;
502 #endif /* INSERT_SIMM25_A16_5 */
504 #ifndef EXTRACT_SIMM25_A16_5
505 #define EXTRACT_SIMM25_A16_5
506 /* mask = 00000111111111102222222222003333. */
507 static long long int
508 extract_simm25_a16_5 (unsigned long long insn ATTRIBUTE_UNUSED,
509 bool *invalid ATTRIBUTE_UNUSED)
511 int value = 0;
513 value |= ((insn >> 17) & 0x03ff) << 1;
514 value |= ((insn >> 6) & 0x03ff) << 11;
515 value |= ((insn >> 0) & 0x000f) << 21;
517 /* Extend the sign. */
518 int signbit = 1 << (25 - 1);
519 value = (value ^ signbit) - signbit;
521 return value;
523 #endif /* EXTRACT_SIMM25_A16_5 */
525 #ifndef INSERT_SIMM10_A16_7_S
526 #define INSERT_SIMM10_A16_7_S
527 /* mask = 0000000111111111
528 insn = 1111001sssssssss. */
529 static unsigned long long
530 insert_simm10_a16_7_s (unsigned long long insn ATTRIBUTE_UNUSED,
531 long long int value ATTRIBUTE_UNUSED,
532 const char **errmsg ATTRIBUTE_UNUSED)
534 if (value & 0x01)
535 *errmsg = _("Target address is not 16bit aligned.");
537 insn |= ((value >> 1) & 0x01ff) << 0;
539 return insn;
541 #endif /* INSERT_SIMM10_A16_7_S */
543 #ifndef EXTRACT_SIMM10_A16_7_S
544 #define EXTRACT_SIMM10_A16_7_S
545 /* mask = 0000000111111111. */
546 static long long int
547 extract_simm10_a16_7_s (unsigned long long insn ATTRIBUTE_UNUSED,
548 bool *invalid ATTRIBUTE_UNUSED)
550 int value = 0;
552 value |= ((insn >> 0) & 0x01ff) << 1;
554 /* Extend the sign. */
555 int signbit = 1 << (10 - 1);
556 value = (value ^ signbit) - signbit;
558 return value;
560 #endif /* EXTRACT_SIMM10_A16_7_S */
562 #ifndef INSERT_SIMM7_A16_10_S
563 #define INSERT_SIMM7_A16_10_S
564 /* mask = 0000000000111111
565 insn = 1111011000ssssss. */
566 static unsigned long long
567 insert_simm7_a16_10_s (unsigned long long insn ATTRIBUTE_UNUSED,
568 long long int value ATTRIBUTE_UNUSED,
569 const char **errmsg ATTRIBUTE_UNUSED)
571 if (value & 0x01)
572 *errmsg = _("Target address is not 16bit aligned.");
574 insn |= ((value >> 1) & 0x003f) << 0;
576 return insn;
578 #endif /* INSERT_SIMM7_A16_10_S */
580 #ifndef EXTRACT_SIMM7_A16_10_S
581 #define EXTRACT_SIMM7_A16_10_S
582 /* mask = 0000000000111111. */
583 static long long int
584 extract_simm7_a16_10_s (unsigned long long insn ATTRIBUTE_UNUSED,
585 bool *invalid ATTRIBUTE_UNUSED)
587 int value = 0;
589 value |= ((insn >> 0) & 0x003f) << 1;
591 /* Extend the sign. */
592 int signbit = 1 << (7 - 1);
593 value = (value ^ signbit) - signbit;
595 return value;
597 #endif /* EXTRACT_SIMM7_A16_10_S */
599 #ifndef INSERT_SIMM21_A32_5
600 #define INSERT_SIMM21_A32_5
601 /* mask = 00000111111111002222222222000000
602 insn = 00001sssssssss00SSSSSSSSSSNQQQQQ. */
603 static unsigned long long
604 insert_simm21_a32_5 (unsigned long long insn ATTRIBUTE_UNUSED,
605 long long int value ATTRIBUTE_UNUSED,
606 const char **errmsg ATTRIBUTE_UNUSED)
608 if (value & 0x03)
609 *errmsg = _("Target address is not 32bit aligned.");
611 insn |= ((value >> 2) & 0x01ff) << 18;
612 insn |= ((value >> 11) & 0x03ff) << 6;
614 return insn;
616 #endif /* INSERT_SIMM21_A32_5 */
618 #ifndef EXTRACT_SIMM21_A32_5
619 #define EXTRACT_SIMM21_A32_5
620 /* mask = 00000111111111002222222222000000. */
621 static long long int
622 extract_simm21_a32_5 (unsigned long long insn ATTRIBUTE_UNUSED,
623 bool *invalid ATTRIBUTE_UNUSED)
625 int value = 0;
627 value |= ((insn >> 18) & 0x01ff) << 2;
628 value |= ((insn >> 6) & 0x03ff) << 11;
630 /* Extend the sign. */
631 int signbit = 1 << (21 - 1);
632 value = (value ^ signbit) - signbit;
634 return value;
636 #endif /* EXTRACT_SIMM21_A32_5 */
638 #ifndef INSERT_SIMM25_A32_5
639 #define INSERT_SIMM25_A32_5
640 /* mask = 00000111111111002222222222003333
641 insn = 00001sssssssss10SSSSSSSSSSNRtttt. */
642 static unsigned long long
643 insert_simm25_a32_5 (unsigned long long insn ATTRIBUTE_UNUSED,
644 long long int value ATTRIBUTE_UNUSED,
645 const char **errmsg ATTRIBUTE_UNUSED)
647 if (value & 0x03)
648 *errmsg = _("Target address is not 32bit aligned.");
650 insn |= ((value >> 2) & 0x01ff) << 18;
651 insn |= ((value >> 11) & 0x03ff) << 6;
652 insn |= ((value >> 21) & 0x000f) << 0;
654 return insn;
656 #endif /* INSERT_SIMM25_A32_5 */
658 #ifndef EXTRACT_SIMM25_A32_5
659 #define EXTRACT_SIMM25_A32_5
660 /* mask = 00000111111111002222222222003333. */
661 static long long int
662 extract_simm25_a32_5 (unsigned long long insn ATTRIBUTE_UNUSED,
663 bool *invalid ATTRIBUTE_UNUSED)
665 int value = 0;
667 value |= ((insn >> 18) & 0x01ff) << 2;
668 value |= ((insn >> 6) & 0x03ff) << 11;
669 value |= ((insn >> 0) & 0x000f) << 21;
671 /* Extend the sign. */
672 int signbit = 1 << (25 - 1);
673 value = (value ^ signbit) - signbit;
675 return value;
677 #endif /* EXTRACT_SIMM25_A32_5 */
679 #ifndef INSERT_SIMM13_A32_5_S
680 #define INSERT_SIMM13_A32_5_S
681 /* mask = 0000011111111111
682 insn = 11111sssssssssss. */
683 static unsigned long long
684 insert_simm13_a32_5_s (unsigned long long insn ATTRIBUTE_UNUSED,
685 long long int value ATTRIBUTE_UNUSED,
686 const char **errmsg ATTRIBUTE_UNUSED)
688 if (value & 0x03)
689 *errmsg = _("Target address is not 32bit aligned.");
691 insn |= ((value >> 2) & 0x07ff) << 0;
693 return insn;
695 #endif /* INSERT_SIMM13_A32_5_S */
697 #ifndef EXTRACT_SIMM13_A32_5_S
698 #define EXTRACT_SIMM13_A32_5_S
699 /* mask = 0000011111111111. */
700 static long long int
701 extract_simm13_a32_5_s (unsigned long long insn ATTRIBUTE_UNUSED,
702 bool *invalid ATTRIBUTE_UNUSED)
704 int value = 0;
706 value |= ((insn >> 0) & 0x07ff) << 2;
708 /* Extend the sign. */
709 int signbit = 1 << (13 - 1);
710 value = (value ^ signbit) - signbit;
712 return value;
714 #endif /* EXTRACT_SIMM13_A32_5_S */
716 #ifndef INSERT_SIMM8_A16_9_S
717 #define INSERT_SIMM8_A16_9_S
718 /* mask = 0000000001111111
719 insn = 11101bbb1sssssss. */
720 static unsigned long long
721 insert_simm8_a16_9_s (unsigned long long insn ATTRIBUTE_UNUSED,
722 long long int value ATTRIBUTE_UNUSED,
723 const char **errmsg ATTRIBUTE_UNUSED)
725 if (value & 0x01)
726 *errmsg = _("Target address is not 16bit aligned.");
728 insn |= ((value >> 1) & 0x007f) << 0;
730 return insn;
732 #endif /* INSERT_SIMM8_A16_9_S */
734 #ifndef EXTRACT_SIMM8_A16_9_S
735 #define EXTRACT_SIMM8_A16_9_S
736 /* mask = 0000000001111111. */
737 static long long int
738 extract_simm8_a16_9_s (unsigned long long insn ATTRIBUTE_UNUSED,
739 bool *invalid ATTRIBUTE_UNUSED)
741 int value = 0;
743 value |= ((insn >> 0) & 0x007f) << 1;
745 /* Extend the sign. */
746 int signbit = 1 << (8 - 1);
747 value = (value ^ signbit) - signbit;
749 return value;
751 #endif /* EXTRACT_SIMM8_A16_9_S */
753 #ifndef INSERT_UIMM3_23
754 #define INSERT_UIMM3_23
755 /* mask = 00000000000000000000000111000000
756 insn = 00100011011011110001RRRuuu111111. */
757 static unsigned long long
758 insert_uimm3_23 (unsigned long long insn ATTRIBUTE_UNUSED,
759 long long int value ATTRIBUTE_UNUSED,
760 const char **errmsg ATTRIBUTE_UNUSED)
763 insn |= ((value >> 0) & 0x0007) << 6;
765 return insn;
767 #endif /* INSERT_UIMM3_23 */
769 #ifndef EXTRACT_UIMM3_23
770 #define EXTRACT_UIMM3_23
771 /* mask = 00000000000000000000000111000000. */
772 static long long int
773 extract_uimm3_23 (unsigned long long insn ATTRIBUTE_UNUSED,
774 bool *invalid ATTRIBUTE_UNUSED)
776 unsigned value = 0;
778 value |= ((insn >> 6) & 0x0007) << 0;
780 return value;
782 #endif /* EXTRACT_UIMM3_23 */
784 #ifndef INSERT_UIMM10_6_S
785 #define INSERT_UIMM10_6_S
786 /* mask = 0000001111111111
787 insn = 010111uuuuuuuuuu. */
788 static unsigned long long
789 insert_uimm10_6_s (unsigned long long insn ATTRIBUTE_UNUSED,
790 long long int value ATTRIBUTE_UNUSED,
791 const char **errmsg ATTRIBUTE_UNUSED)
794 insn |= ((value >> 0) & 0x03ff) << 0;
796 return insn;
798 #endif /* INSERT_UIMM10_6_S */
800 #ifndef EXTRACT_UIMM10_6_S
801 #define EXTRACT_UIMM10_6_S
802 /* mask = 0000001111111111. */
803 static long long int
804 extract_uimm10_6_s (unsigned long long insn ATTRIBUTE_UNUSED,
805 bool *invalid ATTRIBUTE_UNUSED)
807 unsigned value = 0;
809 value |= ((insn >> 0) & 0x03ff) << 0;
811 return value;
813 #endif /* EXTRACT_UIMM10_6_S */
815 #ifndef INSERT_UIMM6_11_S
816 #define INSERT_UIMM6_11_S
817 /* mask = 0000002200011110
818 insn = 110000UU111uuuu0. */
819 static unsigned long long
820 insert_uimm6_11_s (unsigned long long insn ATTRIBUTE_UNUSED,
821 long long int value ATTRIBUTE_UNUSED,
822 const char **errmsg ATTRIBUTE_UNUSED)
825 insn |= ((value >> 0) & 0x000f) << 1;
826 insn |= ((value >> 4) & 0x0003) << 8;
828 return insn;
830 #endif /* INSERT_UIMM6_11_S */
832 #ifndef EXTRACT_UIMM6_11_S
833 #define EXTRACT_UIMM6_11_S
834 /* mask = 0000002200011110. */
835 static long long int
836 extract_uimm6_11_s (unsigned long long insn ATTRIBUTE_UNUSED,
837 bool *invalid ATTRIBUTE_UNUSED)
839 unsigned value = 0;
841 value |= ((insn >> 1) & 0x000f) << 0;
842 value |= ((insn >> 8) & 0x0003) << 4;
844 return value;
846 #endif /* EXTRACT_UIMM6_11_S */
848 #ifndef INSERT_SIMM9_8
849 #define INSERT_SIMM9_8
850 /* mask = 00000000111111112000000000000000
851 insn = 00010bbbssssssssSBBBDaaZZXAAAAAA. */
852 static unsigned long long
853 insert_simm9_8 (unsigned long long insn ATTRIBUTE_UNUSED,
854 long long int value ATTRIBUTE_UNUSED,
855 const char **errmsg ATTRIBUTE_UNUSED)
858 insn |= ((value >> 0) & 0x00ff) << 16;
859 insn |= ((value >> 8) & 0x0001) << 15;
861 return insn;
863 #endif /* INSERT_SIMM9_8 */
865 #ifndef EXTRACT_SIMM9_8
866 #define EXTRACT_SIMM9_8
867 /* mask = 00000000111111112000000000000000. */
868 static long long int
869 extract_simm9_8 (unsigned long long insn ATTRIBUTE_UNUSED,
870 bool *invalid ATTRIBUTE_UNUSED)
872 int value = 0;
874 value |= ((insn >> 16) & 0x00ff) << 0;
875 value |= ((insn >> 15) & 0x0001) << 8;
877 /* Extend the sign. */
878 int signbit = 1 << (9 - 1);
879 value = (value ^ signbit) - signbit;
881 return value;
883 #endif /* EXTRACT_SIMM9_8 */
885 #ifndef INSERT_UIMM10_A32_8_S
886 #define INSERT_UIMM10_A32_8_S
887 /* mask = 0000000011111111
888 insn = 11010bbbuuuuuuuu. */
889 static unsigned long long
890 insert_uimm10_a32_8_s (unsigned long long insn ATTRIBUTE_UNUSED,
891 long long int value ATTRIBUTE_UNUSED,
892 const char **errmsg ATTRIBUTE_UNUSED)
894 if (value & 0x03)
895 *errmsg = _("Target address is not 32bit aligned.");
897 insn |= ((value >> 2) & 0x00ff) << 0;
899 return insn;
901 #endif /* INSERT_UIMM10_A32_8_S */
903 #ifndef EXTRACT_UIMM10_A32_8_S
904 #define EXTRACT_UIMM10_A32_8_S
905 /* mask = 0000000011111111. */
906 static long long int
907 extract_uimm10_a32_8_s (unsigned long long insn ATTRIBUTE_UNUSED,
908 bool *invalid ATTRIBUTE_UNUSED)
910 unsigned value = 0;
912 value |= ((insn >> 0) & 0x00ff) << 2;
914 return value;
916 #endif /* EXTRACT_UIMM10_A32_8_S */
918 #ifndef INSERT_SIMM9_7_S
919 #define INSERT_SIMM9_7_S
920 /* mask = 0000000111111111
921 insn = 1100101sssssssss. */
922 static unsigned long long
923 insert_simm9_7_s (unsigned long long insn ATTRIBUTE_UNUSED,
924 long long int value ATTRIBUTE_UNUSED,
925 const char **errmsg ATTRIBUTE_UNUSED)
928 insn |= ((value >> 0) & 0x01ff) << 0;
930 return insn;
932 #endif /* INSERT_SIMM9_7_S */
934 #ifndef EXTRACT_SIMM9_7_S
935 #define EXTRACT_SIMM9_7_S
936 /* mask = 0000000111111111. */
937 static long long int
938 extract_simm9_7_s (unsigned long long insn ATTRIBUTE_UNUSED,
939 bool *invalid ATTRIBUTE_UNUSED)
941 int value = 0;
943 value |= ((insn >> 0) & 0x01ff) << 0;
945 /* Extend the sign. */
946 int signbit = 1 << (9 - 1);
947 value = (value ^ signbit) - signbit;
949 return value;
951 #endif /* EXTRACT_SIMM9_7_S */
953 #ifndef INSERT_UIMM6_A16_11_S
954 #define INSERT_UIMM6_A16_11_S
955 /* mask = 0000000000011111
956 insn = 10010bbbcccuuuuu. */
957 static unsigned long long
958 insert_uimm6_a16_11_s (unsigned long long insn ATTRIBUTE_UNUSED,
959 long long int value ATTRIBUTE_UNUSED,
960 const char **errmsg ATTRIBUTE_UNUSED)
962 if (value & 0x01)
963 *errmsg = _("Target address is not 16bit aligned.");
965 insn |= ((value >> 1) & 0x001f) << 0;
967 return insn;
969 #endif /* INSERT_UIMM6_A16_11_S */
971 #ifndef EXTRACT_UIMM6_A16_11_S
972 #define EXTRACT_UIMM6_A16_11_S
973 /* mask = 0000000000011111. */
974 static long long int
975 extract_uimm6_a16_11_s (unsigned long long insn ATTRIBUTE_UNUSED,
976 bool *invalid ATTRIBUTE_UNUSED)
978 unsigned value = 0;
980 value |= ((insn >> 0) & 0x001f) << 1;
982 return value;
984 #endif /* EXTRACT_UIMM6_A16_11_S */
986 #ifndef INSERT_UIMM5_A32_11_S
987 #define INSERT_UIMM5_A32_11_S
988 /* mask = 0000020000011000
989 insn = 01000U00hhhuu1HH. */
990 static unsigned long long
991 insert_uimm5_a32_11_s (unsigned long long insn ATTRIBUTE_UNUSED,
992 long long int value ATTRIBUTE_UNUSED,
993 const char **errmsg ATTRIBUTE_UNUSED)
995 if (value & 0x03)
996 *errmsg = _("Target address is not 32bit aligned.");
998 insn |= ((value >> 2) & 0x0003) << 3;
999 insn |= ((value >> 4) & 0x0001) << 10;
1001 return insn;
1003 #endif /* INSERT_UIMM5_A32_11_S */
1005 #ifndef EXTRACT_UIMM5_A32_11_S
1006 #define EXTRACT_UIMM5_A32_11_S
1007 /* mask = 0000020000011000. */
1008 static long long int
1009 extract_uimm5_a32_11_s (unsigned long long insn ATTRIBUTE_UNUSED,
1010 bool *invalid ATTRIBUTE_UNUSED)
1012 unsigned value = 0;
1014 value |= ((insn >> 3) & 0x0003) << 2;
1015 value |= ((insn >> 10) & 0x0001) << 4;
1017 return value;
1019 #endif /* EXTRACT_UIMM5_A32_11_S */
1021 #ifndef INSERT_SIMM11_A32_13_S
1022 #define INSERT_SIMM11_A32_13_S
1023 /* mask = 0000022222200111
1024 insn = 01010SSSSSS00sss. */
1025 static unsigned long long
1026 insert_simm11_a32_13_s (unsigned long long insn ATTRIBUTE_UNUSED,
1027 long long int value ATTRIBUTE_UNUSED,
1028 const char **errmsg ATTRIBUTE_UNUSED)
1030 if (value & 0x03)
1031 *errmsg = _("Target address is not 32bit aligned.");
1033 insn |= ((value >> 2) & 0x0007) << 0;
1034 insn |= ((value >> 5) & 0x003f) << 5;
1036 return insn;
1038 #endif /* INSERT_SIMM11_A32_13_S */
1040 #ifndef EXTRACT_SIMM11_A32_13_S
1041 #define EXTRACT_SIMM11_A32_13_S
1042 /* mask = 0000022222200111. */
1043 static long long int
1044 extract_simm11_a32_13_s (unsigned long long insn ATTRIBUTE_UNUSED,
1045 bool *invalid ATTRIBUTE_UNUSED)
1047 int value = 0;
1049 value |= ((insn >> 0) & 0x0007) << 2;
1050 value |= ((insn >> 5) & 0x003f) << 5;
1052 /* Extend the sign. */
1053 int signbit = 1 << (11 - 1);
1054 value = (value ^ signbit) - signbit;
1056 return value;
1058 #endif /* EXTRACT_SIMM11_A32_13_S */
1060 #ifndef INSERT_UIMM7_13_S
1061 #define INSERT_UIMM7_13_S
1062 /* mask = 0000000022220111
1063 insn = 01010bbbUUUU1uuu. */
1064 static unsigned long long
1065 insert_uimm7_13_s (unsigned long long insn ATTRIBUTE_UNUSED,
1066 long long int value ATTRIBUTE_UNUSED,
1067 const char **errmsg ATTRIBUTE_UNUSED)
1070 insn |= ((value >> 0) & 0x0007) << 0;
1071 insn |= ((value >> 3) & 0x000f) << 4;
1073 return insn;
1075 #endif /* INSERT_UIMM7_13_S */
1077 #ifndef EXTRACT_UIMM7_13_S
1078 #define EXTRACT_UIMM7_13_S
1079 /* mask = 0000000022220111. */
1080 static long long int
1081 extract_uimm7_13_s (unsigned long long insn ATTRIBUTE_UNUSED,
1082 bool *invalid ATTRIBUTE_UNUSED)
1084 unsigned value = 0;
1086 value |= ((insn >> 0) & 0x0007) << 0;
1087 value |= ((insn >> 4) & 0x000f) << 3;
1089 return value;
1091 #endif /* EXTRACT_UIMM7_13_S */
1093 #ifndef INSERT_UIMM6_A16_21
1094 #define INSERT_UIMM6_A16_21
1095 /* mask = 00000000000000000000011111000000
1096 insn = 00101bbb01001100RBBBRuuuuuAAAAAA. */
1097 static unsigned long long
1098 insert_uimm6_a16_21 (unsigned long long insn ATTRIBUTE_UNUSED,
1099 long long int value ATTRIBUTE_UNUSED,
1100 const char **errmsg ATTRIBUTE_UNUSED)
1102 if (value & 0x01)
1103 *errmsg = _("Target address is not 16bit aligned.");
1105 insn |= ((value >> 1) & 0x001f) << 6;
1107 return insn;
1109 #endif /* INSERT_UIMM6_A16_21 */
1111 #ifndef EXTRACT_UIMM6_A16_21
1112 #define EXTRACT_UIMM6_A16_21
1113 /* mask = 00000000000000000000011111000000. */
1114 static long long int
1115 extract_uimm6_a16_21 (unsigned long long insn ATTRIBUTE_UNUSED,
1116 bool *invalid ATTRIBUTE_UNUSED)
1118 unsigned value = 0;
1120 value |= ((insn >> 6) & 0x001f) << 1;
1122 return value;
1124 #endif /* EXTRACT_UIMM6_A16_21 */
1126 #ifndef INSERT_UIMM7_11_S
1127 #define INSERT_UIMM7_11_S
1128 /* mask = 0000022200011110
1129 insn = 11000UUU110uuuu0. */
1130 static unsigned long long
1131 insert_uimm7_11_s (unsigned long long insn ATTRIBUTE_UNUSED,
1132 long long int value ATTRIBUTE_UNUSED,
1133 const char **errmsg ATTRIBUTE_UNUSED)
1136 insn |= ((value >> 0) & 0x000f) << 1;
1137 insn |= ((value >> 4) & 0x0007) << 8;
1139 return insn;
1141 #endif /* INSERT_UIMM7_11_S */
1143 #ifndef EXTRACT_UIMM7_11_S
1144 #define EXTRACT_UIMM7_11_S
1145 /* mask = 0000022200011110. */
1146 static long long int
1147 extract_uimm7_11_s (unsigned long long insn ATTRIBUTE_UNUSED,
1148 bool *invalid ATTRIBUTE_UNUSED)
1150 unsigned value = 0;
1152 value |= ((insn >> 1) & 0x000f) << 0;
1153 value |= ((insn >> 8) & 0x0007) << 4;
1155 return value;
1157 #endif /* EXTRACT_UIMM7_11_S */
1159 #ifndef INSERT_UIMM7_A16_20
1160 #define INSERT_UIMM7_A16_20
1161 /* mask = 00000000000000000000111111000000
1162 insn = 00100RRR111010000RRRuuuuuu1QQQQQ. */
1163 static unsigned long long
1164 insert_uimm7_a16_20 (unsigned long long insn ATTRIBUTE_UNUSED,
1165 long long int value ATTRIBUTE_UNUSED,
1166 const char **errmsg ATTRIBUTE_UNUSED)
1168 if (value & 0x01)
1169 *errmsg = _("Target address is not 16bit aligned.");
1171 insn |= ((value >> 1) & 0x003f) << 6;
1173 return insn;
1175 #endif /* INSERT_UIMM7_A16_20 */
1177 #ifndef EXTRACT_UIMM7_A16_20
1178 #define EXTRACT_UIMM7_A16_20
1179 /* mask = 00000000000000000000111111000000. */
1180 static long long int
1181 extract_uimm7_a16_20 (unsigned long long insn ATTRIBUTE_UNUSED,
1182 bool *invalid ATTRIBUTE_UNUSED)
1184 unsigned value = 0;
1186 value |= ((insn >> 6) & 0x003f) << 1;
1188 return value;
1190 #endif /* EXTRACT_UIMM7_A16_20 */
1192 #ifndef INSERT_SIMM13_A16_20
1193 #define INSERT_SIMM13_A16_20
1194 /* mask = 00000000000000000000111111222222
1195 insn = 00100RRR101010000RRRssssssSSSSSS. */
1196 static unsigned long long
1197 insert_simm13_a16_20 (unsigned long long insn ATTRIBUTE_UNUSED,
1198 long long int value ATTRIBUTE_UNUSED,
1199 const char **errmsg ATTRIBUTE_UNUSED)
1201 if (value & 0x01)
1202 *errmsg = _("Target address is not 16bit aligned.");
1204 insn |= ((value >> 1) & 0x003f) << 6;
1205 insn |= ((value >> 7) & 0x003f) << 0;
1207 return insn;
1209 #endif /* INSERT_SIMM13_A16_20 */
1211 #ifndef EXTRACT_SIMM13_A16_20
1212 #define EXTRACT_SIMM13_A16_20
1213 /* mask = 00000000000000000000111111222222. */
1214 static long long int
1215 extract_simm13_a16_20 (unsigned long long insn ATTRIBUTE_UNUSED,
1216 bool *invalid ATTRIBUTE_UNUSED)
1218 int value = 0;
1220 value |= ((insn >> 6) & 0x003f) << 1;
1221 value |= ((insn >> 0) & 0x003f) << 7;
1223 /* Extend the sign. */
1224 int signbit = 1 << (13 - 1);
1225 value = (value ^ signbit) - signbit;
1227 return value;
1229 #endif /* EXTRACT_SIMM13_A16_20 */
1231 #ifndef INSERT_UIMM8_8_S
1232 #define INSERT_UIMM8_8_S
1233 /* mask = 0000000011111111
1234 insn = 11011bbbuuuuuuuu. */
1235 static unsigned long long
1236 insert_uimm8_8_s (unsigned long long insn ATTRIBUTE_UNUSED,
1237 long long int value ATTRIBUTE_UNUSED,
1238 const char **errmsg ATTRIBUTE_UNUSED)
1241 insn |= ((value >> 0) & 0x00ff) << 0;
1243 return insn;
1245 #endif /* INSERT_UIMM8_8_S */
1247 #ifndef EXTRACT_UIMM8_8_S
1248 #define EXTRACT_UIMM8_8_S
1249 /* mask = 0000000011111111. */
1250 static long long int
1251 extract_uimm8_8_s (unsigned long long insn ATTRIBUTE_UNUSED,
1252 bool *invalid ATTRIBUTE_UNUSED)
1254 unsigned value = 0;
1256 value |= ((insn >> 0) & 0x00ff) << 0;
1258 return value;
1260 #endif /* EXTRACT_UIMM8_8_S */
1262 #ifndef INSERT_UIMM6_5_S
1263 #define INSERT_UIMM6_5_S
1264 /* mask = 0000011111100000
1265 insn = 01111uuuuuu11111. */
1266 static unsigned long long
1267 insert_uimm6_5_s (unsigned long long insn ATTRIBUTE_UNUSED,
1268 long long int value ATTRIBUTE_UNUSED,
1269 const char **errmsg ATTRIBUTE_UNUSED)
1272 insn |= ((value >> 0) & 0x003f) << 5;
1274 return insn;
1276 #endif /* INSERT_UIMM6_5_S */
1278 #ifndef EXTRACT_UIMM6_5_S
1279 #define EXTRACT_UIMM6_5_S
1280 /* mask = 0000011111100000. */
1281 static long long int
1282 extract_uimm6_5_s (unsigned long long insn ATTRIBUTE_UNUSED,
1283 bool *invalid ATTRIBUTE_UNUSED)
1285 unsigned value = 0;
1287 value |= ((insn >> 5) & 0x003f) << 0;
1289 return value;
1291 #endif /* EXTRACT_UIMM6_5_S */
1293 #ifndef INSERT_UIMM6_AXX_
1294 #define INSERT_UIMM6_AXX_
1295 /* mask = 00000000000000000000000000000000
1296 insn = 00110bbb11100001100001100001QQQQ. */
1297 static ATTRIBUTE_UNUSED unsigned
1298 insert_uimm6_axx_ (unsigned long long insn ATTRIBUTE_UNUSED,
1299 long long int value ATTRIBUTE_UNUSED,
1300 const char **errmsg ATTRIBUTE_UNUSED)
1302 if (value & 0x3f)
1303 *errmsg = _("Target address is not 512bit aligned.");
1305 return insn;
1307 #endif /* INSERT_UIMM6_AXX_ */
1309 #ifndef EXTRACT_UIMM6_AXX_
1310 #define EXTRACT_UIMM6_AXX_
1311 /* mask = 00000000000000000000000000000000. */
1312 static ATTRIBUTE_UNUSED int
1313 extract_uimm6_axx_ (unsigned long long insn ATTRIBUTE_UNUSED,
1314 bool *invalid ATTRIBUTE_UNUSED)
1316 unsigned value = 0;
1318 return value;
1320 #endif /* EXTRACT_UIMM6_AXX_ */