summaryrefslogtreecommitdiff
path: root/include/linalg1/Analysis.h
blob: ef8fb9888d9e0c9c1aa7f914cf6f776532b0a3c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//===- Analysis.h - Linalg dialect Analysis function definitions ----------===//
//
// Copyright 2019 The MLIR Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =============================================================================

#ifndef LINALG1_ANALYSIS_H_
#define LINALG1_ANALYSIS_H_

#include "mlir/Support/LLVM.h"

namespace mlir {
class Value;
} // namespace mlir

namespace linalg {
class ViewOp;

/// Walks the chain of SliceOp until the unique base ViewOp.
ViewOp getViewBaseViewOp(mlir::Value *view);

/// Walks the chain of SliceOp until the unique base ViewOp and returns the
/// MemRef upon which the ViewOp is laid.
mlir::Value *getViewSupportingMemRef(mlir::Value *view);

/// Extract the indexing from the root ViewOp that this slice constrins along
/// `dim`. To achieve this, it walks back the chain of SliceOp and determine the
/// first slice that constrains `dim`.
/// Note that the dimension in the original ViewOp may shift due to
/// rank-reducing operations.
/// Returns a pair, with the indexing as the first element and the actual
/// dimension, in the root ViewOp, as the second element.
std::pair<mlir::Value *, unsigned> getViewRootIndexing(mlir::Value *view,
                                                       unsigned dim);

} // namespace linalg

#endif // LINALG1_ANALYSIS_H_