1 //===- TestDynDialect.cpp -------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file defines a fake 'test_dyn' dynamic dialect that is used to test the
10 // registration of dynamic dialects.
12 //===----------------------------------------------------------------------===//
14 #include "mlir/IR/ExtensibleDialect.h"
19 void registerTestDynDialect(DialectRegistry
®istry
) {
20 registry
.insertDynamic(
21 "test_dyn", [](MLIRContext
*ctx
, DynamicDialect
*testDyn
) {
22 auto opVerifier
= [](Operation
*op
) -> LogicalResult
{
23 if (op
->getNumOperands() == 0 && op
->getNumResults() == 1 &&
24 op
->getNumRegions() == 0)
27 "expected a single result, no operands and no regions");
30 auto opRegionVerifier
= [](Operation
*op
) { return success(); };
32 testDyn
->registerDynamicOp(DynamicOpDefinition::get(
33 "one_result", testDyn
, opVerifier
, opRegionVerifier
));