MLIR 22.0.0git
IRDLSymbols.cpp
Go to the documentation of this file.
1//===- IRDLSymbols.cpp - IRDL-related symbol logic --------------*- C++ -*-===//
2//
3// This file is licensed 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::irdl;
14
16 Operation *dialectOp = source;
17 while (dialectOp && !isa<DialectOp>(dialectOp))
18 dialectOp = dialectOp->getParentOp();
19
20 if (!dialectOp)
21 llvm_unreachable("symbol lookup near dialect must originate from "
22 "within a dialect definition");
23
24 return dialectOp;
25}
26
29 Operation *source, SymbolRefAttr symbol) {
30 return symbolTable.lookupNearestSymbolFrom(
31 lookupDialectOp(source)->getParentOp(), symbol);
32}
33
35 SymbolRefAttr symbol) {
37 lookupDialectOp(source)->getParentOp(), symbol);
38}
static Operation * lookupDialectOp(Operation *source)
Operation is the basic unit of execution within MLIR.
Definition Operation.h:88
Operation * getParentOp()
Returns the closest surrounding operation that contains this operation or nullptr if this is a top-le...
Definition Operation.h:234
This class represents a collection of SymbolTables.
virtual Operation * lookupNearestSymbolFrom(Operation *from, StringAttr symbol)
Returns the operation registered with the given symbol name within the closest parent operation of,...
static Operation * lookupNearestSymbolFrom(Operation *from, StringAttr symbol)
Returns the operation registered with the given symbol name within the closest parent operation of,...
Operation * lookupSymbolNearDialect(SymbolTableCollection &symbolTable, Operation *source, SymbolRefAttr symbol)
Looks up a symbol from the symbol table containing the source operation's dialect definition operatio...
Include the generated interface declarations.