[flang-commits] [flang] 1ffc1aa - [mlir] Use mlir::OpState::operator->() to get to methods of mlir::Operation.
Christian Sigg via flang-commits
flang-commits at lists.llvm.org
Sun Dec 13 00:58:28 PST 2020
Author: Christian Sigg
Date: 2020-12-13T09:58:16+01:00
New Revision: 1ffc1aaa09674824ce66600ee0b77d6a2c042e68
URL: https://github.com/llvm/llvm-project/commit/1ffc1aaa09674824ce66600ee0b77d6a2c042e68
DIFF: https://github.com/llvm/llvm-project/commit/1ffc1aaa09674824ce66600ee0b77d6a2c042e68.diff
LOG: [mlir] Use mlir::OpState::operator->() to get to methods of mlir::Operation.
This is a preparation step to remove those methods from OpState.
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D93098
Added:
Modified:
flang/include/flang/Optimizer/Dialect/FIROps.td
mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
mlir/include/mlir/Dialect/Affine/IR/AffineOps.td
mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td
mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
mlir/include/mlir/IR/FunctionSupport.h
mlir/include/mlir/IR/Operation.h
mlir/include/mlir/IR/SymbolInterfaces.td
mlir/lib/Analysis/Utils.cpp
mlir/lib/Conversion/GPUCommon/ConvertKernelFuncToBlob.cpp
mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp
mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp
mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp
mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
mlir/lib/Dialect/Affine/IR/AffineOps.cpp
mlir/lib/Dialect/Affine/Utils/Utils.cpp
mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Dialect/Linalg/Transforms/Interchange.cpp
mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp
mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp
mlir/lib/Dialect/Vector/VectorOps.cpp
mlir/lib/Dialect/Vector/VectorTransforms.cpp
mlir/test/lib/Dialect/SPIRV/TestEntryPointAbi.cpp
mlir/test/lib/Dialect/Test/TestDialect.cpp
mlir/test/lib/Dialect/Test/TestOps.td
mlir/test/lib/Dialect/Test/TestPatterns.cpp
mlir/test/lib/Transforms/TestCallGraph.cpp
mlir/test/mlir-tblgen/op-attribute.td
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
mlir/tools/mlir-tblgen/OpFormatGen.cpp
mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
Removed:
################################################################################
diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index 9f477aa81b0c..4ffca0395804 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -2700,7 +2700,7 @@ def fir_GlobalOp : fir_Op<"global", [IsolatedFromAbove, Symbol]> {
p.printAttributeWithoutType(getAttr(symbolAttrName()));
if (auto val = getValueOrNull())
p << '(' << val << ')';
- if (getAttr(constantAttrName()))
+ if ((*this)->getAttr(constantAttrName()))
p << " constant";
p << " : ";
p.printType(getType());
diff --git a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
index c4bed26bfc29..b097f18e8cea 100644
--- a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
+++ b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
@@ -107,7 +107,7 @@ class AffineDmaStartOp
/// Returns the affine map used to access the src memref.
AffineMap getSrcMap() { return getSrcMapAttr().getValue(); }
AffineMapAttr getSrcMapAttr() {
- return getAttr(getSrcMapAttrName()).cast<AffineMapAttr>();
+ return (*this)->getAttr(getSrcMapAttrName()).cast<AffineMapAttr>();
}
/// Returns the source memref affine map indices for this DMA operation.
@@ -146,7 +146,7 @@ class AffineDmaStartOp
/// Returns the affine map used to access the dst memref.
AffineMap getDstMap() { return getDstMapAttr().getValue(); }
AffineMapAttr getDstMapAttr() {
- return getAttr(getDstMapAttrName()).cast<AffineMapAttr>();
+ return (*this)->getAttr(getDstMapAttrName()).cast<AffineMapAttr>();
}
/// Returns the destination memref indices for this DMA operation.
@@ -175,7 +175,7 @@ class AffineDmaStartOp
/// Returns the affine map used to access the tag memref.
AffineMap getTagMap() { return getTagMapAttr().getValue(); }
AffineMapAttr getTagMapAttr() {
- return getAttr(getTagMapAttrName()).cast<AffineMapAttr>();
+ return (*this)->getAttr(getTagMapAttrName()).cast<AffineMapAttr>();
}
/// Returns the tag memref indices for this DMA operation.
@@ -289,7 +289,7 @@ class AffineDmaWaitOp
/// Returns the affine map used to access the tag memref.
AffineMap getTagMap() { return getTagMapAttr().getValue(); }
AffineMapAttr getTagMapAttr() {
- return getAttr(getTagMapAttrName()).cast<AffineMapAttr>();
+ return (*this)->getAttr(getTagMapAttrName()).cast<AffineMapAttr>();
}
// Returns the tag memref index for this DMA operation.
diff --git a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td
index 5b1180889072..cc63603f6c90 100644
--- a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td
+++ b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td
@@ -258,18 +258,18 @@ def AffineForOp : Affine_Op<"for",
/// Returns loop step.
int64_t getStep() {
- return getAttr(getStepAttrName()).cast<IntegerAttr>().getInt();
+ return (*this)->getAttr(getStepAttrName()).cast<IntegerAttr>().getInt();
}
/// Returns affine map for the lower bound.
AffineMap getLowerBoundMap() { return getLowerBoundMapAttr().getValue(); }
AffineMapAttr getLowerBoundMapAttr() {
- return getAttr(getLowerBoundAttrName()).cast<AffineMapAttr>();
+ return (*this)->getAttr(getLowerBoundAttrName()).cast<AffineMapAttr>();
}
/// Returns affine map for the upper bound. The upper bound is exclusive.
AffineMap getUpperBoundMap() { return getUpperBoundMapAttr().getValue(); }
AffineMapAttr getUpperBoundMapAttr() {
- return getAttr(getUpperBoundAttrName()).cast<AffineMapAttr>();
+ return (*this)->getAttr(getUpperBoundAttrName()).cast<AffineMapAttr>();
}
/// Set lower bound. The new bound must have the same number of operands as
@@ -289,8 +289,8 @@ def AffineForOp : Affine_Op<"for",
void setStep(int64_t step) {
assert(step > 0 && "step has to be a positive integer constant");
auto *context = getLowerBoundMap().getContext();
- setAttr(Identifier::get(getStepAttrName(), context),
- IntegerAttr::get(IndexType::get(context), step));
+ (*this)->setAttr(Identifier::get(getStepAttrName(), context),
+ IntegerAttr::get(IndexType::get(context), step));
}
/// Returns number of region arguments for loop-carried values.
@@ -471,7 +471,7 @@ class AffineLoadOpBase<string mnemonic, list<OpTrait> traits = []> :
/// Returns the affine map used to index the memref for this operation.
AffineMapAttr getAffineMapAttr() {
- return getAttr(getMapAttrName()).cast<AffineMapAttr>();
+ return (*this)->getAttr(getMapAttrName()).cast<AffineMapAttr>();
}
static StringRef getMapAttrName() { return "map"; }
@@ -749,7 +749,7 @@ def AffinePrefetchOp : Affine_Op<"prefetch"> {
/// Returns the affine map used to index the memref for this operation.
AffineMap getAffineMap() { return getAffineMapAttr().getValue(); }
AffineMapAttr getAffineMapAttr() {
- return getAttr(getMapAttrName()).cast<AffineMapAttr>();
+ return (*this)->getAttr(getMapAttrName()).cast<AffineMapAttr>();
}
/// Returns the AffineMapAttr associated with 'memref'.
@@ -789,7 +789,7 @@ class AffineStoreOpBase<string mnemonic, list<OpTrait> traits = []> :
/// Returns the affine map used to index the memref for this operation.
AffineMapAttr getAffineMapAttr() {
- return getAttr(getMapAttrName()).cast<AffineMapAttr>();
+ return (*this)->getAttr(getMapAttrName()).cast<AffineMapAttr>();
}
/// Returns the AffineMapAttr associated with 'memref'.
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td
index fcf3e86a014d..380eaed74b30 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td
@@ -748,7 +748,7 @@ def LinalgStructuredInterface : OpInterface<"LinalgOp"> {
/*args=*/(ins),
/*methodBody=*/"",
/*defaultImplementation=*/[{
- return $_op.getAttr(getSparseAttrName()).template dyn_cast_or_null<ArrayAttr>() != nullptr;
+ return $_op->getAttr(getSparseAttrName()).template dyn_cast_or_null<ArrayAttr>() != nullptr;
}]
>,
InterfaceMethod<
@@ -849,7 +849,7 @@ def LinalgStructuredInterface : OpInterface<"LinalgOp"> {
[{
BlockAndValueMapping map;
unsigned numRegions = $_op->getNumRegions();
- Operation *res = create(b, loc, resultTypes, operands, $_op.getAttrs());
+ Operation *res = create(b, loc, resultTypes, operands, $_op->getAttrs());
assert(res->getNumRegions() == numRegions && "inconsistent # regions");
for (unsigned ridx = 0; ridx < numRegions; ++ridx)
$_op->getRegion(ridx).cloneInto(
@@ -908,7 +908,7 @@ def LinalgStructuredInterface : OpInterface<"LinalgOp"> {
private:
void setOperandSegmentAt(unsigned idx, unsigned val) {
- auto attr = getOperation()->getAttr("operand_segment_sizes")
+ auto attr = (*this)->getAttr("operand_segment_sizes")
.cast<DenseIntElementsAttr>();
unsigned i = 0;
auto newAttr = attr.mapValues(IntegerType::get(32, getContext()),
diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
index 89934cf7648e..c218618eb111 100644
--- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
+++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
@@ -1388,7 +1388,7 @@ def ConstantOp : Std_Op<"constant",
[{ build($_builder, $_state, value.getType(), value); }]>];
let extraClassDeclaration = [{
- Attribute getValue() { return getAttr("value"); }
+ Attribute getValue() { return (*this)->getAttr("value"); }
/// Returns true if a constant operation can be built with the given value
/// and result type.
diff --git a/mlir/include/mlir/IR/FunctionSupport.h b/mlir/include/mlir/IR/FunctionSupport.h
index 324e777ec788..2d28c457e413 100644
--- a/mlir/include/mlir/IR/FunctionSupport.h
+++ b/mlir/include/mlir/IR/FunctionSupport.h
@@ -549,7 +549,7 @@ void FunctionLike<ConcreteType>::setType(FunctionType newType) {
concreteOp->removeAttr(getArgAttrName(i, nameBuf));
for (int i = newType.getNumResults(), e = oldType.getNumResults(); i < e; i++)
concreteOp->removeAttr(getResultAttrName(i, nameBuf));
- concreteOp->setAttr(getTypeAttrName(), TypeAttr::get(newType));
+ (*concreteOp)->setAttr(getTypeAttrName(), TypeAttr::get(newType));
}
//===----------------------------------------------------------------------===//
diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h
index 0c295027923d..b63a09fcd244 100644
--- a/mlir/include/mlir/IR/Operation.h
+++ b/mlir/include/mlir/IR/Operation.h
@@ -318,6 +318,7 @@ class alignas(8) Operation final
/// Using a MutableDictionaryAttr is more efficient as it does not require new
/// uniquing in the MLIRContext.
void setAttrs(MutableDictionaryAttr newAttrs) { attrs = newAttrs; }
+ void setAttrs(ArrayRef<NamedAttribute> newAttrs) { attrs = newAttrs; }
/// Return the specified attribute if present, null otherwise.
Attribute getAttr(Identifier name) { return attrs.get(name); }
diff --git a/mlir/include/mlir/IR/SymbolInterfaces.td b/mlir/include/mlir/IR/SymbolInterfaces.td
index 83cd6bdbd861..f5158f238985 100644
--- a/mlir/include/mlir/IR/SymbolInterfaces.td
+++ b/mlir/include/mlir/IR/SymbolInterfaces.td
@@ -164,7 +164,7 @@ def Symbol : OpInterface<"SymbolOpInterface"> {
// If this is an optional symbol, bail out early if possible.
auto concreteOp = cast<ConcreteOp>($_op);
if (concreteOp.isOptionalSymbol()) {
- if(!concreteOp.getAttr(::mlir::SymbolTable::getSymbolAttrName()))
+ if(!concreteOp->getAttr(::mlir::SymbolTable::getSymbolAttrName()))
return success();
}
if (::mlir::failed(::mlir::detail::verifySymbol($_op)))
diff --git a/mlir/lib/Analysis/Utils.cpp b/mlir/lib/Analysis/Utils.cpp
index b51966858175..a1e7d1ffe844 100644
--- a/mlir/lib/Analysis/Utils.cpp
+++ b/mlir/lib/Analysis/Utils.cpp
@@ -829,7 +829,7 @@ void mlir::getComputationSliceState(
for (unsigned i = 0; i < numSliceLoopIVs; ++i) {
Value iv = getSliceLoop(i).getInductionVar();
if (sequentialLoops.count(iv) == 0 &&
- getSliceLoop(i).getAttr(kSliceFusionBarrierAttrName) == nullptr)
+ getSliceLoop(i)->getAttr(kSliceFusionBarrierAttrName) == nullptr)
continue;
for (unsigned j = i; j < numSliceLoopIVs; ++j) {
sliceState->lbs[j] = AffineMap();
diff --git a/mlir/lib/Conversion/GPUCommon/ConvertKernelFuncToBlob.cpp b/mlir/lib/Conversion/GPUCommon/ConvertKernelFuncToBlob.cpp
index 5d6f74458612..f21ee1f23547 100644
--- a/mlir/lib/Conversion/GPUCommon/ConvertKernelFuncToBlob.cpp
+++ b/mlir/lib/Conversion/GPUCommon/ConvertKernelFuncToBlob.cpp
@@ -70,7 +70,7 @@ class GpuKernelToBlobPass
// attribute to the module.
if (auto blobAttr = translateGPUModuleToBinaryAnnotation(
*llvmModule, module.getLoc(), module.getName()))
- module.setAttr(blobAnnotation, blobAttr);
+ module->setAttr(blobAnnotation, blobAttr);
else
signalPassFailure();
}
diff --git a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp
index c7ad1c7dc270..1b25ffd0943f 100644
--- a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp
+++ b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp
@@ -197,7 +197,7 @@ lowerAsEntryFunction(gpu::GPUFuncOp funcOp, SPIRVTypeConverter &typeConverter,
if (namedAttr.first == impl::getTypeAttrName() ||
namedAttr.first == SymbolTable::getSymbolAttrName())
continue;
- newFuncOp.setAttr(namedAttr.first, namedAttr.second);
+ newFuncOp->setAttr(namedAttr.first, namedAttr.second);
}
rewriter.inlineRegionBefore(funcOp.getBody(), newFuncOp.getBody(),
diff --git a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
index 2da29303513f..fbb860f9e2ea 100644
--- a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
+++ b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
@@ -175,12 +175,12 @@ void ConvertGpuLaunchFuncToVulkanLaunchFunc::convertGpuLaunchFunc(
vulkanLaunchOperands);
// Set SPIR-V binary shader data as an attribute.
- vulkanLaunchCallOp.setAttr(
+ vulkanLaunchCallOp->setAttr(
kSPIRVBlobAttrName,
StringAttr::get({binary.data(), binary.size()}, loc->getContext()));
// Set entry point name as an attribute.
- vulkanLaunchCallOp.setAttr(
+ vulkanLaunchCallOp->setAttr(
kSPIRVEntryPointAttrName,
StringAttr::get(launchOp.getKernelName(), loc->getContext()));
diff --git a/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp b/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp
index 5bb1db46e4af..f884a15bd017 100644
--- a/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp
+++ b/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp
@@ -76,7 +76,7 @@ static FlatSymbolRefAttr getLibraryCallSymbolRef(Operation *op,
// Insert a function attribute that will trigger the emission of the
// corresponding `_mlir_ciface_xxx` interface so that external libraries see
// a normalized ABI. This interface is added during std to llvm conversion.
- funcOp.setAttr("llvm.emit_c_interface", UnitAttr::get(op->getContext()));
+ funcOp->setAttr("llvm.emit_c_interface", UnitAttr::get(op->getContext()));
funcOp.setPrivate();
return fnNameAttr;
}
diff --git a/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp b/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp
index 39b0d62c7645..c011dfde2ab0 100644
--- a/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp
+++ b/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp
@@ -524,7 +524,7 @@ static LogicalResult processParallelLoop(
if (namedAttr.first == gpu::getMappingAttrName() ||
namedAttr.first == ParallelOp::getOperandSegmentSizeAttr())
continue;
- launchOp.setAttr(namedAttr.first, namedAttr.second);
+ launchOp->setAttr(namedAttr.first, namedAttr.second);
}
Block *body = parallelOp.getBody();
@@ -648,6 +648,6 @@ void mlir::populateParallelLoopToGPUPatterns(OwningRewritePatternList &patterns,
void mlir::configureParallelLoopToGPULegality(ConversionTarget &target) {
target.addDynamicallyLegalOp<scf::ParallelOp>([](scf::ParallelOp parallelOp) {
- return !parallelOp.getAttr(gpu::getMappingAttrName());
+ return !parallelOp->getAttr(gpu::getMappingAttrName());
});
}
diff --git a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp
index 5309daec5e52..935433cf11a8 100644
--- a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp
+++ b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp
@@ -1302,17 +1302,17 @@ class FuncConversionPattern : public SPIRVToLLVMConversion<spirv::FuncOp> {
switch (funcOp.function_control()) {
#define DISPATCH(functionControl, llvmAttr) \
case functionControl: \
- newFuncOp.setAttr("passthrough", ArrayAttr::get({llvmAttr}, context)); \
+ newFuncOp->setAttr("passthrough", ArrayAttr::get({llvmAttr}, context)); \
break;
- DISPATCH(spirv::FunctionControl::Inline,
- StringAttr::get("alwaysinline", context));
- DISPATCH(spirv::FunctionControl::DontInline,
- StringAttr::get("noinline", context));
- DISPATCH(spirv::FunctionControl::Pure,
- StringAttr::get("readonly", context));
- DISPATCH(spirv::FunctionControl::Const,
- StringAttr::get("readnone", context));
+ DISPATCH(spirv::FunctionControl::Inline,
+ StringAttr::get("alwaysinline", context));
+ DISPATCH(spirv::FunctionControl::DontInline,
+ StringAttr::get("noinline", context));
+ DISPATCH(spirv::FunctionControl::Pure,
+ StringAttr::get("readonly", context));
+ DISPATCH(spirv::FunctionControl::Const,
+ StringAttr::get("readnone", context));
#undef DISPATCH
diff --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
index 2f6856dc275a..939bc7d50e27 100644
--- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
+++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
@@ -4154,8 +4154,8 @@ struct LLVMLoweringPass : public ConvertStandardToLLVMBase<LLVMLoweringPass> {
LLVMConversionTarget target(getContext());
if (failed(applyPartialConversion(m, target, std::move(patterns))))
signalPassFailure();
- m.setAttr(LLVM::LLVMDialect::getDataLayoutAttrName(),
- StringAttr::get(this->dataLayout, m.getContext()));
+ m->setAttr(LLVM::LLVMDialect::getDataLayoutAttrName(),
+ StringAttr::get(this->dataLayout, m.getContext()));
}
};
} // end namespace
diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
index d1d577799b39..3fd1b62a5d2d 100644
--- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
+++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
@@ -1796,7 +1796,7 @@ void AffineForOp::setLowerBound(ValueRange lbOperands, AffineMap map) {
newOperands.append(iterOperands.begin(), iterOperands.end());
(*this)->setOperands(newOperands);
- setAttr(getLowerBoundAttrName(), AffineMapAttr::get(map));
+ (*this)->setAttr(getLowerBoundAttrName(), AffineMapAttr::get(map));
}
void AffineForOp::setUpperBound(ValueRange ubOperands, AffineMap map) {
@@ -1809,7 +1809,7 @@ void AffineForOp::setUpperBound(ValueRange ubOperands, AffineMap map) {
newOperands.append(iterOperands.begin(), iterOperands.end());
(*this)->setOperands(newOperands);
- setAttr(getUpperBoundAttrName(), AffineMapAttr::get(map));
+ (*this)->setAttr(getUpperBoundAttrName(), AffineMapAttr::get(map));
}
void AffineForOp::setLowerBoundMap(AffineMap map) {
@@ -1818,7 +1818,7 @@ void AffineForOp::setLowerBoundMap(AffineMap map) {
lbMap.getNumSymbols() == map.getNumSymbols());
assert(map.getNumResults() >= 1 && "bound map has at least one result");
(void)lbMap;
- setAttr(getLowerBoundAttrName(), AffineMapAttr::get(map));
+ (*this)->setAttr(getLowerBoundAttrName(), AffineMapAttr::get(map));
}
void AffineForOp::setUpperBoundMap(AffineMap map) {
@@ -1827,7 +1827,7 @@ void AffineForOp::setUpperBoundMap(AffineMap map) {
ubMap.getNumSymbols() == map.getNumSymbols());
assert(map.getNumResults() >= 1 && "bound map has at least one result");
(void)ubMap;
- setAttr(getUpperBoundAttrName(), AffineMapAttr::get(map));
+ (*this)->setAttr(getUpperBoundAttrName(), AffineMapAttr::get(map));
}
bool AffineForOp::hasConstantLowerBound() {
@@ -2128,7 +2128,7 @@ IntegerSet AffineIfOp::getIntegerSet() {
.getValue();
}
void AffineIfOp::setIntegerSet(IntegerSet newSet) {
- setAttr(getConditionAttrName(), IntegerSetAttr::get(newSet));
+ (*this)->setAttr(getConditionAttrName(), IntegerSetAttr::get(newSet));
}
void AffineIfOp::setConditional(IntegerSet set, ValueRange operands) {
@@ -2412,7 +2412,7 @@ static LogicalResult verifyAffineMinMaxOp(T op) {
template <typename T>
static void printAffineMinMaxOp(OpAsmPrinter &p, T op) {
- p << op.getOperationName() << ' ' << op.getAttr(T::getMapAttrName());
+ p << op.getOperationName() << ' ' << op->getAttr(T::getMapAttrName());
auto operands = op.getOperands();
unsigned numDims = op.map().getNumDims();
p << '(' << operands.take_front(numDims) << ')';
@@ -2461,7 +2461,7 @@ static OpFoldResult foldMinMaxOp(T op, ArrayRef<Attribute> operands) {
// If the map is the same, report that folding did not happen.
if (foldedMap == op.map())
return {};
- op.setAttr("map", AffineMapAttr::get(foldedMap));
+ op->setAttr("map", AffineMapAttr::get(foldedMap));
return op.getResult();
}
@@ -2673,8 +2673,8 @@ void AffineParallelOp::build(OpBuilder &builder, OperationState &result,
result.addOperands(lbArgs);
result.addOperands(ubArgs);
// Create a region and a block for the body.
- auto bodyRegion = result.addRegion();
- auto body = new Block();
+ auto *bodyRegion = result.addRegion();
+ auto *body = new Block();
// Add all the block arguments.
for (unsigned i = 0; i < numDims; ++i)
body->addArgument(IndexType::get(builder.getContext()));
diff --git a/mlir/lib/Dialect/Affine/Utils/Utils.cpp b/mlir/lib/Dialect/Affine/Utils/Utils.cpp
index b57b2908d635..844a02f8aa21 100644
--- a/mlir/lib/Dialect/Affine/Utils/Utils.cpp
+++ b/mlir/lib/Dialect/Affine/Utils/Utils.cpp
@@ -92,7 +92,7 @@ static AffineIfOp hoistAffineIfOp(AffineIfOp ifOp, Operation *hoistOverOp) {
operandMap.clear();
b.setInsertionPointAfter(hoistOverOp);
// We'll set an attribute to identify this op in a clone of this sub-tree.
- ifOp.setAttr(idForIfOp, b.getBoolAttr(true));
+ ifOp->setAttr(idForIfOp, b.getBoolAttr(true));
hoistOverOpClone = b.clone(*hoistOverOp, operandMap);
// Promote the 'then' block of the original affine.if in the then version.
@@ -107,7 +107,7 @@ static AffineIfOp hoistAffineIfOp(AffineIfOp ifOp, Operation *hoistOverOp) {
// Find the clone of the original affine.if op in the else version.
AffineIfOp ifCloneInElse;
hoistOverOpClone->walk([&](AffineIfOp ifClone) {
- if (!ifClone.getAttr(idForIfOp))
+ if (!ifClone->getAttr(idForIfOp))
return WalkResult::advance();
ifCloneInElse = ifClone;
return WalkResult::interrupt();
diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
index ee66ede11214..e8a90acf8830 100644
--- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
+++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
@@ -524,7 +524,8 @@ static void printLaunchFuncOperands(OpAsmPrinter &printer, Operation *,
BlockArgument GPUFuncOp::addWorkgroupAttribution(Type type) {
auto attrName = getNumWorkgroupAttributionsAttrName();
auto attr = (*this)->getAttrOfType<IntegerAttr>(attrName);
- setAttr(attrName, IntegerAttr::get(attr.getType(), attr.getValue() + 1));
+ (*this)->setAttr(attrName,
+ IntegerAttr::get(attr.getType(), attr.getValue() + 1));
return getBody().insertArgument(getType().getNumInputs() + attr.getInt(),
type);
}
@@ -701,7 +702,7 @@ void GPUFuncOp::setType(FunctionType newType) {
for (int i = newType.getNumInputs(), e = oldType.getNumInputs(); i < e; i++)
removeAttr(getArgAttrName(i, nameBuf));
- setAttr(getTypeAttrName(), TypeAttr::get(newType));
+ (*this)->setAttr(getTypeAttrName(), TypeAttr::get(newType));
}
/// Hook for FunctionLike verifier.
diff --git a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
index ac5fe8c9458d..83bc316a86f6 100644
--- a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
@@ -157,8 +157,8 @@ static gpu::GPUFuncOp outlineKernelFuncImpl(gpu::LaunchOp launchOp,
FunctionType type =
FunctionType::get(kernelOperandTypes, {}, launchOp.getContext());
auto outlinedFunc = builder.create<gpu::GPUFuncOp>(loc, kernelFnName, type);
- outlinedFunc.setAttr(gpu::GPUDialect::getKernelFuncAttrName(),
- builder.getUnitAttr());
+ outlinedFunc->setAttr(gpu::GPUDialect::getKernelFuncAttrName(),
+ builder.getUnitAttr());
BlockAndValueMapping map;
// Map the arguments corresponding to the launch parameters like blockIdx,
@@ -269,8 +269,8 @@ class GpuKernelOutliningPass
// If any new module was inserted in this module, annotate this module as
// a container module.
if (modified)
- getOperation().setAttr(gpu::GPUDialect::getContainerModuleAttrName(),
- UnitAttr::get(&getContext()));
+ getOperation()->setAttr(gpu::GPUDialect::getContainerModuleAttrName(),
+ UnitAttr::get(&getContext()));
}
private:
diff --git a/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp b/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp
index 43a27db9df69..1b0fecab36c9 100644
--- a/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp
@@ -52,8 +52,8 @@ LogicalResult setMappingAttr(scf::ParallelOp ploopOp,
"invalid mapping multiple loops to same processor");
}
ArrayRef<Attribute> mappingAsAttrs(mapping.data(), mapping.size());
- ploopOp.setAttr(getMappingAttrName(),
- ArrayAttr::get(mappingAsAttrs, ploopOp.getContext()));
+ ploopOp->setAttr(getMappingAttrName(),
+ ArrayAttr::get(mappingAsAttrs, ploopOp.getContext()));
return success();
}
} // namespace gpu
@@ -122,7 +122,7 @@ static gpu::Processor getHardwareIdForMapping(MappingLevel level,
static void mapParallelOp(ParallelOp parallelOp,
MappingLevel mappingLevel = MapGrid) {
// Do not try to add a mapping to already mapped loops or nested loops.
- if (parallelOp.getAttr(getMappingAttrName()) ||
+ if (parallelOp->getAttr(getMappingAttrName()) ||
((mappingLevel == MapGrid) && parallelOp->getParentOfType<ParallelOp>()))
return;
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index 4c48dccad096..1c03037644bb 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -1738,8 +1738,8 @@ static ParseResult parseFenceOp(OpAsmParser &parser, OperationState &result) {
static void printFenceOp(OpAsmPrinter &p, FenceOp &op) {
StringRef syncscopeKeyword = "syncscope";
p << op.getOperationName() << ' ';
- if (!op.getAttr(syncscopeKeyword).cast<StringAttr>().getValue().empty())
- p << "syncscope(" << op.getAttr(syncscopeKeyword) << ") ";
+ if (!op->getAttr(syncscopeKeyword).cast<StringAttr>().getValue().empty())
+ p << "syncscope(" << op->getAttr(syncscopeKeyword) << ") ";
p << stringifyAtomicOrdering(op.ordering());
}
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Interchange.cpp b/mlir/lib/Dialect/Linalg/Transforms/Interchange.cpp
index b191cbea9482..a7f0660281b5 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Interchange.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Interchange.cpp
@@ -76,10 +76,10 @@ LinalgOp mlir::linalg::interchange(LinalgOp op,
itTypesVector.push_back(itTypes[i]);
applyPermutationToVector(itTypesVector, interchangeVector);
- op.setAttr(getIndexingMapsAttrName(),
- ArrayAttr::get(newIndexingMaps, context));
- op.setAttr(getIteratorTypesAttrName(),
- ArrayAttr::get(itTypesVector, context));
+ op->setAttr(getIndexingMapsAttrName(),
+ ArrayAttr::get(newIndexingMaps, context));
+ op->setAttr(getIteratorTypesAttrName(),
+ ArrayAttr::get(itTypesVector, context));
return op;
}
diff --git a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp b/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
index 756e318ac399..d629e2229ce6 100644
--- a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
+++ b/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
@@ -496,7 +496,7 @@ FuncOpConversion::matchAndRewrite(FuncOp funcOp, ArrayRef<Value> operands,
for (const auto &namedAttr : funcOp.getAttrs()) {
if (namedAttr.first != impl::getTypeAttrName() &&
namedAttr.first != SymbolTable::getSymbolAttrName())
- newFuncOp.setAttr(namedAttr.first, namedAttr.second);
+ newFuncOp->setAttr(namedAttr.first, namedAttr.second);
}
rewriter.inlineRegionBefore(funcOp.getBody(), newFuncOp.getBody(),
@@ -656,7 +656,7 @@ mlir::spirv::setABIAttrs(spirv::FuncOp funcOp,
for (auto argIndex : llvm::seq<unsigned>(0, argABIInfo.size())) {
funcOp.setArgAttr(argIndex, argABIAttrName, argABIInfo[argIndex]);
}
- funcOp.setAttr(spirv::getEntryPointABIAttrName(), entryPointInfo);
+ funcOp->setAttr(spirv::getEntryPointABIAttrName(), entryPointInfo);
return success();
}
diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp
index ea67db378798..97d1b6e534b0 100644
--- a/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp
+++ b/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp
@@ -721,19 +721,20 @@ LogicalResult Deserializer::processExtInstImport(ArrayRef<uint32_t> words) {
}
void Deserializer::attachVCETriple() {
- module->setAttr(spirv::ModuleOp::getVCETripleAttrName(),
- spirv::VerCapExtAttr::get(version, capabilities.getArrayRef(),
- extensions.getArrayRef(), context));
+ (*module)->setAttr(
+ spirv::ModuleOp::getVCETripleAttrName(),
+ spirv::VerCapExtAttr::get(version, capabilities.getArrayRef(),
+ extensions.getArrayRef(), context));
}
LogicalResult Deserializer::processMemoryModel(ArrayRef<uint32_t> operands) {
if (operands.size() != 2)
return emitError(unknownLoc, "OpMemoryModel must have two operands");
- module->setAttr(
+ (*module)->setAttr(
"addressing_model",
opBuilder.getI32IntegerAttr(llvm::bit_cast<int32_t>(operands.front())));
- module->setAttr(
+ (*module)->setAttr(
"memory_model",
opBuilder.getI32IntegerAttr(llvm::bit_cast<int32_t>(operands.back())));
@@ -1035,7 +1036,7 @@ spirv::SpecConstantOp Deserializer::createSpecConstant(Location loc,
defaultValue);
if (decorations.count(resultID)) {
for (auto attr : decorations[resultID].getAttrs())
- op.setAttr(attr.first, attr.second);
+ op->setAttr(attr.first, attr.second);
}
specConstMap[resultID] = op;
return op;
@@ -1105,7 +1106,7 @@ LogicalResult Deserializer::processGlobalVariable(ArrayRef<uint32_t> operands) {
// Decorations.
if (decorations.count(variableID)) {
for (auto attr : decorations[variableID].getAttrs()) {
- varOp.setAttr(attr.first, attr.second);
+ varOp->setAttr(attr.first, attr.second);
}
}
globalVariableMap[variableID] = varOp;
diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
index 691cf973f06c..38f9e5c53a13 100644
--- a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
+++ b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
@@ -915,7 +915,7 @@ LogicalResult Serializer::processVariableOp(spirv::VariableOp op) {
resultID = getNextID();
valueIDMap[op.getResult()] = resultID;
operands.push_back(resultID);
- auto attr = op.getAttr(spirv::attributeName<spirv::StorageClass>());
+ auto attr = op->getAttr(spirv::attributeName<spirv::StorageClass>());
if (attr) {
operands.push_back(static_cast<uint32_t>(
attr.cast<IntegerAttr>().getValue().getZExtValue()));
@@ -930,7 +930,7 @@ LogicalResult Serializer::processVariableOp(spirv::VariableOp op) {
}
emitDebugLine(functionHeader, op.getLoc());
encodeInstructionInto(functionHeader, spirv::Opcode::OpVariable, operands);
- for (auto attr : op.getAttrs()) {
+ for (auto attr : op->getAttrs()) {
if (llvm::any_of(elidedAttrs,
[&](StringRef elided) { return attr.first == elided; })) {
continue;
@@ -999,7 +999,7 @@ Serializer::processGlobalVariableOp(spirv::GlobalVariableOp varOp) {
}
// Encode decorations.
- for (auto attr : varOp.getAttrs()) {
+ for (auto attr : varOp->getAttrs()) {
if (llvm::any_of(elidedAttrs,
[&](StringRef elided) { return attr.first == elided; })) {
continue;
@@ -2071,28 +2071,28 @@ Serializer::processOp<spirv::CopyMemoryOp>(spirv::CopyMemoryOp op) {
operands.push_back(id);
}
- if (auto attr = op.getAttr("memory_access")) {
+ if (auto attr = op->getAttr("memory_access")) {
operands.push_back(static_cast<uint32_t>(
attr.cast<IntegerAttr>().getValue().getZExtValue()));
}
elidedAttrs.push_back("memory_access");
- if (auto attr = op.getAttr("alignment")) {
+ if (auto attr = op->getAttr("alignment")) {
operands.push_back(static_cast<uint32_t>(
attr.cast<IntegerAttr>().getValue().getZExtValue()));
}
elidedAttrs.push_back("alignment");
- if (auto attr = op.getAttr("source_memory_access")) {
+ if (auto attr = op->getAttr("source_memory_access")) {
operands.push_back(static_cast<uint32_t>(
attr.cast<IntegerAttr>().getValue().getZExtValue()));
}
elidedAttrs.push_back("source_memory_access");
- if (auto attr = op.getAttr("source_alignment")) {
+ if (auto attr = op->getAttr("source_alignment")) {
operands.push_back(static_cast<uint32_t>(
attr.cast<IntegerAttr>().getValue().getZExtValue()));
}
diff --git a/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp
index 13e04f80c2b8..00e9ffa813a9 100644
--- a/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp
+++ b/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp
@@ -169,7 +169,7 @@ void UpdateVCEPass::runOnOperation() {
auto triple = spirv::VerCapExtAttr::get(
deducedVersion, deducedCapabilities.getArrayRef(),
deducedExtensions.getArrayRef(), &getContext());
- module.setAttr(spirv::ModuleOp::getVCETripleAttrName(), triple);
+ module->setAttr(spirv::ModuleOp::getVCETripleAttrName(), triple);
}
std::unique_ptr<OperationPass<spirv::ModuleOp>>
diff --git a/mlir/lib/Dialect/Vector/VectorOps.cpp b/mlir/lib/Dialect/Vector/VectorOps.cpp
index fe26949ced10..c74ef88165ce 100644
--- a/mlir/lib/Dialect/Vector/VectorOps.cpp
+++ b/mlir/lib/Dialect/Vector/VectorOps.cpp
@@ -666,8 +666,8 @@ static LogicalResult foldExtractOpFromExtractChain(ExtractOp extractOp) {
// OpBuilder is only used as a helper to build an I64ArrayAttr.
OpBuilder b(extractOp.getContext());
std::reverse(globalPosition.begin(), globalPosition.end());
- extractOp.setAttr(ExtractOp::getPositionAttrName(),
- b.getI64ArrayAttr(globalPosition));
+ extractOp->setAttr(ExtractOp::getPositionAttrName(),
+ b.getI64ArrayAttr(globalPosition));
return success();
}
@@ -722,8 +722,8 @@ static LogicalResult foldExtractOpFromTranspose(ExtractOp extractOp) {
inversePermutation(permutationMap).compose(extractedPos);
// OpBuilder is only used as a helper to build an I64ArrayAttr.
OpBuilder b(extractOp.getContext());
- extractOp.setAttr(ExtractOp::getPositionAttrName(),
- b.getI64ArrayAttr(newExtractedPos));
+ extractOp->setAttr(ExtractOp::getPositionAttrName(),
+ b.getI64ArrayAttr(newExtractedPos));
return success();
}
@@ -832,8 +832,8 @@ static Value foldExtractFromBroadcast(ExtractOp extractOp) {
extractOp.setOperand(broadcastOp.source());
// OpBuilder is only used as a helper to build an I64ArrayAttr.
OpBuilder b(extractOp.getContext());
- extractOp.setAttr(ExtractOp::getPositionAttrName(),
- b.getI64ArrayAttr(extractPos));
+ extractOp->setAttr(ExtractOp::getPositionAttrName(),
+ b.getI64ArrayAttr(extractPos));
return extractOp.getResult();
}
// TODO: In case the rank of the broadcast source is greater than the rank of
@@ -895,8 +895,8 @@ static Value foldExtractFromShapeCast(ExtractOp extractOp) {
SmallVector<int64_t, 4> newPosition = delinearize(newStrides, position);
// OpBuilder is only used as a helper to build an I64ArrayAttr.
OpBuilder b(extractOp.getContext());
- extractOp.setAttr(ExtractOp::getPositionAttrName(),
- b.getI64ArrayAttr(newPosition));
+ extractOp->setAttr(ExtractOp::getPositionAttrName(),
+ b.getI64ArrayAttr(newPosition));
extractOp.setOperand(shapeCastOp.source());
return extractOp.getResult();
}
@@ -1737,8 +1737,8 @@ foldExtractStridedOpFromInsertChain(ExtractStridedSliceOp op) {
op.setOperand(insertOp.source());
// OpBuilder is only used as a helper to build an I64ArrayAttr.
OpBuilder b(op.getContext());
- op.setAttr(ExtractStridedSliceOp::getOffsetsAttrName(),
- b.getI64ArrayAttr(offsetDiffs));
+ op->setAttr(ExtractStridedSliceOp::getOffsetsAttrName(),
+ b.getI64ArrayAttr(offsetDiffs));
return success();
}
// If the chunk extracted is disjoint from the chunk inserted, keep looking
@@ -2135,7 +2135,7 @@ static LogicalResult foldTransferMaskAttribute(TransferOp op) {
return failure();
// OpBuilder is only used as a helper to build an I64ArrayAttr.
OpBuilder b(op.getContext());
- op.setAttr(TransferOp::getMaskedAttrName(), b.getBoolArrayAttr(isMasked));
+ op->setAttr(TransferOp::getMaskedAttrName(), b.getBoolArrayAttr(isMasked));
return success();
}
diff --git a/mlir/lib/Dialect/Vector/VectorTransforms.cpp b/mlir/lib/Dialect/Vector/VectorTransforms.cpp
index f7bfc66c3fdc..d3aa77a82f8c 100644
--- a/mlir/lib/Dialect/Vector/VectorTransforms.cpp
+++ b/mlir/lib/Dialect/Vector/VectorTransforms.cpp
@@ -2391,7 +2391,7 @@ LogicalResult mlir::vector::splitFullAndPartialTransfer(
SmallVector<bool, 4> bools(xferOp.getTransferRank(), false);
auto unmaskedAttr = b.getBoolArrayAttr(bools);
if (options.vectorTransferSplit == VectorTransferSplit::ForceUnmasked) {
- xferOp.setAttr(vector::TransferReadOp::getMaskedAttrName(), unmaskedAttr);
+ xferOp->setAttr(vector::TransferReadOp::getMaskedAttrName(), unmaskedAttr);
return success();
}
@@ -2447,7 +2447,7 @@ LogicalResult mlir::vector::splitFullAndPartialTransfer(
// Unmask the existing read op, it always reads from a full buffer.
for (unsigned i = 0, e = returnTypes.size(); i != e; ++i)
xferReadOp.setOperand(i, fullPartialIfOp.getResult(i));
- xferOp.setAttr(vector::TransferReadOp::getMaskedAttrName(), unmaskedAttr);
+ xferOp->setAttr(vector::TransferReadOp::getMaskedAttrName(), unmaskedAttr);
return success();
}
diff --git a/mlir/test/lib/Dialect/SPIRV/TestEntryPointAbi.cpp b/mlir/test/lib/Dialect/SPIRV/TestEntryPointAbi.cpp
index bcbdb828523d..b8b544a8f228 100644
--- a/mlir/test/lib/Dialect/SPIRV/TestEntryPointAbi.cpp
+++ b/mlir/test/lib/Dialect/SPIRV/TestEntryPointAbi.cpp
@@ -44,13 +44,13 @@ void TestSpirvEntryPointABIPass::runOnOperation() {
MLIRContext *context = &getContext();
StringRef attrName = spirv::getEntryPointABIAttrName();
for (gpu::GPUFuncOp gpuFunc : gpuModule.getOps<gpu::GPUFuncOp>()) {
- if (!gpu::GPUDialect::isKernel(gpuFunc) || gpuFunc.getAttr(attrName))
+ if (!gpu::GPUDialect::isKernel(gpuFunc) || gpuFunc->getAttr(attrName))
continue;
SmallVector<int32_t, 3> workgroupSizeVec(workgroupSize.begin(),
workgroupSize.end());
workgroupSizeVec.resize(3, 1);
- gpuFunc.setAttr(attrName,
- spirv::getEntryPointABIAttr(workgroupSizeVec, context));
+ gpuFunc->setAttr(attrName,
+ spirv::getEntryPointABIAttr(workgroupSizeVec, context));
}
}
diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp
index eeff840daeea..933b59dc5b8f 100644
--- a/mlir/test/lib/Dialect/Test/TestDialect.cpp
+++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp
@@ -674,7 +674,7 @@ LogicalResult TestOpWithVariadicResultsAndFolder::fold(
OpFoldResult TestOpInPlaceFold::fold(ArrayRef<Attribute> operands) {
assert(operands.size() == 1);
if (operands.front()) {
- setAttr("attr", operands.front());
+ (*this)->setAttr("attr", operands.front());
return getResult();
}
return {};
diff --git a/mlir/test/lib/Dialect/Test/TestOps.td b/mlir/test/lib/Dialect/Test/TestOps.td
index 9008ee7ca99f..6a7291abfec7 100644
--- a/mlir/test/lib/Dialect/Test/TestOps.td
+++ b/mlir/test/lib/Dialect/Test/TestOps.td
@@ -822,7 +822,7 @@ def TestOpConstant : TEST_Op<"constant", [ConstantLike, NoSideEffect]> {
let arguments = (ins AnyAttr:$value);
let results = (outs AnyType);
let extraClassDeclaration = [{
- Attribute getValue() { return getAttr("value"); }
+ Attribute getValue() { return (*this)->getAttr("value"); }
}];
let hasFolder = 1;
diff --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp
index 5aab1bbfe463..7795b79f76d6 100644
--- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp
+++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp
@@ -467,7 +467,7 @@ struct TestBoundedRecursiveRewrite
PatternRewriter &rewriter) const final {
// Decrement the depth of the op in-place.
rewriter.updateRootInPlace(op, [&] {
- op.setAttr("depth", rewriter.getI64IntegerAttr(op.depth() - 1));
+ op->setAttr("depth", rewriter.getI64IntegerAttr(op.depth() - 1));
});
return success();
}
diff --git a/mlir/test/lib/Transforms/TestCallGraph.cpp b/mlir/test/lib/Transforms/TestCallGraph.cpp
index 56182e28cd87..ee6458750174 100644
--- a/mlir/test/lib/Transforms/TestCallGraph.cpp
+++ b/mlir/test/lib/Transforms/TestCallGraph.cpp
@@ -20,7 +20,8 @@ namespace {
struct TestCallGraphPass
: public PassWrapper<TestCallGraphPass, OperationPass<ModuleOp>> {
void runOnOperation() override {
- llvm::errs() << "Testing : " << getOperation().getAttr("test.name") << "\n";
+ llvm::errs() << "Testing : " << getOperation()->getAttr("test.name")
+ << "\n";
getAnalysis<CallGraph>().print(llvm::errs());
}
};
diff --git a/mlir/test/mlir-tblgen/op-attribute.td b/mlir/test/mlir-tblgen/op-attribute.td
index e170d9f9fe0a..d5daebb57475 100644
--- a/mlir/test/mlir-tblgen/op-attribute.td
+++ b/mlir/test/mlir-tblgen/op-attribute.td
@@ -48,21 +48,21 @@ def AOp : NS_Op<"a_op", []> {
// ---
// DEF: some-attr-kind AOp::aAttrAttr()
-// DEF-NEXT: this->getAttr("aAttr").cast<some-attr-kind>()
+// DEF-NEXT: (*this)->getAttr("aAttr").cast<some-attr-kind>()
// DEF: some-return-type AOp::aAttr() {
// DEF-NEXT: auto attr = aAttrAttr()
// DEF-NEXT: return attr.some-convert-from-storage();
// DEF: some-attr-kind AOp::bAttrAttr()
-// DEF-NEXT: return this->getAttr("bAttr").dyn_cast_or_null<some-attr-kind>()
+// DEF-NEXT: return (*this)->getAttr("bAttr").dyn_cast_or_null<some-attr-kind>()
// DEF: some-return-type AOp::bAttr() {
// DEF-NEXT: auto attr = bAttrAttr();
// DEF-NEXT: if (!attr)
-// DEF-NEXT: return some-const-builder-call(::mlir::Builder(this->getContext()), 4.2).some-convert-from-storage();
+// DEF-NEXT: return some-const-builder-call(::mlir::Builder((*this)->getContext()), 4.2).some-convert-from-storage();
// DEF-NEXT: return attr.some-convert-from-storage();
// DEF: some-attr-kind AOp::cAttrAttr()
-// DEF-NEXT: return this->getAttr("cAttr").dyn_cast_or_null<some-attr-kind>()
+// DEF-NEXT: return (*this)->getAttr("cAttr").dyn_cast_or_null<some-attr-kind>()
// DEF: ::llvm::Optional<some-return-type> AOp::cAttr() {
// DEF-NEXT: auto attr = cAttrAttr()
// DEF-NEXT: return attr ? ::llvm::Optional<some-return-type>(attr.some-convert-from-storage()) : (::llvm::None);
@@ -164,11 +164,11 @@ def COp : NS_Op<"c_op", []> {
}
// DEF-LABEL: COp definitions
-// DEF: ::mlir::Builder(this->getContext()).getI32ArrayAttr({1, 2})
-// DEF: ::mlir::Builder(this->getContext()).getI64ArrayAttr({3, 4})
-// DEF: ::mlir::Builder(this->getContext()).getF32ArrayAttr({5.f, 6.f})
-// DEF: ::mlir::Builder(this->getContext()).getF64ArrayAttr({7., 8.})
-// DEF: ::mlir::Builder(this->getContext()).getStrArrayAttr({"a", "b"})
+// DEF: ::mlir::Builder((*this)->getContext()).getI32ArrayAttr({1, 2})
+// DEF: ::mlir::Builder((*this)->getContext()).getI64ArrayAttr({3, 4})
+// DEF: ::mlir::Builder((*this)->getContext()).getF32ArrayAttr({5.f, 6.f})
+// DEF: ::mlir::Builder((*this)->getContext()).getF64ArrayAttr({7., 8.})
+// DEF: ::mlir::Builder((*this)->getContext()).getStrArrayAttr({"a", "b"})
// Test builder method which takes unwrapped values for attributes
diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index c97aa043bb6c..5d756e708a43 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -479,7 +479,7 @@ void OpEmitter::emitDef(raw_ostream &os) { opClass.writeDefTo(os); }
void OpEmitter::genAttrGetters() {
FmtContext fctx;
- fctx.withBuilder("::mlir::Builder(this->getContext())");
+ fctx.withBuilder("::mlir::Builder((*this)->getContext())");
Dialect opDialect = op.getDialect();
// Emit the derived attribute body.
@@ -521,7 +521,7 @@ void OpEmitter::genAttrGetters() {
if (!method)
return;
auto &body = method->body();
- body << " return this->getAttr(\"" << name << "\").";
+ body << " return (*this)->getAttr(\"" << name << "\").";
if (attr.isOptional() || attr.hasDefaultValue())
body << "dyn_cast_or_null<";
else
@@ -837,13 +837,13 @@ void OpEmitter::genNamedRegionGetters() {
if (region.isVariadic()) {
auto *m = opClass.addMethodAndPrune("::mlir::MutableArrayRef<Region>",
region.name);
- m->body() << formatv(
- " return this->getOperation()->getRegions().drop_front({0});", i);
+ m->body() << formatv(" return (*this)->getRegions().drop_front({0});",
+ i);
continue;
}
auto *m = opClass.addMethodAndPrune("::mlir::Region &", region.name);
- m->body() << formatv(" return this->getOperation()->getRegion({0});", i);
+ m->body() << formatv(" return (*this)->getRegion({0});", i);
}
}
@@ -859,15 +859,14 @@ void OpEmitter::genNamedSuccessorGetters() {
auto *m =
opClass.addMethodAndPrune("::mlir::SuccessorRange", successor.name);
m->body() << formatv(
- " return {std::next(this->getOperation()->successor_begin(), {0}), "
- "this->getOperation()->successor_end()};",
+ " return {std::next((*this)->successor_begin(), {0}), "
+ "(*this)->successor_end()};",
i);
continue;
}
auto *m = opClass.addMethodAndPrune("::mlir::Block *", successor.name);
- m->body() << formatv(" return this->getOperation()->getSuccessor({0});",
- i);
+ m->body() << formatv(" return (*this)->getSuccessor({0});", i);
}
}
@@ -1826,16 +1825,16 @@ void OpEmitter::genVerifier() {
auto *method = opClass.addMethodAndPrune("::mlir::LogicalResult", "verify");
auto &body = method->body();
body << " if (failed(" << op.getAdaptorName()
- << "(*this).verify(this->getLoc()))) "
+ << "(*this).verify((*this)->getLoc()))) "
<< "return ::mlir::failure();\n";
auto *valueInit = def.getValueInit("verifier");
StringInit *stringInit = dyn_cast<StringInit>(valueInit);
bool hasCustomVerify = stringInit && !stringInit->getValue().empty();
- populateSubstitutions(op, "this->getAttr", "this->getODSOperands",
+ populateSubstitutions(op, "(*this)->getAttr", "this->getODSOperands",
"this->getODSResults", verifyCtx);
- genAttributeVerifier(op, "this->getAttr", "emitOpError(",
+ genAttributeVerifier(op, "(*this)->getAttr", "emitOpError(",
/*emitVerificationRequiringOp=*/true, verifyCtx, body);
genOperandResultVerifier(body, op.getOperands(), "operand");
genOperandResultVerifier(body, op.getResults(), "result");
@@ -1932,8 +1931,8 @@ void OpEmitter::genRegionVerifier(OpMethodBody &body) {
body << " for (::mlir::Region ®ion : ";
body << formatv(region.isVariadic()
? "{0}()"
- : "::mlir::MutableArrayRef<::mlir::Region>(this->"
- "getOperation()->getRegion({1}))",
+ : "::mlir::MutableArrayRef<::mlir::Region>((*this)"
+ "->getRegion({1}))",
region.name, i);
body << ") {\n";
auto constraint = tgfmt(region.constraint.getConditionTemplate(),
diff --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
index 4b53c18b7717..e09cdd2ac6d4 100644
--- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
@@ -1640,7 +1640,7 @@ void OperationFormat::genElementPrinter(Element *element, OpMethodBody &body,
body << " if (!" << var->name << "().empty()) {\n";
} else {
- body << " if (getAttr(\""
+ body << " if ((*this)->getAttr(\""
<< cast<AttributeVariable>(anchor)->getVar()->name << "\")) {\n";
}
diff --git a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
index 6919a1032412..f5a40e290889 100644
--- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
+++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
@@ -491,7 +491,7 @@ static void emitAttributeSerialization(const Attribute &attr,
StringRef opVar, StringRef operandList,
StringRef attrName, raw_ostream &os) {
os << tabs
- << formatv("if (auto attr = {0}.getAttr(\"{1}\")) {{\n", opVar, attrName);
+ << formatv("if (auto attr = {0}->getAttr(\"{1}\")) {{\n", opVar, attrName);
if (attr.getAttrDefName() == "SPV_ScopeAttr" ||
attr.getAttrDefName() == "SPV_MemorySemanticsAttr") {
os << tabs
@@ -645,7 +645,7 @@ static void emitDecorationSerialization(const Operator &op, StringRef tabs,
StringRef resultID, raw_ostream &os) {
if (op.getNumResults() == 1) {
// All non-argument attributes translated into OpDecorate instruction
- os << tabs << formatv("for (auto attr : {0}.getAttrs()) {{\n", opVar);
+ os << tabs << formatv("for (auto attr : {0}->getAttrs()) {{\n", opVar);
os << tabs
<< formatv(" if (llvm::any_of({0}, [&](StringRef elided)", elidedAttrs);
os << " {return attr.first == elided;})) {\n";
More information about the flang-commits
mailing list