Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HW][circt-synth] Implement AggregateToComb pass and add to circt-synth pipeline #8068

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

uenoku
Copy link
Member

@uenoku uenoku commented Jan 12, 2025

This PR adds a new pass HWAggregateToComb that lowers array operations to comb operations. The pass converts:

  • hw.array_get to a mux tree using comb operations
  • hw.array_create and hw.array_concat to comb.concat
  • hw.aggregate_constant to comb.concat of individual constants

The PR also moves two utility functions from CombToAIG to the Comb dialect:

  • extractBits: Extracts individual bits from a value
  • constructMuxTree: Builds a multiplexer tree from selectors and leaf nodes

The pass is required to run before CombToAIG to ensure array operations are
properly lowered to AIG. Strictly speaking other than array_get operations can be preserved
but array values prevent optimizations at AIG level. So for the simplicity, I think it's reasonable
to lower array operations within circt-synth pipeline.

I currently added the pass under HW/Transforms considering FlattenIO is very similar but the pass might better belong to Conversion.

@maerhart
Copy link
Member

Would it make sense to have aggregate to comb lowering in a separate pass? To me, it seems like it could also be useful outside of the AIG lowering path.

@uenoku
Copy link
Member Author

uenoku commented Jan 13, 2025

Would it make sense to have aggregate to comb lowering in a separate pass?

Generally yes, I agree. One concern is that the lowering pattern for HWArrayGetOpConversion might be too low-level for general use case. ArrayGet is lowered into mux-chains for each selector bits but some downstream pass might prefer chains of comb.icmp. Anyway I think having HWAggregateToComb looks great.

Base automatically changed from dev/hidetou/shift to main January 14, 2025 18:48
@uenoku uenoku force-pushed the dev/hidetou/array branch from 592f785 to b43e6f8 Compare January 15, 2025 09:20
@uenoku uenoku requested a review from darthscsi as a code owner January 15, 2025 09:20
@uenoku uenoku force-pushed the dev/hidetou/array branch from b43e6f8 to abb9d77 Compare January 15, 2025 09:21
@uenoku uenoku changed the title [CombToAIG] Implement ArrayGet/ArrayCreate/AggregateConst lowering [HW][circt-synth] Implement AggregateToComb pass and add to circt-syinth pipeline Jan 15, 2025
@uenoku uenoku requested a review from maerhart January 15, 2025 09:31
#include "circt/Dialect/HW/HWPasses.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/DialectConversion.h"
#include "llvm/ADT/TypeSwitch.h"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary include

@uenoku uenoku changed the title [HW][circt-synth] Implement AggregateToComb pass and add to circt-syinth pipeline [HW][circt-synth] Implement AggregateToComb pass and add to circt-synth pipeline Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants