1 /* Common hooks for ARM.
2 Copyright (C) 1991-2018 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
24 #include "coretypes.h"
28 #include "common/common-target.h"
29 #include "common/common-target-def.h"
33 #include "diagnostic.h"
36 /* Set default optimization options. */
37 static const struct default_options arm_option_optimization_table
[] =
39 /* Enable section anchors by default at -O1 or higher. */
40 { OPT_LEVELS_1_PLUS
, OPT_fsection_anchors
, NULL
, 1 },
41 { OPT_LEVELS_1_PLUS
, OPT_fsched_pressure
, NULL
, 1 },
42 { OPT_LEVELS_NONE
, 0, NULL
, 0 }
45 /* Implement TARGET_EXCEPT_UNWIND_INFO. */
48 arm_except_unwind_info (struct gcc_options
*opts
)
50 /* Honor the --enable-sjlj-exceptions configure switch. */
51 #ifdef CONFIG_SJLJ_EXCEPTIONS
52 if (CONFIG_SJLJ_EXCEPTIONS
)
56 /* If not using ARM EABI unwind tables... */
59 /* For simplicity elsewhere in this file, indicate that all unwind
60 info is disabled if we're not emitting unwind tables. */
61 if (!opts
->x_flag_exceptions
&& !opts
->x_flag_unwind_tables
)
67 /* ... honor target configurations requesting DWARF2 EH... */
68 #ifdef DWARF2_UNWIND_INFO
69 if (DWARF2_UNWIND_INFO
)
73 /* ... or fallback to sjlj exceptions for backwards compatibility. */
77 #define ARM_CPU_NAME_LENGTH 20
79 /* Truncate NAME at the first '.' or '+' character seen, or return
83 arm_rewrite_selected_cpu (const char *name
)
85 static char output_buf
[ARM_CPU_NAME_LENGTH
+ 1] = {0};
88 strncpy (output_buf
, name
, ARM_CPU_NAME_LENGTH
);
89 output_buf
[ARM_CPU_NAME_LENGTH
] = 0;
91 arg_pos
= strchr (output_buf
, '.');
93 /* If we found a '.' truncate the entry at that point. */
97 arg_pos
= strchr (output_buf
, '+');
99 /* If we found a '+' truncate the entry at that point. */
106 /* Called by the driver to rewrite a name passed to the -mcpu
107 argument in preparation to be passed to the assembler. The
108 names passed from the command line will be in ARGV, we want
109 to use the right-most argument, which should be in
110 ARGV[ARGC - 1]. ARGC should always be greater than 0. */
113 arm_rewrite_mcpu (int argc
, const char **argv
)
116 return arm_rewrite_selected_cpu (argv
[argc
- 1]);
119 /* Comparator for arm_rewrite_selected_arch. Compare the two arch extension
120 strings FIRST and SECOND and return TRUE if FIRST is less than SECOND
124 compare_opt_names (const char *first
, const char *second
)
126 return strcmp (first
, second
) <= 0;
129 /* Rewrite the architecture string for passing to the assembler.
130 Although the syntax is similar we cannot assume that it supports
131 the newer FP related options. So strip any option that only
132 defines features in the standard -mfpu options out. We'll generate
133 a suitable -mfpu option elsewhere to carry that information. NAME
134 should already have been canonicalized, so we do not expect to
135 encounter +no.. options that remove features. A final problem is
136 that the assembler expects the feature extensions to be listed
137 alphabetically, so we build a list of required options and then
138 sort them into canonical order in the resulting string. */
140 arm_rewrite_selected_arch (const char *name
)
142 /* The result we return needs to be semi persistent, so handle being
144 static char *asm_arch
= NULL
;
152 const char *arg_pos
= strchr (name
, '+');
154 /* No extension options? just return the original string. */
158 const arch_option
*arch_opt
159 = arm_parse_arch_option_name (all_architectures
, "-march", name
);
161 auto_sbitmap
fpu_bits (isa_num_bits
);
162 static const enum isa_feature fpu_bitlist
[]
163 = { ISA_ALL_FPU_INTERNAL
, isa_nobit
};
165 arm_initialize_isa (fpu_bits
, fpu_bitlist
);
167 auto_sbitmap
opt_bits (isa_num_bits
);
169 /* Ensure that the resulting string is large enough for the result. We
170 never add options, so using strdup here will ensure that. */
171 asm_arch
= xstrdup (name
);
172 asm_arch
[arg_pos
- name
] = '\0';
174 std::vector
<const char *>optlist
;
178 const char *end
= strchr (arg_pos
+ 1, '+');
179 size_t len
= end
? end
- arg_pos
: strlen (arg_pos
);
181 for (const cpu_arch_extension
*entry
= arch_opt
->common
.extensions
;
185 if (strncmp (entry
->name
, arg_pos
+ 1, len
- 1) == 0
186 && entry
->name
[len
- 1] == '\0')
188 /* Don't expect removal options. */
189 gcc_assert (!entry
->remove
);
190 arm_initialize_isa (opt_bits
, entry
->isa_bits
);
191 if (!bitmap_subset_p (opt_bits
, fpu_bits
))
192 optlist
.push_back (entry
->name
);
193 bitmap_clear (opt_bits
);
201 std::sort (optlist
.begin (), optlist
.end (), compare_opt_names
);
203 for (std::vector
<const char *>::iterator opt_iter
= optlist
.begin ();
204 opt_iter
!= optlist
.end ();
207 strcat (asm_arch
, "+");
208 strcat (asm_arch
, (*opt_iter
));
214 /* Called by the driver to rewrite a name passed to the -march
215 argument in preparation to be passed to the assembler. The
216 names passed from the command line will be in ARGV, we want
217 to use the right-most argument, which should be in
218 ARGV[ARGC - 1]. ARGC should always be greater than 0. */
221 arm_rewrite_march (int argc
, const char **argv
)
224 return arm_rewrite_selected_arch (argv
[argc
- 1]);
227 #include "arm-cpu-cdata.h"
229 /* Scan over a raw feature array BITS checking for BIT being present.
230 This is slower than the normal bitmask checks, but we would spend longer
231 initializing that than doing the check this way. Returns true iff
234 check_isa_bits_for (const enum isa_feature
* bits
, enum isa_feature bit
)
236 while (*bits
!= isa_nobit
)
243 /* Called by the driver to check whether the target denoted by current
244 command line options is a Thumb-only target. ARGV is an array of
245 tupples (normally only one) where the first element of the tupple
246 is 'cpu' or 'arch' and the second is the option passed to the
247 compiler for that. An architecture tupple is always taken in
248 preference to a cpu tupple and the last of each type always
249 overrides any earlier setting. */
252 arm_target_thumb_only (int argc
, const char **argv
)
254 const char *arch
= NULL
;
255 const char *cpu
= NULL
;
258 fatal_error (input_location
,
259 "%%:target_mode_check takes an even number of parameters");
263 if (strcmp (argv
[0], "arch") == 0)
265 else if (strcmp (argv
[0], "cpu") == 0)
268 fatal_error (input_location
,
269 "unrecognized option passed to %%:target_mode_check");
274 /* No architecture, or CPU, has option extensions that change
275 whether or not we have a Thumb-only device, so there is no need
276 to scan any option extensions specified. */
278 /* If the architecture is specified, that overrides any CPU setting. */
281 const arch_option
*arch_opt
282 = arm_parse_arch_option_name (all_architectures
, "-march", arch
,
285 if (arch_opt
&& !check_isa_bits_for (arch_opt
->common
.isa_bits
,
291 const cpu_option
*cpu_opt
292 = arm_parse_cpu_option_name (all_cores
, "-mcpu", cpu
, false);
294 if (cpu_opt
&& !check_isa_bits_for (cpu_opt
->common
.isa_bits
,
299 /* Compiler hasn't been configured with a default, and the CPU
300 doesn't require Thumb, so default to ARM. */
304 /* List the permitted CPU option names. If TARGET is a near miss for an
305 entry, print out the suggested alternative. */
307 arm_print_hint_for_cpu_option (const char *target
,
308 const cpu_option
*list
)
310 auto_vec
<const char*> candidates
;
311 for (; list
->common
.name
!= NULL
; list
++)
312 candidates
.safe_push (list
->common
.name
);
314 #ifdef HAVE_LOCAL_CPU_DETECT
315 /* Add also "native" as possible value. */
316 candidates
.safe_push ("native");
320 const char *hint
= candidates_list_and_hint (target
, s
, candidates
);
322 inform (input_location
, "valid arguments are: %s; did you mean %qs?",
325 inform (input_location
, "valid arguments are: %s", s
);
330 /* Parse the base component of a CPU selection in LIST. Return a
331 pointer to the entry in the architecture table. OPTNAME is the
332 name of the option we are parsing and can be used if a diagnostic
333 is needed. If COMPLAIN is true (the default) emit error
334 messages and hints on invalid input. */
336 arm_parse_cpu_option_name (const cpu_option
*list
, const char *optname
,
337 const char *target
, bool complain
)
339 const cpu_option
*entry
;
340 const char *end
= strchr (target
, '+');
341 size_t len
= end
? end
- target
: strlen (target
);
343 for (entry
= list
; entry
->common
.name
!= NULL
; entry
++)
345 if (strncmp (entry
->common
.name
, target
, len
) == 0
346 && entry
->common
.name
[len
] == '\0')
352 error_at (input_location
, "unrecognized %s target: %s", optname
, target
);
353 arm_print_hint_for_cpu_option (target
, list
);
358 /* List the permitted architecture option names. If TARGET is a near
359 miss for an entry, print out the suggested alternative. */
361 arm_print_hint_for_arch_option (const char *target
,
362 const arch_option
*list
)
364 auto_vec
<const char*> candidates
;
365 for (; list
->common
.name
!= NULL
; list
++)
366 candidates
.safe_push (list
->common
.name
);
368 #ifdef HAVE_LOCAL_CPU_DETECT
369 /* Add also "native" as possible value. */
370 candidates
.safe_push ("native");
374 const char *hint
= candidates_list_and_hint (target
, s
, candidates
);
376 inform (input_location
, "valid arguments are: %s; did you mean %qs?",
379 inform (input_location
, "valid arguments are: %s", s
);
384 /* Parse the base component of a CPU or architecture selection in
385 LIST. Return a pointer to the entry in the architecture table.
386 OPTNAME is the name of the option we are parsing and can be used if
387 a diagnostic is needed. If COMPLAIN is true (the default) emit error
388 messages and hints on invalid input. */
390 arm_parse_arch_option_name (const arch_option
*list
, const char *optname
,
391 const char *target
, bool complain
)
393 const arch_option
*entry
;
394 const char *end
= strchr (target
, '+');
395 size_t len
= end
? end
- target
: strlen (target
);
397 for (entry
= list
; entry
->common
.name
!= NULL
; entry
++)
399 if (strncmp (entry
->common
.name
, target
, len
) == 0
400 && entry
->common
.name
[len
] == '\0')
406 error_at (input_location
, "unrecognized %s target: %s", optname
, target
);
407 arm_print_hint_for_arch_option (target
, list
);
412 /* List the permitted architecture option names. If TARGET is a near
413 miss for an entry, print out the suggested alternative. */
415 arm_print_hint_for_fpu_option (const char *target
)
417 auto_vec
<const char*> candidates
;
418 for (int i
= 0; i
< TARGET_FPU_auto
; i
++)
419 candidates
.safe_push (all_fpus
[i
].name
);
421 const char *hint
= candidates_list_and_hint (target
, s
, candidates
);
423 inform (input_location
, "valid arguments are: %s; did you mean %qs?",
426 inform (input_location
, "valid arguments are: %s", s
);
431 static const arm_fpu_desc
*
432 arm_parse_fpu_option (const char *opt
)
436 for (i
= 0; i
< TARGET_FPU_auto
; i
++)
438 if (strcmp (all_fpus
[i
].name
, opt
) == 0)
442 error_at (input_location
, "unrecognized -mfpu target: %s", opt
);
443 arm_print_hint_for_fpu_option (opt
);
447 /* Convert a static initializer array of feature bits to sbitmap
450 arm_initialize_isa (sbitmap isa
, const enum isa_feature
*isa_bits
)
453 while (*isa_bits
!= isa_nobit
)
454 bitmap_set_bit (isa
, *(isa_bits
++));
457 /* OPT isn't a recognized feature. Print a suitable error message and
458 suggest a possible value. Always print the list of permitted
461 arm_unrecognized_feature (const char *opt
, size_t len
,
462 const cpu_arch_option
*target
)
464 char *this_opt
= XALLOCAVEC (char, len
+1);
465 auto_vec
<const char*> candidates
;
467 strncpy (this_opt
, opt
, len
);
470 error_at (input_location
, "%qs does not support feature %qs", target
->name
,
472 for (const cpu_arch_extension
*list
= target
->extensions
;
475 candidates
.safe_push (list
->name
);
478 const char *hint
= candidates_list_and_hint (this_opt
, s
, candidates
);
481 inform (input_location
, "valid feature names are: %s; did you mean %qs?",
484 inform (input_location
, "valid feature names are: %s", s
);
489 /* Parse any feature extensions to add to (or remove from) the
490 permitted ISA selection. */
492 arm_parse_option_features (sbitmap isa
, const cpu_arch_option
*target
,
495 const char *opts
= opts_in
;
500 if (!target
->extensions
)
502 error_at (input_location
, "%s does not take any feature options",
509 gcc_assert (*opts
== '+');
510 const struct cpu_arch_extension
*entry
;
511 const char *end
= strchr (++opts
, '+');
512 size_t len
= end
? end
- opts
: strlen (opts
);
513 bool matched
= false;
515 for (entry
= target
->extensions
;
516 !matched
&& entry
->name
!= NULL
;
519 if (strncmp (entry
->name
, opts
, len
) == 0
520 && entry
->name
[len
] == '\0')
524 const enum isa_feature
*f
= entry
->isa_bits
;
527 while (*f
!= isa_nobit
)
528 bitmap_clear_bit (isa
, *(f
++));
532 while (*f
!= isa_nobit
)
533 bitmap_set_bit (isa
, *(f
++));
541 arm_unrecognized_feature (opts
, len
, target
);
547 class candidate_extension
550 const cpu_arch_extension
*extension
;
554 candidate_extension (const cpu_arch_extension
*ext
, sbitmap bits
)
555 : extension (ext
), isa_bits (bits
), required (true)
557 ~candidate_extension ()
559 sbitmap_free (isa_bits
);
563 /* Generate a canonical representation of the -march option from the
564 current -march string (if given) and other options on the command
565 line that might affect the architecture. This aids multilib selection
567 a) the option is always present
568 b) only the minimal set of options are used
569 c) when there are multiple extensions, they are in a consistent order.
571 The options array consists of couplets of information where the
572 first item in each couplet is the string describing which option
573 name was selected (arch, cpu, fpu) and the second is the value
574 passed for that option. */
576 arm_canon_arch_option (int argc
, const char **argv
)
578 const char *arch
= NULL
;
579 const char *cpu
= NULL
;
580 const char *fpu
= NULL
;
581 const char *abi
= NULL
;
582 static char *canonical_arch
= NULL
;
584 /* Just in case we're called more than once. */
587 free (canonical_arch
);
588 canonical_arch
= NULL
;
592 fatal_error (input_location
,
593 "%%:canon_for_mlib takes 1 or more pairs of parameters");
597 if (strcmp (argv
[0], "arch") == 0)
599 else if (strcmp (argv
[0], "cpu") == 0)
601 else if (strcmp (argv
[0], "fpu") == 0)
603 else if (strcmp (argv
[0], "abi") == 0)
606 fatal_error (input_location
,
607 "unrecognized operand to %%:canon_for_mlib");
613 auto_sbitmap
target_isa (isa_num_bits
);
614 auto_sbitmap
base_isa (isa_num_bits
);
615 auto_sbitmap
fpu_isa (isa_num_bits
);
617 bitmap_clear (fpu_isa
);
619 const arch_option
*selected_arch
= NULL
;
621 /* At least one of these must be defined by either the specs or the
623 gcc_assert (cpu
|| arch
);
630 if (TARGET_DEFAULT_FLOAT_ABI
== ARM_FLOAT_ABI_SOFT
)
632 else if (TARGET_DEFAULT_FLOAT_ABI
== ARM_FLOAT_ABI_SOFTFP
)
634 else if (TARGET_DEFAULT_FLOAT_ABI
== ARM_FLOAT_ABI_HARD
)
638 /* First build up a bitmap describing the target architecture. */
641 selected_arch
= arm_parse_arch_option_name (all_architectures
,
644 if (selected_arch
== NULL
)
647 arm_initialize_isa (target_isa
, selected_arch
->common
.isa_bits
);
648 arm_parse_option_features (target_isa
, &selected_arch
->common
,
650 if (fpu
&& strcmp (fpu
, "auto") != 0)
652 /* We assume that architectures do not have any FPU bits
653 enabled by default. If they did, we would need to strip
655 const arm_fpu_desc
*target_fpu
= arm_parse_fpu_option (fpu
);
656 if (target_fpu
== NULL
)
659 arm_initialize_isa (fpu_isa
, target_fpu
->isa_bits
);
660 bitmap_ior (target_isa
, target_isa
, fpu_isa
);
665 const cpu_option
*selected_cpu
666 = arm_parse_cpu_option_name (all_cores
, "-mcpu", cpu
);
668 if (selected_cpu
== NULL
)
671 arm_initialize_isa (target_isa
, selected_cpu
->common
.isa_bits
);
672 arm_parse_option_features (target_isa
, &selected_cpu
->common
,
674 if (fpu
&& strcmp (fpu
, "auto") != 0)
676 /* The easiest and safest way to remove the default fpu
677 capabilities is to look for a '+no..' option that removes
678 the base FPU bit (isa_bit_vfpv2). If that doesn't exist
679 then the best we can do is strip out all the bits that
680 might be part of the most capable FPU we know about,
681 which is "crypto-neon-fp-armv8". */
682 bool default_fpu_found
= false;
683 if (selected_cpu
->common
.extensions
)
685 const cpu_arch_extension
*ext
;
686 for (ext
= selected_cpu
->common
.extensions
; ext
->name
!= NULL
;
690 && check_isa_bits_for (ext
->isa_bits
, isa_bit_vfpv2
))
692 arm_initialize_isa (fpu_isa
, ext
->isa_bits
);
693 bitmap_and_compl (target_isa
, target_isa
, fpu_isa
);
694 default_fpu_found
= true;
700 if (!default_fpu_found
)
704 all_fpus
[TARGET_FPU_crypto_neon_fp_armv8
].isa_bits
);
705 bitmap_and_compl (target_isa
, target_isa
, fpu_isa
);
708 const arm_fpu_desc
*target_fpu
= arm_parse_fpu_option (fpu
);
709 if (target_fpu
== NULL
)
712 arm_initialize_isa (fpu_isa
, target_fpu
->isa_bits
);
713 bitmap_ior (target_isa
, target_isa
, fpu_isa
);
716 selected_arch
= all_architectures
+ selected_cpu
->arch
;
719 /* If we have a soft-float ABI, disable the FPU. */
720 if (abi
&& strcmp (abi
, "soft") == 0)
722 /* Clearing the VFPv2 bit is sufficient to stop any extention that
723 builds on the FPU from matching. */
724 bitmap_clear_bit (target_isa
, isa_bit_vfpv2
);
727 /* If we don't have a selected architecture by now, something's
729 gcc_assert (selected_arch
);
731 arm_initialize_isa (base_isa
, selected_arch
->common
.isa_bits
);
733 /* Architecture has no extension options, so just return the canonical
734 architecture name. */
735 if (selected_arch
->common
.extensions
== NULL
)
736 return selected_arch
->common
.name
;
738 /* We're only interested in extension bits. */
739 bitmap_and_compl (target_isa
, target_isa
, base_isa
);
741 /* There are no extensions needed. Just return the canonical architecture
743 if (bitmap_empty_p (target_isa
))
744 return selected_arch
->common
.name
;
746 /* What is left is the architecture that the compiler will target. We
747 now need to map that back into a suitable option+features list.
749 The list is built in two passes. First we scan every additive
750 option feature supported by the architecture. If the option
751 provides a subset of the features we need we add it to the list
752 of candidates. We then scan backwards over the list of
753 candidates and if we find a feature that adds nothing to one that
754 was later in the list we mark it as redundant. The result is a
755 minimal list of required features for the target
758 std::list
<candidate_extension
*> extensions
;
760 auto_sbitmap
target_isa_unsatisfied (isa_num_bits
);
761 bitmap_copy (target_isa_unsatisfied
, target_isa
);
763 sbitmap isa_bits
= NULL
;
764 for (const cpu_arch_extension
*cand
= selected_arch
->common
.extensions
;
768 if (cand
->remove
|| cand
->alias
)
771 if (isa_bits
== NULL
)
772 isa_bits
= sbitmap_alloc (isa_num_bits
);
774 arm_initialize_isa (isa_bits
, cand
->isa_bits
);
775 if (bitmap_subset_p (isa_bits
, target_isa
))
777 extensions
.push_back (new candidate_extension (cand
, isa_bits
));
778 bitmap_and_compl (target_isa_unsatisfied
, target_isa_unsatisfied
,
784 /* There's one extra case to consider, which is that the user has
785 specified an FPU that is less capable than this architecture
786 supports. In that case the code above will fail to find a
787 suitable feature. We handle this by scanning the list of options
788 again, matching the first option that provides an FPU that is
789 more capable than the selected FPU.
791 Note that the other case (user specified a more capable FPU than
792 this architecture supports) should end up selecting the most
793 capable FPU variant that we do support. This is sufficient for
794 multilib selection. */
796 if (bitmap_bit_p (target_isa_unsatisfied
, isa_bit_vfpv2
)
797 && bitmap_bit_p (fpu_isa
, isa_bit_vfpv2
))
799 std::list
<candidate_extension
*>::iterator ipoint
= extensions
.begin ();
801 for (const cpu_arch_extension
*cand
= selected_arch
->common
.extensions
;
805 if (cand
->remove
|| cand
->alias
)
808 if (isa_bits
== NULL
)
809 isa_bits
= sbitmap_alloc (isa_num_bits
);
811 /* We need to keep the features in canonical order, so move the
812 insertion point if this feature is a candidate. */
813 if (ipoint
!= extensions
.end ()
814 && (*ipoint
)->extension
== cand
)
817 arm_initialize_isa (isa_bits
, cand
->isa_bits
);
818 if (bitmap_subset_p (fpu_isa
, isa_bits
))
820 extensions
.insert (ipoint
,
821 new candidate_extension (cand
, isa_bits
));
829 sbitmap_free (isa_bits
);
831 bitmap_clear (target_isa
);
833 for (std::list
<candidate_extension
*>::reverse_iterator riter
834 = extensions
.rbegin ();
835 riter
!= extensions
.rend (); ++riter
)
837 if (bitmap_subset_p ((*riter
)->isa_bits
, target_isa
))
838 (*riter
)->required
= false;
841 bitmap_ior (target_isa
, target_isa
, (*riter
)->isa_bits
);
842 len
+= strlen ((*riter
)->extension
->name
) + 1;
847 = (char *) xmalloc (len
+ strlen (selected_arch
->common
.name
));
849 strcpy (canonical_arch
, selected_arch
->common
.name
);
851 for (std::list
<candidate_extension
*>::iterator iter
= extensions
.begin ();
852 iter
!= extensions
.end (); ++iter
)
854 if ((*iter
)->required
)
856 strcat (canonical_arch
, "+");
857 strcat (canonical_arch
, (*iter
)->extension
->name
);
862 return canonical_arch
;
865 /* If building big-endian on a BE8 target generate a --be8 option for
866 the linker. Takes four types of option: "little" - little-endian;
867 "big" - big-endian; "be8" - force be8 iff big-endian; and "arch"
868 "<arch-name>" (two arguments) - the target architecture. The
869 parameter names are generated by the driver from the command-line
872 arm_be8_option (int argc
, const char **argv
)
874 int endian
= TARGET_ENDIAN_DEFAULT
;
875 const char *arch
= NULL
;
879 for (arg
= 0; arg
< argc
; arg
++)
881 if (strcmp (argv
[arg
], "little") == 0)
883 else if (strcmp (argv
[arg
], "big") == 0)
885 else if (strcmp (argv
[arg
], "be8") == 0)
887 else if (strcmp (argv
[arg
], "arch") == 0)
890 gcc_assert (arg
< argc
);
897 /* Little endian - no be8 option. */
904 /* Arch might not be set iff arm_canon_arch (above) detected an
905 error. Do nothing in that case. */
909 const arch_option
*selected_arch
910 = arm_parse_arch_option_name (all_architectures
, "-march", arch
);
912 /* Similarly if the given arch option was itself invalid. */
916 if (check_isa_bits_for (selected_arch
->common
.isa_bits
, isa_bit_be8
))
922 /* Generate a -mfpu= option for passing to the assembler. This is
923 only called when -mfpu was set (possibly defaulted) to auto and is
924 needed to ensure that the assembler knows the correct FPU to use.
925 It wouldn't really be needed except that the compiler can be used
926 to invoke the assembler directly on hand-written files that lack
927 the necessary internal .fpu directives. We assume that the architecture
928 canonicalization calls have already been made so that we have a final
929 -march= option to derive the fpu from. */
931 arm_asm_auto_mfpu (int argc
, const char **argv
)
933 static char *auto_fpu
= NULL
;
934 const char *arch
= NULL
;
935 static const enum isa_feature fpu_bitlist
[]
936 = { ISA_ALL_FPU_INTERNAL
, isa_nobit
};
937 const arch_option
*selected_arch
;
938 static const char* fpuname
= "softvfp";
940 /* Handle multiple calls to this routine. */
949 if (strcmp (argv
[0], "arch") == 0)
952 fatal_error (input_location
,
953 "unrecognized operand to %%:asm_auto_mfpu");
958 auto_sbitmap
target_isa (isa_num_bits
);
959 auto_sbitmap
fpubits (isa_num_bits
);
961 gcc_assert (arch
!= NULL
);
962 selected_arch
= arm_parse_arch_option_name (all_architectures
,
964 if (selected_arch
== NULL
)
967 arm_initialize_isa (target_isa
, selected_arch
->common
.isa_bits
);
968 arm_parse_option_features (target_isa
, &selected_arch
->common
,
970 arm_initialize_isa (fpubits
, fpu_bitlist
);
972 bitmap_and (fpubits
, fpubits
, target_isa
);
974 /* The logic below is essentially identical to that in
975 arm.c:arm_identify_fpu_from_isa(), but that only works in the main
976 part of the compiler. */
978 /* If there are no FPU capability bits, we just pass -mfpu=softvfp. */
979 if (!bitmap_empty_p (fpubits
))
982 auto_sbitmap
cand_fpubits (isa_num_bits
);
983 for (i
= 0; i
< TARGET_FPU_auto
; i
++)
985 arm_initialize_isa (cand_fpubits
, all_fpus
[i
].isa_bits
);
986 if (bitmap_equal_p (fpubits
, cand_fpubits
))
988 fpuname
= all_fpus
[i
].name
;
993 gcc_assert (i
!= TARGET_FPU_auto
);
996 auto_fpu
= (char *) xmalloc (strlen (fpuname
) + sizeof ("-mfpu="));
997 strcpy (auto_fpu
, "-mfpu=");
998 strcat (auto_fpu
, fpuname
);
1002 #undef ARM_CPU_NAME_LENGTH
1005 #undef TARGET_DEFAULT_TARGET_FLAGS
1006 #define TARGET_DEFAULT_TARGET_FLAGS (TARGET_DEFAULT | MASK_SCHED_PROLOG)
1008 #undef TARGET_OPTION_OPTIMIZATION_TABLE
1009 #define TARGET_OPTION_OPTIMIZATION_TABLE arm_option_optimization_table
1011 #undef TARGET_EXCEPT_UNWIND_INFO
1012 #define TARGET_EXCEPT_UNWIND_INFO arm_except_unwind_info
1014 struct gcc_targetm_common targetm_common
= TARGETM_COMMON_INITIALIZER
;