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