MLIR  20.0.0git
Transforms.h
Go to the documentation of this file.
1 //===- Transforms.h - Arith Transforms --------------------------*- 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_ARITH_TRANSFORMS_TRANSFORMS_H
10 #define MLIR_DIALECT_ARITH_TRANSFORMS_TRANSFORMS_H
11 
13 
14 namespace mlir {
15 class Location;
16 class OpBuilder;
17 class OpFoldResult;
18 class Value;
19 
20 namespace presburger {
21 enum class BoundType;
22 } // namespace presburger
23 
24 namespace arith {
25 
26 /// Reify a bound for the given variable in terms of SSA values for which
27 /// `stopCondition` is met.
28 ///
29 /// By default, lower/equal bounds are closed and upper bounds are open. If
30 /// `closedUB` is set to "true", upper bounds are also closed.
31 FailureOr<OpFoldResult>
32 reifyValueBound(OpBuilder &b, Location loc, presburger::BoundType type,
33  const ValueBoundsConstraintSet::Variable &var,
35  bool closedUB = false);
36 
37 /// Reify a bound for the given index-typed value in terms of SSA values for
38 /// which `stopCondition` is met. If no stop condition is specified, reify in
39 /// terms of the operands of the owner op.
40 ///
41 /// By default, lower/equal bounds are closed and upper bounds are open. If
42 /// `closedUB` is set to "true", upper bounds are also closed.
43 ///
44 /// Example:
45 /// %0 = arith.addi %a, %b : index
46 /// %1 = arith.addi %0, %c : index
47 ///
48 /// * If `stopCondition` evaluates to "true" for %0 and %c, "%0 + %c" is an EQ
49 /// bound for %1.
50 /// * If `stopCondition` evaluates to "true" for %a, %b and %c, "%a + %b + %c"
51 /// is an EQ bound for %1.
52 /// * Otherwise, if the owners of %a, %b or %c do not implement the
53 /// ValueBoundsOpInterface, no bound can be computed.
54 FailureOr<OpFoldResult> reifyIndexValueBound(
55  OpBuilder &b, Location loc, presburger::BoundType type, Value value,
56  ValueBoundsConstraintSet::StopConditionFn stopCondition = nullptr,
57  bool closedUB = false);
58 
59 /// Reify a bound for the specified dimension of the given shaped value in terms
60 /// of SSA values for which `stopCondition` is met. If no stop condition is
61 /// specified, reify in terms of the operands of the owner op.
62 ///
63 /// By default, lower/equal bounds are closed and upper bounds are open. If
64 /// `closedUB` is set to "true", upper bounds are also closed.
65 FailureOr<OpFoldResult> reifyShapedValueDimBound(
66  OpBuilder &b, Location loc, presburger::BoundType type, Value value,
67  int64_t dim,
68  ValueBoundsConstraintSet::StopConditionFn stopCondition = nullptr,
69  bool closedUB = false);
70 
71 } // namespace arith
72 } // namespace mlir
73 
74 #endif // MLIR_DIALECT_ARITH_TRANSFORMS_TRANSFORMS_H
std::function< bool(Value, std::optional< int64_t >, ValueBoundsConstraintSet &cstr)> StopConditionFn
The stop condition when traversing the backward slice of a shaped value/ index-type value.
FailureOr< OpFoldResult > reifyValueBound(OpBuilder &b, Location loc, presburger::BoundType type, const ValueBoundsConstraintSet::Variable &var, ValueBoundsConstraintSet::StopConditionFn stopCondition, bool closedUB=false)
Reify a bound for the given variable in terms of SSA values for which stopCondition is met.
FailureOr< OpFoldResult > reifyIndexValueBound(OpBuilder &b, Location loc, presburger::BoundType type, Value value, ValueBoundsConstraintSet::StopConditionFn stopCondition=nullptr, bool closedUB=false)
Reify a bound for the given index-typed value in terms of SSA values for which stopCondition is met.
FailureOr< OpFoldResult > reifyShapedValueDimBound(OpBuilder &b, Location loc, presburger::BoundType type, Value value, int64_t dim, ValueBoundsConstraintSet::StopConditionFn stopCondition=nullptr, bool closedUB=false)
Reify a bound for the specified dimension of the given shaped value in terms of SSA values for which ...
BoundType
The type of bound: equal, lower bound or upper bound.
Include the generated interface declarations.