public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Matthew Malcomson <matmal01@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/morello)] Allow capability->non-capability pointer conversions Date: Thu, 5 May 2022 12:05:55 +0000 (GMT) [thread overview] Message-ID: <20220505120555.C1E3C385626C@sourceware.org> (raw) https://gcc.gnu.org/g:2912ef897f2684d69ee05eca50a42ac2e61749ab commit 2912ef897f2684d69ee05eca50a42ac2e61749ab Author: Richard Sandiford <richard.sandiford@arm.com> Date: Thu Apr 7 16:14:11 2022 +0100 Allow capability->non-capability pointer conversions This patch allows a capability pointer to be converted to a non-capability pointer, dropping the metadata in the process. Such conversions can only occur for hybrid capabilities; in other cases, all pointers are capabilities or all pointers are not. Co-authored-by: Matthew Malcolmson <matthew.malcomson@arm.com> Diff: --- gcc/testsuite/gcc.target/aarch64/morello/pointer-arith-3.c | 9 +++++++++ gcc/tree.h | 14 +++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/gcc/testsuite/gcc.target/aarch64/morello/pointer-arith-3.c b/gcc/testsuite/gcc.target/aarch64/morello/pointer-arith-3.c new file mode 100644 index 00000000000..59d92287ba6 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/morello/pointer-arith-3.c @@ -0,0 +1,9 @@ +/* { dg-do assemble } */ +/* { dg-additional-options "-save-temps" } */ +/* { dg-final { check-function-bodies "**" "" { {-O[123s]} } } } */ + +/* +** foo: +** ret +*/ +int *foo(int *__capability x) { return (int *)x; } diff --git a/gcc/tree.h b/gcc/tree.h index e5706f13340..0085afb091f 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -6426,15 +6426,15 @@ capability_args_valid (const_tree type, || (TYPE_MODE (type) != TYPE_MODE (rhs_type)))) return false; - /* Any conversions *from* a capability type must be either to - another capability type of the same machine mode, to an - integral type with precision less than or equal to that of - the value of a given capability, or to void_type_node. The - first case is handled by the above clause, while we handle - the other cases here. */ + /* Any conversions *from* a capability type must be either to another + capability type of the same machine mode, to an integral type or + non-capability pointer type with a precision less than or equal to + the precision of the value of a given capability, or to + void_type_node. The first case is handled by the above clause, + while we handle the other cases here. */ if (capability_type_p (rhs_type) && !capability_type_p (type) - && (!INTEGRAL_TYPE_P (type) + && (!(INTEGRAL_TYPE_P (type) || POINTER_TYPE_P (type)) || (TYPE_PRECISION (type) > TYPE_NONCAP_PRECISION (rhs_type))) && type != void_type_node) return false;
reply other threads:[~2022-05-05 12:05 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220505120555.C1E3C385626C@sourceware.org \ --to=matmal01@gcc.gnu.org \ --cc=gcc-cvs@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: linkBe 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).