Imported Upstream version 4.8.1
[platform/upstream/gcc48.git] / gcc / common / config / aarch64 / aarch64-common.c
1 /* Common hooks for AArch64.
2    Copyright (C) 2012-2013 Free Software Foundation, Inc.
3    Contributed by ARM Ltd.
4
5    This file is part of GCC.
6
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
9    by the Free Software Foundation; either version 3, or (at your
10    option) any later version.
11
12    GCC is distributed in the hope that it will be useful, but WITHOUT
13    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
15    License for more details.
16
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/>.  */
20
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tm.h"
25 #include "tm_p.h"
26 #include "common/common-target.h"
27 #include "common/common-target-def.h"
28 #include "opts.h"
29 #include "flags.h"
30
31 #ifdef  TARGET_BIG_ENDIAN_DEFAULT
32 #undef  TARGET_DEFAULT_TARGET_FLAGS
33 #define TARGET_DEFAULT_TARGET_FLAGS (MASK_BIG_END)
34 #endif
35
36 #undef  TARGET_HANDLE_OPTION
37 #define TARGET_HANDLE_OPTION aarch64_handle_option
38
39 #undef  TARGET_OPTION_OPTIMIZATION_TABLE
40 #define TARGET_OPTION_OPTIMIZATION_TABLE aarch_option_optimization_table
41
42 /* Set default optimization options.  */
43 static const struct default_options aarch_option_optimization_table[] =
44   {
45     /* Enable section anchors by default at -O1 or higher.  */
46     { OPT_LEVELS_1_PLUS, OPT_fsection_anchors, NULL, 1 },
47     { OPT_LEVELS_NONE, 0, NULL, 0 }
48   };
49
50 /* Implement TARGET_HANDLE_OPTION.
51    This function handles the target specific options for CPU/target selection.
52
53    march wins over mcpu, so when march is defined, mcpu takes the same value,
54    otherwise march remains undefined. mtune can be used with either march or
55    mcpu. If march and mcpu are used together, the rightmost option wins.
56    mtune can be used with either march or mcpu.  */
57
58 static bool
59 aarch64_handle_option (struct gcc_options *opts,
60                        struct gcc_options *opts_set ATTRIBUTE_UNUSED,
61                        const struct cl_decoded_option *decoded,
62                        location_t loc ATTRIBUTE_UNUSED)
63 {
64   size_t code = decoded->opt_index;
65   const char *arg = decoded->arg;
66
67   switch (code)
68     {
69     case OPT_march_:
70       opts->x_aarch64_arch_string = arg;
71       opts->x_aarch64_cpu_string = arg;
72       return true;
73
74     case OPT_mcpu_:
75       opts->x_aarch64_cpu_string = arg;
76       opts->x_aarch64_arch_string = NULL;
77       return true;
78
79     case OPT_mtune_:
80       opts->x_aarch64_tune_string = arg;
81       return true;
82
83     default:
84       return true;
85     }
86 }
87
88 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;