arm: Add pacbti related multilib support for armv8.1-m.main.

This patch adds the support for pacbti multlilib linking by making
"-mbranch-protection=none" as default multilib option for arm-none-eabi
target.

Eg 1.

If the passed command line flags are (without mbranch-protection):
a) -march=armv8.1-m.main+mve -mfloat-abi=hard -mfpu=auto

"-mbranch-protection=none" will be used in the multilib matching.

Eg 2.

If the passed command line flags are (with mbranch-protection):
a) -march=armv8.1-m.main+mve+pacbti -mfloat-abi=hard -mfpu=auto  -mbranch-protection=pac-ret

"-mbranch-protection=standard" will be used in the multilib matching.

gcc/ChangeLog:

2023-01-11  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>

	* config.gcc ($tm_file): Update variable.
	* config/arm/arm-mlib.h: Create new header file.
	* config/arm/t-rmprofile (MULTI_ARCH_DIRS_RM): Rename mbranch-protection
	multilib arch directory.
	(MULTILIB_REUSE): Add multilib reuse rules.
	(MULTILIB_MATCHES): Add multilib match rules.

gcc/testsuite/ChangeLog:

2023-01-11  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>

	* gcc.target/arm/multilib.exp (multilib_config "rmprofile"): Update
	tests.
	* gcc.target/arm/pac-12.c: New test.
	* gcc.target/arm/pac-13.c: Likewise.
	* gcc.target/arm/pac-14.c: Likewise.
This commit is contained in:
Srinath Parvathaneni
2023-01-23 11:04:19 +00:00
committed by Andrea Corallo
parent 403d1b1760
commit 014175926e
7 changed files with 106 additions and 18 deletions

View File

@@ -4462,6 +4462,7 @@ case "${target}" in
case ${arm_multilib} in
aprofile|rmprofile)
tmake_profile_file="arm/t-multilib"
tm_file="$tm_file arm/arm-mlib.h"
;;
@*)
ml=`echo "X$arm_multilib" | sed '1s,^X@,,'`

22
gcc/config/arm/arm-mlib.h Normal file
View File

