1//===- Dialect.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#include "mlir/Tools/PDLL/ODS/Dialect.h"
10#include "mlir/Tools/PDLL/ODS/Constraint.h"
11#include "mlir/Tools/PDLL/ODS/Operation.h"
12#include "llvm/Support/raw_ostream.h"
13
14using namespace mlir;
15using namespace mlir::pdll::ods;
16
17//===----------------------------------------------------------------------===//
18// Dialect
19//===----------------------------------------------------------------------===//
20
21Dialect::Dialect(StringRef name) : name(name.str()) {}
22Dialect::~Dialect() = default;
23
24std::pair<Operation *, bool>
25Dialect::insertOperation(StringRef name, StringRef summary, StringRef desc,
26 StringRef nativeClassName,
27 bool supportsResultTypeInferrence, llvm::SMLoc loc) {
28 std::unique_ptr<Operation> &operation = operations[name];
29 if (operation)
30 return std::make_pair(x: &*operation, /*wasInserted*/ y: false);
31
32 operation.reset(p: new Operation(name, summary, desc, nativeClassName,
33 supportsResultTypeInferrence, loc));
34 return std::make_pair(x: &*operation, /*wasInserted*/ y: true);
35}
36
37Operation *Dialect::lookupOperation(StringRef name) const {
38 auto it = operations.find(Key: name);
39 return it != operations.end() ? it->second.get() : nullptr;
40}
41

source code of mlir/lib/Tools/PDLL/ODS/Dialect.cpp