cucapra / filament

Fearless hardware design
http://filamenthdl.com/
MIT License
141 stars 9 forks source link

Remove dependence on specific `Info`s #462

Open UnsignedByte opened 5 hours ago

UnsignedByte commented 5 hours ago

@ethanuppal has mentioned issues that arise when every info is set to empty. This is something that arises from the info_cast macro defined in info.rs: https://github.com/cucapra/filament/blob/1f9525419ecad50e2ef6c44514939f654c29fc82/crates/ir/src/info.rs#L264-L298 It defines the From trait for infos, which panics if the incorrect info type is found. This is used in certain locations primarily to generate ir::Info::Reasons for constraints (some listed below). These should theoretically just return Info::Empty if either of the parents is missing, rather than panicking, so that we could remove the dependency on info entirely throughout the IR.

We should instead implement TryFrom or instead just directly force the user to use the as_type functions that are already defined.

Non-exhaustive examples

https://github.com/cucapra/filament/blob/1f9525419ecad50e2ef6c44514939f654c29fc82/crates/filament/src/ir_passes/type_check.rs#L28-L36 https://github.com/cucapra/filament/blob/1f9525419ecad50e2ef6c44514939f654c29fc82/crates/filament/src/ir_passes/interval_check.rs#L91-L112

rachitnigam commented 2 hours ago

Hm, some of these are tricky because they are not quite "info" (i.e., optional things that you are allowed to forget)...