MLIR  16.0.0git
BufferViewFlowAnalysis.h
Go to the documentation of this file.
1 //===- BufferViewFlowAnalysis.h - Buffer dependency analysis ---*- 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_DIALECT_BUFFERIZATION_TRANSFORMS_BUFFERVIEWFLOWANALYSIS_H
10 #define MLIR_DIALECT_BUFFERIZATION_TRANSFORMS_BUFFERVIEWFLOWANALYSIS_H
11 
12 #include "mlir/IR/Operation.h"
13 #include "llvm/ADT/SmallPtrSet.h"
14 
15 namespace mlir {
16 
17 /// A straight-forward alias analysis which ensures that all dependencies of all
18 /// values will be determined. This is a requirement for the BufferPlacement
19 /// class since you need to determine safe positions to place alloc and
20 /// deallocs. This alias analysis only finds aliases that might have been
21 /// created on top of the specified view. To find all aliases, resolve the
22 /// intial alloc/argument value.
24 public:
27 
28  /// Constructs a new alias analysis using the op provided.
30 
31  /// Find all immediate dependencies this value could potentially have.
32  ValueMapT::const_iterator find(Value value) const {
33  return dependencies.find(value);
34  }
35 
36  /// Returns the begin iterator to iterate over all dependencies.
37  ValueMapT::const_iterator begin() const { return dependencies.begin(); }
38 
39  /// Returns the end iterator that can be used in combination with find.
40  ValueMapT::const_iterator end() const { return dependencies.end(); }
41 
42  /// Find all immediate and indirect views upon this value. This will find all
43  /// dependencies on this value that can potentially be later in the execution
44  /// of the program, but will not return values that this alias might have been
45  /// created from (such as if the value is created by a subview, this will not
46  /// return the parent view if there is no cyclic behavior). Note that the
47  /// resulting set will also contain the value provided as it is an alias of
48  /// itself.
49  ///
50  /// A = *
51  /// B = subview(A)
52  /// C = B
53  ///
54  /// Results in resolve(B) returning {B, C}
56 
57  /// Removes the given values from all alias sets.
58  void remove(const SmallPtrSetImpl<Value> &aliasValues);
59 
60 private:
61  /// This function constructs a mapping from values to its immediate
62  /// dependencies.
63  void build(Operation *op);
64 
65  /// Maps values to all immediate dependencies this value can have.
66  ValueMapT dependencies;
67 };
68 
69 } // namespace mlir
70 
71 #endif // MLIR_DIALECT_BUFFERIZATION_TRANSFORMS_BUFFERVIEWFLOWANALYSIS_H
ValueMapT::const_iterator begin() const
Returns the begin iterator to iterate over all dependencies.
Include the generated interface declarations.
Operation is a basic unit of execution within MLIR.
Definition: Operation.h:28
ValueMapT::const_iterator end() const
Returns the end iterator that can be used in combination with find.
A straight-forward alias analysis which ensures that all dependencies of all values will be determine...
ValueSetT resolve(Value value) const
Find all immediate and indirect views upon this value.
static constexpr const bool value
BufferViewFlowAnalysis(Operation *op)
Constructs a new alias analysis using the op provided.
ValueMapT::const_iterator find(Value value) const
Find all immediate dependencies this value could potentially have.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Definition: Value.h:85