+/* DO NOT EDIT! -*- buffer-read-only: t -*- vi:set ro: */
/* Assembler interface for targets using CGEN. -*- C -*-
CGEN: Cpu tools GENerator
THIS FILE IS MACHINE GENERATED WITH CGEN.
- the resultant file is machine generated, cgen-asm.in isn't
- Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005, 2007, 2008
- Free Software Foundation, Inc.
+ Copyright (C) 1996-2017 Free Software Foundation, Inc.
This file is part of libopcodes.
break;
default:
/* Safe assumption? */
- abort ();
+ abort ();
}
errmsg = cgen_parse_address (cd, strp, opindex, reloc,
NULL, &value);
if ((MEP_CPU & EF_MEP_CPU_MASK) == EF_MEP_CPU_C5)
wide = 1;
- if (strncmp (*strp, "0x0", 3) == 0
+ if (strncmp (*strp, "0x0", 3) == 0
|| (**strp == '0' && *(*strp + 1) != 'x'))
have_zero = 1;
static char *
str_append (char *dest, const char *input, int len)
-{
+{
char *new_dest;
int oldlen;
char *result = 0, *rescanned_result = 0;
char *e = mac->expansion;
char *mark = e;
- int arg = 0;
+ int mac_arg = 0;
/* printf("expanding macro %s with %d args\n", mac->name, narg + 1); */
while (*e)
{
- if (*e == '`' &&
- (*e+1) &&
+ if (*e == '`' &&
+ (*e+1) &&
((*(e + 1) - '1') <= MAXARGS) &&
((*(e + 1) - '1') <= narg))
{
result = str_append (result, mark, e - mark);
- arg = (*(e + 1) - '1');
- /* printf("replacing `%d with %s\n", arg+1, args[arg].start); */
- result = str_append (result, args[arg].start, args[arg].len);
+ mac_arg = (*(e + 1) - '1');
+ /* printf("replacing `%d with %s\n", mac_arg+1, args[mac_arg].start); */
+ result = str_append (result, args[mac_arg].start, args[mac_arg].len);
++e;
mark = e+1;
}
free (result);
return rescanned_result;
}
- else
+ else
return result;
}
arg args[MAXARGS];
int state = IN_TEXT;
const char *mark = in;
- macro *macro = 0;
-
+ macro *pmacro = NULL;
char *expansion = 0;
char *result = 0;
switch (state)
{
case IN_TEXT:
- if (*in == '%' && *(in + 1) && (!first_only || num_expansions == 0))
- {
- macro = lookup_macro (in + 1);
- if (macro)
+ if (*in == '%' && *(in + 1) && (!first_only || num_expansions == 0))
+ {
+ pmacro = lookup_macro (in + 1);
+ if (pmacro)
{
/* printf("entering state %d at '%s'...\n", state, in); */
result = str_append (result, mark, in - mark);
mark = in;
- in += 1 + strlen (macro->name);
+ in += 1 + strlen (pmacro->name);
while (*in == ' ') ++in;
if (*in != '(')
{
- state = IN_TEXT;
- macro = 0;
+ state = IN_TEXT;
+ pmacro = NULL;
}
else
{
narg = 0;
args[narg].start = in + 1;
args[narg].len = 0;
- mark = in + 1;
+ mark = in + 1;
}
}
}
case ')':
state = IN_TEXT;
/* printf("entering state %d at '%s'...\n", state, in); */
- if (macro)
+ if (pmacro)
{
expansion = 0;
- expansion = expand_macro (args, narg, macro);
+ expansion = expand_macro (args, narg, pmacro);
num_expansions++;
if (expansion)
{
{
result = str_append (result, mark, in - mark);
}
- macro = 0;
+ pmacro = NULL;
mark = in + 1;
break;
case '(':
depth++;
+ /* Fall through. */
default:
args[narg].len++;
- break;
+ break;
}
- }
+ }
else
{
if (*in == ')')
if (narg > -1)
args[narg].len++;
}
-
+
}
++in;
}
-
+
if (mark != in)
result = str_append (result, mark, in - mark);
-
+
return result;
}
{
if (strstr (*strp_in, str))
/* A macro-expansion was pulled off the front. */
- *strp_in = strstr (*strp_in, str);
+ *strp_in = strstr (*strp_in, str);
else
/* A non-macro-expansion was pulled off the front. */
- *strp_in += (str - hold);
+ *strp_in += (str - hold);
}
if (hold)
return errmsg;
}
-#define CGEN_ASM_INIT_HOOK (cd->parse_operand = mep_cgen_expand_macros_and_parse_operand);
+#define CGEN_ASM_INIT_HOOK (cd->parse_operand = mep_cgen_expand_macros_and_parse_operand);
/* -- dis.c */
return errmsg;
}
-cgen_parse_fn * const mep_cgen_parse_handlers[] =
+cgen_parse_fn * const mep_cgen_parse_handlers[] =
{
parse_insn_normal,
};
Returns NULL for success, an error message for failure. */
-char *
+char *
mep_cgen_build_insn_regex (CGEN_INSN *insn)
-{
+{
CGEN_OPCODE *opc = (CGEN_OPCODE *) CGEN_INSN_OPCODE (insn);
const char *mnem = CGEN_INSN_MNEMONIC (insn);
char rxbuf[CGEN_MAX_RX_ELEMENTS];
/* Copy any remaining literals from the syntax string into the rx. */
for(; * syn != 0 && rx <= rxbuf + (CGEN_MAX_RX_ELEMENTS - 7 - 4); ++syn)
{
- if (CGEN_SYNTAX_CHAR_P (* syn))
+ if (CGEN_SYNTAX_CHAR_P (* syn))
{
char c = CGEN_SYNTAX_CHAR (* syn);
- switch (c)
+ switch (c)
{
/* Escape any regex metacharacters in the syntax. */
- case '.': case '[': case '\\':
- case '*': case '^': case '$':
+ case '.': case '[': case '\\':
+ case '*': case '^': case '$':
#ifdef CGEN_ESCAPE_EXTENDED_REGEX
- case '?': case '{': case '}':
+ case '?': case '{': case '}':
case '(': case ')': case '*':
case '|': case '+': case ']':
#endif
}
/* Trailing whitespace ok. */
- * rx++ = '[';
- * rx++ = ' ';
- * rx++ = '\t';
- * rx++ = ']';
- * rx++ = '*';
+ * rx++ = '[';
+ * rx++ = ' ';
+ * rx++ = '\t';
+ * rx++ = ']';
+ * rx++ = '*';
/* But anchor it after that. */
- * rx++ = '$';
+ * rx++ = '$';
* rx = '\0';
CGEN_INSN_RX (insn) = xmalloc (sizeof (regex_t));
reg_err = regcomp ((regex_t *) CGEN_INSN_RX (insn), rxbuf, REG_NOSUB);
- if (reg_err == 0)
+ if (reg_err == 0)
return NULL;
else
{
continue;
}
+#ifdef CGEN_MNEMONIC_OPERANDS
+ (void) past_opcode_p;
+#endif
/* We have an operand of some sort. */
- errmsg = cd->parse_operand (cd, CGEN_SYNTAX_FIELD (*syn),
- &str, fields);
+ errmsg = cd->parse_operand (cd, CGEN_SYNTAX_FIELD (*syn), &str, fields);
if (errmsg)
return errmsg;
const CGEN_INSN *insn = ilist->insn;
recognized_mnemonic = 1;
-#ifdef CGEN_VALIDATE_INSN_SUPPORTED
+#ifdef CGEN_VALIDATE_INSN_SUPPORTED
/* Not usually needed as unsupported opcodes
shouldn't be in the hash lists. */
/* Is this insn supported by the selected cpu? */
{
static char errbuf[150];
-#ifdef CGEN_VERBOSE_ASSEMBLER_ERRORS
const char *tmp_errmsg;
-
- /* If requesting verbose error messages, use insert_errmsg.
- Failing that, use parse_errmsg. */
- tmp_errmsg = (insert_errmsg ? insert_errmsg :
- parse_errmsg ? parse_errmsg :
- recognized_mnemonic ?
- _("unrecognized form of instruction") :
- _("unrecognized instruction"));
-
- if (strlen (start) > 50)
- /* xgettext:c-format */
- sprintf (errbuf, "%s `%.50s...'", tmp_errmsg, start);
- else
- /* xgettext:c-format */
- sprintf (errbuf, "%s `%.50s'", tmp_errmsg, start);
+#ifdef CGEN_VERBOSE_ASSEMBLER_ERRORS
+#define be_verbose 1
#else
- if (strlen (start) > 50)
- /* xgettext:c-format */
- sprintf (errbuf, _("bad instruction `%.50s...'"), start);
- else
- /* xgettext:c-format */
- sprintf (errbuf, _("bad instruction `%.50s'"), start);
+#define be_verbose 0
#endif
-
+
+ if (be_verbose)
+ {
+ /* If requesting verbose error messages, use insert_errmsg.
+ Failing that, use parse_errmsg. */
+ tmp_errmsg = (insert_errmsg ? insert_errmsg :
+ parse_errmsg ? parse_errmsg :
+ recognized_mnemonic ?
+ _("unrecognized form of instruction") :
+ _("unrecognized instruction"));
+
+ if (strlen (start) > 50)
+ /* xgettext:c-format */
+ sprintf (errbuf, "%s `%.50s...'", tmp_errmsg, start);
+ else
+ /* xgettext:c-format */
+ sprintf (errbuf, "%s `%.50s'", tmp_errmsg, start);
+ }
+ else
+ {
+ if (strlen (start) > 50)
+ /* xgettext:c-format */
+ sprintf (errbuf, _("bad instruction `%.50s...'"), start);
+ else
+ /* xgettext:c-format */
+ sprintf (errbuf, _("bad instruction `%.50s'"), start);
+ }
+
*errmsg = errbuf;
return NULL;
}