1 /* Assembler interface for targets using CGEN. -*- C -*-
2 CGEN: Cpu tools GENerator
4 THIS FILE IS MACHINE GENERATED WITH CGEN.
5 - the resultant file is machine generated, cgen-asm.in isn't
7 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005, 2007, 2008
8 Free Software Foundation, Inc.
10 This file is part of libopcodes.
12 This library is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 3, or (at your option)
17 It is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
20 License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software Foundation, Inc.,
24 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
27 /* ??? Eventually more and more of this stuff can go to cpu-independent files.
35 #include "m32c-desc.h"
39 #include "libiberty.h"
40 #include "safe-ctype.h"
43 #define min(a,b) ((a) < (b) ? (a) : (b))
45 #define max(a,b) ((a) > (b) ? (a) : (b))
47 static const char * parse_insn_normal
48 (CGEN_CPU_DESC
, const CGEN_INSN
*, const char **, CGEN_FIELDS
*);
50 /* -- assembler routines inserted here. */
53 #include "safe-ctype.h"
55 #define MACH_M32C 5 /* Must match md_begin. */
58 m32c_cgen_isa_register (const char **strp
)
61 const char *s
= *strp
;
62 static char * m32c_register_names
[] =
64 "r0", "r1", "r2", "r3", "r0l", "r0h", "r1l", "r1h",
65 "a0", "a1", "r2r0", "r3r1", "sp", "fb", "dct0", "dct1", "flg", "svf",
66 "drc0", "drc1", "dmd0", "dmd1", "intb", "svp", "vct", "isp", "dma0",
67 "dma1", "dra0", "dra1", "dsa0", "dsa1", 0
70 for (u
= 0; m32c_register_names
[u
]; u
++)
72 int len
= strlen (m32c_register_names
[u
]);
74 if (memcmp (m32c_register_names
[u
], s
, len
) == 0
75 && (s
[len
] == 0 || ! ISALNUM (s
[len
])))
81 #define PARSE_UNSIGNED \
84 /* Don't successfully parse literals beginning with '['. */ \
86 return "Invalid literal"; /* Anything -- will not be seen. */ \
88 errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, & value);\
94 #define PARSE_SIGNED \
97 /* Don't successfully parse literals beginning with '['. */ \
99 return "Invalid literal"; /* Anything -- will not be seen. */ \
101 errmsg = cgen_parse_signed_integer (cd, strp, opindex, & value); \
108 parse_unsigned6 (CGEN_CPU_DESC cd
, const char **strp
,
109 int opindex
, unsigned long *valuep
)
111 const char *errmsg
= 0;
117 return _("imm:6 immediate is out of range");
124 parse_unsigned8 (CGEN_CPU_DESC cd
, const char **strp
,
125 int opindex
, unsigned long *valuep
)
127 const char *errmsg
= 0;
131 if (strncasecmp (*strp
, "%dsp8(", 6) == 0)
133 enum cgen_parse_operand_result result_type
;
138 errmsg
= cgen_parse_address (cd
, strp
, opindex
, BFD_RELOC_8
,
139 & result_type
, & value
);
141 return _("missing `)'");
145 && result_type
== CGEN_PARSE_OPERAND_RESULT_NUMBER
)
147 return _("%dsp8() takes a symbolic address, not a number");
153 if (strncmp (*strp
, "0x0", 3) == 0
154 || (**strp
== '0' && *(*strp
+ 1) != 'x'))
160 return _("dsp:8 immediate is out of range");
162 /* If this field may require a relocation then use larger dsp16. */
163 if (! have_zero
&& value
== 0)
164 return _("dsp:8 immediate is out of range");
171 parse_signed4 (CGEN_CPU_DESC cd
, const char **strp
,
172 int opindex
, signed long *valuep
)
174 const char *errmsg
= 0;
178 if (strncmp (*strp
, "0x0", 3) == 0
179 || (**strp
== '0' && *(*strp
+ 1) != 'x'))
184 if (value
< -8 || value
> 7)
185 return _("Immediate is out of range -8 to 7");
187 /* If this field may require a relocation then use larger dsp16. */
188 if (! have_zero
&& value
== 0)
189 return _("Immediate is out of range -8 to 7");
196 parse_signed4n (CGEN_CPU_DESC cd
, const char **strp
,
197 int opindex
, signed long *valuep
)
199 const char *errmsg
= 0;
203 if (strncmp (*strp
, "0x0", 3) == 0
204 || (**strp
== '0' && *(*strp
+ 1) != 'x'))
209 if (value
< -7 || value
> 8)
210 return _("Immediate is out of range -7 to 8");
212 /* If this field may require a relocation then use larger dsp16. */
213 if (! have_zero
&& value
== 0)
214 return _("Immediate is out of range -7 to 8");
221 parse_signed8 (CGEN_CPU_DESC cd
, const char **strp
,
222 int opindex
, signed long *valuep
)
224 const char *errmsg
= 0;
227 if (strncasecmp (*strp
, "%hi8(", 5) == 0)
229 enum cgen_parse_operand_result result_type
;
234 errmsg
= cgen_parse_address (cd
, strp
, opindex
, BFD_RELOC_M32C_HI8
,
235 & result_type
, & value
);
237 return _("missing `)'");
241 && result_type
== CGEN_PARSE_OPERAND_RESULT_NUMBER
)
251 if (value
<= 255 && value
> 127)
254 if (value
< -128 || value
> 127)
255 return _("dsp:8 immediate is out of range");
262 parse_unsigned16 (CGEN_CPU_DESC cd
, const char **strp
,
263 int opindex
, unsigned long *valuep
)
265 const char *errmsg
= 0;
269 if (strncasecmp (*strp
, "%dsp16(", 7) == 0)
271 enum cgen_parse_operand_result result_type
;
276 errmsg
= cgen_parse_address (cd
, strp
, opindex
, BFD_RELOC_16
,
277 & result_type
, & value
);
279 return _("missing `)'");
283 && result_type
== CGEN_PARSE_OPERAND_RESULT_NUMBER
)
285 return _("%dsp16() takes a symbolic address, not a number");
291 /* Don't successfully parse literals beginning with '['. */
293 return "Invalid literal"; /* Anything -- will not be seen. */
295 /* Don't successfully parse register names. */
296 if (m32c_cgen_isa_register (strp
))
297 return "Invalid literal"; /* Anything -- will not be seen. */
299 if (strncmp (*strp
, "0x0", 3) == 0
300 || (**strp
== '0' && *(*strp
+ 1) != 'x'))
303 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, opindex
, & value
);
308 return _("dsp:16 immediate is out of range");
310 /* If this field may require a relocation then use larger dsp24. */
311 if (cd
->machs
== MACH_M32C
&& ! have_zero
&& value
== 0
312 && (strncmp (*strp
, "[a", 2) == 0
315 return _("dsp:16 immediate is out of range");
322 parse_signed16 (CGEN_CPU_DESC cd
, const char **strp
,
323 int opindex
, signed long *valuep
)
325 const char *errmsg
= 0;
328 if (strncasecmp (*strp
, "%lo16(", 6) == 0)
330 enum cgen_parse_operand_result result_type
;
335 errmsg
= cgen_parse_address (cd
, strp
, opindex
, BFD_RELOC_LO16
,
336 & result_type
, & value
);
338 return _("missing `)'");
342 && result_type
== CGEN_PARSE_OPERAND_RESULT_NUMBER
)
350 if (strncasecmp (*strp
, "%hi16(", 6) == 0)
352 enum cgen_parse_operand_result result_type
;
357 errmsg
= cgen_parse_address (cd
, strp
, opindex
, BFD_RELOC_HI16
,
358 & result_type
, & value
);
360 return _("missing `)'");
364 && result_type
== CGEN_PARSE_OPERAND_RESULT_NUMBER
)
374 if (value
<= 65535 && value
> 32767)
377 if (value
< -32768 || value
> 32767)
378 return _("dsp:16 immediate is out of range");
385 parse_unsigned20 (CGEN_CPU_DESC cd
, const char **strp
,
386 int opindex
, unsigned long *valuep
)
388 const char *errmsg
= 0;
391 /* Don't successfully parse literals beginning with '['. */
393 return "Invalid literal"; /* Anything -- will not be seen. */
395 /* Don't successfully parse register names. */
396 if (m32c_cgen_isa_register (strp
))
397 return "Invalid literal"; /* Anything -- will not be seen. */
399 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, opindex
, & value
);
404 return _("dsp:20 immediate is out of range");
411 parse_unsigned24 (CGEN_CPU_DESC cd
, const char **strp
,
412 int opindex
, unsigned long *valuep
)
414 const char *errmsg
= 0;
417 /* Don't successfully parse literals beginning with '['. */
419 return "Invalid literal"; /* Anything -- will not be seen. */
421 /* Don't successfully parse register names. */
422 if (m32c_cgen_isa_register (strp
))
423 return "Invalid literal"; /* Anything -- will not be seen. */
425 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, opindex
, & value
);
429 if (value
> 0xffffff)
430 return _("dsp:24 immediate is out of range");
436 /* This should only be used for #imm->reg. */
438 parse_signed24 (CGEN_CPU_DESC cd
, const char **strp
,
439 int opindex
, signed long *valuep
)
441 const char *errmsg
= 0;
446 if (value
<= 0xffffff && value
> 0x7fffff)
449 if (value
> 0xffffff)
450 return _("dsp:24 immediate is out of range");
457 parse_signed32 (CGEN_CPU_DESC cd
, const char **strp
,
458 int opindex
, signed long *valuep
)
460 const char *errmsg
= 0;
463 errmsg
= cgen_parse_signed_integer (cd
, strp
, opindex
, & value
);
472 parse_imm1_S (CGEN_CPU_DESC cd
, const char **strp
,
473 int opindex
, signed long *valuep
)
475 const char *errmsg
= 0;
478 errmsg
= cgen_parse_signed_integer (cd
, strp
, opindex
, & value
);
482 if (value
< 1 || value
> 2)
483 return _("immediate is out of range 1-2");
490 parse_imm3_S (CGEN_CPU_DESC cd
, const char **strp
,
491 int opindex
, signed long *valuep
)
493 const char *errmsg
= 0;
496 errmsg
= cgen_parse_signed_integer (cd
, strp
, opindex
, & value
);
500 if (value
< 1 || value
> 8)
501 return _("immediate is out of range 1-8");
508 parse_bit3_S (CGEN_CPU_DESC cd
, const char **strp
,
509 int opindex
, signed long *valuep
)
511 const char *errmsg
= 0;
514 errmsg
= cgen_parse_signed_integer (cd
, strp
, opindex
, & value
);
518 if (value
< 0 || value
> 7)
519 return _("immediate is out of range 0-7");
526 parse_lab_5_3 (CGEN_CPU_DESC cd
,
528 int opindex ATTRIBUTE_UNUSED
,
530 enum cgen_parse_operand_result
*type_addr
,
533 const char *errmsg
= 0;
535 enum cgen_parse_operand_result op_res
;
537 errmsg
= cgen_parse_address (cd
, strp
, M32C_OPERAND_LAB_5_3
,
538 opinfo
, & op_res
, & value
);
543 if (op_res
== CGEN_PARSE_OPERAND_ADDRESS
)
545 /* This is a hack; the field cannot handle near-zero signed
546 offsets that CGEN wants to put in to indicate an "empty"
554 if (value
< 2 || value
> 9)
555 return _("immediate is out of range 2-9");
562 parse_Bitno16R (CGEN_CPU_DESC cd
, const char **strp
,
563 int opindex
, unsigned long *valuep
)
565 const char *errmsg
= 0;
568 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, opindex
, & value
);
573 return _("Bit number for indexing general register is out of range 0-15");
580 parse_unsigned_bitbase (CGEN_CPU_DESC cd
, const char **strp
,
581 int opindex
, unsigned long *valuep
,
582 unsigned bits
, int allow_syms
)
584 const char *errmsg
= 0;
587 const char *newp
= *strp
;
588 unsigned long long bitbase
;
591 errmsg
= cgen_parse_unsigned_integer (cd
, & newp
, opindex
, & bit
);
596 return "Missing base for bit,base:8";
600 if (strncmp (newp
, "0x0", 3) == 0
601 || (newp
[0] == '0' && newp
[1] != 'x'))
604 errmsg
= cgen_parse_unsigned_integer (cd
, & newp
, opindex
, & base
);
608 bitbase
= (unsigned long long) bit
+ ((unsigned long long) base
* 8);
610 if (bitbase
>= (1ull << bits
))
611 return _("bit,base is out of range");
613 /* If this field may require a relocation then use larger displacement. */
614 if (! have_zero
&& base
== 0)
616 switch (allow_syms
) {
618 return _("bit,base out of range for symbol");
622 if (strncmp (newp
, "[sb]", 4) != 0)
623 return _("bit,base out of range for symbol");
634 parse_signed_bitbase (CGEN_CPU_DESC cd
, const char **strp
,
635 int opindex
, signed long *valuep
,
636 unsigned bits
, int allow_syms
)
638 const char *errmsg
= 0;
641 const char *newp
= *strp
;
646 errmsg
= cgen_parse_unsigned_integer (cd
, & newp
, opindex
, & bit
);
651 return "Missing base for bit,base:8";
655 if (strncmp (newp
, "0x0", 3) == 0
656 || (newp
[0] == '0' && newp
[1] != 'x'))
659 errmsg
= cgen_parse_signed_integer (cd
, & newp
, opindex
, & base
);
663 bitbase
= (long long)bit
+ ((long long)base
* 8);
665 limit
= 1ll << (bits
- 1);
666 if (bitbase
< -limit
|| bitbase
>= limit
)
667 return _("bit,base is out of range");
669 /* If this field may require a relocation then use larger displacement. */
670 if (! have_zero
&& base
== 0 && ! allow_syms
)
671 return _("bit,base out of range for symbol");
679 parse_unsigned_bitbase8 (CGEN_CPU_DESC cd
, const char **strp
,
680 int opindex
, unsigned long *valuep
)
682 return parse_unsigned_bitbase (cd
, strp
, opindex
, valuep
, 8, 0);
686 parse_unsigned_bitbase11 (CGEN_CPU_DESC cd
, const char **strp
,
687 int opindex
, unsigned long *valuep
)
689 return parse_unsigned_bitbase (cd
, strp
, opindex
, valuep
, 11, 0);
693 parse_unsigned_bitbase16 (CGEN_CPU_DESC cd
, const char **strp
,
694 int opindex
, unsigned long *valuep
)
696 return parse_unsigned_bitbase (cd
, strp
, opindex
, valuep
, 16, 1);
700 parse_unsigned_bitbase19 (CGEN_CPU_DESC cd
, const char **strp
,
701 int opindex
, unsigned long *valuep
)
703 return parse_unsigned_bitbase (cd
, strp
, opindex
, valuep
, 19, 2);
707 parse_unsigned_bitbase27 (CGEN_CPU_DESC cd
, const char **strp
,
708 int opindex
, unsigned long *valuep
)
710 return parse_unsigned_bitbase (cd
, strp
, opindex
, valuep
, 27, 1);
714 parse_signed_bitbase8 (CGEN_CPU_DESC cd
, const char **strp
,
715 int opindex
, signed long *valuep
)
717 return parse_signed_bitbase (cd
, strp
, opindex
, valuep
, 8, 1);
721 parse_signed_bitbase11 (CGEN_CPU_DESC cd
, const char **strp
,
722 int opindex
, signed long *valuep
)
724 return parse_signed_bitbase (cd
, strp
, opindex
, valuep
, 11, 0);
728 parse_signed_bitbase19 (CGEN_CPU_DESC cd
, const char **strp
,
729 int opindex
, signed long *valuep
)
731 return parse_signed_bitbase (cd
, strp
, opindex
, valuep
, 19, 1);
734 /* Parse the suffix as :<char> or as nothing followed by a whitespace. */
737 parse_suffix (const char **strp
, char suffix
)
739 const char *newp
= *strp
;
741 if (**strp
== ':' && TOLOWER (*(*strp
+ 1)) == suffix
)
750 return "Invalid suffix"; /* Anything -- will not be seen. */
754 parse_S (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
, const char **strp
,
755 int opindex ATTRIBUTE_UNUSED
, signed long *valuep ATTRIBUTE_UNUSED
)
757 return parse_suffix (strp
, 's');
761 parse_G (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
, const char **strp
,
762 int opindex ATTRIBUTE_UNUSED
, signed long *valuep ATTRIBUTE_UNUSED
)
764 return parse_suffix (strp
, 'g');
768 parse_Q (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
, const char **strp
,
769 int opindex ATTRIBUTE_UNUSED
, signed long *valuep ATTRIBUTE_UNUSED
)
771 return parse_suffix (strp
, 'q');
775 parse_Z (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
, const char **strp
,
776 int opindex ATTRIBUTE_UNUSED
, signed long *valuep ATTRIBUTE_UNUSED
)
778 return parse_suffix (strp
, 'z');
781 /* Parse an empty suffix. Fail if the next char is ':'. */
784 parse_X (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
, const char **strp
,
785 int opindex ATTRIBUTE_UNUSED
, signed long *valuep ATTRIBUTE_UNUSED
)
788 return "Unexpected suffix";
793 parse_r0l_r0h (CGEN_CPU_DESC cd
, const char **strp
,
794 int opindex ATTRIBUTE_UNUSED
, signed long *valuep
)
799 const char *newp
= *strp
;
802 errmsg
= cgen_parse_keyword (cd
, & newp
, & m32c_cgen_opval_h_r0l_r0h
, & value
);
807 return _("not a valid r0l/r0h pair");
810 /* Parse the second register in the pair. */
811 if (value
== 0) /* r0l */
812 errmsg
= cgen_parse_keyword (cd
, & newp
, & m32c_cgen_opval_h_r0h
, & junk
);
814 errmsg
= cgen_parse_keyword (cd
, & newp
, & m32c_cgen_opval_h_r0l
, & junk
);
823 /* Accept .b or .w in any case. */
826 parse_size (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
, const char **strp
,
827 int opindex ATTRIBUTE_UNUSED
, signed long *valuep ATTRIBUTE_UNUSED
)
830 && (*(*strp
+ 1) == 'b' || *(*strp
+ 1) == 'B'
831 || *(*strp
+ 1) == 'w' || *(*strp
+ 1) == 'W'))
837 return _("Invalid size specifier");
840 /* Special check to ensure that instruction exists for given machine. */
843 m32c_cgen_insn_supported (CGEN_CPU_DESC cd
,
844 const CGEN_INSN
*insn
)
846 int machs
= CGEN_INSN_ATTR_VALUE (insn
, CGEN_INSN_MACH
);
847 CGEN_BITSET isas
= CGEN_INSN_BITSET_ATTR_VALUE (insn
, CGEN_INSN_ISA
);
849 /* If attributes are absent, assume no restriction. */
853 return ((machs
& cd
->machs
)
854 && cgen_bitset_intersect_p (& isas
, cd
->isas
));
857 /* Parse a set of registers, R0,R1,A0,A1,SB,FB. */
860 parse_regset (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
862 int opindex ATTRIBUTE_UNUSED
,
863 unsigned long *valuep
,
866 const char *errmsg
= 0;
870 while (**strp
&& **strp
!= ')')
872 if (**strp
== 'r' || **strp
== 'R')
875 regno
= **strp
- '0';
877 errmsg
= _("Register number is not valid");
879 else if (**strp
== 'a' || **strp
== 'A')
882 regno
= **strp
- '0';
884 errmsg
= _("Register number is not valid");
885 regno
= **strp
- '0' + 4;
888 else if (strncasecmp (*strp
, "sb", 2) == 0 || strncasecmp (*strp
, "SB", 2) == 0)
894 else if (strncasecmp (*strp
, "fb", 2) == 0 || strncasecmp (*strp
, "FB", 2) == 0)
900 if (push
) /* Mask is reversed for push. */
901 *valuep
|= 0x80 >> regno
;
903 *valuep
|= 1 << regno
;
908 if (*(*strp
+ 1) == ')')
915 errmsg
= _("Register list is not valid");
924 parse_pop_regset (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
926 int opindex ATTRIBUTE_UNUSED
,
927 unsigned long *valuep
)
929 return parse_regset (cd
, strp
, opindex
, valuep
, POP
);
933 parse_push_regset (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
935 int opindex ATTRIBUTE_UNUSED
,
936 unsigned long *valuep
)
938 return parse_regset (cd
, strp
, opindex
, valuep
, PUSH
);
943 const char * m32c_cgen_parse_operand
944 (CGEN_CPU_DESC
, int, const char **, CGEN_FIELDS
*);
946 /* Main entry point for operand parsing.
948 This function is basically just a big switch statement. Earlier versions
949 used tables to look up the function to use, but
950 - if the table contains both assembler and disassembler functions then
951 the disassembler contains much of the assembler and vice-versa,
952 - there's a lot of inlining possibilities as things grow,
953 - using a switch statement avoids the function call overhead.
955 This function could be moved into `parse_insn_normal', but keeping it
956 separate makes clear the interface between `parse_insn_normal' and each of
960 m32c_cgen_parse_operand (CGEN_CPU_DESC cd
,
963 CGEN_FIELDS
* fields
)
965 const char * errmsg
= NULL
;
966 /* Used by scalar operands that still need to be parsed. */
967 long junk ATTRIBUTE_UNUSED
;
971 case M32C_OPERAND_A0
:
972 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_a0
, & junk
);
974 case M32C_OPERAND_A1
:
975 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_a1
, & junk
);
977 case M32C_OPERAND_AN16_PUSH_S
:
978 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_HI
, & fields
->f_4_1
);
980 case M32C_OPERAND_BIT16AN
:
981 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_dst16_an
);
983 case M32C_OPERAND_BIT16RN
:
984 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_HI
, & fields
->f_dst16_rn
);
986 case M32C_OPERAND_BIT3_S
:
987 errmsg
= parse_bit3_S (cd
, strp
, M32C_OPERAND_BIT3_S
, (long *) (& fields
->f_imm3_S
));
989 case M32C_OPERAND_BIT32ANPREFIXED
:
990 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_dst32_an_prefixed
);
992 case M32C_OPERAND_BIT32ANUNPREFIXED
:
993 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_dst32_an_unprefixed
);
995 case M32C_OPERAND_BIT32RNPREFIXED
:
996 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_QI
, & fields
->f_dst32_rn_prefixed_QI
);
998 case M32C_OPERAND_BIT32RNUNPREFIXED
:
999 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_QI
, & fields
->f_dst32_rn_unprefixed_QI
);
1001 case M32C_OPERAND_BITBASE16_16_S8
:
1002 errmsg
= parse_signed_bitbase8 (cd
, strp
, M32C_OPERAND_BITBASE16_16_S8
, (long *) (& fields
->f_dsp_16_s8
));
1004 case M32C_OPERAND_BITBASE16_16_U16
:
1005 errmsg
= parse_unsigned_bitbase16 (cd
, strp
, M32C_OPERAND_BITBASE16_16_U16
, (unsigned long *) (& fields
->f_dsp_16_u16
));
1007 case M32C_OPERAND_BITBASE16_16_U8
:
1008 errmsg
= parse_unsigned_bitbase8 (cd
, strp
, M32C_OPERAND_BITBASE16_16_U8
, (unsigned long *) (& fields
->f_dsp_16_u8
));
1010 case M32C_OPERAND_BITBASE16_8_U11_S
:
1011 errmsg
= parse_unsigned_bitbase11 (cd
, strp
, M32C_OPERAND_BITBASE16_8_U11_S
, (unsigned long *) (& fields
->f_bitbase16_u11_S
));
1013 case M32C_OPERAND_BITBASE32_16_S11_UNPREFIXED
:
1014 errmsg
= parse_signed_bitbase11 (cd
, strp
, M32C_OPERAND_BITBASE32_16_S11_UNPREFIXED
, (long *) (& fields
->f_bitbase32_16_s11_unprefixed
));
1016 case M32C_OPERAND_BITBASE32_16_S19_UNPREFIXED
:
1017 errmsg
= parse_signed_bitbase19 (cd
, strp
, M32C_OPERAND_BITBASE32_16_S19_UNPREFIXED
, (long *) (& fields
->f_bitbase32_16_s19_unprefixed
));
1019 case M32C_OPERAND_BITBASE32_16_U11_UNPREFIXED
:
1020 errmsg
= parse_unsigned_bitbase11 (cd
, strp
, M32C_OPERAND_BITBASE32_16_U11_UNPREFIXED
, (unsigned long *) (& fields
->f_bitbase32_16_u11_unprefixed
));
1022 case M32C_OPERAND_BITBASE32_16_U19_UNPREFIXED
:
1023 errmsg
= parse_unsigned_bitbase19 (cd
, strp
, M32C_OPERAND_BITBASE32_16_U19_UNPREFIXED
, (unsigned long *) (& fields
->f_bitbase32_16_u19_unprefixed
));
1025 case M32C_OPERAND_BITBASE32_16_U27_UNPREFIXED
:
1026 errmsg
= parse_unsigned_bitbase27 (cd
, strp
, M32C_OPERAND_BITBASE32_16_U27_UNPREFIXED
, (unsigned long *) (& fields
->f_bitbase32_16_u27_unprefixed
));
1028 case M32C_OPERAND_BITBASE32_24_S11_PREFIXED
:
1029 errmsg
= parse_signed_bitbase11 (cd
, strp
, M32C_OPERAND_BITBASE32_24_S11_PREFIXED
, (long *) (& fields
->f_bitbase32_24_s11_prefixed
));
1031 case M32C_OPERAND_BITBASE32_24_S19_PREFIXED
:
1032 errmsg
= parse_signed_bitbase19 (cd
, strp
, M32C_OPERAND_BITBASE32_24_S19_PREFIXED
, (long *) (& fields
->f_bitbase32_24_s19_prefixed
));
1034 case M32C_OPERAND_BITBASE32_24_U11_PREFIXED
:
1035 errmsg
= parse_unsigned_bitbase11 (cd
, strp
, M32C_OPERAND_BITBASE32_24_U11_PREFIXED
, (unsigned long *) (& fields
->f_bitbase32_24_u11_prefixed
));
1037 case M32C_OPERAND_BITBASE32_24_U19_PREFIXED
:
1038 errmsg
= parse_unsigned_bitbase19 (cd
, strp
, M32C_OPERAND_BITBASE32_24_U19_PREFIXED
, (unsigned long *) (& fields
->f_bitbase32_24_u19_prefixed
));
1040 case M32C_OPERAND_BITBASE32_24_U27_PREFIXED
:
1041 errmsg
= parse_unsigned_bitbase27 (cd
, strp
, M32C_OPERAND_BITBASE32_24_U27_PREFIXED
, (unsigned long *) (& fields
->f_bitbase32_24_u27_prefixed
));
1043 case M32C_OPERAND_BITNO16R
:
1044 errmsg
= parse_Bitno16R (cd
, strp
, M32C_OPERAND_BITNO16R
, (unsigned long *) (& fields
->f_dsp_16_u8
));
1046 case M32C_OPERAND_BITNO32PREFIXED
:
1047 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, M32C_OPERAND_BITNO32PREFIXED
, (unsigned long *) (& fields
->f_bitno32_prefixed
));
1049 case M32C_OPERAND_BITNO32UNPREFIXED
:
1050 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, M32C_OPERAND_BITNO32UNPREFIXED
, (unsigned long *) (& fields
->f_bitno32_unprefixed
));
1052 case M32C_OPERAND_DSP_10_U6
:
1053 errmsg
= parse_unsigned6 (cd
, strp
, M32C_OPERAND_DSP_10_U6
, (unsigned long *) (& fields
->f_dsp_10_u6
));
1055 case M32C_OPERAND_DSP_16_S16
:
1056 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_DSP_16_S16
, (long *) (& fields
->f_dsp_16_s16
));
1058 case M32C_OPERAND_DSP_16_S8
:
1059 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_DSP_16_S8
, (long *) (& fields
->f_dsp_16_s8
));
1061 case M32C_OPERAND_DSP_16_U16
:
1062 errmsg
= parse_unsigned16 (cd
, strp
, M32C_OPERAND_DSP_16_U16
, (unsigned long *) (& fields
->f_dsp_16_u16
));
1064 case M32C_OPERAND_DSP_16_U20
:
1065 errmsg
= parse_unsigned20 (cd
, strp
, M32C_OPERAND_DSP_16_U20
, (unsigned long *) (& fields
->f_dsp_16_u24
));
1067 case M32C_OPERAND_DSP_16_U24
:
1068 errmsg
= parse_unsigned24 (cd
, strp
, M32C_OPERAND_DSP_16_U24
, (unsigned long *) (& fields
->f_dsp_16_u24
));
1070 case M32C_OPERAND_DSP_16_U8
:
1071 errmsg
= parse_unsigned8 (cd
, strp
, M32C_OPERAND_DSP_16_U8
, (unsigned long *) (& fields
->f_dsp_16_u8
));
1073 case M32C_OPERAND_DSP_24_S16
:
1074 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_DSP_24_S16
, (long *) (& fields
->f_dsp_24_s16
));
1076 case M32C_OPERAND_DSP_24_S8
:
1077 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_DSP_24_S8
, (long *) (& fields
->f_dsp_24_s8
));
1079 case M32C_OPERAND_DSP_24_U16
:
1080 errmsg
= parse_unsigned16 (cd
, strp
, M32C_OPERAND_DSP_24_U16
, (unsigned long *) (& fields
->f_dsp_24_u16
));
1082 case M32C_OPERAND_DSP_24_U20
:
1083 errmsg
= parse_unsigned20 (cd
, strp
, M32C_OPERAND_DSP_24_U20
, (unsigned long *) (& fields
->f_dsp_24_u24
));
1085 case M32C_OPERAND_DSP_24_U24
:
1086 errmsg
= parse_unsigned24 (cd
, strp
, M32C_OPERAND_DSP_24_U24
, (unsigned long *) (& fields
->f_dsp_24_u24
));
1088 case M32C_OPERAND_DSP_24_U8
:
1089 errmsg
= parse_unsigned8 (cd
, strp
, M32C_OPERAND_DSP_24_U8
, (unsigned long *) (& fields
->f_dsp_24_u8
));
1091 case M32C_OPERAND_DSP_32_S16
:
1092 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_DSP_32_S16
, (long *) (& fields
->f_dsp_32_s16
));
1094 case M32C_OPERAND_DSP_32_S8
:
1095 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_DSP_32_S8
, (long *) (& fields
->f_dsp_32_s8
));
1097 case M32C_OPERAND_DSP_32_U16
:
1098 errmsg
= parse_unsigned16 (cd
, strp
, M32C_OPERAND_DSP_32_U16
, (unsigned long *) (& fields
->f_dsp_32_u16
));
1100 case M32C_OPERAND_DSP_32_U20
:
1101 errmsg
= parse_unsigned20 (cd
, strp
, M32C_OPERAND_DSP_32_U20
, (unsigned long *) (& fields
->f_dsp_32_u24
));
1103 case M32C_OPERAND_DSP_32_U24
:
1104 errmsg
= parse_unsigned24 (cd
, strp
, M32C_OPERAND_DSP_32_U24
, (unsigned long *) (& fields
->f_dsp_32_u24
));
1106 case M32C_OPERAND_DSP_32_U8
:
1107 errmsg
= parse_unsigned8 (cd
, strp
, M32C_OPERAND_DSP_32_U8
, (unsigned long *) (& fields
->f_dsp_32_u8
));
1109 case M32C_OPERAND_DSP_40_S16
:
1110 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_DSP_40_S16
, (long *) (& fields
->f_dsp_40_s16
));
1112 case M32C_OPERAND_DSP_40_S8
:
1113 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_DSP_40_S8
, (long *) (& fields
->f_dsp_40_s8
));
1115 case M32C_OPERAND_DSP_40_U16
:
1116 errmsg
= parse_unsigned16 (cd
, strp
, M32C_OPERAND_DSP_40_U16
, (unsigned long *) (& fields
->f_dsp_40_u16
));
1118 case M32C_OPERAND_DSP_40_U20
:
1119 errmsg
= parse_unsigned20 (cd
, strp
, M32C_OPERAND_DSP_40_U20
, (unsigned long *) (& fields
->f_dsp_40_u20
));
1121 case M32C_OPERAND_DSP_40_U24
:
1122 errmsg
= parse_unsigned24 (cd
, strp
, M32C_OPERAND_DSP_40_U24
, (unsigned long *) (& fields
->f_dsp_40_u24
));
1124 case M32C_OPERAND_DSP_40_U8
:
1125 errmsg
= parse_unsigned8 (cd
, strp
, M32C_OPERAND_DSP_40_U8
, (unsigned long *) (& fields
->f_dsp_40_u8
));
1127 case M32C_OPERAND_DSP_48_S16
:
1128 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_DSP_48_S16
, (long *) (& fields
->f_dsp_48_s16
));
1130 case M32C_OPERAND_DSP_48_S8
:
1131 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_DSP_48_S8
, (long *) (& fields
->f_dsp_48_s8
));
1133 case M32C_OPERAND_DSP_48_U16
:
1134 errmsg
= parse_unsigned16 (cd
, strp
, M32C_OPERAND_DSP_48_U16
, (unsigned long *) (& fields
->f_dsp_48_u16
));
1136 case M32C_OPERAND_DSP_48_U20
:
1137 errmsg
= parse_unsigned24 (cd
, strp
, M32C_OPERAND_DSP_48_U20
, (unsigned long *) (& fields
->f_dsp_48_u20
));
1139 case M32C_OPERAND_DSP_48_U24
:
1140 errmsg
= parse_unsigned24 (cd
, strp
, M32C_OPERAND_DSP_48_U24
, (unsigned long *) (& fields
->f_dsp_48_u24
));
1142 case M32C_OPERAND_DSP_48_U8
:
1143 errmsg
= parse_unsigned8 (cd
, strp
, M32C_OPERAND_DSP_48_U8
, (unsigned long *) (& fields
->f_dsp_48_u8
));
1145 case M32C_OPERAND_DSP_8_S24
:
1146 errmsg
= parse_signed24 (cd
, strp
, M32C_OPERAND_DSP_8_S24
, (long *) (& fields
->f_dsp_8_s24
));
1148 case M32C_OPERAND_DSP_8_S8
:
1149 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_DSP_8_S8
, (long *) (& fields
->f_dsp_8_s8
));
1151 case M32C_OPERAND_DSP_8_U16
:
1152 errmsg
= parse_unsigned16 (cd
, strp
, M32C_OPERAND_DSP_8_U16
, (unsigned long *) (& fields
->f_dsp_8_u16
));
1154 case M32C_OPERAND_DSP_8_U24
:
1155 errmsg
= parse_unsigned24 (cd
, strp
, M32C_OPERAND_DSP_8_U24
, (unsigned long *) (& fields
->f_dsp_8_u24
));
1157 case M32C_OPERAND_DSP_8_U6
:
1158 errmsg
= parse_unsigned6 (cd
, strp
, M32C_OPERAND_DSP_8_U6
, (unsigned long *) (& fields
->f_dsp_8_u6
));
1160 case M32C_OPERAND_DSP_8_U8
:
1161 errmsg
= parse_unsigned8 (cd
, strp
, M32C_OPERAND_DSP_8_U8
, (unsigned long *) (& fields
->f_dsp_8_u8
));
1163 case M32C_OPERAND_DST16AN
:
1164 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_dst16_an
);
1166 case M32C_OPERAND_DST16AN_S
:
1167 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_HI
, & fields
->f_dst16_an_s
);
1169 case M32C_OPERAND_DST16ANHI
:
1170 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_HI
, & fields
->f_dst16_an
);
1172 case M32C_OPERAND_DST16ANQI
:
1173 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_QI
, & fields
->f_dst16_an
);
1175 case M32C_OPERAND_DST16ANQI_S
:
1176 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_QI
, & fields
->f_dst16_rn_QI_s
);
1178 case M32C_OPERAND_DST16ANSI
:
1179 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_SI
, & fields
->f_dst16_an
);
1181 case M32C_OPERAND_DST16RNEXTQI
:
1182 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_ext_QI
, & fields
->f_dst16_rn_ext
);
1184 case M32C_OPERAND_DST16RNHI
:
1185 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_HI
, & fields
->f_dst16_rn
);
1187 case M32C_OPERAND_DST16RNQI
:
1188 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_QI
, & fields
->f_dst16_rn
);
1190 case M32C_OPERAND_DST16RNQI_S
:
1191 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r0l_r0h
, & fields
->f_dst16_rn_QI_s
);
1193 case M32C_OPERAND_DST16RNSI
:
1194 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_SI
, & fields
->f_dst16_rn
);
1196 case M32C_OPERAND_DST32ANEXTUNPREFIXED
:
1197 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_dst32_an_unprefixed
);
1199 case M32C_OPERAND_DST32ANPREFIXED
:
1200 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_dst32_an_prefixed
);
1202 case M32C_OPERAND_DST32ANPREFIXEDHI
:
1203 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_HI
, & fields
->f_dst32_an_prefixed
);
1205 case M32C_OPERAND_DST32ANPREFIXEDQI
:
1206 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_QI
, & fields
->f_dst32_an_prefixed
);
1208 case M32C_OPERAND_DST32ANPREFIXEDSI
:
1209 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_dst32_an_prefixed
);
1211 case M32C_OPERAND_DST32ANUNPREFIXED
:
1212 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_dst32_an_unprefixed
);
1214 case M32C_OPERAND_DST32ANUNPREFIXEDHI
:
1215 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_HI
, & fields
->f_dst32_an_unprefixed
);
1217 case M32C_OPERAND_DST32ANUNPREFIXEDQI
:
1218 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_QI
, & fields
->f_dst32_an_unprefixed
);
1220 case M32C_OPERAND_DST32ANUNPREFIXEDSI
:
1221 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_dst32_an_unprefixed
);
1223 case M32C_OPERAND_DST32R0HI_S
:
1224 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r0
, & junk
);
1226 case M32C_OPERAND_DST32R0QI_S
:
1227 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r0l
, & junk
);
1229 case M32C_OPERAND_DST32RNEXTUNPREFIXEDHI
:
1230 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_ext_HI
, & fields
->f_dst32_rn_ext_unprefixed
);
1232 case M32C_OPERAND_DST32RNEXTUNPREFIXEDQI
:
1233 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_ext_QI
, & fields
->f_dst32_rn_ext_unprefixed
);
1235 case M32C_OPERAND_DST32RNPREFIXEDHI
:
1236 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_HI
, & fields
->f_dst32_rn_prefixed_HI
);
1238 case M32C_OPERAND_DST32RNPREFIXEDQI
:
1239 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_QI
, & fields
->f_dst32_rn_prefixed_QI
);
1241 case M32C_OPERAND_DST32RNPREFIXEDSI
:
1242 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_SI
, & fields
->f_dst32_rn_prefixed_SI
);
1244 case M32C_OPERAND_DST32RNUNPREFIXEDHI
:
1245 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_HI
, & fields
->f_dst32_rn_unprefixed_HI
);
1247 case M32C_OPERAND_DST32RNUNPREFIXEDQI
:
1248 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_QI
, & fields
->f_dst32_rn_unprefixed_QI
);
1250 case M32C_OPERAND_DST32RNUNPREFIXEDSI
:
1251 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_SI
, & fields
->f_dst32_rn_unprefixed_SI
);
1253 case M32C_OPERAND_G
:
1254 errmsg
= parse_G (cd
, strp
, M32C_OPERAND_G
, (long *) (& junk
));
1256 case M32C_OPERAND_IMM_12_S4
:
1257 errmsg
= parse_signed4 (cd
, strp
, M32C_OPERAND_IMM_12_S4
, (long *) (& fields
->f_imm_12_s4
));
1259 case M32C_OPERAND_IMM_12_S4N
:
1260 errmsg
= parse_signed4n (cd
, strp
, M32C_OPERAND_IMM_12_S4N
, (long *) (& fields
->f_imm_12_s4
));
1262 case M32C_OPERAND_IMM_13_U3
:
1263 errmsg
= parse_signed4 (cd
, strp
, M32C_OPERAND_IMM_13_U3
, (long *) (& fields
->f_imm_13_u3
));
1265 case M32C_OPERAND_IMM_16_HI
:
1266 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_IMM_16_HI
, (long *) (& fields
->f_dsp_16_s16
));
1268 case M32C_OPERAND_IMM_16_QI
:
1269 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_IMM_16_QI
, (long *) (& fields
->f_dsp_16_s8
));
1271 case M32C_OPERAND_IMM_16_SI
:
1272 errmsg
= parse_signed32 (cd
, strp
, M32C_OPERAND_IMM_16_SI
, (long *) (& fields
->f_dsp_16_s32
));
1274 case M32C_OPERAND_IMM_20_S4
:
1275 errmsg
= parse_signed4 (cd
, strp
, M32C_OPERAND_IMM_20_S4
, (long *) (& fields
->f_imm_20_s4
));
1277 case M32C_OPERAND_IMM_24_HI
:
1278 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_IMM_24_HI
, (long *) (& fields
->f_dsp_24_s16
));
1280 case M32C_OPERAND_IMM_24_QI
:
1281 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_IMM_24_QI
, (long *) (& fields
->f_dsp_24_s8
));
1283 case M32C_OPERAND_IMM_24_SI
:
1284 errmsg
= parse_signed32 (cd
, strp
, M32C_OPERAND_IMM_24_SI
, (long *) (& fields
->f_dsp_24_s32
));
1286 case M32C_OPERAND_IMM_32_HI
:
1287 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_IMM_32_HI
, (long *) (& fields
->f_dsp_32_s16
));
1289 case M32C_OPERAND_IMM_32_QI
:
1290 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_IMM_32_QI
, (long *) (& fields
->f_dsp_32_s8
));
1292 case M32C_OPERAND_IMM_32_SI
:
1293 errmsg
= parse_signed32 (cd
, strp
, M32C_OPERAND_IMM_32_SI
, (long *) (& fields
->f_dsp_32_s32
));
1295 case M32C_OPERAND_IMM_40_HI
:
1296 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_IMM_40_HI
, (long *) (& fields
->f_dsp_40_s16
));
1298 case M32C_OPERAND_IMM_40_QI
:
1299 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_IMM_40_QI
, (long *) (& fields
->f_dsp_40_s8
));
1301 case M32C_OPERAND_IMM_40_SI
:
1302 errmsg
= parse_signed32 (cd
, strp
, M32C_OPERAND_IMM_40_SI
, (long *) (& fields
->f_dsp_40_s32
));
1304 case M32C_OPERAND_IMM_48_HI
:
1305 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_IMM_48_HI
, (long *) (& fields
->f_dsp_48_s16
));
1307 case M32C_OPERAND_IMM_48_QI
:
1308 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_IMM_48_QI
, (long *) (& fields
->f_dsp_48_s8
));
1310 case M32C_OPERAND_IMM_48_SI
:
1311 errmsg
= parse_signed32 (cd
, strp
, M32C_OPERAND_IMM_48_SI
, (long *) (& fields
->f_dsp_48_s32
));
1313 case M32C_OPERAND_IMM_56_HI
:
1314 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_IMM_56_HI
, (long *) (& fields
->f_dsp_56_s16
));
1316 case M32C_OPERAND_IMM_56_QI
:
1317 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_IMM_56_QI
, (long *) (& fields
->f_dsp_56_s8
));
1319 case M32C_OPERAND_IMM_64_HI
:
1320 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_IMM_64_HI
, (long *) (& fields
->f_dsp_64_s16
));
1322 case M32C_OPERAND_IMM_8_HI
:
1323 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_IMM_8_HI
, (long *) (& fields
->f_dsp_8_s16
));
1325 case M32C_OPERAND_IMM_8_QI
:
1326 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_IMM_8_QI
, (long *) (& fields
->f_dsp_8_s8
));
1328 case M32C_OPERAND_IMM_8_S4
:
1329 errmsg
= parse_signed4 (cd
, strp
, M32C_OPERAND_IMM_8_S4
, (long *) (& fields
->f_imm_8_s4
));
1331 case M32C_OPERAND_IMM_8_S4N
:
1332 errmsg
= parse_signed4n (cd
, strp
, M32C_OPERAND_IMM_8_S4N
, (long *) (& fields
->f_imm_8_s4
));
1334 case M32C_OPERAND_IMM_SH_12_S4
:
1335 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_shimm
, & fields
->f_imm_12_s4
);
1337 case M32C_OPERAND_IMM_SH_20_S4
:
1338 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_shimm
, & fields
->f_imm_20_s4
);
1340 case M32C_OPERAND_IMM_SH_8_S4
:
1341 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_shimm
, & fields
->f_imm_8_s4
);
1343 case M32C_OPERAND_IMM1_S
:
1344 errmsg
= parse_imm1_S (cd
, strp
, M32C_OPERAND_IMM1_S
, (long *) (& fields
->f_imm1_S
));
1346 case M32C_OPERAND_IMM3_S
:
1347 errmsg
= parse_imm3_S (cd
, strp
, M32C_OPERAND_IMM3_S
, (long *) (& fields
->f_imm3_S
));
1349 case M32C_OPERAND_LAB_16_8
:
1352 errmsg
= cgen_parse_address (cd
, strp
, M32C_OPERAND_LAB_16_8
, 0, NULL
, & value
);
1353 fields
->f_lab_16_8
= value
;
1356 case M32C_OPERAND_LAB_24_8
:
1359 errmsg
= cgen_parse_address (cd
, strp
, M32C_OPERAND_LAB_24_8
, 0, NULL
, & value
);
1360 fields
->f_lab_24_8
= value
;
1363 case M32C_OPERAND_LAB_32_8
:
1366 errmsg
= cgen_parse_address (cd
, strp
, M32C_OPERAND_LAB_32_8
, 0, NULL
, & value
);
1367 fields
->f_lab_32_8
= value
;
1370 case M32C_OPERAND_LAB_40_8
:
1373 errmsg
= cgen_parse_address (cd
, strp
, M32C_OPERAND_LAB_40_8
, 0, NULL
, & value
);
1374 fields
->f_lab_40_8
= value
;
1377 case M32C_OPERAND_LAB_5_3
:
1380 errmsg
= parse_lab_5_3 (cd
, strp
, M32C_OPERAND_LAB_5_3
, 0, NULL
, & value
);
1381 fields
->f_lab_5_3
= value
;
1384 case M32C_OPERAND_LAB_8_16
:
1387 errmsg
= cgen_parse_address (cd
, strp
, M32C_OPERAND_LAB_8_16
, 0, NULL
, & value
);
1388 fields
->f_lab_8_16
= value
;
1391 case M32C_OPERAND_LAB_8_24
:
1394 errmsg
= cgen_parse_address (cd
, strp
, M32C_OPERAND_LAB_8_24
, 0, NULL
, & value
);
1395 fields
->f_lab_8_24
= value
;
1398 case M32C_OPERAND_LAB_8_8
:
1401 errmsg
= cgen_parse_address (cd
, strp
, M32C_OPERAND_LAB_8_8
, 0, NULL
, & value
);
1402 fields
->f_lab_8_8
= value
;
1405 case M32C_OPERAND_LAB32_JMP_S
:
1408 errmsg
= parse_lab_5_3 (cd
, strp
, M32C_OPERAND_LAB32_JMP_S
, 0, NULL
, & value
);
1409 fields
->f_lab32_jmp_s
= value
;
1412 case M32C_OPERAND_Q
:
1413 errmsg
= parse_Q (cd
, strp
, M32C_OPERAND_Q
, (long *) (& junk
));
1415 case M32C_OPERAND_R0
:
1416 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r0
, & junk
);
1418 case M32C_OPERAND_R0H
:
1419 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r0h
, & junk
);
1421 case M32C_OPERAND_R0L
:
1422 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r0l
, & junk
);
1424 case M32C_OPERAND_R1
:
1425 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r1
, & junk
);
1427 case M32C_OPERAND_R1R2R0
:
1428 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r1r2r0
, & junk
);
1430 case M32C_OPERAND_R2
:
1431 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r2
, & junk
);
1433 case M32C_OPERAND_R2R0
:
1434 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r2r0
, & junk
);
1436 case M32C_OPERAND_R3
:
1437 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r3
, & junk
);
1439 case M32C_OPERAND_R3R1
:
1440 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r3r1
, & junk
);
1442 case M32C_OPERAND_REGSETPOP
:
1443 errmsg
= parse_pop_regset (cd
, strp
, M32C_OPERAND_REGSETPOP
, (unsigned long *) (& fields
->f_8_8
));
1445 case M32C_OPERAND_REGSETPUSH
:
1446 errmsg
= parse_push_regset (cd
, strp
, M32C_OPERAND_REGSETPUSH
, (unsigned long *) (& fields
->f_8_8
));
1448 case M32C_OPERAND_RN16_PUSH_S
:
1449 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_QI
, & fields
->f_4_1
);
1451 case M32C_OPERAND_S
:
1452 errmsg
= parse_S (cd
, strp
, M32C_OPERAND_S
, (long *) (& junk
));
1454 case M32C_OPERAND_SRC16AN
:
1455 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_src16_an
);
1457 case M32C_OPERAND_SRC16ANHI
:
1458 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_HI
, & fields
->f_src16_an
);
1460 case M32C_OPERAND_SRC16ANQI
:
1461 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_QI
, & fields
->f_src16_an
);
1463 case M32C_OPERAND_SRC16RNHI
:
1464 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_HI
, & fields
->f_src16_rn
);
1466 case M32C_OPERAND_SRC16RNQI
:
1467 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_QI
, & fields
->f_src16_rn
);
1469 case M32C_OPERAND_SRC32ANPREFIXED
:
1470 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_src32_an_prefixed
);
1472 case M32C_OPERAND_SRC32ANPREFIXEDHI
:
1473 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_HI
, & fields
->f_src32_an_prefixed
);
1475 case M32C_OPERAND_SRC32ANPREFIXEDQI
:
1476 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_QI
, & fields
->f_src32_an_prefixed
);
1478 case M32C_OPERAND_SRC32ANPREFIXEDSI
:
1479 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_src32_an_prefixed
);
1481 case M32C_OPERAND_SRC32ANUNPREFIXED
:
1482 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_src32_an_unprefixed
);
1484 case M32C_OPERAND_SRC32ANUNPREFIXEDHI
:
1485 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_HI
, & fields
->f_src32_an_unprefixed
);
1487 case M32C_OPERAND_SRC32ANUNPREFIXEDQI
:
1488 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_QI
, & fields
->f_src32_an_unprefixed
);
1490 case M32C_OPERAND_SRC32ANUNPREFIXEDSI
:
1491 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_src32_an_unprefixed
);
1493 case M32C_OPERAND_SRC32RNPREFIXEDHI
:
1494 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_HI
, & fields
->f_src32_rn_prefixed_HI
);
1496 case M32C_OPERAND_SRC32RNPREFIXEDQI
:
1497 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_QI
, & fields
->f_src32_rn_prefixed_QI
);
1499 case M32C_OPERAND_SRC32RNPREFIXEDSI
:
1500 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_SI
, & fields
->f_src32_rn_prefixed_SI
);
1502 case M32C_OPERAND_SRC32RNUNPREFIXEDHI
:
1503 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_HI
, & fields
->f_src32_rn_unprefixed_HI
);
1505 case M32C_OPERAND_SRC32RNUNPREFIXEDQI
:
1506 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_QI
, & fields
->f_src32_rn_unprefixed_QI
);
1508 case M32C_OPERAND_SRC32RNUNPREFIXEDSI
:
1509 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_SI
, & fields
->f_src32_rn_unprefixed_SI
);
1511 case M32C_OPERAND_SRCDST16_R0L_R0H_S_NORMAL
:
1512 errmsg
= parse_r0l_r0h (cd
, strp
, M32C_OPERAND_SRCDST16_R0L_R0H_S_NORMAL
, (long *) (& fields
->f_5_1
));
1514 case M32C_OPERAND_X
:
1515 errmsg
= parse_X (cd
, strp
, M32C_OPERAND_X
, (long *) (& junk
));
1517 case M32C_OPERAND_Z
:
1518 errmsg
= parse_Z (cd
, strp
, M32C_OPERAND_Z
, (long *) (& junk
));
1520 case M32C_OPERAND_COND16_16
:
1521 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond16
, & fields
->f_dsp_16_u8
);
1523 case M32C_OPERAND_COND16_24
:
1524 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond16
, & fields
->f_dsp_24_u8
);
1526 case M32C_OPERAND_COND16_32
:
1527 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond16
, & fields
->f_dsp_32_u8
);
1529 case M32C_OPERAND_COND16C
:
1530 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond16c
, & fields
->f_cond16
);
1532 case M32C_OPERAND_COND16J
:
1533 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond16j
, & fields
->f_cond16
);
1535 case M32C_OPERAND_COND16J5
:
1536 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond16j_5
, & fields
->f_cond16j_5
);
1538 case M32C_OPERAND_COND32
:
1539 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond32
, & fields
->f_cond32
);
1541 case M32C_OPERAND_COND32_16
:
1542 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond32
, & fields
->f_dsp_16_u8
);
1544 case M32C_OPERAND_COND32_24
:
1545 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond32
, & fields
->f_dsp_24_u8
);
1547 case M32C_OPERAND_COND32_32
:
1548 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond32
, & fields
->f_dsp_32_u8
);
1550 case M32C_OPERAND_COND32_40
:
1551 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond32
, & fields
->f_dsp_40_u8
);
1553 case M32C_OPERAND_COND32J
:
1554 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond32
, & fields
->f_cond32j
);
1556 case M32C_OPERAND_CR1_PREFIXED_32
:
1557 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cr1_32
, & fields
->f_21_3
);
1559 case M32C_OPERAND_CR1_UNPREFIXED_32
:
1560 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cr1_32
, & fields
->f_13_3
);
1562 case M32C_OPERAND_CR16
:
1563 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cr_16
, & fields
->f_9_3
);
1565 case M32C_OPERAND_CR2_32
:
1566 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cr2_32
, & fields
->f_13_3
);
1568 case M32C_OPERAND_CR3_PREFIXED_32
:
1569 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cr3_32
, & fields
->f_21_3
);
1571 case M32C_OPERAND_CR3_UNPREFIXED_32
:
1572 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cr3_32
, & fields
->f_13_3
);
1574 case M32C_OPERAND_FLAGS16
:
1575 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_flags
, & fields
->f_9_3
);
1577 case M32C_OPERAND_FLAGS32
:
1578 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_flags
, & fields
->f_13_3
);
1580 case M32C_OPERAND_SCCOND32
:
1581 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond32
, & fields
->f_cond16
);
1583 case M32C_OPERAND_SIZE
:
1584 errmsg
= parse_size (cd
, strp
, M32C_OPERAND_SIZE
, (long *) (& junk
));
1588 /* xgettext:c-format */
1589 fprintf (stderr
, _("Unrecognized field %d while parsing.\n"), opindex
);
1596 cgen_parse_fn
* const m32c_cgen_parse_handlers
[] =
1602 m32c_cgen_init_asm (CGEN_CPU_DESC cd
)
1604 m32c_cgen_init_opcode_table (cd
);
1605 m32c_cgen_init_ibld_table (cd
);
1606 cd
->parse_handlers
= & m32c_cgen_parse_handlers
[0];
1607 cd
->parse_operand
= m32c_cgen_parse_operand
;
1608 #ifdef CGEN_ASM_INIT_HOOK
1615 /* Regex construction routine.
1617 This translates an opcode syntax string into a regex string,
1618 by replacing any non-character syntax element (such as an
1619 opcode) with the pattern '.*'
1621 It then compiles the regex and stores it in the opcode, for
1622 later use by m32c_cgen_assemble_insn
1624 Returns NULL for success, an error message for failure. */
1627 m32c_cgen_build_insn_regex (CGEN_INSN
*insn
)
1629 CGEN_OPCODE
*opc
= (CGEN_OPCODE
*) CGEN_INSN_OPCODE (insn
);
1630 const char *mnem
= CGEN_INSN_MNEMONIC (insn
);
1631 char rxbuf
[CGEN_MAX_RX_ELEMENTS
];
1633 const CGEN_SYNTAX_CHAR_TYPE
*syn
;
1636 syn
= CGEN_SYNTAX_STRING (CGEN_OPCODE_SYNTAX (opc
));
1638 /* Mnemonics come first in the syntax string. */
1639 if (! CGEN_SYNTAX_MNEMONIC_P (* syn
))
1640 return _("missing mnemonic in syntax string");
1643 /* Generate a case sensitive regular expression that emulates case
1644 insensitive matching in the "C" locale. We cannot generate a case
1645 insensitive regular expression because in Turkish locales, 'i' and 'I'
1646 are not equal modulo case conversion. */
1648 /* Copy the literal mnemonic out of the insn. */
1649 for (; *mnem
; mnem
++)
1656 *rx
++ = TOLOWER (c
);
1657 *rx
++ = TOUPPER (c
);
1664 /* Copy any remaining literals from the syntax string into the rx. */
1665 for(; * syn
!= 0 && rx
<= rxbuf
+ (CGEN_MAX_RX_ELEMENTS
- 7 - 4); ++syn
)
1667 if (CGEN_SYNTAX_CHAR_P (* syn
))
1669 char c
= CGEN_SYNTAX_CHAR (* syn
);
1673 /* Escape any regex metacharacters in the syntax. */
1674 case '.': case '[': case '\\':
1675 case '*': case '^': case '$':
1677 #ifdef CGEN_ESCAPE_EXTENDED_REGEX
1678 case '?': case '{': case '}':
1679 case '(': case ')': case '*':
1680 case '|': case '+': case ']':
1690 *rx
++ = TOLOWER (c
);
1691 *rx
++ = TOUPPER (c
);
1701 /* Replace non-syntax fields with globs. */
1707 /* Trailing whitespace ok. */
1714 /* But anchor it after that. */
1718 CGEN_INSN_RX (insn
) = xmalloc (sizeof (regex_t
));
1719 reg_err
= regcomp ((regex_t
*) CGEN_INSN_RX (insn
), rxbuf
, REG_NOSUB
);
1725 static char msg
[80];
1727 regerror (reg_err
, (regex_t
*) CGEN_INSN_RX (insn
), msg
, 80);
1728 regfree ((regex_t
*) CGEN_INSN_RX (insn
));
1729 free (CGEN_INSN_RX (insn
));
1730 (CGEN_INSN_RX (insn
)) = NULL
;
1736 /* Default insn parser.
1738 The syntax string is scanned and operands are parsed and stored in FIELDS.
1739 Relocs are queued as we go via other callbacks.
1741 ??? Note that this is currently an all-or-nothing parser. If we fail to
1742 parse the instruction, we return 0 and the caller will start over from
1743 the beginning. Backtracking will be necessary in parsing subexpressions,
1744 but that can be handled there. Not handling backtracking here may get
1745 expensive in the case of the m68k. Deal with later.
1747 Returns NULL for success, an error message for failure. */
1750 parse_insn_normal (CGEN_CPU_DESC cd
,
1751 const CGEN_INSN
*insn
,
1753 CGEN_FIELDS
*fields
)
1755 /* ??? Runtime added insns not handled yet. */
1756 const CGEN_SYNTAX
*syntax
= CGEN_INSN_SYNTAX (insn
);
1757 const char *str
= *strp
;
1760 const CGEN_SYNTAX_CHAR_TYPE
* syn
;
1761 #ifdef CGEN_MNEMONIC_OPERANDS
1766 /* For now we assume the mnemonic is first (there are no leading operands).
1767 We can parse it without needing to set up operand parsing.
1768 GAS's input scrubber will ensure mnemonics are lowercase, but we may
1769 not be called from GAS. */
1770 p
= CGEN_INSN_MNEMONIC (insn
);
1771 while (*p
&& TOLOWER (*p
) == TOLOWER (*str
))
1775 return _("unrecognized instruction");
1777 #ifndef CGEN_MNEMONIC_OPERANDS
1778 if (* str
&& ! ISSPACE (* str
))
1779 return _("unrecognized instruction");
1782 CGEN_INIT_PARSE (cd
);
1783 cgen_init_parse_operand (cd
);
1784 #ifdef CGEN_MNEMONIC_OPERANDS
1788 /* We don't check for (*str != '\0') here because we want to parse
1789 any trailing fake arguments in the syntax string. */
1790 syn
= CGEN_SYNTAX_STRING (syntax
);
1792 /* Mnemonics come first for now, ensure valid string. */
1793 if (! CGEN_SYNTAX_MNEMONIC_P (* syn
))
1800 /* Non operand chars must match exactly. */
1801 if (CGEN_SYNTAX_CHAR_P (* syn
))
1803 /* FIXME: While we allow for non-GAS callers above, we assume the
1804 first char after the mnemonic part is a space. */
1805 /* FIXME: We also take inappropriate advantage of the fact that
1806 GAS's input scrubber will remove extraneous blanks. */
1807 if (TOLOWER (*str
) == TOLOWER (CGEN_SYNTAX_CHAR (* syn
)))
1809 #ifdef CGEN_MNEMONIC_OPERANDS
1810 if (CGEN_SYNTAX_CHAR(* syn
) == ' ')
1818 /* Syntax char didn't match. Can't be this insn. */
1819 static char msg
[80];
1821 /* xgettext:c-format */
1822 sprintf (msg
, _("syntax error (expected char `%c', found `%c')"),
1823 CGEN_SYNTAX_CHAR(*syn
), *str
);
1828 /* Ran out of input. */
1829 static char msg
[80];
1831 /* xgettext:c-format */
1832 sprintf (msg
, _("syntax error (expected char `%c', found end of instruction)"),
1833 CGEN_SYNTAX_CHAR(*syn
));
1839 /* We have an operand of some sort. */
1840 errmsg
= cd
->parse_operand (cd
, CGEN_SYNTAX_FIELD (*syn
),
1845 /* Done with this operand, continue with next one. */
1849 /* If we're at the end of the syntax string, we're done. */
1852 /* FIXME: For the moment we assume a valid `str' can only contain
1853 blanks now. IE: We needn't try again with a longer version of
1854 the insn and it is assumed that longer versions of insns appear
1855 before shorter ones (eg: lsr r2,r3,1 vs lsr r2,r3). */
1856 while (ISSPACE (* str
))
1860 return _("junk at end of line"); /* FIXME: would like to include `str' */
1865 /* We couldn't parse it. */
1866 return _("unrecognized instruction");
1869 /* Main entry point.
1870 This routine is called for each instruction to be assembled.
1871 STR points to the insn to be assembled.
1872 We assume all necessary tables have been initialized.
1873 The assembled instruction, less any fixups, is stored in BUF.
1874 Remember that if CGEN_INT_INSN_P then BUF is an int and thus the value
1875 still needs to be converted to target byte order, otherwise BUF is an array
1876 of bytes in target byte order.
1877 The result is a pointer to the insn's entry in the opcode table,
1878 or NULL if an error occured (an error message will have already been
1881 Note that when processing (non-alias) macro-insns,
1882 this function recurses.
1884 ??? It's possible to make this cpu-independent.
1885 One would have to deal with a few minor things.
1886 At this point in time doing so would be more of a curiosity than useful
1887 [for example this file isn't _that_ big], but keeping the possibility in
1888 mind helps keep the design clean. */
1891 m32c_cgen_assemble_insn (CGEN_CPU_DESC cd
,
1893 CGEN_FIELDS
*fields
,
1894 CGEN_INSN_BYTES_PTR buf
,
1898 CGEN_INSN_LIST
*ilist
;
1899 const char *parse_errmsg
= NULL
;
1900 const char *insert_errmsg
= NULL
;
1901 int recognized_mnemonic
= 0;
1903 /* Skip leading white space. */
1904 while (ISSPACE (* str
))
1907 /* The instructions are stored in hashed lists.
1908 Get the first in the list. */
1909 ilist
= CGEN_ASM_LOOKUP_INSN (cd
, str
);
1911 /* Keep looking until we find a match. */
1913 for ( ; ilist
!= NULL
; ilist
= CGEN_ASM_NEXT_INSN (ilist
))
1915 const CGEN_INSN
*insn
= ilist
->insn
;
1916 recognized_mnemonic
= 1;
1918 #ifdef CGEN_VALIDATE_INSN_SUPPORTED
1919 /* Not usually needed as unsupported opcodes
1920 shouldn't be in the hash lists. */
1921 /* Is this insn supported by the selected cpu? */
1922 if (! m32c_cgen_insn_supported (cd
, insn
))
1925 /* If the RELAXED attribute is set, this is an insn that shouldn't be
1926 chosen immediately. Instead, it is used during assembler/linker
1927 relaxation if possible. */
1928 if (CGEN_INSN_ATTR_VALUE (insn
, CGEN_INSN_RELAXED
) != 0)
1933 /* Skip this insn if str doesn't look right lexically. */
1934 if (CGEN_INSN_RX (insn
) != NULL
&&
1935 regexec ((regex_t
*) CGEN_INSN_RX (insn
), str
, 0, NULL
, 0) == REG_NOMATCH
)
1938 /* Allow parse/insert handlers to obtain length of insn. */
1939 CGEN_FIELDS_BITSIZE (fields
) = CGEN_INSN_BITSIZE (insn
);
1941 parse_errmsg
= CGEN_PARSE_FN (cd
, insn
) (cd
, insn
, & str
, fields
);
1942 if (parse_errmsg
!= NULL
)
1945 /* ??? 0 is passed for `pc'. */
1946 insert_errmsg
= CGEN_INSERT_FN (cd
, insn
) (cd
, insn
, fields
, buf
,
1948 if (insert_errmsg
!= NULL
)
1951 /* It is up to the caller to actually output the insn and any
1957 static char errbuf
[150];
1958 #ifdef CGEN_VERBOSE_ASSEMBLER_ERRORS
1959 const char *tmp_errmsg
;
1961 /* If requesting verbose error messages, use insert_errmsg.
1962 Failing that, use parse_errmsg. */
1963 tmp_errmsg
= (insert_errmsg
? insert_errmsg
:
1964 parse_errmsg
? parse_errmsg
:
1965 recognized_mnemonic
?
1966 _("unrecognized form of instruction") :
1967 _("unrecognized instruction"));
1969 if (strlen (start
) > 50)
1970 /* xgettext:c-format */
1971 sprintf (errbuf
, "%s `%.50s...'", tmp_errmsg
, start
);
1973 /* xgettext:c-format */
1974 sprintf (errbuf
, "%s `%.50s'", tmp_errmsg
, start
);
1976 if (strlen (start
) > 50)
1977 /* xgettext:c-format */
1978 sprintf (errbuf
, _("bad instruction `%.50s...'"), start
);
1980 /* xgettext:c-format */
1981 sprintf (errbuf
, _("bad instruction `%.50s'"), start
);