My Project
LoopAnalysis.h
Go to the documentation of this file.
1 //===- LoopAnalysis.h - loop analysis methods -------------------*- C++ -*-===//
2 //
3 // Part of the MLIR 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 header file defines prototypes for methods to analyze loops.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef MLIR_ANALYSIS_LOOP_ANALYSIS_H
14 #define MLIR_ANALYSIS_LOOP_ANALYSIS_H
15 
16 #include "mlir/Support/LLVM.h"
17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/Optional.h"
19 
20 namespace mlir {
21 
22 class AffineExpr;
23 class AffineForOp;
24 class AffineMap;
25 class MemRefType;
26 class NestedPattern;
27 class Operation;
28 class Value;
29 
36 // TODO(mlir-team): this should be moved into 'Transforms/' and be replaced by a
37 // pure analysis method relying on FlatAffineConstraints
38 void buildTripCountMapAndOperands(AffineForOp forOp, AffineMap *map,
39  SmallVectorImpl<Value> *operands);
40 
44 Optional<uint64_t> getConstantTripCount(AffineForOp forOp);
45 
49 uint64_t getLargestDivisorOfTripCount(AffineForOp forOp);
50 
60 DenseSet<Value, DenseMapInfo<Value>>
61 getInvariantAccesses(Value iv, ArrayRef<Value> indices);
62 
63 using VectorizableLoopFun = std::function<bool(AffineForOp)>;
64 
69 bool isVectorizableLoopBody(AffineForOp loop,
70  NestedPattern &vectorTransferMatcher);
71 
77 bool isVectorizableLoopBody(AffineForOp loop, int *memRefDim,
78  NestedPattern &vectorTransferMatcher);
79 
83 // TODO(mlir-team): extend this to check for memory-based dependence
84 // violation when we have the support.
85 bool isInstwiseShiftValid(AffineForOp forOp, ArrayRef<uint64_t> shifts);
86 } // end namespace mlir
87 
88 #endif // MLIR_ANALYSIS_LOOP_ANALYSIS_H
Definition: InferTypeOpInterface.cpp:20
Definition: Attributes.h:129
std::function< bool(AffineForOp)> VectorizableLoopFun
Definition: LoopAnalysis.h:63
Definition: LLVM.h:37
auto map(Fn fun, IterType begin, IterType end) -> SmallVector< typename std::result_of< Fn(decltype(*begin))>::type, 8 >
Map with iterators.
Definition: Functional.h:28
void buildTripCountMapAndOperands(AffineForOp forOp, AffineMap *map, SmallVectorImpl< Value > *operands)
Definition: LoopAnalysis.cpp:35
uint64_t getLargestDivisorOfTripCount(AffineForOp forOp)
Definition: LoopAnalysis.cpp:117
bool isInstwiseShiftValid(AffineForOp forOp, ArrayRef< uint64_t > shifts)
Definition: LoopAnalysis.cpp:355
Definition: NestedMatcher.h:92
Optional< uint64_t > getConstantTripCount(AffineForOp forOp)
Definition: LoopAnalysis.cpp:91
DenseSet< Value, DenseMapInfo< Value > > getInvariantAccesses(Value iv, ArrayRef< Value > indices)
Definition: LoopAnalysis.cpp:191
bool isVectorizableLoopBody(AffineForOp loop, NestedPattern &vectorTransferMatcher)
Definition: LoopAnalysis.cpp:345