blob: 482a74c3de0bfb9f82af4f4023ee895154078243 [file] [log] [blame]
Uday Bondhugulacf4f4c42018-09-12 10:21:23 -07001//===- LoopAnalysis.h - loop analysis methods -------------------*- C++ -*-===//
2//
3// Copyright 2019 The MLIR Authors.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16// =============================================================================
17//
18// This header file defines prototypes for methods to analyze loops.
19//
20//===----------------------------------------------------------------------===//
21
22#ifndef MLIR_ANALYSIS_LOOP_ANALYSIS_H
23#define MLIR_ANALYSIS_LOOP_ANALYSIS_H
24
25#include "llvm/ADT/Optional.h"
26
27namespace mlir {
28
29class AffineExpr;
30class ForStmt;
31
32/// Returns the trip count of the loop as an affine expression if the latter is
33/// expressible as an affine expression, and nullptr otherwise. The trip count
34/// expression is simplified before returning.
35AffineExpr *getTripCount(const ForStmt &forStmt);
36
37/// Returns the trip count of the loop if it's a constant, None otherwise. This
38/// uses affine expression analysis and is able to determine constant trip count
39/// in non-trivial cases.
40llvm::Optional<uint64_t> getConstantTripCount(const ForStmt &forStmt);
41
42/// Returns the greatest known integral divisor of the trip count. Affine
43/// expression analysis is used (indirectly through getTripCount), and
44/// this method is thus able to determine non-trivial divisors.
45uint64_t getLargestDivisorOfTripCount(const ForStmt &forStmt);
46
47} // end namespace mlir
48
49#endif // MLIR_ANALYSIS_LOOP_ANALYSIS_H