* target-def.h (TARGET_HAVE_NAMED_SECTIONS): Move to
[official-gcc.git] / gcc / common / config / v850 / v850-common.c
blob0e2d81760ea7255a37b82e1858f1253ba0129617
1 /* Common hooks for NEC V850 series.
2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
3 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "diagnostic-core.h"
25 #include "tm.h"
26 #include "common/common-target.h"
27 #include "common/common-target-def.h"
28 #include "opts.h"
29 #include "flags.h"
31 /* Information about the various small memory areas. */
32 static const int small_memory_physical_max[(int) SMALL_MEMORY_max] =
34 256,
35 65536,
36 32768,
39 /* Set the maximum size of small memory area TYPE to the value given
40 by SIZE in structure OPTS (option text OPT passed at location LOC). */
42 static void
43 v850_handle_memory_option (enum small_memory_type type,
44 struct gcc_options *opts, const char *opt,
45 int size, location_t loc)
47 if (size > small_memory_physical_max[type])
48 error_at (loc, "value passed in %qs is too large", opt);
49 else
50 opts->x_small_memory_max[type] = size;
53 /* Implement TARGET_HANDLE_OPTION. */
55 static bool
56 v850_handle_option (struct gcc_options *opts,
57 struct gcc_options *opts_set ATTRIBUTE_UNUSED,
58 const struct cl_decoded_option *decoded,
59 location_t loc)
61 size_t code = decoded->opt_index;
62 int value = decoded->value;
64 switch (code)
66 case OPT_mspace:
67 opts->x_target_flags |= MASK_EP | MASK_PROLOG_FUNCTION;
68 return true;
70 case OPT_mv850:
71 opts->x_target_flags &= ~(MASK_CPU ^ MASK_V850);
72 return true;
74 case OPT_mv850e:
75 case OPT_mv850e1:
76 case OPT_mv850es:
77 opts->x_target_flags &= ~(MASK_CPU ^ MASK_V850E);
78 return true;
80 case OPT_mv850e2:
81 opts->x_target_flags &= ~(MASK_CPU ^ MASK_V850E2);
82 return true;
84 case OPT_mv850e2v3:
85 opts->x_target_flags &= ~(MASK_CPU ^ MASK_V850E2V3);
86 return true;
88 case OPT_mtda_:
89 v850_handle_memory_option (SMALL_MEMORY_TDA, opts,
90 decoded->orig_option_with_args_text,
91 value, loc);
92 return true;
94 case OPT_msda_:
95 v850_handle_memory_option (SMALL_MEMORY_SDA, opts,
96 decoded->orig_option_with_args_text,
97 value, loc);
98 return true;
100 case OPT_mzda_:
101 v850_handle_memory_option (SMALL_MEMORY_ZDA, opts,
102 decoded->orig_option_with_args_text,
103 value, loc);
104 return true;
106 default:
107 return true;
111 /* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */
113 static const struct default_options v850_option_optimization_table[] =
115 { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 },
116 /* Note - we no longer enable MASK_EP when optimizing. This is
117 because of a hardware bug which stops the SLD and SST instructions
118 from correctly detecting some hazards. If the user is sure that
119 their hardware is fixed or that their program will not encounter
120 the conditions that trigger the bug then they can enable -mep by
121 hand. */
122 { OPT_LEVELS_1_PLUS, OPT_mprolog_function, NULL, 1 },
123 { OPT_LEVELS_NONE, 0, NULL, 0 }
126 #undef TARGET_DEFAULT_TARGET_FLAGS
127 #define TARGET_DEFAULT_TARGET_FLAGS (MASK_DEFAULT | MASK_APP_REGS)
128 #undef TARGET_HANDLE_OPTION
129 #define TARGET_HANDLE_OPTION v850_handle_option
130 #undef TARGET_OPTION_OPTIMIZATION_TABLE
131 #define TARGET_OPTION_OPTIMIZATION_TABLE v850_option_optimization_table
133 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;