Skip to content

Commit

Permalink
[mlir][NFC] Use fully qualified C++ namespaces in .td files.
Browse files Browse the repository at this point in the history
Add missing llvm:: and mlir:: namespaces qualifiers to some auto-generated code.

Reviewed By: ftynse, springerm

Differential Revision: https://reviews.llvm.org/D143381
  • Loading branch information
vinograd47 committed Feb 6, 2023
1 parent 2dd221f commit 6da0184
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 43 deletions.
Expand Up @@ -463,7 +463,7 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
/*args=*/(ins "unsigned":$index),
/*methodBody=*/"",
/*defaultImplementation=*/[{
return mlir::bufferization::detail::defaultIsRepetitiveRegion(
return ::mlir::bufferization::detail::defaultIsRepetitiveRegion(
cast<BufferizableOpInterface>($_op.getOperation()), index);
}]
>
Expand All @@ -472,19 +472,21 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
let extraClassDeclaration = [{
/// Resolve out-of-place tensor OpOperands with explicit allocations in the
/// form of `bufferization.alloc_tensor` ops.
LogicalResult resolveTensorOpOperandConflicts(
RewriterBase &rewriter, const AnalysisState &state);
::mlir::LogicalResult resolveTensorOpOperandConflicts(
::mlir::RewriterBase &rewriter,
const ::mlir::bufferization::AnalysisState &state);

/// Return `true` if the given OpOperand creates an alias but does neither
/// read nor write. This implies that `bufferizesToMemoryRead` and
/// `bufferizesToMemoryWrite` must return `false`. This method will never
/// be called on OpOperands that do not have a tensor type.
///
/// Examples of such ops are `tensor.extract_slice` and `tensor.cast`.
bool bufferizesToAliasOnly(OpOperand &opOperand,
const AnalysisState &state) {
bool bufferizesToAliasOnly(
::mlir::OpOperand &opOperand,
const ::mlir::bufferization::AnalysisState &state) {
auto bufferizableOp =
cast<BufferizableOpInterface>(getOperation());
cast<::mlir::bufferization::BufferizableOpInterface>(getOperation());
return !bufferizableOp.bufferizesToMemoryRead(opOperand, state)
&& !bufferizableOp.bufferizesToMemoryWrite(opOperand, state)
&& !bufferizableOp.getAliasingOpResults(opOperand, state).empty();
Expand Down
40 changes: 20 additions & 20 deletions mlir/include/mlir/Interfaces/DestinationStyleOpInterface.td
Expand Up @@ -85,14 +85,14 @@ def DestinationStyleOpInterface : OpInterface<"DestinationStyleOpInterface"> {
>,
InterfaceMethod<
/*desc=*/"Return the init operands.",
/*retTy=*/"OpOperandVector",
/*retTy=*/"::mlir::OpOperandVector",
/*methodName=*/"getDpsInitOperands",
/*args=*/(ins),
/*methodBody=*/"",
/*defaultImplementation=*/[{
auto [start, end] = $_op.getDpsInitsPositionRange();

OpOperandVector result;
::mlir::OpOperandVector result;
result.reserve(end - start);
for (int i = start; i < end; ++i)
result.push_back(&$_op->getOpOperand(i));
Expand All @@ -101,7 +101,7 @@ def DestinationStyleOpInterface : OpInterface<"DestinationStyleOpInterface"> {
>,
InterfaceMethod<
/*desc=*/"Return the `i`-th init operand.",
/*retTy=*/"OpOperand *",
/*retTy=*/"::mlir::OpOperand *",
/*methodName=*/"getDpsInitOperand",
/*args=*/(ins "int64_t":$i),
/*methodBody=*/"",
Expand All @@ -115,7 +115,7 @@ def DestinationStyleOpInterface : OpInterface<"DestinationStyleOpInterface"> {
/*desc=*/"Set the `i`-th init operand.",
/*retTy=*/"void",
/*methodName=*/"setDpsInitOperand",
/*args=*/(ins "int64_t":$i, "Value":$value),
/*args=*/(ins "int64_t":$i, "::mlir::Value":$value),
/*methodBody=*/"",
/*defaultImplementation=*/[{
assert(i >= 0 && i < $_op.getNumDpsInits());
Expand All @@ -135,7 +135,7 @@ def DestinationStyleOpInterface : OpInterface<"DestinationStyleOpInterface"> {
>,
InterfaceMethod<
/*desc=*/"Return the input operands.",
/*retTy=*/"OpOperandVector",
/*retTy=*/"::mlir::OpOperandVector",
/*methodName=*/"getDpsInputOperands",
/*args=*/(ins),
/*methodBody=*/"",
Expand All @@ -144,7 +144,7 @@ def DestinationStyleOpInterface : OpInterface<"DestinationStyleOpInterface"> {
int64_t numInits = end - start;
int64_t numOperands = $_op.getNumOperands();

OpOperandVector result;
::mlir::OpOperandVector result;
result.reserve(numOperands - numInits);
for (int i = 0; i < start; ++i)
result.push_back(&$_op->getOpOperand(i));
Expand All @@ -156,7 +156,7 @@ def DestinationStyleOpInterface : OpInterface<"DestinationStyleOpInterface"> {
>,
InterfaceMethod<
/*desc=*/[{ Return the `i`-th input operand. }],
/*retTy=*/"OpOperand *",
/*retTy=*/"::mlir::OpOperand *",
/*methodName=*/"getDpsInputOperand",
/*args=*/(ins "int64_t":$i),
/*methodBody=*/"",
Expand All @@ -173,7 +173,7 @@ def DestinationStyleOpInterface : OpInterface<"DestinationStyleOpInterface"> {
/*desc=*/"Return true if `opOperand` is an input.",
/*retTy=*/"bool",
/*methodName=*/"isDpsInput",
/*args=*/(ins "OpOperand *":$opOperand),
/*args=*/(ins "::mlir::OpOperand *":$opOperand),
/*methodBody=*/"",
/*defaultImplementation=*/[{
auto [start, end] = $_op.getDpsInitsPositionRange();
Expand All @@ -185,7 +185,7 @@ def DestinationStyleOpInterface : OpInterface<"DestinationStyleOpInterface"> {
/*desc=*/"Return true if `opOperand` is an init.",
/*retTy=*/"bool",
/*methodName=*/"isDpsInit",
/*args=*/(ins "OpOperand *":$opOperand),
/*args=*/(ins "::mlir::OpOperand *":$opOperand),
/*methodBody=*/"",
/*defaultImplementation=*/[{
auto [start, end] = $_op.getDpsInitsPositionRange();
Expand All @@ -197,7 +197,7 @@ def DestinationStyleOpInterface : OpInterface<"DestinationStyleOpInterface"> {
/*desc=*/"Return true if the `opOperand` is a scalar value.",
/*retTy=*/"bool",
/*methodName=*/"isScalar",
/*args=*/(ins "OpOperand *":$opOperand),
/*args=*/(ins "::mlir::OpOperand *":$opOperand),
/*methodBody=*/"",
/*defaultImplementation=*/[{
assert(opOperand->getOwner() == $_op.getOperation());
Expand All @@ -206,9 +206,9 @@ def DestinationStyleOpInterface : OpInterface<"DestinationStyleOpInterface"> {
>,
InterfaceMethod<
/*desc=*/"Return the OpResult that is tied to the given OpOperand.",
/*retTy=*/"OpResult",
/*retTy=*/"::mlir::OpResult",
/*methodName=*/"getTiedOpResult",
/*args=*/(ins "OpOperand *":$opOperand),
/*args=*/(ins "::mlir::OpOperand *":$opOperand),
/*methodBody=*/"",
/*defaultImplementation=*/[{
assert(opOperand->getOwner() == $_op.getOperation());
Expand All @@ -222,9 +222,9 @@ def DestinationStyleOpInterface : OpInterface<"DestinationStyleOpInterface"> {
>,
InterfaceMethod<
/*desc=*/"Return the OpOperand that is tied to the given OpResult.",
/*retTy=*/"OpOperand *",
/*retTy=*/"::mlir::OpOperand *",
/*methodName=*/"getTiedOpOperand",
/*args=*/(ins "OpResult":$opResult),
/*args=*/(ins "::mlir::OpResult":$opResult),
/*methodBody=*/"",
/*defaultImplementation=*/[{
assert(opResult.getDefiningOp() == $_op.getOperation());
Expand All @@ -242,10 +242,10 @@ def DestinationStyleOpInterface : OpInterface<"DestinationStyleOpInterface"> {
/*methodBody=*/"",
/*defaultImplementation=*/[{
return $_op->getNumResults() == 0 &&
llvm::all_of($_op->getOpOperands(),
[&](OpOperand &opOperand) {
::llvm::all_of($_op->getOpOperands(),
[&](::mlir::OpOperand &opOperand) {
return isScalar(&opOperand) ||
opOperand.get().getType().template isa<MemRefType>();
opOperand.get().getType().template isa<::mlir::MemRefType>();
});
}]
>,
Expand All @@ -256,10 +256,10 @@ def DestinationStyleOpInterface : OpInterface<"DestinationStyleOpInterface"> {
/*args=*/(ins),
/*methodBody=*/"",
/*defaultImplementation=*/[{
return llvm::all_of($_op->getOpOperands(),
[&](OpOperand &opOperand) {
return ::llvm::all_of($_op->getOpOperands(),
[&](::mlir::OpOperand &opOperand) {
return isScalar(&opOperand) ||
opOperand.get().getType().template isa<RankedTensorType>();
opOperand.get().getType().template isa<::mlir::RankedTensorType>();
});
}]
>
Expand Down
37 changes: 20 additions & 17 deletions mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td
Expand Up @@ -61,57 +61,60 @@ class EffectOpInterfaceBase<string name, string baseEffect>
/// Collect all of the effect instances that correspond to the given
/// `Effect` and place them in 'effects'.
template <typename Effect> void getEffects(
SmallVectorImpl<::mlir::SideEffects::EffectInstance<
::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<
}] # baseEffect # [{>> &effects) {
getEffects(effects);
llvm::erase_if(effects, [&](auto &it) {
return !llvm::isa<Effect>(it.getEffect());
::llvm::erase_if(effects, [&](auto &it) {
return !::llvm::isa<Effect>(it.getEffect());
});
}

/// Returns true if this operation exhibits the given effect.
template <typename Effect> bool hasEffect() {
SmallVector<SideEffects::EffectInstance<}] # baseEffect # [{>, 4> effects;
::llvm::SmallVector<::mlir::SideEffects::EffectInstance<
}] # baseEffect # [{>, 4> effects;
getEffects(effects);
return llvm::any_of(effects, [](const auto &it) {
return llvm::isa<Effect>(it.getEffect());
return ::llvm::any_of(effects, [](const auto &it) {
return ::llvm::isa<Effect>(it.getEffect());
});
}

/// Returns true if this operation only has the given effect.
template <typename Effect> bool onlyHasEffect() {
SmallVector<SideEffects::EffectInstance<}] # baseEffect # [{>, 4> effects;
::llvm::SmallVector<::mlir::SideEffects::EffectInstance<
}] # baseEffect # [{>, 4> effects;
getEffects(effects);
return !effects.empty() && llvm::all_of(effects, [](const auto &it) {
return !effects.empty() && ::llvm::all_of(effects, [](const auto &it) {
return isa<Effect>(it.getEffect());
});
}

/// Returns true if this operation has no effects.
bool hasNoEffect() {
SmallVector<::mlir::SideEffects::EffectInstance<}] # baseEffect # [{>, 4> effects;
::llvm::SmallVector<::mlir::SideEffects::EffectInstance<
}] # baseEffect # [{>, 4> effects;
getEffects(effects);
return effects.empty();
}

/// Collect all of the effect instances that operate on the provided value
/// and place them in 'effects'.
void getEffectsOnValue(::mlir::Value value,
llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<
::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<
}] # baseEffect # [{>> & effects) {
getEffects(effects);
llvm::erase_if(effects, [&](auto &it) { return it.getValue() != value; });
::llvm::erase_if(effects, [&](auto &it) { return it.getValue() != value; });
}

/// Return the effect of the given type `Effect` that is applied to the
/// given value, or std::nullopt if no effect exists.
template <typename Effect>
::std::optional<::mlir::SideEffects::EffectInstance<}] # baseEffect # [{>>
getEffectOnValue(::mlir::Value value) {
llvm::SmallVector<::mlir::SideEffects::EffectInstance<
::llvm::SmallVector<::mlir::SideEffects::EffectInstance<
}] # baseEffect # [{>, 4> effects;
getEffects(effects);
auto it = llvm::find_if(effects, [&](auto &it) {
auto it = ::llvm::find_if(effects, [&](auto &it) {
return isa<Effect>(it.getEffect()) && it.getValue() == value;
});
if (it == effects.end())
Expand All @@ -122,21 +125,21 @@ class EffectOpInterfaceBase<string name, string baseEffect>
/// Collect all of the effect instances that operate on the provided symbol
/// reference and place them in 'effects'.
void getEffectsOnSymbol(::mlir::SymbolRefAttr value,
llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<
::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<
}] # baseEffect # [{>> & effects) {
getEffects(effects);
llvm::erase_if(effects, [&](auto &it) {
::llvm::erase_if(effects, [&](auto &it) {
return it.getSymbolRef() != value;
});
}

/// Collect all of the effect instances that operate on the provided
/// resource and place them in 'effects'.
void getEffectsOnResource(::mlir::SideEffects::Resource *resource,
llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<
::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<
}] # baseEffect # [{>> & effects) {
getEffects(effects);
llvm::erase_if(effects, [&](auto &it) {
::llvm::erase_if(effects, [&](auto &it) {
return it.getResource() != resource;
});
}
Expand Down

0 comments on commit 6da0184

Please sign in to comment.