calyxir / calyx

Intermediate Language (IL) for Hardware Accelerator Generators
https://calyxir.org
MIT License
460 stars 47 forks source link

eDSL: Superior NameGen #2153

Open anshumanmohan opened 2 weeks ago

anshumanmohan commented 2 weeks ago

The eDSL currently does a quick and dirty job when it comes to name generation.

It maintains a counter starting at 0, and every time it needs to makes a new name for a cell, it does something like {the_op_in_question}_{counter++}. This is why end up with things like reg_0, add_1, mult_2, etc.

The true solution is something akin to what Calyx itself does:

https://github.com/calyxir/calyx/blob/6f895a1353020ce254860c3aa0fcfa2ba1abf4c4/calyx-utils/src/namegenerator.rs#L7-L10

It actually tracks existing names and avoids clashes. Let's eventually upgrade the eDSL to something like this.

_Originally posted by @anshumanmohan in https://github.com/calyxir/calyx/pull/2152#discussion_r1643119305_

ethanuppal commented 2 weeks ago

@rachitnigam, I'm curious why name_hash isn't used additionally to store whether the name has been defined, this task delegated to a separate HashSet? It doesn't seem hard to remove generated_names and keep the same functionality. That being said, it's not important.