Skip to content

Commit 17f6b0c

Browse files
committed
[MLIR][NFC] Fix warning, trim includes + cleanup in AffineOps.h
Fix style/clang-tidy warning, trim stale includes and forward declarations, and cleanup/fix stale comments. Differential Revision: https://reviews.llvm.org/D101021
1 parent afaf36b commit 17f6b0c

File tree

1 file changed

+21
-30
lines changed

1 file changed

+21
-30
lines changed

mlir/include/mlir/Dialect/Affine/IR/AffineOps.h

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,12 @@
1717
#include "mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.h"
1818
#include "mlir/Dialect/StandardOps/IR/Ops.h"
1919
#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"
2420
#include "mlir/Interfaces/LoopLikeInterface.h"
25-
#include "mlir/Interfaces/SideEffectInterfaces.h"
2621

2722
namespace mlir {
2823
class AffineApplyOp;
2924
class AffineBound;
30-
class AffineDimExpr;
3125
class AffineValueMap;
32-
class AffineYieldOp;
33-
class FlatAffineConstraints;
34-
class OpBuilder;
3526

3627
/// A utility function to check if a value is defined at the top level of an
3728
/// op with trait `AffineScope` or is a region argument for such an op. A value
@@ -58,9 +49,9 @@ bool isTopLevelValue(Value value);
5849
/// specified. The value of 'num_elements' must be a multiple of
5950
/// 'number_of_elements_per_stride'.
6051
//
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:
6455
//
6556
// %num_elements = constant 256
6657
// %idx = constant 0 : index
@@ -79,7 +70,6 @@ bool isTopLevelValue(Value value);
7970
// TODO: add additional operands to allow source and destination striding, and
8071
// multiple stride levels (possibly using AffineMaps to specify multiple levels
8172
// of striding).
82-
// TODO: Consider replacing src/dst memref indices with view memrefs.
8373
class AffineDmaStartOp
8474
: public Op<AffineDmaStartOp, OpTrait::MemRefsNormalizable,
8575
OpTrait::VariadicOperands, OpTrait::ZeroResult,
@@ -93,7 +83,7 @@ class AffineDmaStartOp
9383
AffineMap tagMap, ValueRange tagIndices, Value numElements,
9484
Value stride = nullptr, Value elementsPerStride = nullptr);
9585

96-
/// Returns the operand index of the src memref.
86+
/// Returns the operand index of the source memref.
9787
unsigned getSrcMemRefOperandIndex() { return 0; }
9888

9989
/// Returns the source MemRefType for this DMA operation.
@@ -105,7 +95,7 @@ class AffineDmaStartOp
10595
/// Returns the rank (number of indices) of the source MemRefType.
10696
unsigned getSrcMemRefRank() { return getSrcMemRefType().getRank(); }
10797

108-
/// Returns the affine map used to access the src memref.
98+
/// Returns the affine map used to access the source memref.
10999
AffineMap getSrcMap() { return getSrcMapAttr().getValue(); }
110100
AffineMapAttr getSrcMapAttr() {
111101
return (*this)->getAttr(getSrcMapAttrName()).cast<AffineMapAttr>();
@@ -118,17 +108,17 @@ class AffineDmaStartOp
118108
getSrcMap().getNumInputs()};
119109
}
120110

121-
/// Returns the memory space of the src memref.
111+
/// Returns the memory space of the source memref.
122112
unsigned getSrcMemorySpace() {
123113
return getSrcMemRef().getType().cast<MemRefType>().getMemorySpaceAsInt();
124114
}
125115

126-
/// Returns the operand index of the dst memref.
116+
/// Returns the operand index of the destination memref.
127117
unsigned getDstMemRefOperandIndex() {
128118
return getSrcMemRefOperandIndex() + 1 + getSrcMap().getNumInputs();
129119
}
130120

131-
/// Returns the destination MemRefType for this DMA operations.
121+
/// Returns the destination MemRefType for this DMA operation.
132122
Value getDstMemRef() { return getOperand(getDstMemRefOperandIndex()); }
133123
MemRefType getDstMemRefType() {
134124
return getDstMemRef().getType().cast<MemRefType>();
@@ -139,12 +129,12 @@ class AffineDmaStartOp
139129
return getDstMemRef().getType().cast<MemRefType>().getRank();
140130
}
141131

