MLIR  19.0.0git
OptUtils.h
Go to the documentation of this file.
1 //===- OptUtils.h - MLIR Execution Engine opt pass 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 file declares the utility functions to trigger LLVM optimizations from
10 // MLIR Execution Engine.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef MLIR_EXECUTIONENGINE_OPTUTILS_H
15 #define MLIR_EXECUTIONENGINE_OPTUTILS_H
16 
17 #include <functional>
18 #include <string>
19 
20 namespace llvm {
21 class Module;
22 class Error;
23 class TargetMachine;
24 } // namespace llvm
25 
26 namespace mlir {
27 
28 /// Create a module transformer function for MLIR ExecutionEngine that runs
29 /// LLVM IR passes corresponding to the given speed and size optimization
30 /// levels (e.g. -O2 or -Os). If not null, `targetMachine` is used to
31 /// initialize passes that provide target-specific information to the LLVM
32 /// optimizer. `targetMachine` must outlive the returned std::function.
33 std::function<llvm::Error(llvm::Module *)>
34 makeOptimizingTransformer(unsigned optLevel, unsigned sizeLevel,
35  llvm::TargetMachine *targetMachine);
36 
37 } // namespace mlir
38 
39 #endif // MLIR_EXECUTIONENGINE_OPTUTILS_H
@ Error
Include the generated interface declarations.
Definition: CallGraph.h:229
Include the generated interface declarations.
std::function< llvm::Error(llvm::Module *)> makeOptimizingTransformer(unsigned optLevel, unsigned sizeLevel, llvm::TargetMachine *targetMachine)
Create a module transformer function for MLIR ExecutionEngine that runs LLVM IR passes corresponding ...