diff options
author | Antoni Boucher <bouanto@zoho.com> | 2024-01-02 16:04:10 -0500 |
---|---|---|
committer | Antoni Boucher <bouanto@zoho.com> | 2024-07-05 10:26:08 -0400 |
commit | 533f807e17034b20c586eeb480c989a42869bb36 (patch) | |
tree | 43c8ad4c41441a845fff6f673aebaaf52c6048f0 /gcc/jit/jit-recording.h | |
parent | 1c314247aab43aaa278ecc51d666f8c5896d8bbb (diff) | |
download | gcc-533f807e17034b20c586eeb480c989a42869bb36.zip gcc-533f807e17034b20c586eeb480c989a42869bb36.tar.gz gcc-533f807e17034b20c586eeb480c989a42869bb36.tar.bz2 |
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.
Diffstat (limited to 'gcc/jit/jit-recording.h')
-rw-r--r-- | gcc/jit/jit-recording.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h index cce25f1..abd4f6f 100644 --- a/gcc/jit/jit-recording.h +++ b/gcc/jit/jit-recording.h @@ -560,6 +560,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) @@ -829,6 +830,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; @@ -895,6 +901,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; } |