Skip to content

Commit

Permalink
Merge pull request #31 from antoyo/fix/aligned-int-comparison
Browse files Browse the repository at this point in the history
Allow comparing aligned int types
  • Loading branch information
antoyo committed Oct 17, 2023
2 parents 42f9055 + 23ac83d commit 5627014
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions gcc/jit/jit-recording.h
Expand Up @@ -593,6 +593,14 @@ class type : public memento

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;
}

Expand All @@ -609,6 +617,7 @@ class type : public memento
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; }
Expand Down Expand Up @@ -672,13 +681,6 @@ class memento_of_get_type : public type
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);
Expand Down Expand Up @@ -882,6 +884,18 @@ class memento_of_get_aligned : public decorated_type
return result;
}

bool is_same_type_as (type *other) final override
{
// TODO: check if outermost alignment is equal?
if (!other->is_aligned ())
{
return m_other_type->is_same_type_as (other);
}
return 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; }

Expand Down

0 comments on commit 5627014

Please sign in to comment.