142-
/// Returns the memory space of the src memref.
132+
/// Returns the memory space of the source memref.
143133
unsigned getDstMemorySpace() {
144134
return getDstMemRef().getType().cast<MemRefType>().getMemorySpaceAsInt();
145135
}
146136

147-
/// Returns the affine map used to access the dst memref.
137+
/// Returns the affine map used to access the destination memref.
148138
AffineMap getDstMap() { return getDstMapAttr().getValue(); }
149139
AffineMapAttr getDstMapAttr() {
150140
return (*this)->getAttr(getDstMapAttrName()).cast<AffineMapAttr>();
@@ -198,7 +188,7 @@ class AffineDmaStartOp
198188
if (memref == getSrcMemRef())
199189
return {Identifier::get(getSrcMapAttrName(), getContext()),
200190
getSrcMapAttr()};
201-
else if (memref == getDstMemRef())
191+
if (memref == getDstMemRef())
202192
return {Identifier::get(getDstMapAttrName(), getContext()),
203193
getDstMapAttr()};
204194
assert(memref == getTagMemRef() &&
@@ -283,7 +273,7 @@ class AffineDmaWaitOp
283273

284274
static StringRef getOperationName() { return "affine.dma_wait"; }
285275

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.
287277
Value getTagMemRef() { return getOperand(0); }
288278
MemRefType getTagMemRefType() {
289279
return getTagMemRef().getType().cast<MemRefType>();
@@ -295,26 +285,26 @@ class AffineDmaWaitOp
295285
return (*this)->getAttr(getTagMapAttrName()).cast<AffineMapAttr>();
296286
}
297287

298-
// Returns the tag memref index for this DMA operation.
288+
/// Returns the tag memref index for this DMA operation.
299289
operand_range getTagIndices() {
300290
return {operand_begin() + 1,
301291
operand_begin() + 1 + getTagMap().getNumInputs()};
302292
}
303293

304-
// Returns the rank (number of indices) of the tag memref.
294+
/// Returns the rank (number of indices) of the tag memref.
305295
unsigned getTagMemRefRank() {
306296
return getTagMemRef().getType().cast<MemRefType>().getRank();
307297
}
308298

309-
/// Impelements the AffineMapAccessInterface.
310-
/// Returns the AffineMapAttr associated with 'memref'.
299+
/// Impelements the AffineMapAccessInterface. Returns the AffineMapAttr
300+
/// associated with 'memref'.
311301
NamedAttribute getAffineMapAttrForMemRef(Value memref) {
312302
assert(memref == getTagMemRef());
313303
return {Identifier::get(getTagMapAttrName(), getContext()),
314304
getTagMapAttr()};
315305
}
316306

317-
/// Returns the number of elements transferred in the associated DMA op.
307+
/// Returns the number of elements transferred by the associated DMA op.
318308
Value getNumElements() { return getOperand(1 + getTagMap().getNumInputs()); }
319309

320310
static StringRef getTagMapAttrName() { return "tag_map"; }
@@ -341,7 +331,8 @@ bool isValidSymbol(Value value);
341331
/// for all its uses in `region`.
342332
bool isValidSymbol(Value value, Region *region);
343333

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.
345336
ParseResult parseDimAndSymbolList(OpAsmParser &parser,
346337
SmallVectorImpl<Value> &operands,
347338
unsigned &numDims);
@@ -394,8 +385,8 @@ AffineForOp getForInductionVarOwner(Value val);
394385
void extractForInductionVars(ArrayRef<AffineForOp> forInsts,
395386
SmallVectorImpl<Value> *ivs);
396387

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
399390
/// from "lbs" to "ubs" with "steps". The body of the innermost loop is
400391
/// populated by calling "bodyBuilderFn" and providing it with an OpBuilder, a
401392
/// Location and a list of loop induction variables.

0 commit comments

Comments
 (0)