* [PATCH] Allow `gcc_jit_type_get_size` to work with pointers
@ 2024-03-28 22:47 Guillaume Gomez
2024-03-29 17:48 ` David Malcolm
0 siblings, 1 reply; 4+ messages in thread
From: Guillaume Gomez @ 2024-03-28 22:47 UTC (permalink / raw)
To: gcc-patches, jit, David Malcolm, Antoni
[-- Attachment #1: Type: text/plain, Size: 117 bytes --]
Hi,
Here's a little fix to allow the `gcc_jit_type_get_size` function to
work on pointer types as well.
Cordially.
[-- Attachment #2: 0001-PATH-Allow-gcc_jit_type_get_size-to-work-with-pointe.patch --]
[-- Type: text/x-patch, Size: 2214 bytes --]
From 21e6e2d5ea897fc74d0e3194973093c58157e6fa Mon Sep 17 00:00:00 2001
From: Guillaume Gomez <guillaume1.gomez@gmail.com>
Date: Tue, 26 Mar 2024 17:56:36 +0100
Subject: [PATCH] [PATH] Allow `gcc_jit_type_get_size` to work with pointers
gcc/jit/ChangeLog:
* libgccjit.cc (gcc_jit_type_get_size): Add pointer support
---
gcc/jit/libgccjit.cc | 4 ++--
gcc/testsuite/jit.dg/test-pointer_size.c | 27 ++++++++++++++++++++++++
2 files changed, 29 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/jit.dg/test-pointer_size.c
diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc
index a2cdc01a3a4..58d47723e38 100644
--- a/gcc/jit/libgccjit.cc
+++ b/gcc/jit/libgccjit.cc
@@ -575,8 +575,8 @@ gcc_jit_type_get_size (gcc_jit_type *type)
{
RETURN_VAL_IF_FAIL (type, -1, NULL, NULL, "NULL type");
RETURN_VAL_IF_FAIL
- (type->is_int () || type->is_float (), -1, NULL, NULL,
- "only getting the size of integer or floating-point types is supported for now");
+ (type->is_int () || type->is_float () || type->is_pointer (), -1, NULL, NULL,
+ "only getting the size of integer or floating-point or pointer types is supported for now");
return type->get_size ();
}
diff --git a/gcc/testsuite/jit.dg/test-pointer_size.c b/gcc/testsuite/jit.dg/test-pointer_size.c
new file mode 100644
index 00000000000..337796acc2a
--- /dev/null
+++ b/gcc/testsuite/jit.dg/test-pointer_size.c
@@ -0,0 +1,27 @@
+/* { dg-do compile { target x86_64-*-* } } */
+
+#include <assert.h>
+#include "libgccjit.h"
+
+#include "harness.h"
+
+void
+create_code (gcc_jit_context *ctxt, void *user_data)
+{}
+
+void
+verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
+{
+ gcc_jit_type *int_type =
+ gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
+ gcc_jit_type *int_ptr_type = gcc_jit_type_get_pointer (int_type);
+
+ int int_ptr_size = gcc_jit_type_get_size (int_ptr_type);
+ CHECK_VALUE (int_ptr_size, 8);
+
+ gcc_jit_type *void_type =
+ gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID);
+ gcc_jit_type *void_ptr_type = gcc_jit_type_get_pointer (void_type);
+
+ CHECK_VALUE (int_ptr_size, gcc_jit_type_get_size (void_ptr_type));
+}
--
2.24.1.2762.gfe2e4819b8
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Allow `gcc_jit_type_get_size` to work with pointers
2024-03-28 22:47 [PATCH] Allow `gcc_jit_type_get_size` to work with pointers Guillaume Gomez
@ 2024-03-29 17:48 ` David Malcolm
2024-03-29 17:50 ` Guillaume Gomez
0 siblings, 1 reply; 4+ messages in thread
From: David Malcolm @ 2024-03-29 17:48 UTC (permalink / raw)
To: Guillaume Gomez, gcc-patches, jit, Antoni
On Thu, 2024-03-28 at 23:47 +0100, Guillaume Gomez wrote:
> Hi,
>
> Here's a little fix to allow the `gcc_jit_type_get_size` function to
> work on pointer types as well.
>
Thanks, looks good to me.
Are you able to push this, or do you want me to?
Dave
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Allow `gcc_jit_type_get_size` to work with pointers
2024-03-29 17:48 ` David Malcolm
@ 2024-03-29 17:50 ` Guillaume Gomez
2024-03-29 19:10 ` Guillaume Gomez
0 siblings, 1 reply; 4+ messages in thread
From: Guillaume Gomez @ 2024-03-29 17:50 UTC (permalink / raw)
To: David Malcolm; +Cc: gcc-patches, jit, Antoni
I can push it. Thanks for the (very quick) review!
Le ven. 29 mars 2024 à 18:48, David Malcolm <dmalcolm@redhat.com> a écrit :
>
> On Thu, 2024-03-28 at 23:47 +0100, Guillaume Gomez wrote:
> > Hi,
> >
> > Here's a little fix to allow the `gcc_jit_type_get_size` function to
> > work on pointer types as well.
> >
> Thanks, looks good to me.
>
> Are you able to push this, or do you want me to?
>
> Dave
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Allow `gcc_jit_type_get_size` to work with pointers
2024-03-29 17:50 ` Guillaume Gomez
@ 2024-03-29 19:10 ` Guillaume Gomez
0 siblings, 0 replies; 4+ messages in thread
From: Guillaume Gomez @ 2024-03-29 19:10 UTC (permalink / raw)
To: David Malcolm; +Cc: gcc-patches, jit, Antoni
Pushed as commit 4c18ace1cb69a31af4ac719850a66de79ed12e93.
Le ven. 29 mars 2024 à 18:50, Guillaume Gomez
<guillaume1.gomez@gmail.com> a écrit :
>
> I can push it. Thanks for the (very quick) review!
>
> Le ven. 29 mars 2024 à 18:48, David Malcolm <dmalcolm@redhat.com> a écrit :
> >
> > On Thu, 2024-03-28 at 23:47 +0100, Guillaume Gomez wrote:
> > > Hi,
> > >
> > > Here's a little fix to allow the `gcc_jit_type_get_size` function to
> > > work on pointer types as well.
> > >
> > Thanks, looks good to me.
> >
> > Are you able to push this, or do you want me to?
> >
> > Dave
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-03-29 19:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-28 22:47 [PATCH] Allow `gcc_jit_type_get_size` to work with pointers Guillaume Gomez
2024-03-29 17:48 ` David Malcolm
2024-03-29 17:50 ` Guillaume Gomez
2024-03-29 19:10 ` Guillaume Gomez
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).