MLIR  15.0.0git
AffineOps.h
Go to the documentation of this file.
1 //===- AffineOps.h - MLIR Affine Operations -------------------------------===//
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 // This file defines convenience types for working with Affine operations
10 // in the MLIR operation set.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef MLIR_DIALECT_AFFINE_IR_AFFINEOPS_H
15 #define MLIR_DIALECT_AFFINE_IR_AFFINEOPS_H
16 
19 #include "mlir/IR/AffineMap.h"
20 #include "mlir/IR/Builders.h"
23 
24 namespace mlir {
25 class AffineApplyOp;
26 class AffineBound;
27 class AffineValueMap;
28 
29 /// TODO: These should be renamed if they are on the mlir namespace.
30 /// Ideally, they should go in a mlir::affine:: namespace.
31 
32 /// A utility function to check if a value is defined at the top level of an
33 /// op with trait `AffineScope` or is a region argument for such an op. A value
34 /// of index type defined at the top level is always a valid symbol for all its
35 /// uses.
36 bool isTopLevelValue(Value value);
37 
38 /// A utility function to check if a value is defined at the top level of
39 /// `region` or is an argument of `region`. A value of index type defined at the
40 /// top level of a `AffineScope` region is always a valid symbol for all
41 /// uses in that region.
42 bool isTopLevelValue(Value value, Region *region);
43 
44 /// Returns the closest region enclosing `op` that is held by an operation with
45 /// trait `AffineScope`; `nullptr` if there is no such region.
46 Region *getAffineScope(Operation *op);
47 
48 /// AffineDmaStartOp starts a non-blocking DMA operation that transfers data
49 /// from a source memref to a destination memref. The source and destination
50 /// memref need not be of the same dimensionality, but need to have the same
51 /// elemental type. The operands include the source and destination memref's
52 /// each followed by its indices, size of the data transfer in terms of the
53 /// number of elements (of the elemental type of the memref), a tag memref with
54 /// its indices, and optionally at the end, a stride and a
55 /// number_of_elements_per_stride arguments. The tag location is used by an
56 /// AffineDmaWaitOp to check for completion. The indices of the source memref,
57 /// destination memref, and the tag memref have the same restrictions as any
58 /// affine.load/store. In particular, index for each memref dimension must be an
59 /// affine expression of loop induction variables and symbols.
60 /// The optional stride arguments should be of 'index' type, and specify a
61 /// stride for the slower memory space (memory space with a lower memory space
62 /// id), transferring chunks of number_of_elements_per_stride every stride until
63 /// %num_elements are transferred. Either both or no stride arguments should be
64 /// specified. The value of 'num_elements' must be a multiple of
65 /// 'number_of_elements_per_stride'. If the source and destination locations
66 /// overlap the behavior of this operation is not defined.
67 //
68 // For example, an AffineDmaStartOp operation that transfers 256 elements of a
69 // memref '%src' in memory space 0 at indices [%i + 3, %j] to memref '%dst' in
70 // memory space 1 at indices [%k + 7, %l], would be specified as follows:
71 //
72 // %num_elements = arith.constant 256
73 // %idx = arith.constant 0 : index
74 // %tag = memref.alloc() : memref<1xi32, 4>
75 // affine.dma_start %src[%i + 3, %j], %dst[%k + 7, %l], %tag[%idx],
76 // %num_elements :
77 // memref<40x128xf32, 0>, memref<2x1024xf32, 1>, memref<1xi32, 2>
78 //
79 // If %stride and %num_elt_per_stride are specified, the DMA is expected to
80 // transfer %num_elt_per_stride elements every %stride elements apart from
81 // memory space 0 until %num_elements are transferred.
82 //
83 // affine.dma_start %src[%i, %j], %dst[%k, %l], %tag[%idx], %num_elements,
84 // %stride, %num_elt_per_stride : ...
85 //
86 // TODO: add additional operands to allow source and destination striding, and
87 // multiple stride levels (possibly using AffineMaps to specify multiple levels
88 // of striding).
90  : public Op<AffineDmaStartOp, OpTrait::MemRefsNormalizable,
91  OpTrait::VariadicOperands, OpTrait::ZeroResults,
92  OpTrait::OpInvariants, AffineMapAccessInterface::Trait> {
93 public:
94  using Op::Op;
95  static ArrayRef<StringRef> getAttributeNames() { return {}; }
96 
97  static void build(OpBuilder &builder, OperationState &result, Value srcMemRef,
98  AffineMap srcMap, ValueRange srcIndices, Value destMemRef,
99  AffineMap dstMap, ValueRange destIndices, Value tagMemRef,
100  AffineMap tagMap, ValueRange tagIndices, Value numElements,
101  Value stride = nullptr, Value elementsPerStride = nullptr);
102 
103  /// Returns the operand index of the source memref.
104  unsigned getSrcMemRefOperandIndex() { return 0; }
105 
106  /// Returns the source MemRefType for this DMA operation.
107  Value getSrcMemRef() { return getOperand(getSrcMemRefOperandIndex()); }
108  MemRefType getSrcMemRefType() {
109  return getSrcMemRef().getType().cast<MemRefType>();
110  }
111 
112  /// Returns the rank (number of indices) of the source MemRefType.
113  unsigned getSrcMemRefRank() { return getSrcMemRefType().getRank(); }
114 
115  /// Returns the affine map used to access the source memref.
116  AffineMap getSrcMap() { return getSrcMapAttr().getValue(); }
117  AffineMapAttr getSrcMapAttr() {
118  return (*this)->getAttr(getSrcMapAttrStrName()).cast<AffineMapAttr>();
119  }
120 
121  /// Returns the source memref affine map indices for this DMA operation.
122  operand_range getSrcIndices() {
123  return {operand_begin() + getSrcMemRefOperandIndex() + 1,
124  operand_begin() + getSrcMemRefOperandIndex() + 1 +
125  getSrcMap().getNumInputs()};
126  }
127 
128  /// Returns the memory space of the source memref.
129  unsigned getSrcMemorySpace() {
130  return getSrcMemRef().getType().cast<MemRefType>().getMemorySpaceAsInt();
131  }
132 
133  /// Returns the operand index of the destination memref.
136  }
137 
138  /// Returns the destination MemRefType for this DMA operation.
139  Value getDstMemRef() { return getOperand(getDstMemRefOperandIndex()); }
140  MemRefType getDstMemRefType() {
141  return getDstMemRef().getType().cast<MemRefType>();
142  }
143 
144  /// Returns the rank (number of indices) of the destination MemRefType.
145  unsigned getDstMemRefRank() {
146  return getDstMemRef().getType().cast<MemRefType>().getRank();
147  }
148 
149  /// Returns the memory space of the source memref.
150  unsigned getDstMemorySpace() {
151  return getDstMemRef().getType().cast<MemRefType>().getMemorySpaceAsInt();
152  }
153 
154  /// Returns the affine map used to access the destination memref.
155  AffineMap getDstMap() { return getDstMapAttr().getValue(); }
156  AffineMapAttr getDstMapAttr() {
157  return (*this)->getAttr(getDstMapAttrStrName()).cast<AffineMapAttr>();
158  }
159 
160  /// Returns the destination memref indices for this DMA operation.
161  operand_range getDstIndices() {
162  return {operand_begin() + getDstMemRefOperandIndex() + 1,
163  operand_begin() + getDstMemRefOperandIndex() + 1 +
164  getDstMap().getNumInputs()};
165  }
166 
167  /// Returns the operand index of the tag memref.
170  }
171 
172  /// Returns the Tag MemRef for this DMA operation.
173  Value getTagMemRef() { return getOperand(getTagMemRefOperandIndex()); }
174  MemRefType getTagMemRefType() {
175  return getTagMemRef().getType().cast<MemRefType>();
176  }
177 
178  /// Returns the rank (number of indices) of the tag MemRefType.
179  unsigned getTagMemRefRank() {
180  return getTagMemRef().getType().cast<MemRefType>().getRank();
181  }
182 
183  /// Returns the affine map used to access the tag memref.
184  AffineMap getTagMap() { return getTagMapAttr().getValue(); }
185  AffineMapAttr getTagMapAttr() {
186  return (*this)->getAttr(getTagMapAttrStrName()).cast<AffineMapAttr>();
187  }
188 
189  /// Returns the tag memref indices for this DMA operation.
190  operand_range getTagIndices() {
191  return {operand_begin() + getTagMemRefOperandIndex() + 1,
192  operand_begin() + getTagMemRefOperandIndex() + 1 +
193  getTagMap().getNumInputs()};
194  }
195 
196  /// Returns the number of elements being transferred by this DMA operation.
198  return getOperand(getTagMemRefOperandIndex() + 1 +
199  getTagMap().getNumInputs());
200  }
201 
202  /// Impelements the AffineMapAccessInterface.
203  /// Returns the AffineMapAttr associated with 'memref'.
205  if (memref == getSrcMemRef())
206  return {StringAttr::get(getContext(), getSrcMapAttrStrName()),
207  getSrcMapAttr()};
208  if (memref == getDstMemRef())
209  return {StringAttr::get(getContext(), getDstMapAttrStrName()),
210  getDstMapAttr()};
211  assert(memref == getTagMemRef() &&
212  "DmaStartOp expected source, destination or tag memref");
213  return {StringAttr::get(getContext(), getTagMapAttrStrName()),
214  getTagMapAttr()};
215  }
216 
217  /// Returns true if this is a DMA from a faster memory space to a slower one.
219  return (getSrcMemorySpace() < getDstMemorySpace());
220  }
221 
222  /// Returns true if this is a DMA from a slower memory space to a faster one.
224  // Assumes that a lower number is for a slower memory space.
225  return (getDstMemorySpace() < getSrcMemorySpace());
226  }
227 
228  /// Given a DMA start operation, returns the operand position of either the
229  /// source or destination memref depending on the one that is at the higher
230  /// level of the memory hierarchy. Asserts failure if neither is true.
231  unsigned getFasterMemPos() {
234  }
235 
236  static StringRef getSrcMapAttrStrName() { return "src_map"; }
237  static StringRef getDstMapAttrStrName() { return "dst_map"; }
238  static StringRef getTagMapAttrStrName() { return "tag_map"; }
239 
240  static StringRef getOperationName() { return "affine.dma_start"; }
242  void print(OpAsmPrinter &p);
247 
248  /// Returns true if this DMA operation is strided, returns false otherwise.
249  bool isStrided() {
250  return getNumOperands() !=
252  }
253 
254  /// Returns the stride value for this DMA operation.
256  if (!isStrided())
257  return nullptr;
258  return getOperand(getNumOperands() - 1 - 1);
259  }
260 
261  /// Returns the number of elements to transfer per stride for this DMA op.
263  if (!isStrided())
264  return nullptr;
265  return getOperand(getNumOperands() - 1);
266  }
267 };
268 
269 /// AffineDmaWaitOp blocks until the completion of a DMA operation associated
270 /// with the tag element '%tag[%index]'. %tag is a memref, and %index has to be
271 /// an index with the same restrictions as any load/store index. In particular,
272 /// index for each memref dimension must be an affine expression of loop
273 /// induction variables and symbols. %num_elements is the number of elements
274 /// associated with the DMA operation. For example:
275 //
276 // affine.dma_start %src[%i, %j], %dst[%k, %l], %tag[%index], %num_elements :
277 // memref<2048xf32, 0>, memref<256xf32, 1>, memref<1xi32, 2>
278 // ...
279 // ...
280 // affine.dma_wait %tag[%index], %num_elements : memref<1xi32, 2>
281 //
283  : public Op<AffineDmaWaitOp, OpTrait::MemRefsNormalizable,
284  OpTrait::VariadicOperands, OpTrait::ZeroResults,
285  OpTrait::OpInvariants, AffineMapAccessInterface::Trait> {
286 public:
287  using Op::Op;
288  static ArrayRef<StringRef> getAttributeNames() { return {}; }
289 
290  static void build(OpBuilder &builder, OperationState &result, Value tagMemRef,
291  AffineMap tagMap, ValueRange tagIndices, Value numElements);
292 
293  static StringRef getOperationName() { return "affine.dma_wait"; }
294 
295  /// Returns the Tag MemRef associated with the DMA operation being waited on.
296  Value getTagMemRef() { return getOperand(0); }
297  MemRefType getTagMemRefType() {
298  return getTagMemRef().getType().cast<MemRefType>();
299  }
300 
301  /// Returns the affine map used to access the tag memref.
302  AffineMap getTagMap() { return getTagMapAttr().getValue(); }
303  AffineMapAttr getTagMapAttr() {
304  return (*this)->getAttr(getTagMapAttrStrName()).cast<AffineMapAttr>();
305  }
306 
307  /// Returns the tag memref index for this DMA operation.
308  operand_range getTagIndices() {
309  return {operand_begin() + 1,
310  operand_begin() + 1 + getTagMap().getNumInputs()};
311  }
312 
313  /// Returns the rank (number of indices) of the tag memref.
314  unsigned getTagMemRefRank() {
315  return getTagMemRef().getType().cast<MemRefType>().getRank();
316  }
317 
318  /// Impelements the AffineMapAccessInterface. Returns the AffineMapAttr
319  /// associated with 'memref'.
321  assert(memref == getTagMemRef());
322  return {StringAttr::get(getContext(), getTagMapAttrStrName()),
323  getTagMapAttr()};
324  }
325 
326  /// Returns the number of elements transferred by the associated DMA op.
327  Value getNumElements() { return getOperand(1 + getTagMap().getNumInputs()); }
328 
329  static StringRef getTagMapAttrStrName() { return "tag_map"; }
331  void print(OpAsmPrinter &p);
336 };
337 
338 /// Returns true if the given Value can be used as a dimension id in the region
339 /// of the closest surrounding op that has the trait `AffineScope`.
340 bool isValidDim(Value value);
341 
342 /// Returns true if the given Value can be used as a dimension id in `region`,
343 /// i.e., for all its uses in `region`.
344 bool isValidDim(Value value, Region *region);
345 
346 /// Returns true if the given value can be used as a symbol in the region of the
347 /// closest surrounding op that has the trait `AffineScope`.
348 bool isValidSymbol(Value value);
349 
350 /// Returns true if the given Value can be used as a symbol for `region`, i.e.,
351 /// for all its uses in `region`.
352 bool isValidSymbol(Value value, Region *region);
353 
354 /// Parses dimension and symbol list. `numDims` is set to the number of
355 /// dimensions in the list parsed.
357  SmallVectorImpl<Value> &operands,
358  unsigned &numDims);
359 
360 /// Modifies both `map` and `operands` in-place so as to:
361 /// 1. drop duplicate operands
362 /// 2. drop unused dims and symbols from map
363 /// 3. promote valid symbols to symbolic operands in case they appeared as
364 /// dimensional operands
365 /// 4. propagate constant operands and drop them
367  SmallVectorImpl<Value> *operands);
368 
369 /// Canonicalizes an integer set the same way canonicalizeMapAndOperands does
370 /// for affine maps.
372  SmallVectorImpl<Value> *operands);
373 
374 /// Returns a composed AffineApplyOp by composing `map` and `operands` with
375 /// other AffineApplyOps supplying those operands. The operands of the resulting
376 /// AffineApplyOp do not change the length of AffineApplyOp chains.
377 AffineApplyOp makeComposedAffineApply(OpBuilder &b, Location loc, AffineMap map,
378  ValueRange operands);
379 /// Variant of `makeComposedAffineApply` which infers the AffineMap from `e`.
380 AffineApplyOp makeComposedAffineApply(OpBuilder &b, Location loc, AffineExpr e,
381  ValueRange values);
382 
383 /// Returns the values obtained by applying `map` to the list of values.
385  AffineMap map, ValueRange values);
386 
387 /// Given an affine map `map` and its input `operands`, this method composes
388 /// into `map`, maps of AffineApplyOps whose results are the values in
389 /// `operands`, iteratively until no more of `operands` are the result of an
390 /// AffineApplyOp. When this function returns, `map` becomes the composed affine
391 /// map, and each Value in `operands` is guaranteed to be either a loop IV or a
392 /// terminal symbol, i.e., a symbol defined at the top level or a block/function
393 /// argument.
395  SmallVectorImpl<Value> *operands);
396 } // namespace mlir
397 #include "mlir/Dialect/Affine/IR/AffineOpsDialect.h.inc"
398 
399 #define GET_OP_CLASSES
400 #include "mlir/Dialect/Affine/IR/AffineOps.h.inc"
401 
402 namespace mlir {
403 /// Returns true if the provided value is the induction variable of a
404 /// AffineForOp.
405 bool isForInductionVar(Value val);
406 
407 /// Returns the loop parent of an induction variable. If the provided value is
408 /// not an induction variable, then return nullptr.
409 AffineForOp getForInductionVarOwner(Value val);
410 
411 /// Extracts the induction variables from a list of AffineForOps and places them
412 /// in the output argument `ivs`.
413 void extractForInductionVars(ArrayRef<AffineForOp> forInsts,
414  SmallVectorImpl<Value> *ivs);
415 
416 /// Builds a perfect nest of affine.for loops, i.e., each loop except the
417 /// innermost one contains only another loop and a terminator. The loops iterate
418 /// from "lbs" to "ubs" with "steps". The body of the innermost loop is
419 /// populated by calling "bodyBuilderFn" and providing it with an OpBuilder, a
420 /// Location and a list of loop induction variables.
421 void buildAffineLoopNest(OpBuilder &builder, Location loc,
422  ArrayRef<int64_t> lbs, ArrayRef<int64_t> ubs,
423  ArrayRef<int64_t> steps,
424  function_ref<void(OpBuilder &, Location, ValueRange)>
425  bodyBuilderFn = nullptr);
426 void buildAffineLoopNest(OpBuilder &builder, Location loc, ValueRange lbs,
427  ValueRange ubs, ArrayRef<int64_t> steps,
428  function_ref<void(OpBuilder &, Location, ValueRange)>
429  bodyBuilderFn = nullptr);
430 
431 /// Replace `loop` with a new loop where `newIterOperands` are appended with
432 /// new initialization values and `newYieldedValues` are added as new yielded
433 /// values. The returned ForOp has `newYieldedValues.size()` new result values.
434 /// Additionally, if `replaceLoopResults` is true, all uses of
435 /// `loop.getResults()` are replaced with the first `loop.getNumResults()`
436 /// return values of the original loop respectively. The original loop is
437 /// deleted and the new loop returned.
438 /// Prerequisite: `newIterOperands.size() == newYieldedValues.size()`.
439 AffineForOp replaceForOpWithNewYields(OpBuilder &b, AffineForOp loop,
440  ValueRange newIterOperands,
441  ValueRange newYieldedValues,
442  ValueRange newIterArgs,
443  bool replaceLoopResults = true);
444 
445 /// AffineBound represents a lower or upper bound in the for operation.
446 /// This class does not own the underlying operands. Instead, it refers
447 /// to the operands stored in the AffineForOp. Its life span should not exceed
448 /// that of the for operation it refers to.
449 class AffineBound {
450 public:
451  AffineForOp getAffineForOp() { return op; }
452  AffineMap getMap() { return map; }
453 
454  unsigned getNumOperands() { return opEnd - opStart; }
455  Value getOperand(unsigned idx) { return op.getOperand(opStart + idx); }
456 
457  using operand_iterator = AffineForOp::operand_iterator;
458  using operand_range = AffineForOp::operand_range;
459 
460  operand_iterator operandBegin() { return op.operand_begin() + opStart; }
461  operand_iterator operandEnd() { return op.operand_begin() + opEnd; }
462  operand_range getOperands() { return {operandBegin(), operandEnd()}; }
463 
464 private:
465  // 'affine.for' operation that contains this bound.
466  AffineForOp op;
467  // Start and end positions of this affine bound operands in the list of
468  // the containing 'affine.for' operation operands.
469  unsigned opStart, opEnd;
470  // Affine map for this bound.
471  AffineMap map;
472 
473  AffineBound(AffineForOp op, unsigned opStart, unsigned opEnd, AffineMap map)
474  : op(op), opStart(opStart), opEnd(opEnd), map(map) {}
475 
476  friend class AffineForOp;
477 };
478 
479 } // namespace mlir
480 
481 #endif
TODO: Remove this file when SCCP and integer range analysis have been ported to the new framework...
bool isStrided()
Returns true if this DMA operation is strided, returns false otherwise.
Definition: AffineOps.h:249
This class contains a list of basic blocks and a link to the parent operation it is attached to...
Definition: Region.h:26
llvm::function_ref< Fn > function_ref
Definition: LLVM.h:129
ParseResult parseDimAndSymbolList(OpAsmParser &parser, SmallVectorImpl< Value > &operands, unsigned &numDims)
Parses dimension and symbol list.
Definition: AffineOps.cpp:447
AffineMapAttr getDstMapAttr()
Definition: AffineOps.h:156
Value getOperand(unsigned idx)
Definition: AffineOps.h:455
AffineForOp getAffineForOp()
Definition: AffineOps.h:451
unsigned getFasterMemPos()
Given a DMA start operation, returns the operand position of either the source or destination memref ...
Definition: AffineOps.h:231
operand_range getDstIndices()
Returns the destination memref indices for this DMA operation.
Definition: AffineOps.h:161
MLIRContext * getContext()
Return the context this operation belongs to.
Definition: OpDefinition.h:94
NamedAttribute getAffineMapAttrForMemRef(Value memref)
Impelements the AffineMapAccessInterface.
Definition: AffineOps.h:204
static StringRef getOperationName()
Definition: AffineOps.h:240
AffineApplyOp makeComposedAffineApply(OpBuilder &b, Location loc, AffineMap map, ValueRange operands)
Returns a composed AffineApplyOp by composing map and operands with other AffineApplyOps supplying th...
Definition: AffineOps.cpp:708
operand_range getTagIndices()
Returns the tag memref indices for this DMA operation.
Definition: AffineOps.h:190
The OpAsmParser has methods for interacting with the asm parser: parsing things from it...
MemRefType getTagMemRefType()
Definition: AffineOps.h:297
void extractForInductionVars(ArrayRef< AffineForOp > forInsts, SmallVectorImpl< Value > *ivs)
Extracts the induction variables from a list of AffineForOps and places them in the output argument i...
Definition: AffineOps.cpp:1965
static constexpr const bool value
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Definition: Location.h:48
LogicalResult verifyInvariantsImpl()
Definition: AffineOps.cpp:1120
NamedAttribute represents a combination of a name and an Attribute value.
Definition: Attributes.h:144
NamedAttribute getAffineMapAttrForMemRef(Value memref)
Impelements the AffineMapAccessInterface.
Definition: AffineOps.h:320
unsigned getNumInputs() const
Definition: AffineMap.cpp:303
Value getNumElementsPerStride()
Returns the number of elements to transfer per stride for this DMA op.
Definition: AffineOps.h:262
AffineForOp::operand_iterator operand_iterator
Definition: AffineOps.h:457
unsigned getDstMemRefRank()
Returns the rank (number of indices) of the destination MemRefType.
Definition: AffineOps.h:145
Value getTagMemRef()
Returns the Tag MemRef associated with the DMA operation being waited on.
Definition: AffineOps.h:296
Value getNumElements()
Returns the number of elements transferred by the associated DMA op.
Definition: AffineOps.h:327
This class represents an efficient way to signal success or failure.
Definition: LogicalResult.h:26
AffineForOp::operand_range operand_range
Definition: AffineOps.h:458
LogicalResult verifyInvariants()
Definition: AffineOps.h:333
bool isValidDim(Value value)
Returns true if the given Value can be used as a dimension id in the region of the closest surroundin...
Definition: AffineOps.cpp:259
static ArrayRef< StringRef > getAttributeNames()
Definition: AffineOps.h:288
unsigned getNumOperands()
Definition: AffineOps.h:454
bool isDestMemorySpaceFaster()
Returns true if this is a DMA from a faster memory space to a slower one.
Definition: AffineOps.h:218
bool isValidSymbol(Value value)
Returns true if the given value can be used as a symbol in the region of the closest surrounding op t...
Definition: AffineOps.cpp:356
operand_range getTagIndices()
Returns the tag memref index for this DMA operation.
Definition: AffineOps.h:308
unsigned getSrcMemRefOperandIndex()
Returns the operand index of the source memref.
Definition: AffineOps.h:104
Value getNumElements()
Returns the number of elements being transferred by this DMA operation.
Definition: AffineOps.h:197
void fullyComposeAffineMapAndOperands(AffineMap *map, SmallVectorImpl< Value > *operands)
Given an affine map map and its input operands, this method composes into map, maps of AffineApplyOps...
Definition: AffineOps.cpp:699
MemRefType getSrcMemRefType()
Definition: AffineOps.h:108
Base type for affine expression.
Definition: AffineExpr.h:68
void canonicalizeMapAndOperands(AffineMap *map, SmallVectorImpl< Value > *operands)
Modifies both map and operands in-place so as to:
Definition: AffineOps.cpp:873
void print(OpAsmPrinter &p)
Definition: AffineOps.cpp:1022
LogicalResult verifyInvariants()
Definition: AffineOps.h:244
void canonicalizeSetAndOperands(IntegerSet *set, SmallVectorImpl< Value > *operands)
Canonicalizes an integer set the same way canonicalizeMapAndOperands does for affine maps...
Definition: AffineOps.cpp:878
SmallVector< Value, 4 > applyMapToValues(OpBuilder &b, Location loc, AffineMap map, ValueRange values)
Returns the values obtained by applying map to the list of values.
Definition: AffineOps.cpp:736
This is a pure-virtual base class that exposes the asmprinter hooks necessary to implement a custom p...
static StringRef getTagMapAttrStrName()
Definition: AffineOps.h:238
unsigned getSrcMemorySpace()
Returns the memory space of the source memref.
Definition: AffineOps.h:129
This represents an operation in an abstracted form, suitable for use with the builder APIs...
AffineMapAttr getTagMapAttr()
Definition: AffineOps.h:185
A multi-dimensional affine map Affine map&#39;s are immutable like Type&#39;s, and they are uniqued...
Definition: AffineMap.h:41
static ArrayRef< StringRef > getAttributeNames()
Definition: AffineOps.h:95
bool isForInductionVar(Value val)
Returns true if the provided value is the induction variable of a AffineForOp.
Definition: AffineOps.cpp:1946
AffineDmaWaitOp blocks until the completion of a DMA operation associated with the tag element &#39;tag[i...
Definition: AffineOps.h:282
AffineBound represents a lower or upper bound in the for operation.
Definition: AffineOps.h:449
Value getDstMemRef()
Returns the destination MemRefType for this DMA operation.
Definition: AffineOps.h:139
Value getSrcMemRef()
Returns the source MemRefType for this DMA operation.
Definition: AffineOps.h:107
static void build(OpBuilder &builder, OperationState &result, Value srcMemRef, AffineMap srcMap, ValueRange srcIndices, Value destMemRef, AffineMap dstMap, ValueRange destIndices, Value tagMemRef, AffineMap tagMap, ValueRange tagIndices, Value numElements, Value stride=nullptr, Value elementsPerStride=nullptr)
Definition: AffineOps.cpp:1000
Op()
This is a public constructor. Any op can be initialized to null.
Value getTagMemRef()
Returns the Tag MemRef for this DMA operation.
Definition: AffineOps.h:173
AffineForOp getForInductionVarOwner(Value val)
Returns the loop parent of an induction variable.
Definition: AffineOps.cpp:1952
static ParseResult parse(OpAsmParser &parser, OperationState &result)
Definition: AffineOps.cpp:1044
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Definition: Value.h:85
bool isSrcMemorySpaceFaster()
Returns true if this is a DMA from a slower memory space to a faster one.
Definition: AffineOps.h:223
AffineMap getTagMap()
Returns the affine map used to access the tag memref.
Definition: AffineOps.h:302
bool isTopLevelValue(Value value)
TODO: These should be renamed if they are on the mlir namespace.
Definition: AffineOps.cpp:229
AffineMap getTagMap()
Returns the affine map used to access the tag memref.
Definition: AffineOps.h:184
Region * getAffineScope(Operation *op)
Returns the closest region enclosing op that is held by an operation with trait AffineScope; nullptr ...
Definition: AffineOps.cpp:244
AffineMap getSrcMap()
Returns the affine map used to access the source memref.
Definition: AffineOps.h:116
MemRefType getDstMemRefType()
Definition: AffineOps.h:140
AffineMap getMap()
Definition: AffineOps.h:452
Type getType() const
Return the type of this value.
Definition: Value.h:118
unsigned getSrcMemRefRank()
Returns the rank (number of indices) of the source MemRefType.
Definition: AffineOps.h:113
unsigned getTagMemRefRank()
Returns the rank (number of indices) of the tag MemRefType.
Definition: AffineOps.h:179
static StringRef getDstMapAttrStrName()
Definition: AffineOps.h:237
AffineMap getDstMap()
Returns the affine map used to access the destination memref.
Definition: AffineOps.h:155
unsigned getTagMemRefOperandIndex()
Returns the operand index of the tag memref.
Definition: AffineOps.h:168
operand_range getSrcIndices()
Returns the source memref affine map indices for this DMA operation.
Definition: AffineOps.h:122
AffineForOp replaceForOpWithNewYields(OpBuilder &b, AffineForOp loop, ValueRange newIterOperands, ValueRange newYieldedValues, ValueRange newIterArgs, bool replaceLoopResults=true)
Replace loop with a new loop where newIterOperands are appended with new initialization values and ne...
Definition: AffineOps.cpp:2054
AffineDmaStartOp starts a non-blocking DMA operation that transfers data from a source memref to a de...
Definition: AffineOps.h:89
unsigned getDstMemorySpace()
Returns the memory space of the source memref.
Definition: AffineOps.h:150
AffineMapAttr getTagMapAttr()
Definition: AffineOps.h:303
unsigned getTagMemRefRank()
Returns the rank (number of indices) of the tag memref.
Definition: AffineOps.h:314
This provides public APIs that all operations should have.
operand_iterator operandBegin()
Definition: AffineOps.h:460
static StringRef getSrcMapAttrStrName()
Definition: AffineOps.h:236
MemRefType getTagMemRefType()
Definition: AffineOps.h:174
static StringRef getOperationName()
Definition: AffineOps.h:293
AffineMapAttr getSrcMapAttr()
Definition: AffineOps.h:117
This class represents success/failure for parsing-like operations that find it important to chain tog...
This class helps build Operations.
Definition: Builders.h:184
This class provides an abstraction over the different types of ranges over Values.
operand_iterator operandEnd()
Definition: AffineOps.h:461
operand_range getOperands()
Definition: AffineOps.h:462
unsigned getDstMemRefOperandIndex()
Returns the operand index of the destination memref.
Definition: AffineOps.h:134
unsigned getMemorySpaceAsInt(Attribute memorySpace)
[deprecated] Returns the memory space in old raw integer representation.
Value getStride()
Returns the stride value for this DMA operation.
Definition: AffineOps.h:255
LogicalResult fold(ArrayRef< Attribute > cstOperands, SmallVectorImpl< OpFoldResult > &results)
Definition: AffineOps.cpp:1158
U cast() const
Definition: Types.h:262
void buildAffineLoopNest(OpBuilder &builder, Location loc, ArrayRef< int64_t > lbs, ArrayRef< int64_t > ubs, ArrayRef< int64_t > steps, function_ref< void(OpBuilder &, Location, ValueRange)> bodyBuilderFn=nullptr)
Builds a perfect nest of affine.for loops, i.e., each loop except the innermost one contains only ano...
Definition: AffineOps.cpp:2038
An integer set representing a conjunction of one or more affine equalities and inequalities.
Definition: IntegerSet.h:44
static StringRef getTagMapAttrStrName()
Definition: AffineOps.h:329