MLIR 22.0.0git
Dialect.cpp
Go to the documentation of this file.
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
11
12using namespace mlir;
13using namespace mlir::pdll::ods;
14
15//===----------------------------------------------------------------------===//
16// Dialect
17//===----------------------------------------------------------------------===//
18
19Dialect::Dialect(StringRef name) : name(name.str()) {}
20Dialect::~Dialect() = default;
21
22std::pair<Operation *, bool>
23Dialect::insertOperation(StringRef name, StringRef summary, StringRef desc,
24 StringRef nativeClassName,
25 bool supportsResultTypeInferrence, llvm::SMLoc loc) {
26 std::unique_ptr<Operation> &operation = operations[name];
27 if (operation)
28 return std::make_pair(&*operation, /*wasInserted*/ false);
29
30 operation.reset(new Operation(name, summary, desc, nativeClassName,
31 supportsResultTypeInferrence, loc));
32 return std::make_pair(&*operation, /*wasInserted*/ true);
33}
34
35Operation *Dialect::lookupOperation(StringRef name) const {
36 auto it = operations.find(name);
37 return it != operations.end() ? it->second.get() : nullptr;
38}
virtual ~Dialect()
Dialect(StringRef name, MLIRContext *context, TypeID id)
The constructor takes a unique namespace for this dialect as well as the context to bind to.
Definition Dialect.cpp:35
Operation * lookupOperation(StringRef name) const
Lookup an operation registered with the given name, or null if no operation with that name is registe...
Definition Dialect.cpp:35
std::pair< Operation *, bool > insertOperation(StringRef name, StringRef summary, StringRef desc, StringRef nativeClassName, bool supportsResultTypeInferrence, SMLoc loc)
Insert a new operation with the dialect.
Definition Dialect.cpp:23
This class provides an ODS representation of a specific operation.
Definition Operation.h:125
Include the generated interface declarations.