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 
12 using namespace mlir;
13 using namespace mlir::pdll::ods;
14 
15 //===----------------------------------------------------------------------===//
16 // Dialect
17 //===----------------------------------------------------------------------===//
18 
19 Dialect::Dialect(StringRef name) : name(name.str()) {}
20 Dialect::~Dialect() = default;
21 
22 std::pair<Operation *, bool>
23 Dialect::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 
35 Operation *Dialect::lookupOperation(StringRef name) const {
36  auto it = operations.find(name);
37  return it != operations.end() ? it->second.get() : nullptr;
38 }
This class provides an ODS representation of a specific operation.
Definition: Operation.h:125
Include the generated interface declarations.