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