Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 11 additions & 0 deletions mlir/test/lib/Dialect/Test/TestOpDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1637,3 +1637,14 @@ test::TestCreateTensorOp::getBufferType(

return convertTensorToBuffer(getOperation(), options, type);
}

// Define a custom builder for ManyRegionsOp declared in TestOps.td.
// OpBuilder<(ins "::std::unique_ptr<::mlir::Region>":$firstRegion,
// "::std::unique_ptr<::mlir::Region>":$secondRegion)>
void test::ManyRegionsOp::build(
mlir::OpBuilder &builder, mlir::OperationState &state,
llvm::SmallVectorImpl<std::unique_ptr<mlir::Region>> &&regions) {
for (auto &&regionPtr : std::move(regions))
state.addRegion(std::move(regionPtr));
ManyRegionsOp::build(builder, state, {}, regions.size());
}
18 changes: 18 additions & 0 deletions mlir/test/lib/Dialect/Test/TestOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -2352,6 +2352,24 @@ def IsolatedGraphRegionOp : TEST_Op<"isolated_graph_region", [
let assemblyFormat = "attr-dict-with-keyword $region";
}

def ManyRegionsOp : TEST_Op<"many_regions", []> {
let summary = "operation created with move-only objects";
let description = [{
Test op with multiple regions with a `create` function that
takes parameters containing move-only objects.
}];

let regions = (region VariadicRegion<AnyRegion>:$regions);
let builders =
[OpBuilder<(ins "::std::unique_ptr<::mlir::Region>":$singleRegion), [{
$_state.addRegion(std::move(singleRegion));
build($_builder, $_state, {}, /*regionsCount=*/1);
}]>,
// Define in TestOps.cpp.
OpBuilder<(ins "::llvm::SmallVectorImpl<::std::unique_ptr<::mlir::"
"Region>>&&":$regions)>];
}

def AffineScopeOp : TEST_Op<"affine_scope", [AffineScope]> {
let summary = "affine scope operation";
let description = [{
Expand Down
Loading