1 /* Insert/extract functions for the ARC opcodes.
2 Copyright (C) 2015-2021 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. */
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
)
34 #endif /* INSERT_LIMM */
38 /* mask = 00000000000000000000000000000000. */
39 static ATTRIBUTE_UNUSED
int
40 extract_limm (unsigned long long insn ATTRIBUTE_UNUSED
,
41 bool *invalid ATTRIBUTE_UNUSED
)
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;
63 #endif /* INSERT_UIMM6_20 */
65 #ifndef EXTRACT_UIMM6_20
66 #define EXTRACT_UIMM6_20
67 /* mask = 00000000000000000000111111000000. */
69 extract_uimm6_20 (unsigned long long insn ATTRIBUTE_UNUSED
,
70 bool *invalid ATTRIBUTE_UNUSED
)
74 value
|= ((insn
>> 6) & 0x003f) << 0;
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;
95 #endif /* INSERT_SIMM12_20 */
97 #ifndef EXTRACT_SIMM12_20
98 #define EXTRACT_SIMM12_20
99 /* mask = 00000000000000000000111111222222. */
101 extract_simm12_20 (unsigned long long insn ATTRIBUTE_UNUSED
,
102 bool *invalid ATTRIBUTE_UNUSED
)
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
;
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;
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
)
142 value
|= ((insn
>> 8) & 0x0007) << 0;
144 /* Extend the sign. */
145 int signbit
= 1 << (3 - 1);
146 value
= (value
^ signbit
) - signbit
;
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
)
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
)
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
)
189 *errmsg
= _("Target address is not 32bit aligned.");
191 insn
|= ((value
>> 2) & 0x001f) << 0;
195 #endif /* INSERT_UIMM7_A32_11_S */
197 #ifndef EXTRACT_UIMM7_A32_11_S
198 #define EXTRACT_UIMM7_A32_11_S
199 /* mask = 0000000000011111. */
201 extract_uimm7_a32_11_s (unsigned long long insn ATTRIBUTE_UNUSED
,
202 bool *invalid ATTRIBUTE_UNUSED
)
206 value
|= ((insn
>> 0) & 0x001f) << 2;
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;
226 #endif /* INSERT_UIMM7_9_S */
228 #ifndef EXTRACT_UIMM7_9_S
229 #define EXTRACT_UIMM7_9_S
230 /* mask = 0000000001111111. */
232 extract_uimm7_9_s (unsigned long long insn ATTRIBUTE_UNUSED
,
233 bool *invalid ATTRIBUTE_UNUSED
)
237 value
|= ((insn
>> 0) & 0x007f) << 0;
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;
257 #endif /* INSERT_UIMM3_13_S */
259 #ifndef EXTRACT_UIMM3_13_S
260 #define EXTRACT_UIMM3_13_S
261 /* mask = 0000000000000111. */
263 extract_uimm3_13_s (unsigned long long insn ATTRIBUTE_UNUSED
,
264 bool *invalid ATTRIBUTE_UNUSED
)
268 value
|= ((insn
>> 0) & 0x0007) << 0;
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
)
284 *errmsg
= _("Target address is not 32bit aligned.");
286 insn
|= ((value
>> 2) & 0x01ff) << 0;
290 #endif /* INSERT_SIMM11_A32_7_S */
292 #ifndef EXTRACT_SIMM11_A32_7_S
293 #define EXTRACT_SIMM11_A32_7_S
294 /* mask = 0000000111111111. */
296 extract_simm11_a32_7_s (unsigned long long insn ATTRIBUTE_UNUSED
,
297 bool *invalid ATTRIBUTE_UNUSED
)
301 value
|= ((insn
>> 0) & 0x01ff) << 2;
303 /* Extend the sign. */
304 int signbit
= 1 << (11 - 1);
305 value
= (value
^ signbit
) - signbit
;
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;
326 #endif /* INSERT_UIMM6_13_S */
328 #ifndef EXTRACT_UIMM6_13_S
329 #define EXTRACT_UIMM6_13_S
330 /* mask = 0000000002220111. */
332 extract_uimm6_13_s (unsigned long long insn ATTRIBUTE_UNUSED
,
333 bool *invalid ATTRIBUTE_UNUSED
)
337 value
|= ((insn
>> 0) & 0x0007) << 0;
338 value
|= ((insn
>> 4) & 0x0007) << 3;
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;
358 #endif /* INSERT_UIMM5_11_S */
360 #ifndef EXTRACT_UIMM5_11_S
361 #define EXTRACT_UIMM5_11_S
362 /* mask = 0000000000011111. */
364 extract_uimm5_11_s (unsigned long long insn ATTRIBUTE_UNUSED
,
365 bool *invalid ATTRIBUTE_UNUSED
)
369 value
|= ((insn
>> 0) & 0x001f) << 0;
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
)
385 *errmsg
= _("Target address is not 16bit aligned.");
387 insn
|= ((value
>> 1) & 0x007f) << 17;
388 insn
|= ((value
>> 8) & 0x0001) << 15;
392 #endif /* INSERT_SIMM9_A16_8 */
394 #ifndef EXTRACT_SIMM9_A16_8
395 #define EXTRACT_SIMM9_A16_8
396 /* mask = 00000000111111102000000000000000. */
398 extract_simm9_a16_8 (unsigned long long insn ATTRIBUTE_UNUSED
,
399 bool *invalid ATTRIBUTE_UNUSED
)
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
;
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;
428 #endif /* INSERT_UIMM6_8 */
430 #ifndef EXTRACT_UIMM6_8
431 #define EXTRACT_UIMM6_8
432 /* mask = 00000000000000000000111111000000. */
434 extract_uimm6_8 (unsigned long long insn ATTRIBUTE_UNUSED
,
435 bool *invalid ATTRIBUTE_UNUSED
)
439 value
|= ((insn
>> 6) & 0x003f) << 0;
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
)
455 *errmsg
= _("Target address is not 16bit aligned.");
457 insn
|= ((value
>> 1) & 0x03ff) << 17;
458 insn
|= ((value
>> 11) & 0x03ff) << 6;
462 #endif /* INSERT_SIMM21_A16_5 */
464 #ifndef EXTRACT_SIMM21_A16_5
465 #define EXTRACT_SIMM21_A16_5
466 /* mask = 00000111111111102222222222000000. */
468 extract_simm21_a16_5 (unsigned long long insn ATTRIBUTE_UNUSED
,
469 bool *invalid ATTRIBUTE_UNUSED
)
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
;
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
)
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;
502 #endif /* INSERT_SIMM25_A16_5 */
504 #ifndef EXTRACT_SIMM25_A16_5
505 #define EXTRACT_SIMM25_A16_5
506 /* mask = 00000111111111102222222222003333. */
508 extract_simm25_a16_5 (unsigned long long insn ATTRIBUTE_UNUSED
,
509 bool *invalid ATTRIBUTE_UNUSED
)
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
;
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
)
535 *errmsg
= _("Target address is not 16bit aligned.");
537 insn
|= ((value
>> 1) & 0x01ff) << 0;
541 #endif /* INSERT_SIMM10_A16_7_S */
543 #ifndef EXTRACT_SIMM10_A16_7_S
544 #define EXTRACT_SIMM10_A16_7_S
545 /* mask = 0000000111111111. */
547 extract_simm10_a16_7_s (unsigned long long insn ATTRIBUTE_UNUSED
,
548 bool *invalid ATTRIBUTE_UNUSED
)
552 value
|= ((insn
>> 0) & 0x01ff) << 1;
554 /* Extend the sign. */
555 int signbit
= 1 << (10 - 1);
556 value
= (value
^ signbit
) - signbit
;
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
)
572 *errmsg
= _("Target address is not 16bit aligned.");
574 insn
|= ((value
>> 1) & 0x003f) << 0;
578 #endif /* INSERT_SIMM7_A16_10_S */
580 #ifndef EXTRACT_SIMM7_A16_10_S
581 #define EXTRACT_SIMM7_A16_10_S
582 /* mask = 0000000000111111. */
584 extract_simm7_a16_10_s (unsigned long long insn ATTRIBUTE_UNUSED
,
585 bool *invalid ATTRIBUTE_UNUSED
)
589 value
|= ((insn
>> 0) & 0x003f) << 1;
591 /* Extend the sign. */
592 int signbit
= 1 << (7 - 1);
593 value
= (value
^ signbit
) - signbit
;
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
)
609 *errmsg
= _("Target address is not 32bit aligned.");
611 insn
|= ((value
>> 2) & 0x01ff) << 18;
612 insn
|= ((value
>> 11) & 0x03ff) << 6;
616 #endif /* INSERT_SIMM21_A32_5 */
618 #ifndef EXTRACT_SIMM21_A32_5
619 #define EXTRACT_SIMM21_A32_5
620 /* mask = 00000111111111002222222222000000. */
622 extract_simm21_a32_5 (unsigned long long insn ATTRIBUTE_UNUSED
,
623 bool *invalid ATTRIBUTE_UNUSED
)
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
;
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
)
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;
656 #endif /* INSERT_SIMM25_A32_5 */
658 #ifndef EXTRACT_SIMM25_A32_5
659 #define EXTRACT_SIMM25_A32_5
660 /* mask = 00000111111111002222222222003333. */
662 extract_simm25_a32_5 (unsigned long long insn ATTRIBUTE_UNUSED
,
663 bool *invalid ATTRIBUTE_UNUSED
)
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
;
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
)
689 *errmsg
= _("Target address is not 32bit aligned.");
691 insn
|= ((value
>> 2) & 0x07ff) << 0;
695 #endif /* INSERT_SIMM13_A32_5_S */
697 #ifndef EXTRACT_SIMM13_A32_5_S
698 #define EXTRACT_SIMM13_A32_5_S
699 /* mask = 0000011111111111. */
701 extract_simm13_a32_5_s (unsigned long long insn ATTRIBUTE_UNUSED
,
702 bool *invalid ATTRIBUTE_UNUSED
)
706 value
|= ((insn
>> 0) & 0x07ff) << 2;
708 /* Extend the sign. */
709 int signbit
= 1 << (13 - 1);
710 value
= (value
^ signbit
) - signbit
;
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
)
726 *errmsg
= _("Target address is not 16bit aligned.");
728 insn
|= ((value
>> 1) & 0x007f) << 0;
732 #endif /* INSERT_SIMM8_A16_9_S */
734 #ifndef EXTRACT_SIMM8_A16_9_S
735 #define EXTRACT_SIMM8_A16_9_S
736 /* mask = 0000000001111111. */
738 extract_simm8_a16_9_s (unsigned long long insn ATTRIBUTE_UNUSED
,
739 bool *invalid ATTRIBUTE_UNUSED
)
743 value
|= ((insn
>> 0) & 0x007f) << 1;
745 /* Extend the sign. */
746 int signbit
= 1 << (8 - 1);
747 value
= (value
^ signbit
) - signbit
;
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;
767 #endif /* INSERT_UIMM3_23 */
769 #ifndef EXTRACT_UIMM3_23
770 #define EXTRACT_UIMM3_23
771 /* mask = 00000000000000000000000111000000. */
773 extract_uimm3_23 (unsigned long long insn ATTRIBUTE_UNUSED
,
774 bool *invalid ATTRIBUTE_UNUSED
)
778 value
|= ((insn
>> 6) & 0x0007) << 0;
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;
798 #endif /* INSERT_UIMM10_6_S */
800 #ifndef EXTRACT_UIMM10_6_S
801 #define EXTRACT_UIMM10_6_S
802 /* mask = 0000001111111111. */
804 extract_uimm10_6_s (unsigned long long insn ATTRIBUTE_UNUSED
,
805 bool *invalid ATTRIBUTE_UNUSED
)
809 value
|= ((insn
>> 0) & 0x03ff) << 0;
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;
830 #endif /* INSERT_UIMM6_11_S */
832 #ifndef EXTRACT_UIMM6_11_S
833 #define EXTRACT_UIMM6_11_S
834 /* mask = 0000002200011110. */
836 extract_uimm6_11_s (unsigned long long insn ATTRIBUTE_UNUSED
,
837 bool *invalid ATTRIBUTE_UNUSED
)
841 value
|= ((insn
>> 1) & 0x000f) << 0;
842 value
|= ((insn
>> 8) & 0x0003) << 4;
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;
863 #endif /* INSERT_SIMM9_8 */
865 #ifndef EXTRACT_SIMM9_8
866 #define EXTRACT_SIMM9_8
867 /* mask = 00000000111111112000000000000000. */
869 extract_simm9_8 (unsigned long long insn ATTRIBUTE_UNUSED
,
870 bool *invalid ATTRIBUTE_UNUSED
)
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
;
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
)
895 *errmsg
= _("Target address is not 32bit aligned.");
897 insn
|= ((value
>> 2) & 0x00ff) << 0;
901 #endif /* INSERT_UIMM10_A32_8_S */
903 #ifndef EXTRACT_UIMM10_A32_8_S
904 #define EXTRACT_UIMM10_A32_8_S
905 /* mask = 0000000011111111. */
907 extract_uimm10_a32_8_s (unsigned long long insn ATTRIBUTE_UNUSED
,
908 bool *invalid ATTRIBUTE_UNUSED
)
912 value
|= ((insn
>> 0) & 0x00ff) << 2;
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;
932 #endif /* INSERT_SIMM9_7_S */
934 #ifndef EXTRACT_SIMM9_7_S
935 #define EXTRACT_SIMM9_7_S
936 /* mask = 0000000111111111. */
938 extract_simm9_7_s (unsigned long long insn ATTRIBUTE_UNUSED
,
939 bool *invalid ATTRIBUTE_UNUSED
)
943 value
|= ((insn
>> 0) & 0x01ff) << 0;
945 /* Extend the sign. */
946 int signbit
= 1 << (9 - 1);
947 value
= (value
^ signbit
) - signbit
;
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
)
963 *errmsg
= _("Target address is not 16bit aligned.");
965 insn
|= ((value
>> 1) & 0x001f) << 0;
969 #endif /* INSERT_UIMM6_A16_11_S */
971 #ifndef EXTRACT_UIMM6_A16_11_S
972 #define EXTRACT_UIMM6_A16_11_S
973 /* mask = 0000000000011111. */
975 extract_uimm6_a16_11_s (unsigned long long insn ATTRIBUTE_UNUSED
,
976 bool *invalid ATTRIBUTE_UNUSED
)
980 value
|= ((insn
>> 0) & 0x001f) << 1;
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
)
996 *errmsg
= _("Target address is not 32bit aligned.");
998 insn
|= ((value
>> 2) & 0x0003) << 3;
999 insn
|= ((value
>> 4) & 0x0001) << 10;
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
)
1014 value
|= ((insn
>> 3) & 0x0003) << 2;
1015 value
|= ((insn
>> 10) & 0x0001) << 4;
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
)
1031 *errmsg
= _("Target address is not 32bit aligned.");
1033 insn
|= ((value
>> 2) & 0x0007) << 0;
1034 insn
|= ((value
>> 5) & 0x003f) << 5;
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
)
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
;
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;
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
)
1086 value
|= ((insn
>> 0) & 0x0007) << 0;
1087 value
|= ((insn
>> 4) & 0x000f) << 3;
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
)
1103 *errmsg
= _("Target address is not 16bit aligned.");
1105 insn
|= ((value
>> 1) & 0x001f) << 6;
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
)
1120 value
|= ((insn
>> 6) & 0x001f) << 1;
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;
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
)
1152 value
|= ((insn
>> 1) & 0x000f) << 0;
1153 value
|= ((insn
>> 8) & 0x0007) << 4;
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
)
1169 *errmsg
= _("Target address is not 16bit aligned.");
1171 insn
|= ((value
>> 1) & 0x003f) << 6;
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
)
1186 value
|= ((insn
>> 6) & 0x003f) << 1;
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
)
1202 *errmsg
= _("Target address is not 16bit aligned.");
1204 insn
|= ((value
>> 1) & 0x003f) << 6;
1205 insn
|= ((value
>> 7) & 0x003f) << 0;
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
)
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
;
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;
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
)
1256 value
|= ((insn
>> 0) & 0x00ff) << 0;
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;
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
)
1287 value
|= ((insn
>> 5) & 0x003f) << 0;
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
)
1303 *errmsg
= _("Target address is not 512bit aligned.");
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
)
1320 #endif /* EXTRACT_UIMM6_AXX_ */