[mlir] Replace deprecated 'getAttrs'

'getAttrs' has been explicitly marked deprecated. This patch refactors
to use Operation::getAttrs().

Reviewed By: csigg

Differential Revision: https://reviews.llvm.org/D97546
This commit is contained in:
Marius Brehler 2021-02-26 13:28:32 +00:00
parent ec7b9b0c18
commit 56774bdda5
8 changed files with 18 additions and 16 deletions

View File

@ -56,7 +56,7 @@ GPUFuncOpLowering::matchAndRewrite(gpu::GPUFuncOp gpuFuncOp,
// Create the new function operation. Only copy those attributes that are
// not specific to function modeling.
SmallVector<NamedAttribute, 4> attributes;
for (const auto &attr : gpuFuncOp.getAttrs()) {
for (const auto &attr : gpuFuncOp->getAttrs()) {
if (attr.first == SymbolTable::getSymbolAttrName() ||
attr.first == impl::getTypeAttrName() ||
attr.first == gpu::GPUFuncOp::getNumWorkgroupAttributionsAttrName())

View File

@ -194,7 +194,7 @@ lowerAsEntryFunction(gpu::GPUFuncOp funcOp, TypeConverter &typeConverter,
funcOp.getLoc(), funcOp.getName(),
rewriter.getFunctionType(signatureConverter.getConvertedTypes(),
llvm::None));
for (const auto &namedAttr : funcOp.getAttrs()) {
for (const auto &namedAttr : funcOp->getAttrs()) {
if (namedAttr.first == impl::getTypeAttrName() ||
namedAttr.first == SymbolTable::getSymbolAttrName())
continue;

View File

@ -28,7 +28,7 @@ struct RegionOpConversion : public ConvertOpToLLVMPattern<OpType> {
matchAndRewrite(OpType curOp, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
auto newOp = rewriter.create<OpType>(curOp.getLoc(), TypeRange(), operands,
curOp.getAttrs());
curOp->getAttrs());
rewriter.inlineRegionBefore(curOp.region(), newOp.region(),
newOp.region().end());
if (failed(rewriter.convertRegionTypes(&newOp.region(),

View File

@ -520,7 +520,7 @@ static LogicalResult processParallelLoop(
// Propagate custom user defined optional attributes, that can be used at
// later stage, such as extension data for GPU kernel dispatch
for (const auto &namedAttr : parallelOp.getAttrs()) {
for (const auto &namedAttr : parallelOp->getAttrs()) {
if (namedAttr.first == gpu::getMappingAttrName() ||
namedAttr.first == ParallelOp::getOperandSegmentSizeAttr())
continue;

View File

@ -1216,7 +1216,8 @@ static void wrapForExternalCallers(OpBuilder &rewriter, Location loc,
FuncOp funcOp, LLVM::LLVMFuncOp newFuncOp) {
auto type = funcOp.getType();
SmallVector<NamedAttribute, 4> attributes;
filterFuncAttributes(funcOp.getAttrs(), /*filterArgAttrs=*/false, attributes);
filterFuncAttributes(funcOp->getAttrs(), /*filterArgAttrs=*/false,
attributes);
auto wrapperFuncOp = rewriter.create<LLVM::LLVMFuncOp>(
loc, llvm::formatv("_mlir_ciface_{0}", funcOp.getName()).str(),
typeConverter.convertFunctionTypeCWrapper(type), LLVM::Linkage::External,
@ -1265,7 +1266,8 @@ static void wrapExternalFunction(OpBuilder &builder, Location loc,
assert(wrapperType && "unexpected type conversion failure");
SmallVector<NamedAttribute, 4> attributes;
filterFuncAttributes(funcOp.getAttrs(), /*filterArgAttrs=*/false, attributes);
filterFuncAttributes(funcOp->getAttrs(), /*filterArgAttrs=*/false,
attributes);
// Create the auxiliary function.
auto wrapperFunc = builder.create<LLVM::LLVMFuncOp>(
@ -1343,7 +1345,7 @@ protected:
// Propagate argument attributes to all converted arguments obtained after
// converting a given original argument.
SmallVector<NamedAttribute, 4> attributes;
filterFuncAttributes(funcOp.getAttrs(), /*filterArgAttrs=*/true,
filterFuncAttributes(funcOp->getAttrs(), /*filterArgAttrs=*/true,
attributes);
for (unsigned i = 0, e = funcOp.getNumArguments(); i < e; ++i) {
auto attr = impl::getArgAttrDict(funcOp, i);
@ -2127,7 +2129,7 @@ struct CallOpInterfaceLowering : public ConvertOpToLLVMPattern<CallOpType> {
rewriter);
auto newOp = rewriter.create<LLVM::CallOp>(
callOp.getLoc(), packedResult ? TypeRange(packedResult) : TypeRange(),
promoted, callOp.getAttrs());
promoted, callOp->getAttrs());
SmallVector<Value, 4> results;
if (numResults < 2) {
@ -3034,7 +3036,7 @@ struct OneToOneLLVMTerminatorLowering
matchAndRewrite(SourceOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
rewriter.replaceOpWithNewOp<TargetOp>(op, operands, op->getSuccessors(),
op.getAttrs());
op->getAttrs());
return success();
}
};
@ -3082,12 +3084,12 @@ struct ReturnOpLowering : public ConvertOpToLLVMPattern<ReturnOp> {
// If ReturnOp has 0 or 1 operand, create it and return immediately.
if (numArguments == 0) {
rewriter.replaceOpWithNewOp<LLVM::ReturnOp>(op, TypeRange(), ValueRange(),
op.getAttrs());
op->getAttrs());
return success();
}
if (numArguments == 1) {
rewriter.replaceOpWithNewOp<LLVM::ReturnOp>(
op, TypeRange(), updatedOperands, op.getAttrs());
op, TypeRange(), updatedOperands, op->getAttrs());
return success();
}
@ -3103,7 +3105,7 @@ struct ReturnOpLowering : public ConvertOpToLLVMPattern<ReturnOp> {
rewriter.getI64ArrayAttr(i));
}
rewriter.replaceOpWithNewOp<LLVM::ReturnOp>(op, TypeRange(), packed,
op.getAttrs());
op->getAttrs());
return success();
}
};

View File

@ -2556,7 +2556,7 @@ static void print(spirv::ModuleOp moduleOp, OpAsmPrinter &printer) {
elidedAttrs.push_back(spirv::ModuleOp::getVCETripleAttrName());
}
printer.printOptionalAttrDictWithKeyword(moduleOp.getAttrs(), elidedAttrs);
printer.printOptionalAttrDictWithKeyword(moduleOp->getAttrs(), elidedAttrs);
printer.printRegion(moduleOp.body(), /*printEntryBlockArgs=*/false,
/*printBlockTerminators=*/false);
}

View File

@ -498,7 +498,7 @@ FuncOpConversion::matchAndRewrite(FuncOp funcOp, ArrayRef<Value> operands,
: TypeRange()));
// Copy over all attributes other than the function name and type.
for (const auto &namedAttr : funcOp.getAttrs()) {
for (const auto &namedAttr : funcOp->getAttrs()) {
if (namedAttr.first != impl::getTypeAttrName() &&
namedAttr.first != SymbolTable::getSymbolAttrName())
newFuncOp->setAttr(namedAttr.first, namedAttr.second);

View File

@ -804,9 +804,9 @@ static void print(OpAsmPrinter &p, StringAttrPrettyNameOp op) {
}
if (namesDisagree)
p.printOptionalAttrDictWithKeyword(op.getAttrs());
p.printOptionalAttrDictWithKeyword(op->getAttrs());
else
p.printOptionalAttrDictWithKeyword(op.getAttrs(), {"names"});
p.printOptionalAttrDictWithKeyword(op->getAttrs(), {"names"});
}
// We set the SSA name in the asm syntax to the contents of the name