MLIR  20.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 
12 #include "llvm/Support/raw_ostream.h"
13 
14 using namespace mlir;
15 using namespace mlir::pdll::ods;
16 
17 //===----------------------------------------------------------------------===//
18 // Dialect
19 //===----------------------------------------------------------------------===//
20 
21 Dialect::Dialect(StringRef name) : name(name.str()) {}
22 Dialect::~Dialect() = default;
23 
24 std::pair<Operation *, bool>
25 Dialect::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(&*operation, /*wasInserted*/ false);
31 
32  operation.reset(new Operation(name, summary, desc, nativeClassName,
33  supportsResultTypeInferrence, loc));
34  return std::make_pair(&*operation, /*wasInserted*/ true);
35 }
36 
37 Operation *Dialect::lookupOperation(StringRef name) const {
38  auto it = operations.find(name);
39  return it != operations.end() ? it->second.get() : nullptr;
40 }
This class provides an ODS representation of a specific operation.
Definition: Operation.h:125
Include the generated interface declarations.