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 index-typed value in terms of SSA values for
28 /// which `stopCondition` is met. If no stop condition is specified, reify in
29 /// terms of the operands of the owner op.
30 ///
31 /// By default, lower/equal bounds are closed and upper bounds are open. If
32 /// `closedUB` is set to "true", upper bounds are also closed.
33 ///
34 /// Example:
35 /// %0 = arith.addi %a, %b : index
36 /// %1 = arith.addi %0, %c : index
37 ///
38 /// * If `stopCondition` evaluates to "true" for %0 and %c, "%0 + %c" is an EQ
39 /// bound for %1.
40 /// * If `stopCondition` evaluates to "true" for %a, %b and %c, "%a + %b + %c"
41 /// is an EQ bound for %1.
42 /// * Otherwise, if the owners of %a, %b or %c do not implement the
43 /// ValueBoundsOpInterface, no bound can be computed.
44 FailureOr<OpFoldResult> reifyIndexValueBound(
45  OpBuilder &b, Location loc, presburger::BoundType type, Value value,
46  ValueBoundsConstraintSet::StopConditionFn stopCondition = nullptr,
47  bool closedUB = false);
48 
49 /// Reify a bound for the specified dimension of the given shaped value in terms
50 /// of SSA values for which `stopCondition` is met. If no stop condition is
51 /// specified, reify in terms of the operands of the owner op.
52 ///
53 /// By default, lower/equal bounds are closed and upper bounds are open. If
54 /// `closedUB` is set to "true", upper bounds are also closed.
55 FailureOr<OpFoldResult> reifyShapedValueDimBound(
56  OpBuilder &b, Location loc, presburger::BoundType type, Value value,
57  int64_t dim,
58  ValueBoundsConstraintSet::StopConditionFn stopCondition = nullptr,
59  bool closedUB = false);
60 
61 } // namespace arith
62 } // namespace mlir
63 
64 #endif // MLIR_DIALECT_ARITH_TRANSFORMS_TRANSFORMS_H
function_ref< bool(Value, std::optional< int64_t >)> StopConditionFn
The stop condition when traversing the backward slice of a shaped value/ index-type value.
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.