brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 1757f1d Raw
37 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8//9// This file defines a fake 'test_dyn' dynamic dialect that is used to test the10// registration of dynamic dialects.11//12//===----------------------------------------------------------------------===//13 14#include "mlir/IR/ExtensibleDialect.h"15 16using namespace mlir;17 18namespace test {19void registerTestDynDialect(DialectRegistry &registry) {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 test37