From 10fba7f14e2917aa41cbbd212de08aaf80912480 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Thu, 24 Oct 1996 22:55:22 +0000 Subject: [PATCH] * config/tc-v850.h (TC_PARSE_CONS_EXPRESSION): Define. (TC_CONS_FIX_NEW): Likewise. * config/tc-v850.c (parse_cons_expression_v850): New function. (cons_fix_new_v850): Likewise. So we can handle ".hword lo(_foo)". --- gas/ChangeLog | 5 +++++ gas/config/tc-v850.c | 47 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/gas/ChangeLog b/gas/ChangeLog index 32d4fe4a985..3621240dc66 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,6 +1,11 @@ start-sanitize-v850 Thu Oct 24 14:31:04 1996 Jeffrey A Law (law@cygnus.com) + * config/tc-v850.h (TC_PARSE_CONS_EXPRESSION): Define. + (TC_CONS_FIX_NEW): Likewise. + * config/tc-v850.c (parse_cons_expression_v850): New function. + (cons_fix_new_v850): Likewise. + * config/tc-v850.h (tc_fix_adjustable): Don't adjust TDA relocs. end-sanitize-v850 diff --git a/gas/config/tc-v850.c b/gas/config/tc-v850.c index cab16ee8407..355815b1582 100644 --- a/gas/config/tc-v850.c +++ b/gas/config/tc-v850.c @@ -24,6 +24,9 @@ #include "as.h" #include "subsegs.h" #include "opcode/v850.h" + +/* Temporarily holds the reloc in a cons expression. */ +static bfd_reloc_code_real_type hold_cons_reloc; /* Structure to hold information about predefined registers. */ struct reg_name @@ -1004,3 +1007,47 @@ v850_insert_operand (insn, operand, val, file, line) insn |= (((long) val & ((1 << operand->bits) - 1)) << operand->shift); return insn; } + +/* Parse a cons expression. We have to handle hi(), lo(), etc + on the v850. */ +void +parse_cons_expression_v850 (exp) + expressionS *exp; +{ + /* See if there's a reloc prefix like hi() we have to handle. */ + hold_cons_reloc = v850_reloc_prefix (); + + /* Do normal expression parsing. */ + expression (exp); + + /* If we had to handle a reloc prefix, then eat the trailing + close paren. */ + if (hold_cons_reloc != BFD_RELOC_UNUSED) + input_line_pointer++; +} + +/* Create a fixup for a cons expression. If parse_cons_expression_v850 + found a reloc prefix, then we use that reloc, else we choose an + appropriate one based on the size of the expression. */ +void +cons_fix_new_v850 (frag, where, size, exp) + fragS *frag; + int where; + int size; + expressionS *exp; +{ + if (hold_cons_reloc == BFD_RELOC_UNUSED) + { + if (size == 4) + hold_cons_reloc = BFD_RELOC_32; + if (size == 2) + hold_cons_reloc = BFD_RELOC_16; + if (size == 1) + hold_cons_reloc = BFD_RELOC_8; + } + + if (exp != NULL) + fix_new_exp (frag, where, size, exp, 0, hold_cons_reloc); + else + fix_new (frag, where, size, NULL, 0, 0, hold_cons_reloc); +} -- 2.30.2