Imported Upstream version 4.7.3
[platform/upstream/gcc48.git] / gcc / common / config / m68k / m68k-common.c
1 /* Common hooks for Motorola 68000 family.
2    Copyright (C) 1987, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3    2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4    Free Software Foundation, 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 "common/common-target-def.h"
29 #include "opts.h"
30 #include "flags.h"
31
32 /* Implement TARGET_HANDLE_OPTION.  */
33
34 static bool
35 m68k_handle_option (struct gcc_options *opts,
36                     struct gcc_options *opts_set,
37                     const struct cl_decoded_option *decoded,
38                     location_t loc)
39 {
40   size_t code = decoded->opt_index;
41   const char *arg = decoded->arg;
42   int value = decoded->value;
43
44   switch (code)
45     {
46     case OPT_m68020_40:
47       opts->x_m68k_tune_option = u68020_40;
48       opts_set->x_m68k_tune_option = (enum uarch_type) 1;
49       opts->x_m68k_cpu_option = m68020;
50       opts_set->x_m68k_cpu_option = (enum target_device) 1;
51       return true;
52
53     case OPT_m68020_60:
54       opts->x_m68k_tune_option = u68020_60;
55       opts_set->x_m68k_tune_option = (enum uarch_type) 1;
56       opts->x_m68k_cpu_option = m68020;
57       opts_set->x_m68k_cpu_option = (enum target_device) 1;
58       return true;
59
60     case OPT_mshared_library_id_:
61       if (value > MAX_LIBRARY_ID)
62         error_at (loc, "-mshared-library-id=%s is not between 0 and %d",
63                   arg, MAX_LIBRARY_ID);
64       else
65         {
66           char *tmp;
67           asprintf (&tmp, "%d", (value * -4) - 4);
68           opts->x_m68k_library_id_string = tmp;
69         }
70       return true;
71
72     default:
73       return true;
74     }
75 }
76
77 #undef TARGET_HANDLE_OPTION
78 #define TARGET_HANDLE_OPTION m68k_handle_option
79
80 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;