Skip to content

Commit 5627014

Browse files
authored
Merge pull request #31 from antoyo/fix/aligned-int-comparison
Allow comparing aligned int types
2 parents 42f9055 + 23ac83d commit 5627014

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

gcc/jit/jit-recording.h

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,14 @@ class type : public memento
593593

594594
virtual bool is_same_type_as (type *other)
595595
{
596+
if (is_int ()
597+
&& other->is_int ()
598+
&& get_size () == other->get_size ()
599+
&& is_signed () == other->is_signed ())
600+
{
601+
/* LHS (this) is an integer of the same size and sign as rtype. */
602+
return true;
603+
}
596604
return this == other;
597605
}
598606

@@ -609,6 +617,7 @@ class type : public memento
609617
virtual type *is_volatile () { return NULL; }
610618
virtual type *is_restrict () { return NULL; }
611619
virtual type *is_const () { return NULL; }
620+
virtual type *is_aligned () { return NULL; }
612621
virtual type *is_array () = 0;
613622
virtual struct_ *is_struct () { return NULL; }
614623
virtual bool is_union () const { return false; }
@@ -672,13 +681,6 @@ class memento_of_get_type : public type
672681
accept it: */
673682
return true;
674683
}
675-
} else if (is_int ()
676-
&& rtype->is_int ()
677-
&& get_size () == rtype->get_size ()
678-
&& is_signed () == rtype->is_signed ())
679-
{
680-
/* LHS (this) is an integer of the same size and sign as rtype. */
681-
return true;
682684
}
683685

684686
return type::accepts_writes_from (rtype);
@@ -882,6 +884,18 @@ class memento_of_get_aligned : public decorated_type
882884
return result;
883885
}
884886

887+
bool is_same_type_as (type *other) final override
888+
{
889+
// TODO: check if outermost alignment is equal?
890+
if (!other->is_aligned ())
891+
{
892+
return m_other_type->is_same_type_as (other);
893+
}
894+
return m_other_type->is_same_type_as (other->is_aligned ());
895+
}
896+
897+
type *is_aligned () final override { return m_other_type; }
898+
885899
/* Strip off the alignment, giving the underlying type. */
886900
type *unqualified () final override { return m_other_type; }
887901

0 commit comments

Comments
 (0)