brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 5e4ea50 Raw
39 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "mlir/Tools/PDLL/ODS/Dialect.h"10#include "mlir/Tools/PDLL/ODS/Operation.h"11 12using namespace mlir;13using namespace mlir::pdll::ods;14 15//===----------------------------------------------------------------------===//16// Dialect17//===----------------------------------------------------------------------===//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}39