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 Free Software Foundation, Inc.
9 This file is part of the GNU Binutils and GDB, the GNU debugger.
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2, or (at your option)
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software Foundation, Inc.,
23 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
25 /* ??? Eventually more and more of this stuff can go to cpu-independent files.
33 #include "iq2000-desc.h"
34 #include "iq2000-opc.h"
37 #include "libiberty.h"
38 #include "safe-ctype.h"
41 #define min(a,b) ((a) < (b) ? (a) : (b))
43 #define max(a,b) ((a) > (b) ? (a) : (b))
45 static const char * parse_insn_normal
46 (CGEN_CPU_DESC
, const CGEN_INSN
*, const char **, CGEN_FIELDS
*);
48 /* -- assembler routines inserted here. */
52 #include "safe-ctype.h"
54 static int iq2000_cgen_isa_register
PARAMS ((const char **));
55 static const char * parse_jtargq10
PARAMS ((CGEN_CPU_DESC
, const char **, int, int, enum cgen_parse_operand_result
*, bfd_vma
*));
56 static const char * parse_mimm
PARAMS ((CGEN_CPU_DESC
, const char **, int, unsigned long *));
57 static const char * parse_imm
PARAMS ((CGEN_CPU_DESC
, const char **, int, unsigned long *));
58 static const char * parse_hi16
PARAMS ((CGEN_CPU_DESC
, const char **, int, unsigned long *));
59 static const char * parse_lo16
PARAMS ((CGEN_CPU_DESC
, const char **, int, unsigned long *));
60 static const char * parse_mlo16
PARAMS ((CGEN_CPU_DESC
, const char **, int, unsigned long *));
62 /* Special check to ensure that instruction exists for given machine */
64 iq2000_cgen_insn_supported (cd
, insn
)
66 const CGEN_INSN
*insn
;
68 int machs
= cd
->machs
;
70 return ((CGEN_INSN_ATTR_VALUE (insn
, CGEN_INSN_MACH
) & machs
) != 0);
73 static int iq2000_cgen_isa_register (strp
)
78 if (**strp
== 'r' || **strp
== 'R')
84 if ('0' <= ch1
&& ch1
<= '9')
91 if (('1' <= ch1
&& ch1
<= '2') && ('0' <= ch2
&& ch2
<= '9'))
93 if ('3' == ch1
&& (ch2
== '0' || ch2
== '1'))
97 if (**strp
== '%' && TOLOWER((*strp
)[1]) != 'l' && TOLOWER((*strp
)[1]) != 'h')
102 /* Handle negated literal. */
105 parse_mimm (cd
, strp
, opindex
, valuep
)
109 unsigned long *valuep
;
113 /* Verify this isn't a register. */
114 if (iq2000_cgen_isa_register (strp
))
115 errmsg
= _("immediate value cannot be register");
120 errmsg
= cgen_parse_signed_integer (cd
, strp
, opindex
, & value
);
123 long x
= (-value
) & 0xFFFF0000;
125 if (x
!= 0 && x
!= (long) 0xFFFF0000)
126 errmsg
= _("immediate value out of range");
128 *valuep
= (-value
& 0xFFFF);
134 /* Handle signed/unsigned literal. */
137 parse_imm (cd
, strp
, opindex
, valuep
)
141 unsigned long *valuep
;
145 if (iq2000_cgen_isa_register (strp
))
146 errmsg
= _("immediate value cannot be register");
151 errmsg
= cgen_parse_signed_integer (cd
, strp
, opindex
, & value
);
154 long x
= value
& 0xFFFF0000;
155 if (x
!= 0 && x
!= (long) 0xFFFF0000)
156 errmsg
= _("immediate value out of range");
158 *valuep
= (value
& 0xFFFF);
164 /* Handle iq10 21-bit jmp offset. */
167 parse_jtargq10 (cd
, strp
, opindex
, reloc
, type_addr
, valuep
)
171 int reloc ATTRIBUTE_UNUSED
;
172 enum cgen_parse_operand_result
*type_addr ATTRIBUTE_UNUSED
;
177 enum cgen_parse_operand_result result_type
= CGEN_PARSE_OPERAND_RESULT_NUMBER
;
179 errmsg
= cgen_parse_address (cd
, strp
, opindex
, BFD_RELOC_IQ2000_OFFSET_21
,
180 &result_type
, &value
);
181 if (errmsg
== NULL
&& result_type
== CGEN_PARSE_OPERAND_RESULT_NUMBER
)
183 /* Check value is within 23-bits (remembering that 2-bit shift right will occur). */
184 if (value
> 0x7fffff)
185 return _("21-bit offset out of range");
187 *valuep
= (value
& 0x7FFFFF);
194 parse_hi16 (cd
, strp
, opindex
, valuep
)
198 unsigned long *valuep
;
200 if (strncasecmp (*strp
, "%hi(", 4) == 0)
202 enum cgen_parse_operand_result result_type
;
207 errmsg
= cgen_parse_address (cd
, strp
, opindex
, BFD_RELOC_HI16
,
208 &result_type
, &value
);
210 return _("missing `)'");
214 && result_type
== CGEN_PARSE_OPERAND_RESULT_NUMBER
)
216 /* if value has top-bit of %lo on, then it will
217 sign-propagate and so we compensate by adding
218 1 to the resultant %hi value */
228 /* we add %uhi in case a user just wants the high 16-bits or is using
229 an insn like ori for %lo which does not sign-propagate */
230 if (strncasecmp (*strp
, "%uhi(", 5) == 0)
232 enum cgen_parse_operand_result result_type
;
237 errmsg
= cgen_parse_address (cd
, strp
, opindex
, BFD_RELOC_IQ2000_UHI16
,
238 &result_type
, &value
);
240 return _("missing `)'");
244 && result_type
== CGEN_PARSE_OPERAND_RESULT_NUMBER
)
253 return parse_imm (cd
, strp
, opindex
, valuep
);
256 /* Handle %lo in a signed context.
257 The signedness of the value doesn't matter to %lo(), but this also
258 handles the case where %lo() isn't present. */
261 parse_lo16 (cd
, strp
, opindex
, valuep
)
265 unsigned long *valuep
;
267 if (strncasecmp (*strp
, "%lo(", 4) == 0)
270 enum cgen_parse_operand_result result_type
;
274 errmsg
= cgen_parse_address (cd
, strp
, opindex
, BFD_RELOC_LO16
,
275 &result_type
, &value
);
277 return _("missing `)'");
280 && result_type
== CGEN_PARSE_OPERAND_RESULT_NUMBER
)
286 return parse_imm (cd
, strp
, opindex
, valuep
);
289 /* Handle %lo in a negated signed context.
290 The signedness of the value doesn't matter to %lo(), but this also
291 handles the case where %lo() isn't present. */
294 parse_mlo16 (cd
, strp
, opindex
, valuep
)
298 unsigned long *valuep
;
300 if (strncasecmp (*strp
, "%lo(", 4) == 0)
303 enum cgen_parse_operand_result result_type
;
307 errmsg
= cgen_parse_address (cd
, strp
, opindex
, BFD_RELOC_LO16
,
308 &result_type
, &value
);
310 return _("missing `)'");
313 && result_type
== CGEN_PARSE_OPERAND_RESULT_NUMBER
)
314 value
= (-value
) & 0xffff;
319 return parse_mimm (cd
, strp
, opindex
, valuep
);
324 const char * iq2000_cgen_parse_operand
325 PARAMS ((CGEN_CPU_DESC
, int, const char **, CGEN_FIELDS
*));
327 /* Main entry point for operand parsing.
329 This function is basically just a big switch statement. Earlier versions
330 used tables to look up the function to use, but
331 - if the table contains both assembler and disassembler functions then
332 the disassembler contains much of the assembler and vice-versa,
333 - there's a lot of inlining possibilities as things grow,
334 - using a switch statement avoids the function call overhead.
336 This function could be moved into `parse_insn_normal', but keeping it
337 separate makes clear the interface between `parse_insn_normal' and each of
341 iq2000_cgen_parse_operand (cd
, opindex
, strp
, fields
)
345 CGEN_FIELDS
* fields
;
347 const char * errmsg
= NULL
;
348 /* Used by scalar operands that still need to be parsed. */
349 long junk ATTRIBUTE_UNUSED
;
353 case IQ2000_OPERAND__INDEX
:
354 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, IQ2000_OPERAND__INDEX
, (unsigned long *) (& fields
->f_index
));
356 case IQ2000_OPERAND_BASE
:
357 errmsg
= cgen_parse_keyword (cd
, strp
, & iq2000_cgen_opval_gr_names
, & fields
->f_rs
);
359 case IQ2000_OPERAND_BASEOFF
:
362 errmsg
= cgen_parse_address (cd
, strp
, IQ2000_OPERAND_BASEOFF
, 0, NULL
, & value
);
363 fields
->f_imm
= value
;
366 case IQ2000_OPERAND_BITNUM
:
367 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, IQ2000_OPERAND_BITNUM
, (unsigned long *) (& fields
->f_rt
));
369 case IQ2000_OPERAND_BYTECOUNT
:
370 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, IQ2000_OPERAND_BYTECOUNT
, (unsigned long *) (& fields
->f_bytecount
));
372 case IQ2000_OPERAND_CAM_Y
:
373 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, IQ2000_OPERAND_CAM_Y
, (unsigned long *) (& fields
->f_cam_y
));
375 case IQ2000_OPERAND_CAM_Z
:
376 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, IQ2000_OPERAND_CAM_Z
, (unsigned long *) (& fields
->f_cam_z
));
378 case IQ2000_OPERAND_CM_3FUNC
:
379 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, IQ2000_OPERAND_CM_3FUNC
, (unsigned long *) (& fields
->f_cm_3func
));
381 case IQ2000_OPERAND_CM_3Z
:
382 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, IQ2000_OPERAND_CM_3Z
, (unsigned long *) (& fields
->f_cm_3z
));
384 case IQ2000_OPERAND_CM_4FUNC
:
385 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, IQ2000_OPERAND_CM_4FUNC
, (unsigned long *) (& fields
->f_cm_4func
));
387 case IQ2000_OPERAND_CM_4Z
:
388 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, IQ2000_OPERAND_CM_4Z
, (unsigned long *) (& fields
->f_cm_4z
));
390 case IQ2000_OPERAND_COUNT
:
391 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, IQ2000_OPERAND_COUNT
, (unsigned long *) (& fields
->f_count
));
393 case IQ2000_OPERAND_EXECODE
:
394 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, IQ2000_OPERAND_EXECODE
, (unsigned long *) (& fields
->f_excode
));
396 case IQ2000_OPERAND_HI16
:
397 errmsg
= parse_hi16 (cd
, strp
, IQ2000_OPERAND_HI16
, (unsigned long *) (& fields
->f_imm
));
399 case IQ2000_OPERAND_IMM
:
400 errmsg
= parse_imm (cd
, strp
, IQ2000_OPERAND_IMM
, (unsigned long *) (& fields
->f_imm
));
402 case IQ2000_OPERAND_JMPTARG
:
405 errmsg
= cgen_parse_address (cd
, strp
, IQ2000_OPERAND_JMPTARG
, 0, NULL
, & value
);
406 fields
->f_jtarg
= value
;
409 case IQ2000_OPERAND_JMPTARGQ10
:
413 errmsg
= parse_jtargq10 (cd
, strp
, IQ2000_OPERAND_JMPTARGQ10
, 0, NULL
, & value
);
414 fields
->f_jtargq10
= value
;
417 case IQ2000_OPERAND_LO16
:
418 errmsg
= parse_lo16 (cd
, strp
, IQ2000_OPERAND_LO16
, (unsigned long *) (& fields
->f_imm
));
420 case IQ2000_OPERAND_MASK
:
421 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, IQ2000_OPERAND_MASK
, (unsigned long *) (& fields
->f_mask
));
423 case IQ2000_OPERAND_MASKL
:
424 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, IQ2000_OPERAND_MASKL
, (unsigned long *) (& fields
->f_maskl
));
426 case IQ2000_OPERAND_MASKQ10
:
427 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, IQ2000_OPERAND_MASKQ10
, (unsigned long *) (& fields
->f_maskq10
));
429 case IQ2000_OPERAND_MASKR
:
430 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, IQ2000_OPERAND_MASKR
, (unsigned long *) (& fields
->f_rs
));
432 case IQ2000_OPERAND_MLO16
:
433 errmsg
= parse_mlo16 (cd
, strp
, IQ2000_OPERAND_MLO16
, (unsigned long *) (& fields
->f_imm
));
435 case IQ2000_OPERAND_OFFSET
:
438 errmsg
= cgen_parse_address (cd
, strp
, IQ2000_OPERAND_OFFSET
, 0, NULL
, & value
);
439 fields
->f_offset
= value
;
442 case IQ2000_OPERAND_RD
:
443 errmsg
= cgen_parse_keyword (cd
, strp
, & iq2000_cgen_opval_gr_names
, & fields
->f_rd
);
445 case IQ2000_OPERAND_RD_RS
:
446 errmsg
= cgen_parse_keyword (cd
, strp
, & iq2000_cgen_opval_gr_names
, & fields
->f_rd_rs
);
448 case IQ2000_OPERAND_RD_RT
:
449 errmsg
= cgen_parse_keyword (cd
, strp
, & iq2000_cgen_opval_gr_names
, & fields
->f_rd_rt
);
451 case IQ2000_OPERAND_RS
:
452 errmsg
= cgen_parse_keyword (cd
, strp
, & iq2000_cgen_opval_gr_names
, & fields
->f_rs
);
454 case IQ2000_OPERAND_RT
:
455 errmsg
= cgen_parse_keyword (cd
, strp
, & iq2000_cgen_opval_gr_names
, & fields
->f_rt
);
457 case IQ2000_OPERAND_RT_RS
:
458 errmsg
= cgen_parse_keyword (cd
, strp
, & iq2000_cgen_opval_gr_names
, & fields
->f_rt_rs
);
460 case IQ2000_OPERAND_SHAMT
:
461 errmsg
= cgen_parse_unsigned_integer (cd
, strp
, IQ2000_OPERAND_SHAMT
, (unsigned long *) (& fields
->f_shamt
));
465 /* xgettext:c-format */
466 fprintf (stderr
, _("Unrecognized field %d while parsing.\n"), opindex
);
473 cgen_parse_fn
* const iq2000_cgen_parse_handlers
[] =
479 iq2000_cgen_init_asm (cd
)
482 iq2000_cgen_init_opcode_table (cd
);
483 iq2000_cgen_init_ibld_table (cd
);
484 cd
->parse_handlers
= & iq2000_cgen_parse_handlers
[0];
485 cd
->parse_operand
= iq2000_cgen_parse_operand
;
490 /* Regex construction routine.
492 This translates an opcode syntax string into a regex string,
493 by replacing any non-character syntax element (such as an
494 opcode) with the pattern '.*'
496 It then compiles the regex and stores it in the opcode, for
497 later use by iq2000_cgen_assemble_insn
499 Returns NULL for success, an error message for failure. */
502 iq2000_cgen_build_insn_regex (CGEN_INSN
*insn
)
504 CGEN_OPCODE
*opc
= (CGEN_OPCODE
*) CGEN_INSN_OPCODE (insn
);
505 const char *mnem
= CGEN_INSN_MNEMONIC (insn
);
506 char rxbuf
[CGEN_MAX_RX_ELEMENTS
];
508 const CGEN_SYNTAX_CHAR_TYPE
*syn
;
511 syn
= CGEN_SYNTAX_STRING (CGEN_OPCODE_SYNTAX (opc
));
513 /* Mnemonics come first in the syntax string. */
514 if (! CGEN_SYNTAX_MNEMONIC_P (* syn
))
515 return _("missing mnemonic in syntax string");
518 /* Generate a case sensitive regular expression that emulates case
519 insensitive matching in the "C" locale. We cannot generate a case
520 insensitive regular expression because in Turkish locales, 'i' and 'I'
521 are not equal modulo case conversion. */
523 /* Copy the literal mnemonic out of the insn. */
524 for (; *mnem
; mnem
++)
539 /* Copy any remaining literals from the syntax string into the rx. */
540 for(; * syn
!= 0 && rx
<= rxbuf
+ (CGEN_MAX_RX_ELEMENTS
- 7 - 4); ++syn
)
542 if (CGEN_SYNTAX_CHAR_P (* syn
))
544 char c
= CGEN_SYNTAX_CHAR (* syn
);
548 /* Escape any regex metacharacters in the syntax. */
549 case '.': case '[': case '\\':
550 case '*': case '^': case '$':
552 #ifdef CGEN_ESCAPE_EXTENDED_REGEX
553 case '?': case '{': case '}':
554 case '(': case ')': case '*':
555 case '|': case '+': case ']':
576 /* Replace non-syntax fields with globs. */
582 /* Trailing whitespace ok. */
589 /* But anchor it after that. */
593 CGEN_INSN_RX (insn
) = xmalloc (sizeof (regex_t
));
594 reg_err
= regcomp ((regex_t
*) CGEN_INSN_RX (insn
), rxbuf
, REG_NOSUB
);
602 regerror (reg_err
, (regex_t
*) CGEN_INSN_RX (insn
), msg
, 80);
603 regfree ((regex_t
*) CGEN_INSN_RX (insn
));
604 free (CGEN_INSN_RX (insn
));
605 (CGEN_INSN_RX (insn
)) = NULL
;
611 /* Default insn parser.
613 The syntax string is scanned and operands are parsed and stored in FIELDS.
614 Relocs are queued as we go via other callbacks.
616 ??? Note that this is currently an all-or-nothing parser. If we fail to
617 parse the instruction, we return 0 and the caller will start over from
618 the beginning. Backtracking will be necessary in parsing subexpressions,
619 but that can be handled there. Not handling backtracking here may get
620 expensive in the case of the m68k. Deal with later.
622 Returns NULL for success, an error message for failure. */
625 parse_insn_normal (CGEN_CPU_DESC cd
,
626 const CGEN_INSN
*insn
,
630 /* ??? Runtime added insns not handled yet. */
631 const CGEN_SYNTAX
*syntax
= CGEN_INSN_SYNTAX (insn
);
632 const char *str
= *strp
;
635 const CGEN_SYNTAX_CHAR_TYPE
* syn
;
636 #ifdef CGEN_MNEMONIC_OPERANDS
641 /* For now we assume the mnemonic is first (there are no leading operands).
642 We can parse it without needing to set up operand parsing.
643 GAS's input scrubber will ensure mnemonics are lowercase, but we may
644 not be called from GAS. */
645 p
= CGEN_INSN_MNEMONIC (insn
);
646 while (*p
&& TOLOWER (*p
) == TOLOWER (*str
))
650 return _("unrecognized instruction");
652 #ifndef CGEN_MNEMONIC_OPERANDS
653 if (* str
&& ! ISSPACE (* str
))
654 return _("unrecognized instruction");
657 CGEN_INIT_PARSE (cd
);
658 cgen_init_parse_operand (cd
);
659 #ifdef CGEN_MNEMONIC_OPERANDS
663 /* We don't check for (*str != '\0') here because we want to parse
664 any trailing fake arguments in the syntax string. */
665 syn
= CGEN_SYNTAX_STRING (syntax
);
667 /* Mnemonics come first for now, ensure valid string. */
668 if (! CGEN_SYNTAX_MNEMONIC_P (* syn
))
675 /* Non operand chars must match exactly. */
676 if (CGEN_SYNTAX_CHAR_P (* syn
))
678 /* FIXME: While we allow for non-GAS callers above, we assume the
679 first char after the mnemonic part is a space. */
680 /* FIXME: We also take inappropriate advantage of the fact that
681 GAS's input scrubber will remove extraneous blanks. */
682 if (TOLOWER (*str
) == TOLOWER (CGEN_SYNTAX_CHAR (* syn
)))
684 #ifdef CGEN_MNEMONIC_OPERANDS
685 if (CGEN_SYNTAX_CHAR(* syn
) == ' ')
693 /* Syntax char didn't match. Can't be this insn. */
694 static char msg
[80];
696 /* xgettext:c-format */
697 sprintf (msg
, _("syntax error (expected char `%c', found `%c')"),
698 CGEN_SYNTAX_CHAR(*syn
), *str
);
703 /* Ran out of input. */
704 static char msg
[80];
706 /* xgettext:c-format */
707 sprintf (msg
, _("syntax error (expected char `%c', found end of instruction)"),
708 CGEN_SYNTAX_CHAR(*syn
));
714 /* We have an operand of some sort. */
715 errmsg
= cd
->parse_operand (cd
, CGEN_SYNTAX_FIELD (*syn
),
720 /* Done with this operand, continue with next one. */
724 /* If we're at the end of the syntax string, we're done. */
727 /* FIXME: For the moment we assume a valid `str' can only contain
728 blanks now. IE: We needn't try again with a longer version of
729 the insn and it is assumed that longer versions of insns appear
730 before shorter ones (eg: lsr r2,r3,1 vs lsr r2,r3). */
731 while (ISSPACE (* str
))
735 return _("junk at end of line"); /* FIXME: would like to include `str' */
740 /* We couldn't parse it. */
741 return _("unrecognized instruction");
745 This routine is called for each instruction to be assembled.
746 STR points to the insn to be assembled.
747 We assume all necessary tables have been initialized.
748 The assembled instruction, less any fixups, is stored in BUF.
749 Remember that if CGEN_INT_INSN_P then BUF is an int and thus the value
750 still needs to be converted to target byte order, otherwise BUF is an array
751 of bytes in target byte order.
752 The result is a pointer to the insn's entry in the opcode table,
753 or NULL if an error occured (an error message will have already been
756 Note that when processing (non-alias) macro-insns,
757 this function recurses.
759 ??? It's possible to make this cpu-independent.
760 One would have to deal with a few minor things.
761 At this point in time doing so would be more of a curiosity than useful
762 [for example this file isn't _that_ big], but keeping the possibility in
763 mind helps keep the design clean. */
766 iq2000_cgen_assemble_insn (CGEN_CPU_DESC cd
,
769 CGEN_INSN_BYTES_PTR buf
,
773 CGEN_INSN_LIST
*ilist
;
774 const char *parse_errmsg
= NULL
;
775 const char *insert_errmsg
= NULL
;
776 int recognized_mnemonic
= 0;
778 /* Skip leading white space. */
779 while (ISSPACE (* str
))
782 /* The instructions are stored in hashed lists.
783 Get the first in the list. */
784 ilist
= CGEN_ASM_LOOKUP_INSN (cd
, str
);
786 /* Keep looking until we find a match. */
788 for ( ; ilist
!= NULL
; ilist
= CGEN_ASM_NEXT_INSN (ilist
))
790 const CGEN_INSN
*insn
= ilist
->insn
;
791 recognized_mnemonic
= 1;
793 #ifdef CGEN_VALIDATE_INSN_SUPPORTED
794 /* Not usually needed as unsupported opcodes
795 shouldn't be in the hash lists. */
796 /* Is this insn supported by the selected cpu? */
797 if (! iq2000_cgen_insn_supported (cd
, insn
))
800 /* If the RELAXED attribute is set, this is an insn that shouldn't be
801 chosen immediately. Instead, it is used during assembler/linker
802 relaxation if possible. */
803 if (CGEN_INSN_ATTR_VALUE (insn
, CGEN_INSN_RELAXED
) != 0)
808 /* Skip this insn if str doesn't look right lexically. */
809 if (CGEN_INSN_RX (insn
) != NULL
&&
810 regexec ((regex_t
*) CGEN_INSN_RX (insn
), str
, 0, NULL
, 0) == REG_NOMATCH
)
813 /* Allow parse/insert handlers to obtain length of insn. */
814 CGEN_FIELDS_BITSIZE (fields
) = CGEN_INSN_BITSIZE (insn
);
816 parse_errmsg
= CGEN_PARSE_FN (cd
, insn
) (cd
, insn
, & str
, fields
);
817 if (parse_errmsg
!= NULL
)
820 /* ??? 0 is passed for `pc'. */
821 insert_errmsg
= CGEN_INSERT_FN (cd
, insn
) (cd
, insn
, fields
, buf
,
823 if (insert_errmsg
!= NULL
)
826 /* It is up to the caller to actually output the insn and any
832 static char errbuf
[150];
833 #ifdef CGEN_VERBOSE_ASSEMBLER_ERRORS
834 const char *tmp_errmsg
;
836 /* If requesting verbose error messages, use insert_errmsg.
837 Failing that, use parse_errmsg. */
838 tmp_errmsg
= (insert_errmsg
? insert_errmsg
:
839 parse_errmsg
? parse_errmsg
:
840 recognized_mnemonic
?
841 _("unrecognized form of instruction") :
842 _("unrecognized instruction"));
844 if (strlen (start
) > 50)
845 /* xgettext:c-format */
846 sprintf (errbuf
, "%s `%.50s...'", tmp_errmsg
, start
);
848 /* xgettext:c-format */
849 sprintf (errbuf
, "%s `%.50s'", tmp_errmsg
, start
);
851 if (strlen (start
) > 50)
852 /* xgettext:c-format */
853 sprintf (errbuf
, _("bad instruction `%.50s...'"), start
);
855 /* xgettext:c-format */
856 sprintf (errbuf
, _("bad instruction `%.50s'"), start
);
864 #if 0 /* This calls back to GAS which we can't do without care. */
866 /* Record each member of OPVALS in the assembler's symbol table.
867 This lets GAS parse registers for us.
868 ??? Interesting idea but not currently used. */
870 /* Record each member of OPVALS in the assembler's symbol table.
871 FIXME: Not currently used. */
874 iq2000_cgen_asm_hash_keywords (CGEN_CPU_DESC cd
, CGEN_KEYWORD
*opvals
)
876 CGEN_KEYWORD_SEARCH search
= cgen_keyword_search_init (opvals
, NULL
);
877 const CGEN_KEYWORD_ENTRY
* ke
;
879 while ((ke
= cgen_keyword_search_next (& search
)) != NULL
)
881 #if 0 /* Unnecessary, should be done in the search routine. */
882 if (! iq2000_cgen_opval_supported (ke
))
885 cgen_asm_record_register (cd
, ke
->name
, ke
->value
);