@@ -116,11 +116,28 @@ class OverrideDelayModel : public PlaceDelayModel {
116
116
friend ALWAYS_INLINE bool operator <(const t_override& lhs, const t_override& rhs) {
117
117
const short * left = reinterpret_cast <const short *>(&lhs);
118
118
const short * right = reinterpret_cast <const short *>(&rhs);
119
- return std::lexicographical_compare (left, left + 6 , right, right + 6 );
119
+ constexpr size_t NUM_T_OVERRIDE_MEMBERS = sizeof (t_override) / sizeof (short );
120
+ return std::lexicographical_compare (left, left + NUM_T_OVERRIDE_MEMBERS, right, right + NUM_T_OVERRIDE_MEMBERS);
120
121
}
121
122
};
122
123
123
124
vtr::flat_map2<t_override, float > delay_overrides_;
125
+
126
+ // operator< treats memory layout of t_override as an array of short
127
+ // this requires all members of t_override are shorts and there is no padding between members of t_override
128
+ static_assert (sizeof (t_override) == sizeof (t_override::from_type)
129
+ + sizeof (t_override::to_type)
130
+ + sizeof (t_override::from_class)
131
+ + sizeof (t_override::to_class)
132
+ + sizeof (t_override::delta_x)
133
+ + sizeof (t_override::delta_y),
134
+ " Expect t_override to have a memory layout equivalent to an array of short (no padding)" );
135
+ static_assert (sizeof (t_override::from_type) == sizeof (short ), " Expect all t_override data members to be shorts" );
136
+ static_assert (sizeof (t_override::to_type) == sizeof (short ), " Expect all t_override data members to be shorts" );
137
+ static_assert (sizeof (t_override::from_class) == sizeof (short ), " Expect all t_override data members to be shorts" );
138
+ static_assert (sizeof (t_override::to_class) == sizeof (short ), " Expect all t_override data members to be shorts" );
139
+ static_assert (sizeof (t_override::delta_x) == sizeof (short ), " Expect all t_override data members to be shorts" );
140
+ static_assert (sizeof (t_override::delta_y) == sizeof (short ), " Expect all t_override data members to be shorts" );
124
141
};
125
142
126
143
#endif
0 commit comments