2003-10-03 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / opcodes / openrisc-asm.c
CommitLineData
87e6d782
NC
1/* Assembler interface for targets using CGEN. -*- C -*-
2 CGEN: Cpu tools GENerator
3
4THIS FILE IS MACHINE GENERATED WITH CGEN.
5- the resultant file is machine generated, cgen-asm.in isn't
6
7Copyright 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
8
9This file is part of the GNU Binutils and GDB, the GNU debugger.
10
11This program is free software; you can redistribute it and/or modify
12it under the terms of the GNU General Public License as published by
13the Free Software Foundation; either version 2, or (at your option)
14any later version.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19GNU General Public License for more details.
20
21You should have received a copy of the GNU General Public License
22along with this program; if not, write to the Free Software Foundation, Inc.,
2359 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
24
25/* ??? Eventually more and more of this stuff can go to cpu-independent files.
26 Keep that in mind. */
27
28#include "sysdep.h"
87e6d782
NC
29#include <stdio.h>
30#include "ansidecl.h"
31#include "bfd.h"
32#include "symcat.h"
33#include "openrisc-desc.h"
34#include "openrisc-opc.h"
35#include "opintl.h"
fc7bc883 36#include "xregex.h"
fc05c67f 37#include "libiberty.h"
37111cc7 38#include "safe-ctype.h"
87e6d782 39
37111cc7 40#undef min
87e6d782 41#define min(a,b) ((a) < (b) ? (a) : (b))
37111cc7 42#undef max
87e6d782
NC
43#define max(a,b) ((a) > (b) ? (a) : (b))
44
45static const char * parse_insn_normal
ffead7ae 46 (CGEN_CPU_DESC, const CGEN_INSN *, const char **, CGEN_FIELDS *);
87e6d782 47\f
37111cc7 48/* -- assembler routines inserted here. */
87e6d782
NC
49
50/* -- asm.c */
51
52#define CGEN_VERBOSE_ASSEMBLER_ERRORS
53
0e2ee3ca
NC
54static const char * parse_hi16
55 PARAMS ((CGEN_CPU_DESC, const char **, int, unsigned long *));
56static const char * parse_lo16
57 PARAMS ((CGEN_CPU_DESC, const char **, int, unsigned long *));
58
87e6d782
NC
59long
60openrisc_sign_extend_16bit (value)
61 long value;
62{
63 return (long) (short) value;
64}
65
87e6d782
NC
66/* Handle hi(). */
67
68static const char *
69parse_hi16 (cd, strp, opindex, valuep)
70 CGEN_CPU_DESC cd;
71 const char **strp;
72 int opindex;
73 unsigned long *valuep;
74{
75 const char *errmsg;
76 enum cgen_parse_operand_result result_type;
77 bfd_vma value;
78
79 if (**strp == '#')
80 ++*strp;
81
82 if (strncasecmp (*strp, "hi(", 3) == 0)
83 {
84 *strp += 3;
85
86#if 0
87 errmsg = cgen_parse_signed_integer (cd, strp, opindex, valuep);
88 if (errmsg != NULL)
89 fprintf (stderr, "parse_hi: %s\n", errmsg);
90 if (errmsg != NULL)
91#endif
92 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_HI16,
93 &result_type, &value);
94 if (**strp != ')')
95 return "missing `)'";
96 ++*strp;
97 if (errmsg == NULL
98 && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
99 value >>= 16;
100 *valuep = (long) (short) value;
101
102 return errmsg;
103 }
104 else
105 {
106 if (**strp == '-')
107 errmsg = cgen_parse_signed_integer (cd, strp, opindex, (long *) &value);
108 else
2c8721ec 109 errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, (unsigned long *) &value);
87e6d782
NC
110 }
111 *valuep = (long) (short) (value & 0xffff);
112 return errmsg;
113}
114
0e2ee3ca 115/* Handle lo(). */
87e6d782
NC
116
117static const char *
118parse_lo16 (cd, strp, opindex, valuep)
119 CGEN_CPU_DESC cd;
120 const char **strp;
121 int opindex;
122 unsigned long *valuep;
123{
124 const char *errmsg;
125 enum cgen_parse_operand_result result_type;
126 bfd_vma value;
127
128 if (**strp == '#')
129 ++*strp;
130
131 if (strncasecmp (*strp, "lo(", 3) == 0)
132 {
133 *strp += 3;
134
135#if 0
136 errmsg = cgen_parse_signed_integer (cd, strp, opindex, valuep);
137 if (errmsg != NULL)
138 fprintf (stderr, "parse_lo: %s\n", errmsg);
139
140 if (errmsg != NULL)
141#endif
142 errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_LO16,
143 &result_type, &value);
144 if (**strp != ')')
145 return "missing `)'";
146 ++*strp;
147 if (errmsg == NULL
148 && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
149 value &= 0xffff;
150 *valuep = (long) (short) value;
151
152 return errmsg;
153 }
154
155 if (**strp == '-')
156 errmsg = cgen_parse_signed_integer (cd, strp, opindex, (long *) &value);
157 else
2c8721ec 158 errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, (unsigned long *) &value);
87e6d782
NC
159 *valuep = (long) (short) (value & 0xffff);
160 return errmsg;
161}
162
163/* -- */
164
0e2ee3ca
NC
165const char * openrisc_cgen_parse_operand
166 PARAMS ((CGEN_CPU_DESC, int, const char **, CGEN_FIELDS *));
167
87e6d782
NC
168/* Main entry point for operand parsing.
169
170 This function is basically just a big switch statement. Earlier versions
171 used tables to look up the function to use, but
172 - if the table contains both assembler and disassembler functions then
173 the disassembler contains much of the assembler and vice-versa,
174 - there's a lot of inlining possibilities as things grow,
175 - using a switch statement avoids the function call overhead.
176
177 This function could be moved into `parse_insn_normal', but keeping it
178 separate makes clear the interface between `parse_insn_normal' and each of
9a2e995d 179 the handlers. */
87e6d782
NC
180
181const char *
182openrisc_cgen_parse_operand (cd, opindex, strp, fields)
183 CGEN_CPU_DESC cd;
184 int opindex;
185 const char ** strp;
186 CGEN_FIELDS * fields;
187{
188 const char * errmsg = NULL;
189 /* Used by scalar operands that still need to be parsed. */
fc05c67f 190 long junk ATTRIBUTE_UNUSED;
87e6d782
NC
191
192 switch (opindex)
193 {
194 case OPENRISC_OPERAND_ABS_26 :
195 {
196 bfd_vma value;
197 errmsg = cgen_parse_address (cd, strp, OPENRISC_OPERAND_ABS_26, 0, NULL, & value);
198 fields->f_abs26 = value;
199 }
200 break;
201 case OPENRISC_OPERAND_DISP_26 :
202 {
203 bfd_vma value;
204 errmsg = cgen_parse_address (cd, strp, OPENRISC_OPERAND_DISP_26, 0, NULL, & value);
205 fields->f_disp26 = value;
206 }
207 break;
208 case OPENRISC_OPERAND_HI16 :
209 errmsg = parse_hi16 (cd, strp, OPENRISC_OPERAND_HI16, &fields->f_simm16);
210 break;
211 case OPENRISC_OPERAND_LO16 :
212 errmsg = parse_lo16 (cd, strp, OPENRISC_OPERAND_LO16, &fields->f_lo16);
213 break;
214 case OPENRISC_OPERAND_OP_F_23 :
215 errmsg = cgen_parse_unsigned_integer (cd, strp, OPENRISC_OPERAND_OP_F_23, &fields->f_op4);
216 break;
217 case OPENRISC_OPERAND_OP_F_3 :
218 errmsg = cgen_parse_unsigned_integer (cd, strp, OPENRISC_OPERAND_OP_F_3, &fields->f_op5);
219 break;
220 case OPENRISC_OPERAND_RA :
221 errmsg = cgen_parse_keyword (cd, strp, & openrisc_cgen_opval_h_gr, & fields->f_r2);
222 break;
223 case OPENRISC_OPERAND_RB :
224 errmsg = cgen_parse_keyword (cd, strp, & openrisc_cgen_opval_h_gr, & fields->f_r3);
225 break;
226 case OPENRISC_OPERAND_RD :
227 errmsg = cgen_parse_keyword (cd, strp, & openrisc_cgen_opval_h_gr, & fields->f_r1);
228 break;
229 case OPENRISC_OPERAND_SIMM_16 :
230 errmsg = cgen_parse_signed_integer (cd, strp, OPENRISC_OPERAND_SIMM_16, &fields->f_simm16);
231 break;
232 case OPENRISC_OPERAND_UI16NC :
233 errmsg = parse_lo16 (cd, strp, OPENRISC_OPERAND_UI16NC, &fields->f_i16nc);
234 break;
235 case OPENRISC_OPERAND_UIMM_16 :
236 errmsg = cgen_parse_unsigned_integer (cd, strp, OPENRISC_OPERAND_UIMM_16, &fields->f_uimm16);
237 break;
238 case OPENRISC_OPERAND_UIMM_5 :
239 errmsg = cgen_parse_unsigned_integer (cd, strp, OPENRISC_OPERAND_UIMM_5, &fields->f_uimm5);
240 break;
241
242 default :
243 /* xgettext:c-format */
244 fprintf (stderr, _("Unrecognized field %d while parsing.\n"), opindex);
245 abort ();
246 }
247
248 return errmsg;
249}
250
251cgen_parse_fn * const openrisc_cgen_parse_handlers[] =
252{
253 parse_insn_normal,
254};
255
256void
257openrisc_cgen_init_asm (cd)
258 CGEN_CPU_DESC cd;
259{
260 openrisc_cgen_init_opcode_table (cd);
261 openrisc_cgen_init_ibld_table (cd);
262 cd->parse_handlers = & openrisc_cgen_parse_handlers[0];
263 cd->parse_operand = openrisc_cgen_parse_operand;
264}
265
fc7bc883
RH
266\f
267
37111cc7 268/* Regex construction routine.
fc7bc883 269
37111cc7
NC
270 This translates an opcode syntax string into a regex string,
271 by replacing any non-character syntax element (such as an
272 opcode) with the pattern '.*'
fc7bc883 273
37111cc7
NC
274 It then compiles the regex and stores it in the opcode, for
275 later use by openrisc_cgen_assemble_insn
fc7bc883 276
37111cc7 277 Returns NULL for success, an error message for failure. */
fc7bc883
RH
278
279char *
ffead7ae 280openrisc_cgen_build_insn_regex (CGEN_INSN *insn)
fc7bc883 281{
fc05c67f 282 CGEN_OPCODE *opc = (CGEN_OPCODE *) CGEN_INSN_OPCODE (insn);
fc7bc883 283 const char *mnem = CGEN_INSN_MNEMONIC (insn);
fc7bc883
RH
284 char rxbuf[CGEN_MAX_RX_ELEMENTS];
285 char *rx = rxbuf;
286 const CGEN_SYNTAX_CHAR_TYPE *syn;
287 int reg_err;
288
289 syn = CGEN_SYNTAX_STRING (CGEN_OPCODE_SYNTAX (opc));
290
f3a55c17
NC
291 /* Mnemonics come first in the syntax string. */
292 if (! CGEN_SYNTAX_MNEMONIC_P (* syn))
293 return _("missing mnemonic in syntax string");
fc7bc883
RH
294 ++syn;
295
f3a55c17
NC
296 /* Generate a case sensitive regular expression that emulates case
297 insensitive matching in the "C" locale. We cannot generate a case
298 insensitive regular expression because in Turkish locales, 'i' and 'I'
299 are not equal modulo case conversion. */
fc7bc883 300
f3a55c17
NC
301 /* Copy the literal mnemonic out of the insn. */
302 for (; *mnem; mnem++)
303 {
304 char c = *mnem;
305
306 if (ISALPHA (c))
307 {
308 *rx++ = '[';
309 *rx++ = TOLOWER (c);
310 *rx++ = TOUPPER (c);
311 *rx++ = ']';
312 }
313 else
314 *rx++ = c;
315 }
316
317 /* Copy any remaining literals from the syntax string into the rx. */
318 for(; * syn != 0 && rx <= rxbuf + (CGEN_MAX_RX_ELEMENTS - 7 - 4); ++syn)
fc7bc883
RH
319 {
320 if (CGEN_SYNTAX_CHAR_P (* syn))
321 {
f3a55c17
NC
322 char c = CGEN_SYNTAX_CHAR (* syn);
323
324 switch (c)
325 {
326 /* Escape any regex metacharacters in the syntax. */
327 case '.': case '[': case '\\':
328 case '*': case '^': case '$':
fc7bc883
RH
329
330#ifdef CGEN_ESCAPE_EXTENDED_REGEX
f3a55c17
NC
331 case '?': case '{': case '}':
332 case '(': case ')': case '*':
333 case '|': case '+': case ']':
fc7bc883 334#endif
f3a55c17
NC
335 *rx++ = '\\';
336 *rx++ = c;
337 break;
338
339 default:
340 if (ISALPHA (c))
341 {
342 *rx++ = '[';
343 *rx++ = TOLOWER (c);
344 *rx++ = TOUPPER (c);
345 *rx++ = ']';
346 }
347 else
348 *rx++ = c;
349 break;
350 }
fc7bc883
RH
351 }
352 else
353 {
f3a55c17
NC
354 /* Replace non-syntax fields with globs. */
355 *rx++ = '.';
356 *rx++ = '*';
fc7bc883
RH
357 }
358 }
359
f3a55c17 360 /* Trailing whitespace ok. */
fc7bc883
RH
361 * rx++ = '[';
362 * rx++ = ' ';
363 * rx++ = '\t';
364 * rx++ = ']';
365 * rx++ = '*';
366
f3a55c17 367 /* But anchor it after that. */
fc7bc883
RH
368 * rx++ = '$';
369 * rx = '\0';
370
371 CGEN_INSN_RX (insn) = xmalloc (sizeof (regex_t));
f3a55c17 372 reg_err = regcomp ((regex_t *) CGEN_INSN_RX (insn), rxbuf, REG_NOSUB);
fc7bc883
RH
373
374 if (reg_err == 0)
375 return NULL;
376 else
377 {
378 static char msg[80];
f3a55c17 379
fc7bc883
RH
380 regerror (reg_err, (regex_t *) CGEN_INSN_RX (insn), msg, 80);
381 regfree ((regex_t *) CGEN_INSN_RX (insn));
382 free (CGEN_INSN_RX (insn));
383 (CGEN_INSN_RX (insn)) = NULL;
37111cc7 384 return msg;
fc7bc883
RH
385 }
386}
387
87e6d782
NC
388\f
389/* Default insn parser.
390
391 The syntax string is scanned and operands are parsed and stored in FIELDS.
392 Relocs are queued as we go via other callbacks.
393
394 ??? Note that this is currently an all-or-nothing parser. If we fail to
395 parse the instruction, we return 0 and the caller will start over from
396 the beginning. Backtracking will be necessary in parsing subexpressions,
397 but that can be handled there. Not handling backtracking here may get
398 expensive in the case of the m68k. Deal with later.
399
f3a55c17 400 Returns NULL for success, an error message for failure. */
87e6d782
NC
401
402static const char *
ffead7ae
MM
403parse_insn_normal (CGEN_CPU_DESC cd,
404 const CGEN_INSN *insn,
405 const char **strp,
406 CGEN_FIELDS *fields)
87e6d782
NC
407{
408 /* ??? Runtime added insns not handled yet. */
409 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
410 const char *str = *strp;
411 const char *errmsg;
412 const char *p;
413 const CGEN_SYNTAX_CHAR_TYPE * syn;
414#ifdef CGEN_MNEMONIC_OPERANDS
415 /* FIXME: wip */
416 int past_opcode_p;
417#endif
418
419 /* For now we assume the mnemonic is first (there are no leading operands).
420 We can parse it without needing to set up operand parsing.
421 GAS's input scrubber will ensure mnemonics are lowercase, but we may
422 not be called from GAS. */
423 p = CGEN_INSN_MNEMONIC (insn);
37111cc7 424 while (*p && TOLOWER (*p) == TOLOWER (*str))
87e6d782
NC
425 ++p, ++str;
426
427 if (* p)
428 return _("unrecognized instruction");
429
430#ifndef CGEN_MNEMONIC_OPERANDS
37111cc7 431 if (* str && ! ISSPACE (* str))
87e6d782
NC
432 return _("unrecognized instruction");
433#endif
434
435 CGEN_INIT_PARSE (cd);
436 cgen_init_parse_operand (cd);
437#ifdef CGEN_MNEMONIC_OPERANDS
438 past_opcode_p = 0;
439#endif
440
441 /* We don't check for (*str != '\0') here because we want to parse
442 any trailing fake arguments in the syntax string. */
443 syn = CGEN_SYNTAX_STRING (syntax);
444
445 /* Mnemonics come first for now, ensure valid string. */
446 if (! CGEN_SYNTAX_MNEMONIC_P (* syn))
447 abort ();
448
449 ++syn;
450
451 while (* syn != 0)
452 {
453 /* Non operand chars must match exactly. */
454 if (CGEN_SYNTAX_CHAR_P (* syn))
455 {
456 /* FIXME: While we allow for non-GAS callers above, we assume the
457 first char after the mnemonic part is a space. */
458 /* FIXME: We also take inappropriate advantage of the fact that
459 GAS's input scrubber will remove extraneous blanks. */
37111cc7 460 if (TOLOWER (*str) == TOLOWER (CGEN_SYNTAX_CHAR (* syn)))
87e6d782
NC
461 {
462#ifdef CGEN_MNEMONIC_OPERANDS
463 if (CGEN_SYNTAX_CHAR(* syn) == ' ')
464 past_opcode_p = 1;
465#endif
466 ++ syn;
467 ++ str;
468 }
469 else if (*str)
470 {
471 /* Syntax char didn't match. Can't be this insn. */
472 static char msg [80];
f3a55c17 473
87e6d782
NC
474 /* xgettext:c-format */
475 sprintf (msg, _("syntax error (expected char `%c', found `%c')"),
476 CGEN_SYNTAX_CHAR(*syn), *str);
477 return msg;
478 }
479 else
480 {
481 /* Ran out of input. */
482 static char msg [80];
f3a55c17 483
87e6d782
NC
484 /* xgettext:c-format */
485 sprintf (msg, _("syntax error (expected char `%c', found end of instruction)"),
486 CGEN_SYNTAX_CHAR(*syn));
487 return msg;
488 }
489 continue;
490 }
491
492 /* We have an operand of some sort. */
a978a3e5 493 errmsg = cd->parse_operand (cd, CGEN_SYNTAX_FIELD (*syn),
87e6d782
NC
494 &str, fields);
495 if (errmsg)
496 return errmsg;
497
498 /* Done with this operand, continue with next one. */
499 ++ syn;
500 }
501
502 /* If we're at the end of the syntax string, we're done. */
503 if (* syn == 0)
504 {
505 /* FIXME: For the moment we assume a valid `str' can only contain
506 blanks now. IE: We needn't try again with a longer version of
507 the insn and it is assumed that longer versions of insns appear
508 before shorter ones (eg: lsr r2,r3,1 vs lsr r2,r3). */
37111cc7 509 while (ISSPACE (* str))
87e6d782
NC
510 ++ str;
511
512 if (* str != '\0')
513 return _("junk at end of line"); /* FIXME: would like to include `str' */
514
515 return NULL;
516 }
517
518 /* We couldn't parse it. */
519 return _("unrecognized instruction");
520}
521\f
522/* Main entry point.
523 This routine is called for each instruction to be assembled.
524 STR points to the insn to be assembled.
525 We assume all necessary tables have been initialized.
526 The assembled instruction, less any fixups, is stored in BUF.
527 Remember that if CGEN_INT_INSN_P then BUF is an int and thus the value
528 still needs to be converted to target byte order, otherwise BUF is an array
529 of bytes in target byte order.
530 The result is a pointer to the insn's entry in the opcode table,
531 or NULL if an error occured (an error message will have already been
532 printed).
533
534 Note that when processing (non-alias) macro-insns,
535 this function recurses.
536
537 ??? It's possible to make this cpu-independent.
538 One would have to deal with a few minor things.
539 At this point in time doing so would be more of a curiosity than useful
540 [for example this file isn't _that_ big], but keeping the possibility in
541 mind helps keep the design clean. */
542
543const CGEN_INSN *
ffead7ae
MM
544openrisc_cgen_assemble_insn (CGEN_CPU_DESC cd,
545 const char *str,
546 CGEN_FIELDS *fields,
547 CGEN_INSN_BYTES_PTR buf,
548 char **errmsg)
87e6d782
NC
549{
550 const char *start;
551 CGEN_INSN_LIST *ilist;
552 const char *parse_errmsg = NULL;
553 const char *insert_errmsg = NULL;
fc7bc883 554 int recognized_mnemonic = 0;
87e6d782
NC
555
556 /* Skip leading white space. */
37111cc7 557 while (ISSPACE (* str))
87e6d782
NC
558 ++ str;
559
560 /* The instructions are stored in hashed lists.
561 Get the first in the list. */
562 ilist = CGEN_ASM_LOOKUP_INSN (cd, str);
563
564 /* Keep looking until we find a match. */
87e6d782
NC
565 start = str;
566 for ( ; ilist != NULL ; ilist = CGEN_ASM_NEXT_INSN (ilist))
567 {
568 const CGEN_INSN *insn = ilist->insn;
fc7bc883 569 recognized_mnemonic = 1;
87e6d782
NC
570
571#ifdef CGEN_VALIDATE_INSN_SUPPORTED
f3a55c17
NC
572 /* Not usually needed as unsupported opcodes
573 shouldn't be in the hash lists. */
87e6d782
NC
574 /* Is this insn supported by the selected cpu? */
575 if (! openrisc_cgen_insn_supported (cd, insn))
576 continue;
577#endif
b11dcf4e 578 /* If the RELAXED attribute is set, this is an insn that shouldn't be
87e6d782
NC
579 chosen immediately. Instead, it is used during assembler/linker
580 relaxation if possible. */
b11dcf4e 581 if (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_RELAXED) != 0)
87e6d782
NC
582 continue;
583
584 str = start;
585
f3a55c17 586 /* Skip this insn if str doesn't look right lexically. */
fc7bc883
RH
587 if (CGEN_INSN_RX (insn) != NULL &&
588 regexec ((regex_t *) CGEN_INSN_RX (insn), str, 0, NULL, 0) == REG_NOMATCH)
589 continue;
590
87e6d782
NC
591 /* Allow parse/insert handlers to obtain length of insn. */
592 CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn);
593
594 parse_errmsg = CGEN_PARSE_FN (cd, insn) (cd, insn, & str, fields);
595 if (parse_errmsg != NULL)
596 continue;
597
f3a55c17 598 /* ??? 0 is passed for `pc'. */
87e6d782
NC
599 insert_errmsg = CGEN_INSERT_FN (cd, insn) (cd, insn, fields, buf,
600 (bfd_vma) 0);
601 if (insert_errmsg != NULL)
602 continue;
603
604 /* It is up to the caller to actually output the insn and any
605 queued relocs. */
606 return insn;
607 }
608
609 {
610 static char errbuf[150];
611#ifdef CGEN_VERBOSE_ASSEMBLER_ERRORS
612 const char *tmp_errmsg;
613
614 /* If requesting verbose error messages, use insert_errmsg.
f3a55c17 615 Failing that, use parse_errmsg. */
87e6d782
NC
616 tmp_errmsg = (insert_errmsg ? insert_errmsg :
617 parse_errmsg ? parse_errmsg :
f3a55c17
NC
618 recognized_mnemonic ?
619 _("unrecognized form of instruction") :
87e6d782
NC
620 _("unrecognized instruction"));
621
622 if (strlen (start) > 50)
623 /* xgettext:c-format */
624 sprintf (errbuf, "%s `%.50s...'", tmp_errmsg, start);
625 else
626 /* xgettext:c-format */
627 sprintf (errbuf, "%s `%.50s'", tmp_errmsg, start);
628#else
629 if (strlen (start) > 50)
630 /* xgettext:c-format */
631 sprintf (errbuf, _("bad instruction `%.50s...'"), start);
632 else
633 /* xgettext:c-format */
634 sprintf (errbuf, _("bad instruction `%.50s'"), start);
635#endif
636
637 *errmsg = errbuf;
638 return NULL;
639 }
640}
641\f
642#if 0 /* This calls back to GAS which we can't do without care. */
643
644/* Record each member of OPVALS in the assembler's symbol table.
645 This lets GAS parse registers for us.
646 ??? Interesting idea but not currently used. */
647
648/* Record each member of OPVALS in the assembler's symbol table.
649 FIXME: Not currently used. */
650
651void
ffead7ae 652openrisc_cgen_asm_hash_keywords (CGEN_CPU_DESC cd, CGEN_KEYWORD *opvals)
87e6d782
NC
653{
654 CGEN_KEYWORD_SEARCH search = cgen_keyword_search_init (opvals, NULL);
655 const CGEN_KEYWORD_ENTRY * ke;
656
657 while ((ke = cgen_keyword_search_next (& search)) != NULL)
658 {
659#if 0 /* Unnecessary, should be done in the search routine. */
660 if (! openrisc_cgen_opval_supported (ke))
661 continue;
662#endif
663 cgen_asm_record_register (cd, ke->name, ke->value);
664 }
665}
666
667#endif /* 0 */
This page took 0.228489 seconds and 4 git commands to generate.