1 /* Common hooks for ARM.
2 Copyright (C) 1991-2022 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published
8 by the Free Software Foundation; either version 3, or (at your
9 option) any later version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
21 #define INCLUDE_VECTOR
22 #define INCLUDE_ALGORITHM
25 #include "coretypes.h"
29 #include "common/common-target.h"
30 #include "common/common-target-def.h"
34 #include "diagnostic.h"
36 #include "configargs.h"
38 /* Set default optimization options. */
39 static const struct default_options arm_option_optimization_table
[] =
41 /* Enable section anchors by default at -O1 or higher. */
42 { OPT_LEVELS_1_PLUS
, OPT_fsection_anchors
, NULL
, 1 },
43 { OPT_LEVELS_1_PLUS
, OPT_fsched_pressure
, NULL
, 1 },
44 { OPT_LEVELS_NONE
, 0, NULL
, 0 }
47 /* Implement TARGET_EXCEPT_UNWIND_INFO. */
50 arm_except_unwind_info (struct gcc_options
*opts
)
52 /* Honor the --enable-sjlj-exceptions configure switch. */
53 #ifdef CONFIG_SJLJ_EXCEPTIONS
54 if (CONFIG_SJLJ_EXCEPTIONS
)
58 /* If not using ARM EABI unwind tables... */
61 /* For simplicity elsewhere in this file, indicate that all unwind
62 info is disabled if we're not emitting unwind tables. */
63 if (!opts
->x_flag_exceptions
&& !opts
->x_flag_unwind_tables
)
69 /* ... honor target configurations requesting DWARF2 EH... */
70 #ifdef DWARF2_UNWIND_INFO
71 if (DWARF2_UNWIND_INFO
)
75 /* ... or fallback to sjlj exceptions for backwards compatibility. */
79 #define ARM_CPU_NAME_LENGTH 20
81 /* Truncate NAME at the first '.' or '+' character seen, or return
85 arm_rewrite_selected_cpu (const char *name
)
87 static char output_buf
[ARM_CPU_NAME_LENGTH
+ 1] = {0};
90 strncpy (output_buf
, name
, ARM_CPU_NAME_LENGTH
);
91 output_buf
[ARM_CPU_NAME_LENGTH
] = 0;
93 arg_pos
= strchr (output_buf
, '.');
95 /* If we found a '.' truncate the entry at that point. */
99 arg_pos
= strchr (output_buf
, '+');
101 /* If we found a '+' truncate the entry at that point. */
108 /* Called by the driver to rewrite a name passed to the -mcpu
109 argument in preparation to be passed to the assembler. The
110 names passed from the command line will be in ARGV, we want
111 to use the right-most argument, which should be in
112 ARGV[ARGC - 1]. ARGC should always be greater than 0. */
115 arm_rewrite_mcpu (int argc
, const char **argv
)
119 #ifdef HAVE_GAS_ARM_EXTENDED_ARCH
120 return argv
[argc
- 1];
122 return arm_rewrite_selected_cpu (argv
[argc
- 1]);
126 /* Comparator for arm_rewrite_selected_arch. Compare the two arch extension
127 strings FIRST and SECOND and return TRUE if FIRST is less than SECOND
131 compare_opt_names (const char *first
, const char *second
)
133 return strcmp (first
, second
) <= 0;
136 /* Rewrite the architecture string for passing to the assembler.
137 Although the syntax is similar we cannot assume that it supports
138 the newer FP related options. So strip any option that only
139 defines features in the standard -mfpu options out. We'll generate
140 a suitable -mfpu option elsewhere to carry that information. NAME
141 should already have been canonicalized, so we do not expect to
142 encounter +no.. options that remove features. A final problem is
143 that the assembler expects the feature extensions to be listed
144 alphabetically, so we build a list of required options and then
145 sort them into canonical order in the resulting string. */
147 arm_rewrite_selected_arch (const char *name
)
149 /* The result we return needs to be semi persistent, so handle being
151 static char *asm_arch
= NULL
;
159 const char *arg_pos
= strchr (name
, '+');
161 /* No extension options? just return the original string. */
165 const arch_option
*arch_opt
166 = arm_parse_arch_option_name (all_architectures
, "-march", name
);
168 auto_sbitmap
fpu_bits (isa_num_bits
);
169 static const enum isa_feature fpu_bitlist
[]
170 = { ISA_ALL_FPU_INTERNAL
, isa_nobit
};
172 arm_initialize_isa (fpu_bits
, fpu_bitlist
);
174 auto_sbitmap
opt_bits (isa_num_bits
);
176 /* Ensure that the resulting string is large enough for the result. We
177 never add options, so using strdup here will ensure that. */
178 asm_arch
= xstrdup (name
);
179 asm_arch
[arg_pos
- name
] = '\0';
181 std::vector
<const char *>optlist
;
185 const char *end
= strchr (arg_pos
+ 1, '+');
186 size_t len
= end
? end
- arg_pos
: strlen (arg_pos
);
188 for (const cpu_arch_extension
*entry
= arch_opt
->common
.extensions
;
192 if (strncmp (entry
->name
, arg_pos
+ 1, len
- 1) == 0
193 && entry
->name
[len
- 1] == '\0')
195 /* Don't expect removal options. */
196 gcc_assert (!entry
->remove
);
197 arm_initialize_isa (opt_bits
, entry
->isa_bits
);
198 if (!bitmap_subset_p (opt_bits
, fpu_bits
))
199 optlist
.push_back (entry
->name
);
200 bitmap_clear (opt_bits
);
208 std::sort (optlist
.begin (), optlist
.end (), compare_opt_names
);
210 for (std::vector
<const char *>::iterator opt_iter
= optlist
.begin ();
211 opt_iter
!= optlist
.end ();
214 strcat (asm_arch
, "+");
215 strcat (asm_arch
, (*opt_iter
));
221 /* Called by the driver to rewrite a name passed to the -march
222 argument in preparation to be passed to the assembler. The
223 names passed from the command line will be in ARGV, we want
224 to use the right-most argument, which should be in
225 ARGV[ARGC - 1]. ARGC should always be greater than 0. */
228 arm_rewrite_march (int argc
, const char **argv
)
232 #ifdef HAVE_GAS_ARM_EXTENDED_ARCH
233 return argv
[argc
- 1];
235 return arm_rewrite_selected_arch (argv
[argc
- 1]);
239 #include "arm-cpu-cdata.h"
241 /* Scan over a raw feature array BITS checking for BIT being present.
242 This is slower than the normal bitmask checks, but we would spend longer
243 initializing that than doing the check this way. Returns true iff
246 check_isa_bits_for (const enum isa_feature
* bits
, enum isa_feature bit
)
248 while (*bits
!= isa_nobit
)
255 /* Look up NAME in the configuration defaults for this build of the
256 the compiler. Return the value associated with that name, or NULL
257 if no value is found. */
259 arm_config_default (const char *name
)
263 if (configure_default_options
[0].name
== NULL
)
266 for (i
= 0; i
< ARRAY_SIZE (configure_default_options
); i
++)
267 if (strcmp (configure_default_options
[i
].name
, name
) == 0)
268 return configure_default_options
[i
].value
;
273 /* Called by the driver to check whether the target denoted by current
274 command line options is a Thumb-only, or ARM-only, target. ARGV is
275 an array of tupples (normally only one) where the first element of
276 the tupple is 'cpu' or 'arch' and the second is the option passed
277 to the compiler for that. An architecture tupple is always taken
278 in preference to a cpu tupple and the last of each type always
279 overrides any earlier setting. */
282 arm_target_mode (int argc
, const char **argv
)
284 const char *arch
= NULL
;
285 const char *cpu
= NULL
;
288 fatal_error (input_location
,
289 "%%:%<target_mode_check%> takes an even number of parameters");
293 if (strcmp (argv
[0], "arch") == 0)
295 else if (strcmp (argv
[0], "cpu") == 0)
298 fatal_error (input_location
, "unrecognized option passed to %%:"
299 "%<target_mode_check%>");
304 /* No architecture, or CPU, has option extensions that change
305 whether or not we have a Thumb-only device, so there is no need
306 to scan any option extensions specified. */
308 /* If the architecture is specified, that overrides any CPU setting. */
311 const arch_option
*arch_opt
312 = arm_parse_arch_option_name (all_architectures
, "-march", arch
,
315 if (arch_opt
&& !check_isa_bits_for (arch_opt
->common
.isa_bits
,
318 if (arch_opt
&& !check_isa_bits_for (arch_opt
->common
.isa_bits
,
324 const cpu_option
*cpu_opt
325 = arm_parse_cpu_option_name (all_cores
, "-mcpu", cpu
, false);
327 if (cpu_opt
&& !check_isa_bits_for (cpu_opt
->common
.isa_bits
,
330 if (cpu_opt
&& !check_isa_bits_for (cpu_opt
->common
.isa_bits
,
335 const char *default_mode
= arm_config_default ("mode");
338 if (strcmp (default_mode
, "thumb") == 0)
340 else if (strcmp (default_mode
, "arm") == 0)
346 /* Compiler hasn't been configured with a default, and the CPU
347 doesn't require Thumb, so default to ARM. */
351 /* List the permitted CPU option names. If TARGET is a near miss for an
352 entry, print out the suggested alternative. */
354 arm_print_hint_for_cpu_option (const char *target
,
355 const cpu_option
*list
)
357 auto_vec
<const char*> candidates
;
358 for (; list
->common
.name
!= NULL
; list
++)
360 candidates
.safe_push (list
->common
.name
);
363 for (const cpu_alias
*alias
= list
->aliases
; alias
->name
!= NULL
;
366 candidates
.safe_push (alias
->name
);
370 #ifdef HAVE_LOCAL_CPU_DETECT
371 /* Add also "native" as possible value. */
372 candidates
.safe_push ("native");
376 const char *hint
= candidates_list_and_hint (target
, s
, candidates
);
378 inform (input_location
, "valid arguments are: %s; did you mean %qs?",
381 inform (input_location
, "valid arguments are: %s", s
);
386 /* Parse the base component of a CPU selection in LIST. Return a
387 pointer to the entry in the architecture table. OPTNAME is the
388 name of the option we are parsing and can be used if a diagnostic
389 is needed. If COMPLAIN is true (the default) emit error
390 messages and hints on invalid input. */
392 arm_parse_cpu_option_name (const cpu_option
*list
, const char *optname
,
393 const char *target
, bool complain
)
395 const cpu_option
*entry
;
396 const char *end
= strchr (target
, '+');
397 size_t len
= end
? end
- target
: strlen (target
);
399 for (entry
= list
; entry
->common
.name
!= NULL
; entry
++)
401 if (strncmp (entry
->common
.name
, target
, len
) == 0
402 && entry
->common
.name
[len
] == '\0')
405 /* Match against any legal alias for this CPU candidate. */
408 for (const cpu_alias
*alias
= entry
->aliases
; alias
->name
!= NULL
;
410 if (strncmp (alias
->name
, target
, len
) == 0
411 && alias
->name
[len
] == '\0')
418 error_at (input_location
, "unrecognized %s target: %s", optname
, target
);
419 arm_print_hint_for_cpu_option (target
, list
);
424 /* List the permitted architecture option names. If TARGET is a near
425 miss for an entry, print out the suggested alternative. */
427 arm_print_hint_for_arch_option (const char *target
,
428 const arch_option
*list
)
430 auto_vec
<const char*> candidates
;
431 for (; list
->common
.name
!= NULL
; list
++)
432 candidates
.safe_push (list
->common
.name
);
434 #ifdef HAVE_LOCAL_CPU_DETECT
435 /* Add also "native" as possible value. */
436 candidates
.safe_push ("native");
440 const char *hint
= candidates_list_and_hint (target
, s
, candidates
);
442 inform (input_location
, "valid arguments are: %s; did you mean %qs?",
445 inform (input_location
, "valid arguments are: %s", s
);
450 /* Parse the base component of a CPU or architecture selection in
451 LIST. Return a pointer to the entry in the architecture table.
452 OPTNAME is the name of the option we are parsing and can be used if
453 a diagnostic is needed. If COMPLAIN is true (the default) emit error
454 messages and hints on invalid input. */
456 arm_parse_arch_option_name (const arch_option
*list
, const char *optname
,
457 const char *target
, bool complain
)
459 const arch_option
*entry
;
460 const char *end
= strchr (target
, '+');
461 size_t len
= end
? end
- target
: strlen (target
);
463 for (entry
= list
; entry
->common
.name
!= NULL
; entry
++)
465 if (strncmp (entry
->common
.name
, target
, len
) == 0
466 && entry
->common
.name
[len
] == '\0')
472 error_at (input_location
, "unrecognized %s target: %s", optname
, target
);
473 arm_print_hint_for_arch_option (target
, list
);
478 /* List the permitted architecture option names. If TARGET is a near
479 miss for an entry, print out the suggested alternative. */
481 arm_print_hint_for_fpu_option (const char *target
)
483 auto_vec
<const char*> candidates
;
484 for (int i
= 0; i
< TARGET_FPU_auto
; i
++)
485 candidates
.safe_push (all_fpus
[i
].name
);
487 const char *hint
= candidates_list_and_hint (target
, s
, candidates
);
489 inform (input_location
, "valid arguments are: %s; did you mean %qs?",
492 inform (input_location
, "valid arguments are: %s", s
);
497 static const arm_fpu_desc
*
498 arm_parse_fpu_option (const char *opt
)
502 for (i
= 0; i
< TARGET_FPU_auto
; i
++)
504 if (strcmp (all_fpus
[i
].name
, opt
) == 0)
508 error_at (input_location
, "unrecognized %<-mfpu%> target: %s", opt
);
509 arm_print_hint_for_fpu_option (opt
);
513 /* Convert a static initializer array of feature bits to sbitmap
516 arm_initialize_isa (sbitmap isa
, const enum isa_feature
*isa_bits
)
519 while (*isa_bits
!= isa_nobit
)
520 bitmap_set_bit (isa
, *(isa_bits
++));
523 /* OPT isn't a recognized feature. Print a suitable error message and
524 suggest a possible value. Always print the list of permitted
527 arm_unrecognized_feature (const char *opt
, size_t len
,
528 const cpu_arch_option
*target
)
530 char *this_opt
= XALLOCAVEC (char, len
+1);
531 auto_vec
<const char*> candidates
;
533 strncpy (this_opt
, opt
, len
);
536 error_at (input_location
, "%qs does not support feature %qs", target
->name
,
538 for (const cpu_arch_extension
*list
= target
->extensions
;
541 candidates
.safe_push (list
->name
);
544 const char *hint
= candidates_list_and_hint (this_opt
, s
, candidates
);
547 inform (input_location
, "valid feature names are: %s; did you mean %qs?",
550 inform (input_location
, "valid feature names are: %s", s
);
555 /* Parse any feature extensions to add to (or remove from) the
556 permitted ISA selection. */
558 arm_parse_option_features (sbitmap isa
, const cpu_arch_option
*target
,
561 const char *opts
= opts_in
;
566 if (!target
->extensions
)
568 error_at (input_location
, "%s does not take any feature options",
575 gcc_assert (*opts
== '+');
576 const struct cpu_arch_extension
*entry
;
577 const char *end
= strchr (++opts
, '+');
578 size_t len
= end
? end
- opts
: strlen (opts
);
579 bool matched
= false;
581 for (entry
= target
->extensions
;
582 !matched
&& entry
->name
!= NULL
;
585 if (strncmp (entry
->name
, opts
, len
) == 0
586 && entry
->name
[len
] == '\0')
590 const enum isa_feature
*f
= entry
->isa_bits
;
593 while (*f
!= isa_nobit
)
594 bitmap_clear_bit (isa
, *(f
++));
598 while (*f
!= isa_nobit
)
599 bitmap_set_bit (isa
, *(f
++));
607 arm_unrecognized_feature (opts
, len
, target
);
613 class candidate_extension
616 const cpu_arch_extension
*extension
;
620 candidate_extension (const cpu_arch_extension
*ext
, sbitmap bits
)
621 : extension (ext
), isa_bits (bits
), required (true)
623 ~candidate_extension ()
625 sbitmap_free (isa_bits
);
629 /* Generate a canonical representation of the -march option from the
630 current -march string (if given) and other options on the command
631 line that might affect the architecture. This aids multilib selection
633 a) the option is always present
634 b) only the minimal set of options are used
635 c) when there are multiple extensions, they are in a consistent order.
637 The options array consists of couplets of information where the
638 first item in each couplet is the string describing which option
639 name was selected (arch, cpu, fpu) and the second is the value
640 passed for that option.
642 arch_for_multilib is boolean variable taking value true or false.
643 arch_for_multilib is false when the canonical representation is for -march
644 option and it is true when canonical representation is for -mlibarch option.
645 On passing arch_for_multilib true the canonical string generated will be
646 without the compiler options which are not required for multilib linking. */
648 arm_canon_arch_option_1 (int argc
, const char **argv
, bool arch_for_multilib
)
650 const char *arch
= NULL
;
651 const char *cpu
= NULL
;
652 const char *fpu
= NULL
;
653 const char *abi
= NULL
;
654 static char *canonical_arch
= NULL
;
656 /* Just in case we're called more than once. */
659 free (canonical_arch
);
660 canonical_arch
= NULL
;
664 fatal_error (input_location
,
665 "%%:%<canon_for_mlib%> takes 1 or more pairs of parameters");
669 if (strcmp (argv
[0], "arch") == 0)
671 else if (strcmp (argv
[0], "cpu") == 0)
673 else if (strcmp (argv
[0], "fpu") == 0)
675 else if (strcmp (argv
[0], "abi") == 0)
678 fatal_error (input_location
,
679 "unrecognized operand to %%:%<canon_for_mlib%>");
685 auto_sbitmap
target_isa (isa_num_bits
);
686 auto_sbitmap
base_isa (isa_num_bits
);
687 auto_sbitmap
fpu_isa (isa_num_bits
);
689 bitmap_clear (fpu_isa
);
691 const arch_option
*selected_arch
= NULL
;
693 /* At least one of these must be defined by either the specs or the
695 gcc_assert (cpu
|| arch
);
702 if (TARGET_DEFAULT_FLOAT_ABI
== ARM_FLOAT_ABI_SOFT
)
704 else if (TARGET_DEFAULT_FLOAT_ABI
== ARM_FLOAT_ABI_SOFTFP
)
706 else if (TARGET_DEFAULT_FLOAT_ABI
== ARM_FLOAT_ABI_HARD
)
710 /* First build up a bitmap describing the target architecture. */
713 selected_arch
= arm_parse_arch_option_name (all_architectures
, "-march",
714 arch
, !arch_for_multilib
);
716 if (selected_arch
== NULL
)
719 arm_initialize_isa (target_isa
, selected_arch
->common
.isa_bits
);
720 arm_parse_option_features (target_isa
, &selected_arch
->common
,
722 if (arch_for_multilib
)
724 const enum isa_feature removable_bits
[] = {ISA_IGNORE_FOR_MULTILIB
,
726 sbitmap isa_bits
= sbitmap_alloc (isa_num_bits
);
727 arm_initialize_isa (isa_bits
, removable_bits
);
728 bitmap_and_compl (target_isa
, target_isa
, isa_bits
);
731 if (fpu
&& strcmp (fpu
, "auto") != 0)
733 /* We assume that architectures do not have any FPU bits
734 enabled by default. If they did, we would need to strip
736 const arm_fpu_desc
*target_fpu
= arm_parse_fpu_option (fpu
);
737 if (target_fpu
== NULL
)
740 arm_initialize_isa (fpu_isa
, target_fpu
->isa_bits
);
741 bitmap_ior (target_isa
, target_isa
, fpu_isa
);
746 const cpu_option
*selected_cpu
747 = arm_parse_cpu_option_name (all_cores
, "-mcpu", cpu
,
750 if (selected_cpu
== NULL
)
753 arm_initialize_isa (target_isa
, selected_cpu
->common
.isa_bits
);
754 arm_parse_option_features (target_isa
, &selected_cpu
->common
,
756 if (fpu
&& strcmp (fpu
, "auto") != 0)
758 /* The easiest and safest way to remove the default fpu
759 capabilities is to look for a '+no..' option that removes
760 the base FPU bit (isa_bit_vfpv2). If that doesn't exist
761 then the best we can do is strip out all the bits that
762 might be part of the most capable FPU we know about,
763 which is "crypto-neon-fp-armv8". */
764 bool default_fpu_found
= false;
765 if (selected_cpu
->common
.extensions
)
767 const cpu_arch_extension
*ext
;
768 for (ext
= selected_cpu
->common
.extensions
; ext
->name
!= NULL
;
772 && check_isa_bits_for (ext
->isa_bits
, isa_bit_vfpv2
))
774 arm_initialize_isa (fpu_isa
, ext
->isa_bits
);
775 bitmap_and_compl (target_isa
, target_isa
, fpu_isa
);
776 default_fpu_found
= true;
782 if (!default_fpu_found
)
786 all_fpus
[TARGET_FPU_crypto_neon_fp_armv8
].isa_bits
);
787 bitmap_and_compl (target_isa
, target_isa
, fpu_isa
);
790 const arm_fpu_desc
*target_fpu
= arm_parse_fpu_option (fpu
);
791 if (target_fpu
== NULL
)
794 arm_initialize_isa (fpu_isa
, target_fpu
->isa_bits
);
795 bitmap_ior (target_isa
, target_isa
, fpu_isa
);
798 selected_arch
= all_architectures
+ selected_cpu
->arch
;
801 /* If we have a soft-float ABI, disable the FPU. */
802 if (abi
&& strcmp (abi
, "soft") == 0)
804 /* Clearing the VFPv2 bit is sufficient to stop any extention that
805 builds on the FPU from matching. */
806 bitmap_clear_bit (target_isa
, isa_bit_vfpv2
);
809 /* If we don't have a selected architecture by now, something's
811 gcc_assert (selected_arch
);
813 arm_initialize_isa (base_isa
, selected_arch
->common
.isa_bits
);
815 /* Architecture has no extension options, so just return the canonical
816 architecture name. */
817 if (selected_arch
->common
.extensions
== NULL
)
818 return selected_arch
->common
.name
;
820 /* We're only interested in extension bits. */
821 bitmap_and_compl (target_isa
, target_isa
, base_isa
);
823 /* There are no extensions needed. Just return the canonical architecture
825 if (bitmap_empty_p (target_isa
))
826 return selected_arch
->common
.name
;
828 /* What is left is the architecture that the compiler will target. We
829 now need to map that back into a suitable option+features list.
831 The list is built in two passes. First we scan every additive
832 option feature supported by the architecture. If the option
833 provides a subset of the features we need we add it to the list
834 of candidates. We then scan backwards over the list of
835 candidates and if we find a feature that adds nothing to one that
836 was later in the list we mark it as redundant. The result is a
837 minimal list of required features for the target
840 std::list
<candidate_extension
*> extensions
;
842 auto_sbitmap
target_isa_unsatisfied (isa_num_bits
);
843 bitmap_copy (target_isa_unsatisfied
, target_isa
);
845 sbitmap isa_bits
= NULL
;
846 for (const cpu_arch_extension
*cand
= selected_arch
->common
.extensions
;
850 if (cand
->remove
|| cand
->alias
)
853 if (isa_bits
== NULL
)
854 isa_bits
= sbitmap_alloc (isa_num_bits
);
856 arm_initialize_isa (isa_bits
, cand
->isa_bits
);
857 if (bitmap_subset_p (isa_bits
, target_isa
))
859 extensions
.push_back (new candidate_extension (cand
, isa_bits
));
860 bitmap_and_compl (target_isa_unsatisfied
, target_isa_unsatisfied
,
866 /* There's one extra case to consider, which is that the user has
867 specified an FPU that is less capable than this architecture
868 supports. In that case the code above will fail to find a
869 suitable feature. We handle this by scanning the list of options
870 again, matching the first option that provides an FPU that is
871 more capable than the selected FPU.
873 Note that the other case (user specified a more capable FPU than
874 this architecture supports) should end up selecting the most
875 capable FPU variant that we do support. This is sufficient for
876 multilib selection. */
878 if (bitmap_bit_p (target_isa_unsatisfied
, isa_bit_vfpv2
)
879 && bitmap_bit_p (fpu_isa
, isa_bit_vfpv2
))
881 std::list
<candidate_extension
*>::iterator ipoint
= extensions
.begin ();
883 for (const cpu_arch_extension
*cand
= selected_arch
->common
.extensions
;
887 if (cand
->remove
|| cand
->alias
)
890 if (isa_bits
== NULL
)
891 isa_bits
= sbitmap_alloc (isa_num_bits
);
893 /* We need to keep the features in canonical order, so move the
894 insertion point if this feature is a candidate. */
895 if (ipoint
!= extensions
.end ()
896 && (*ipoint
)->extension
== cand
)
899 arm_initialize_isa (isa_bits
, cand
->isa_bits
);
900 if (bitmap_subset_p (fpu_isa
, isa_bits
))
902 extensions
.insert (ipoint
,
903 new candidate_extension (cand
, isa_bits
));
911 sbitmap_free (isa_bits
);
913 bitmap_clear (target_isa
);
915 for (std::list
<candidate_extension
*>::reverse_iterator riter
916 = extensions
.rbegin ();
917 riter
!= extensions
.rend (); ++riter
)
919 if (bitmap_subset_p ((*riter
)->isa_bits
, target_isa
))
920 (*riter
)->required
= false;
923 bitmap_ior (target_isa
, target_isa
, (*riter
)->isa_bits
);
924 len
+= strlen ((*riter
)->extension
->name
) + 1;
929 = (char *) xmalloc (len
+ strlen (selected_arch
->common
.name
));
931 strcpy (canonical_arch
, selected_arch
->common
.name
);
933 for (std::list
<candidate_extension
*>::iterator iter
= extensions
.begin ();
934 iter
!= extensions
.end (); ++iter
)
936 if ((*iter
)->required
)
938 strcat (canonical_arch
, "+");
939 strcat (canonical_arch
, (*iter
)->extension
->name
);
944 return canonical_arch
;
947 /* If building big-endian on a BE8 target generate a --be8 option for
948 the linker. Takes four types of option: "little" - little-endian;
949 "big" - big-endian; "be8" - force be8 iff big-endian; and "arch"
950 "<arch-name>" (two arguments) - the target architecture. The
951 parameter names are generated by the driver from the command-line
954 arm_be8_option (int argc
, const char **argv
)
956 int endian
= TARGET_ENDIAN_DEFAULT
;
957 const char *arch
= NULL
;
961 for (arg
= 0; arg
< argc
; arg
++)
963 if (strcmp (argv
[arg
], "little") == 0)
965 else if (strcmp (argv
[arg
], "big") == 0)
967 else if (strcmp (argv
[arg
], "be8") == 0)
969 else if (strcmp (argv
[arg
], "arch") == 0)
972 gcc_assert (arg
< argc
);
979 /* Little endian - no be8 option. */
986 /* Arch might not be set iff arm_canon_arch (above) detected an
987 error. Do nothing in that case. */
991 const arch_option
*selected_arch
992 = arm_parse_arch_option_name (all_architectures
, "-march", arch
);
994 /* Similarly if the given arch option was itself invalid. */
998 if (check_isa_bits_for (selected_arch
->common
.isa_bits
, isa_bit_be8
))
1004 /* Generate a -mfpu= option for passing to the assembler. This is
1005 only called when -mfpu was set (possibly defaulted) to auto and is
1006 needed to ensure that the assembler knows the correct FPU to use.
1007 It wouldn't really be needed except that the compiler can be used
1008 to invoke the assembler directly on hand-written files that lack
1009 the necessary internal .fpu directives. We assume that the architecture
1010 canonicalization calls have already been made so that we have a final
1011 -march= option to derive the fpu from. */
1013 arm_asm_auto_mfpu (int argc
, const char **argv
)
1015 static char *auto_fpu
= NULL
;
1016 const char *arch
= NULL
;
1017 static const enum isa_feature fpu_bitlist
[]
1018 = { ISA_ALL_FPU_INTERNAL
, isa_nobit
};
1019 const arch_option
*selected_arch
;
1020 static const char* fpuname
= "softvfp";
1022 /* Handle multiple calls to this routine. */
1031 if (strcmp (argv
[0], "arch") == 0)
1034 fatal_error (input_location
,
1035 "unrecognized operand to %%:%<asm_auto_mfpu%>");
1040 auto_sbitmap
target_isa (isa_num_bits
);
1041 auto_sbitmap
fpubits (isa_num_bits
);
1043 gcc_assert (arch
!= NULL
);
1044 selected_arch
= arm_parse_arch_option_name (all_architectures
,
1046 if (selected_arch
== NULL
)
1049 arm_initialize_isa (target_isa
, selected_arch
->common
.isa_bits
);
1050 arm_parse_option_features (target_isa
, &selected_arch
->common
,
1051 strchr (arch
, '+'));
1052 arm_initialize_isa (fpubits
, fpu_bitlist
);
1054 bitmap_and (fpubits
, fpubits
, target_isa
);
1056 /* The logic below is essentially identical to that in
1057 arm.cc:arm_identify_fpu_from_isa(), but that only works in the main
1058 part of the compiler. */
1060 /* If there are no FPU capability bits, we just pass -mfpu=softvfp. */
1061 if (!bitmap_empty_p (fpubits
))
1064 auto_sbitmap
cand_fpubits (isa_num_bits
);
1065 for (i
= 0; i
< TARGET_FPU_auto
; i
++)
1067 arm_initialize_isa (cand_fpubits
, all_fpus
[i
].isa_bits
);
1068 if (bitmap_equal_p (fpubits
, cand_fpubits
))
1070 fpuname
= all_fpus
[i
].name
;
1075 gcc_assert (i
!= TARGET_FPU_auto
1076 || bitmap_bit_p (target_isa
, isa_bit_vfp_base
));
1079 auto_fpu
= (char *) xmalloc (strlen (fpuname
) + sizeof ("-mfpu="));
1080 strcpy (auto_fpu
, "-mfpu=");
1081 strcat (auto_fpu
, fpuname
);
1085 #undef ARM_CPU_NAME_LENGTH
1088 #undef TARGET_DEFAULT_TARGET_FLAGS
1089 #define TARGET_DEFAULT_TARGET_FLAGS (TARGET_DEFAULT | MASK_SCHED_PROLOG)
1091 #undef TARGET_OPTION_OPTIMIZATION_TABLE
1092 #define TARGET_OPTION_OPTIMIZATION_TABLE arm_option_optimization_table
1094 #undef TARGET_EXCEPT_UNWIND_INFO
1095 #define TARGET_EXCEPT_UNWIND_INFO arm_except_unwind_info
1097 struct gcc_targetm_common targetm_common
= TARGETM_COMMON_INITIALIZER
;
1099 /* Returns a canonical representation of the -march option from the current
1100 -march string (if given) and other options on the command line that might
1101 affect the architecture. */
1103 arm_canon_arch_option (int argc
, const char **argv
)
1105 return arm_canon_arch_option_1 (argc
, argv
, false);
1108 /* Returns a canonical representation of the -mlibarch option from the current
1109 -march string (if given) and other options on the command line that might
1110 affect the architecture after removing the compiler extension options which
1111 are not required for multilib linking. */
1113 arm_canon_arch_multilib_option (int argc
, const char **argv
)
1115 return arm_canon_arch_option_1 (argc
, argv
, true);