MLIR 22.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
14namespace mlir {
15class Location;
16class OpBuilder;
17class OpFoldResult;
18class Value;
19
20namespace presburger {
21enum class BoundType;
22} // namespace presburger
23
24namespace 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.
31FailureOr<OpFoldResult>
32reifyValueBound(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.
54FailureOr<OpFoldResult> reifyIndexValueBound(
55 OpBuilder &b, Location loc, presburger::BoundType type, Value value,
56 const 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.
65FailureOr<OpFoldResult> reifyShapedValueDimBound(
66 OpBuilder &b, Location loc, presburger::BoundType type, Value value,
67 int64_t dim,
68 const ValueBoundsConstraintSet::StopConditionFn &stopCondition = nullptr,
69 bool closedUB = false);
70
71} // namespace arith
72} // namespace mlir
73
74#endif // MLIR_DIALECT_ARITH_TRANSFORMS_TRANSFORMS_H
b
Return true if permutation is a valid permutation of the outer_dims_perm (case OuterOrInnerPerm::Oute...
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Definition Location.h:76
This class helps build Operations.
Definition Builders.h:207
This class represents a single result from folding an operation.
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.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Definition Value.h:96
FailureOr< OpFoldResult > reifyShapedValueDimBound(OpBuilder &b, Location loc, presburger::BoundType type, Value value, int64_t dim, const 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 ...
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, const 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.
BoundType
The type of bound: equal, lower bound or upper bound.
Include the generated interface declarations.