Stream: git-cranelift

Topic: cranelift / Issue #1072 Live ranges: remove the cmp! macro


view this post on Zulip GitHub (Jan 10 2020 at 10:36):

bnjbvr commented on Issue #1072:

It's a tiny detail, and it doesn't cause much trouble since it's nicely enclosed, so closing this issue for now.

view this post on Zulip GitHub (Jan 10 2020 at 10:36):

bnjbvr closed Issue #1072:

#1045 introduces a new macro to make comparisons of live ranges easier, according to the ProgramOrder ordering them. This was done to make it easier to read things like "order.cmp(a, b) != Ordering::Less", which means "a is greater or equal than b". The need to invert the meaning makes it hard to grasp what it's doing, and I thought using plain < / > signs made it simpler.

@abrown suggested:

What about just implementing Ord and Eq on ProgramOrder or ExpandedProgramPoint or wherever it is needed so that the <, <=, >, etc. are overloaded and we can just use the operators directly instead of a macro or order.cmp...? It may require adding a method to ProgramOrder but the following seems more clear to me: order.of(to) >= order.of(self.def_begin).

While the former can't be done (since the ProgramOrder uses its own data fields to retrieve the actual position index used in the comparison), the latter with an "order.of" function can be done. See here for an incomplete implementation.

Alternatives


Last updated: Nov 22 2024 at 17:03 UTC