17
17
#include " mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.h"
18
18
#include " mlir/Dialect/StandardOps/IR/Ops.h"
19
19
#include " mlir/IR/AffineMap.h"
20
- #include " mlir/IR/Builders.h"
21
- #include " mlir/IR/BuiltinTypes.h"
22
- #include " mlir/IR/Dialect.h"
23
- #include " mlir/IR/OpDefinition.h"
24
20
#include " mlir/Interfaces/LoopLikeInterface.h"
25
- #include " mlir/Interfaces/SideEffectInterfaces.h"
26
21
27
22
namespace mlir {
28
23
class AffineApplyOp ;
29
24
class AffineBound ;
30
- class AffineDimExpr ;
31
25
class AffineValueMap ;
32
- class AffineYieldOp ;
33
- class FlatAffineConstraints ;
34
- class OpBuilder ;
35
26
36
27
// / A utility function to check if a value is defined at the top level of an
37
28
// / op with trait `AffineScope` or is a region argument for such an op. A value
@@ -58,9 +49,9 @@ bool isTopLevelValue(Value value);
58
49
// / specified. The value of 'num_elements' must be a multiple of
59
50
// / 'number_of_elements_per_stride'.
60
51
//
61
- // For example, a DmaStartOp operation that transfers 256 elements of a memref
62
- // '%src' in memory space 0 at indices [%i + 3, %j] to memref '%dst' in memory
63
- // space 1 at indices [%k + 7, %l], would be specified as follows:
52
+ // For example, an AffineDmaStartOp operation that transfers 256 elements of a
53
+ // memref '%src' in memory space 0 at indices [%i + 3, %j] to memref '%dst' in
54
+ // memory space 1 at indices [%k + 7, %l], would be specified as follows:
64
55
//
65
56
// %num_elements = constant 256
66
57
// %idx = constant 0 : index
@@ -79,7 +70,6 @@ bool isTopLevelValue(Value value);
79
70
// TODO: add additional operands to allow source and destination striding, and
80
71
// multiple stride levels (possibly using AffineMaps to specify multiple levels
81
72
// of striding).
82
- // TODO: Consider replacing src/dst memref indices with view memrefs.
83
73
class AffineDmaStartOp
84
74
: public Op<AffineDmaStartOp, OpTrait::MemRefsNormalizable,
85
75
OpTrait::VariadicOperands, OpTrait::ZeroResult,
@@ -93,7 +83,7 @@ class AffineDmaStartOp
93
83
AffineMap tagMap, ValueRange tagIndices, Value numElements,
94
84
Value stride = nullptr , Value elementsPerStride = nullptr );
95
85
96
- // / Returns the operand index of the src memref.
86
+ // / Returns the operand index of the source memref.
97
87
unsigned getSrcMemRefOperandIndex () { return 0 ; }
98
88
99
89
// / Returns the source MemRefType for this DMA operation.
@@ -105,7 +95,7 @@ class AffineDmaStartOp
105
95
// / Returns the rank (number of indices) of the source MemRefType.
106
96
unsigned getSrcMemRefRank () { return getSrcMemRefType ().getRank (); }
107
97
108
- // / Returns the affine map used to access the src memref.
98
+ // / Returns the affine map used to access the source memref.
109
99
AffineMap getSrcMap () { return getSrcMapAttr ().getValue (); }
110
100
AffineMapAttr getSrcMapAttr () {
111
101
return (*this )->getAttr (getSrcMapAttrName ()).cast <AffineMapAttr>();
@@ -118,17 +108,17 @@ class AffineDmaStartOp
118
108
getSrcMap ().getNumInputs ()};
119
109
}
120
110
121
- // / Returns the memory space of the src memref.
111
+ // / Returns the memory space of the source memref.
122
112
unsigned getSrcMemorySpace () {
123
113
return getSrcMemRef ().getType ().cast <MemRefType>().getMemorySpaceAsInt ();
124
114
}
125
115
126
- // / Returns the operand index of the dst memref.
116
+ // / Returns the operand index of the destination memref.
127
117
unsigned getDstMemRefOperandIndex () {
128
118
return getSrcMemRefOperandIndex () + 1 + getSrcMap ().getNumInputs ();
129
119
}
130
120
131
- // / Returns the destination MemRefType for this DMA operations .
121
+ // / Returns the destination MemRefType for this DMA operation .
132
122
Value getDstMemRef () { return getOperand (getDstMemRefOperandIndex ()); }
133
123
MemRefType getDstMemRefType () {
134
124
return getDstMemRef ().getType ().cast <MemRefType>();
@@ -139,12 +129,12 @@ class AffineDmaStartOp
139
129
return getDstMemRef ().getType ().cast <MemRefType>().getRank ();
140
130
}
141
131
142
- // / Returns the memory space of the src memref.
132
+ // / Returns the memory space of the source memref.
143
133
unsigned getDstMemorySpace () {
144
134
return getDstMemRef ().getType ().cast <MemRefType>().getMemorySpaceAsInt ();
145
135
}
146
136
147
- // / Returns the affine map used to access the dst memref.
137
+ // / Returns the affine map used to access the destination memref.
148
138
AffineMap getDstMap () { return getDstMapAttr ().getValue (); }
149
139
AffineMapAttr getDstMapAttr () {
150
140
return (*this )->getAttr (getDstMapAttrName ()).cast <AffineMapAttr>();
@@ -198,7 +188,7 @@ class AffineDmaStartOp
198
188
if (memref == getSrcMemRef ())
199
189
return {Identifier::get (getSrcMapAttrName (), getContext ()),
200
190
getSrcMapAttr ()};
201
- else if (memref == getDstMemRef ())
191
+ if (memref == getDstMemRef ())
202
192
return {Identifier::get (getDstMapAttrName (), getContext ()),
203
193
getDstMapAttr ()};
204
194
assert (memref == getTagMemRef () &&
@@ -283,7 +273,7 @@ class AffineDmaWaitOp
283
273
284
274
static StringRef getOperationName () { return " affine.dma_wait" ; }
285
275
286
- // Returns the Tag MemRef associated with the DMA operation being waited on.
276
+ // / Returns the Tag MemRef associated with the DMA operation being waited on.
287
277
Value getTagMemRef () { return getOperand (0 ); }
288
278
MemRefType getTagMemRefType () {
289
279
return getTagMemRef ().getType ().cast <MemRefType>();
@@ -295,26 +285,26 @@ class AffineDmaWaitOp
295
285
return (*this )->getAttr (getTagMapAttrName ()).cast <AffineMapAttr>();
296
286
}
297
287
298
- // Returns the tag memref index for this DMA operation.
288
+ // / Returns the tag memref index for this DMA operation.
299
289
operand_range getTagIndices () {
300
290
return {operand_begin () + 1 ,
301
291
operand_begin () + 1 + getTagMap ().getNumInputs ()};
302
292
}
303
293
304
- // Returns the rank (number of indices) of the tag memref.
294
+ // / Returns the rank (number of indices) of the tag memref.
305
295
unsigned getTagMemRefRank () {
306
296
return getTagMemRef ().getType ().cast <MemRefType>().getRank ();
307
297
}
308
298
309
- // / Impelements the AffineMapAccessInterface.
310
- // / Returns the AffineMapAttr associated with 'memref'.
299
+ // / Impelements the AffineMapAccessInterface. Returns the AffineMapAttr
300
+ // / associated with 'memref'.
311
301
NamedAttribute getAffineMapAttrForMemRef (Value memref) {
312
302
assert (memref == getTagMemRef ());
313
303
return {Identifier::get (getTagMapAttrName (), getContext ()),
314
304
getTagMapAttr ()};
315
305
}
316
306
317
- // / Returns the number of elements transferred in the associated DMA op.
307
+ // / Returns the number of elements transferred by the associated DMA op.
318
308
Value getNumElements () { return getOperand (1 + getTagMap ().getNumInputs ()); }
319
309
320
310
static StringRef getTagMapAttrName () { return " tag_map" ; }
@@ -341,7 +331,8 @@ bool isValidSymbol(Value value);
341
331
// / for all its uses in `region`.
342
332
bool isValidSymbol (Value value, Region *region);
343
333
344
- // / Parses dimension and symbol list and returns true if parsing failed.
334
+ // / Parses dimension and symbol list. `numDims` is set to the number of
335
+ // / dimensions in the list parsed.
345
336
ParseResult parseDimAndSymbolList (OpAsmParser &parser,
346
337
SmallVectorImpl<Value> &operands,
347
338
unsigned &numDims);
@@ -394,8 +385,8 @@ AffineForOp getForInductionVarOwner(Value val);
394
385
void extractForInductionVars (ArrayRef<AffineForOp> forInsts,
395
386
SmallVectorImpl<Value> *ivs);
396
387
397
- // / Builds a perfect nest of affine " for" loops, i.e. each loop except the
398
- // / innermost only contains another loop and a terminator. The loops iterate
388
+ // / Builds a perfect nest of affine. for loops, i.e., each loop except the
389
+ // / innermost one contains only another loop and a terminator. The loops iterate
399
390
// / from "lbs" to "ubs" with "steps". The body of the innermost loop is
400
391
// / populated by calling "bodyBuilderFn" and providing it with an OpBuilder, a
401
392
// / Location and a list of loop induction variables.
0 commit comments