xref: /llvm-project/mlir/include/mlir/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.h (revision 599c73990532333e62edf8ba19a5302b543f976f)
1 //===- ControlFlowToLLVM.h - ControlFlow to LLVM -----------*- 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 // Define conversions from the ControlFlow dialect to the LLVM IR dialect.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef MLIR_CONVERSION_CONTROLFLOWTOLLVM_CONTROLFLOWTOLLVM_H
14 #define MLIR_CONVERSION_CONTROLFLOWTOLLVM_CONTROLFLOWTOLLVM_H
15 
16 #include <memory>
17 
18 namespace mlir {
19 class DialectRegistry;
20 class LLVMTypeConverter;
21 class RewritePatternSet;
22 class Pass;
23 
24 #define GEN_PASS_DECL_CONVERTCONTROLFLOWTOLLVMPASS
25 #include "mlir/Conversion/Passes.h.inc"
26 
27 namespace cf {
28 
29 /// Collect the patterns to convert from the ControlFlow dialect to LLVM. The
30 /// conversion patterns capture the LLVMTypeConverter by reference meaning the
31 /// references have to remain alive during the entire pattern lifetime.
32 ///
33 /// Note: This function does not populate the default cf.assert lowering. That
34 /// is because some platforms have a custom cf.assert lowering. The default
35 /// lowering can be populated with `populateAssertToLLVMConversionPattern`.
36 void populateControlFlowToLLVMConversionPatterns(
37     const LLVMTypeConverter &converter, RewritePatternSet &patterns);
38 
39 /// Populate the cf.assert to LLVM conversion pattern. If `abortOnFailure` is
40 /// set to false, the program execution continues when a condition is
41 /// unsatisfied.
42 void populateAssertToLLVMConversionPattern(const LLVMTypeConverter &converter,
43                                            RewritePatternSet &patterns,
44                                            bool abortOnFailure = true);
45 
46 void registerConvertControlFlowToLLVMInterface(DialectRegistry &registry);
47 
48 } // namespace cf
49 } // namespace mlir
50 
51 #endif // MLIR_CONVERSION_CONTROLFLOWTOLLVM_CONTROLFLOWTOLLVM_H
52