[Patch 1/8, Arm, AArch64, GCC] Refactor mbranch-protection option parsing and make it common to AArch32 and AArch64 backends. [Was RE: [Patch 2/7, Arm, GCC] Add option -mbranch-protection.]

Tejas Belagod Tejas.Belagod@arm.com
Mon Nov 15 17:05:56 GMT 2021


Ping for this series.

Thanks,
Tejas.

> -----Original Message-----
> From: Gcc-patches <gcc-patches-
> bounces+belagod=gcc.gnu.org@gcc.gnu.org> On Behalf Of Tejas Belagod via
> Gcc-patches
> Sent: Thursday, October 28, 2021 12:41 PM
> To: Richard Earnshaw <Richard.Earnshaw@arm.com>; gcc-
> patches@gcc.gnu.org
> Subject: [Patch 1/8, Arm, AArch64, GCC] Refactor mbranch-protection option
> parsing and make it common to AArch32 and AArch64 backends. [Was RE:
> [Patch 2/7, Arm, GCC] Add option -mbranch-protection.]
> 
> 
> 
> > -----Original Message-----
> > From: Richard Earnshaw <Richard.Earnshaw@arm.com>
> > Sent: Monday, October 11, 2021 1:58 PM
> > To: Tejas Belagod <Tejas.Belagod@arm.com>; gcc-patches@gcc.gnu.org
> > Subject: Re: [Patch 2/7, Arm, GCC] Add option -mbranch-protection.
> >
> > On 08/10/2021 13:17, Tejas Belagod via Gcc-patches wrote:
> > > Hi,
> > >
> > > Add -mbranch-protection option and its associated parsing routines.
> > > This option enables the code-generation of pointer signing and
> > > authentication instructions in function prologues and epilogues.
> > >
> > > Tested on arm-none-eabi. OK for trunk?
> > >
> > > 2021-10-04  Tejas Belagod  <tbelagod@arm.com>
> > >
> > > gcc/ChangeLog:
> > >
> > > 	* common/config/arm/arm-common.c
> > > 	 (arm_print_hit_for_pacbti_option): New.
> > > 	 (arm_progress_next_token): New.
> > > 	 (arm_parse_pac_ret_clause): New routine for parsing the
> > > 	pac-ret clause for -mbranch-protection.
> > > 	(arm_parse_pacbti_option): New routine to parse all the options
> > > 	to -mbranch-protection.
> > > 	* config/arm/arm-protos.h (arm_parse_pacbti_option): Export.
> > > 	* config/arm/arm.c (arm_configure)build_target): Handle option
> > > 	to -mbranch-protection.
> > > 	* config/arm/arm.opt (mbranch-protection). New.
> > > 	(arm_enable_pacbti): New.
> > >
> >
> > You're missing documentation for invoke.texi.
> >
> > Also, how does this differ from the exising option in aarch64?  Can
> > the code from that be adapted to be made common to both targets rather
> > than doing a new implementation?
> >
> > Finally, there are far to many manifest constants in this patch, they
> > need replacing with enums or #defines as appropriate if we cannot
> > share the
> > aarch64 code.
> >
> 
> Thanks for the reviews.
> 
> This change refactors all the mbranch-protection option parsing code and
> types to make it common to both AArch32 and AArch64 backends.  This
> change also pulls in some supporting types from AArch64 to make it common
> (aarch_parse_opt_result).  The significant changes in this patch are the
> movement of all branch protection parsing routines from aarch64.c to aarch-
> common.c and supporting data types and static data structures.  This patch
> also pre-declares variables and types required in the aarch32 back for moved
> variables for function sign scope and key to prepare for the impending series
> of patches that support parsing the feature mbranch-protection in the
> aarch32 back end.
> 
> 2021-10-25  Tejas Belagod  <tbelagod@arm.com>
> 
> gcc/ChangeLog:
> 
> 	* common/config/aarch64/aarch64-common.c: Include aarch-
> common.h.
> 	(all_architectures): Fix comment.
> 	(aarch64_parse_extension): Rename return type, enum value
> names.
> 	* config/aarch64/aarch64-c.c (aarch64_update_cpp_builtins):
> Rename
> 	factored out aarch_ra_sign_scope and aarch_ra_sign_key variables.
> 	Also rename corresponding enum values.
> 	* config/aarch64/aarch64-opts.h (aarch64_function_type): Factor out
> 	aarch64_function_type and move it to common code as
> aarch_function_type
> 	in aarch-common.h.
> 	* config/aarch64/aarch64-protos.h: Include common types header,
> move out
> 	types aarch64_parse_opt_result and aarch64_key_type to aarch-
> common.h
> 	* config/aarch64/aarch64.c: Move mbranch-protection parsing types
> and
> 	functions out into aarch-common.h and aarch-common.c.  Fix up all
> the name
> 	changes resulting from the move.
> 	* config/aarch64/aarch64.md: Fix up aarch64_ra_sign_key type name
> change
> 	and enum value.
> 	* config/aarch64/aarch64.opt: Include aarch-common.h to import
> type move.
> 	Fix up name changes from factoring out common code and data.
> 	* config/arm/aarch-common-protos.h: Export factored out routines
> to both
> 	backends.
> 	* config/arm/aarch-common.c: Include newly factored out types.
> Move all
> 	mbranch-protection code and data structures from aarch64.c.
> 	* config/arm/aarch-common.h: New header that declares types
> shared between
> 	aarch32 and aarch64 backends.
> 	* config/arm/arm-protos.h: Declare types and variables that are
> made common
> 	to aarch64 and aarch32 backends - aarch_ra_sign_key,
> aarch_ra_sign_scope and
> 	aarch_enable_bti.
> 
> 
> Tested the following configurations. OK for trunk?
> 
> -mthumb/-march=armv8.1-m.main+pacbti/-mfloat-abi=soft
> -marm/-march=armv7-a/-mfpu=vfpv3-d16/-mfloat-abi=softfp
> mcmodel=small and tiny
> aarch64-none-linux-gnu native test and bootstrap
> 
> Thanks,
> Tejas.
> 
> > R.


More information about the Gcc-patches mailing list