llvm / llvm/circt

[FIRRTL] ConstCast: cast aggregates instead of ground elements of aggregates?

Open
#5,334 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

ConstCast nicely supports aggregate types, but presently we only const-cast individual leaves of aggregates, even when a higher-level const cast could do the trick.

Sample input:

circuit ConstAgg:
  module ConstAgg:
    input x: const { a: UInt<1>[100] }
    output y: { a: UInt<1>[100] }

    y <= x

Running with --preserve-aggregate=all --scalarize-top-module=false, we const-cast + connect each of the 100 individual elements.

This is done for uninferred reset/width casts, as they do not support aggregate types (yet?).

It'd be nice to emit the higher-level constcast directly, to preserve aggregates, if possible to do without excessive recursive checking.

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

Locate the FIRRTL ConstCast implementation and reproduce the sample with --preserve-aggregate=all and --scalarize-top-module=false. Compare the current per-leaf casts with the desired aggregate-level cast; done means preserving the aggregate while retaining correct behavior for uninferred reset/width casts.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.