This is a preparation step to remove those methods from OpState.
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D93194
}];
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() << ')';
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<mlir::IntegerAttr>(lenpName()))
p << getOperationName() << ' ';
p.printOperand(getSelector());
p << " : " << getSelector().getType() << " [";
- auto cases = getAttrOfType<mlir::ArrayAttr>(getCasesAttr()).getValue();
+ auto cases = (*this)->getAttrOfType<mlir::ArrayAttr>(getCasesAttr()).getValue();
auto count = getNumConditions();
for (decltype(count) i = 0; i != count; ++i) {
if (i)
getSelector().getType().isa<mlir::IndexType>() ||
getSelector().getType().isa<fir::IntType>()))
return emitOpError("must be an integer");
- auto cases = getAttrOfType<mlir::ArrayAttr>(getCasesAttr()).getValue();
+ auto cases = (*this)->getAttrOfType<mlir::ArrayAttr>(getCasesAttr()).getValue();
auto count = getNumDest();
if (count == 0)
return emitOpError("must have at least one successor");
p << getOperationName() << ' ';
p.printOperand(getSelector());
p << " : " << getSelector().getType() << " [";
- auto cases = getAttrOfType<mlir::ArrayAttr>(getCasesAttr()).getValue();
+ auto cases = (*this)->getAttrOfType<mlir::ArrayAttr>(getCasesAttr()).getValue();
auto count = getNumConditions();
for (decltype(count) i = 0; i != count; ++i) {
if (i)
getSelector().getType().isa<fir::LogicalType>() ||
getSelector().getType().isa<fir::CharacterType>()))
return emitOpError("must be an integer, character, or logical");
- auto cases = getAttrOfType<mlir::ArrayAttr>(getCasesAttr()).getValue();
+ auto cases = (*this)->getAttrOfType<mlir::ArrayAttr>(getCasesAttr()).getValue();
auto count = getNumDest();
if (count == 0)
return emitOpError("must have at least one successor");
p << getOperationName() << ' ';
p.printOperand(getSelector());
p << " : " << getSelector().getType() << " [";
- auto cases = getAttrOfType<mlir::ArrayAttr>(getCasesAttr()).getValue();
+ auto cases = (*this)->getAttrOfType<mlir::ArrayAttr>(getCasesAttr()).getValue();
auto count = getNumConditions();
for (decltype(count) i = 0; i != count; ++i) {
if (i)
let verifier = [{
if (!(getSelector().getType().isa<fir::BoxType>()))
return emitOpError("must be a boxed type");
- auto cases = getAttrOfType<mlir::ArrayAttr>(getCasesAttr()).getValue();
+ auto cases = (*this)->getAttrOfType<mlir::ArrayAttr>(getCasesAttr()).getValue();
auto count = getNumDest();
if (count == 0)
return emitOpError("must have at least one successor");
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()});
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<mlir::IntegerAttr>(lenpName()))
+ if (auto x = (*this)->getAttrOfType<mlir::IntegerAttr>(lenpName()))
return x.getInt();
return 0;
}
}];
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();
if (!ref().getType().dyn_cast<BoxType>())
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<mlir::TypeAttr>())
return emitOpError("improperly constructed");
} else {
let printer = [{
p << getOperationName() << ' '
- << getAttrOfType<mlir::StringAttr>(fieldAttrName()).getValue() << ", "
- << getAttr(typeAttrName());
+ << (*this)->getAttrOfType<mlir::StringAttr>(fieldAttrName()).getValue()
+ << ", " << (*this)->getAttr(typeAttrName());
if (getNumOperands()) {
p << '(';
p.printOperands(lenparams());
let printer = [{
p << getOperationName() << ' '
- << getAttrOfType<mlir::StringAttr>(fieldAttrName()).getValue() << ", "
- << getAttr(typeAttrName());
+ << (*this)->getAttrOfType<mlir::StringAttr>(fieldAttrName()).getValue()
+ << ", " << (*this)->getAttr(typeAttrName());
}];
let builders = [
static constexpr llvm::StringRef fieldAttrName() { return "field_id"; }
static constexpr llvm::StringRef typeAttrName() { return "on_type"; }
mlir::Type getOnType() {
- return getAttrOfType<TypeAttr>(typeAttrName()).getValue();
+ return (*this)->getAttrOfType<TypeAttr>(typeAttrName()).getValue();
}
}];
}
}];
let printer = [{
- p << getOperationName() << ' ' << getAttr("method") << '(';
+ p << getOperationName() << ' ' << (*this)->getAttr("method") << '(';
p.printOperand(object());
if (arg_operand_begin() != arg_operand_end()) {
p << ", ";
auto eleTy = getType().cast<fir::SequenceType>().getEleTy();
if (!eleTy.isa<fir::CharacterType>())
return emitOpError("must have !fir.char type");
- if (auto xl = getAttr(xlist())) {
+ if (auto xl = (*this)->getAttr(xlist())) {
auto xList = xl.cast<mlir::ArrayAttr>();
for (auto a : xList)
if (!a.isa<mlir::IntegerAttr>())
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)
static CmpFPredicate getPredicateByName(llvm::StringRef name);
CmpFPredicate getPredicate() {
- return (CmpFPredicate)getAttrOfType<mlir::IntegerAttr>(
+ return (CmpFPredicate)(*this)->getAttrOfType<mlir::IntegerAttr>(
getPredicateAttrName()).getInt();
}
}];
let printer = [{
p << getOperationName() << " (0x";
- auto f1 = getAttr(realAttrName()).cast<mlir::FloatAttr>();
+ auto f1 = (*this)->getAttr(realAttrName()).cast<mlir::FloatAttr>();
auto i1 = f1.getValue().bitcastToAPInt();
p.getStream().write_hex(i1.getZExtValue());
p << ", 0x";
- auto f2 = getAttr(imagAttrName()).cast<mlir::FloatAttr>();
+ auto f2 = (*this)->getAttr(imagAttrName()).cast<mlir::FloatAttr>();
auto i2 = f2.getValue().bitcastToAPInt();
p.getStream().write_hex(i2.getZExtValue());
p << ") : ";
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()); }
}];
}
}
CmpFPredicate getPredicate() {
- return (CmpFPredicate)getAttrOfType<mlir::IntegerAttr>(
+ return (CmpFPredicate)(*this)->getAttrOfType<mlir::IntegerAttr>(
getPredicateAttrName()).getInt();
}
}];
}];
let printer = [{
- p << getOperationName() << ' ' << getAttr("in_type");
+ p << getOperationName() << ' ' << (*this)->getAttr("in_type");
p.printOptionalAttrDict(getAttrs(), {"in_type"});
}];
let extraClassDeclaration = [{
mlir::Type getInType() {
// get the type that the type descriptor describes
- return getAttrOfType<mlir::TypeAttr>("in_type").getValue();
+ return (*this)->getAttrOfType<mlir::TypeAttr>("in_type").getValue();
}
}];
}
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()))
/// The printable type of the global
mlir::Type getType() {
- return getAttrOfType<TypeAttr>(typeAttrName()).getValue();
+ return (*this)->getAttrOfType<TypeAttr>(typeAttrName()).getValue();
}
/// The semantic type of the global
}
mlir::FlatSymbolRefAttr getSymbol() {
- return mlir::FlatSymbolRefAttr::get(getAttrOfType<mlir::StringAttr>(
- mlir::SymbolTable::getSymbolAttrName()).getValue(), getContext());
+ return mlir::FlatSymbolRefAttr::get(
+ (*this)->getAttrOfType<mlir::StringAttr>(
+ mlir::SymbolTable::getSymbolAttrName()).getValue(), getContext());
}
}];
}
}];
let printer = [{
- p << getOperationName() << ' ' << getAttr(lenParamAttrName()) << ", "
- << getAttr(intAttrName());
+ p << getOperationName() << ' ' << (*this)->getAttr(lenParamAttrName())
+ << ", " << (*this)->getAttr(intAttrName());
}];
let extraClassDeclaration = [{
}];
let printer = [{
- auto tableName = getAttrOfType<StringAttr>(
+ auto tableName = (*this)->getAttrOfType<StringAttr>(
mlir::SymbolTable::getSymbolAttrName()).getValue();
p << getOperationName() << " @" << tableName;
}];
let printer = [{
- p << getOperationName() << ' ' << getAttr(methodAttrName()) << ", "
- << getAttr(procAttrName());
+ p << getOperationName() << ' ' << (*this)->getAttr(methodAttrName()) << ", "
+ << (*this)->getAttr(procAttrName());
}];
let extraClassDeclaration = [{
/// return true iff the Operation is a non-volatile LoadOp
inline bool nonVolatileLoad(mlir::Operation *op) {
if (auto load = dyn_cast<fir::LoadOp>(op))
- return !load.getAttr("volatile");
+ return !load->getAttr("volatile");
return false;
}
return func;
auto funTy = getTypeModel<E>()(builder.getContext());
func = builder.createFunction(loc, name, funTy);
- func.setAttr("fir.runtime", builder.getUnitAttr());
+ func->setAttr("fir.runtime", builder.getUnitAttr());
return func;
}
return func;
auto funTy = getTypeModel<E>()(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;
}
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;
}
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
builder.setInsertionPointToStart(&block);
builder.create<Terminator>(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);
const SmallVectorImpl<int32_t> &operandSegments) {
llvm::ArrayRef<mlir::Type> argTy;
Op op = builder.create<Op>(loc, argTy, operands);
- op.setAttr(Op::getOperandSegmentSizeAttr(),
- builder.getI32VectorAttr(operandSegments));
+ op->setAttr(Op::getOperandSegmentSizeAttr(),
+ builder.getI32VectorAttr(operandSegments));
return op;
}
auto loopOp = createRegionOp<mlir::acc::LoopOp, mlir::acc::YieldOp>(
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) {
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<Fortran::parser::AccClause::Seq>(&clause.u)) {
- loopOp.setAttr(mlir::acc::LoopOp::getSeqAttrName(),
- firOpBuilder.getUnitAttr());
+ loopOp->setAttr(mlir::acc::LoopOp::getSeqAttrName(),
+ firOpBuilder.getUnitAttr());
} else if (std::get_if<Fortran::parser::AccClause::Independent>(
&clause.u)) {
- loopOp.setAttr(mlir::acc::LoopOp::getIndependentAttrName(),
- firOpBuilder.getUnitAttr());
+ loopOp->setAttr(mlir::acc::LoopOp::getIndependentAttrName(),
+ firOpBuilder.getUnitAttr());
} else if (std::get_if<Fortran::parser::AccClause::Auto>(&clause.u)) {
- loopOp.setAttr(mlir::acc::LoopOp::getAutoAttrName(),
- firOpBuilder.getUnitAttr());
+ loopOp->setAttr(mlir::acc::LoopOp::getAutoAttrName(),
+ firOpBuilder.getUnitAttr());
}
}
}
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,
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<Type, 8> argTypes(
static void printCmpOp(OpAsmPrinter &p, OPTY op) {
p << op.getOperationName() << ' ';
auto predSym = mlir::symbolizeCmpFPredicate(
- op.template getAttrOfType<mlir::IntegerAttr>(OPTY::getPredicateAttrName())
+ op->template getAttrOfType<mlir::IntegerAttr>(
+ OPTY::getPredicateAttrName())
.getInt());
assert(predSym.hasValue() && "invalid symbol value for predicate");
p << '"' << mlir::stringifyCmpFPredicate(predSym.getValue()) << '"' << ", ";
}
mlir::Type fir::CoordinateOp::getBaseType() {
- return getAttr(CoordinateOp::baseType()).cast<mlir::TypeAttr>().getValue();
+ return (*this)
+ ->getAttr(CoordinateOp::baseType())
+ .cast<mlir::TypeAttr>()
+ .getValue();
}
void fir::CoordinateOp::build(OpBuilder &, OperationState &result,
//===----------------------------------------------------------------------===//
mlir::FunctionType fir::DispatchOp::getFunctionType() {
- auto attr = getAttr("fn_type").cast<mlir::TypeAttr>();
+ auto attr = (*this)->getAttr("fn_type").cast<mlir::TypeAttr>();
return attr.getValue().cast<mlir::FunctionType>();
}
[&](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);
}
p << ") -> (" << op.getResultTypes() << ')';
printBlockTerminators = true;
}
- p.printOptionalAttrDictWithKeyword(op.getAttrs(),
+ p.printOptionalAttrDictWithKeyword(op->getAttrs(),
{fir::LoopOp::unorderedAttrName()});
p.printRegion(op.region(), /*printEntryBlockArgs=*/false,
printBlockTerminators);
//===----------------------------------------------------------------------===//
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";
llvm::Optional<llvm::ArrayRef<mlir::Value>>
fir::SelectOp::getSuccessorOperands(llvm::ArrayRef<mlir::Value> operands,
unsigned oper) {
- auto a = getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr());
- auto segments =
- getAttrOfType<mlir::DenseIntElementsAttr>(getOperandSegmentSizeAttr());
+ auto a =
+ (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr());
+ auto segments = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
+ getOperandSegmentSizeAttr());
return {getSubOperands(oper, getSubOperands(2, operands, segments), a)};
}
unsigned fir::SelectOp::targetOffsetSize() {
- return denseElementsSize(
- getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr()));
+ return denseElementsSize((*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
+ getTargetOffsetAttr()));
}
//===----------------------------------------------------------------------===//
llvm::Optional<mlir::OperandRange>
fir::SelectCaseOp::getCompareOperands(unsigned cond) {
- auto a = getAttrOfType<mlir::DenseIntElementsAttr>(getCompareOffsetAttr());
+ auto a = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
+ getCompareOffsetAttr());
return {getSubOperands(cond, compareArgs(), a)};
}
llvm::Optional<llvm::ArrayRef<mlir::Value>>
fir::SelectCaseOp::getCompareOperands(llvm::ArrayRef<mlir::Value> operands,
unsigned cond) {
- auto a = getAttrOfType<mlir::DenseIntElementsAttr>(getCompareOffsetAttr());
- auto segments =
- getAttrOfType<mlir::DenseIntElementsAttr>(getOperandSegmentSizeAttr());
+ auto a = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
+ getCompareOffsetAttr());
+ auto segments = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
+ getOperandSegmentSizeAttr());
return {getSubOperands(cond, getSubOperands(1, operands, segments), a)};
}
llvm::Optional<llvm::ArrayRef<mlir::Value>>
fir::SelectCaseOp::getSuccessorOperands(llvm::ArrayRef<mlir::Value> operands,
unsigned oper) {
- auto a = getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr());
- auto segments =
- getAttrOfType<mlir::DenseIntElementsAttr>(getOperandSegmentSizeAttr());
+ auto a =
+ (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr());
+ auto segments = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
+ getOperandSegmentSizeAttr());
return {getSubOperands(oper, getSubOperands(2, operands, segments), a)};
}
}
unsigned fir::SelectCaseOp::compareOffsetSize() {
- return denseElementsSize(
- getAttrOfType<mlir::DenseIntElementsAttr>(getCompareOffsetAttr()));
+ return denseElementsSize((*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
+ getCompareOffsetAttr()));
}
unsigned fir::SelectCaseOp::targetOffsetSize() {
- return denseElementsSize(
- getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr()));
+ return denseElementsSize((*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
+ getTargetOffsetAttr()));
}
void fir::SelectCaseOp::build(mlir::OpBuilder &builder,
llvm::Optional<llvm::ArrayRef<mlir::Value>>
fir::SelectRankOp::getSuccessorOperands(llvm::ArrayRef<mlir::Value> operands,
unsigned oper) {
- auto a = getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr());
- auto segments =
- getAttrOfType<mlir::DenseIntElementsAttr>(getOperandSegmentSizeAttr());
+ auto a =
+ (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr());
+ auto segments = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
+ getOperandSegmentSizeAttr());
return {getSubOperands(oper, getSubOperands(2, operands, segments), a)};
}
unsigned fir::SelectRankOp::targetOffsetSize() {
- return denseElementsSize(
- getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr()));
+ return denseElementsSize((*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
+ getTargetOffsetAttr()));
}
//===----------------------------------------------------------------------===//
llvm::Optional<llvm::ArrayRef<mlir::Value>>
fir::SelectTypeOp::getSuccessorOperands(llvm::ArrayRef<mlir::Value> operands,
unsigned oper) {
- auto a = getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr());
- auto segments =
- getAttrOfType<mlir::DenseIntElementsAttr>(getOperandSegmentSizeAttr());
+ auto a =
+ (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr());
+ auto segments = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
+ getOperandSegmentSizeAttr());
return {getSubOperands(oper, getSubOperands(2, operands, segments), a)};
}
}
unsigned fir::SelectTypeOp::targetOffsetSize() {
- return denseElementsSize(
- getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr()));
+ return denseElementsSize((*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
+ getTargetOffsetAttr()));
}
//===----------------------------------------------------------------------===//
p.printRegion(otherReg, /*printEntryBlockArgs=*/false,
printBlockTerminators);
}
- p.printOptionalAttrDict(op.getAttrs());
+ p.printOptionalAttrDict(op->getAttrs());
}
//===----------------------------------------------------------------------===//
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");
// ---
// DEF: some-attr-kind AOp::aAttrAttr()
-// DEF-NEXT: (*this)->getAttr("aAttr").cast<some-attr-kind>()
+// DEF-NEXT: (*this)->getAttr("aAttr").template 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").template 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 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").template 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);
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;
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
: public PassWrapper<AnnotateFunctionPass, OperationPass<FuncOp>> {
void runOnOperation() override {
FuncOp op = getOperation();
- Builder builder(op.getParentOfType<ModuleOp>());
+ Builder builder(op->getParentOfType<ModuleOp>());
auto &ga = getAnalysis<GenericAnalysis>();
auto &sa = getAnalysis<OpSpecificAnalysis>();
- 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));
}
};
// Verify that each function got annotated with expected attributes.
for (FuncOp func : module->getOps<FuncOp>()) {
- ASSERT_TRUE(func.getAttr("isFunc").isa<BoolAttr>());
- EXPECT_TRUE(func.getAttr("isFunc").cast<BoolAttr>().getValue());
+ ASSERT_TRUE(func->getAttr("isFunc").isa<BoolAttr>());
+ EXPECT_TRUE(func->getAttr("isFunc").cast<BoolAttr>().getValue());
bool isSecret = func.getName() == "secret";
- ASSERT_TRUE(func.getAttr("isSecret").isa<BoolAttr>());
- EXPECT_EQ(func.getAttr("isSecret").cast<BoolAttr>().getValue(), isSecret);
+ ASSERT_TRUE(func->getAttr("isSecret").isa<BoolAttr>());
+ EXPECT_EQ(func->getAttr("isSecret").cast<BoolAttr>().getValue(), isSecret);
}
}