1 //===- TestDynDialect.cpp -------------------------------------------------===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file defines a fake 'test_dyn' dynamic dialect that is used to test the 10 // registration of dynamic dialects. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #include "mlir/IR/ExtensibleDialect.h" 15 16 using namespace mlir; 17 18 namespace test { registerTestDynDialect(DialectRegistry & registry)19void 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) 25 return success(); 26 return op->emitError( 27 "expected a single result, no operands and no regions"); 28 }; 29 30 auto opRegionVerifier = [](Operation *op) { return success(); }; 31 32 testDyn->registerDynamicOp(DynamicOpDefinition::get( 33 "one_result", testDyn, opVerifier, opRegionVerifier)); 34 }); 35 } 36 } // namespace test 37