X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gas%2Fconfig%2Ftc-fr30.c;h=058733b4b8af4493921dd58e671d7a4daaf230bb;hb=b19ea8d28b1c06c2973738c1cda076f895ac3ad0;hp=4b820f4dce3208dab3f0763fb9763ed98af56c5d;hpb=65ec77d24561f693faed3798a7233bc4f947a6b8;p=deliverable%2Fbinutils-gdb.git diff --git a/gas/config/tc-fr30.c b/gas/config/tc-fr30.c index 4b820f4dce..058733b4b8 100644 --- a/gas/config/tc-fr30.c +++ b/gas/config/tc-fr30.c @@ -1,12 +1,11 @@ /* tc-fr30.c -- Assembler for the Fujitsu FR30. - Copyright 1998, 1999, 2000, 2001, 2002, 2003 - Free Software Foundation, Inc. + Copyright (C) 1998-2016 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. GAS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) + the Free Software Foundation; either version 3, or (at your option) any later version. GAS is distributed in the hope that it will be useful, @@ -16,10 +15,9 @@ You should have received a copy of the GNU General Public License along with GAS; see the file COPYING. If not, write to - the Free Software Foundation, 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ + the Free Software Foundation, 51 Franklin Street - Fifth Floor, + Boston, MA 02110-1301, USA. */ -#include #include "as.h" #include "safe-ctype.h" #include "subsegs.h" @@ -66,9 +64,8 @@ struct option md_longopts[] = size_t md_longopts_size = sizeof (md_longopts); int -md_parse_option (c, arg) - int c ATTRIBUTE_UNUSED; - char *arg ATTRIBUTE_UNUSED; +md_parse_option (int c ATTRIBUTE_UNUSED, + const char *arg ATTRIBUTE_UNUSED) { switch (c) { @@ -79,8 +76,7 @@ md_parse_option (c, arg) } void -md_show_usage (stream) - FILE * stream; +md_show_usage (FILE * stream) { fprintf (stream, _(" FR30 specific command line options:\n")); } @@ -94,7 +90,7 @@ const pseudo_typeS md_pseudo_table[] = void -md_begin () +md_begin (void) { /* Initialize the `cgen' interface. */ @@ -110,8 +106,7 @@ md_begin () } void -md_assemble (str) - char *str; +md_assemble (char *str) { static int last_insn_had_delay_slot = 0; fr30_insn insn; @@ -125,7 +120,7 @@ md_assemble (str) if (!insn.insn) { - as_bad (errmsg); + as_bad ("%s", errmsg); return; } @@ -147,8 +142,7 @@ md_assemble (str) We just ignore it. */ void -md_operand (expressionP) - expressionS * expressionP; +md_operand (expressionS * expressionP) { if (* input_line_pointer == '#') { @@ -158,19 +152,17 @@ md_operand (expressionP) } valueT -md_section_align (segment, size) - segT segment; - valueT size; +md_section_align (segT segment, valueT size) { int align = bfd_get_section_alignment (stdoutput, segment); - return ((size + (1 << align) - 1) & (-1 << align)); + + return ((size + (1 << align) - 1) & -(1 << align)); } symbolS * -md_undefined_symbol (name) - char *name ATTRIBUTE_UNUSED; +md_undefined_symbol (char *name ATTRIBUTE_UNUSED) { - return 0; + return NULL; } /* Interface to relax_segment. */ @@ -215,9 +207,7 @@ const relax_typeS md_relax_table[] = 0 value. */ int -md_estimate_size_before_relax (fragP, segment) - fragS * fragP; - segT segment; +md_estimate_size_before_relax (fragS * fragP, segT segment) { /* The only thing we have to handle here are symbols outside of the current segment. They may be undefined or in a different segment in @@ -268,10 +258,9 @@ md_estimate_size_before_relax (fragP, segment) fragP->fr_subtype is the subtype of what the address relaxed to. */ void -md_convert_frag (abfd, sec, fragP) - bfd *abfd ATTRIBUTE_UNUSED; - segT sec ATTRIBUTE_UNUSED; - fragS *fragP ATTRIBUTE_UNUSED; +md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, + segT sec ATTRIBUTE_UNUSED, + fragS *fragP ATTRIBUTE_UNUSED) { } @@ -281,18 +270,14 @@ md_convert_frag (abfd, sec, fragP) given a PC relative reloc. */ long -md_pcrel_from_section (fixP, sec) - fixS * fixP; - segT sec; +md_pcrel_from_section (fixS * fixP, segT sec) { if (fixP->fx_addsy != (symbolS *) NULL && (! S_IS_DEFINED (fixP->fx_addsy) || S_GET_SEGMENT (fixP->fx_addsy) != sec)) - { - /* The symbol is undefined (or is defined but not in this section). - Let the linker figure it out. */ - return 0; - } + /* The symbol is undefined (or is defined but not in this section). + Let the linker figure it out. */ + return 0; return (fixP->fx_frag->fr_address + fixP->fx_where) & ~1; } @@ -302,10 +287,9 @@ md_pcrel_from_section (fixP, sec) *FIXP may be modified if desired. */ bfd_reloc_code_real_type -md_cgen_lookup_reloc (insn, operand, fixP) - const CGEN_INSN *insn ATTRIBUTE_UNUSED; - const CGEN_OPERAND *operand; - fixS *fixP; +md_cgen_lookup_reloc (const CGEN_INSN *insn ATTRIBUTE_UNUSED, + const CGEN_OPERAND *operand, + fixS *fixP) { switch (operand->type) { @@ -318,7 +302,7 @@ md_cgen_lookup_reloc (insn, operand, fixP) case FR30_OPERAND_I8: return BFD_RELOC_8; case FR30_OPERAND_I32: return BFD_RELOC_FR30_48; case FR30_OPERAND_I20: return BFD_RELOC_FR30_20; - default : /* avoid -Wall warning */ + default : /* Avoid -Wall warning. */ break; } @@ -328,88 +312,28 @@ md_cgen_lookup_reloc (insn, operand, fixP) /* Write a value out to the object file, using the appropriate endianness. */ void -md_number_to_chars (buf, val, n) - char * buf; - valueT val; - int n; +md_number_to_chars (char * buf, valueT val, int n) { number_to_chars_bigendian (buf, val, n); } -/* Turn a string in input_line_pointer into a floating point constant of type - type, and store the appropriate bytes in *litP. The number of LITTLENUMS - emitted is stored in *sizeP . An error message is returned, or NULL on OK. -*/ - -/* Equal to MAX_PRECISION in atof-ieee.c */ -#define MAX_LITTLENUMS 6 - -char * -md_atof (type, litP, sizeP) - char type; - char * litP; - int * sizeP; +const char * +md_atof (int type, char * litP, int * sizeP) { - int i; - int prec; - LITTLENUM_TYPE words [MAX_LITTLENUMS]; - char * t; - - switch (type) - { - case 'f': - case 'F': - case 's': - case 'S': - prec = 2; - break; - - case 'd': - case 'D': - case 'r': - case 'R': - prec = 4; - break; - - /* FIXME: Some targets allow other format chars for bigger sizes here. */ - - default: - * sizeP = 0; - return _("Bad call to md_atof()"); - } - - t = atof_ieee (input_line_pointer, type, words); - if (t) - input_line_pointer = t; - * sizeP = prec * sizeof (LITTLENUM_TYPE); - - for (i = 0; i < prec; i++) - { - md_number_to_chars (litP, (valueT) words[i], - sizeof (LITTLENUM_TYPE)); - litP += sizeof (LITTLENUM_TYPE); - } - - return 0; + return ieee_md_atof (type, litP, sizeP, TRUE); } /* Worker function for fr30_is_colon_insn(). */ -static char restore_colon PARAMS ((int)); - -static char -restore_colon (advance_i_l_p_by) - int advance_i_l_p_by; +static int +restore_colon (char *next_i_l_p, char *nul_char) { - char c; - /* Restore the colon, and advance input_line_pointer to the end of the new symbol. */ - * input_line_pointer = ':'; - input_line_pointer += advance_i_l_p_by; - c = * input_line_pointer; - * input_line_pointer = 0; - - return c; + *input_line_pointer = *nul_char; + input_line_pointer = next_i_l_p; + *nul_char = *next_i_l_p; + *next_i_l_p = 0; + return 1; } /* Determines if the symbol starting at START and ending in @@ -417,15 +341,17 @@ restore_colon (advance_i_l_p_by) (but which has now been replaced bu a NUL) is in fact an LDI:8, LDI:20, LDI:32, CALL:D. JMP:D, RET:D or Bcc:D instruction. If it is, then it restores the colon, advances INPUT_LINE_POINTER - to the real end of the instruction/symbol, and returns the character - that really terminated the symbol. Otherwise it returns 0. */ -char -fr30_is_colon_insn (start) - char * start; + to the real end of the instruction/symbol, saves the char there to + NUL_CHAR and pokes a NUL, and returns 1. Otherwise it returns 0. */ +int +fr30_is_colon_insn (char *start, char *nul_char) { char * i_l_p = input_line_pointer; - /* Check to see if the symbol parsed so far is 'ldi' */ + if (*nul_char == '"') + ++i_l_p; + + /* Check to see if the symbol parsed so far is 'ldi'. */ if ( (start[0] != 'l' && start[0] != 'L') || (start[1] != 'd' && start[1] != 'D') || (start[2] != 'i' && start[2] != 'I') @@ -437,7 +363,7 @@ fr30_is_colon_insn (start) { /* Yup - it might be delay slot instruction. */ int i; - static char * delay_insns [] = + static const char * delay_insns [] = { "call", "jmp", "ret", "bra", "bno", "beq", "bne", "bc", "bnc", "bn", @@ -447,7 +373,7 @@ fr30_is_colon_insn (start) for (i = sizeof (delay_insns) / sizeof (delay_insns[0]); i--;) { - char * insn = delay_insns[i]; + const char * insn = delay_insns[i]; int len = strlen (insn); if (start [len] != 0) @@ -458,7 +384,7 @@ fr30_is_colon_insn (start) break; if (len == -1) - return restore_colon (1); + return restore_colon (i_l_p + 1, nul_char); } } @@ -466,26 +392,27 @@ fr30_is_colon_insn (start) return 0; } - /* Check to see if the text following the colon is '8' */ + /* Check to see if the text following the colon is '8'. */ if (i_l_p[1] == '8' && (i_l_p[2] == ' ' || i_l_p[2] == '\t')) - return restore_colon (2); + return restore_colon (i_l_p + 2, nul_char); - /* Check to see if the text following the colon is '20' */ - else if (i_l_p[1] == '2' && i_l_p[2] =='0' && (i_l_p[3] == ' ' || i_l_p[3] == '\t')) - return restore_colon (3); + /* Check to see if the text following the colon is '20'. */ + else if (i_l_p[1] == '2' && i_l_p[2] =='0' + && (i_l_p[3] == ' ' || i_l_p[3] == '\t')) + return restore_colon (i_l_p + 3, nul_char); - /* Check to see if the text following the colon is '32' */ - else if (i_l_p[1] == '3' && i_l_p[2] =='2' && (i_l_p[3] == ' ' || i_l_p[3] == '\t')) - return restore_colon (3); + /* Check to see if the text following the colon is '32'. */ + else if (i_l_p[1] == '3' && i_l_p[2] =='2' + && (i_l_p[3] == ' ' || i_l_p[3] == '\t')) + return restore_colon (i_l_p + 3, nul_char); return 0; } bfd_boolean -fr30_fix_adjustable (fixP) - fixS * fixP; +fr30_fix_adjustable (fixS * fixP) { - /* We need the symbol name for the VTABLE entries */ + /* We need the symbol name for the VTABLE entries. */ if (fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT || fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY) return 0;