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

[FIRRTL] Add list concatenation operation. #7486

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions include/circt/Dialect/FIRRTL/FIRRTLExpressions.td
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,23 @@ def ListCreateOp : FIRRTLOp<"list.create", [Pure, SameTypeOperands]> {
let hasVerifier = 1;
}

def ListConcatOp : FIRRTLOp<"list.concat", [Pure, SameOperandsAndResultType]> {
mikeurbach marked this conversation as resolved.
Show resolved Hide resolved
let summary = "Concatenate multiple lists to produce a new list";
let description = [{
Produces a value of list type by concatenating the provided lists.

Example:
```mlir
%3 = firrtl.list.concat %0, %1, %2 : !firrtl.list<string>
```
}];

let arguments = (ins Variadic<ListType>:$subLists);
let results = (outs ListType:$result);

let assemblyFormat = "$subLists attr-dict `:` type($result)";
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be neat to give this a folder in the future for IR simplification (and use w/IMCP) but that can come later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could be interesting! I think there are lot of interesting optimizations we could explore on properties.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah just thinking about cleaning up the trivial stuff that literally constant-folds. I'm not sure we're likely to feed this constants at first/soon and yep lots of interesting things for sure! Look forward to it, LMK if want some assistance!

Looks like integer ops have issues filed for adding folders there, but quick check on some internal usage suggests these wouldn't help much just yet anyway.

Anyway stray thought, GLHF!

}

def BoolConstantOp : FIRRTLOp<"bool", [Pure, ConstantLike]> {
let summary = "Produce a constant boolean value";
let description = [{
Expand Down
16 changes: 16 additions & 0 deletions test/Dialect/FIRRTL/round-trip.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,20 @@ firrtl.module @PropertyArithmetic() {
%4 = firrtl.integer.shr %0, %1 : (!firrtl.integer, !firrtl.integer) -> !firrtl.integer
}

// CHECK-LABEL: firrtl.module @PropertyListOps
firrtl.module @PropertyListOps() {
%0 = firrtl.integer 0
%1 = firrtl.integer 1
%2 = firrtl.integer 2

// CHECK: [[L0:%.+]] = firrtl.list.create %0, %1
%l0 = firrtl.list.create %0, %1 : !firrtl.list<integer>

// CHECK: [[L1:%.+]] = firrtl.list.create %2
%l1 = firrtl.list.create %2 : !firrtl.list<integer>

// CHECK: firrtl.list.concat [[L0]], [[L1]] : !firrtl.list<integer>
%concat = firrtl.list.concat %l0, %l1 : !firrtl.list<integer>
}

}
Loading