llvm / llvm/circt

[FIRRTL] Need to handle Macro Collision

Open
#6,013 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug FIRRTL
Dominant language
C++
Stars
2.2k
Forks
524
Avg merge
3d 2h
Merged PRs (30d)
46

Description

If a FIRRTL name collides with a macro, the compiler currently crashes. `LowerToHW` and others need to disconnect the symbol creation from the name of the symbol. `sv.macro.decl` already has support for this. It is not used yet.

Consider:

```
FIRRTL version 4.0.0
circuit RANDOM:
module RANDOM:
input clock: Clock
input d: UInt<1>
output q: UInt<1>

reg r: UInt<1>, clock

connect r, d
connect q, r
```

This errors during `LowerToHW` with:

```
:0: error: Referenced macro doesn't exist "ENABLE_INITIAL_MEM_"
:0: note: see current operation: "sv.macro.def"() {format_string = "", macroName = @ENABLE_INITIAL_MEM_, symbols = []} : () -> ()
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the FIRRTL example and tracing the failure in LowerToHW. Read the existing sv.macro.decl support and the related symbol-creation paths; done when a FIRRTL name colliding with a macro no longer causes an invalid macro reference or compiler crash.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.