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
8 Free Software Foundation, Inc.
10 This file is part of the GNU Binutils and GDB, the GNU debugger.
12 This program 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 2, or (at your option)
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public 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. */
26 /* ??? Eventually more and more of this stuff can go to cpu-independent files.
34 #include "m32c-desc.h"
38 #include "libiberty.h"
39 #include "safe-ctype.h"
42 #define min(a,b) ((a) < (b) ? (a) : (b))
44 #define max(a,b) ((a) > (b) ? (a) : (b))
46 static const char * parse_insn_normal
47 (CGEN_CPU_DESC
, const CGEN_INSN
*, const char **, CGEN_FIELDS
*);
49 /* -- assembler routines inserted here. */
52 #include "safe-ctype.h"
54 #define MACH_M32C 5 /* Must match md_begin. */
57 m32c_cgen_isa_register (const char **strp
)
60 const char *s
= *strp
;
61 static char * m32c_register_names
[] =
63 "r0", "r1", "r2", "r3", "r0l", "r0h", "r1l", "r1h",
64 "a0", "a1", "r2r0", "r3r1", "sp", "fb", "dct0", "dct1", "flg", "svf",
65 "drc0", "drc1", "dmd0", "dmd1", "intb", "svp", "vct", "isp", "dma0",
66 "dma1", "dra0", "dra1", "dsa0", "dsa1", 0
69 for (u
= 0; m32c_register_names
[u
]; u
++)
71 int len
= strlen (m32c_register_names
[u
]);
73 if (memcmp (m32c_register_names
[u
], s
, len
) == 0
74 && (s
[len
] == 0 || ! ISALNUM (s
[len
])))
80 #define PARSE_UNSIGNED \
83 /* Don't successfully parse literals beginning with '['. */ \
85 return "Invalid literal"; /* Anything -- will not be seen. */ \
87 errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, & value);\
93 #define PARSE_SIGNED \
96 /* Don't successfully parse literals beginning with '['. */ \
98 return "Invalid literal"; /* Anything -- will not be seen. */ \
100 errmsg = cgen_parse_signed_integer (cd, strp, opindex, & value); \
107 parse_unsigned6 (CGEN_CPU_DESC cd
, const char **strp
,
108 int opindex
, unsigned long *valuep
)
110 const char *errmsg
= 0;
116 return _("imm:6 immediate is out of range");
123 parse_unsigned8 (CGEN_CPU_DESC cd
, const char **strp
,
124 int opindex
, unsigned long *valuep
)
126 const char *errmsg
= 0;
130 if (strncasecmp (*strp
, "%dsp8(", 6) == 0)
132 enum cgen_parse_operand_result result_type
;
137 errmsg
= cgen_parse_address (cd
, strp
, opindex
, BFD_RELOC_8
,
138 & result_type
, & value
);
140 return _("missing `)'");
144 && result_type
== CGEN_PARSE_OPERAND_RESULT_NUMBER
)
146 return _("%dsp8() takes a symbolic address, not a number");
152 if (strncmp (*strp
, "0x0", 3) == 0
153 || (**strp
== '0' && *(*strp
+ 1) != 'x'))
159 return _("dsp:8 immediate is out of range");
161 /* If this field may require a relocation then use larger dsp16. */
162 if (! have_zero
&& value
== 0)
163 return _("dsp:8 immediate is out of range");
170 parse_signed4 (CGEN_CPU_DESC cd
, const char **strp
,
171 int opindex
, signed long *valuep
)
173 const char *errmsg
= 0;
177 if (strncmp (*strp
, "0x0", 3) == 0
178 || (**strp
== '0' && *(*strp
+ 1) != 'x'))
183 if (value
< -8 || value
> 7)
184 return _("Immediate is out of range -8 to 7");
186 /* If this field may require a relocation then use larger dsp16. */
187 if (! have_zero
&& value
== 0)
188 return _("Immediate is out of range -8 to 7");
195 parse_signed4n (CGEN_CPU_DESC cd
, const char **strp
,
196 int opindex
, signed long *valuep
)
198 const char *errmsg
= 0;
202 if (strncmp (*strp
, "0x0", 3) == 0
203 || (**strp
== '0' && *(*strp
+ 1) != 'x'))
208 if (value
< -7 || value
> 8)
209 return _("Immediate is out of range -7 to 8");
211 /* If this field may require a relocation then use larger dsp16. */
212 if (! have_zero
&& value
== 0)
213 return _("Immediate is out of range -7 to 8");
220 parse_signed8 (CGEN_CPU_DESC cd
, const char **strp
,
221 int opindex
, signed long *valuep
)
223 const char *errmsg
= 0;
226 if (strncasecmp (*strp
, "%hi8(", 5) == 0)
228 enum cgen_parse_operand_result result_type
;
233 errmsg
= cgen_parse_address (cd
, strp
, opindex
, BFD_RELOC_M32C_HI8
,
234 & result_type
, & value
);
236 return _("missing `)'");
240 && result_type
== CGEN_PARSE_OPERAND_RESULT_NUMBER
)
250 if (value
<= 255 && value
> 127)
253 if (value
< -128 || value
> 127)
254 return _("dsp:8 immediate is out of range");
261 parse_unsigned16 (CGEN_CPU_DESC cd
, const char **strp
,
262 int opindex
, unsigned long *valuep
)
264 const char *errmsg
= 0;
268 if (strncasecmp (*strp
, "%dsp16(", 7) == 0)
270 enum cgen_parse_operand_result result_type
;
275 errmsg
= cgen_parse_address (cd
, strp
, opindex
, BFD_RELOC_16
,
276 & result_type
, & value
);
278 return _("missing `)'");
282 && result_type
== CGEN_PARSE_OPERAND_RESULT_NUMBER
)
284 return _("%dsp16() takes a symbolic address, not a number");
290 /* Don't successfully parse literals beginning with '['. */
292 return "Invalid literal"; /* Anything -- will not be seen. */
294 /* Don't successfully parse register names. */
295 if (m32c_cgen_isa_register (strp
))
296 return "Invalid literal"; /* Anything -- will not be seen. */
298 if (strncmp (*strp
, "0x0", 3) == 0
299 || (**strp
== '0' && *(*strp
+ 1) != 'x'))
302 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, opindex
, & value
);
307 return _("dsp:16 immediate is out of range");
309 /* If this field may require a relocation then use larger dsp24. */
310 if (cd
->machs
== MACH_M32C
&& ! have_zero
&& value
== 0
311 && (strncmp (*strp
, "[a", 2) == 0
314 return _("dsp:16 immediate is out of range");
321 parse_signed16 (CGEN_CPU_DESC cd
, const char **strp
,
322 int opindex
, signed long *valuep
)
324 const char *errmsg
= 0;
327 if (strncasecmp (*strp
, "%lo16(", 6) == 0)
329 enum cgen_parse_operand_result result_type
;
334 errmsg
= cgen_parse_address (cd
, strp
, opindex
, BFD_RELOC_LO16
,
335 & result_type
, & value
);
337 return _("missing `)'");
341 && result_type
== CGEN_PARSE_OPERAND_RESULT_NUMBER
)
349 if (strncasecmp (*strp
, "%hi16(", 6) == 0)
351 enum cgen_parse_operand_result result_type
;
356 errmsg
= cgen_parse_address (cd
, strp
, opindex
, BFD_RELOC_HI16
,
357 & result_type
, & value
);
359 return _("missing `)'");
363 && result_type
== CGEN_PARSE_OPERAND_RESULT_NUMBER
)
373 if (value
<= 65535 && value
> 32767)
376 if (value
< -32768 || value
> 32767)
377 return _("dsp:16 immediate is out of range");
384 parse_unsigned20 (CGEN_CPU_DESC cd
, const char **strp
,
385 int opindex
, unsigned long *valuep
)
387 const char *errmsg
= 0;
390 /* Don't successfully parse literals beginning with '['. */
392 return "Invalid literal"; /* Anything -- will not be seen. */
394 /* Don't successfully parse register names. */
395 if (m32c_cgen_isa_register (strp
))
396 return "Invalid literal"; /* Anything -- will not be seen. */
398 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, opindex
, & value
);
403 return _("dsp:20 immediate is out of range");
410 parse_unsigned24 (CGEN_CPU_DESC cd
, const char **strp
,
411 int opindex
, unsigned long *valuep
)
413 const char *errmsg
= 0;
416 /* Don't successfully parse literals beginning with '['. */
418 return "Invalid literal"; /* Anything -- will not be seen. */
420 /* Don't successfully parse register names. */
421 if (m32c_cgen_isa_register (strp
))
422 return "Invalid literal"; /* Anything -- will not be seen. */
424 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, opindex
, & value
);
428 if (value
> 0xffffff)
429 return _("dsp:24 immediate is out of range");
435 /* This should only be used for #imm->reg. */
437 parse_signed24 (CGEN_CPU_DESC cd
, const char **strp
,
438 int opindex
, signed long *valuep
)
440 const char *errmsg
= 0;
445 if (value
<= 0xffffff && value
> 0x7fffff)
448 if (value
> 0xffffff)
449 return _("dsp:24 immediate is out of range");
456 parse_signed32 (CGEN_CPU_DESC cd
, const char **strp
,
457 int opindex
, signed long *valuep
)
459 const char *errmsg
= 0;
462 errmsg
= cgen_parse_signed_integer (cd
, strp
, opindex
, & value
);
471 parse_imm1_S (CGEN_CPU_DESC cd
, const char **strp
,
472 int opindex
, signed long *valuep
)
474 const char *errmsg
= 0;
477 errmsg
= cgen_parse_signed_integer (cd
, strp
, opindex
, & value
);
481 if (value
< 1 || value
> 2)
482 return _("immediate is out of range 1-2");
489 parse_imm3_S (CGEN_CPU_DESC cd
, const char **strp
,
490 int opindex
, signed long *valuep
)
492 const char *errmsg
= 0;
495 errmsg
= cgen_parse_signed_integer (cd
, strp
, opindex
, & value
);
499 if (value
< 1 || value
> 8)
500 return _("immediate is out of range 1-8");
507 parse_bit3_S (CGEN_CPU_DESC cd
, const char **strp
,
508 int opindex
, signed long *valuep
)
510 const char *errmsg
= 0;
513 errmsg
= cgen_parse_signed_integer (cd
, strp
, opindex
, & value
);
517 if (value
< 0 || value
> 7)
518 return _("immediate is out of range 0-7");
525 parse_lab_5_3 (CGEN_CPU_DESC cd
,
527 int opindex ATTRIBUTE_UNUSED
,
529 enum cgen_parse_operand_result
*type_addr
,
532 const char *errmsg
= 0;
534 enum cgen_parse_operand_result op_res
;
536 errmsg
= cgen_parse_address (cd
, strp
, M32C_OPERAND_LAB_5_3
,
537 opinfo
, & op_res
, & value
);
542 if (op_res
== CGEN_PARSE_OPERAND_ADDRESS
)
544 /* This is a hack; the field cannot handle near-zero signed
545 offsets that CGEN wants to put in to indicate an "empty"
553 if (value
< 2 || value
> 9)
554 return _("immediate is out of range 2-9");
561 parse_Bitno16R (CGEN_CPU_DESC cd
, const char **strp
,
562 int opindex
, unsigned long *valuep
)
564 const char *errmsg
= 0;
567 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, opindex
, & value
);
572 return _("Bit number for indexing general register is out of range 0-15");
579 parse_unsigned_bitbase (CGEN_CPU_DESC cd
, const char **strp
,
580 int opindex
, unsigned long *valuep
,
581 unsigned bits
, int allow_syms
)
583 const char *errmsg
= 0;
586 const char *newp
= *strp
;
587 unsigned long long bitbase
;
590 errmsg
= cgen_parse_unsigned_integer (cd
, & newp
, opindex
, & bit
);
595 return "Missing base for bit,base:8";
599 if (strncmp (newp
, "0x0", 3) == 0
600 || (newp
[0] == '0' && newp
[1] != 'x'))
603 errmsg
= cgen_parse_unsigned_integer (cd
, & newp
, opindex
, & base
);
607 bitbase
= (unsigned long long) bit
+ ((unsigned long long) base
* 8);
609 if (bitbase
>= (1ull << bits
))
610 return _("bit,base is out of range");
612 /* If this field may require a relocation then use larger displacement. */
613 if (! have_zero
&& base
== 0)
615 switch (allow_syms
) {
617 return _("bit,base out of range for symbol");
621 if (strncmp (newp
, "[sb]", 4) != 0)
622 return _("bit,base out of range for symbol");
633 parse_signed_bitbase (CGEN_CPU_DESC cd
, const char **strp
,
634 int opindex
, signed long *valuep
,
635 unsigned bits
, int allow_syms
)
637 const char *errmsg
= 0;
640 const char *newp
= *strp
;
645 errmsg
= cgen_parse_unsigned_integer (cd
, & newp
, opindex
, & bit
);
650 return "Missing base for bit,base:8";
654 if (strncmp (newp
, "0x0", 3) == 0
655 || (newp
[0] == '0' && newp
[1] != 'x'))
658 errmsg
= cgen_parse_signed_integer (cd
, & newp
, opindex
, & base
);
662 bitbase
= (long long)bit
+ ((long long)base
* 8);
664 limit
= 1ll << (bits
- 1);
665 if (bitbase
< -limit
|| bitbase
>= limit
)
666 return _("bit,base is out of range");
668 /* If this field may require a relocation then use larger displacement. */
669 if (! have_zero
&& base
== 0 && ! allow_syms
)
670 return _("bit,base out of range for symbol");
678 parse_unsigned_bitbase8 (CGEN_CPU_DESC cd
, const char **strp
,
679 int opindex
, unsigned long *valuep
)
681 return parse_unsigned_bitbase (cd
, strp
, opindex
, valuep
, 8, 0);
685 parse_unsigned_bitbase11 (CGEN_CPU_DESC cd
, const char **strp
,
686 int opindex
, unsigned long *valuep
)
688 return parse_unsigned_bitbase (cd
, strp
, opindex
, valuep
, 11, 0);
692 parse_unsigned_bitbase16 (CGEN_CPU_DESC cd
, const char **strp
,
693 int opindex
, unsigned long *valuep
)
695 return parse_unsigned_bitbase (cd
, strp
, opindex
, valuep
, 16, 1);
699 parse_unsigned_bitbase19 (CGEN_CPU_DESC cd
, const char **strp
,
700 int opindex
, unsigned long *valuep
)
702 return parse_unsigned_bitbase (cd
, strp
, opindex
, valuep
, 19, 2);
706 parse_unsigned_bitbase27 (CGEN_CPU_DESC cd
, const char **strp
,
707 int opindex
, unsigned long *valuep
)
709 return parse_unsigned_bitbase (cd
, strp
, opindex
, valuep
, 27, 1);
713 parse_signed_bitbase8 (CGEN_CPU_DESC cd
, const char **strp
,
714 int opindex
, signed long *valuep
)
716 return parse_signed_bitbase (cd
, strp
, opindex
, valuep
, 8, 1);
720 parse_signed_bitbase11 (CGEN_CPU_DESC cd
, const char **strp
,
721 int opindex
, signed long *valuep
)
723 return parse_signed_bitbase (cd
, strp
, opindex
, valuep
, 11, 0);
727 parse_signed_bitbase19 (CGEN_CPU_DESC cd
, const char **strp
,
728 int opindex
, signed long *valuep
)
730 return parse_signed_bitbase (cd
, strp
, opindex
, valuep
, 19, 1);
733 /* Parse the suffix as :<char> or as nothing followed by a whitespace. */
736 parse_suffix (const char **strp
, char suffix
)
738 const char *newp
= *strp
;
740 if (**strp
== ':' && TOLOWER (*(*strp
+ 1)) == suffix
)
749 return "Invalid suffix"; /* Anything -- will not be seen. */
753 parse_S (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
, const char **strp
,
754 int opindex ATTRIBUTE_UNUSED
, signed long *valuep ATTRIBUTE_UNUSED
)
756 return parse_suffix (strp
, 's');
760 parse_G (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
, const char **strp
,
761 int opindex ATTRIBUTE_UNUSED
, signed long *valuep ATTRIBUTE_UNUSED
)
763 return parse_suffix (strp
, 'g');
767 parse_Q (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
, const char **strp
,
768 int opindex ATTRIBUTE_UNUSED
, signed long *valuep ATTRIBUTE_UNUSED
)
770 return parse_suffix (strp
, 'q');
774 parse_Z (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
, const char **strp
,
775 int opindex ATTRIBUTE_UNUSED
, signed long *valuep ATTRIBUTE_UNUSED
)
777 return parse_suffix (strp
, 'z');
780 /* Parse an empty suffix. Fail if the next char is ':'. */
783 parse_X (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
, const char **strp
,
784 int opindex ATTRIBUTE_UNUSED
, signed long *valuep ATTRIBUTE_UNUSED
)
787 return "Unexpected suffix";
792 parse_r0l_r0h (CGEN_CPU_DESC cd
, const char **strp
,
793 int opindex ATTRIBUTE_UNUSED
, signed long *valuep
)
798 const char *newp
= *strp
;
801 errmsg
= cgen_parse_keyword (cd
, & newp
, & m32c_cgen_opval_h_r0l_r0h
, & value
);
806 return _("not a valid r0l/r0h pair");
809 /* Parse the second register in the pair. */
810 if (value
== 0) /* r0l */
811 errmsg
= cgen_parse_keyword (cd
, & newp
, & m32c_cgen_opval_h_r0h
, & junk
);
813 errmsg
= cgen_parse_keyword (cd
, & newp
, & m32c_cgen_opval_h_r0l
, & junk
);
822 /* Accept .b or .w in any case. */
825 parse_size (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
, const char **strp
,
826 int opindex ATTRIBUTE_UNUSED
, signed long *valuep ATTRIBUTE_UNUSED
)
829 && (*(*strp
+ 1) == 'b' || *(*strp
+ 1) == 'B'
830 || *(*strp
+ 1) == 'w' || *(*strp
+ 1) == 'W'))
836 return _("Invalid size specifier");
839 /* Special check to ensure that instruction exists for given machine. */
842 m32c_cgen_insn_supported (CGEN_CPU_DESC cd
,
843 const CGEN_INSN
*insn
)
845 int machs
= CGEN_INSN_ATTR_VALUE (insn
, CGEN_INSN_MACH
);
846 CGEN_BITSET isas
= CGEN_INSN_BITSET_ATTR_VALUE (insn
, CGEN_INSN_ISA
);
848 /* If attributes are absent, assume no restriction. */
852 return ((machs
& cd
->machs
)
853 && cgen_bitset_intersect_p (& isas
, cd
->isas
));
856 /* Parse a set of registers, R0,R1,A0,A1,SB,FB. */
859 parse_regset (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
861 int opindex ATTRIBUTE_UNUSED
,
862 unsigned long *valuep
,
865 const char *errmsg
= 0;
869 while (**strp
&& **strp
!= ')')
871 if (**strp
== 'r' || **strp
== 'R')
874 regno
= **strp
- '0';
876 errmsg
= _("Register number is not valid");
878 else if (**strp
== 'a' || **strp
== 'A')
881 regno
= **strp
- '0';
883 errmsg
= _("Register number is not valid");
884 regno
= **strp
- '0' + 4;
887 else if (strncasecmp (*strp
, "sb", 2) == 0 || strncasecmp (*strp
, "SB", 2) == 0)
893 else if (strncasecmp (*strp
, "fb", 2) == 0 || strncasecmp (*strp
, "FB", 2) == 0)
899 if (push
) /* Mask is reversed for push. */
900 *valuep
|= 0x80 >> regno
;
902 *valuep
|= 1 << regno
;
907 if (*(*strp
+ 1) == ')')
914 errmsg
= _("Register list is not valid");
923 parse_pop_regset (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
925 int opindex ATTRIBUTE_UNUSED
,
926 unsigned long *valuep
)
928 return parse_regset (cd
, strp
, opindex
, valuep
, POP
);
932 parse_push_regset (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
934 int opindex ATTRIBUTE_UNUSED
,
935 unsigned long *valuep
)
937 return parse_regset (cd
, strp
, opindex
, valuep
, PUSH
);
942 const char * m32c_cgen_parse_operand
943 (CGEN_CPU_DESC
, int, const char **, CGEN_FIELDS
*);
945 /* Main entry point for operand parsing.
947 This function is basically just a big switch statement. Earlier versions
948 used tables to look up the function to use, but
949 - if the table contains both assembler and disassembler functions then
950 the disassembler contains much of the assembler and vice-versa,
951 - there's a lot of inlining possibilities as things grow,
952 - using a switch statement avoids the function call overhead.
954 This function could be moved into `parse_insn_normal', but keeping it
955 separate makes clear the interface between `parse_insn_normal' and each of
959 m32c_cgen_parse_operand (CGEN_CPU_DESC cd
,
962 CGEN_FIELDS
* fields
)
964 const char * errmsg
= NULL
;
965 /* Used by scalar operands that still need to be parsed. */
966 long junk ATTRIBUTE_UNUSED
;
970 case M32C_OPERAND_A0
:
971 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_a0
, & junk
);
973 case M32C_OPERAND_A1
:
974 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_a1
, & junk
);
976 case M32C_OPERAND_AN16_PUSH_S
:
977 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_HI
, & fields
->f_4_1
);
979 case M32C_OPERAND_BIT16AN
:
980 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_dst16_an
);
982 case M32C_OPERAND_BIT16RN
:
983 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_HI
, & fields
->f_dst16_rn
);
985 case M32C_OPERAND_BIT3_S
:
986 errmsg
= parse_bit3_S (cd
, strp
, M32C_OPERAND_BIT3_S
, (long *) (& fields
->f_imm3_S
));
988 case M32C_OPERAND_BIT32ANPREFIXED
:
989 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_dst32_an_prefixed
);
991 case M32C_OPERAND_BIT32ANUNPREFIXED
:
992 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_dst32_an_unprefixed
);
994 case M32C_OPERAND_BIT32RNPREFIXED
:
995 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_QI
, & fields
->f_dst32_rn_prefixed_QI
);
997 case M32C_OPERAND_BIT32RNUNPREFIXED
:
998 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_QI
, & fields
->f_dst32_rn_unprefixed_QI
);
1000 case M32C_OPERAND_BITBASE16_16_S8
:
1001 errmsg
= parse_signed_bitbase8 (cd
, strp
, M32C_OPERAND_BITBASE16_16_S8
, (long *) (& fields
->f_dsp_16_s8
));
1003 case M32C_OPERAND_BITBASE16_16_U16
:
1004 errmsg
= parse_unsigned_bitbase16 (cd
, strp
, M32C_OPERAND_BITBASE16_16_U16
, (unsigned long *) (& fields
->f_dsp_16_u16
));
1006 case M32C_OPERAND_BITBASE16_16_U8
:
1007 errmsg
= parse_unsigned_bitbase8 (cd
, strp
, M32C_OPERAND_BITBASE16_16_U8
, (unsigned long *) (& fields
->f_dsp_16_u8
));
1009 case M32C_OPERAND_BITBASE16_8_U11_S
:
1010 errmsg
= parse_unsigned_bitbase11 (cd
, strp
, M32C_OPERAND_BITBASE16_8_U11_S
, (unsigned long *) (& fields
->f_bitbase16_u11_S
));
1012 case M32C_OPERAND_BITBASE32_16_S11_UNPREFIXED
:
1013 errmsg
= parse_signed_bitbase11 (cd
, strp
, M32C_OPERAND_BITBASE32_16_S11_UNPREFIXED
, (long *) (& fields
->f_bitbase32_16_s11_unprefixed
));
1015 case M32C_OPERAND_BITBASE32_16_S19_UNPREFIXED
:
1016 errmsg
= parse_signed_bitbase19 (cd
, strp
, M32C_OPERAND_BITBASE32_16_S19_UNPREFIXED
, (long *) (& fields
->f_bitbase32_16_s19_unprefixed
));
1018 case M32C_OPERAND_BITBASE32_16_U11_UNPREFIXED
:
1019 errmsg
= parse_unsigned_bitbase11 (cd
, strp
, M32C_OPERAND_BITBASE32_16_U11_UNPREFIXED
, (unsigned long *) (& fields
->f_bitbase32_16_u11_unprefixed
));
1021 case M32C_OPERAND_BITBASE32_16_U19_UNPREFIXED
:
1022 errmsg
= parse_unsigned_bitbase19 (cd
, strp
, M32C_OPERAND_BITBASE32_16_U19_UNPREFIXED
, (unsigned long *) (& fields
->f_bitbase32_16_u19_unprefixed
));
1024 case M32C_OPERAND_BITBASE32_16_U27_UNPREFIXED
:
1025 errmsg
= parse_unsigned_bitbase27 (cd
, strp
, M32C_OPERAND_BITBASE32_16_U27_UNPREFIXED
, (unsigned long *) (& fields
->f_bitbase32_16_u27_unprefixed
));
1027 case M32C_OPERAND_BITBASE32_24_S11_PREFIXED
:
1028 errmsg
= parse_signed_bitbase11 (cd
, strp
, M32C_OPERAND_BITBASE32_24_S11_PREFIXED
, (long *) (& fields
->f_bitbase32_24_s11_prefixed
));
1030 case M32C_OPERAND_BITBASE32_24_S19_PREFIXED
:
1031 errmsg
= parse_signed_bitbase19 (cd
, strp
, M32C_OPERAND_BITBASE32_24_S19_PREFIXED
, (long *) (& fields
->f_bitbase32_24_s19_prefixed
));
1033 case M32C_OPERAND_BITBASE32_24_U11_PREFIXED
:
1034 errmsg
= parse_unsigned_bitbase11 (cd
, strp
, M32C_OPERAND_BITBASE32_24_U11_PREFIXED
, (unsigned long *) (& fields
->f_bitbase32_24_u11_prefixed
));
1036 case M32C_OPERAND_BITBASE32_24_U19_PREFIXED
:
1037 errmsg
= parse_unsigned_bitbase19 (cd
, strp
, M32C_OPERAND_BITBASE32_24_U19_PREFIXED
, (unsigned long *) (& fields
->f_bitbase32_24_u19_prefixed
));
1039 case M32C_OPERAND_BITBASE32_24_U27_PREFIXED
:
1040 errmsg
= parse_unsigned_bitbase27 (cd
, strp
, M32C_OPERAND_BITBASE32_24_U27_PREFIXED
, (unsigned long *) (& fields
->f_bitbase32_24_u27_prefixed
));
1042 case M32C_OPERAND_BITNO16R
:
1043 errmsg
= parse_Bitno16R (cd
, strp
, M32C_OPERAND_BITNO16R
, (unsigned long *) (& fields
->f_dsp_16_u8
));
1045 case M32C_OPERAND_BITNO32PREFIXED
:
1046 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, M32C_OPERAND_BITNO32PREFIXED
, (unsigned long *) (& fields
->f_bitno32_prefixed
));
1048 case M32C_OPERAND_BITNO32UNPREFIXED
:
1049 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, M32C_OPERAND_BITNO32UNPREFIXED
, (unsigned long *) (& fields
->f_bitno32_unprefixed
));
1051 case M32C_OPERAND_DSP_10_U6
:
1052 errmsg
= parse_unsigned6 (cd
, strp
, M32C_OPERAND_DSP_10_U6
, (unsigned long *) (& fields
->f_dsp_10_u6
));
1054 case M32C_OPERAND_DSP_16_S16
:
1055 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_DSP_16_S16
, (long *) (& fields
->f_dsp_16_s16
));
1057 case M32C_OPERAND_DSP_16_S8
:
1058 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_DSP_16_S8
, (long *) (& fields
->f_dsp_16_s8
));
1060 case M32C_OPERAND_DSP_16_U16
:
1061 errmsg
= parse_unsigned16 (cd
, strp
, M32C_OPERAND_DSP_16_U16
, (unsigned long *) (& fields
->f_dsp_16_u16
));
1063 case M32C_OPERAND_DSP_16_U20
:
1064 errmsg
= parse_unsigned20 (cd
, strp
, M32C_OPERAND_DSP_16_U20
, (unsigned long *) (& fields
->f_dsp_16_u24
));
1066 case M32C_OPERAND_DSP_16_U24
:
1067 errmsg
= parse_unsigned24 (cd
, strp
, M32C_OPERAND_DSP_16_U24
, (unsigned long *) (& fields
->f_dsp_16_u24
));
1069 case M32C_OPERAND_DSP_16_U8
:
1070 errmsg
= parse_unsigned8 (cd
, strp
, M32C_OPERAND_DSP_16_U8
, (unsigned long *) (& fields
->f_dsp_16_u8
));
1072 case M32C_OPERAND_DSP_24_S16
:
1073 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_DSP_24_S16
, (long *) (& fields
->f_dsp_24_s16
));
1075 case M32C_OPERAND_DSP_24_S8
:
1076 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_DSP_24_S8
, (long *) (& fields
->f_dsp_24_s8
));
1078 case M32C_OPERAND_DSP_24_U16
:
1079 errmsg
= parse_unsigned16 (cd
, strp
, M32C_OPERAND_DSP_24_U16
, (unsigned long *) (& fields
->f_dsp_24_u16
));
1081 case M32C_OPERAND_DSP_24_U20
:
1082 errmsg
= parse_unsigned20 (cd
, strp
, M32C_OPERAND_DSP_24_U20
, (unsigned long *) (& fields
->f_dsp_24_u24
));
1084 case M32C_OPERAND_DSP_24_U24
:
1085 errmsg
= parse_unsigned24 (cd
, strp
, M32C_OPERAND_DSP_24_U24
, (unsigned long *) (& fields
->f_dsp_24_u24
));
1087 case M32C_OPERAND_DSP_24_U8
:
1088 errmsg
= parse_unsigned8 (cd
, strp
, M32C_OPERAND_DSP_24_U8
, (unsigned long *) (& fields
->f_dsp_24_u8
));
1090 case M32C_OPERAND_DSP_32_S16
:
1091 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_DSP_32_S16
, (long *) (& fields
->f_dsp_32_s16
));
1093 case M32C_OPERAND_DSP_32_S8
:
1094 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_DSP_32_S8
, (long *) (& fields
->f_dsp_32_s8
));
1096 case M32C_OPERAND_DSP_32_U16
:
1097 errmsg
= parse_unsigned16 (cd
, strp
, M32C_OPERAND_DSP_32_U16
, (unsigned long *) (& fields
->f_dsp_32_u16
));
1099 case M32C_OPERAND_DSP_32_U20
:
1100 errmsg
= parse_unsigned20 (cd
, strp
, M32C_OPERAND_DSP_32_U20
, (unsigned long *) (& fields
->f_dsp_32_u24
));
1102 case M32C_OPERAND_DSP_32_U24
:
1103 errmsg
= parse_unsigned24 (cd
, strp
, M32C_OPERAND_DSP_32_U24
, (unsigned long *) (& fields
->f_dsp_32_u24
));
1105 case M32C_OPERAND_DSP_32_U8
:
1106 errmsg
= parse_unsigned8 (cd
, strp
, M32C_OPERAND_DSP_32_U8
, (unsigned long *) (& fields
->f_dsp_32_u8
));
1108 case M32C_OPERAND_DSP_40_S16
:
1109 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_DSP_40_S16
, (long *) (& fields
->f_dsp_40_s16
));
1111 case M32C_OPERAND_DSP_40_S8
:
1112 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_DSP_40_S8
, (long *) (& fields
->f_dsp_40_s8
));
1114 case M32C_OPERAND_DSP_40_U16
:
1115 errmsg
= parse_unsigned16 (cd
, strp
, M32C_OPERAND_DSP_40_U16
, (unsigned long *) (& fields
->f_dsp_40_u16
));
1117 case M32C_OPERAND_DSP_40_U24
:
1118 errmsg
= parse_unsigned24 (cd
, strp
, M32C_OPERAND_DSP_40_U24
, (unsigned long *) (& fields
->f_dsp_40_u24
));
1120 case M32C_OPERAND_DSP_40_U8
:
1121 errmsg
= parse_unsigned8 (cd
, strp
, M32C_OPERAND_DSP_40_U8
, (unsigned long *) (& fields
->f_dsp_40_u8
));
1123 case M32C_OPERAND_DSP_48_S16
:
1124 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_DSP_48_S16
, (long *) (& fields
->f_dsp_48_s16
));
1126 case M32C_OPERAND_DSP_48_S8
:
1127 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_DSP_48_S8
, (long *) (& fields
->f_dsp_48_s8
));
1129 case M32C_OPERAND_DSP_48_U16
:
1130 errmsg
= parse_unsigned16 (cd
, strp
, M32C_OPERAND_DSP_48_U16
, (unsigned long *) (& fields
->f_dsp_48_u16
));
1132 case M32C_OPERAND_DSP_48_U24
:
1133 errmsg
= parse_unsigned24 (cd
, strp
, M32C_OPERAND_DSP_48_U24
, (unsigned long *) (& fields
->f_dsp_48_u24
));
1135 case M32C_OPERAND_DSP_48_U8
:
1136 errmsg
= parse_unsigned8 (cd
, strp
, M32C_OPERAND_DSP_48_U8
, (unsigned long *) (& fields
->f_dsp_48_u8
));
1138 case M32C_OPERAND_DSP_8_S24
:
1139 errmsg
= parse_signed24 (cd
, strp
, M32C_OPERAND_DSP_8_S24
, (long *) (& fields
->f_dsp_8_s24
));
1141 case M32C_OPERAND_DSP_8_S8
:
1142 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_DSP_8_S8
, (long *) (& fields
->f_dsp_8_s8
));
1144 case M32C_OPERAND_DSP_8_U16
:
1145 errmsg
= parse_unsigned16 (cd
, strp
, M32C_OPERAND_DSP_8_U16
, (unsigned long *) (& fields
->f_dsp_8_u16
));
1147 case M32C_OPERAND_DSP_8_U24
:
1148 errmsg
= parse_unsigned24 (cd
, strp
, M32C_OPERAND_DSP_8_U24
, (unsigned long *) (& fields
->f_dsp_8_u24
));
1150 case M32C_OPERAND_DSP_8_U6
:
1151 errmsg
= parse_unsigned6 (cd
, strp
, M32C_OPERAND_DSP_8_U6
, (unsigned long *) (& fields
->f_dsp_8_u6
));
1153 case M32C_OPERAND_DSP_8_U8
:
1154 errmsg
= parse_unsigned8 (cd
, strp
, M32C_OPERAND_DSP_8_U8
, (unsigned long *) (& fields
->f_dsp_8_u8
));
1156 case M32C_OPERAND_DST16AN
:
1157 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_dst16_an
);
1159 case M32C_OPERAND_DST16AN_S
:
1160 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_HI
, & fields
->f_dst16_an_s
);
1162 case M32C_OPERAND_DST16ANHI
:
1163 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_HI
, & fields
->f_dst16_an
);
1165 case M32C_OPERAND_DST16ANQI
:
1166 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_QI
, & fields
->f_dst16_an
);
1168 case M32C_OPERAND_DST16ANQI_S
:
1169 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_QI
, & fields
->f_dst16_rn_QI_s
);
1171 case M32C_OPERAND_DST16ANSI
:
1172 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_SI
, & fields
->f_dst16_an
);
1174 case M32C_OPERAND_DST16RNEXTQI
:
1175 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_ext_QI
, & fields
->f_dst16_rn_ext
);
1177 case M32C_OPERAND_DST16RNHI
:
1178 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_HI
, & fields
->f_dst16_rn
);
1180 case M32C_OPERAND_DST16RNQI
:
1181 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_QI
, & fields
->f_dst16_rn
);
1183 case M32C_OPERAND_DST16RNQI_S
:
1184 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r0l_r0h
, & fields
->f_dst16_rn_QI_s
);
1186 case M32C_OPERAND_DST16RNSI
:
1187 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_SI
, & fields
->f_dst16_rn
);
1189 case M32C_OPERAND_DST32ANEXTUNPREFIXED
:
1190 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_dst32_an_unprefixed
);
1192 case M32C_OPERAND_DST32ANPREFIXED
:
1193 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_dst32_an_prefixed
);
1195 case M32C_OPERAND_DST32ANPREFIXEDHI
:
1196 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_HI
, & fields
->f_dst32_an_prefixed
);
1198 case M32C_OPERAND_DST32ANPREFIXEDQI
:
1199 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_QI
, & fields
->f_dst32_an_prefixed
);
1201 case M32C_OPERAND_DST32ANPREFIXEDSI
:
1202 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_dst32_an_prefixed
);
1204 case M32C_OPERAND_DST32ANUNPREFIXED
:
1205 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_dst32_an_unprefixed
);
1207 case M32C_OPERAND_DST32ANUNPREFIXEDHI
:
1208 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_HI
, & fields
->f_dst32_an_unprefixed
);
1210 case M32C_OPERAND_DST32ANUNPREFIXEDQI
:
1211 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_QI
, & fields
->f_dst32_an_unprefixed
);
1213 case M32C_OPERAND_DST32ANUNPREFIXEDSI
:
1214 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_dst32_an_unprefixed
);
1216 case M32C_OPERAND_DST32R0HI_S
:
1217 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r0
, & junk
);
1219 case M32C_OPERAND_DST32R0QI_S
:
1220 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r0l
, & junk
);
1222 case M32C_OPERAND_DST32RNEXTUNPREFIXEDHI
:
1223 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_ext_HI
, & fields
->f_dst32_rn_ext_unprefixed
);
1225 case M32C_OPERAND_DST32RNEXTUNPREFIXEDQI
:
1226 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_ext_QI
, & fields
->f_dst32_rn_ext_unprefixed
);
1228 case M32C_OPERAND_DST32RNPREFIXEDHI
:
1229 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_HI
, & fields
->f_dst32_rn_prefixed_HI
);
1231 case M32C_OPERAND_DST32RNPREFIXEDQI
:
1232 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_QI
, & fields
->f_dst32_rn_prefixed_QI
);
1234 case M32C_OPERAND_DST32RNPREFIXEDSI
:
1235 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_SI
, & fields
->f_dst32_rn_prefixed_SI
);
1237 case M32C_OPERAND_DST32RNUNPREFIXEDHI
:
1238 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_HI
, & fields
->f_dst32_rn_unprefixed_HI
);
1240 case M32C_OPERAND_DST32RNUNPREFIXEDQI
:
1241 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_QI
, & fields
->f_dst32_rn_unprefixed_QI
);
1243 case M32C_OPERAND_DST32RNUNPREFIXEDSI
:
1244 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_SI
, & fields
->f_dst32_rn_unprefixed_SI
);
1246 case M32C_OPERAND_G
:
1247 errmsg
= parse_G (cd
, strp
, M32C_OPERAND_G
, (long *) (& junk
));
1249 case M32C_OPERAND_IMM_12_S4
:
1250 errmsg
= parse_signed4 (cd
, strp
, M32C_OPERAND_IMM_12_S4
, (long *) (& fields
->f_imm_12_s4
));
1252 case M32C_OPERAND_IMM_12_S4N
:
1253 errmsg
= parse_signed4n (cd
, strp
, M32C_OPERAND_IMM_12_S4N
, (long *) (& fields
->f_imm_12_s4
));
1255 case M32C_OPERAND_IMM_13_U3
:
1256 errmsg
= parse_signed4 (cd
, strp
, M32C_OPERAND_IMM_13_U3
, (long *) (& fields
->f_imm_13_u3
));
1258 case M32C_OPERAND_IMM_16_HI
:
1259 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_IMM_16_HI
, (long *) (& fields
->f_dsp_16_s16
));
1261 case M32C_OPERAND_IMM_16_QI
:
1262 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_IMM_16_QI
, (long *) (& fields
->f_dsp_16_s8
));
1264 case M32C_OPERAND_IMM_16_SI
:
1265 errmsg
= parse_signed32 (cd
, strp
, M32C_OPERAND_IMM_16_SI
, (long *) (& fields
->f_dsp_16_s32
));
1267 case M32C_OPERAND_IMM_20_S4
:
1268 errmsg
= parse_signed4 (cd
, strp
, M32C_OPERAND_IMM_20_S4
, (long *) (& fields
->f_imm_20_s4
));
1270 case M32C_OPERAND_IMM_24_HI
:
1271 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_IMM_24_HI
, (long *) (& fields
->f_dsp_24_s16
));
1273 case M32C_OPERAND_IMM_24_QI
:
1274 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_IMM_24_QI
, (long *) (& fields
->f_dsp_24_s8
));
1276 case M32C_OPERAND_IMM_24_SI
:
1277 errmsg
= parse_signed32 (cd
, strp
, M32C_OPERAND_IMM_24_SI
, (long *) (& fields
->f_dsp_24_s32
));
1279 case M32C_OPERAND_IMM_32_HI
:
1280 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_IMM_32_HI
, (long *) (& fields
->f_dsp_32_s16
));
1282 case M32C_OPERAND_IMM_32_QI
:
1283 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_IMM_32_QI
, (long *) (& fields
->f_dsp_32_s8
));
1285 case M32C_OPERAND_IMM_32_SI
:
1286 errmsg
= parse_signed32 (cd
, strp
, M32C_OPERAND_IMM_32_SI
, (long *) (& fields
->f_dsp_32_s32
));
1288 case M32C_OPERAND_IMM_40_HI
:
1289 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_IMM_40_HI
, (long *) (& fields
->f_dsp_40_s16
));
1291 case M32C_OPERAND_IMM_40_QI
:
1292 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_IMM_40_QI
, (long *) (& fields
->f_dsp_40_s8
));
1294 case M32C_OPERAND_IMM_40_SI
:
1295 errmsg
= parse_signed32 (cd
, strp
, M32C_OPERAND_IMM_40_SI
, (long *) (& fields
->f_dsp_40_s32
));
1297 case M32C_OPERAND_IMM_48_HI
:
1298 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_IMM_48_HI
, (long *) (& fields
->f_dsp_48_s16
));
1300 case M32C_OPERAND_IMM_48_QI
:
1301 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_IMM_48_QI
, (long *) (& fields
->f_dsp_48_s8
));
1303 case M32C_OPERAND_IMM_48_SI
:
1304 errmsg
= parse_signed32 (cd
, strp
, M32C_OPERAND_IMM_48_SI
, (long *) (& fields
->f_dsp_48_s32
));
1306 case M32C_OPERAND_IMM_56_HI
:
1307 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_IMM_56_HI
, (long *) (& fields
->f_dsp_56_s16
));
1309 case M32C_OPERAND_IMM_56_QI
:
1310 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_IMM_56_QI
, (long *) (& fields
->f_dsp_56_s8
));
1312 case M32C_OPERAND_IMM_64_HI
:
1313 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_IMM_64_HI
, (long *) (& fields
->f_dsp_64_s16
));
1315 case M32C_OPERAND_IMM_8_HI
:
1316 errmsg
= parse_signed16 (cd
, strp
, M32C_OPERAND_IMM_8_HI
, (long *) (& fields
->f_dsp_8_s16
));
1318 case M32C_OPERAND_IMM_8_QI
:
1319 errmsg
= parse_signed8 (cd
, strp
, M32C_OPERAND_IMM_8_QI
, (long *) (& fields
->f_dsp_8_s8
));
1321 case M32C_OPERAND_IMM_8_S4
:
1322 errmsg
= parse_signed4 (cd
, strp
, M32C_OPERAND_IMM_8_S4
, (long *) (& fields
->f_imm_8_s4
));
1324 case M32C_OPERAND_IMM_8_S4N
:
1325 errmsg
= parse_signed4n (cd
, strp
, M32C_OPERAND_IMM_8_S4N
, (long *) (& fields
->f_imm_8_s4
));
1327 case M32C_OPERAND_IMM_SH_12_S4
:
1328 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_shimm
, & fields
->f_imm_12_s4
);
1330 case M32C_OPERAND_IMM_SH_20_S4
:
1331 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_shimm
, & fields
->f_imm_20_s4
);
1333 case M32C_OPERAND_IMM_SH_8_S4
:
1334 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_shimm
, & fields
->f_imm_8_s4
);
1336 case M32C_OPERAND_IMM1_S
:
1337 errmsg
= parse_imm1_S (cd
, strp
, M32C_OPERAND_IMM1_S
, (long *) (& fields
->f_imm1_S
));
1339 case M32C_OPERAND_IMM3_S
:
1340 errmsg
= parse_imm3_S (cd
, strp
, M32C_OPERAND_IMM3_S
, (long *) (& fields
->f_imm3_S
));
1342 case M32C_OPERAND_LAB_16_8
:
1345 errmsg
= cgen_parse_address (cd
, strp
, M32C_OPERAND_LAB_16_8
, 0, NULL
, & value
);
1346 fields
->f_lab_16_8
= value
;
1349 case M32C_OPERAND_LAB_24_8
:
1352 errmsg
= cgen_parse_address (cd
, strp
, M32C_OPERAND_LAB_24_8
, 0, NULL
, & value
);
1353 fields
->f_lab_24_8
= value
;
1356 case M32C_OPERAND_LAB_32_8
:
1359 errmsg
= cgen_parse_address (cd
, strp
, M32C_OPERAND_LAB_32_8
, 0, NULL
, & value
);
1360 fields
->f_lab_32_8
= value
;
1363 case M32C_OPERAND_LAB_40_8
:
1366 errmsg
= cgen_parse_address (cd
, strp
, M32C_OPERAND_LAB_40_8
, 0, NULL
, & value
);
1367 fields
->f_lab_40_8
= value
;
1370 case M32C_OPERAND_LAB_5_3
:
1373 errmsg
= parse_lab_5_3 (cd
, strp
, M32C_OPERAND_LAB_5_3
, 0, NULL
, & value
);
1374 fields
->f_lab_5_3
= value
;
1377 case M32C_OPERAND_LAB_8_16
:
1380 errmsg
= cgen_parse_address (cd
, strp
, M32C_OPERAND_LAB_8_16
, 0, NULL
, & value
);
1381 fields
->f_lab_8_16
= value
;
1384 case M32C_OPERAND_LAB_8_24
:
1387 errmsg
= cgen_parse_address (cd
, strp
, M32C_OPERAND_LAB_8_24
, 0, NULL
, & value
);
1388 fields
->f_lab_8_24
= value
;
1391 case M32C_OPERAND_LAB_8_8
:
1394 errmsg
= cgen_parse_address (cd
, strp
, M32C_OPERAND_LAB_8_8
, 0, NULL
, & value
);
1395 fields
->f_lab_8_8
= value
;
1398 case M32C_OPERAND_LAB32_JMP_S
:
1401 errmsg
= parse_lab_5_3 (cd
, strp
, M32C_OPERAND_LAB32_JMP_S
, 0, NULL
, & value
);
1402 fields
->f_lab32_jmp_s
= value
;
1405 case M32C_OPERAND_Q
:
1406 errmsg
= parse_Q (cd
, strp
, M32C_OPERAND_Q
, (long *) (& junk
));
1408 case M32C_OPERAND_R0
:
1409 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r0
, & junk
);
1411 case M32C_OPERAND_R0H
:
1412 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r0h
, & junk
);
1414 case M32C_OPERAND_R0L
:
1415 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r0l
, & junk
);
1417 case M32C_OPERAND_R1
:
1418 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r1
, & junk
);
1420 case M32C_OPERAND_R1R2R0
:
1421 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r1r2r0
, & junk
);
1423 case M32C_OPERAND_R2
:
1424 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r2
, & junk
);
1426 case M32C_OPERAND_R2R0
:
1427 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r2r0
, & junk
);
1429 case M32C_OPERAND_R3
:
1430 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r3
, & junk
);
1432 case M32C_OPERAND_R3R1
:
1433 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_r3r1
, & junk
);
1435 case M32C_OPERAND_REGSETPOP
:
1436 errmsg
= parse_pop_regset (cd
, strp
, M32C_OPERAND_REGSETPOP
, (unsigned long *) (& fields
->f_8_8
));
1438 case M32C_OPERAND_REGSETPUSH
:
1439 errmsg
= parse_push_regset (cd
, strp
, M32C_OPERAND_REGSETPUSH
, (unsigned long *) (& fields
->f_8_8
));
1441 case M32C_OPERAND_RN16_PUSH_S
:
1442 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_QI
, & fields
->f_4_1
);
1444 case M32C_OPERAND_S
:
1445 errmsg
= parse_S (cd
, strp
, M32C_OPERAND_S
, (long *) (& junk
));
1447 case M32C_OPERAND_SRC16AN
:
1448 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_src16_an
);
1450 case M32C_OPERAND_SRC16ANHI
:
1451 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_HI
, & fields
->f_src16_an
);
1453 case M32C_OPERAND_SRC16ANQI
:
1454 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_QI
, & fields
->f_src16_an
);
1456 case M32C_OPERAND_SRC16RNHI
:
1457 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_HI
, & fields
->f_src16_rn
);
1459 case M32C_OPERAND_SRC16RNQI
:
1460 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_QI
, & fields
->f_src16_rn
);
1462 case M32C_OPERAND_SRC32ANPREFIXED
:
1463 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_src32_an_prefixed
);
1465 case M32C_OPERAND_SRC32ANPREFIXEDHI
:
1466 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_HI
, & fields
->f_src32_an_prefixed
);
1468 case M32C_OPERAND_SRC32ANPREFIXEDQI
:
1469 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_QI
, & fields
->f_src32_an_prefixed
);
1471 case M32C_OPERAND_SRC32ANPREFIXEDSI
:
1472 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_src32_an_prefixed
);
1474 case M32C_OPERAND_SRC32ANUNPREFIXED
:
1475 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_src32_an_unprefixed
);
1477 case M32C_OPERAND_SRC32ANUNPREFIXEDHI
:
1478 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_HI
, & fields
->f_src32_an_unprefixed
);
1480 case M32C_OPERAND_SRC32ANUNPREFIXEDQI
:
1481 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar_QI
, & fields
->f_src32_an_unprefixed
);
1483 case M32C_OPERAND_SRC32ANUNPREFIXEDSI
:
1484 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_ar
, & fields
->f_src32_an_unprefixed
);
1486 case M32C_OPERAND_SRC32RNPREFIXEDHI
:
1487 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_HI
, & fields
->f_src32_rn_prefixed_HI
);
1489 case M32C_OPERAND_SRC32RNPREFIXEDQI
:
1490 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_QI
, & fields
->f_src32_rn_prefixed_QI
);
1492 case M32C_OPERAND_SRC32RNPREFIXEDSI
:
1493 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_SI
, & fields
->f_src32_rn_prefixed_SI
);
1495 case M32C_OPERAND_SRC32RNUNPREFIXEDHI
:
1496 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_HI
, & fields
->f_src32_rn_unprefixed_HI
);
1498 case M32C_OPERAND_SRC32RNUNPREFIXEDQI
:
1499 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_QI
, & fields
->f_src32_rn_unprefixed_QI
);
1501 case M32C_OPERAND_SRC32RNUNPREFIXEDSI
:
1502 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_gr_SI
, & fields
->f_src32_rn_unprefixed_SI
);
1504 case M32C_OPERAND_SRCDST16_R0L_R0H_S_NORMAL
:
1505 errmsg
= parse_r0l_r0h (cd
, strp
, M32C_OPERAND_SRCDST16_R0L_R0H_S_NORMAL
, (long *) (& fields
->f_5_1
));
1507 case M32C_OPERAND_X
:
1508 errmsg
= parse_X (cd
, strp
, M32C_OPERAND_X
, (long *) (& junk
));
1510 case M32C_OPERAND_Z
:
1511 errmsg
= parse_Z (cd
, strp
, M32C_OPERAND_Z
, (long *) (& junk
));
1513 case M32C_OPERAND_COND16_16
:
1514 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond16
, & fields
->f_dsp_16_u8
);
1516 case M32C_OPERAND_COND16_24
:
1517 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond16
, & fields
->f_dsp_24_u8
);
1519 case M32C_OPERAND_COND16_32
:
1520 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond16
, & fields
->f_dsp_32_u8
);
1522 case M32C_OPERAND_COND16C
:
1523 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond16c
, & fields
->f_cond16
);
1525 case M32C_OPERAND_COND16J
:
1526 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond16j
, & fields
->f_cond16
);
1528 case M32C_OPERAND_COND16J5
:
1529 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond16j_5
, & fields
->f_cond16j_5
);
1531 case M32C_OPERAND_COND32
:
1532 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond32
, & fields
->f_cond32
);
1534 case M32C_OPERAND_COND32_16
:
1535 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond32
, & fields
->f_dsp_16_u8
);
1537 case M32C_OPERAND_COND32_24
:
1538 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond32
, & fields
->f_dsp_24_u8
);
1540 case M32C_OPERAND_COND32_32
:
1541 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond32
, & fields
->f_dsp_32_u8
);
1543 case M32C_OPERAND_COND32_40
:
1544 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond32
, & fields
->f_dsp_40_u8
);
1546 case M32C_OPERAND_COND32J
:
1547 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond32
, & fields
->f_cond32j
);
1549 case M32C_OPERAND_CR1_PREFIXED_32
:
1550 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cr1_32
, & fields
->f_21_3
);
1552 case M32C_OPERAND_CR1_UNPREFIXED_32
:
1553 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cr1_32
, & fields
->f_13_3
);
1555 case M32C_OPERAND_CR16
:
1556 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cr_16
, & fields
->f_9_3
);
1558 case M32C_OPERAND_CR2_32
:
1559 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cr2_32
, & fields
->f_13_3
);
1561 case M32C_OPERAND_CR3_PREFIXED_32
:
1562 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cr3_32
, & fields
->f_21_3
);
1564 case M32C_OPERAND_CR3_UNPREFIXED_32
:
1565 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cr3_32
, & fields
->f_13_3
);
1567 case M32C_OPERAND_FLAGS16
:
1568 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_flags
, & fields
->f_9_3
);
1570 case M32C_OPERAND_FLAGS32
:
1571 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_flags
, & fields
->f_13_3
);
1573 case M32C_OPERAND_SCCOND32
:
1574 errmsg
= cgen_parse_keyword (cd
, strp
, & m32c_cgen_opval_h_cond32
, & fields
->f_cond16
);
1576 case M32C_OPERAND_SIZE
:
1577 errmsg
= parse_size (cd
, strp
, M32C_OPERAND_SIZE
, (long *) (& junk
));
1581 /* xgettext:c-format */
1582 fprintf (stderr
, _("Unrecognized field %d while parsing.\n"), opindex
);
1589 cgen_parse_fn
* const m32c_cgen_parse_handlers
[] =
1595 m32c_cgen_init_asm (CGEN_CPU_DESC cd
)
1597 m32c_cgen_init_opcode_table (cd
);
1598 m32c_cgen_init_ibld_table (cd
);
1599 cd
->parse_handlers
= & m32c_cgen_parse_handlers
[0];
1600 cd
->parse_operand
= m32c_cgen_parse_operand
;
1605 /* Regex construction routine.
1607 This translates an opcode syntax string into a regex string,
1608 by replacing any non-character syntax element (such as an
1609 opcode) with the pattern '.*'
1611 It then compiles the regex and stores it in the opcode, for
1612 later use by m32c_cgen_assemble_insn
1614 Returns NULL for success, an error message for failure. */
1617 m32c_cgen_build_insn_regex (CGEN_INSN
*insn
)
1619 CGEN_OPCODE
*opc
= (CGEN_OPCODE
*) CGEN_INSN_OPCODE (insn
);
1620 const char *mnem
= CGEN_INSN_MNEMONIC (insn
);
1621 char rxbuf
[CGEN_MAX_RX_ELEMENTS
];
1623 const CGEN_SYNTAX_CHAR_TYPE
*syn
;
1626 syn
= CGEN_SYNTAX_STRING (CGEN_OPCODE_SYNTAX (opc
));
1628 /* Mnemonics come first in the syntax string. */
1629 if (! CGEN_SYNTAX_MNEMONIC_P (* syn
))
1630 return _("missing mnemonic in syntax string");
1633 /* Generate a case sensitive regular expression that emulates case
1634 insensitive matching in the "C" locale. We cannot generate a case
1635 insensitive regular expression because in Turkish locales, 'i' and 'I'
1636 are not equal modulo case conversion. */
1638 /* Copy the literal mnemonic out of the insn. */
1639 for (; *mnem
; mnem
++)
1646 *rx
++ = TOLOWER (c
);
1647 *rx
++ = TOUPPER (c
);
1654 /* Copy any remaining literals from the syntax string into the rx. */
1655 for(; * syn
!= 0 && rx
<= rxbuf
+ (CGEN_MAX_RX_ELEMENTS
- 7 - 4); ++syn
)
1657 if (CGEN_SYNTAX_CHAR_P (* syn
))
1659 char c
= CGEN_SYNTAX_CHAR (* syn
);
1663 /* Escape any regex metacharacters in the syntax. */
1664 case '.': case '[': case '\\':
1665 case '*': case '^': case '$':
1667 #ifdef CGEN_ESCAPE_EXTENDED_REGEX
1668 case '?': case '{': case '}':
1669 case '(': case ')': case '*':
1670 case '|': case '+': case ']':
1680 *rx
++ = TOLOWER (c
);
1681 *rx
++ = TOUPPER (c
);
1691 /* Replace non-syntax fields with globs. */
1697 /* Trailing whitespace ok. */
1704 /* But anchor it after that. */
1708 CGEN_INSN_RX (insn
) = xmalloc (sizeof (regex_t
));
1709 reg_err
= regcomp ((regex_t
*) CGEN_INSN_RX (insn
), rxbuf
, REG_NOSUB
);
1715 static char msg
[80];
1717 regerror (reg_err
, (regex_t
*) CGEN_INSN_RX (insn
), msg
, 80);
1718 regfree ((regex_t
*) CGEN_INSN_RX (insn
));
1719 free (CGEN_INSN_RX (insn
));
1720 (CGEN_INSN_RX (insn
)) = NULL
;
1726 /* Default insn parser.
1728 The syntax string is scanned and operands are parsed and stored in FIELDS.
1729 Relocs are queued as we go via other callbacks.
1731 ??? Note that this is currently an all-or-nothing parser. If we fail to
1732 parse the instruction, we return 0 and the caller will start over from
1733 the beginning. Backtracking will be necessary in parsing subexpressions,
1734 but that can be handled there. Not handling backtracking here may get
1735 expensive in the case of the m68k. Deal with later.
1737 Returns NULL for success, an error message for failure. */
1740 parse_insn_normal (CGEN_CPU_DESC cd
,
1741 const CGEN_INSN
*insn
,
1743 CGEN_FIELDS
*fields
)
1745 /* ??? Runtime added insns not handled yet. */
1746 const CGEN_SYNTAX
*syntax
= CGEN_INSN_SYNTAX (insn
);
1747 const char *str
= *strp
;
1750 const CGEN_SYNTAX_CHAR_TYPE
* syn
;
1751 #ifdef CGEN_MNEMONIC_OPERANDS
1756 /* For now we assume the mnemonic is first (there are no leading operands).
1757 We can parse it without needing to set up operand parsing.
1758 GAS's input scrubber will ensure mnemonics are lowercase, but we may
1759 not be called from GAS. */
1760 p
= CGEN_INSN_MNEMONIC (insn
);
1761 while (*p
&& TOLOWER (*p
) == TOLOWER (*str
))
1765 return _("unrecognized instruction");
1767 #ifndef CGEN_MNEMONIC_OPERANDS
1768 if (* str
&& ! ISSPACE (* str
))
1769 return _("unrecognized instruction");
1772 CGEN_INIT_PARSE (cd
);
1773 cgen_init_parse_operand (cd
);
1774 #ifdef CGEN_MNEMONIC_OPERANDS
1778 /* We don't check for (*str != '\0') here because we want to parse
1779 any trailing fake arguments in the syntax string. */
1780 syn
= CGEN_SYNTAX_STRING (syntax
);
1782 /* Mnemonics come first for now, ensure valid string. */
1783 if (! CGEN_SYNTAX_MNEMONIC_P (* syn
))
1790 /* Non operand chars must match exactly. */
1791 if (CGEN_SYNTAX_CHAR_P (* syn
))
1793 /* FIXME: While we allow for non-GAS callers above, we assume the
1794 first char after the mnemonic part is a space. */
1795 /* FIXME: We also take inappropriate advantage of the fact that
1796 GAS's input scrubber will remove extraneous blanks. */
1797 if (TOLOWER (*str
) == TOLOWER (CGEN_SYNTAX_CHAR (* syn
)))
1799 #ifdef CGEN_MNEMONIC_OPERANDS
1800 if (CGEN_SYNTAX_CHAR(* syn
) == ' ')
1808 /* Syntax char didn't match. Can't be this insn. */
1809 static char msg
[80];
1811 /* xgettext:c-format */
1812 sprintf (msg
, _("syntax error (expected char `%c', found `%c')"),
1813 CGEN_SYNTAX_CHAR(*syn
), *str
);
1818 /* Ran out of input. */
1819 static char msg
[80];
1821 /* xgettext:c-format */
1822 sprintf (msg
, _("syntax error (expected char `%c', found end of instruction)"),
1823 CGEN_SYNTAX_CHAR(*syn
));
1829 /* We have an operand of some sort. */
1830 errmsg
= cd
->parse_operand (cd
, CGEN_SYNTAX_FIELD (*syn
),
1835 /* Done with this operand, continue with next one. */
1839 /* If we're at the end of the syntax string, we're done. */
1842 /* FIXME: For the moment we assume a valid `str' can only contain
1843 blanks now. IE: We needn't try again with a longer version of
1844 the insn and it is assumed that longer versions of insns appear
1845 before shorter ones (eg: lsr r2,r3,1 vs lsr r2,r3). */
1846 while (ISSPACE (* str
))
1850 return _("junk at end of line"); /* FIXME: would like to include `str' */
1855 /* We couldn't parse it. */
1856 return _("unrecognized instruction");
1859 /* Main entry point.
1860 This routine is called for each instruction to be assembled.
1861 STR points to the insn to be assembled.
1862 We assume all necessary tables have been initialized.
1863 The assembled instruction, less any fixups, is stored in BUF.
1864 Remember that if CGEN_INT_INSN_P then BUF is an int and thus the value
1865 still needs to be converted to target byte order, otherwise BUF is an array
1866 of bytes in target byte order.
1867 The result is a pointer to the insn's entry in the opcode table,
1868 or NULL if an error occured (an error message will have already been
1871 Note that when processing (non-alias) macro-insns,
1872 this function recurses.
1874 ??? It's possible to make this cpu-independent.
1875 One would have to deal with a few minor things.
1876 At this point in time doing so would be more of a curiosity than useful
1877 [for example this file isn't _that_ big], but keeping the possibility in
1878 mind helps keep the design clean. */
1881 m32c_cgen_assemble_insn (CGEN_CPU_DESC cd
,
1883 CGEN_FIELDS
*fields
,
1884 CGEN_INSN_BYTES_PTR buf
,
1888 CGEN_INSN_LIST
*ilist
;
1889 const char *parse_errmsg
= NULL
;
1890 const char *insert_errmsg
= NULL
;
1891 int recognized_mnemonic
= 0;
1893 /* Skip leading white space. */
1894 while (ISSPACE (* str
))
1897 /* The instructions are stored in hashed lists.
1898 Get the first in the list. */
1899 ilist
= CGEN_ASM_LOOKUP_INSN (cd
, str
);
1901 /* Keep looking until we find a match. */
1903 for ( ; ilist
!= NULL
; ilist
= CGEN_ASM_NEXT_INSN (ilist
))
1905 const CGEN_INSN
*insn
= ilist
->insn
;
1906 recognized_mnemonic
= 1;
1908 #ifdef CGEN_VALIDATE_INSN_SUPPORTED
1909 /* Not usually needed as unsupported opcodes
1910 shouldn't be in the hash lists. */
1911 /* Is this insn supported by the selected cpu? */
1912 if (! m32c_cgen_insn_supported (cd
, insn
))
1915 /* If the RELAXED attribute is set, this is an insn that shouldn't be
1916 chosen immediately. Instead, it is used during assembler/linker
1917 relaxation if possible. */
1918 if (CGEN_INSN_ATTR_VALUE (insn
, CGEN_INSN_RELAXED
) != 0)
1923 /* Skip this insn if str doesn't look right lexically. */
1924 if (CGEN_INSN_RX (insn
) != NULL
&&
1925 regexec ((regex_t
*) CGEN_INSN_RX (insn
), str
, 0, NULL
, 0) == REG_NOMATCH
)
1928 /* Allow parse/insert handlers to obtain length of insn. */
1929 CGEN_FIELDS_BITSIZE (fields
) = CGEN_INSN_BITSIZE (insn
);
1931 parse_errmsg
= CGEN_PARSE_FN (cd
, insn
) (cd
, insn
, & str
, fields
);
1932 if (parse_errmsg
!= NULL
)
1935 /* ??? 0 is passed for `pc'. */
1936 insert_errmsg
= CGEN_INSERT_FN (cd
, insn
) (cd
, insn
, fields
, buf
,
1938 if (insert_errmsg
!= NULL
)
1941 /* It is up to the caller to actually output the insn and any
1947 static char errbuf
[150];
1948 #ifdef CGEN_VERBOSE_ASSEMBLER_ERRORS
1949 const char *tmp_errmsg
;
1951 /* If requesting verbose error messages, use insert_errmsg.
1952 Failing that, use parse_errmsg. */
1953 tmp_errmsg
= (insert_errmsg
? insert_errmsg
:
1954 parse_errmsg
? parse_errmsg
:
1955 recognized_mnemonic
?
1956 _("unrecognized form of instruction") :
1957 _("unrecognized instruction"));
1959 if (strlen (start
) > 50)
1960 /* xgettext:c-format */
1961 sprintf (errbuf
, "%s `%.50s...'", tmp_errmsg
, start
);
1963 /* xgettext:c-format */
1964 sprintf (errbuf
, "%s `%.50s'", tmp_errmsg
, start
);
1966 if (strlen (start
) > 50)
1967 /* xgettext:c-format */
1968 sprintf (errbuf
, _("bad instruction `%.50s...'"), start
);
1970 /* xgettext:c-format */
1971 sprintf (errbuf
, _("bad instruction `%.50s'"), start
);