1 /* DO NOT EDIT! -*- buffer-read-only: t -*- vi:set ro: */
2 /* Assembler interface for targets using CGEN. -*- C -*-
3 CGEN: Cpu tools GENerator
5 THIS FILE IS MACHINE GENERATED WITH CGEN.
6 - the resultant file is machine generated, cgen-asm.in isn't
8 Copyright (C) 1996-2020 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 "or1k-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. */
54 static const char * MISSING_CLOSING_PARENTHESIS
= N_("missing `)'");
55 static const char * INVALID_STORE_RELOC
= N_("relocation invalid for store");
56 static const char * INVALID_RELOC_TYPE
= N_("internal relocation type invalid");
58 #define CGEN_VERBOSE_ASSEMBLER_ERRORS
61 parse_disp26 (CGEN_CPU_DESC cd
,
64 int opinfo ATTRIBUTE_UNUSED
,
65 enum cgen_parse_operand_result
* resultp
,
68 const char *str
= *strp
;
69 const char *errmsg
= NULL
;
70 bfd_reloc_code_real_type reloc
= BFD_RELOC_OR1K_REL_26
;
72 if (strncasecmp (str
, "plta(", 5) == 0)
75 reloc
= BFD_RELOC_OR1K_PLTA26
;
77 else if (strncasecmp (str
, "plt(", 4) == 0)
80 reloc
= BFD_RELOC_OR1K_PLT26
;
83 errmsg
= cgen_parse_address (cd
, strp
, opindex
, reloc
, resultp
, valuep
);
85 if (reloc
!= BFD_RELOC_OR1K_REL_26
)
88 errmsg
= MISSING_CLOSING_PARENTHESIS
;
97 parse_disp21 (CGEN_CPU_DESC cd
,
100 int opinfo ATTRIBUTE_UNUSED
,
101 enum cgen_parse_operand_result
* resultp
,
104 const char *str
= *strp
;
105 const char *errmsg
= NULL
;
106 bfd_reloc_code_real_type reloc
= BFD_RELOC_OR1K_PCREL_PG21
;
108 if (strncasecmp (str
, "got(", 4) == 0)
111 reloc
= BFD_RELOC_OR1K_GOT_PG21
;
113 else if (strncasecmp (str
, "tlsgd(", 6) == 0)
116 reloc
= BFD_RELOC_OR1K_TLS_GD_PG21
;
118 else if (strncasecmp (str
, "tlsldm(", 7) == 0)
121 reloc
= BFD_RELOC_OR1K_TLS_LDM_PG21
;
123 else if (strncasecmp (str
, "gottp(", 6) == 0)
126 reloc
= BFD_RELOC_OR1K_TLS_IE_PG21
;
129 errmsg
= cgen_parse_address (cd
, strp
, opindex
, reloc
, resultp
, valuep
);
131 if (reloc
!= BFD_RELOC_OR1K_PCREL_PG21
)
134 errmsg
= MISSING_CLOSING_PARENTHESIS
;
165 #define RCLASS_SHIFT 3
168 static const bfd_reloc_code_real_type or1k_imm16_relocs
[][6] = {
170 BFD_RELOC_OR1K_SLO16
,
172 BFD_RELOC_OR1K_SLO13
,
175 { BFD_RELOC_OR1K_GOT16
,
177 BFD_RELOC_OR1K_GOT_LO13
,
181 { BFD_RELOC_OR1K_GOTPC_LO16
,
185 BFD_RELOC_OR1K_GOTPC_HI16
,
187 { BFD_RELOC_LO16_GOTOFF
,
188 BFD_RELOC_OR1K_GOTOFF_SLO16
,
191 BFD_RELOC_HI16_GOTOFF
,
192 BFD_RELOC_HI16_S_GOTOFF
},
193 { BFD_RELOC_OR1K_TLS_GD_LO16
,
195 BFD_RELOC_OR1K_TLS_GD_LO13
,
197 BFD_RELOC_OR1K_TLS_GD_HI16
,
199 { BFD_RELOC_OR1K_TLS_LDM_LO16
,
201 BFD_RELOC_OR1K_TLS_LDM_LO13
,
203 BFD_RELOC_OR1K_TLS_LDM_HI16
,
205 { BFD_RELOC_OR1K_TLS_LDO_LO16
,
209 BFD_RELOC_OR1K_TLS_LDO_HI16
,
211 { BFD_RELOC_OR1K_TLS_IE_LO16
,
213 BFD_RELOC_OR1K_TLS_IE_LO13
,
215 BFD_RELOC_OR1K_TLS_IE_HI16
,
216 BFD_RELOC_OR1K_TLS_IE_AHI16
},
217 { BFD_RELOC_OR1K_TLS_LE_LO16
,
218 BFD_RELOC_OR1K_TLS_LE_SLO16
,
221 BFD_RELOC_OR1K_TLS_LE_HI16
,
222 BFD_RELOC_OR1K_TLS_LE_AHI16
},
226 parse_reloc (const char **strp
)
228 const char *str
= *strp
;
229 enum or1k_rclass cls
= RCLASS_DIRECT
;
232 if (strncasecmp (str
, "got(", 4) == 0)
235 return (RCLASS_GOT
<< RCLASS_SHIFT
) | RTYPE_LO
;
237 if (strncasecmp (str
, "gotpo(", 6) == 0)
240 return (RCLASS_GOT
<< RCLASS_SHIFT
) | RTYPE_PO
;
242 if (strncasecmp (str
, "gottppo(", 8) == 0)
245 return (RCLASS_GOTTPOFF
<< RCLASS_SHIFT
) | RTYPE_PO
;
248 if (strncasecmp (str
, "gotpc", 5) == 0)
253 else if (strncasecmp (str
, "gotoff", 6) == 0)
258 else if (strncasecmp (str
, "tlsgd", 5) == 0)
263 else if (strncasecmp (str
, "tlsldm", 6) == 0)
268 else if (strncasecmp (str
, "dtpoff", 6) == 0)
273 else if (strncasecmp (str
, "gottpoff", 8) == 0)
276 cls
= RCLASS_GOTTPOFF
;
278 else if (strncasecmp (str
, "tpoff", 5) == 0)
284 if (strncasecmp (str
, "hi(", 3) == 0)
289 else if (strncasecmp (str
, "lo(", 3) == 0)
294 else if (strncasecmp (str
, "ha(", 3) == 0)
299 else if (strncasecmp (str
, "po(", 3) == 0 && cls
!= RCLASS_GOTTPOFF
)
308 return (cls
<< RCLASS_SHIFT
) | typ
;
312 parse_imm16 (CGEN_CPU_DESC cd
, const char **strp
, int opindex
,
313 long *valuep
, int splitp
)
316 enum cgen_parse_operand_result result_type
;
317 bfd_reloc_code_real_type reloc
= BFD_RELOC_UNUSED
;
318 enum or1k_rtype reloc_type
;
325 reloc_code
= parse_reloc (strp
);
326 reloc_type
= reloc_code
& RTYPE_MASK
;
329 enum or1k_rclass reloc_class
= reloc_code
>> RCLASS_SHIFT
;
332 if ((reloc_type
== RTYPE_LO
|| reloc_type
== RTYPE_PO
)
333 && reloc_class
!= RCLASS_GOT
)
334 /* If split we or up the type to RTYPE_SLO or RTYPE_SPO. */
337 return INVALID_STORE_RELOC
;
339 reloc
= or1k_imm16_relocs
[reloc_class
][reloc_type
];
342 if (reloc
!= BFD_RELOC_UNUSED
)
346 errmsg
= cgen_parse_address (cd
, strp
, opindex
, reloc
,
347 &result_type
, &value
);
349 errmsg
= MISSING_CLOSING_PARENTHESIS
;
354 if (errmsg
== NULL
&& result_type
== CGEN_PARSE_OPERAND_RESULT_NUMBER
)
366 ret
= (ret
^ 0x8000) - 0x8000;
373 errmsg
= INVALID_RELOC_TYPE
;
379 errmsg
= cgen_parse_signed_integer (cd
, strp
, opindex
, &value
);
390 parse_simm16 (CGEN_CPU_DESC cd
, const char **strp
, int opindex
, long *valuep
)
392 return parse_imm16(cd
, strp
, opindex
, (long *) valuep
, 0);
396 parse_simm16_split (CGEN_CPU_DESC cd
, const char **strp
, int opindex
,
399 return parse_imm16(cd
, strp
, opindex
, (long *) valuep
, 1);
403 parse_uimm16 (CGEN_CPU_DESC cd
, const char **strp
, int opindex
,
404 unsigned long *valuep
)
406 const char *errmsg
= parse_imm16(cd
, strp
, opindex
, (long *) valuep
, 0);
413 parse_uimm16_split (CGEN_CPU_DESC cd
, const char **strp
, int opindex
,
414 unsigned long *valuep
)
416 const char *errmsg
= parse_imm16(cd
, strp
, opindex
, (long *) valuep
, 1);
422 /* Parse register pairs with syntax rA,rB to a flag + rA value. */
425 parse_regpair (CGEN_CPU_DESC cd
, const char **strp
,
426 int opindex ATTRIBUTE_UNUSED
, unsigned long *valuep
)
432 /* The first part should just be a register. */
433 errmsg
= cgen_parse_keyword (cd
, strp
, &or1k_cgen_opval_h_gpr
,
436 /* If that worked skip the comma separator. */
442 errmsg
= "Unexpected character, expected ','";
445 /* If that worked the next part is just another register. */
447 errmsg
= cgen_parse_keyword (cd
, strp
, &or1k_cgen_opval_h_gpr
,
450 /* Validate the register pair is valid and create the output value. */
453 int regoffset
= reg2_index
- reg1_index
;
455 if (regoffset
== 1 || regoffset
== 2)
457 unsigned short offsetmask
;
458 unsigned short value
;
460 offsetmask
= ((regoffset
== 2 ? 1 : 0) << 5);
461 value
= offsetmask
| reg1_index
;
466 errmsg
= "Invalid register pair, offset not 1 or 2.";
474 const char * or1k_cgen_parse_operand
475 (CGEN_CPU_DESC
, int, const char **, CGEN_FIELDS
*);
477 /* Main entry point for operand parsing.
479 This function is basically just a big switch statement. Earlier versions
480 used tables to look up the function to use, but
481 - if the table contains both assembler and disassembler functions then
482 the disassembler contains much of the assembler and vice-versa,
483 - there's a lot of inlining possibilities as things grow,
484 - using a switch statement avoids the function call overhead.
486 This function could be moved into `parse_insn_normal', but keeping it
487 separate makes clear the interface between `parse_insn_normal' and each of
491 or1k_cgen_parse_operand (CGEN_CPU_DESC cd
,
494 CGEN_FIELDS
* fields
)
496 const char * errmsg
= NULL
;
497 /* Used by scalar operands that still need to be parsed. */
498 long junk ATTRIBUTE_UNUSED
;
502 case OR1K_OPERAND_DISP21
:
505 errmsg
= parse_disp21 (cd
, strp
, OR1K_OPERAND_DISP21
, 0, NULL
, & value
);
506 fields
->f_disp21
= value
;
509 case OR1K_OPERAND_DISP26
:
512 errmsg
= parse_disp26 (cd
, strp
, OR1K_OPERAND_DISP26
, 0, NULL
, & value
);
513 fields
->f_disp26
= value
;
516 case OR1K_OPERAND_RA
:
517 errmsg
= cgen_parse_keyword (cd
, strp
, & or1k_cgen_opval_h_gpr
, & fields
->f_r2
);
519 case OR1K_OPERAND_RAD32F
:
520 errmsg
= parse_regpair (cd
, strp
, OR1K_OPERAND_RAD32F
, (unsigned long *) (& fields
->f_rad32
));
522 case OR1K_OPERAND_RADI
:
523 errmsg
= parse_regpair (cd
, strp
, OR1K_OPERAND_RADI
, (unsigned long *) (& fields
->f_rad32
));
525 case OR1K_OPERAND_RASF
:
526 errmsg
= cgen_parse_keyword (cd
, strp
, & or1k_cgen_opval_h_fsr
, & fields
->f_r2
);
528 case OR1K_OPERAND_RB
:
529 errmsg
= cgen_parse_keyword (cd
, strp
, & or1k_cgen_opval_h_gpr
, & fields
->f_r3
);
531 case OR1K_OPERAND_RBD32F
:
532 errmsg
= parse_regpair (cd
, strp
, OR1K_OPERAND_RBD32F
, (unsigned long *) (& fields
->f_rbd32
));
534 case OR1K_OPERAND_RBDI
:
535 errmsg
= parse_regpair (cd
, strp
, OR1K_OPERAND_RBDI
, (unsigned long *) (& fields
->f_rbd32
));
537 case OR1K_OPERAND_RBSF
:
538 errmsg
= cgen_parse_keyword (cd
, strp
, & or1k_cgen_opval_h_fsr
, & fields
->f_r3
);
540 case OR1K_OPERAND_RD
:
541 errmsg
= cgen_parse_keyword (cd
, strp
, & or1k_cgen_opval_h_gpr
, & fields
->f_r1
);
543 case OR1K_OPERAND_RDD32F
:
544 errmsg
= parse_regpair (cd
, strp
, OR1K_OPERAND_RDD32F
, (unsigned long *) (& fields
->f_rdd32
));
546 case OR1K_OPERAND_RDDI
:
547 errmsg
= parse_regpair (cd
, strp
, OR1K_OPERAND_RDDI
, (unsigned long *) (& fields
->f_rdd32
));
549 case OR1K_OPERAND_RDSF
:
550 errmsg
= cgen_parse_keyword (cd
, strp
, & or1k_cgen_opval_h_fsr
, & fields
->f_r1
);
552 case OR1K_OPERAND_SIMM16
:
553 errmsg
= parse_simm16 (cd
, strp
, OR1K_OPERAND_SIMM16
, (long *) (& fields
->f_simm16
));
555 case OR1K_OPERAND_SIMM16_SPLIT
:
556 errmsg
= parse_simm16_split (cd
, strp
, OR1K_OPERAND_SIMM16_SPLIT
, (long *) (& fields
->f_simm16_split
));
558 case OR1K_OPERAND_UIMM16
:
559 errmsg
= parse_uimm16 (cd
, strp
, OR1K_OPERAND_UIMM16
, (unsigned long *) (& fields
->f_uimm16
));
561 case OR1K_OPERAND_UIMM16_SPLIT
:
562 errmsg
= parse_uimm16_split (cd
, strp
, OR1K_OPERAND_UIMM16_SPLIT
, (unsigned long *) (& fields
->f_uimm16_split
));
564 case OR1K_OPERAND_UIMM6
:
565 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, OR1K_OPERAND_UIMM6
, (unsigned long *) (& fields
->f_uimm6
));
569 /* xgettext:c-format */
570 opcodes_error_handler
571 (_("internal error: unrecognized field %d while parsing"),
579 cgen_parse_fn
* const or1k_cgen_parse_handlers
[] =
585 or1k_cgen_init_asm (CGEN_CPU_DESC cd
)
587 or1k_cgen_init_opcode_table (cd
);
588 or1k_cgen_init_ibld_table (cd
);
589 cd
->parse_handlers
= & or1k_cgen_parse_handlers
[0];
590 cd
->parse_operand
= or1k_cgen_parse_operand
;
591 #ifdef CGEN_ASM_INIT_HOOK
598 /* Regex construction routine.
600 This translates an opcode syntax string into a regex string,
601 by replacing any non-character syntax element (such as an
602 opcode) with the pattern '.*'
604 It then compiles the regex and stores it in the opcode, for
605 later use by or1k_cgen_assemble_insn
607 Returns NULL for success, an error message for failure. */
610 or1k_cgen_build_insn_regex (CGEN_INSN
*insn
)
612 CGEN_OPCODE
*opc
= (CGEN_OPCODE
*) CGEN_INSN_OPCODE (insn
);
613 const char *mnem
= CGEN_INSN_MNEMONIC (insn
);
614 char rxbuf
[CGEN_MAX_RX_ELEMENTS
];
616 const CGEN_SYNTAX_CHAR_TYPE
*syn
;
619 syn
= CGEN_SYNTAX_STRING (CGEN_OPCODE_SYNTAX (opc
));
621 /* Mnemonics come first in the syntax string. */
622 if (! CGEN_SYNTAX_MNEMONIC_P (* syn
))
623 return _("missing mnemonic in syntax string");
626 /* Generate a case sensitive regular expression that emulates case
627 insensitive matching in the "C" locale. We cannot generate a case
628 insensitive regular expression because in Turkish locales, 'i' and 'I'
629 are not equal modulo case conversion. */
631 /* Copy the literal mnemonic out of the insn. */
632 for (; *mnem
; mnem
++)
647 /* Copy any remaining literals from the syntax string into the rx. */
648 for(; * syn
!= 0 && rx
<= rxbuf
+ (CGEN_MAX_RX_ELEMENTS
- 7 - 4); ++syn
)
650 if (CGEN_SYNTAX_CHAR_P (* syn
))
652 char c
= CGEN_SYNTAX_CHAR (* syn
);
656 /* Escape any regex metacharacters in the syntax. */
657 case '.': case '[': case '\\':
658 case '*': case '^': case '$':
660 #ifdef CGEN_ESCAPE_EXTENDED_REGEX
661 case '?': case '{': case '}':
662 case '(': case ')': case '*':
663 case '|': case '+': case ']':
684 /* Replace non-syntax fields with globs. */
690 /* Trailing whitespace ok. */
697 /* But anchor it after that. */
701 CGEN_INSN_RX (insn
) = xmalloc (sizeof (regex_t
));
702 reg_err
= regcomp ((regex_t
*) CGEN_INSN_RX (insn
), rxbuf
, REG_NOSUB
);
710 regerror (reg_err
, (regex_t
*) CGEN_INSN_RX (insn
), msg
, 80);
711 regfree ((regex_t
*) CGEN_INSN_RX (insn
));
712 free (CGEN_INSN_RX (insn
));
713 (CGEN_INSN_RX (insn
)) = NULL
;
719 /* Default insn parser.
721 The syntax string is scanned and operands are parsed and stored in FIELDS.
722 Relocs are queued as we go via other callbacks.
724 ??? Note that this is currently an all-or-nothing parser. If we fail to
725 parse the instruction, we return 0 and the caller will start over from
726 the beginning. Backtracking will be necessary in parsing subexpressions,
727 but that can be handled there. Not handling backtracking here may get
728 expensive in the case of the m68k. Deal with later.
730 Returns NULL for success, an error message for failure. */
733 parse_insn_normal (CGEN_CPU_DESC cd
,
734 const CGEN_INSN
*insn
,
738 /* ??? Runtime added insns not handled yet. */
739 const CGEN_SYNTAX
*syntax
= CGEN_INSN_SYNTAX (insn
);
740 const char *str
= *strp
;
743 const CGEN_SYNTAX_CHAR_TYPE
* syn
;
744 #ifdef CGEN_MNEMONIC_OPERANDS
749 /* For now we assume the mnemonic is first (there are no leading operands).
750 We can parse it without needing to set up operand parsing.
751 GAS's input scrubber will ensure mnemonics are lowercase, but we may
752 not be called from GAS. */
753 p
= CGEN_INSN_MNEMONIC (insn
);
754 while (*p
&& TOLOWER (*p
) == TOLOWER (*str
))
758 return _("unrecognized instruction");
760 #ifndef CGEN_MNEMONIC_OPERANDS
761 if (* str
&& ! ISSPACE (* str
))
762 return _("unrecognized instruction");
765 CGEN_INIT_PARSE (cd
);
766 cgen_init_parse_operand (cd
);
767 #ifdef CGEN_MNEMONIC_OPERANDS
771 /* We don't check for (*str != '\0') here because we want to parse
772 any trailing fake arguments in the syntax string. */
773 syn
= CGEN_SYNTAX_STRING (syntax
);
775 /* Mnemonics come first for now, ensure valid string. */
776 if (! CGEN_SYNTAX_MNEMONIC_P (* syn
))
783 /* Non operand chars must match exactly. */
784 if (CGEN_SYNTAX_CHAR_P (* syn
))
786 /* FIXME: While we allow for non-GAS callers above, we assume the
787 first char after the mnemonic part is a space. */
788 /* FIXME: We also take inappropriate advantage of the fact that
789 GAS's input scrubber will remove extraneous blanks. */
790 if (TOLOWER (*str
) == TOLOWER (CGEN_SYNTAX_CHAR (* syn
)))
792 #ifdef CGEN_MNEMONIC_OPERANDS
793 if (CGEN_SYNTAX_CHAR(* syn
) == ' ')
801 /* Syntax char didn't match. Can't be this insn. */
802 static char msg
[80];
804 /* xgettext:c-format */
805 sprintf (msg
, _("syntax error (expected char `%c', found `%c')"),
806 CGEN_SYNTAX_CHAR(*syn
), *str
);
811 /* Ran out of input. */
812 static char msg
[80];
814 /* xgettext:c-format */
815 sprintf (msg
, _("syntax error (expected char `%c', found end of instruction)"),
816 CGEN_SYNTAX_CHAR(*syn
));
822 #ifdef CGEN_MNEMONIC_OPERANDS
823 (void) past_opcode_p
;
825 /* We have an operand of some sort. */
826 errmsg
= cd
->parse_operand (cd
, CGEN_SYNTAX_FIELD (*syn
), &str
, fields
);
830 /* Done with this operand, continue with next one. */
834 /* If we're at the end of the syntax string, we're done. */
837 /* FIXME: For the moment we assume a valid `str' can only contain
838 blanks now. IE: We needn't try again with a longer version of
839 the insn and it is assumed that longer versions of insns appear
840 before shorter ones (eg: lsr r2,r3,1 vs lsr r2,r3). */
841 while (ISSPACE (* str
))
845 return _("junk at end of line"); /* FIXME: would like to include `str' */
850 /* We couldn't parse it. */
851 return _("unrecognized instruction");
855 This routine is called for each instruction to be assembled.
856 STR points to the insn to be assembled.
857 We assume all necessary tables have been initialized.
858 The assembled instruction, less any fixups, is stored in BUF.
859 Remember that if CGEN_INT_INSN_P then BUF is an int and thus the value
860 still needs to be converted to target byte order, otherwise BUF is an array
861 of bytes in target byte order.
862 The result is a pointer to the insn's entry in the opcode table,
863 or NULL if an error occured (an error message will have already been
866 Note that when processing (non-alias) macro-insns,
867 this function recurses.
869 ??? It's possible to make this cpu-independent.
870 One would have to deal with a few minor things.
871 At this point in time doing so would be more of a curiosity than useful
872 [for example this file isn't _that_ big], but keeping the possibility in
873 mind helps keep the design clean. */
876 or1k_cgen_assemble_insn (CGEN_CPU_DESC cd
,
879 CGEN_INSN_BYTES_PTR buf
,
883 CGEN_INSN_LIST
*ilist
;
884 const char *parse_errmsg
= NULL
;
885 const char *insert_errmsg
= NULL
;
886 int recognized_mnemonic
= 0;
888 /* Skip leading white space. */
889 while (ISSPACE (* str
))
892 /* The instructions are stored in hashed lists.
893 Get the first in the list. */
894 ilist
= CGEN_ASM_LOOKUP_INSN (cd
, str
);
896 /* Keep looking until we find a match. */
898 for ( ; ilist
!= NULL
; ilist
= CGEN_ASM_NEXT_INSN (ilist
))
900 const CGEN_INSN
*insn
= ilist
->insn
;
901 recognized_mnemonic
= 1;
903 #ifdef CGEN_VALIDATE_INSN_SUPPORTED
904 /* Not usually needed as unsupported opcodes
905 shouldn't be in the hash lists. */
906 /* Is this insn supported by the selected cpu? */
907 if (! or1k_cgen_insn_supported (cd
, insn
))
910 /* If the RELAXED attribute is set, this is an insn that shouldn't be
911 chosen immediately. Instead, it is used during assembler/linker
912 relaxation if possible. */
913 if (CGEN_INSN_ATTR_VALUE (insn
, CGEN_INSN_RELAXED
) != 0)
918 /* Skip this insn if str doesn't look right lexically. */
919 if (CGEN_INSN_RX (insn
) != NULL
&&
920 regexec ((regex_t
*) CGEN_INSN_RX (insn
), str
, 0, NULL
, 0) == REG_NOMATCH
)
923 /* Allow parse/insert handlers to obtain length of insn. */
924 CGEN_FIELDS_BITSIZE (fields
) = CGEN_INSN_BITSIZE (insn
);
926 parse_errmsg
= CGEN_PARSE_FN (cd
, insn
) (cd
, insn
, & str
, fields
);
927 if (parse_errmsg
!= NULL
)
930 /* ??? 0 is passed for `pc'. */
931 insert_errmsg
= CGEN_INSERT_FN (cd
, insn
) (cd
, insn
, fields
, buf
,
933 if (insert_errmsg
!= NULL
)
936 /* It is up to the caller to actually output the insn and any
942 static char errbuf
[150];
943 const char *tmp_errmsg
;
944 #ifdef CGEN_VERBOSE_ASSEMBLER_ERRORS
952 /* If requesting verbose error messages, use insert_errmsg.
953 Failing that, use parse_errmsg. */
954 tmp_errmsg
= (insert_errmsg
? insert_errmsg
:
955 parse_errmsg
? parse_errmsg
:
956 recognized_mnemonic
?
957 _("unrecognized form of instruction") :
958 _("unrecognized instruction"));
960 if (strlen (start
) > 50)
961 /* xgettext:c-format */
962 sprintf (errbuf
, "%s `%.50s...'", tmp_errmsg
, start
);
964 /* xgettext:c-format */
965 sprintf (errbuf
, "%s `%.50s'", tmp_errmsg
, start
);
969 if (strlen (start
) > 50)
970 /* xgettext:c-format */
971 sprintf (errbuf
, _("bad instruction `%.50s...'"), start
);
973 /* xgettext:c-format */
974 sprintf (errbuf
, _("bad instruction `%.50s'"), start
);