#define max(a,b) ((a) > (b) ? (a) : (b))
static const char * parse_insn_normal
- PARAMS ((CGEN_CPU_DESC, const CGEN_INSN *, const char **, CGEN_FIELDS *));
+ (CGEN_CPU_DESC, const CGEN_INSN *, const char **, CGEN_FIELDS *);
\f
/* -- assembler routines inserted here. */
PARAMS ((CGEN_CPU_DESC, const char **, int, unsigned long *));
static const char * parse_small_immediate
PARAMS ((CGEN_CPU_DESC, const char **, int, unsigned long *));
+static const char * parse_immediate16
+ PARAMS ((CGEN_CPU_DESC, const char **, int, unsigned long *));
/* The machine-independent code doesn't know how to disambiguate
mov (foo),r3
if (s[1] == '-' && s[2] == '-')
return _("Bad register in preincrement");
- while (isalnum (*++s))
+ while (ISALNUM (*++s))
;
if (s[0] == '+' && s[1] == '+' && (s[2] == ')' || s[2] == ','))
return _("Bad register in postincrement");
enum cgen_parse_operand_result result;
const char *errmsg;
+ if (**strp == '@')
+ return _("No relocation for small immediate");
+
errmsg = (* cd->parse_operand_fn)
(cd, CGEN_PARSE_OPERAND_INTEGER, strp, opindex, BFD_RELOC_NONE,
&result, &value);
*valuep = value;
return NULL;
}
+
+/* Literal scan be either a normal literal, a @hi() or @lo relocation. */
+
+static const char *
+parse_immediate16 (cd, strp, opindex, valuep)
+ CGEN_CPU_DESC cd;
+ const char **strp;
+ int opindex;
+ unsigned long *valuep;
+{
+ const char *errmsg;
+ enum cgen_parse_operand_result result;
+ bfd_reloc_code_real_type code = BFD_RELOC_NONE;
+ bfd_vma value;
+
+ if (strncmp (*strp, "@hi(", 4) == 0)
+ {
+ *strp += 4;
+ code = BFD_RELOC_HI16;
+ }
+ else
+ if (strncmp (*strp, "@lo(", 4) == 0)
+ {
+ *strp += 4;
+ code = BFD_RELOC_LO16;
+ }
+
+ if (code == BFD_RELOC_NONE)
+ errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, valuep);
+ else
+ {
+ errmsg = cgen_parse_address (cd, strp, opindex, code, &result, &value);
+ if ((errmsg == NULL) &&
+ (result != CGEN_PARSE_OPERAND_RESULT_QUEUED))
+ errmsg = _("Operand is not a symbol");
+
+ *valuep = value;
+ if ((code == BFD_RELOC_HI16 || code == BFD_RELOC_LO16)
+ && **strp == ')')
+ *strp += 1;
+ else
+ {
+ errmsg = _("Syntax error: No trailing ')'");
+ return errmsg;
+ }
+ }
+ return errmsg;
+}
/* -- */
const char * xstormy16_cgen_parse_operand
errmsg = cgen_parse_signed_integer (cd, strp, XSTORMY16_OPERAND_IMM12, &fields->f_imm12);
break;
case XSTORMY16_OPERAND_IMM16 :
- errmsg = cgen_parse_unsigned_integer (cd, strp, XSTORMY16_OPERAND_IMM16, &fields->f_imm16);
+ errmsg = parse_immediate16 (cd, strp, XSTORMY16_OPERAND_IMM16, &fields->f_imm16);
break;
case XSTORMY16_OPERAND_IMM2 :
errmsg = cgen_parse_unsigned_integer (cd, strp, XSTORMY16_OPERAND_IMM2, &fields->f_imm2);
Returns NULL for success, an error message for failure. */
char *
-xstormy16_cgen_build_insn_regex (insn)
- CGEN_INSN *insn;
+xstormy16_cgen_build_insn_regex (CGEN_INSN *insn)
{
CGEN_OPCODE *opc = (CGEN_OPCODE *) CGEN_INSN_OPCODE (insn);
const char *mnem = CGEN_INSN_MNEMONIC (insn);
Returns NULL for success, an error message for failure. */
static const char *
-parse_insn_normal (cd, insn, strp, fields)
- CGEN_CPU_DESC cd;
- const CGEN_INSN *insn;
- const char **strp;
- CGEN_FIELDS *fields;
+parse_insn_normal (CGEN_CPU_DESC cd,
+ const CGEN_INSN *insn,
+ const char **strp,
+ CGEN_FIELDS *fields)
{
/* ??? Runtime added insns not handled yet. */
const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
mind helps keep the design clean. */
const CGEN_INSN *
-xstormy16_cgen_assemble_insn (cd, str, fields, buf, errmsg)
- CGEN_CPU_DESC cd;
- const char *str;
- CGEN_FIELDS *fields;
- CGEN_INSN_BYTES_PTR buf;
- char **errmsg;
+xstormy16_cgen_assemble_insn (CGEN_CPU_DESC cd,
+ const char *str,
+ CGEN_FIELDS *fields,
+ CGEN_INSN_BYTES_PTR buf,
+ char **errmsg)
{
const char *start;
CGEN_INSN_LIST *ilist;
if (! xstormy16_cgen_insn_supported (cd, insn))
continue;
#endif
- /* If the RELAX attribute is set, this is an insn that shouldn't be
+ /* If the RELAXED attribute is set, this is an insn that shouldn't be
chosen immediately. Instead, it is used during assembler/linker
relaxation if possible. */
- if (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_RELAX) != 0)
+ if (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_RELAXED) != 0)
continue;
str = start;
FIXME: Not currently used. */
void
-xstormy16_cgen_asm_hash_keywords (cd, opvals)
- CGEN_CPU_DESC cd;
- CGEN_KEYWORD *opvals;
+xstormy16_cgen_asm_hash_keywords (CGEN_CPU_DESC cd, CGEN_KEYWORD *opvals)
{
CGEN_KEYWORD_SEARCH search = cgen_keyword_search_init (opvals, NULL);
const CGEN_KEYWORD_ENTRY * ke;