Skip to content

[FIRRTL][OM] Add {firrtl,om}.string.concat#9986

Merged
seldridge merged 5 commits intomainfrom
dev/seldridge/string_cat
Mar 20, 2026
Merged

[FIRRTL][OM] Add {firrtl,om}.string.concat#9986
seldridge merged 5 commits intomainfrom
dev/seldridge/string_cat

Conversation

@seldridge
Copy link
Member

Add FIRRTL and OM string concatenation operations. Implement lowering and OM
evaluation.

This PR is structured as a logical series of multiple commits that I am
intending to land via rebase. Please review individually for less overload.

AI-assisted-by: Augment (Sonnet 4.5)

Add a new `firrtl.string.concat` operation to the FIRRTL dialect for
concatenating two string property values.

AI-assisted-by: Augment (Sonnet 4.5)
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
@seldridge seldridge requested a review from darthscsi as a code owner March 20, 2026 06:07
@seldridge seldridge requested review from mikeurbach and uenoku March 20, 2026 06:07
@seldridge seldridge force-pushed the dev/seldridge/string_cat branch from 8792217 to 0a58bfd Compare March 20, 2026 06:12
Add support for `string_concat` parsing and emission.

AI-assisted-by: Augment (Claude Sonnet 4.5)
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Add a new `string.concat` operation to the OM dialect.  This operation
concatenates two string values.

AI-assisted-by: Augment (Sonnet 4.5)
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Add a conversion pattern to lower FIRRTL `StringConcatOp` to OM
`StringConcatOp` in the LowerClasses pass.

AI-assisted-by: Augment (Sonnet 4.5)
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Copy link
Contributor

@fabianschuiki fabianschuiki left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines +189 to +194
%0 = om.constant "Hello, " : !om.string
%1 = om.constant "World" : !om.string
%2 = om.constant "!" : !om.string

// CHECK: om.string.concat %0, %1, %2 : !om.string
%3 = om.string.concat %0, %1, %2 : !om.string
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes me wonder if we'll want some constant folding for these ops at a later point 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah we've done some for the arithmetic ops!

Copy link
Member Author

Choose a reason for hiding this comment

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

I have been thinking the same thing. I can add this in a follow-up.

Copy link
Member Author

Choose a reason for hiding this comment

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

Canonicalizer follow-up: #9997

Copy link
Member

@uenoku uenoku left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@mikeurbach mikeurbach left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks for adding this!

Comment on lines +189 to +194
%0 = om.constant "Hello, " : !om.string
%1 = om.constant "World" : !om.string
%2 = om.constant "!" : !om.string

// CHECK: om.string.concat %0, %1, %2 : !om.string
%3 = om.string.concat %0, %1, %2 : !om.string
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah we've done some for the arithmetic ops!

Implement string concatenation evaluation in the OM evaluator. The
evaluator extracts string attributes from both operands and concatenates
them to produce a new string attribute.

This enables runtime evaluation of string concatenation operations in
the OM dialect.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
@seldridge seldridge force-pushed the dev/seldridge/string_cat branch from 7a6a324 to 73c1e1b Compare March 20, 2026 22:30
@seldridge seldridge merged commit 34e5533 into main Mar 20, 2026
7 checks passed
@seldridge seldridge deleted the dev/seldridge/string_cat branch March 20, 2026 22:48
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.

4 participants