MLIR  18.0.0git
AffineExpr.h
Go to the documentation of this file.
1 //===- AffineExpr.h - MLIR Affine Expr Class --------------------*- 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 // An affine expression is an affine combination of dimension identifiers and
10 // symbols, including ceildiv/floordiv/mod by a constant integer.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef MLIR_IR_AFFINEEXPR_H
15 #define MLIR_IR_AFFINEEXPR_H
16 
17 #include "mlir/Support/LLVM.h"
18 #include "llvm/ADT/DenseMapInfo.h"
19 #include "llvm/ADT/Hashing.h"
20 #include "llvm/ADT/SmallVector.h"
21 #include "llvm/Support/Casting.h"
22 #include <functional>
23 #include <type_traits>
24 
25 namespace mlir {
26 
27 class MLIRContext;
28 class AffineMap;
29 class IntegerSet;
30 
31 namespace detail {
32 
33 struct AffineExprStorage;
34 struct AffineBinaryOpExprStorage;
35 struct AffineDimExprStorage;
36 struct AffineConstantExprStorage;
37 
38 } // namespace detail
39 
40 enum class AffineExprKind {
41  Add,
42  /// RHS of mul is always a constant or a symbolic expression.
43  Mul,
44  /// RHS of mod is always a constant or a symbolic expression with a positive
45  /// value.
46  Mod,
47  /// RHS of floordiv is always a constant or a symbolic expression.
48  FloorDiv,
49  /// RHS of ceildiv is always a constant or a symbolic expression.
50  CeilDiv,
51 
52  /// This is a marker for the last affine binary op. The range of binary
53  /// op's is expected to be this element and earlier.
55 
56  /// Constant integer.
57  Constant,
58  /// Dimensional identifier.
59  DimId,
60  /// Symbolic identifier.
61  SymbolId,
62 };
63 
64 /// Base type for affine expression.
65 /// AffineExpr's are immutable value types with intuitive operators to
66 /// operate on chainable, lightweight compositions.
67 /// An AffineExpr is an interface to the underlying storage type pointer.
68 class AffineExpr {
69 public:
71 
72  constexpr AffineExpr() {}
73  /* implicit */ AffineExpr(const ImplType *expr)
74  : expr(const_cast<ImplType *>(expr)) {}
75 
76  bool operator==(AffineExpr other) const { return expr == other.expr; }
77  bool operator!=(AffineExpr other) const { return !(*this == other); }
78  bool operator==(int64_t v) const;
79  bool operator!=(int64_t v) const { return !(*this == v); }
80  explicit operator bool() const { return expr; }
81 
82  bool operator!() const { return expr == nullptr; }
83 
84  template <typename U>
85  [[deprecated("Use llvm::isa<U>() instead")]] constexpr bool isa() const;
86 
87  template <typename U>
88  [[deprecated("Use llvm::dyn_cast<U>() instead")]] U dyn_cast() const;
89 
90  template <typename U>
91  [[deprecated("Use llvm::dyn_cast_or_null<U>() instead")]] U
92  dyn_cast_or_null() const;
93 
94  template <typename U>
95  [[deprecated("Use llvm::cast<U>() instead")]] U cast() const;
96 
97  MLIRContext *getContext() const;
98 
99  /// Return the classification for this type.
100  AffineExprKind getKind() const;
101 
102  void print(raw_ostream &os) const;
103  void dump() const;
104 
105  /// Returns true if this expression is made out of only symbols and
106  /// constants, i.e., it does not involve dimensional identifiers.
107  bool isSymbolicOrConstant() const;
108 
109  /// Returns true if this is a pure affine expression, i.e., multiplication,
110  /// floordiv, ceildiv, and mod is only allowed w.r.t constants.
111  bool isPureAffine() const;
112 
113  /// Returns the greatest known integral divisor of this affine expression. The
114  /// result is always positive.
115  int64_t getLargestKnownDivisor() const;
116 
117  /// Return true if the affine expression is a multiple of 'factor'.
118  bool isMultipleOf(int64_t factor) const;
119 
120  /// Return true if the affine expression involves AffineDimExpr `position`.
121  bool isFunctionOfDim(unsigned position) const;
122 
123  /// Return true if the affine expression involves AffineSymbolExpr `position`.
124  bool isFunctionOfSymbol(unsigned position) const;
125 
126  /// Walk all of the AffineExpr's in this expression in postorder.
127  void walk(std::function<void(AffineExpr)> callback) const;
128 
129  /// This method substitutes any uses of dimensions and symbols (e.g.
130  /// dim#0 with dimReplacements[0]) and returns the modified expression tree.
131  /// This is a dense replacement method: a replacement must be specified for
132  /// every single dim and symbol.
134  ArrayRef<AffineExpr> symReplacements) const;
135 
136  /// Dim-only version of replaceDimsAndSymbols.
137  AffineExpr replaceDims(ArrayRef<AffineExpr> dimReplacements) const;
138 
139  /// Symbol-only version of replaceDimsAndSymbols.
140  AffineExpr replaceSymbols(ArrayRef<AffineExpr> symReplacements) const;
141 
142  /// Sparse replace method. Replace `expr` by `replacement` and return the
143  /// modified expression tree.
144  AffineExpr replace(AffineExpr expr, AffineExpr replacement) const;
145 
146  /// Sparse replace method. If `*this` appears in `map` replaces it by
147  /// `map[*this]` and return the modified expression tree. Otherwise traverse
148  /// `*this` and apply replace with `map` on its subexpressions.
150 
151  /// Replace dims[offset ... numDims)
152  /// by dims[offset + shift ... shift + numDims).
153  AffineExpr shiftDims(unsigned numDims, unsigned shift,
154  unsigned offset = 0) const;
155 
156  /// Replace symbols[offset ... numSymbols)
157  /// by symbols[offset + shift ... shift + numSymbols).
158  AffineExpr shiftSymbols(unsigned numSymbols, unsigned shift,
159  unsigned offset = 0) const;
160 
161  AffineExpr operator+(int64_t v) const;
162  AffineExpr operator+(AffineExpr other) const;
163  AffineExpr operator-() const;
164  AffineExpr operator-(int64_t v) const;
165  AffineExpr operator-(AffineExpr other) const;
166  AffineExpr operator*(int64_t v) const;
167  AffineExpr operator*(AffineExpr other) const;
168  AffineExpr floorDiv(uint64_t v) const;
169  AffineExpr floorDiv(AffineExpr other) const;
170  AffineExpr ceilDiv(uint64_t v) const;
171  AffineExpr ceilDiv(AffineExpr other) const;
172  AffineExpr operator%(uint64_t v) const;
173  AffineExpr operator%(AffineExpr other) const;
174 
175  /// Compose with an AffineMap.
176  /// Returns the composition of this AffineExpr with `map`.
177  ///
178  /// Prerequisites:
179  /// `this` and `map` are composable, i.e. that the number of AffineDimExpr of
180  /// `this` is smaller than the number of results of `map`. If a result of a
181  /// map does not have a corresponding AffineDimExpr, that result simply does
182  /// not appear in the produced AffineExpr.
183  ///
184  /// Example:
185  /// expr: `d0 + d2`
186  /// map: `(d0, d1, d2)[s0, s1] -> (d0 + s1, d1 + s0, d0 + d1 + d2)`
187  /// returned expr: `d0 * 2 + d1 + d2 + s1`
188  AffineExpr compose(AffineMap map) const;
189 
190  friend ::llvm::hash_code hash_value(AffineExpr arg);
191 
192  /// Methods supporting C API.
193  const void *getAsOpaquePointer() const {
194  return static_cast<const void *>(expr);
195  }
196  static AffineExpr getFromOpaquePointer(const void *pointer) {
197  return AffineExpr(
198  reinterpret_cast<ImplType *>(const_cast<void *>(pointer)));
199  }
200 
201  ImplType *getImpl() const { return expr; }
202 
203 protected:
204  ImplType *expr{nullptr};
205 };
206 
207 /// Affine binary operation expression. An affine binary operation could be an
208 /// add, mul, floordiv, ceildiv, or a modulo operation. (Subtraction is
209 /// represented through a multiply by -1 and add.) These expressions are always
210 /// constructed in a simplified form. For eg., the LHS and RHS operands can't
211 /// both be constants. There are additional canonicalizing rules depending on
212 /// the op type: see checks in the constructor.
214 public:
216  /* implicit */ AffineBinaryOpExpr(AffineExpr::ImplType *ptr);
217  AffineExpr getLHS() const;
218  AffineExpr getRHS() const;
219 };
220 
221 /// A dimensional identifier appearing in an affine expression.
222 class AffineDimExpr : public AffineExpr {
223 public:
225  /* implicit */ AffineDimExpr(AffineExpr::ImplType *ptr);
226  unsigned getPosition() const;
227 };
228 
229 /// A symbolic identifier appearing in an affine expression.
230 class AffineSymbolExpr : public AffineExpr {
231 public:
233  /* implicit */ AffineSymbolExpr(AffineExpr::ImplType *ptr);
234  unsigned getPosition() const;
235 };
236 
237 /// An integer constant appearing in affine expression.
239 public:
241  /* implicit */ AffineConstantExpr(AffineExpr::ImplType *ptr = nullptr);
242  int64_t getValue() const;
243 };
244 
245 /// Make AffineExpr hashable.
246 inline ::llvm::hash_code hash_value(AffineExpr arg) {
248 }
249 
250 inline AffineExpr operator+(int64_t val, AffineExpr expr) { return expr + val; }
251 inline AffineExpr operator*(int64_t val, AffineExpr expr) { return expr * val; }
252 inline AffineExpr operator-(int64_t val, AffineExpr expr) {
253  return expr * (-1) + val;
254 }
255 
256 /// These free functions allow clients of the API to not use classes in detail.
257 AffineExpr getAffineDimExpr(unsigned position, MLIRContext *context);
258 AffineExpr getAffineSymbolExpr(unsigned position, MLIRContext *context);
259 AffineExpr getAffineConstantExpr(int64_t constant, MLIRContext *context);
260 SmallVector<AffineExpr> getAffineConstantExprs(ArrayRef<int64_t> constants,
261  MLIRContext *context);
262 AffineExpr getAffineBinaryOpExpr(AffineExprKind kind, AffineExpr lhs,
263  AffineExpr rhs);
264 
265 /// Constructs an affine expression from a flat ArrayRef. If there are local
266 /// identifiers (neither dimensional nor symbolic) that appear in the sum of
267 /// products expression, 'localExprs' is expected to have the AffineExpr
268 /// for it, and is substituted into. The ArrayRef 'eq' is expected to be in the
269 /// format [dims, symbols, locals, constant term].
270 AffineExpr getAffineExprFromFlatForm(ArrayRef<int64_t> flatExprs,
271  unsigned numDims, unsigned numSymbols,
272  ArrayRef<AffineExpr> localExprs,
273  MLIRContext *context);
274 
275 raw_ostream &operator<<(raw_ostream &os, AffineExpr expr);
276 
277 template <typename U>
278 constexpr bool AffineExpr::isa() const {
279  if constexpr (std::is_same_v<U, AffineBinaryOpExpr>)
281  if constexpr (std::is_same_v<U, AffineDimExpr>)
282  return getKind() == AffineExprKind::DimId;
283  if constexpr (std::is_same_v<U, AffineSymbolExpr>)
284  return getKind() == AffineExprKind::SymbolId;
285  if constexpr (std::is_same_v<U, AffineConstantExpr>)
286  return getKind() == AffineExprKind::Constant;
287 }
288 template <typename U>
290  return llvm::dyn_cast<U>(*this);
291 }
292 template <typename U>
294  return llvm::dyn_cast_or_null<U>(*this);
295 }
296 template <typename U>
297 U AffineExpr::cast() const {
298  return llvm::cast<U>(*this);
299 }
300 
301 /// Simplify an affine expression by flattening and some amount of simple
302 /// analysis. This has complexity linear in the number of nodes in 'expr'.
303 /// Returns the simplified expression, which is the same as the input expression
304 /// if it can't be simplified. When `expr` is semi-affine, a simplified
305 /// semi-affine expression is constructed in the sorted order of dimension and
306 /// symbol positions.
307 AffineExpr simplifyAffineExpr(AffineExpr expr, unsigned numDims,
308  unsigned numSymbols);
309 
310 namespace detail {
311 template <int N>
312 void bindDims(MLIRContext *ctx) {}
313 
314 template <int N, typename AffineExprTy, typename... AffineExprTy2>
315 void bindDims(MLIRContext *ctx, AffineExprTy &e, AffineExprTy2 &...exprs) {
316  e = getAffineDimExpr(N, ctx);
317  bindDims<N + 1, AffineExprTy2 &...>(ctx, exprs...);
318 }
319 
320 template <int N>
322 
323 template <int N, typename AffineExprTy, typename... AffineExprTy2>
324 void bindSymbols(MLIRContext *ctx, AffineExprTy &e, AffineExprTy2 &...exprs) {
325  e = getAffineSymbolExpr(N, ctx);
326  bindSymbols<N + 1, AffineExprTy2 &...>(ctx, exprs...);
327 }
328 
329 } // namespace detail
330 
331 /// Bind a list of AffineExpr references to DimExpr at positions:
332 /// [0 .. sizeof...(exprs)]
333 template <typename... AffineExprTy>
334 void bindDims(MLIRContext *ctx, AffineExprTy &...exprs) {
335  detail::bindDims<0>(ctx, exprs...);
336 }
337 
338 template <typename AffineExprTy>
340  int idx = 0;
341  for (AffineExprTy &e : exprs)
342  e = getAffineDimExpr(idx++, ctx);
343 }
344 
345 /// Bind a list of AffineExpr references to SymbolExpr at positions:
346 /// [0 .. sizeof...(exprs)]
347 template <typename... AffineExprTy>
348 void bindSymbols(MLIRContext *ctx, AffineExprTy &...exprs) {
349  detail::bindSymbols<0>(ctx, exprs...);
350 }
351 
352 template <typename AffineExprTy>
354  int idx = 0;
355  for (AffineExprTy &e : exprs)
356  e = getAffineSymbolExpr(idx++, ctx);
357 }
358 
359 /// Get a lower or upper (depending on `isUpper`) bound for `expr` while using
360 /// the constant lower and upper bounds for its inputs provided in
361 /// `constLowerBounds` and `constUpperBounds`. Return std::nullopt if such a
362 /// bound can't be computed. This method only handles simple sum of product
363 /// expressions (w.r.t constant coefficients) so as to not depend on anything
364 /// heavyweight in `Analysis`. Expressions of the form: c0*d0 + c1*d1 + c2*s0 +
365 /// ... + c_n are handled. Expressions involving floordiv, ceildiv, mod or
366 /// semi-affine ones will lead a none being returned.
367 std::optional<int64_t>
368 getBoundForAffineExpr(AffineExpr expr, unsigned numDims, unsigned numSymbols,
369  ArrayRef<std::optional<int64_t>> constLowerBounds,
370  ArrayRef<std::optional<int64_t>> constUpperBounds,
371  bool isUpper);
372 
373 } // namespace mlir
374 
375 namespace llvm {
376 
377 // AffineExpr hash just like pointers
378 template <>
379 struct DenseMapInfo<mlir::AffineExpr> {
381  auto *pointer = llvm::DenseMapInfo<void *>::getEmptyKey();
382  return mlir::AffineExpr(static_cast<mlir::AffineExpr::ImplType *>(pointer));
383  }
386  return mlir::AffineExpr(static_cast<mlir::AffineExpr::ImplType *>(pointer));
387  }
388  static unsigned getHashValue(mlir::AffineExpr val) {
389  return mlir::hash_value(val);
390  }
391  static bool isEqual(mlir::AffineExpr LHS, mlir::AffineExpr RHS) {
392  return LHS == RHS;
393  }
394 };
395 
396 /// Add support for llvm style casts. We provide a cast between To and From if
397 /// From is mlir::AffineExpr or derives from it.
398 template <typename To, typename From>
399 struct CastInfo<To, From,
400  std::enable_if_t<std::is_same_v<mlir::AffineExpr,
401  std::remove_const_t<From>> ||
402  std::is_base_of_v<mlir::AffineExpr, From>>>
404  DefaultDoCastIfPossible<To, From, CastInfo<To, From>> {
405 
406  static inline bool isPossible(mlir::AffineExpr expr) {
407  /// Return a constant true instead of a dynamic true when casting to self or
408  /// up the hierarchy.
409  if constexpr (std::is_base_of_v<To, From>) {
410  return true;
411  } else {
412  if constexpr (std::is_same_v<To, ::mlir::AffineBinaryOpExpr>)
413  return expr.getKind() <= ::mlir::AffineExprKind::LAST_AFFINE_BINARY_OP;
414  if constexpr (std::is_same_v<To, ::mlir::AffineDimExpr>)
415  return expr.getKind() == ::mlir::AffineExprKind::DimId;
416  if constexpr (std::is_same_v<To, ::mlir::AffineSymbolExpr>)
417  return expr.getKind() == ::mlir::AffineExprKind::SymbolId;
418  if constexpr (std::is_same_v<To, ::mlir::AffineConstantExpr>)
419  return expr.getKind() == ::mlir::AffineExprKind::Constant;
420  }
421  }
422  static inline To doCast(mlir::AffineExpr expr) { return To(expr.getImpl()); }
423 };
424 
425 } // namespace llvm
426 
427 #endif // MLIR_IR_AFFINEEXPR_H
Affine binary operation expression.
Definition: AffineExpr.h:213
AffineExpr getLHS() const
Definition: AffineExpr.cpp:317
AffineBinaryOpExpr(AffineExpr::ImplType *ptr)
Definition: AffineExpr.cpp:315
AffineExpr getRHS() const
Definition: AffineExpr.cpp:320
An integer constant appearing in affine expression.
Definition: AffineExpr.h:238
AffineConstantExpr(AffineExpr::ImplType *ptr=nullptr)
Definition: AffineExpr.cpp:598
int64_t getValue() const
Definition: AffineExpr.cpp:600
A dimensional identifier appearing in an affine expression.
Definition: AffineExpr.h:222
AffineDimExpr(AffineExpr::ImplType *ptr)
Definition: AffineExpr.cpp:324
unsigned getPosition() const
Definition: AffineExpr.cpp:325
Base type for affine expression.
Definition: AffineExpr.h:68
static AffineExpr getFromOpaquePointer(const void *pointer)
Definition: AffineExpr.h:196
AffineExpr replaceDimsAndSymbols(ArrayRef< AffineExpr > dimReplacements, ArrayRef< AffineExpr > symReplacements) const
This method substitutes any uses of dimensions and symbols (e.g.
Definition: AffineExpr.cpp:66
AffineExpr shiftDims(unsigned numDims, unsigned shift, unsigned offset=0) const
Replace dims[offset ...
Definition: AffineExpr.cpp:110
ImplType * getImpl() const
Definition: AffineExpr.h:201
AffineExpr operator+(int64_t v) const
Definition: AffineExpr.cpp:741
U dyn_cast_or_null() const
Definition: AffineExpr.h:293
friend ::llvm::hash_code hash_value(AffineExpr arg)
Make AffineExpr hashable.
Definition: AffineExpr.h:246
bool isSymbolicOrConstant() const
Returns true if this expression is made out of only symbols and constants, i.e., it does not involve ...
Definition: AffineExpr.cpp:165
AffineExpr operator*(int64_t v) const
Definition: AffineExpr.cpp:801
constexpr AffineExpr()
Definition: AffineExpr.h:72
bool operator==(AffineExpr other) const
Definition: AffineExpr.h:76
bool isPureAffine() const
Returns true if this is a pure affine expression, i.e., multiplication, floordiv, ceildiv,...
Definition: AffineExpr.cpp:189
AffineExpr shiftSymbols(unsigned numSymbols, unsigned shift, unsigned offset=0) const
Replace symbols[offset ...
Definition: AffineExpr.cpp:122
AffineExpr operator-() const
Definition: AffineExpr.cpp:814
U cast() const
Definition: AffineExpr.h:297
void walk(std::function< void(AffineExpr)> callback) const
Walk all of the AffineExpr's in this expression in postorder.
Definition: AffineExpr.cpp:30
AffineExpr floorDiv(uint64_t v) const
Definition: AffineExpr.cpp:867
ImplType * expr
Definition: AffineExpr.h:204
bool operator!=(int64_t v) const
Definition: AffineExpr.h:79
AffineExprKind getKind() const
Return the classification for this type.
Definition: AffineExpr.cpp:27
bool isMultipleOf(int64_t factor) const
Return true if the affine expression is a multiple of 'factor'.
Definition: AffineExpr.cpp:260
bool operator!() const
Definition: AffineExpr.h:82
int64_t getLargestKnownDivisor() const
Returns the greatest known integral divisor of this affine expression.
Definition: AffineExpr.cpp:220
AffineExpr compose(AffineMap map) const
Compose with an AffineMap.
Definition: AffineExpr.cpp:978
constexpr bool isa() const
Definition: AffineExpr.h:278
bool isFunctionOfDim(unsigned position) const
Return true if the affine expression involves AffineDimExpr position.
Definition: AffineExpr.cpp:293
const void * getAsOpaquePointer() const
Methods supporting C API.
Definition: AffineExpr.h:193
bool isFunctionOfSymbol(unsigned position) const
Return true if the affine expression involves AffineSymbolExpr position.
Definition: AffineExpr.cpp:304
AffineExpr replaceDims(ArrayRef< AffineExpr > dimReplacements) const
Dim-only version of replaceDimsAndSymbols.
Definition: AffineExpr.cpp:99
bool operator!=(AffineExpr other) const
Definition: AffineExpr.h:77
AffineExpr operator%(uint64_t v) const
Definition: AffineExpr.cpp:966
MLIRContext * getContext() const
Definition: AffineExpr.cpp:25
AffineExpr replace(AffineExpr expr, AffineExpr replacement) const
Sparse replace method.
Definition: AffineExpr.cpp:158
AffineExpr replaceSymbols(ArrayRef< AffineExpr > symReplacements) const
Symbol-only version of replaceDimsAndSymbols.
Definition: AffineExpr.cpp:104
AffineExpr(const ImplType *expr)
Definition: AffineExpr.h:73
void dump() const
AffineExpr ceilDiv(uint64_t v) const
Definition: AffineExpr.cpp:910
void print(raw_ostream &os) const
U dyn_cast() const
Definition: AffineExpr.h:289
A multi-dimensional affine map Affine map's are immutable like Type's, and they are uniqued.
Definition: AffineMap.h:47
A symbolic identifier appearing in an affine expression.
Definition: AffineExpr.h:230
AffineSymbolExpr(AffineExpr::ImplType *ptr)
Definition: AffineExpr.cpp:588
unsigned getPosition() const
Definition: AffineExpr.cpp:590
MLIRContext is the top-level object for a collection of MLIR operations.
Definition: MLIRContext.h:60
Include the generated interface declarations.
Definition: CallGraph.h:229
void bindDims(MLIRContext *ctx)
Definition: AffineExpr.h:312
void bindSymbols(MLIRContext *ctx)
Definition: AffineExpr.h:321
Include the generated interface declarations.
std::optional< int64_t > getBoundForAffineExpr(AffineExpr expr, unsigned numDims, unsigned numSymbols, ArrayRef< std::optional< int64_t >> constLowerBounds, ArrayRef< std::optional< int64_t >> constUpperBounds, bool isUpper)
Get a lower or upper (depending on isUpper) bound for expr while using the constant lower and upper b...
void bindDimsList(MLIRContext *ctx, MutableArrayRef< AffineExprTy > exprs)
Definition: AffineExpr.h:339
void bindDims(MLIRContext *ctx, AffineExprTy &...exprs)
Bind a list of AffineExpr references to DimExpr at positions: [0 .
Definition: AffineExpr.h:334
AffineExprKind
Definition: AffineExpr.h:40
@ CeilDiv
RHS of ceildiv is always a constant or a symbolic expression.
@ LAST_AFFINE_BINARY_OP
This is a marker for the last affine binary op.
@ Mul
RHS of mul is always a constant or a symbolic expression.
@ Mod
RHS of mod is always a constant or a symbolic expression with a positive value.
@ DimId
Dimensional identifier.
@ FloorDiv
RHS of floordiv is always a constant or a symbolic expression.
@ Constant
Constant integer.
@ SymbolId
Symbolic identifier.
AffineExpr getAffineBinaryOpExpr(AffineExprKind kind, AffineExpr lhs, AffineExpr rhs)
Definition: AffineExpr.cpp:47
AffineExpr operator-(int64_t val, AffineExpr expr)
Definition: AffineExpr.h:252
AffineExpr getAffineExprFromFlatForm(ArrayRef< int64_t > flatExprs, unsigned numDims, unsigned numSymbols, ArrayRef< AffineExpr > localExprs, MLIRContext *context)
Constructs an affine expression from a flat ArrayRef.
Definition: AffineExpr.cpp:993
void bindSymbols(MLIRContext *ctx, AffineExprTy &...exprs)
Bind a list of AffineExpr references to SymbolExpr at positions: [0 .
Definition: AffineExpr.h:348
AffineExpr operator+(int64_t val, AffineExpr expr)
Definition: AffineExpr.h:250
AffineExpr operator*(int64_t val, AffineExpr expr)
Definition: AffineExpr.h:251
AffineExpr getAffineConstantExpr(int64_t constant, MLIRContext *context)
Definition: AffineExpr.cpp:608
AffineExpr simplifyAffineExpr(AffineExpr expr, unsigned numDims, unsigned numSymbols)
Simplify an affine expression by flattening and some amount of simple analysis.
SmallVector< AffineExpr > getAffineConstantExprs(ArrayRef< int64_t > constants, MLIRContext *context)
Definition: AffineExpr.cpp:618
inline ::llvm::hash_code hash_value(AffineExpr arg)
Make AffineExpr hashable.
Definition: AffineExpr.h:246
AffineExpr getAffineDimExpr(unsigned position, MLIRContext *context)
These free functions allow clients of the API to not use classes in detail.
Definition: AffineExpr.cpp:584
AffineExpr getAffineSymbolExpr(unsigned position, MLIRContext *context)
Definition: AffineExpr.cpp:594
void bindSymbolsList(MLIRContext *ctx, MutableArrayRef< AffineExprTy > exprs)
Definition: AffineExpr.h:353
raw_ostream & operator<<(raw_ostream &os, const AliasResult &result)
Definition: AliasAnalysis.h:78
static unsigned getHashValue(mlir::AffineExpr val)
Definition: AffineExpr.h:388
static mlir::AffineExpr getEmptyKey()
Definition: AffineExpr.h:380
static mlir::AffineExpr getTombstoneKey()
Definition: AffineExpr.h:384
static bool isEqual(mlir::AffineExpr LHS, mlir::AffineExpr RHS)
Definition: AffineExpr.h:391
A binary operation appearing in an affine expression.
An integer constant appearing in affine expression.
A dimensional or symbolic identifier appearing in an affine expression.
Base storage class appearing in an affine expression.