From 4a8d3d9161118cfa3e8188b7a84f34cf842e0787 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Tue, 22 Mar 2011 22:48:11 +0000 Subject: [PATCH] v850-opts.h: New. * config/v850/v850-opts.h: New. * config/v850/v850.c (small_memory): Replace with small_memory_physical_max array. Make that array static const. (v850_handle_memory_option): Take integer value of argument. Take gcc_options pointer, option text and location. Return void. Update for changes to small memory structures. (v850_handle_option): Access target_flags via opts pointer. Don't assert that global structures are in use. Update calls to v850_handle_memory_option. (v850_encode_data_area): Update references to small memory settings. * config/v850/v850.h (struct small_memory_info, small_memory): Remove. (enum small_memory_type): Move to v850-opts.h. * config/v850/v850.opt (config/v850/v850-opts.h): New HeaderInclude entry. (small_memory_max): New Variable entry. (msda): Replace by pair of options msda= and msda-. Use UInteger. (mtda, mzda): Likewise. From-SVN: r171327 --- gcc/ChangeLog | 22 +++++++++++ gcc/config/v850/v850-opts.h | 34 ++++++++++++++++ gcc/config/v850/v850.c | 79 +++++++++++++++++-------------------- gcc/config/v850/v850.h | 19 --------- gcc/config/v850/v850.opt | 29 ++++++++++---- 5 files changed, 115 insertions(+), 68 deletions(-) create mode 100644 gcc/config/v850/v850-opts.h diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 88c6de61399..965bd3b8811 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,25 @@ +2011-03-22 Joseph Myers + + * config/v850/v850-opts.h: New. + * config/v850/v850.c (small_memory): Replace with + small_memory_physical_max array. Make that array static const. + (v850_handle_memory_option): Take integer value of argument. Take + gcc_options pointer, option text and location. Return void. + Update for changes to small memory structures. + (v850_handle_option): Access target_flags via opts pointer. Don't + assert that global structures are in use. Update calls to + v850_handle_memory_option. + (v850_encode_data_area): Update references to small memory + settings. + * config/v850/v850.h (struct small_memory_info, small_memory): + Remove. + (enum small_memory_type): Move to v850-opts.h. + * config/v850/v850.opt (config/v850/v850-opts.h): New + HeaderInclude entry. + (small_memory_max): New Variable entry. + (msda): Replace by pair of options msda= and msda-. Use UInteger. + (mtda, mzda): Likewise. + 2011-03-22 Joseph Myers * config/sh/sh.c (sh_handle_option): Access target_flags via opts diff --git a/gcc/config/v850/v850-opts.h b/gcc/config/v850/v850-opts.h new file mode 100644 index 00000000000..0d238d3103f --- /dev/null +++ b/gcc/config/v850/v850-opts.h @@ -0,0 +1,34 @@ +/* Definitions for option handling for NEC V850 series. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. + + This file is part of GCC. + + GCC 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 3, or (at your option) + any later version. + + GCC is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + +#ifndef V850_OPTS_H +#define V850_OPTS_H + +enum small_memory_type { + /* tiny data area, using EP as base register */ + SMALL_MEMORY_TDA = 0, + /* small data area using dp as base register */ + SMALL_MEMORY_SDA, + /* zero data area using r0 as base register */ + SMALL_MEMORY_ZDA, + SMALL_MEMORY_max +}; + +#endif diff --git a/gcc/config/v850/v850.c b/gcc/config/v850/v850.c index 4a87bff10e7..f2275961b3a 100644 --- a/gcc/config/v850/v850.c +++ b/gcc/config/v850/v850.c @@ -51,12 +51,11 @@ static void v850_print_operand_address (FILE *, rtx); /* Information about the various small memory areas. */ -struct small_memory_info small_memory[ (int)SMALL_MEMORY_max ] = +static const int small_memory_physical_max[(int) SMALL_MEMORY_max] = { - /* Name Max Physical max. */ - { "tda", 0, 256 }, - { "sda", 0, 65536 }, - { "zda", 0, 32768 }, + 256, + 65536, + 32768, }; /* Names of the various data areas used on the v850. */ @@ -83,66 +82,62 @@ static GTY(()) section * zdata_section; static GTY(()) section * zbss_section; /* Set the maximum size of small memory area TYPE to the value given - by VALUE. Return true if VALUE was syntactically correct. VALUE - starts with the argument separator: either "-" or "=". */ + by SIZE in structure OPTS (option text OPT passed at location LOC). */ -static bool -v850_handle_memory_option (enum small_memory_type type, const char *value) +static void +v850_handle_memory_option (enum small_memory_type type, + struct gcc_options *opts, const char *opt, + int size, location_t loc) { - int i, size; - - if (*value != '-' && *value != '=') - return false; - - value++; - for (i = 0; value[i]; i++) - if (!ISDIGIT (value[i])) - return false; - - size = atoi (value); - if (size > small_memory[type].physical_max) - error ("value passed to %<-m%s%> is too large", small_memory[type].name); + if (size > small_memory_physical_max[type]) + error_at (loc, "value passed in %qs is too large", opt); else - small_memory[type].max = size; - return true; + opts->x_small_memory_max[type] = size; } /* Implement TARGET_HANDLE_OPTION. */ static bool -v850_handle_option (struct gcc_options *opts, struct gcc_options *opts_set, +v850_handle_option (struct gcc_options *opts, + struct gcc_options *opts_set ATTRIBUTE_UNUSED, const struct cl_decoded_option *decoded, - location_t loc ATTRIBUTE_UNUSED) + location_t loc) { size_t code = decoded->opt_index; - const char *arg = decoded->arg; - - gcc_assert (opts == &global_options); - gcc_assert (opts_set == &global_options_set); + int value = decoded->value; switch (code) { case OPT_mspace: - target_flags |= MASK_EP | MASK_PROLOG_FUNCTION; + opts->x_target_flags |= MASK_EP | MASK_PROLOG_FUNCTION; return true; case OPT_mv850: - target_flags &= ~(MASK_CPU ^ MASK_V850); + opts->x_target_flags &= ~(MASK_CPU ^ MASK_V850); return true; case OPT_mv850e: case OPT_mv850e1: - target_flags &= ~(MASK_CPU ^ MASK_V850E); + opts->x_target_flags &= ~(MASK_CPU ^ MASK_V850E); return true; - case OPT_mtda: - return v850_handle_memory_option (SMALL_MEMORY_TDA, arg); + case OPT_mtda_: + v850_handle_memory_option (SMALL_MEMORY_TDA, opts, + decoded->orig_option_with_args_text, + value, loc); + return true; - case OPT_msda: - return v850_handle_memory_option (SMALL_MEMORY_SDA, arg); + case OPT_msda_: + v850_handle_memory_option (SMALL_MEMORY_SDA, opts, + decoded->orig_option_with_args_text, + value, loc); + return true; - case OPT_mzda: - return v850_handle_memory_option (SMALL_MEMORY_ZDA, arg); + case OPT_mzda_: + v850_handle_memory_option (SMALL_MEMORY_ZDA, opts, + decoded->orig_option_with_args_text, + value, loc); + return true; default: return true; @@ -2265,13 +2260,13 @@ v850_encode_data_area (tree decl, rtx symbol) if (size <= 0) ; - else if (size <= small_memory [(int) SMALL_MEMORY_TDA].max) + else if (size <= small_memory_max [(int) SMALL_MEMORY_TDA]) v850_set_data_area (decl, DATA_AREA_TDA); - else if (size <= small_memory [(int) SMALL_MEMORY_SDA].max) + else if (size <= small_memory_max [(int) SMALL_MEMORY_SDA]) v850_set_data_area (decl, DATA_AREA_SDA); - else if (size <= small_memory [(int) SMALL_MEMORY_ZDA].max) + else if (size <= small_memory_max [(int) SMALL_MEMORY_ZDA]) v850_set_data_area (decl, DATA_AREA_ZDA); } diff --git a/gcc/config/v850/v850.h b/gcc/config/v850/v850.h index c21f8204b8e..d1c4320e39e 100644 --- a/gcc/config/v850/v850.h +++ b/gcc/config/v850/v850.h @@ -123,25 +123,6 @@ extern GTY(()) rtx v850_compare_op1; } while(0) #define MASK_CPU (MASK_V850 | MASK_V850E) - -/* Information about the various small memory areas. */ -struct small_memory_info { - const char *name; - long max; - long physical_max; -}; - -enum small_memory_type { - /* tiny data area, using EP as base register */ - SMALL_MEMORY_TDA = 0, - /* small data area using dp as base register */ - SMALL_MEMORY_SDA, - /* zero data area using r0 as base register */ - SMALL_MEMORY_ZDA, - SMALL_MEMORY_max -}; - -extern struct small_memory_info small_memory[(int)SMALL_MEMORY_max]; /* Target machine storage layout */ diff --git a/gcc/config/v850/v850.opt b/gcc/config/v850/v850.opt index 0ae14313ffe..12b0937391d 100644 --- a/gcc/config/v850/v850.opt +++ b/gcc/config/v850/v850.opt @@ -1,6 +1,6 @@ ; Options for the NEC V850 port of the compiler. -; Copyright (C) 2005, 2007, 2010 Free Software Foundation, Inc. +; Copyright (C) 2005, 2007, 2010, 2011 Free Software Foundation, Inc. ; ; This file is part of GCC. ; @@ -18,6 +18,12 @@ ; along with GCC; see the file COPYING3. If not see ; . +HeaderInclude +config/v850/v850-opts.h + +Variable +int small_memory_max[(int)SMALL_MEMORY_max] = { 0, 0, 0 } + mapp-regs Target Report Mask(APP_REGS) Use registers r2 and r5 @@ -50,10 +56,13 @@ mprolog-function Target Report Mask(PROLOG_FUNCTION) Use stubs for function prologues -msda -Target RejectNegative Joined +msda= +Target RejectNegative Joined UInteger Set the max size of data eligible for the SDA area +msda- +Target RejectNegative Joined Undocumented Alias(msda=) + msmall-sld Target Report Mask(SMALL_SLD) Enable the use of the short load instructions @@ -62,10 +71,13 @@ mspace Target RejectNegative Same as: -mep -mprolog-function -mtda -Target RejectNegative Joined +mtda= +Target RejectNegative Joined UInteger Set the max size of data eligible for the TDA area +mtda- +Target RejectNegative Joined Undocumented Alias(mtda=) + mno-strict-align Target Report Mask(NO_STRICT_ALIGN) Do not enforce strict alignment @@ -101,6 +113,9 @@ mv850e2v3 Target Report RejectNegative Mask(V850E2V3) Compile for the v850e2v3 processor -mzda -Target RejectNegative Joined +mzda= +Target RejectNegative Joined UInteger Set the max size of data eligible for the ZDA area + +mzda- +Target RejectNegative Joined Undocumented Alias(mzda=) -- 2.30.2