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"
31 #ifdef TARGET_BIG_ENDIAN_DEFAULT
32 #undef TARGET_DEFAULT_TARGET_FLAGS
33 #define TARGET_DEFAULT_TARGET_FLAGS (MASK_BIG_END)
36 #undef TARGET_HANDLE_OPTION
37 #define TARGET_HANDLE_OPTION aarch64_handle_option
39 #undef TARGET_OPTION_OPTIMIZATION_TABLE
40 #define TARGET_OPTION_OPTIMIZATION_TABLE aarch_option_optimization_table
42 /* Set default optimization options. */
43 static const struct default_options aarch_option_optimization_table
[] =
45 /* Enable section anchors by default at -O1 or higher. */
46 { OPT_LEVELS_1_PLUS
, OPT_fsection_anchors
, NULL
, 1 },
47 /* Enable -fsched-pressure by default when optimizing. */
48 { OPT_LEVELS_1_PLUS
, OPT_fsched_pressure
, NULL
, 1 },
49 /* Enable redundant extension instructions removal at -O2 and higher. */
50 { OPT_LEVELS_2_PLUS
, OPT_free
, NULL
, 1 },
51 { OPT_LEVELS_NONE
, 0, NULL
, 0 }
54 /* Implement TARGET_HANDLE_OPTION.
55 This function handles the target specific options for CPU/target selection.
57 -mcpu=CPU is shorthand for -march=ARCH_FOR_CPU, -mtune=CPU.
58 If either of -march or -mtune is given, they override their
59 respective component of -mcpu. This logic is implemented
60 in config/aarch64/aarch64.c:aarch64_override_options. */
63 aarch64_handle_option (struct gcc_options
*opts
,
64 struct gcc_options
*opts_set ATTRIBUTE_UNUSED
,
65 const struct cl_decoded_option
*decoded
,
66 location_t loc ATTRIBUTE_UNUSED
)
68 size_t code
= decoded
->opt_index
;
69 const char *arg
= decoded
->arg
;
74 opts
->x_aarch64_arch_string
= arg
;
78 opts
->x_aarch64_cpu_string
= arg
;
82 opts
->x_aarch64_tune_string
= arg
;
90 struct gcc_targetm_common targetm_common
= TARGETM_COMMON_INITIALIZER
;
92 #define AARCH64_CPU_NAME_LENGTH 20
94 /* Truncate NAME at the first '.' character seen, or return
98 aarch64_rewrite_selected_cpu (const char *name
)
100 static char output_buf
[AARCH64_CPU_NAME_LENGTH
+ 1] = {0};
103 strncpy (output_buf
, name
, AARCH64_CPU_NAME_LENGTH
);
104 arg_pos
= strchr (output_buf
, '.');
106 /* If we found a '.' truncate the entry at that point. */
113 /* Called by the driver to rewrite a name passed to the -mcpu
114 argument in preparation to be passed to the assembler. The
115 names passed from the commend line will be in ARGV, we want
116 to use the right-most argument, which should be in
117 ARGV[ARGC - 1]. ARGC should always be greater than 0. */
120 aarch64_rewrite_mcpu (int argc
, const char **argv
)
123 return aarch64_rewrite_selected_cpu (argv
[argc
- 1]);
126 #undef AARCH64_CPU_NAME_LENGTH