On Wed, Aug 19, 2015 at 11:39 PM, James Greenhalgh
<james.greenha...@arm.com> wrote:
>
> Hi,
>
> This patch has been sitting in my tree for a while - it comes in handy
> when trying out bootstrap or test with -mcpu values like -mcpu=cortex-a72
> with a system assmebler which trails trunk binutils.
>
> Essentially, we rewrite -mcpu=foo to a -march flag providing the same
> architecture revision and set of optional architecture features. There
> is no reason we should ever need the assembler to see a CPU name, it
> should only be interested in the architecture variant.
>
> While we're there I've long found this function too fragile and hard
> to grok in C. So I've rewritten it in C++ to use std::string rather than
> raw C strings. Making this work with extension strings requires a slight
> refactor to the existing extension printing code to pull it across to
> somewhere common.
>
> Note that this also stops us from having to pick through a big.LITTLE
> target to find and separate the core names - we can just look up the
> architecture of the whole target and use that.
>
> The new function does leak the allocation of a C string to hold the
> result, but looking at gcc.c:getenv_spec_function and
> gcc.c:replace_extension_spec_func this is the usual thing to do.
>
> This has been through an aarch64-none-linux-gnu bootstrap and test run,
> configured with --with-cpu=cortex-a72 , which my system assembler does
> not understand.
>
> Ok?


+     modified string, which seems much worse!  */
+  char *output = (char*) xmalloc (sizeof (*output)
+  * (outstr.length () + 1));
+  strcpy (output, outstr.c_str ());

Why not just:
char *output = xstrdup (outstr.c_str ());

Or at least use XNEWVEC instead of xmalloc with a cast?

Thanks,
Andrew Pinski

>
> Thanks,
> James
>
> ---
> 2015-08-19  James Greenhalgh  <james.greenha...@arm.com>
>
>         * common/config/aarch64/aarch64-common.c
>         (AARCH64_CPU_NAME_LENGTH): Delete.
>         (aarch64_option_extension): New.
>         (all_extensions): Likewise.
>         (processor_name_to_arch): Likewise.
>         (arch_to_arch_name): Likewise.
>         (all_cores): New.
>         (all_architectures): Likewise.
>         (aarch64_get_extension_string_for_isa_flags): Likewise.
>         (aarch64_rewrite_selected_cpu): Change to rewrite CPU names to
>         architecture names.
>         * config/aarch64/aarch64-protos.h
>         (aarch64_get_extension_string_for_isa_flags): New.
>         * config/aarch64/aarch64.c (aarch64_print_extension): Delete.
>         (aarch64_option_print): Get the string to print from
>         aarch64_get_extension_string_for_isa_flags.
>         (aarch64_declare_function_name): Likewise.
>         * config/aarch64/aarch64.h (BIG_LITTLE_SPEC): Rename to...
>         (MCPU_TO_MARCH_SPEC): This.
>         (ASM_CPU_SPEC): Use it.
>         (BIG_LITTLE_SPEC_FUNCTIONS): Rename to...
>         (MCPU_TO_MARCH_SPEC_FUNCTIONS): ...This.
>         (EXTRA_SPEC_FUNCTIONS): Use it.
>

Reply via email to