xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/common/config/arc/arc-common.c (revision c38e7cc395b1472a774ff828e46123de44c628e9)
1 /* Common hooks for Synopsys DesignWare ARC
2    Copyright (C) 1994-2015 Free Software Foundation, Inc.
3    Contributor: Joern Rennecke <joern.rennecke@embecosm.com>
4 		on behalf of Synopsys Inc.
5 
6 This file is part of GCC.
7 
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
12 
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3.  If not see
20 <http://www.gnu.org/licenses/>.  */
21 
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "diagnostic-core.h"
26 #include "tm.h"
27 #include "common/common-target.h"
28 #include "opts.h"
29 #include "flags.h"
30 
31 static void
32 arc_option_init_struct (struct gcc_options *opts)
33 {
34   opts->x_flag_no_common = 255; /* Mark as not user-initialized.  */
35 
36   /* Which cpu we're compiling for (A5, ARC600, ARC601, ARC700).  */
37   arc_cpu = PROCESSOR_NONE;
38 }
39 
40 /* Set default optimization options.  */
41 /* The conditions are incomplete, so we rely on the evaluation order here,
42    which goes from first to last, i.e. the last match prevails.  */
43 /* ??? But this trick only works for reject_negative options.  Approximate
44    missing option combination.  */
45 #define OPT_LEVELS_3_PLUS_SPEED_ONLY OPT_LEVELS_3_PLUS
46 static const struct default_options arc_option_optimization_table[] =
47   {
48     { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 },
49     { OPT_LEVELS_ALL, OPT_mRcq, NULL, 1 },
50     { OPT_LEVELS_ALL, OPT_mRcw, NULL, 1 },
51     { OPT_LEVELS_ALL, OPT_msize_level_, NULL, 1 },
52     { OPT_LEVELS_3_PLUS_SPEED_ONLY, OPT_msize_level_, NULL, 0 },
53     { OPT_LEVELS_SIZE, OPT_msize_level_, NULL, 3 },
54     { OPT_LEVELS_3_PLUS_SPEED_ONLY, OPT_malign_call, NULL, 1 },
55     { OPT_LEVELS_ALL, OPT_mearly_cbranchsi, NULL, 1 },
56     { OPT_LEVELS_ALL, OPT_mbbit_peephole, NULL, 1 },
57     { OPT_LEVELS_SIZE, OPT_mq_class, NULL, 1 },
58     { OPT_LEVELS_SIZE, OPT_mcase_vector_pcrel, NULL, 1 },
59     { OPT_LEVELS_SIZE, OPT_mcompact_casesi, NULL, 1 },
60     { OPT_LEVELS_NONE, 0, NULL, 0 }
61   };
62 
63 /*  Process options.  */
64 static bool
65 arc_handle_option (struct gcc_options *opts, struct gcc_options *opts_set,
66 		   const struct cl_decoded_option *decoded,
67 		   location_t loc)
68 {
69   size_t code = decoded->opt_index;
70   int value = decoded->value;
71 
72   switch (code)
73     {
74       static int mcpu_seen = PROCESSOR_NONE;
75     case OPT_mcpu_:
76       /* N.B., at this point arc_cpu has already been set to its new value by
77 	 our caller, so comparing arc_cpu with PROCESSOR_NONE is pointless.  */
78 
79       if (mcpu_seen != PROCESSOR_NONE && mcpu_seen != value)
80 	warning_at (loc, 0, "multiple -mcpu= options specified.");
81       mcpu_seen = value;
82 
83       switch (value)
84 	{
85 	case PROCESSOR_A5:
86 	case PROCESSOR_ARC600:
87 	case PROCESSOR_ARC700:
88 	  if (! (opts_set->x_target_flags & MASK_BARREL_SHIFTER) )
89 	    opts->x_target_flags |= MASK_BARREL_SHIFTER;
90 	  break;
91 	case PROCESSOR_ARC601:
92 	  if (! (opts_set->x_target_flags & MASK_BARREL_SHIFTER) )
93 	    opts->x_target_flags &= ~MASK_BARREL_SHIFTER;
94 	  break;
95 	default:
96 	  gcc_unreachable ();
97 	}
98     }
99 
100   return true;
101 }
102 
103 #define TARGET_OPTION_INIT_STRUCT arc_option_init_struct
104 #define TARGET_OPTION_OPTIMIZATION_TABLE arc_option_optimization_table
105 #define TARGET_HANDLE_OPTION arc_handle_option
106 
107 #define DEFAULT_NO_SDATA (TARGET_SDATA_DEFAULT ? 0 : MASK_NO_SDATA_SET)
108 
109 /* We default to ARC700, which has the barrel shifter enabled.  */
110 #define TARGET_DEFAULT_TARGET_FLAGS \
111   (MASK_BARREL_SHIFTER|MASK_VOLATILE_CACHE_SET|DEFAULT_NO_SDATA)
112 
113 
114 #include "common/common-target-def.h"
115 
116 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
117