FLANG

DoLoopHelper.h
1 //===-- Lower/DoLoopHelper.h -- gen fir.do_loop ops -------------*- 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 FORTRAN_LOWER_DOLOOPHELPER_H
10 #define FORTRAN_LOWER_DOLOOPHELPER_H
11
12 #include "flang/Lower/FIRBuilder.h"
13
14 namespace Fortran::lower {
15
17 class DoLoopHelper {
18 public:
19 explicit DoLoopHelper(FirOpBuilder &builder, mlir::Location loc)
20 : builder(builder), loc(loc) {}
21 DoLoopHelper(const DoLoopHelper &) = delete;
22
24 using BodyGenerator = std::function<void(FirOpBuilder &, mlir::Value)>;
25
28 void createLoop(mlir::Value lb, mlir::Value ub, mlir::Value step,
29 const BodyGenerator &bodyGenerator);
30
32 void createLoop(mlir::Value lb, mlir::Value ub,
33 const BodyGenerator &bodyGenerator);
34
36 void createLoop(mlir::Value count, const BodyGenerator &bodyGenerator);
37
38 private:
39 FirOpBuilder &builder;
40 mlir::Location loc;
41 };
42
43 } // namespace Fortran::lower
44
45 #endif // FORTRAN_LOWER_DOLOOPHELPER_H
Fortran::lower::DoLoopHelper::createLoop
void createLoop(mlir::Value lb, mlir::Value ub, mlir::Value step, const BodyGenerator &bodyGenerator)
Definition: DoLoopHelper.cpp:15
Fortran::lower::DoLoopHelper::BodyGenerator
std::function< void(FirOpBuilder &, mlir::Value)> BodyGenerator
Type of a callback to generate the loop body.
Definition: DoLoopHelper.h:24
Fortran::lower::DoLoopHelper
Helper to build fir.do_loop Ops.
Definition: DoLoopHelper.h:17
Fortran::lower::FirOpBuilder
Definition: FIRBuilder.h:39