1 /* Common hooks for AArch64.
2 Copyright (C) 2012-2015 Free Software Foundation, Inc.
3 Contributed by ARM Ltd.
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
9 by the Free Software Foundation; either version 3, or (at your
10 option) 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
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 License 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/>. */
23 #include "coretypes.h"
26 #include "common/common-target.h"
27 #include "common/common-target-def.h"
32 #ifdef TARGET_BIG_ENDIAN_DEFAULT
33 #undef TARGET_DEFAULT_TARGET_FLAGS
34 #define TARGET_DEFAULT_TARGET_FLAGS (MASK_BIG_END)
37 #undef TARGET_HANDLE_OPTION
38 #define TARGET_HANDLE_OPTION aarch64_handle_option
40 #undef TARGET_OPTION_OPTIMIZATION_TABLE
41 #define TARGET_OPTION_OPTIMIZATION_TABLE aarch_option_optimization_table
43 /* Set default optimization options. */
44 static const struct default_options aarch_option_optimization_table
[] =
46 /* Enable section anchors by default at -O1 or higher. */
47 { OPT_LEVELS_1_PLUS
, OPT_fsection_anchors
, NULL
, 1 },
48 /* Enable -fsched-pressure by default when optimizing. */
49 { OPT_LEVELS_1_PLUS
, OPT_fsched_pressure
, NULL
, 1 },
50 /* Enable redundant extension instructions removal at -O2 and higher. */
51 { OPT_LEVELS_2_PLUS
, OPT_free
, NULL
, 1 },
52 { OPT_LEVELS_NONE
, 0, NULL
, 0 }
55 /* Implement TARGET_HANDLE_OPTION.
56 This function handles the target specific options for CPU/target selection.
58 -mcpu=CPU is shorthand for -march=ARCH_FOR_CPU, -mtune=CPU.
59 If either of -march or -mtune is given, they override their
60 respective component of -mcpu. This logic is implemented
61 in config/aarch64/aarch64.c:aarch64_override_options. */
64 aarch64_handle_option (struct gcc_options
*opts
,
65 struct gcc_options
*opts_set ATTRIBUTE_UNUSED
,
66 const struct cl_decoded_option
*decoded
,
67 location_t loc ATTRIBUTE_UNUSED
)
69 size_t code
= decoded
->opt_index
;
70 const char *arg
= decoded
->arg
;
75 opts
->x_aarch64_arch_string
= arg
;
79 opts
->x_aarch64_cpu_string
= arg
;
83 opts
->x_aarch64_tune_string
= arg
;
91 struct gcc_targetm_common targetm_common
= TARGETM_COMMON_INITIALIZER
;
93 #define AARCH64_CPU_NAME_LENGTH 128
95 /* Truncate NAME at the first '.' character seen up to the first '+'
96 or return NAME unmodified. */
99 aarch64_rewrite_selected_cpu (const char *name
)
101 static char output_buf
[AARCH64_CPU_NAME_LENGTH
+ 1] = {0};
107 bL_sep
= strchr (name
, '.');
111 feats
= strchr (name
, '+');
112 feat_size
= feats
? strnlen (feats
, AARCH64_CPU_NAME_LENGTH
) : 0;
113 pref_size
= bL_sep
- name
;
115 if ((feat_size
+ pref_size
) > AARCH64_CPU_NAME_LENGTH
)
116 internal_error ("-mcpu string too large");
118 strncpy (output_buf
, name
, pref_size
);
120 strncpy (output_buf
+ pref_size
, feats
, feat_size
);
125 /* Called by the driver to rewrite a name passed to the -mcpu
126 argument in preparation to be passed to the assembler. The
127 names passed from the commend line will be in ARGV, we want
128 to use the right-most argument, which should be in
129 ARGV[ARGC - 1]. ARGC should always be greater than 0. */
132 aarch64_rewrite_mcpu (int argc
, const char **argv
)
135 return aarch64_rewrite_selected_cpu (argv
[argc
- 1]);
138 #undef AARCH64_CPU_NAME_LENGTH