fabianschuiki / moore

A hardware compiler based on LLHD and CIRCT
http://www.llhd.io
Apache License 2.0
243 stars 31 forks source link

Add query derive attribute for equality-by-pointer #214

Open fabianschuiki opened 3 years ago

fabianschuiki commented 3 years ago

There are a lot of variants of Ref(node): Ref<'a, ast::Expr<'a>> scattered around the queries. This makes them hard to read, and annoying to work with.

Make #[moore_derive::query] recognize a #[ptr_eq] attribute (or similar), which wraps the given argument in a Ref-like structure that performs equality/hashing by pointer address. The long-term goal would be to never see Ref<...> again in the code :smiley: .

An alternative would be to require all query arguments to implement a QueryArg trait, which has a corresponding function for deriving lookup keys. This would likely be the most transparent implementation.