MLIR 23.0.0git
Utils.h
Go to the documentation of this file.
1//===- Utils.h - Utils related to the transform dialect ---------*- C++ -*-===//
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
9#ifndef MLIR_DIALECT_TRANSFORM_IR_UTILS_H
10#define MLIR_DIALECT_TRANSFORM_IR_UTILS_H
11
12#include "mlir/Support/LLVM.h"
13
14namespace mlir {
16class Operation;
17template <typename>
18class OwningOpRef;
19
20namespace transform {
21namespace detail {
22
23/// Merge all symbols from `other` into `target`. Both ops need to implement the
24/// `SymbolTable` trait. Operations are moved from `other`, i.e., `other` may be
25/// modified by this function and might not verify after the function returns.
26/// Upon merging, private symbols may be renamed in order to avoid collisions in
27/// the result. Public symbols may not collide, with the exception of
28/// instances of `SymbolOpInterface`, where collisions are allowed if at least
29/// one of the two is external, in which case the other op preserved (or any one
30/// of the two if both are external).
31// TODO: Reconsider cloning individual ops rather than forcing users of the
32// function to clone (or move) `other` in order to improve efficiency.
33// This might primarily make sense if we can also prune the symbols that
34// are merged to a subset (such as those that are actually used).
35LogicalResult mergeSymbolsInto(Operation *target,
36 OwningOpRef<Operation *> other);
37
38/// Verify that the call graph inside `root` contains no cycles. Emit a
39/// diagnostic and return failure if it does.
40LogicalResult verifyNoRecursionInCallGraph(Operation *root);
41
42} // namespace detail
43} // namespace transform
44} // namespace mlir
45
46#endif // MLIR_DIALECT_TRANSFORM_IR_UTILS_H
This class represents a diagnostic that is inflight and set to be reported.
Operation is the basic unit of execution within MLIR.
Definition Operation.h:88
This class acts as an owning reference to an op, and will automatically destroy the held op on destru...
Definition OwningOpRef.h:29
LogicalResult verifyNoRecursionInCallGraph(Operation *root)
Verify that the call graph inside root contains no cycles.
Definition Utils.cpp:83
LogicalResult mergeSymbolsInto(Operation *target, OwningOpRef< Operation * > other)
Merge all symbols from other into target.
Definition Utils.cpp:115
Include the generated interface declarations.