libgccjit: Allow comparing array types
Checks
Commit Message
Hi.
This patch allows comparing different instances of array types as
equal.
Thanks for the review.
Comments
On Fri, 2024-01-19 at 16:55 -0500, Antoni Boucher wrote:
> Hi.
> This patch allows comparing different instances of array types as
> equal.
> Thanks for the review.
Thanks; the patch looks good to me.
Dave
Thanks.
Can we please agree on some wording to use so I know when the patch can
be pushed. Especially since we're now in stage 4, it would help me if
you say something like "you can push to master".
Regards.
On Wed, 2024-01-24 at 12:14 -0500, David Malcolm wrote:
> On Fri, 2024-01-19 at 16:55 -0500, Antoni Boucher wrote:
> > Hi.
> > This patch allows comparing different instances of array types as
> > equal.
> > Thanks for the review.
>
> Thanks; the patch looks good to me.
>
> Dave
>
David: Ping.
On Thu, 2024-01-25 at 07:52 -0500, Antoni Boucher wrote:
> Thanks.
> Can we please agree on some wording to use so I know when the patch
> can
> be pushed. Especially since we're now in stage 4, it would help me if
> you say something like "you can push to master".
> Regards.
>
> On Wed, 2024-01-24 at 12:14 -0500, David Malcolm wrote:
> > On Fri, 2024-01-19 at 16:55 -0500, Antoni Boucher wrote:
> > > Hi.
> > > This patch allows comparing different instances of array types as
> > > equal.
> > > Thanks for the review.
> >
> > Thanks; the patch looks good to me.
> >
> > Dave
> >
>
From ef4afd9de440f10502f3cc84b2112cf83cde2610 Mon Sep 17 00:00:00 2001
From: Antoni Boucher <bouanto@zoho.com>
Date: Tue, 2 Jan 2024 16:04:10 -0500
Subject: [PATCH] libgccjit: Allow comparing array types
gcc/jit/ChangeLog:
* jit-common.h: Add array_type class.
* jit-recording.h (type::dyn_cast_array_type,
memento_of_get_aligned::dyn_cast_array_type,
array_type::dyn_cast_array_type, array_type::is_same_type_as):
New methods.
gcc/testsuite/ChangeLog:
* jit.dg/test-types.c: Add array type comparison to the test.
---
gcc/jit/jit-common.h | 1 +
gcc/jit/jit-recording.h | 17 +++++++++++++++++
gcc/testsuite/jit.dg/test-types.c | 5 +++++
3 files changed, 23 insertions(+)
@@ -118,6 +118,7 @@ namespace recording {
class struct_;
class union_;
class vector_type;
+ class array_type;
class field;
class bitfield;
class fields;
@@ -545,6 +545,7 @@ public:
virtual function_type *as_a_function_type() { gcc_unreachable (); return NULL; }
virtual struct_ *dyn_cast_struct () { return NULL; }
virtual vector_type *dyn_cast_vector_type () { return NULL; }
+ virtual array_type *dyn_cast_array_type () { return NULL; }
/* Is it typesafe to copy to this type from rtype? */
virtual bool accepts_writes_from (type *rtype)
@@ -810,6 +811,11 @@ public:
void replay_into (replayer *) final override;
+ array_type *dyn_cast_array_type () final override
+ {
+ return m_other_type->dyn_cast_array_type ();
+ }
+
private:
string * make_debug_string () final override;
void write_reproducer (reproducer &r) final override;
@@ -868,6 +874,17 @@ class array_type : public type
type *dereference () final override;
+ bool is_same_type_as (type *other) final override
+ {
+ array_type *other_array_type = other->dyn_cast_array_type ();
+ if (!other_array_type)
+ return false;
+ return m_num_elements == other_array_type->m_num_elements
+ && m_element_type->is_same_type_as (other_array_type->m_element_type);
+ }
+
+ array_type *dyn_cast_array_type () final override { return this; }
+
bool is_int () const final override { return false; }
bool is_float () const final override { return false; }
bool is_bool () const final override { return false; }
@@ -492,4 +492,9 @@ verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
CHECK_VALUE (gcc_jit_type_get_size (gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_FLOAT)), sizeof (float));
CHECK_VALUE (gcc_jit_type_get_size (gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_DOUBLE)), sizeof (double));
+
+ gcc_jit_type *int_type = gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
+ gcc_jit_type *array_type1 = gcc_jit_context_new_array_type (ctxt, NULL, int_type, 2);
+ gcc_jit_type *array_type2 = gcc_jit_context_new_array_type (ctxt, NULL, int_type, 2);
+ CHECK (gcc_jit_compatible_types (array_type1, array_type2));
}
--
2.43.0