public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Earnshaw <Richard.Earnshaw@arm.com>
To: Tejas Belagod <Tejas.Belagod@arm.com>,
	"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [Patch 4/7, Arm. GCC] Implement target feature macros for PACBTI.
Date: Mon, 11 Oct 2021 14:58:02 +0100	[thread overview]
Message-ID: <d2a23610-491e-3d6a-b24b-e388bc3cdf86@arm.com> (raw)
In-Reply-To: <AM5PR0801MB18447CDCD0CC98386CFD9ACBEAB29@AM5PR0801MB1844.eurprd08.prod.outlook.com>

On 08/10/2021 13:18, Tejas Belagod via Gcc-patches wrote:
> Hi,
> 
> This patch implements target feature macros when PACBTI is
> enabled through the -march option or -mbranch-protection.
> 
> Tested on arm-none-eabi. OK for trunk?
> 
> 2021-10-04  Tejas Belagod  <tbelagod@arm.com>
> 
> gcc/ChangeLog:
> 
> 	* config/arm/arm-c.c (arm_cpu_builtins): Define
> 	__ARM_FEATURE_BTI_DEFAULT and __ARM_FEATURE_PAC_DEFAULT.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* gcc.target/arm/acle/pacbti-m-predef-2.c: New test.
> 	* gcc.target/arm/acle/pacbti-m-predef-4.c: New test.
> 	* gcc.target/arm/acle/pacbti-m-predef-5.c: New test.
> 

I presume the specification for this is ACLE - please say so rather than 
making me guess.


+  cpp_undef (pfile, "__ARM_FEATURE_BTI_DEFAULT");
+  cpp_undef (pfile, "__ARM_FEATURE_PAC_DEFAULT");
+  if (TARGET_HAVE_PACBTI)
+    {
+      builtin_define_with_int_value ("__ARM_FEATURE_BTI_DEFAULT",
+				     arm_enable_pacbti & 0x1);

My reading of the ACLE specification would suggest this shouldn't be 
defined if it would have a value of 0, but that's not what this code 
does.  I think it would be better to move this outside the 
TARGET_HAVE_PACBTI and use the def_or_undef approach.

+      builtin_define_with_int_value ("__ARM_FEATURE_PAC_DEFAULT",
+				     arm_enable_pacbti >> 1);

This one is less clear, could the value ever be zero?  I guess exactly 
one of a-key and b-key must be defined and each has a separate bit.

+    }
+
+

Not more than one blank line at the end of a block.


diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-2.c 
b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-2.c


Given what I've said above, I think you need to also test that 
__ARM_FEATURE_BTI_DEFAULT is defined before testing the value (and 
emitting #error if it isn't).

R.

      reply	other threads:[~2021-10-11 13:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-08 12:18 Tejas Belagod
2021-10-11 13:58 ` Richard Earnshaw [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d2a23610-491e-3d6a-b24b-e388bc3cdf86@arm.com \
    --to=richard.earnshaw@arm.com \
    --cc=Tejas.Belagod@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).