@@ -732,60 +732,29 @@ aarch64_rewrite_march (int argc, const char **argv)
732732 return xstrdup (outstr.c_str ());
733733}
734734
735- /* Attempt to rewrite NAME, which has been passed on the command line
736- as a -mcpu option to an equivalent -march value. If we can do so,
737- return the new string, otherwise return an error. */
735+ /* Called by the driver to rewrite a name passed to the -mcpu argument
736+ to an equivalent -march value to be passed to the assembler. The
737+ names passed from the commend line will be in ARGV, we want
738+ to use the right-most argument, which should be in
739+ ARGV[ARGC - 1]. ARGC should always be greater than 0. */
738740
739741const char *
740- aarch64_rewrite_selected_cpu ( const char *name )
742+ aarch64_rewrite_mcpu ( int argc, const char **argv )
741743{
742- std::string original_string (name);
743- std::string extension_str;
744- std::string processor;
745- size_t extension_pos = original_string.find_first_of (' +' );
746-
747- /* Strip and save the extension string. */
748- if (extension_pos != std::string::npos)
749- {
750- processor = original_string.substr (0 , extension_pos);
751- extension_str = original_string.substr (extension_pos,
752- std::string::npos);
753- }
754- else
755- {
756- /* No extensions. */
757- processor = original_string;
758- }
759-
760- const struct aarch64_processor_info * p_to_a;
761- for (p_to_a = all_cores;
762- p_to_a->arch != aarch64_no_arch;
763- p_to_a++)
764- {
765- if (p_to_a->name == processor)
766- break ;
767- }
768-
769- const struct aarch64_arch_info * a_to_an;
770- for (a_to_an = all_architectures;
771- a_to_an->arch != aarch64_no_arch;
772- a_to_an++)
773- {
774- if (a_to_an->arch == p_to_a->arch )
775- break ;
776- }
744+ gcc_assert (argc);
745+ const char *name = argv[argc - 1 ];
746+ aarch64_cpu cpu;
747+ aarch64_feature_flags flags;
777748
778- /* We couldn't find that processor name, or the processor name we
779- found does not map to an architecture we understand. */
780- if (p_to_a->arch == aarch64_no_arch
781- || a_to_an->arch == aarch64_no_arch)
782- fatal_error (input_location, " unknown value %qs for %<-mcpu%>" , name);
749+ aarch64_validate_mcpu (name, &cpu, &flags);
783750
784- aarch64_feature_flags extensions = p_to_a->flags ;
785- aarch64_parse_extension (extension_str.c_str (), &extensions, NULL );
751+ const struct aarch64_processor_info *entry;
752+ for (entry = all_cores; entry->processor != aarch64_no_cpu; entry++)
753+ if (entry->processor == cpu)
754+ break ;
786755
787- std::string outstr = aarch64_get_arch_string_for_assembler (a_to_an ->arch ,
788- extensions );
756+ std::string outstr = aarch64_get_arch_string_for_assembler (entry ->arch ,
757+ flags );
789758
790759 /* We are going to memory leak here, nobody elsewhere
791760 in the callchain is going to clean up after us. The alternative is
@@ -794,19 +763,6 @@ aarch64_rewrite_selected_cpu (const char *name)
794763 return xstrdup (outstr.c_str ());
795764}
796765
797- /* Called by the driver to rewrite a name passed to the -mcpu
798- argument in preparation to be passed to the assembler. The
799- names passed from the commend line will be in ARGV, we want
800- to use the right-most argument, which should be in
801- ARGV[ARGC - 1]. ARGC should always be greater than 0. */
802-
803- const char *
804- aarch64_rewrite_mcpu (int argc, const char **argv)
805- {
806- gcc_assert (argc);
807- return aarch64_rewrite_selected_cpu (argv[argc - 1 ]);
808- }
809-
810766/* Checks to see if the host CPU may not be Cortex-A53 or an unknown Armv8-a
811767 baseline CPU. */
812768
0 commit comments