diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td --- a/flang/include/flang/Optimizer/Dialect/FIROps.td +++ b/flang/include/flang/Optimizer/Dialect/FIROps.td @@ -249,7 +249,7 @@ }]; let printer = [{ - p << getOperationName() << ' ' << getAttr(inType()); + p << getOperationName() << ' ' << (*this)->getAttr(inType()); if (hasLenParams()) { // print the LEN parameters to a derived type in parens p << '(' << getLenParams() << " : " << getLenParams().getTypes() << ')'; @@ -267,7 +267,7 @@ static constexpr llvm::StringRef lenpName() { return "len_param_count"; } mlir::Type getAllocatedType(); - bool hasLenParams() { return bool{getAttr(lenpName())}; } + bool hasLenParams() { return bool{(*this)->getAttr(lenpName())}; } unsigned numLenParams() { if (auto val = (*this)->getAttrOfType(lenpName())) @@ -688,7 +688,7 @@ p << getOperationName() << ' '; p.printOperand(getSelector()); p << " : " << getSelector().getType() << " ["; - auto cases = getAttrOfType(getCasesAttr()).getValue(); + auto cases = (*this)->getAttrOfType(getCasesAttr()).getValue(); auto count = getNumConditions(); for (decltype(count) i = 0; i != count; ++i) { if (i) @@ -711,7 +711,7 @@ getSelector().getType().isa() || getSelector().getType().isa())) return emitOpError("must be an integer"); - auto cases = getAttrOfType(getCasesAttr()).getValue(); + auto cases = (*this)->getAttrOfType(getCasesAttr()).getValue(); auto count = getNumDest(); if (count == 0) return emitOpError("must have at least one successor"); @@ -810,7 +810,7 @@ p << getOperationName() << ' '; p.printOperand(getSelector()); p << " : " << getSelector().getType() << " ["; - auto cases = getAttrOfType(getCasesAttr()).getValue(); + auto cases = (*this)->getAttrOfType(getCasesAttr()).getValue(); auto count = getNumConditions(); for (decltype(count) i = 0; i != count; ++i) { if (i) @@ -839,7 +839,7 @@ getSelector().getType().isa() || getSelector().getType().isa())) return emitOpError("must be an integer, character, or logical"); - auto cases = getAttrOfType(getCasesAttr()).getValue(); + auto cases = (*this)->getAttrOfType(getCasesAttr()).getValue(); auto count = getNumDest(); if (count == 0) return emitOpError("must have at least one successor"); @@ -925,7 +925,7 @@ p << getOperationName() << ' '; p.printOperand(getSelector()); p << " : " << getSelector().getType() << " ["; - auto cases = getAttrOfType(getCasesAttr()).getValue(); + auto cases = (*this)->getAttrOfType(getCasesAttr()).getValue(); auto count = getNumConditions(); for (decltype(count) i = 0; i != count; ++i) { if (i) @@ -941,7 +941,7 @@ let verifier = [{ if (!(getSelector().getType().isa())) return emitOpError("must be a boxed type"); - auto cases = getAttrOfType(getCasesAttr()).getValue(); + auto cases = (*this)->getAttrOfType(getCasesAttr()).getValue(); auto count = getNumDest(); if (count == 0) return emitOpError("must have at least one successor"); @@ -1056,7 +1056,7 @@ if (getNumOperands() == 2) { p << ", "; p.printOperands(dims()); - } else if (auto map = getAttr(layoutName())) { + } else if (auto map = (*this)->getAttr(layoutName())) { p << " [" << map << ']'; } p.printOptionalAttrDict(getAttrs(), {layoutName(), lenpName()}); @@ -1097,9 +1097,9 @@ let extraClassDeclaration = [{ static constexpr llvm::StringRef layoutName() { return "layout_map"; } static constexpr llvm::StringRef lenpName() { return "len_param_count"; } - bool hasLenParams() { return bool{getAttr(lenpName())}; } + bool hasLenParams() { return bool{(*this)->getAttr(lenpName())}; } unsigned numLenParams() { - if (auto x = getAttrOfType(lenpName())) + if (auto x = (*this)->getAttrOfType(lenpName())) return x.getInt(); return 0; } @@ -1213,13 +1213,13 @@ }]; let printer = [{ - p << getOperationName() << ' ' << getAttr("funcname"); + p << getOperationName() << ' ' << (*this)->getAttr("funcname"); auto h = host(); if (h) { p << ", "; p.printOperand(h); } - p << " : (" << getAttr("functype"); + p << " : (" << (*this)->getAttr("functype"); if (h) p << ", " << h.getType(); p << ") -> " << getType(); @@ -1587,7 +1587,7 @@ if (!ref().getType().dyn_cast()) return emitOpError("len_param_index must be used on box type"); } - if (auto attr = getAttr(CoordinateOp::baseType())) { + if (auto attr = (*this)->getAttr(CoordinateOp::baseType())) { if (!attr.isa()) return emitOpError("improperly constructed"); } else { @@ -1690,8 +1690,8 @@ let printer = [{ p << getOperationName() << ' ' - << getAttrOfType(fieldAttrName()).getValue() << ", " - << getAttr(typeAttrName()); + << (*this)->getAttrOfType(fieldAttrName()).getValue() + << ", " << (*this)->getAttr(typeAttrName()); if (getNumOperands()) { p << '('; p.printOperands(lenparams()); @@ -1826,8 +1826,8 @@ let printer = [{ p << getOperationName() << ' ' - << getAttrOfType(fieldAttrName()).getValue() << ", " - << getAttr(typeAttrName()); + << (*this)->getAttrOfType(fieldAttrName()).getValue() + << ", " << (*this)->getAttr(typeAttrName()); }]; let builders = [ @@ -1841,7 +1841,7 @@ static constexpr llvm::StringRef fieldAttrName() { return "field_id"; } static constexpr llvm::StringRef typeAttrName() { return "on_type"; } mlir::Type getOnType() { - return getAttrOfType(typeAttrName()).getValue(); + return (*this)->getAttrOfType(typeAttrName()).getValue(); } }]; } @@ -2166,7 +2166,7 @@ }]; let printer = [{ - p << getOperationName() << ' ' << getAttr("method") << '('; + p << getOperationName() << ' ' << (*this)->getAttr("method") << '('; p.printOperand(object()); if (arg_operand_begin() != arg_operand_end()) { p << ", "; @@ -2250,7 +2250,7 @@ auto eleTy = getType().cast().getEleTy(); if (!eleTy.isa()) return emitOpError("must have !fir.char type"); - if (auto xl = getAttr(xlist())) { + if (auto xl = (*this)->getAttr(xlist())) { auto xList = xl.cast(); for (auto a : xList) if (!a.isa()) @@ -2265,12 +2265,12 @@ static constexpr const char *xlist() { return "xlist"; } // Get the LEN attribute of this character constant - mlir::Attribute getSize() { return getAttr(size()); } + mlir::Attribute getSize() { return (*this)->getAttr(size()); } // Get the string value of this character constant mlir::Attribute getValue() { - if (auto attr = getAttr(value())) + if (auto attr = (*this)->getAttr(value())) return attr; - return getAttr(xlist()); + return (*this)->getAttr(xlist()); } /// Is this a wide character literal (1 character > 8 bits) @@ -2381,7 +2381,7 @@ static CmpFPredicate getPredicateByName(llvm::StringRef name); CmpFPredicate getPredicate() { - return (CmpFPredicate)getAttrOfType( + return (CmpFPredicate)(*this)->getAttrOfType( getPredicateAttrName()).getInt(); } }]; @@ -2415,11 +2415,11 @@ let printer = [{ p << getOperationName() << " (0x"; - auto f1 = getAttr(realAttrName()).cast(); + auto f1 = (*this)->getAttr(realAttrName()).cast(); auto i1 = f1.getValue().bitcastToAPInt(); p.getStream().write_hex(i1.getZExtValue()); p << ", 0x"; - auto f2 = getAttr(imagAttrName()).cast(); + auto f2 = (*this)->getAttr(imagAttrName()).cast(); auto i2 = f2.getValue().bitcastToAPInt(); p.getStream().write_hex(i2.getZExtValue()); p << ") : "; @@ -2436,8 +2436,8 @@ static constexpr llvm::StringRef realAttrName() { return "real"; } static constexpr llvm::StringRef imagAttrName() { return "imaginary"; } - mlir::Attribute getReal() { return getAttr(realAttrName()); } - mlir::Attribute getImaginary() { return getAttr(imagAttrName()); } + mlir::Attribute getReal() { return (*this)->getAttr(realAttrName()); } + mlir::Attribute getImaginary() { return (*this)->getAttr(imagAttrName()); } }]; } @@ -2485,7 +2485,7 @@ } CmpFPredicate getPredicate() { - return (CmpFPredicate)getAttrOfType( + return (CmpFPredicate)(*this)->getAttrOfType( getPredicateAttrName()).getInt(); } }]; @@ -2601,7 +2601,7 @@ }]; let printer = [{ - p << getOperationName() << ' ' << getAttr("in_type"); + p << getOperationName() << ' ' << (*this)->getAttr("in_type"); p.printOptionalAttrDict(getAttrs(), {"in_type"}); }]; @@ -2623,7 +2623,7 @@ let extraClassDeclaration = [{ mlir::Type getInType() { // get the type that the type descriptor describes - return getAttrOfType("in_type").getValue(); + return (*this)->getAttrOfType("in_type").getValue(); } }]; } @@ -2697,7 +2697,7 @@ if (linkName().hasValue()) p << ' ' << linkName().getValue(); p << ' '; - p.printAttributeWithoutType(getAttr(symbolAttrName())); + p.printAttributeWithoutType((*this)->getAttr(symbolAttrName())); if (auto val = getValueOrNull()) p << '(' << val << ')'; if ((*this)->getAttr(constantAttrName())) @@ -2738,7 +2738,7 @@ /// The printable type of the global mlir::Type getType() { - return getAttrOfType(typeAttrName()).getValue(); + return (*this)->getAttrOfType(typeAttrName()).getValue(); } /// The semantic type of the global @@ -2768,8 +2768,9 @@ } mlir::FlatSymbolRefAttr getSymbol() { - return mlir::FlatSymbolRefAttr::get(getAttrOfType( - mlir::SymbolTable::getSymbolAttrName()).getValue(), getContext()); + return mlir::FlatSymbolRefAttr::get( + (*this)->getAttrOfType( + mlir::SymbolTable::getSymbolAttrName()).getValue(), getContext()); } }]; } @@ -2811,8 +2812,8 @@ }]; let printer = [{ - p << getOperationName() << ' ' << getAttr(lenParamAttrName()) << ", " - << getAttr(intAttrName()); + p << getOperationName() << ' ' << (*this)->getAttr(lenParamAttrName()) + << ", " << (*this)->getAttr(intAttrName()); }]; let extraClassDeclaration = [{ @@ -2865,7 +2866,7 @@ }]; let printer = [{ - auto tableName = getAttrOfType( + auto tableName = (*this)->getAttrOfType( mlir::SymbolTable::getSymbolAttrName()).getValue(); p << getOperationName() << " @" << tableName; @@ -2946,8 +2947,8 @@ }]; let printer = [{ - p << getOperationName() << ' ' << getAttr(methodAttrName()) << ", " - << getAttr(procAttrName()); + p << getOperationName() << ' ' << (*this)->getAttr(methodAttrName()) << ", " + << (*this)->getAttr(procAttrName()); }]; let extraClassDeclaration = [{ diff --git a/flang/include/flang/Optimizer/Dialect/FIROpsSupport.h b/flang/include/flang/Optimizer/Dialect/FIROpsSupport.h --- a/flang/include/flang/Optimizer/Dialect/FIROpsSupport.h +++ b/flang/include/flang/Optimizer/Dialect/FIROpsSupport.h @@ -18,7 +18,7 @@ /// return true iff the Operation is a non-volatile LoadOp inline bool nonVolatileLoad(mlir::Operation *op) { if (auto load = dyn_cast(op)) - return !load.getAttr("volatile"); + return !load->getAttr("volatile"); return false; } diff --git a/flang/lib/Lower/CharacterRuntime.cpp b/flang/lib/Lower/CharacterRuntime.cpp --- a/flang/lib/Lower/CharacterRuntime.cpp +++ b/flang/lib/Lower/CharacterRuntime.cpp @@ -62,7 +62,7 @@ return func; auto funTy = getTypeModel()(builder.getContext()); func = builder.createFunction(loc, name, funTy); - func.setAttr("fir.runtime", builder.getUnitAttr()); + func->setAttr("fir.runtime", builder.getUnitAttr()); return func; } diff --git a/flang/lib/Lower/IO.cpp b/flang/lib/Lower/IO.cpp --- a/flang/lib/Lower/IO.cpp +++ b/flang/lib/Lower/IO.cpp @@ -123,8 +123,8 @@ return func; auto funTy = getTypeModel()(builder.getContext()); func = builder.createFunction(loc, name, funTy); - func.setAttr("fir.runtime", builder.getUnitAttr()); - func.setAttr("fir.io", builder.getUnitAttr()); + func->setAttr("fir.runtime", builder.getUnitAttr()); + func->setAttr("fir.io", builder.getUnitAttr()); return func; } diff --git a/flang/lib/Lower/IntrinsicCall.cpp b/flang/lib/Lower/IntrinsicCall.cpp --- a/flang/lib/Lower/IntrinsicCall.cpp +++ b/flang/lib/Lower/IntrinsicCall.cpp @@ -497,7 +497,7 @@ const RuntimeFunction &runtime) { auto function = builder.addNamedFunction( loc, runtime.symbol, runtime.typeGenerator(builder.getContext())); - function.setAttr("fir.runtime", builder.getUnitAttr()); + function->setAttr("fir.runtime", builder.getUnitAttr()); return function; } @@ -769,7 +769,7 @@ if (!function) { // First time this wrapper is needed, build it. function = builder.createFunction(loc, wrapperName, funcType); - function.setAttr("fir.intrinsic", builder.getUnitAttr()); + function->setAttr("fir.intrinsic", builder.getUnitAttr()); function.addEntryBlock(); // Create local context to emit code into the newly created function diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp --- a/flang/lib/Lower/OpenACC.cpp +++ b/flang/lib/Lower/OpenACC.cpp @@ -98,8 +98,8 @@ builder.setInsertionPointToStart(&block); builder.create(loc); - op.setAttr(Op::getOperandSegmentSizeAttr(), - builder.getI32VectorAttr(operandSegments)); + op->setAttr(Op::getOperandSegmentSizeAttr(), + builder.getI32VectorAttr(operandSegments)); // Place the insertion point to the start of the first block. builder.setInsertionPointToStart(&block); @@ -114,8 +114,8 @@ const SmallVectorImpl &operandSegments) { llvm::ArrayRef argTy; Op op = builder.create(loc, argTy, operands); - op.setAttr(Op::getOperandSegmentSizeAttr(), - builder.getI32VectorAttr(operandSegments)); + op->setAttr(Op::getOperandSegmentSizeAttr(), + builder.getI32VectorAttr(operandSegments)); return op; } @@ -231,8 +231,8 @@ auto loopOp = createRegionOp( firOpBuilder, currentLocation, operands, operandSegments); - loopOp.setAttr(mlir::acc::LoopOp::getExecutionMappingAttrName(), - firOpBuilder.getI64IntegerAttr(executionMapping)); + loopOp->setAttr(mlir::acc::LoopOp::getExecutionMappingAttrName(), + firOpBuilder.getI64IntegerAttr(executionMapping)); // Lower clauses mapped to attributes for (const auto &clause : accClauseList.v) { @@ -241,19 +241,19 @@ const auto *expr = Fortran::semantics::GetExpr(collapseClause->v); const auto collapseValue = Fortran::evaluate::ToInt64(*expr); if (collapseValue) { - loopOp.setAttr(mlir::acc::LoopOp::getCollapseAttrName(), - firOpBuilder.getI64IntegerAttr(*collapseValue)); + loopOp->setAttr(mlir::acc::LoopOp::getCollapseAttrName(), + firOpBuilder.getI64IntegerAttr(*collapseValue)); } } else if (std::get_if(&clause.u)) { - loopOp.setAttr(mlir::acc::LoopOp::getSeqAttrName(), - firOpBuilder.getUnitAttr()); + loopOp->setAttr(mlir::acc::LoopOp::getSeqAttrName(), + firOpBuilder.getUnitAttr()); } else if (std::get_if( &clause.u)) { - loopOp.setAttr(mlir::acc::LoopOp::getIndependentAttrName(), - firOpBuilder.getUnitAttr()); + loopOp->setAttr(mlir::acc::LoopOp::getIndependentAttrName(), + firOpBuilder.getUnitAttr()); } else if (std::get_if(&clause.u)) { - loopOp.setAttr(mlir::acc::LoopOp::getAutoAttrName(), - firOpBuilder.getUnitAttr()); + loopOp->setAttr(mlir::acc::LoopOp::getAutoAttrName(), + firOpBuilder.getUnitAttr()); } } } @@ -425,14 +425,14 @@ firOpBuilder, currentLocation, operands, operandSegments); if (addAsyncAttr) - parallelOp.setAttr(mlir::acc::ParallelOp::getAsyncAttrName(), - firOpBuilder.getUnitAttr()); + parallelOp->setAttr(mlir::acc::ParallelOp::getAsyncAttrName(), + firOpBuilder.getUnitAttr()); if (addWaitAttr) - parallelOp.setAttr(mlir::acc::ParallelOp::getWaitAttrName(), - firOpBuilder.getUnitAttr()); + parallelOp->setAttr(mlir::acc::ParallelOp::getWaitAttrName(), + firOpBuilder.getUnitAttr()); if (addSelfAttr) - parallelOp.setAttr(mlir::acc::ParallelOp::getSelfAttrName(), - firOpBuilder.getUnitAttr()); + parallelOp->setAttr(mlir::acc::ParallelOp::getSelfAttrName(), + firOpBuilder.getUnitAttr()); } static void genACCDataOp(Fortran::lower::AbstractConverter &converter, diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp --- a/flang/lib/Optimizer/Dialect/FIROps.cpp +++ b/flang/lib/Optimizer/Dialect/FIROps.cpp @@ -166,7 +166,7 @@ p << callee.getValue(); else p << op.getOperand(0); - p << '(' << op.getOperands().drop_front(isDirect ? 0 : 1) << ')'; + p << '(' << op->getOperands().drop_front(isDirect ? 0 : 1) << ')'; p.printOptionalAttrDict(op.getAttrs(), {fir::CallOp::calleeAttrName()}); auto resultTypes{op.getResultTypes()}; llvm::SmallVector argTypes( @@ -240,7 +240,8 @@ static void printCmpOp(OpAsmPrinter &p, OPTY op) { p << op.getOperationName() << ' '; auto predSym = mlir::symbolizeCmpFPredicate( - op.template getAttrOfType(OPTY::getPredicateAttrName()) + op->template getAttrOfType( + OPTY::getPredicateAttrName()) .getInt()); assert(predSym.hasValue() && "invalid symbol value for predicate"); p << '"' << mlir::stringifyCmpFPredicate(predSym.getValue()) << '"' << ", "; @@ -385,7 +386,10 @@ } mlir::Type fir::CoordinateOp::getBaseType() { - return getAttr(CoordinateOp::baseType()).cast().getValue(); + return (*this) + ->getAttr(CoordinateOp::baseType()) + .cast() + .getValue(); } void fir::CoordinateOp::build(OpBuilder &, OperationState &result, @@ -412,7 +416,7 @@ //===----------------------------------------------------------------------===// mlir::FunctionType fir::DispatchOp::getFunctionType() { - auto attr = getAttr("fn_type").cast(); + auto attr = (*this)->getAttr("fn_type").cast(); return attr.getValue().cast(); } @@ -745,7 +749,7 @@ [&](auto it) { p << std::get<0>(it) << " = " << std::get<1>(it); }); p << ") -> (" << op.getResultTypes().drop_front() << ')'; } - p.printOptionalAttrDictWithKeyword(op.getAttrs(), {}); + p.printOptionalAttrDictWithKeyword(op->getAttrs(), {}); p.printRegion(op.region(), /*printEntryBlockArgs=*/false, /*printBlockTerminators=*/true); } @@ -930,7 +934,7 @@ p << ") -> (" << op.getResultTypes() << ')'; printBlockTerminators = true; } - p.printOptionalAttrDictWithKeyword(op.getAttrs(), + p.printOptionalAttrDictWithKeyword(op->getAttrs(), {fir::LoopOp::unorderedAttrName()}); p.printRegion(op.region(), /*printEntryBlockArgs=*/false, printBlockTerminators); @@ -963,9 +967,9 @@ //===----------------------------------------------------------------------===// static mlir::LogicalResult verify(fir::ResultOp op) { - auto parentOp = op.getParentOp(); + auto *parentOp = op->getParentOp(); auto results = parentOp->getResults(); - auto operands = op.getOperands(); + auto operands = op->getOperands(); if (parentOp->getNumResults() != op.getNumOperands()) return op.emitOpError() << "parent of result must have same arity"; @@ -1032,15 +1036,16 @@ llvm::Optional> fir::SelectOp::getSuccessorOperands(llvm::ArrayRef operands, unsigned oper) { - auto a = getAttrOfType(getTargetOffsetAttr()); - auto segments = - getAttrOfType(getOperandSegmentSizeAttr()); + auto a = + (*this)->getAttrOfType(getTargetOffsetAttr()); + auto segments = (*this)->getAttrOfType( + getOperandSegmentSizeAttr()); return {getSubOperands(oper, getSubOperands(2, operands, segments), a)}; } unsigned fir::SelectOp::targetOffsetSize() { - return denseElementsSize( - getAttrOfType(getTargetOffsetAttr())); + return denseElementsSize((*this)->getAttrOfType( + getTargetOffsetAttr())); } //===----------------------------------------------------------------------===// @@ -1049,16 +1054,18 @@ llvm::Optional fir::SelectCaseOp::getCompareOperands(unsigned cond) { - auto a = getAttrOfType(getCompareOffsetAttr()); + auto a = (*this)->getAttrOfType( + getCompareOffsetAttr()); return {getSubOperands(cond, compareArgs(), a)}; } llvm::Optional> fir::SelectCaseOp::getCompareOperands(llvm::ArrayRef operands, unsigned cond) { - auto a = getAttrOfType(getCompareOffsetAttr()); - auto segments = - getAttrOfType(getOperandSegmentSizeAttr()); + auto a = (*this)->getAttrOfType( + getCompareOffsetAttr()); + auto segments = (*this)->getAttrOfType( + getOperandSegmentSizeAttr()); return {getSubOperands(cond, getSubOperands(1, operands, segments), a)}; } @@ -1071,9 +1078,10 @@ llvm::Optional> fir::SelectCaseOp::getSuccessorOperands(llvm::ArrayRef operands, unsigned oper) { - auto a = getAttrOfType(getTargetOffsetAttr()); - auto segments = - getAttrOfType(getOperandSegmentSizeAttr()); + auto a = + (*this)->getAttrOfType(getTargetOffsetAttr()); + auto segments = (*this)->getAttrOfType( + getOperandSegmentSizeAttr()); return {getSubOperands(oper, getSubOperands(2, operands, segments), a)}; } @@ -1152,13 +1160,13 @@ } unsigned fir::SelectCaseOp::compareOffsetSize() { - return denseElementsSize( - getAttrOfType(getCompareOffsetAttr())); + return denseElementsSize((*this)->getAttrOfType( + getCompareOffsetAttr())); } unsigned fir::SelectCaseOp::targetOffsetSize() { - return denseElementsSize( - getAttrOfType(getTargetOffsetAttr())); + return denseElementsSize((*this)->getAttrOfType( + getTargetOffsetAttr())); } void fir::SelectCaseOp::build(mlir::OpBuilder &builder, @@ -1262,15 +1270,16 @@ llvm::Optional> fir::SelectRankOp::getSuccessorOperands(llvm::ArrayRef operands, unsigned oper) { - auto a = getAttrOfType(getTargetOffsetAttr()); - auto segments = - getAttrOfType(getOperandSegmentSizeAttr()); + auto a = + (*this)->getAttrOfType(getTargetOffsetAttr()); + auto segments = (*this)->getAttrOfType( + getOperandSegmentSizeAttr()); return {getSubOperands(oper, getSubOperands(2, operands, segments), a)}; } unsigned fir::SelectRankOp::targetOffsetSize() { - return denseElementsSize( - getAttrOfType(getTargetOffsetAttr())); + return denseElementsSize((*this)->getAttrOfType( + getTargetOffsetAttr())); } //===----------------------------------------------------------------------===// @@ -1296,9 +1305,10 @@ llvm::Optional> fir::SelectTypeOp::getSuccessorOperands(llvm::ArrayRef operands, unsigned oper) { - auto a = getAttrOfType(getTargetOffsetAttr()); - auto segments = - getAttrOfType(getOperandSegmentSizeAttr()); + auto a = + (*this)->getAttrOfType(getTargetOffsetAttr()); + auto segments = (*this)->getAttrOfType( + getOperandSegmentSizeAttr()); return {getSubOperands(oper, getSubOperands(2, operands, segments), a)}; } @@ -1348,8 +1358,8 @@ } unsigned fir::SelectTypeOp::targetOffsetSize() { - return denseElementsSize( - getAttrOfType(getTargetOffsetAttr())); + return denseElementsSize((*this)->getAttrOfType( + getTargetOffsetAttr())); } //===----------------------------------------------------------------------===// @@ -1467,7 +1477,7 @@ p.printRegion(otherReg, /*printEntryBlockArgs=*/false, printBlockTerminators); } - p.printOptionalAttrDict(op.getAttrs()); + p.printOptionalAttrDict(op->getAttrs()); } //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp --- a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp @@ -787,7 +787,7 @@ convertLinkageFromLLVM(f->getLinkage())); if (FlatSymbolRefAttr personality = getPersonalityAsAttr(f)) - fop.setAttr(b.getIdentifier("personality"), personality); + fop->setAttr(b.getIdentifier("personality"), personality); else if (f->hasPersonalityFn()) emitWarning(UnknownLoc::get(context), "could not deduce personality, skipping it"); diff --git a/mlir/test/mlir-tblgen/op-attribute.td b/mlir/test/mlir-tblgen/op-attribute.td --- a/mlir/test/mlir-tblgen/op-attribute.td +++ b/mlir/test/mlir-tblgen/op-attribute.td @@ -48,13 +48,13 @@ // --- // DEF: some-attr-kind AOp::aAttrAttr() -// DEF-NEXT: (*this)->getAttr("aAttr").cast() +// DEF-NEXT: (*this)->getAttr("aAttr").template cast() // 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() +// DEF-NEXT: return (*this)->getAttr("bAttr").template dyn_cast_or_null() // DEF: some-return-type AOp::bAttr() { // DEF-NEXT: auto attr = bAttrAttr(); // DEF-NEXT: if (!attr) @@ -62,7 +62,7 @@ // DEF-NEXT: return attr.some-convert-from-storage(); // DEF: some-attr-kind AOp::cAttrAttr() -// DEF-NEXT: return (*this)->getAttr("cAttr").dyn_cast_or_null() +// DEF-NEXT: return (*this)->getAttr("cAttr").template dyn_cast_or_null() // DEF: ::llvm::Optional AOp::cAttr() { // DEF-NEXT: auto attr = cAttrAttr() // DEF-NEXT: return attr ? ::llvm::Optional(attr.some-convert-from-storage()) : (::llvm::None); diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -90,8 +90,7 @@ auto sizeAttr = odsAttrs.get("{0}").cast<::mlir::DenseIntElementsAttr>(); )"; const char *opSegmentSizeAttrInitCode = R"( - auto sizeAttr = - getOperation()->getAttrOfType<::mlir::DenseIntElementsAttr>("{0}"); + auto sizeAttr = (*this)->getAttrOfType<::mlir::DenseIntElementsAttr>("{0}"); )"; const char *attrSizedSegmentValueRangeCalcCode = R"( unsigned start = 0; @@ -521,7 +520,7 @@ if (!method) return; auto &body = method->body(); - body << " return (*this)->getAttr(\"" << name << "\")."; + body << " return (*this)->getAttr(\"" << name << "\").template "; if (attr.isOptional() || attr.hasDefaultValue()) body << "dyn_cast_or_null<"; else diff --git a/mlir/unittests/Pass/PassManagerTest.cpp b/mlir/unittests/Pass/PassManagerTest.cpp --- a/mlir/unittests/Pass/PassManagerTest.cpp +++ b/mlir/unittests/Pass/PassManagerTest.cpp @@ -34,13 +34,13 @@ : public PassWrapper> { void runOnOperation() override { FuncOp op = getOperation(); - Builder builder(op.getParentOfType()); + Builder builder(op->getParentOfType()); auto &ga = getAnalysis(); auto &sa = getAnalysis(); - op.setAttr("isFunc", builder.getBoolAttr(ga.isFunc)); - op.setAttr("isSecret", builder.getBoolAttr(sa.isSecret)); + op->setAttr("isFunc", builder.getBoolAttr(ga.isFunc)); + op->setAttr("isSecret", builder.getBoolAttr(sa.isSecret)); } }; @@ -66,12 +66,12 @@ // Verify that each function got annotated with expected attributes. for (FuncOp func : module->getOps()) { - ASSERT_TRUE(func.getAttr("isFunc").isa()); - EXPECT_TRUE(func.getAttr("isFunc").cast().getValue()); + ASSERT_TRUE(func->getAttr("isFunc").isa()); + EXPECT_TRUE(func->getAttr("isFunc").cast().getValue()); bool isSecret = func.getName() == "secret"; - ASSERT_TRUE(func.getAttr("isSecret").isa()); - EXPECT_EQ(func.getAttr("isSecret").cast().getValue(), isSecret); + ASSERT_TRUE(func->getAttr("isSecret").isa()); + EXPECT_EQ(func->getAttr("isSecret").cast().getValue(), isSecret); } }