1 /* Insert/extract functions for the ARC opcodes.
2 Copyright 2015 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)
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. */
24 /* mask = 00000000000000000000000000000000
25 insn = 00100bbb00101111FBBB111110001001. */
27 insert_limm (unsigned insn ATTRIBUTE_UNUSED,
28 int value ATTRIBUTE_UNUSED, const char **errmsg ATTRIBUTE_UNUSED)
33 #endif /* INSERT_LIMM */
37 /* mask = 00000000000000000000000000000000. */
38 static ATTRIBUTE_UNUSED int
39 extract_limm (unsigned insn ATTRIBUTE_UNUSED, bfd_boolean * invalid ATTRIBUTE_UNUSED)
45 #endif /* EXTRACT_LIMM */
47 #ifndef INSERT_UIMM6_20
48 #define INSERT_UIMM6_20
49 /* mask = 00000000000000000000111111000000
50 insn = 00100bbb01101111FBBBuuuuuu001001. */
52 insert_uimm6_20 (unsigned insn ATTRIBUTE_UNUSED,
53 int value ATTRIBUTE_UNUSED,
54 const char **errmsg ATTRIBUTE_UNUSED)
57 insn |= ((value >> 0) & 0x003f) << 6;
61 #endif /* INSERT_UIMM6_20 */
63 #ifndef EXTRACT_UIMM6_20
64 #define EXTRACT_UIMM6_20
65 /* mask = 00000000000000000000111111000000. */
67 extract_uimm6_20 (unsigned insn ATTRIBUTE_UNUSED,
68 bfd_boolean * invalid ATTRIBUTE_UNUSED)
72 value |= ((insn >> 6) & 0x003f) << 0;
76 #endif /* EXTRACT_UIMM6_20 */
78 #ifndef INSERT_SIMM12_20
79 #define INSERT_SIMM12_20
80 /* mask = 00000000000000000000111111222222
81 insn = 00110bbb10101000FBBBssssssSSSSSS. */
83 insert_simm12_20 (unsigned insn ATTRIBUTE_UNUSED,
84 int value ATTRIBUTE_UNUSED,
85 const char **errmsg ATTRIBUTE_UNUSED)
88 insn |= ((value >> 0) & 0x003f) << 6;
89 insn |= ((value >> 6) & 0x003f) << 0;
93 #endif /* INSERT_SIMM12_20 */
95 #ifndef EXTRACT_SIMM12_20
96 #define EXTRACT_SIMM12_20
97 /* mask = 00000000000000000000111111222222. */
99 extract_simm12_20 (unsigned insn ATTRIBUTE_UNUSED,
100 bfd_boolean * invalid ATTRIBUTE_UNUSED)
104 value |= ((insn >> 6) & 0x003f) << 0;
105 value |= ((insn >> 0) & 0x003f) << 6;
107 /* Extend the sign. */
108 int signbit = 1 << (12 - 1);
109 value = (value ^ signbit) - signbit;
113 #endif /* EXTRACT_SIMM12_20 */
115 #ifndef INSERT_SIMM3_5_S
116 #define INSERT_SIMM3_5_S
117 /* mask = 0000011100000000
118 insn = 01110ssshhh001HH. */
119 static ATTRIBUTE_UNUSED unsigned
120 insert_simm3_5_s (unsigned insn ATTRIBUTE_UNUSED,
121 int value ATTRIBUTE_UNUSED,
122 const char **errmsg ATTRIBUTE_UNUSED)
125 insn |= ((value >> 0) & 0x0007) << 8;
129 #endif /* INSERT_SIMM3_5_S */
131 #ifndef EXTRACT_SIMM3_5_S
132 #define EXTRACT_SIMM3_5_S
133 /* mask = 0000011100000000. */
134 static ATTRIBUTE_UNUSED int
135 extract_simm3_5_s (unsigned insn ATTRIBUTE_UNUSED,
136 bfd_boolean * invalid ATTRIBUTE_UNUSED)
140 value |= ((insn >> 8) & 0x0007) << 0;
142 /* Extend the sign. */
143 int signbit = 1 << (3 - 1);
144 value = (value ^ signbit) - signbit;
148 #endif /* EXTRACT_SIMM3_5_S */
150 #ifndef INSERT_LIMM_S
151 #define INSERT_LIMM_S
152 /* mask = 0000000000000000
153 insn = 01110sss11000111. */
154 static ATTRIBUTE_UNUSED unsigned
155 insert_limm_s (unsigned insn ATTRIBUTE_UNUSED,
156 int value ATTRIBUTE_UNUSED,
157 const char **errmsg ATTRIBUTE_UNUSED)
162 #endif /* INSERT_LIMM_S */
164 #ifndef EXTRACT_LIMM_S
165 #define EXTRACT_LIMM_S
166 /* mask = 0000000000000000. */
167 static ATTRIBUTE_UNUSED int
168 extract_limm_s (unsigned insn ATTRIBUTE_UNUSED, bfd_boolean * invalid ATTRIBUTE_UNUSED)
174 #endif /* EXTRACT_LIMM_S */
176 #ifndef INSERT_UIMM7_A32_11_S
177 #define INSERT_UIMM7_A32_11_S
178 /* mask = 0000000000011111
179 insn = 11000bbb100uuuuu. */
181 insert_uimm7_a32_11_s (unsigned insn ATTRIBUTE_UNUSED,
182 int value ATTRIBUTE_UNUSED,
183 const char **errmsg ATTRIBUTE_UNUSED)
186 *errmsg = _("Target address is not 32bit aligned.");
188 insn |= ((value >> 2) & 0x001f) << 0;
192 #endif /* INSERT_UIMM7_A32_11_S */
194 #ifndef EXTRACT_UIMM7_A32_11_S
195 #define EXTRACT_UIMM7_A32_11_S
196 /* mask = 0000000000011111. */
198 extract_uimm7_a32_11_s (unsigned insn ATTRIBUTE_UNUSED,
199 bfd_boolean * invalid ATTRIBUTE_UNUSED)
203 value |= ((insn >> 0) & 0x001f) << 2;
207 #endif /* EXTRACT_UIMM7_A32_11_S */
209 #ifndef INSERT_UIMM7_9_S
210 #define INSERT_UIMM7_9_S
211 /* mask = 0000000001111111
212 insn = 11100bbb0uuuuuuu. */
214 insert_uimm7_9_s (unsigned insn ATTRIBUTE_UNUSED,
215 int value ATTRIBUTE_UNUSED,
216 const char **errmsg ATTRIBUTE_UNUSED)
219 insn |= ((value >> 0) & 0x007f) << 0;
223 #endif /* INSERT_UIMM7_9_S */
225 #ifndef EXTRACT_UIMM7_9_S
226 #define EXTRACT_UIMM7_9_S
227 /* mask = 0000000001111111. */
229 extract_uimm7_9_s (unsigned insn ATTRIBUTE_UNUSED,
230 bfd_boolean * invalid ATTRIBUTE_UNUSED)
234 value |= ((insn >> 0) & 0x007f) << 0;
238 #endif /* EXTRACT_UIMM7_9_S */
240 #ifndef INSERT_UIMM3_13_S
241 #define INSERT_UIMM3_13_S
242 /* mask = 0000000000000111
243 insn = 01101bbbccc00uuu. */
245 insert_uimm3_13_s (unsigned insn ATTRIBUTE_UNUSED,
246 int value ATTRIBUTE_UNUSED,
247 const char **errmsg ATTRIBUTE_UNUSED)
250 insn |= ((value >> 0) & 0x0007) << 0;
254 #endif /* INSERT_UIMM3_13_S */
256 #ifndef EXTRACT_UIMM3_13_S
257 #define EXTRACT_UIMM3_13_S
258 /* mask = 0000000000000111. */
260 extract_uimm3_13_s (unsigned insn ATTRIBUTE_UNUSED,
261 bfd_boolean * invalid ATTRIBUTE_UNUSED)
265 value |= ((insn >> 0) & 0x0007) << 0;
269 #endif /* EXTRACT_UIMM3_13_S */
271 #ifndef INSERT_SIMM11_A32_7_S
272 #define INSERT_SIMM11_A32_7_S
273 /* mask = 0000000111111111
274 insn = 1100111sssssssss. */
276 insert_simm11_a32_7_s (unsigned insn ATTRIBUTE_UNUSED,
277 int value ATTRIBUTE_UNUSED,
278 const char **errmsg ATTRIBUTE_UNUSED)
281 *errmsg = _("Target address is not 32bit aligned.");
283 insn |= ((value >> 2) & 0x01ff) << 0;
287 #endif /* INSERT_SIMM11_A32_7_S */
289 #ifndef EXTRACT_SIMM11_A32_7_S
290 #define EXTRACT_SIMM11_A32_7_S
291 /* mask = 0000000111111111. */
293 extract_simm11_a32_7_s (unsigned insn ATTRIBUTE_UNUSED,
294 bfd_boolean * invalid ATTRIBUTE_UNUSED)
298 value |= ((insn >> 0) & 0x01ff) << 2;
300 /* Extend the sign. */
301 int signbit = 1 << (11 - 1);
302 value = (value ^ signbit) - signbit;
306 #endif /* EXTRACT_SIMM11_A32_7_S */
308 #ifndef INSERT_UIMM6_13_S
309 #define INSERT_UIMM6_13_S
310 /* mask = 0000000002220111
311 insn = 01001bbb0UUU1uuu. */
313 insert_uimm6_13_s (unsigned insn ATTRIBUTE_UNUSED,
314 int value ATTRIBUTE_UNUSED,
315 const char **errmsg ATTRIBUTE_UNUSED)
318 insn |= ((value >> 0) & 0x0007) << 0;
319 insn |= ((value >> 3) & 0x0007) << 4;
323 #endif /* INSERT_UIMM6_13_S */
325 #ifndef EXTRACT_UIMM6_13_S
326 #define EXTRACT_UIMM6_13_S
327 /* mask = 0000000002220111. */
329 extract_uimm6_13_s (unsigned insn ATTRIBUTE_UNUSED,
330 bfd_boolean * invalid ATTRIBUTE_UNUSED)
334 value |= ((insn >> 0) & 0x0007) << 0;
335 value |= ((insn >> 4) & 0x0007) << 3;
339 #endif /* EXTRACT_UIMM6_13_S */
341 #ifndef INSERT_UIMM5_11_S
342 #define INSERT_UIMM5_11_S
343 /* mask = 0000000000011111
344 insn = 10111bbb000uuuuu. */
346 insert_uimm5_11_s (unsigned insn ATTRIBUTE_UNUSED,
347 int value ATTRIBUTE_UNUSED,
348 const char **errmsg ATTRIBUTE_UNUSED)
351 insn |= ((value >> 0) & 0x001f) << 0;
355 #endif /* INSERT_UIMM5_11_S */
357 #ifndef EXTRACT_UIMM5_11_S
358 #define EXTRACT_UIMM5_11_S
359 /* mask = 0000000000011111. */
361 extract_uimm5_11_s (unsigned insn ATTRIBUTE_UNUSED,
362 bfd_boolean * invalid ATTRIBUTE_UNUSED)
366 value |= ((insn >> 0) & 0x001f) << 0;
370 #endif /* EXTRACT_UIMM5_11_S */
372 #ifndef INSERT_SIMM9_A16_8
373 #define INSERT_SIMM9_A16_8
374 /* mask = 00000000111111102000000000000000
375 insn = 00001bbbsssssss1SBBBCCCCCCN01110. */
377 insert_simm9_a16_8 (unsigned insn ATTRIBUTE_UNUSED,
378 int value ATTRIBUTE_UNUSED,
379 const char **errmsg ATTRIBUTE_UNUSED)
382 *errmsg = _("Target address is not 16bit aligned.");
384 insn |= ((value >> 1) & 0x007f) << 17;
385 insn |= ((value >> 8) & 0x0001) << 15;
389 #endif /* INSERT_SIMM9_A16_8 */
391 #ifndef EXTRACT_SIMM9_A16_8
392 #define EXTRACT_SIMM9_A16_8
393 /* mask = 00000000111111102000000000000000. */
395 extract_simm9_a16_8 (unsigned insn ATTRIBUTE_UNUSED,
396 bfd_boolean * invalid ATTRIBUTE_UNUSED)
400 value |= ((insn >> 17) & 0x007f) << 1;
401 value |= ((insn >> 15) & 0x0001) << 8;
403 /* Extend the sign. */
404 int signbit = 1 << (9 - 1);
405 value = (value ^ signbit) - signbit;
409 #endif /* EXTRACT_SIMM9_A16_8 */
411 #ifndef INSERT_UIMM6_8
412 #define INSERT_UIMM6_8
413 /* mask = 00000000000000000000111111000000
414 insn = 00001bbbsssssss1SBBBuuuuuuN11110. */
416 insert_uimm6_8 (unsigned insn ATTRIBUTE_UNUSED,
417 int value ATTRIBUTE_UNUSED,
418 const char **errmsg ATTRIBUTE_UNUSED)
421 insn |= ((value >> 0) & 0x003f) << 6;
425 #endif /* INSERT_UIMM6_8 */
427 #ifndef EXTRACT_UIMM6_8
428 #define EXTRACT_UIMM6_8
429 /* mask = 00000000000000000000111111000000. */
431 extract_uimm6_8 (unsigned insn ATTRIBUTE_UNUSED,
432 bfd_boolean * invalid ATTRIBUTE_UNUSED)
436 value |= ((insn >> 6) & 0x003f) << 0;
440 #endif /* EXTRACT_UIMM6_8 */
442 #ifndef INSERT_SIMM21_A16_5
443 #define INSERT_SIMM21_A16_5
444 /* mask = 00000111111111102222222222000000
445 insn = 00000ssssssssss0SSSSSSSSSSNQQQQQ. */
447 insert_simm21_a16_5 (unsigned insn ATTRIBUTE_UNUSED,
448 int value ATTRIBUTE_UNUSED,
449 const char **errmsg ATTRIBUTE_UNUSED)
452 *errmsg = _("Target address is not 16bit aligned.");
454 insn |= ((value >> 1) & 0x03ff) << 17;
455 insn |= ((value >> 11) & 0x03ff) << 6;
459 #endif /* INSERT_SIMM21_A16_5 */
461 #ifndef EXTRACT_SIMM21_A16_5
462 #define EXTRACT_SIMM21_A16_5
463 /* mask = 00000111111111102222222222000000. */
465 extract_simm21_a16_5 (unsigned insn ATTRIBUTE_UNUSED,
466 bfd_boolean * invalid ATTRIBUTE_UNUSED)
470 value |= ((insn >> 17) & 0x03ff) << 1;
471 value |= ((insn >> 6) & 0x03ff) << 11;
473 /* Extend the sign. */
474 int signbit = 1 << (21 - 1);
475 value = (value ^ signbit) - signbit;
479 #endif /* EXTRACT_SIMM21_A16_5 */
481 #ifndef INSERT_SIMM25_A16_5
482 #define INSERT_SIMM25_A16_5
483 /* mask = 00000111111111102222222222003333
484 insn = 00000ssssssssss1SSSSSSSSSSNRtttt. */
486 insert_simm25_a16_5 (unsigned insn ATTRIBUTE_UNUSED,
487 int value ATTRIBUTE_UNUSED,
488 const char **errmsg ATTRIBUTE_UNUSED)
491 *errmsg = _("Target address is not 16bit aligned.");
493 insn |= ((value >> 1) & 0x03ff) << 17;
494 insn |= ((value >> 11) & 0x03ff) << 6;
495 insn |= ((value >> 21) & 0x000f) << 0;
499 #endif /* INSERT_SIMM25_A16_5 */
501 #ifndef EXTRACT_SIMM25_A16_5
502 #define EXTRACT_SIMM25_A16_5
503 /* mask = 00000111111111102222222222003333. */
505 extract_simm25_a16_5 (unsigned insn ATTRIBUTE_UNUSED,
506 bfd_boolean * invalid ATTRIBUTE_UNUSED)
510 value |= ((insn >> 17) & 0x03ff) << 1;
511 value |= ((insn >> 6) & 0x03ff) << 11;
512 value |= ((insn >> 0) & 0x000f) << 21;
514 /* Extend the sign. */
515 int signbit = 1 << (25 - 1);
516 value = (value ^ signbit) - signbit;
520 #endif /* EXTRACT_SIMM25_A16_5 */
522 #ifndef INSERT_SIMM10_A16_7_S
523 #define INSERT_SIMM10_A16_7_S
524 /* mask = 0000000111111111
525 insn = 1111001sssssssss. */
527 insert_simm10_a16_7_s (unsigned insn ATTRIBUTE_UNUSED,
528 int value ATTRIBUTE_UNUSED,
529 const char **errmsg ATTRIBUTE_UNUSED)
532 *errmsg = _("Target address is not 16bit aligned.");
534 insn |= ((value >> 1) & 0x01ff) << 0;
538 #endif /* INSERT_SIMM10_A16_7_S */
540 #ifndef EXTRACT_SIMM10_A16_7_S
541 #define EXTRACT_SIMM10_A16_7_S
542 /* mask = 0000000111111111. */
544 extract_simm10_a16_7_s (unsigned insn ATTRIBUTE_UNUSED,
545 bfd_boolean * invalid ATTRIBUTE_UNUSED)
549 value |= ((insn >> 0) & 0x01ff) << 1;
551 /* Extend the sign. */
552 int signbit = 1 << (10 - 1);
553 value = (value ^ signbit) - signbit;
557 #endif /* EXTRACT_SIMM10_A16_7_S */
559 #ifndef INSERT_SIMM7_A16_10_S
560 #define INSERT_SIMM7_A16_10_S
561 /* mask = 0000000000111111
562 insn = 1111011000ssssss. */
564 insert_simm7_a16_10_s (unsigned insn ATTRIBUTE_UNUSED,
565 int value ATTRIBUTE_UNUSED,
566 const char **errmsg ATTRIBUTE_UNUSED)
569 *errmsg = _("Target address is not 16bit aligned.");
571 insn |= ((value >> 1) & 0x003f) << 0;
575 #endif /* INSERT_SIMM7_A16_10_S */
577 #ifndef EXTRACT_SIMM7_A16_10_S
578 #define EXTRACT_SIMM7_A16_10_S
579 /* mask = 0000000000111111. */
581 extract_simm7_a16_10_s (unsigned insn ATTRIBUTE_UNUSED,
582 bfd_boolean * invalid ATTRIBUTE_UNUSED)
586 value |= ((insn >> 0) & 0x003f) << 1;
588 /* Extend the sign. */
589 int signbit = 1 << (7 - 1);
590 value = (value ^ signbit) - signbit;
594 #endif /* EXTRACT_SIMM7_A16_10_S */
596 #ifndef INSERT_SIMM21_A32_5
597 #define INSERT_SIMM21_A32_5
598 /* mask = 00000111111111002222222222000000
599 insn = 00001sssssssss00SSSSSSSSSSNQQQQQ. */
601 insert_simm21_a32_5 (unsigned insn ATTRIBUTE_UNUSED,
602 int value ATTRIBUTE_UNUSED,
603 const char **errmsg ATTRIBUTE_UNUSED)
606 *errmsg = _("Target address is not 32bit aligned.");
608 insn |= ((value >> 2) & 0x01ff) << 18;
609 insn |= ((value >> 11) & 0x03ff) << 6;
613 #endif /* INSERT_SIMM21_A32_5 */
615 #ifndef EXTRACT_SIMM21_A32_5
616 #define EXTRACT_SIMM21_A32_5
617 /* mask = 00000111111111002222222222000000. */
619 extract_simm21_a32_5 (unsigned insn ATTRIBUTE_UNUSED,
620 bfd_boolean * invalid ATTRIBUTE_UNUSED)
624 value |= ((insn >> 18) & 0x01ff) << 2;
625 value |= ((insn >> 6) & 0x03ff) << 11;
627 /* Extend the sign. */
628 int signbit = 1 << (21 - 1);
629 value = (value ^ signbit) - signbit;
633 #endif /* EXTRACT_SIMM21_A32_5 */
635 #ifndef INSERT_SIMM25_A32_5
636 #define INSERT_SIMM25_A32_5
637 /* mask = 00000111111111002222222222003333
638 insn = 00001sssssssss10SSSSSSSSSSNRtttt. */
640 insert_simm25_a32_5 (unsigned insn ATTRIBUTE_UNUSED,
641 int value ATTRIBUTE_UNUSED,
642 const char **errmsg ATTRIBUTE_UNUSED)
645 *errmsg = _("Target address is not 32bit aligned.");
647 insn |= ((value >> 2) & 0x01ff) << 18;
648 insn |= ((value >> 11) & 0x03ff) << 6;
649 insn |= ((value >> 21) & 0x000f) << 0;
653 #endif /* INSERT_SIMM25_A32_5 */
655 #ifndef EXTRACT_SIMM25_A32_5
656 #define EXTRACT_SIMM25_A32_5
657 /* mask = 00000111111111002222222222003333. */
659 extract_simm25_a32_5 (unsigned insn ATTRIBUTE_UNUSED,
660 bfd_boolean * invalid ATTRIBUTE_UNUSED)
664 value |= ((insn >> 18) & 0x01ff) << 2;
665 value |= ((insn >> 6) & 0x03ff) << 11;
666 value |= ((insn >> 0) & 0x000f) << 21;
668 /* Extend the sign. */
669 int signbit = 1 << (25 - 1);
670 value = (value ^ signbit) - signbit;
674 #endif /* EXTRACT_SIMM25_A32_5 */
676 #ifndef INSERT_SIMM13_A32_5_S
677 #define INSERT_SIMM13_A32_5_S
678 /* mask = 0000011111111111
679 insn = 11111sssssssssss. */
681 insert_simm13_a32_5_s (unsigned insn ATTRIBUTE_UNUSED,
682 int value ATTRIBUTE_UNUSED,
683 const char **errmsg ATTRIBUTE_UNUSED)
686 *errmsg = _("Target address is not 32bit aligned.");
688 insn |= ((value >> 2) & 0x07ff) << 0;
692 #endif /* INSERT_SIMM13_A32_5_S */
694 #ifndef EXTRACT_SIMM13_A32_5_S
695 #define EXTRACT_SIMM13_A32_5_S
696 /* mask = 0000011111111111. */
698 extract_simm13_a32_5_s (unsigned insn ATTRIBUTE_UNUSED,
699 bfd_boolean * invalid ATTRIBUTE_UNUSED)
703 value |= ((insn >> 0) & 0x07ff) << 2;
705 /* Extend the sign. */
706 int signbit = 1 << (13 - 1);
707 value = (value ^ signbit) - signbit;
711 #endif /* EXTRACT_SIMM13_A32_5_S */
713 #ifndef INSERT_SIMM8_A16_9_S
714 #define INSERT_SIMM8_A16_9_S
715 /* mask = 0000000001111111
716 insn = 11101bbb1sssssss. */
718 insert_simm8_a16_9_s (unsigned insn ATTRIBUTE_UNUSED,
719 int value ATTRIBUTE_UNUSED,
720 const char **errmsg ATTRIBUTE_UNUSED)
723 *errmsg = _("Target address is not 16bit aligned.");
725 insn |= ((value >> 1) & 0x007f) << 0;
729 #endif /* INSERT_SIMM8_A16_9_S */
731 #ifndef EXTRACT_SIMM8_A16_9_S
732 #define EXTRACT_SIMM8_A16_9_S
733 /* mask = 0000000001111111. */
735 extract_simm8_a16_9_s (unsigned insn ATTRIBUTE_UNUSED,
736 bfd_boolean * invalid ATTRIBUTE_UNUSED)
740 value |= ((insn >> 0) & 0x007f) << 1;
742 /* Extend the sign. */
743 int signbit = 1 << (8 - 1);
744 value = (value ^ signbit) - signbit;
748 #endif /* EXTRACT_SIMM8_A16_9_S */
750 #ifndef INSERT_UIMM3_23
751 #define INSERT_UIMM3_23
752 /* mask = 00000000000000000000000111000000
753 insn = 00100011011011110001RRRuuu111111. */
755 insert_uimm3_23 (unsigned insn ATTRIBUTE_UNUSED,
756 int value ATTRIBUTE_UNUSED,
757 const char **errmsg ATTRIBUTE_UNUSED)
760 insn |= ((value >> 0) & 0x0007) << 6;
764 #endif /* INSERT_UIMM3_23 */
766 #ifndef EXTRACT_UIMM3_23
767 #define EXTRACT_UIMM3_23
768 /* mask = 00000000000000000000000111000000. */
770 extract_uimm3_23 (unsigned insn ATTRIBUTE_UNUSED,
771 bfd_boolean * invalid ATTRIBUTE_UNUSED)
775 value |= ((insn >> 6) & 0x0007) << 0;
779 #endif /* EXTRACT_UIMM3_23 */
781 #ifndef INSERT_UIMM10_6_S
782 #define INSERT_UIMM10_6_S
783 /* mask = 0000001111111111
784 insn = 010111uuuuuuuuuu. */
786 insert_uimm10_6_s (unsigned insn ATTRIBUTE_UNUSED,
787 int value ATTRIBUTE_UNUSED,
788 const char **errmsg ATTRIBUTE_UNUSED)
791 insn |= ((value >> 0) & 0x03ff) << 0;
795 #endif /* INSERT_UIMM10_6_S */
797 #ifndef EXTRACT_UIMM10_6_S
798 #define EXTRACT_UIMM10_6_S
799 /* mask = 0000001111111111. */
801 extract_uimm10_6_s (unsigned insn ATTRIBUTE_UNUSED,
802 bfd_boolean * invalid ATTRIBUTE_UNUSED)
806 value |= ((insn >> 0) & 0x03ff) << 0;
810 #endif /* EXTRACT_UIMM10_6_S */
812 #ifndef INSERT_UIMM6_11_S
813 #define INSERT_UIMM6_11_S
814 /* mask = 0000002200011110
815 insn = 110000UU111uuuu0. */
817 insert_uimm6_11_s (unsigned insn ATTRIBUTE_UNUSED,
818 int value ATTRIBUTE_UNUSED,
819 const char **errmsg ATTRIBUTE_UNUSED)
822 insn |= ((value >> 0) & 0x000f) << 1;
823 insn |= ((value >> 4) & 0x0003) << 8;
827 #endif /* INSERT_UIMM6_11_S */
829 #ifndef EXTRACT_UIMM6_11_S
830 #define EXTRACT_UIMM6_11_S
831 /* mask = 0000002200011110. */
833 extract_uimm6_11_s (unsigned insn ATTRIBUTE_UNUSED,
834 bfd_boolean * invalid ATTRIBUTE_UNUSED)
838 value |= ((insn >> 1) & 0x000f) << 0;
839 value |= ((insn >> 8) & 0x0003) << 4;
843 #endif /* EXTRACT_UIMM6_11_S */
845 #ifndef INSERT_SIMM9_8
846 #define INSERT_SIMM9_8
847 /* mask = 00000000111111112000000000000000
848 insn = 00010bbbssssssssSBBBDaaZZXAAAAAA. */
850 insert_simm9_8 (unsigned insn ATTRIBUTE_UNUSED,
851 int value ATTRIBUTE_UNUSED,
852 const char **errmsg ATTRIBUTE_UNUSED)
855 insn |= ((value >> 0) & 0x00ff) << 16;
856 insn |= ((value >> 8) & 0x0001) << 15;
860 #endif /* INSERT_SIMM9_8 */
862 #ifndef EXTRACT_SIMM9_8
863 #define EXTRACT_SIMM9_8
864 /* mask = 00000000111111112000000000000000. */
866 extract_simm9_8 (unsigned insn ATTRIBUTE_UNUSED,
867 bfd_boolean * invalid ATTRIBUTE_UNUSED)
871 value |= ((insn >> 16) & 0x00ff) << 0;
872 value |= ((insn >> 15) & 0x0001) << 8;
874 /* Extend the sign. */
875 int signbit = 1 << (9 - 1);
876 value = (value ^ signbit) - signbit;
880 #endif /* EXTRACT_SIMM9_8 */
882 #ifndef INSERT_UIMM10_A32_8_S
883 #define INSERT_UIMM10_A32_8_S
884 /* mask = 0000000011111111
885 insn = 11010bbbuuuuuuuu. */
887 insert_uimm10_a32_8_s (unsigned insn ATTRIBUTE_UNUSED,
888 int value ATTRIBUTE_UNUSED,
889 const char **errmsg ATTRIBUTE_UNUSED)
892 *errmsg = _("Target address is not 32bit aligned.");
894 insn |= ((value >> 2) & 0x00ff) << 0;
898 #endif /* INSERT_UIMM10_A32_8_S */
900 #ifndef EXTRACT_UIMM10_A32_8_S
901 #define EXTRACT_UIMM10_A32_8_S
902 /* mask = 0000000011111111. */
904 extract_uimm10_a32_8_s (unsigned insn ATTRIBUTE_UNUSED,
905 bfd_boolean * invalid ATTRIBUTE_UNUSED)
909 value |= ((insn >> 0) & 0x00ff) << 2;
913 #endif /* EXTRACT_UIMM10_A32_8_S */
915 #ifndef INSERT_SIMM9_7_S
916 #define INSERT_SIMM9_7_S
917 /* mask = 0000000111111111
918 insn = 1100101sssssssss. */
920 insert_simm9_7_s (unsigned insn ATTRIBUTE_UNUSED,
921 int value ATTRIBUTE_UNUSED,
922 const char **errmsg ATTRIBUTE_UNUSED)
925 insn |= ((value >> 0) & 0x01ff) << 0;
929 #endif /* INSERT_SIMM9_7_S */
931 #ifndef EXTRACT_SIMM9_7_S
932 #define EXTRACT_SIMM9_7_S
933 /* mask = 0000000111111111. */
935 extract_simm9_7_s (unsigned insn ATTRIBUTE_UNUSED,
936 bfd_boolean * invalid ATTRIBUTE_UNUSED)
940 value |= ((insn >> 0) & 0x01ff) << 0;
942 /* Extend the sign. */
943 int signbit = 1 << (9 - 1);
944 value = (value ^ signbit) - signbit;
948 #endif /* EXTRACT_SIMM9_7_S */
950 #ifndef INSERT_UIMM6_A16_11_S
951 #define INSERT_UIMM6_A16_11_S
952 /* mask = 0000000000011111
953 insn = 10010bbbcccuuuuu. */
955 insert_uimm6_a16_11_s (unsigned insn ATTRIBUTE_UNUSED,
956 int value ATTRIBUTE_UNUSED,
957 const char **errmsg ATTRIBUTE_UNUSED)
960 *errmsg = _("Target address is not 16bit aligned.");
962 insn |= ((value >> 1) & 0x001f) << 0;
966 #endif /* INSERT_UIMM6_A16_11_S */
968 #ifndef EXTRACT_UIMM6_A16_11_S
969 #define EXTRACT_UIMM6_A16_11_S
970 /* mask = 0000000000011111. */
972 extract_uimm6_a16_11_s (unsigned insn ATTRIBUTE_UNUSED,
973 bfd_boolean * invalid ATTRIBUTE_UNUSED)
977 value |= ((insn >> 0) & 0x001f) << 1;
981 #endif /* EXTRACT_UIMM6_A16_11_S */
983 #ifndef INSERT_UIMM5_A32_11_S
984 #define INSERT_UIMM5_A32_11_S
985 /* mask = 0000020000011000
986 insn = 01000U00hhhuu1HH. */
988 insert_uimm5_a32_11_s (unsigned insn ATTRIBUTE_UNUSED,
989 int value ATTRIBUTE_UNUSED,
990 const char **errmsg ATTRIBUTE_UNUSED)
993 *errmsg = _("Target address is not 32bit aligned.");
995 insn |= ((value >> 2) & 0x0003) << 3;
996 insn |= ((value >> 4) & 0x0001) << 10;
1000 #endif /* INSERT_UIMM5_A32_11_S */
1002 #ifndef EXTRACT_UIMM5_A32_11_S
1003 #define EXTRACT_UIMM5_A32_11_S
1004 /* mask = 0000020000011000. */
1006 extract_uimm5_a32_11_s (unsigned insn ATTRIBUTE_UNUSED,
1007 bfd_boolean * invalid ATTRIBUTE_UNUSED)
1011 value |= ((insn >> 3) & 0x0003) << 2;
1012 value |= ((insn >> 10) & 0x0001) << 4;
1016 #endif /* EXTRACT_UIMM5_A32_11_S */
1018 #ifndef INSERT_SIMM11_A32_13_S
1019 #define INSERT_SIMM11_A32_13_S
1020 /* mask = 0000022222200111
1021 insn = 01010SSSSSS00sss. */
1023 insert_simm11_a32_13_s (unsigned insn ATTRIBUTE_UNUSED,
1024 int value ATTRIBUTE_UNUSED,
1025 const char **errmsg ATTRIBUTE_UNUSED)
1028 *errmsg = _("Target address is not 32bit aligned.");
1030 insn |= ((value >> 2) & 0x0007) << 0;
1031 insn |= ((value >> 5) & 0x003f) << 5;
1035 #endif /* INSERT_SIMM11_A32_13_S */
1037 #ifndef EXTRACT_SIMM11_A32_13_S
1038 #define EXTRACT_SIMM11_A32_13_S
1039 /* mask = 0000022222200111. */
1041 extract_simm11_a32_13_s (unsigned insn ATTRIBUTE_UNUSED,
1042 bfd_boolean * invalid ATTRIBUTE_UNUSED)
1046 value |= ((insn >> 0) & 0x0007) << 2;
1047 value |= ((insn >> 5) & 0x003f) << 5;
1049 /* Extend the sign. */
1050 int signbit = 1 << (11 - 1);
1051 value = (value ^ signbit) - signbit;
1055 #endif /* EXTRACT_SIMM11_A32_13_S */
1057 #ifndef INSERT_UIMM7_13_S
1058 #define INSERT_UIMM7_13_S
1059 /* mask = 0000000022220111
1060 insn = 01010bbbUUUU1uuu. */
1062 insert_uimm7_13_s (unsigned insn ATTRIBUTE_UNUSED,
1063 int value ATTRIBUTE_UNUSED,
1064 const char **errmsg ATTRIBUTE_UNUSED)
1067 insn |= ((value >> 0) & 0x0007) << 0;
1068 insn |= ((value >> 3) & 0x000f) << 4;
1072 #endif /* INSERT_UIMM7_13_S */
1074 #ifndef EXTRACT_UIMM7_13_S
1075 #define EXTRACT_UIMM7_13_S
1076 /* mask = 0000000022220111. */
1078 extract_uimm7_13_s (unsigned insn ATTRIBUTE_UNUSED,
1079 bfd_boolean * invalid ATTRIBUTE_UNUSED)
1083 value |= ((insn >> 0) & 0x0007) << 0;
1084 value |= ((insn >> 4) & 0x000f) << 3;
1088 #endif /* EXTRACT_UIMM7_13_S */
1090 #ifndef INSERT_UIMM6_A16_21
1091 #define INSERT_UIMM6_A16_21
1092 /* mask = 00000000000000000000011111000000
1093 insn = 00101bbb01001100RBBBRuuuuuAAAAAA. */
1095 insert_uimm6_a16_21 (unsigned insn ATTRIBUTE_UNUSED,
1096 int value ATTRIBUTE_UNUSED,
1097 const char **errmsg ATTRIBUTE_UNUSED)
1100 *errmsg = _("Target address is not 16bit aligned.");
1102 insn |= ((value >> 1) & 0x001f) << 6;
1106 #endif /* INSERT_UIMM6_A16_21 */
1108 #ifndef EXTRACT_UIMM6_A16_21
1109 #define EXTRACT_UIMM6_A16_21
1110 /* mask = 00000000000000000000011111000000. */
1112 extract_uimm6_a16_21 (unsigned insn ATTRIBUTE_UNUSED,
1113 bfd_boolean * invalid ATTRIBUTE_UNUSED)
1117 value |= ((insn >> 6) & 0x001f) << 1;
1121 #endif /* EXTRACT_UIMM6_A16_21 */
1123 #ifndef INSERT_UIMM7_11_S
1124 #define INSERT_UIMM7_11_S
1125 /* mask = 0000022200011110
1126 insn = 11000UUU110uuuu0. */
1128 insert_uimm7_11_s (unsigned insn ATTRIBUTE_UNUSED,
1129 int value ATTRIBUTE_UNUSED,
1130 const char **errmsg ATTRIBUTE_UNUSED)
1133 insn |= ((value >> 0) & 0x000f) << 1;
1134 insn |= ((value >> 4) & 0x0007) << 8;
1138 #endif /* INSERT_UIMM7_11_S */
1140 #ifndef EXTRACT_UIMM7_11_S
1141 #define EXTRACT_UIMM7_11_S
1142 /* mask = 0000022200011110. */
1144 extract_uimm7_11_s (unsigned insn ATTRIBUTE_UNUSED,
1145 bfd_boolean * invalid ATTRIBUTE_UNUSED)
1149 value |= ((insn >> 1) & 0x000f) << 0;
1150 value |= ((insn >> 8) & 0x0007) << 4;
1154 #endif /* EXTRACT_UIMM7_11_S */
1156 #ifndef INSERT_UIMM7_A16_20
1157 #define INSERT_UIMM7_A16_20
1158 /* mask = 00000000000000000000111111000000
1159 insn = 00100RRR111010000RRRuuuuuu1QQQQQ. */
1161 insert_uimm7_a16_20 (unsigned insn ATTRIBUTE_UNUSED,
1162 int value ATTRIBUTE_UNUSED,
1163 const char **errmsg ATTRIBUTE_UNUSED)
1166 *errmsg = _("Target address is not 16bit aligned.");
1168 insn |= ((value >> 1) & 0x003f) << 6;
1172 #endif /* INSERT_UIMM7_A16_20 */
1174 #ifndef EXTRACT_UIMM7_A16_20
1175 #define EXTRACT_UIMM7_A16_20
1176 /* mask = 00000000000000000000111111000000. */
1178 extract_uimm7_a16_20 (unsigned insn ATTRIBUTE_UNUSED,
1179 bfd_boolean * invalid ATTRIBUTE_UNUSED)
1183 value |= ((insn >> 6) & 0x003f) << 1;
1187 #endif /* EXTRACT_UIMM7_A16_20 */
1189 #ifndef INSERT_SIMM13_A16_20
1190 #define INSERT_SIMM13_A16_20
1191 /* mask = 00000000000000000000111111222222
1192 insn = 00100RRR101010000RRRssssssSSSSSS. */
1194 insert_simm13_a16_20 (unsigned insn ATTRIBUTE_UNUSED,
1195 int value ATTRIBUTE_UNUSED,
1196 const char **errmsg ATTRIBUTE_UNUSED)
1199 *errmsg = _("Target address is not 16bit aligned.");
1201 insn |= ((value >> 1) & 0x003f) << 6;
1202 insn |= ((value >> 7) & 0x003f) << 0;
1206 #endif /* INSERT_SIMM13_A16_20 */
1208 #ifndef EXTRACT_SIMM13_A16_20
1209 #define EXTRACT_SIMM13_A16_20
1210 /* mask = 00000000000000000000111111222222. */
1212 extract_simm13_a16_20 (unsigned insn ATTRIBUTE_UNUSED,
1213 bfd_boolean * invalid ATTRIBUTE_UNUSED)
1217 value |= ((insn >> 6) & 0x003f) << 1;
1218 value |= ((insn >> 0) & 0x003f) << 7;
1220 /* Extend the sign. */
1221 int signbit = 1 << (13 - 1);
1222 value = (value ^ signbit) - signbit;
1226 #endif /* EXTRACT_SIMM13_A16_20 */
1228 #ifndef INSERT_UIMM8_8_S
1229 #define INSERT_UIMM8_8_S
1230 /* mask = 0000000011111111
1231 insn = 11011bbbuuuuuuuu. */
1233 insert_uimm8_8_s (unsigned insn ATTRIBUTE_UNUSED,
1234 int value ATTRIBUTE_UNUSED,
1235 const char **errmsg ATTRIBUTE_UNUSED)
1238 insn |= ((value >> 0) & 0x00ff) << 0;
1242 #endif /* INSERT_UIMM8_8_S */
1244 #ifndef EXTRACT_UIMM8_8_S
1245 #define EXTRACT_UIMM8_8_S
1246 /* mask = 0000000011111111. */
1248 extract_uimm8_8_s (unsigned insn ATTRIBUTE_UNUSED,
1249 bfd_boolean * invalid ATTRIBUTE_UNUSED)
1253 value |= ((insn >> 0) & 0x00ff) << 0;
1257 #endif /* EXTRACT_UIMM8_8_S */
1259 #ifndef INSERT_UIMM6_5_S
1260 #define INSERT_UIMM6_5_S
1261 /* mask = 0000011111100000
1262 insn = 01111uuuuuu11111. */
1264 insert_uimm6_5_s (unsigned insn ATTRIBUTE_UNUSED,
1265 int value ATTRIBUTE_UNUSED,
1266 const char **errmsg ATTRIBUTE_UNUSED)
1269 insn |= ((value >> 0) & 0x003f) << 5;
1273 #endif /* INSERT_UIMM6_5_S */
1275 #ifndef EXTRACT_UIMM6_5_S
1276 #define EXTRACT_UIMM6_5_S
1277 /* mask = 0000011111100000. */
1279 extract_uimm6_5_s (unsigned insn ATTRIBUTE_UNUSED,
1280 bfd_boolean * invalid ATTRIBUTE_UNUSED)
1284 value |= ((insn >> 5) & 0x003f) << 0;
1288 #endif /* EXTRACT_UIMM6_5_S */
1290 #ifndef INSERT_UIMM6_AXX_
1291 #define INSERT_UIMM6_AXX_
1292 /* mask = 00000000000000000000000000000000
1293 insn = 00110bbb11100001100001100001QQQQ. */
1294 static ATTRIBUTE_UNUSED unsigned
1295 insert_uimm6_axx_ (unsigned insn ATTRIBUTE_UNUSED,
1296 int value ATTRIBUTE_UNUSED,
1297 const char **errmsg ATTRIBUTE_UNUSED)
1300 *errmsg = _("Target address is not 512bit aligned.");
1304 #endif /* INSERT_UIMM6_AXX_ */
1306 #ifndef EXTRACT_UIMM6_AXX_
1307 #define EXTRACT_UIMM6_AXX_
1308 /* mask = 00000000000000000000000000000000. */
1309 static ATTRIBUTE_UNUSED int
1310 extract_uimm6_axx_ (unsigned insn ATTRIBUTE_UNUSED,
1311 bfd_boolean * invalid ATTRIBUTE_UNUSED)
1317 #endif /* EXTRACT_UIMM6_AXX_ */