Skip to content

Commit 689c0a4

Browse files
authored
[OM] Add list concatenation operation. (#7487)
This operation produces a list by concatenating lists of the same type. The operation definition and a simple round trip test have been added. This is used to compose lists, which is a key feature to enable hierarchical composition of OM values.
1 parent e672d0e commit 689c0a4

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

include/circt/Dialect/OM/OMOps.td

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,23 @@ def ListCreateOp : OMOp<"list_create", [Pure, SameTypeOperands]> {
207207
let hasCustomAssemblyFormat = 1;
208208
}
209209

210+
def ListConcatOp : OMOp<"list_concat", [Pure, SameOperandsAndResultType]> {
211+
let summary = "Concatenate multiple lists to produce a new list";
212+
let description = [{
213+
Produces a value of list type by concatenating the provided lists.
214+
215+
Example:
216+
```
217+
%3 = om.list_concat %0, %1, %2 : !om.list<string>
218+
```
219+
}];
220+
221+
let arguments = (ins Variadic<ListType>:$subLists);
222+
let results = (outs ListType:$result);
223+
224+
let assemblyFormat = "$subLists attr-dict `:` type($result)";
225+
}
226+
210227
def TupleCreateOp : OMOp<"tuple_create", [Pure, InferTypeOpInterface]> {
211228
let summary = "Create a tuple of values";
212229
let description = [{

test/Dialect/OM/round-trip.mlir

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,22 @@ om.class @ListCreate() {
158158
om.class.field @list_field, %list : !om.list<!om.class.type<@Widget>>
159159
}
160160

161+
// CHECK-LABEL: @ListConcat
162+
om.class @ListConcat() {
163+
%0 = om.constant #om.integer<0 : i8> : !om.integer
164+
%1 = om.constant #om.integer<1 : i8> : !om.integer
165+
%2 = om.constant #om.integer<2 : i8> : !om.integer
166+
167+
// CHECK: [[L0:%.+]] = om.list_create %0, %1
168+
%l0 = om.list_create %0, %1 : !om.integer
169+
170+
// CHECK: [[L1:%.+]] = om.list_create %2
171+
%l1 = om.list_create %2 : !om.integer
172+
173+
// CHECK: om.list_concat [[L0]], [[L1]]
174+
%concat = om.list_concat %l0, %l1 : !om.list<!om.integer>
175+
}
176+
161177
// CHECK-LABEL: @Integer
162178
om.class @IntegerConstant() {
163179
// CHECK: %[[const1:.+]] = om.constant #om.integer<36755551979133953793 : i67> : !om.integer

0 commit comments

Comments
 (0)