MLIR  21.0.0git
Utils.h
Go to the documentation of this file.
1 //===- Utils.h - General Func transformation utilities ----*- 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 // This header file defines prototypes for various transformation utilities for
10 // the Func dialect. These are not passes by themselves but are used
11 // either by passes, optimization sequences, or in turn by other transformation
12 // utilities.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef MLIR_DIALECT_FUNC_UTILS_H
17 #define MLIR_DIALECT_FUNC_UTILS_H
18 
19 #include "mlir/IR/PatternMatch.h"
20 #include "llvm/ADT/ArrayRef.h"
21 
22 namespace mlir {
23 
24 namespace func {
25 
26 class FuncOp;
27 class CallOp;
28 
29 /// Creates a new function operation with the same name as the original
30 /// function operation, but with the arguments reordered according to
31 /// the `newArgsOrder` and `newResultsOrder`.
32 /// The `funcOp` operation must have exactly one block.
33 /// Returns the new function operation or failure if `funcOp` doesn't
34 /// have exactly one block.
35 FailureOr<FuncOp>
36 replaceFuncWithNewOrder(RewriterBase &rewriter, FuncOp funcOp,
37  llvm::ArrayRef<unsigned> newArgsOrder,
38  llvm::ArrayRef<unsigned> newResultsOrder);
39 /// Creates a new call operation with the values as the original
40 /// call operation, but with the arguments reordered according to
41 /// the `newArgsOrder` and `newResultsOrder`.
42 CallOp replaceCallOpWithNewOrder(RewriterBase &rewriter, CallOp callOp,
43  llvm::ArrayRef<unsigned> newArgsOrder,
44  llvm::ArrayRef<unsigned> newResultsOrder);
45 
46 } // namespace func
47 } // namespace mlir
48 
49 #endif // MLIR_DIALECT_FUNC_UTILS_H
This class coordinates the application of a rewrite on a set of IR, providing a way for clients to tr...
Definition: PatternMatch.h:358
CallOp replaceCallOpWithNewOrder(RewriterBase &rewriter, CallOp callOp, llvm::ArrayRef< unsigned > newArgsOrder, llvm::ArrayRef< unsigned > newResultsOrder)
Creates a new call operation with the values as the original call operation, but with the arguments r...
FailureOr< FuncOp > replaceFuncWithNewOrder(RewriterBase &rewriter, FuncOp funcOp, llvm::ArrayRef< unsigned > newArgsOrder, llvm::ArrayRef< unsigned > newResultsOrder)
Creates a new function operation with the same name as the original function operation,...
Include the generated interface declarations.