This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RE: [PATCH][ARM]Automatically add -mthumb for thumb-only target when mode isn't specified
- From: "Kyrill Tkachov" <kyrylo dot tkachov at arm dot com>
- To: "James Greenhalgh" <James dot Greenhalgh at arm dot com>, "Maxim Kuvyrkov" <maxim dot kuvyrkov at linaro dot org>
- Cc: "Terry Guo" <Terry dot Guo at arm dot com>, <gcc-patches at gcc dot gnu dot org>, "Ramana Radhakrishnan" <Ramana dot Radhakrishnan at arm dot com>, "Richard Earnshaw" <Richard dot Earnshaw at arm dot com>
- Date: Mon, 2 Mar 2015 16:14:36 -0000
- Subject: RE: [PATCH][ARM]Automatically add -mthumb for thumb-only target when mode isn't specified
- Authentication-results: sourceware.org; auth=none
- References: <000001d0548a$789a1bd0$69ce5370$ at arm dot com> <0E847550-2947-46C3-991C-2720641BC881 at linaro dot org> <20150302132814 dot GA16212 at arm dot com>
> -----Original Message-----
> From: gcc-patches-owner@gcc.gnu.org [mailto:gcc-patches-
> owner@gcc.gnu.org] On Behalf Of James Greenhalgh
> Sent: 02 March 2015 13:28
> To: Maxim Kuvyrkov
> Cc: Terry Guo; gcc-patches@gcc.gnu.org; Ramana Radhakrishnan; Richard
> Earnshaw
> Subject: Re: [PATCH][ARM]Automatically add -mthumb for thumb-only
> target when mode isn't specified
>
> On Mon, Mar 02, 2015 at 01:08:13PM +0000, Maxim Kuvyrkov wrote:
> > > On Mar 2, 2015, at 4:44 AM, Terry Guo <terry.guo@arm.com> wrote:
> > >
> > > Hi there,
> > >
> > > If target mode isn't specified via either gcc configuration option
> > > --with-mode or command line, this patch intends to improve gcc
> > > driver to automatically add option -mthumb for thumb-only target.
> > > Tested with gcc regression test for various arm targets, no
regression. Is it
> OK?
FWIW, I had this annoyance that the patch tries to fix as well and filed a
PR for it:
PR target/64802
Kyrill
> > >
> > > BR,
> > > Terry
> > >
> > > gcc/ChangeLog:
> > >
> > > 2015-03-02 Terry Guo <terry.guo@arm.com>
> > >
> > > * common/config/arm/arm-common.c (arm_is_target_thumb_only):
> > > New function.
> > > * config/arm/arm-protos.h (FL_ Macros): Move to ...
> > > * config/arm/arm-opts.h (FL_ Macros): ... here.
> > > (struct arm_arch_core_flag): New struct.
> > > (arm_arch_core_flags): New array for arch/core and flag map.
> > > * config/arm/arm.h (MODE_SET_SPEC_FUNCTIONS): Define new
> SPEC
> > > function.
> > > (EXTRA_SPEC_FUNCTIONS): Include new SPEC function.
> > > (MODE_SET_SPECS): New SPEC.
> > > (DRIVER_SELF_SPECS): Include new
> > > SPEC.<gcc-mthumb-option-v5.txt>
> >
> > Did you consider approach of implementing this purely inside cc1 rather
> than driver?
> >
> > We do not seem to need to pass -mthumb to assembler or linker since
> > those will pick up ARM-ness / Thumb-ness from function annotations.
> > Therefore we need to handle -marm / -mthumb for cc1 only. What am I
> missing?
>
> I recently had a similar argument with myself regarding the usefulness of
> rewriting -mcpu values in the driver before handing them off the assembler
> (as we do for big.LITTLE systems), we could just rely on the .arch
directives in
> the assembler files.
>
> The problem with this argument, and the one you make here, is that it
> doesn't cover users driving the assembler with a GCC command to assemble
> hand-rolled files without directives. i.e.
>
> gcc foo.s bar.c -mthumb -mcpu=cortex-a57.cortex-a53
>
> Should have the effect when assembling foo.s of enforcing thumb mode,
> and permitting ARMv8-A instructions, regardless whether foo.s explicitly
> enables these through directives.
>
> Cheers,
> James
>