aboutsummaryrefslogtreecommitdiff
path: root/gcc/jit
diff options
context:
space:
mode:
authorAntoni Boucher <bouanto@zoho.com>2023-10-08 09:12:12 -0400
committerAntoni Boucher <bouanto@zoho.com>2024-11-20 11:01:35 -0500
commit16cf1c010dbee4e411f0d1289830bfb6ed5c7807 (patch)
treeaa43b6652cfbe488077abbc717b495e69b1022e6 /gcc/jit
parentede14092bc33e182ee6c811c335bf9aac789d7be (diff)
downloadgcc-16cf1c010dbee4e411f0d1289830bfb6ed5c7807.zip
gcc-16cf1c010dbee4e411f0d1289830bfb6ed5c7807.tar.gz
gcc-16cf1c010dbee4e411f0d1289830bfb6ed5c7807.tar.bz2
libgccjit: Allow comparing aligned int types
gcc/jit/ChangeLog: * jit-common.h: Add forward declaration of memento_of_get_aligned. * jit-recording.h (type::is_same_type_as): Compare integer types. (dyn_cast_aligned_type): New method. (type::is_aligned, memento_of_get_aligned::is_same_type_as, memento_of_get_aligned::is_aligned): new methods. gcc/testsuite/ChangeLog: * jit.dg/test-types.c: Add checks comparing aligned types.
Diffstat (limited to 'gcc/jit')
-rw-r--r--gcc/jit/jit-common.h1
-rw-r--r--gcc/jit/jit-recording.h34
2 files changed, 28 insertions, 7 deletions
diff --git a/gcc/jit/jit-common.h b/gcc/jit/jit-common.h
index 655d94e..6ab9622 100644
--- a/gcc/jit/jit-common.h
+++ b/gcc/jit/jit-common.h
@@ -134,6 +134,7 @@ namespace recording {
class statement;
class extended_asm;
class case_;
+ class memento_of_get_aligned;
class top_level_asm;
/* End of recording types. */
diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h
index 13c2ea7..ab4b0ff 100644
--- a/gcc/jit/jit-recording.h
+++ b/gcc/jit/jit-recording.h
@@ -580,6 +580,7 @@ public:
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; }
+ virtual memento_of_get_aligned *dyn_cast_aligned_type () { return NULL; }
/* Is it typesafe to copy to this type from rtype? */
virtual bool accepts_writes_from (type *rtype)
@@ -590,6 +591,14 @@ public:
virtual bool is_same_type_as (type *other)
{
+ if (is_int ()
+ && other->is_int ()
+ && get_size () == other->get_size ()
+ && is_signed () == other->is_signed ())
+ {
+ /* LHS (this) is an integer of the same size and sign as rtype. */
+ return true;
+ }
return this == other;
}
@@ -607,6 +616,7 @@ public:
virtual type *is_volatile () { return NULL; }
virtual type *is_restrict () { return NULL; }
virtual type *is_const () { return NULL; }
+ virtual type *is_aligned () { return NULL; }
virtual type *is_array () = 0;
virtual struct_ *is_struct () { return NULL; }
virtual bool is_union () const { return false; }
@@ -661,13 +671,6 @@ public:
accept it: */
return true;
}
- } else if (is_int ()
- && rtype->is_int ()
- && get_size () == rtype->get_size ()
- && is_signed () == rtype->is_signed ())
- {
- /* LHS (this) is an integer of the same size and sign as rtype. */
- return true;
}
return type::accepts_writes_from (rtype);
@@ -844,10 +847,27 @@ public:
: decorated_type (other_type),
m_alignment_in_bytes (alignment_in_bytes) {}
+ bool is_same_type_as (type *other) final override
+ {
+ if (!other->is_aligned ())
+ {
+ return m_other_type->is_same_type_as (other);
+ }
+ return m_alignment_in_bytes
+ == other->dyn_cast_aligned_type ()->m_alignment_in_bytes
+ && m_other_type->is_same_type_as (other->is_aligned ());
+ }
+
+ type *is_aligned () final override { return m_other_type; }
+
/* Strip off the alignment, giving the underlying type. */
type *unqualified () final override { return m_other_type; }
void replay_into (replayer *) final override;
+ memento_of_get_aligned *dyn_cast_aligned_type () final override
+ {
+ return this;
+ }
array_type *dyn_cast_array_type () final override
{