1 //===- AffineToStandard.h - Convert Affine to Standard 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_CONVERSION_AFFINETOSTANDARD_AFFINETOSTANDARD_H 10 #define MLIR_CONVERSION_AFFINETOSTANDARD_AFFINETOSTANDARD_H 11 12 #include "mlir/Support/LLVM.h" 13 14 namespace mlir { 15 class Location; 16 class OpBuilder; 17 class Pass; 18 class RewritePattern; 19 class RewritePatternSet; 20 class Value; 21 class ValueRange; 22 23 namespace affine { 24 class AffineForOp; 25 } // namespace affine 26 27 #define GEN_PASS_DECL_CONVERTAFFINETOSTANDARD 28 #include "mlir/Conversion/Passes.h.inc" 29 30 /// Collect a set of patterns to convert from the Affine dialect to the Standard 31 /// dialect, in particular convert structured affine control flow into CFG 32 /// branch-based control flow. 33 void populateAffineToStdConversionPatterns(RewritePatternSet &patterns); 34 35 /// Collect a set of patterns to convert vector-related Affine ops to the Vector 36 /// dialect. 37 void populateAffineToVectorConversionPatterns(RewritePatternSet &patterns); 38 39 /// Emit code that computes the lower bound of the given affine loop using 40 /// standard arithmetic operations. 41 Value lowerAffineLowerBound(affine::AffineForOp op, OpBuilder &builder); 42 43 /// Emit code that computes the upper bound of the given affine loop using 44 /// standard arithmetic operations. 45 Value lowerAffineUpperBound(affine::AffineForOp op, OpBuilder &builder); 46 47 /// Lowers affine control flow operations (ForStmt, IfStmt and AffineApplyOp) 48 /// to equivalent lower-level constructs (flow of basic blocks and arithmetic 49 /// primitives). 50 std::unique_ptr<Pass> createLowerAffinePass(); 51 52 } // namespace mlir 53 54 #endif // MLIR_CONVERSION_AFFINETOSTANDARD_AFFINETOSTANDARD_H 55