@@ -0,0 +1,22 @@
/* Arm multilib default option include file.
Copyright (C) 2023 Free Software Foundation, Inc.
Contributed by Arm.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your
option) any later version.
GCC is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#define MULTILIB_DEFAULTS { "mbranch-protection=none" }

View File

@@ -31,7 +31,7 @@ MULTI_ARCH_OPTS_RM = march=armv6s-m/march=armv7-m/march=armv7e-m/march=armv7e-m+
MULTI_ARCH_DIRS_RM = v6-m v7-m v7e-m v7e-m+fp v7e-m+dp v8-m.base v8-m.main v8-m.main+fp v8-m.main+dp v8.1-m.main+mve v8.1-m.main+pacbti v8.1-m.main+pacbti+fp v8.1-m.main+pacbti+dp v8.1-m.main+pacbti+mve
MULTI_ARCH_OPTS_RM += mbranch-protection=standard
MULTI_ARCH_DIRS_RM += mbranch-protection
MULTI_ARCH_DIRS_RM += bp
# Base M-profile (no fp)
MULTILIB_REQUIRED += mthumb/march=armv6s-m/mfloat-abi=soft
@@ -113,7 +113,47 @@ MULTILIB_MATCHES += march?armv8-m.main=mlibarch?armv8-m.main
MULTILIB_MATCHES += march?armv8-m.main+fp=mlibarch?armv8-m.main+fp
MULTILIB_MATCHES += march?armv8-m.main+fp.dp=mlibarch?armv8-m.main+fp.dp
MULTILIB_MATCHES += march?armv8.1-m.main+mve=mlibarch?armv8.1-m.main+mve
# For -mbranch-protection=none and +pacbti reuses the existing non pacbti
# multilibs.
MULTILIB_REUSE += $(foreach OPT, fp fp\.dp, \
mthumb/march.armv8-m\.main+$(OPT)/mfloat-abi.softfp=mthumb/march.armv8\.1-m\.main+pacbti+$(OPT)/mfloat-abi.softfp)
MULTILIB_REUSE += $(foreach OPT, fp fp\.dp, \
mthumb/march.armv8-m\.main+$(OPT)/mfloat-abi.hard=mthumb/march.armv8\.1-m\.main+pacbti+$(OPT)/mfloat-abi.hard)
MULTILIB_REUSE += $(foreach OPT, pacbti pacbti+mve, \
mthumb/march.armv8-m\.main/mfloat-abi.soft=mthumb/march.armv8\.1-m\.main+$(OPT)/mfloat-abi.soft)
MULTILIB_REUSE += $(foreach OPT, pacbti pacbti+mve, \
mthumb/march.armv8-m\.main/mfloat-abi.soft=mthumb/march.armv8\.1-m\.main+$(OPT)/mfloat-abi.softfp)
MULTILIB_REUSE += mthumb/march.armv8\.1-m\.main+mve/mfloat-abi.hard=mthumb/march.armv8\.1-m\.main+pacbti+mve/mfloat-abi.hard
pacbti_fp_variants = fp fp+mve mve.fp fp+mve.fp
pacbti_dp_variants = fp.dp fp.dp+mve fp.dp+mve.fp
# For -mbranch-protection=standard and +pacbti linking to existing pacbti
# multlibs.
MULTILIB_MATCHES += march?armv8.1-m.main+pacbti=mlibarch?armv8.1-m.main+pacbti
MULTILIB_MATCHES += march?armv8.1-m.main+pacbti+fp=mlibarch?armv8.1-m.main+pacbti+fp
MULTILIB_MATCHES += march?armv8.1-m.main+pacbti+fp.dp=mlibarch?armv8.1-m.main+pacbti+fp.dp
MULTILIB_MATCHES += march?armv8.1-m.main+pacbti=mlibarch?armv8.1-m.main+pacbti+dsp
MULTILIB_MATCHES += march?armv8.1-m.main+pacbti=mlibarch?armv8.1-m.main+dsp+pacbti
MULTILIB_MATCHES += march?armv8.1-m.main+pacbti+mve=mlibarch?armv8.1-m.main+pacbti+mve
MULTILIB_MATCHES += march?armv8.1-m.main+pacbti+mve=mlibarch?armv8.1-m.main+pacbti+dsp+mve
MULTILIB_MATCHES += march?armv8.1-m.main+pacbti+mve=mlibarch?armv8.1-m.main+dsp+pacbti+mve
MULTILIB_MATCHES += $(foreach OPT, $(pacbti_fp_variants), \
march?armv8.1-m.main+pacbti+fp=mlibarch?armv8.1-m.main+pacbti+$(OPT))
MULTILIB_MATCHES += $(foreach OPT, $(pacbti_fp_variants), \
march?armv8.1-m.main+pacbti+fp=mlibarch?armv8.1-m.main+pacbti+dsp+$(OPT))
MULTILIB_MATCHES += $(foreach OPT, $(pacbti_dp_variants), \
march?armv8.1-m.main+pacbti+fp.dp=mlibarch?armv8.1-m.main+pacbti+$(OPT))
MULTILIB_MATCHES += $(foreach OPT, $(pacbti_dp_variants), \
march?armv8.1-m.main+pacbti+fp.dp=mlibarch?armv8.1-m.main+pacbti+dsp+$(OPT))
MULTILIB_MATCHES += $(foreach OPT, $(pacbti_fp_variants), \
march?armv8.1-m.main+pacbti+fp=mlibarch?armv8.1-m.main+dsp+pacbti+$(OPT))
MULTILIB_MATCHES += $(foreach OPT, $(pacbti_dp_variants), \
march?armv8.1-m.main+pacbti+fp.dp=mlibarch?armv8.1-m.main+dsp+pacbti+$(OPT))

View File

@@ -526,6 +526,10 @@ if {[multilib_config "rmprofile"] } {
{-mcpu=cortex-m85+nopacbti+nomve -mfpu=auto -mfloat-abi=soft} "thumb/v8-m.main/nofp"
{-mcpu=cortex-m85+nopacbti+nodsp -mfpu=auto -mfloat-abi=soft} "thumb/v8-m.main/nofp"
{-mcpu=cortex-m85+nopacbti+nomve.fp -mfpu=auto -mfloat-abi=soft} "thumb/v8-m.main/nofp"
{-mcpu=cortex-m85 -mfpu=auto -mfloat-abi=soft} "thumb/v8-m.main/nofp"
{-mcpu=cortex-m85+nomve.fp -mfpu=auto -mfloat-abi=soft} "thumb/v8-m.main/nofp"
{-mcpu=cortex-m85+nomve -mfpu=auto -mfloat-abi=soft} "thumb/v8-m.main/nofp"
{-mcpu=cortex-m85+nodsp -mfpu=auto -mfloat-abi=soft} "thumb/v8-m.main/nofp"
{-mcpu=cortex-m4 -mfpu=auto -mfloat-abi=hard} "thumb/v7e-m+fp/hard"
{-mcpu=cortex-m7 -mfpu=auto -mfloat-abi=hard} "thumb/v7e-m+dp/hard"
{-mcpu=cortex-m33 -mfpu=auto -mfloat-abi=hard} "thumb/v8-m.main+fp/hard"
@@ -556,10 +560,10 @@ if {[multilib_config "rmprofile"] } {
{-mcpu=cortex-m85+nopacbti+nodsp -mfpu=auto -mfloat-abi=hard} "thumb/v8-m.main+dp/hard"
{-mcpu=cortex-m85+nopacbti+nofp -mfpu=auto -mfloat-abi=hard} "thumb/v8.1-m.main+mve/hard"
{-mcpu=cortex-m85+nopacbti+nomve.fp -mfpu=auto -mfloat-abi=hard} "thumb/v8-m.main+dp/hard"
{-mcpu=cortex-m85 -mbranch-protection=standard -mfpu=auto -mfloat-abi=hard} "thumb/v8.1-m.main+pacbti+dp/mbranch-protection/hard"
{-mcpu=cortex-m85+nomve.fp -mbranch-protection=standard -mfpu=auto -mfloat-abi=hard} "thumb/v8.1-m.main+pacbti+dp/mbranch-protection/hard"
{-mcpu=cortex-m85+nomve -mbranch-protection=standard -mfpu=auto -mfloat-abi=hard} "thumb/v8.1-m.main+pacbti+dp/mbranch-protection/hard"
{-mcpu=cortex-m85+nodsp -mbranch-protection=standard -mfpu=auto -mfloat-abi=hard} "thumb/v8.1-m.main+pacbti+dp/mbranch-protection/hard"
{-mcpu=cortex-m85 -mbranch-protection=standard -mfpu=auto -mfloat-abi=hard} "thumb/v8.1-m.main+pacbti+dp/bp/hard"
{-mcpu=cortex-m85+nomve -mbranch-protection=standard -mfpu=auto -mfloat-abi=hard} "thumb/v8.1-m.main+pacbti+dp/bp/hard"
{-mcpu=cortex-m85+nomve.fp -mbranch-protection=standard -mfpu=auto -mfloat-abi=hard} "thumb/v8.1-m.main+pacbti+dp/bp/hard"
{-mcpu=cortex-m85+nodsp -mbranch-protection=standard -mfpu=auto -mfloat-abi=hard} "thumb/v8.1-m.main+pacbti+dp/bp/hard"
{-mcpu=cortex-m0 -mfpu=auto -mfloat-abi=softfp} "thumb/v6-m/nofp"
{-mcpu=cortex-m1 -mfpu=auto -mfloat-abi=softfp} "thumb/v6-m/nofp"
{-mcpu=cortex-m3 -mfpu=auto -mfloat-abi=softfp} "thumb/v7-m/nofp"
@@ -610,14 +614,14 @@ if {[multilib_config "rmprofile"] } {
{-mcpu=cortex-m33 -mfpu=fpv5-d16 -mfloat-abi=softfp} "thumb/v8-m.main+dp/softfp"
{-mcpu=cortex-m7+nofp.dp -mfpu=fpv5-d16 -mfloat-abi=softfp} "thumb/v7e-m+dp/softfp"
{-mcpu=cortex-m85+nopacbti+nofp -mfpu=auto -mfloat-abi=softfp} "thumb/v8-m.main/nofp"
{-mcpu=cortex-m85+nopacbti -mfpu=auto -mfloat-abi=softfp} "thumb/v8-m.main+dp/softfp"
{-mcpu=cortex-m85+nopacbti -mfpu=auto -mfloat-abi=softfp} "thumb/v8-m.main+dp/softfp"
{-mcpu=cortex-m85+nopacbti+nomve -mfpu=auto -mfloat-abi=softfp} "thumb/v8-m.main+dp/softfp"
{-mcpu=cortex-m85+nopacbti+nodsp -mfpu=auto -mfloat-abi=softfp} "thumb/v8-m.main+dp/softfp"
{-mcpu=cortex-m85+nopacbti+nomve.fp -mfpu=auto -mfloat-abi=softfp} "thumb/v8-m.main+dp/softfp"
{-mcpu=cortex-m85 -mbranch-protection=standard -mfpu=auto -mfloat-abi=softfp} "thumb/v8.1-m.main+pacbti+dp/mbranch-protection/softfp"
{-mcpu=cortex-m85+nomve.fp -mbranch-protection=standard -mfpu=auto -mfloat-abi=softfp} "thumb/v8.1-m.main+pacbti+dp/mbranch-protection/softfp"
{-mcpu=cortex-m85+nomve -mbranch-protection=standard -mfpu=auto -mfloat-abi=softfp} "thumb/v8.1-m.main+pacbti+dp/mbranch-protection/softfp"
{-mcpu=cortex-m85+nodsp -mbranch-protection=standard -mfpu=auto -mfloat-abi=softfp} "thumb/v8.1-m.main+pacbti+dp/mbranch-protection/softfp"
{-mcpu=cortex-m85 -mbranch-protection=standard -mfpu=auto -mfloat-abi=softfp} "thumb/v8.1-m.main+pacbti+dp/bp/softfp"
{-mcpu=cortex-m85+nomve -mbranch-protection=standard -mfpu=auto -mfloat-abi=softfp} "thumb/v8.1-m.main+pacbti+dp/bp/softfp"
{-mcpu=cortex-m85+nomve.fp -mbranch-protection=standard -mfpu=auto -mfloat-abi=softfp} "thumb/v8.1-m.main+pacbti+dp/bp/softfp"
{-mcpu=cortex-m85+nodsp -mbranch-protection=standard -mfpu=auto -mfloat-abi=softfp} "thumb/v8.1-m.main+pacbti+dp/bp/softfp"
{-march=armv6-m -mfpu=auto -mfloat-abi=soft} "thumb/v6-m/nofp"
{-march=armv7-m -mfpu=auto -mfloat-abi=soft} "thumb/v7-m/nofp"
{-march=armv7e-m -mfpu=auto -mfloat-abi=soft} "thumb/v7e-m/nofp"
@@ -858,12 +862,12 @@ if {[multilib_config "rmprofile"] } {
{-march=armv8.1-m.main+mve.fp+fp.dp -mfpu=auto -mfloat-abi=softfp} "thumb/v8-m.main+dp/softfp"
{-march=armv8.1-m.main+mve+fp.dp -mfpu=auto -mfloat-abi=hard} "thumb/v8-m.main+dp/hard"
{-march=armv8.1-m.main+mve.fp+fp.dp -mfpu=auto -mfloat-abi=hard} "thumb/v8-m.main+dp/hard"
{-march=armv8.1-m.main+pacbti -mbranch-protection=standard -mfloat-abi=soft} "thumb/v8.1-m.main+pacbti/mbranch-protection/nofp"
{-march=armv8.1-m.main+pacbti+fp -mbranch-protection=standard -mfloat-abi=softfp} "thumb/v8.1-m.main+pacbti+fp/mbranch-protection/soft"
{-march=armv8.1-m.main+pacbti+fp -mbranch-protection=standard -mfloat-abi=hard} "thumb/v8.1-m.main+pacbti+fp/mbranch-protection/hard"
{-march=armv8.1-m.main+pacbti+fp.dp -mbranch-protection=standard -mfloat-abi=softfp} "thumb/v8.1-m.main+pacbti+dp/mbranch-protection/soft"
{-march=armv8.1-m.main+pacbti+fp.dp -mbranch-protection=standard -mfloat-abi=hard} "thumb/v8.1-m.main+pacbti+dp/mbranch-protection/hard"
{-march=armv8.1-m.main+pacbti+mve -mbranch-protection=standard -mfloat-abi=hard} "thumb/v8.1-m.main+pacbti+mve/mbranch-protection/hard"
{-march=armv8.1-m.main+pacbti -mbranch-protection=standard -mfloat-abi=soft} "thumb/v8.1-m.main+pacbti/bp/nofp"
{-march=armv8.1-m.main+pacbti+fp -mbranch-protection=standard -mfloat-abi=softfp} "thumb/v8.1-m.main+pacbti+fp/bp/softfp"
{-march=armv8.1-m.main+pacbti+fp -mbranch-protection=standard -mfloat-abi=hard} "thumb/v8.1-m.main+pacbti+fp/bp/hard"
{-march=armv8.1-m.main+pacbti+fp.dp -mbranch-protection=standard -mfloat-abi=softfp} "thumb/v8.1-m.main+pacbti+dp/bp/softfp"
{-march=armv8.1-m.main+pacbti+fp.dp -mbranch-protection=standard -mfloat-abi=hard} "thumb/v8.1-m.main+pacbti+dp/bp/hard"
{-march=armv8.1-m.main+pacbti+mve -mbranch-protection=standard -mfloat-abi=hard} "thumb/v8.1-m.main+pacbti+mve/bp/hard"
{-mcpu=cortex-m55+nomve -mfpu=auto -mfloat-abi=soft} "thumb/v8-m.main/nofp"
{-mcpu=cortex-m55+nomve -mfpu=auto -mfloat-abi=softfp} "thumb/v8-m.main+dp/softfp"
{-mcpu=cortex-m55+nomve -mfpu=auto -mfloat-abi=hard} "thumb/v8-m.main+dp/hard"

View File

@@ -0,0 +1,7 @@
/* Testing PACBTI multilibs matches without mve. */
/* { dg-do run } */
/* { dg-require-effective-target arm_pacbti_hw } */
/* { dg-skip-if "need fp instructions" { *-*-* } { "" } { "-mfloat-abi=hard" } } */
/* { dg-options "-march=armv8.1-m.main+dsp+fp.dp+pacbti -mbranch-protection=standard -mthumb -mfloat-abi=hard" } */
#include "pac.h"

View File

@@ -0,0 +1,7 @@
/* Testing PACBTI multilib matches. */
/* { dg-do run } */
/* { dg-require-effective-target arm_pacbti_hw } */
/* { dg-skip-if "need fp instructions" { *-*-* } { "" } { "-mfloat-abi=hard" } } */
/* { dg-options "-march=armv8.1-m.main+mve.fp+fp.dp+pacbti -mbranch-protection=standard -mthumb -mfloat-abi=hard" } */
#include "pac.h"

View File

@@ -0,0 +1,7 @@
/* Testing PACBTI multilibs matches without mve float. */
/* { dg-do run } */
/* { dg-require-effective-target arm_pacbti_hw } */
/* { dg-skip-if "need fp instructions" { *-*-* } { "" } { "-mfloat-abi=hard" } } */
/* { dg-options "-march=armv8.1-m.main+mve+fp.dp+pacbti -mbranch-protection=standard -mthumb -mfloat-abi=hard" } */
#include "pac.h"