Skip to content

Commit 086214f

Browse files
committed
[MLIR][Interfaces] Make LoopLikeOpInterface inheritable outside of MLIR.
Many interface methods did not prefix the `mlir` namespace, which prevented inheriting from this interface from an interface defined outside the `mlir` namespace. Prefix namespaces everywhere to enable this.
1 parent 148111f commit 086214f

File tree

1 file changed

+33
-29
lines changed

1 file changed

+33
-29
lines changed

mlir/include/mlir/Interfaces/LoopLikeInterface.td

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> {
239239
/// Returns if a block is inside a loop (within the current function). This
240240
/// can either be because the block is nested inside a LoopLikeInterface, or
241241
/// because the control flow graph is cyclic
242-
static bool blockIsInLoop(Block *block);
242+
static bool blockIsInLoop(::mlir::Block *block);
243243
}];
244244

245245
let extraSharedClassDeclaration = [{
@@ -249,23 +249,23 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> {
249249
auto inductionVars = $_op.getLoopInductionVars();
250250
if (inductionVars.has_value() && (*inductionVars).size() == 1)
251251
return (*inductionVars)[0];
252-
return std::nullopt;
252+
return ::std::nullopt;
253253
}
254254
/// Return the single lower bound value or attribute if it exists, otherwise
255255
/// return std::nullopt.
256256
::std::optional<::mlir::OpFoldResult> getSingleLowerBound() {
257257
auto lowerBounds = $_op.getLoopLowerBounds();
258258
if (lowerBounds.has_value() && (*lowerBounds).size() == 1)
259259
return (*lowerBounds)[0];
260-
return std::nullopt;
260+
return ::std::nullopt;
261261
}
262262
/// Return the single step value or attribute if it exists, otherwise
263263
/// return std::nullopt.
264264
::std::optional<::mlir::OpFoldResult> getSingleStep() {
265265
auto steps = $_op.getLoopSteps();
266266
if (steps.has_value() && (*steps).size() == 1)
267267
return (*steps)[0];
268-
return std::nullopt;
268+
return ::std::nullopt;
269269
}
270270
/// Return the single upper bound value or attribute if it exists, otherwise
271271
/// return std::nullopt.
@@ -287,8 +287,9 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> {
287287
bool replaceInitOperandUsesInLoop) {
288288
return $_op.replaceWithAdditionalYields(
289289
rewriter, newInitOperands, replaceInitOperandUsesInLoop,
290-
[](OpBuilder &b, Location loc, ArrayRef<BlockArgument> newBBArgs) {
291-
return SmallVector<Value>(newBBArgs);
290+
[](::mlir::OpBuilder &b, ::mlir::Location loc,
291+
::mlir::ArrayRef<::mlir::BlockArgument> newBBArgs) {
292+
return ::mlir::SmallVector<::mlir::Value>(newBBArgs);
292293
});
293294
}
294295

@@ -298,9 +299,9 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> {
298299
auto mutableValues = $_op.getYieldedValuesMutable();
299300
if (!mutableValues || mutableValues->empty())
300301
return {};
301-
Operation *yieldOp = mutableValues->begin()->getOwner();
302+
::mlir::Operation *yieldOp = mutableValues->begin()->getOwner();
302303
unsigned firstOperandIndex = mutableValues->begin()->getOperandNumber();
303-
return OperandRange(
304+
return ::mlir::OperandRange(
304305
yieldOp->operand_begin() + firstOperandIndex,
305306
yieldOp->operand_begin() + firstOperandIndex + mutableValues->size());
306307
}
@@ -312,15 +313,16 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> {
312313
if (initsMutable.empty())
313314
return ::mlir::OperandRange($_op->operand_end(), $_op->operand_end());
314315
unsigned firstOperandIndex = initsMutable.begin()->getOperandNumber();
315-
return OperandRange(
316+
return ::mlir::OperandRange(
316317
$_op->operand_begin() + firstOperandIndex,
317318
$_op->operand_begin() + firstOperandIndex + initsMutable.size());
318319
}
319320

320321
/// Return the region iter_arg that corresponds to the given init operand.
321322
/// Return an "empty" block argument if the given operand is not an init
322323
/// operand of this loop op.
323-
BlockArgument getTiedLoopRegionIterArg(OpOperand *opOperand) {
324+
::mlir::BlockArgument getTiedLoopRegionIterArg(
325+
::mlir::OpOperand *opOperand) {
324326
auto initsMutable = $_op.getInitsMutable();
325327
auto it = llvm::find(initsMutable, *opOperand);
326328
if (it == initsMutable.end())
@@ -331,88 +333,90 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> {
331333
/// Return the region iter_arg that corresponds to the given loop result.
332334
/// Return an "empty" block argument if the given OpResult is not a loop
333335
/// result or if this op does not expose any loop results.
334-
BlockArgument getTiedLoopRegionIterArg(OpResult opResult) {
336+
::mlir::BlockArgument getTiedLoopRegionIterArg(::mlir::OpResult opResult) {
335337
auto loopResults = $_op.getLoopResults();
336338
if (!loopResults)
337339
return {};
338340
auto it = llvm::find(*loopResults, opResult);
339341
if (it == loopResults->end())
340342
return {};
341-
return $_op.getRegionIterArgs()[std::distance(loopResults->begin(), it)];
343+
return $_op.getRegionIterArgs()[
344+
::std::distance(loopResults->begin(), it)];
342345
}
343346

344347
/// Return the init operand that corresponds to the given region iter_arg.
345348
/// Return "nullptr" if the given block argument is not a region iter_arg
346349
/// of this loop op.
347-
OpOperand *getTiedLoopInit(BlockArgument bbArg) {
350+
::mlir::OpOperand *getTiedLoopInit(::mlir::BlockArgument bbArg) {
348351
auto iterArgs = $_op.getRegionIterArgs();
349-
auto it = llvm::find(iterArgs, bbArg);
352+
auto it = ::llvm::find(iterArgs, bbArg);
350353
if (it == iterArgs.end())
351354
return {};
352-
return &$_op.getInitsMutable()[std::distance(iterArgs.begin(), it)];
355+
return &$_op.getInitsMutable()[::std::distance(iterArgs.begin(), it)];
353356
}
354357

355358
/// Return the init operand that corresponds to the given loop result.
356359
/// Return "nullptr" if the given OpResult is not a loop result or if this
357360
/// op does not expose any loop results.
358-
OpOperand *getTiedLoopInit(OpResult opResult) {
361+
::mlir::OpOperand *getTiedLoopInit(::mlir::OpResult opResult) {
359362
auto loopResults = $_op.getLoopResults();
360363
if (!loopResults)
361364
return nullptr;
362-
auto it = llvm::find(*loopResults, opResult);
365+
auto it = ::llvm::find(*loopResults, opResult);
363366
if (it == loopResults->end())
364367
return nullptr;
365-
return &$_op.getInitsMutable()[std::distance(loopResults->begin(), it)];
368+
return &$_op.getInitsMutable()[::std::distance(
369+
loopResults->begin(), it)];
366370
}
367371

368372
/// Return the yielded value that corresponds to the given region iter_arg.
369373
/// Return "nullptr" if the given block argument is not a region iter_arg
370374
/// of this loop op or if there is no yield corresponding to this `bbArg`.
371-
OpOperand *getTiedLoopYieldedValue(BlockArgument bbArg) {
375+
::mlir::OpOperand *getTiedLoopYieldedValue(::mlir::BlockArgument bbArg) {
372376
auto iterArgs = $_op.getRegionIterArgs();
373-
auto it = llvm::find(iterArgs, bbArg);
377+
auto it = ::llvm::find(iterArgs, bbArg);
374378
if (it == iterArgs.end())
375379
return {};
376-
std::optional<llvm::MutableArrayRef<::mlir::OpOperand>> yieldValues =
380+
::std::optional<::llvm::MutableArrayRef<::mlir::OpOperand>> yieldValues =
377381
$_op.getYieldedValuesMutable();
378382
if (!yieldValues)
379383
return {};
380-
return &yieldValues.value()[std::distance(iterArgs.begin(), it)];
384+
return &yieldValues.value()[::std::distance(iterArgs.begin(), it)];
381385
}
382386

383387
/// Return the loop result that corresponds to the given init operand.
384388
/// Return an "empty" OpResult if the given operand is not an init operand
385389
/// of this loop op or if this op does not expose any loop results.
386-
OpResult getTiedLoopResult(OpOperand *opOperand) {
390+
::mlir::OpResult getTiedLoopResult(::mlir::OpOperand *opOperand) {
387391
auto loopResults = $_op.getLoopResults();
388392
if (!loopResults)
389393
return {};
390394
auto initsMutable = $_op.getInitsMutable();
391-
auto it = llvm::find(initsMutable, *opOperand);
395+
auto it = ::llvm::find(initsMutable, *opOperand);
392396
if (it == initsMutable.end())
393397
return {};
394-
return (*loopResults)[std::distance(initsMutable.begin(), it)];
398+
return (*loopResults)[::std::distance(initsMutable.begin(), it)];
395399
}
396400

397401
/// Return the loop result that corresponds to the given region iter_arg.
398402
/// Return an "empty" OpResult if the given block argument is not a region
399403
/// iter_arg of this loop op or if this op does not expose any loop results.
400-
OpResult getTiedLoopResult(BlockArgument bbArg) {
404+
::mlir::OpResult getTiedLoopResult(::mlir::BlockArgument bbArg) {
401405
auto loopResults = $_op.getLoopResults();
402406
if (!loopResults)
403407
return {};
404408
auto iterArgs = $_op.getRegionIterArgs();
405-
auto it = llvm::find(iterArgs, bbArg);
409+
auto it = ::llvm::find(iterArgs, bbArg);
406410
if (it == iterArgs.end())
407411
return {};
408-
return (*loopResults)[std::distance(iterArgs.begin(), it)];
412+
return (*loopResults)[::std::distance(iterArgs.begin(), it)];
409413
}
410414
}];
411415

412416
let verifyWithRegions = 1;
413417

414418
let verify = [{
415-
return detail::verifyLoopLikeOpInterface($_op);
419+
return ::mlir::detail::verifyLoopLikeOpInterface($_op);
416420
}];
417421
}
418422

0 commit comments

Comments
 (0)