public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] Allow capability->non-capability pointer conversions
@ 2022-05-05 12:05 Matthew Malcomson
0 siblings, 0 replies; only message in thread
From: Matthew Malcomson @ 2022-05-05 12:05 UTC (permalink / raw)
To: gcc-cvs
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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-05 12:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05 12:05 [gcc(refs/vendors/ARM/heads/morello)] Allow capability->non-capability pointer conversions Matthew Malcomson
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).