Lines Matching refs:mlir
42 static bool verifyInType(mlir::Type inType, in verifyInType()
69 static bool verifyTypeParamCount(mlir::Type inType, unsigned numParams) { in verifyTypeParamCount()
89 static mlir::ParseResult parseAllocatableOp(FN wrapResultType, in parseAllocatableOp()
90 mlir::OpAsmParser &parser, in parseAllocatableOp()
91 mlir::OperationState &result) { in parseAllocatableOp()
92 mlir::Type intype; in parseAllocatableOp()
94 return mlir::failure(); in parseAllocatableOp()
96 result.addAttribute("in_type", mlir::TypeAttr::get(intype)); in parseAllocatableOp()
97 llvm::SmallVector<mlir::OpAsmParser::UnresolvedOperand> operands; in parseAllocatableOp()
98 llvm::SmallVector<mlir::Type> typeVec; in parseAllocatableOp()
103 if (parser.parseOperandList(operands, mlir::OpAsmParser::Delimiter::None) || in parseAllocatableOp()
105 return mlir::failure(); in parseAllocatableOp()
112 if (parser.parseOperandList(operands, mlir::OpAsmParser::Delimiter::None)) in parseAllocatableOp()
113 return mlir::failure(); in parseAllocatableOp()
123 return mlir::failure(); in parseAllocatableOp()
124 mlir::Type restype = wrapResultType(intype); in parseAllocatableOp()
127 return mlir::failure(); in parseAllocatableOp()
133 return mlir::failure(); in parseAllocatableOp()
134 return mlir::success(); in parseAllocatableOp()
138 static void printAllocatableOp(mlir::OpAsmPrinter &p, OP &op) { in printAllocatableOp()
157 static mlir::Type wrapAllocaResultType(mlir::Type intype) { in wrapAllocaResultType()
164 mlir::Type fir::AllocaOp::getAllocatedType() { in getAllocatedType()
168 mlir::Type fir::AllocaOp::getRefTy(mlir::Type ty) { in getRefTy()
172 void fir::AllocaOp::build(mlir::OpBuilder &builder, in build()
173 mlir::OperationState &result, mlir::Type inType, in build()
174 llvm::StringRef uniqName, mlir::ValueRange typeparams, in build()
175 mlir::ValueRange shape, in build()
176 llvm::ArrayRef<mlir::NamedAttribute> attributes) { in build()
183 void fir::AllocaOp::build(mlir::OpBuilder &builder, in build()
184 mlir::OperationState &result, mlir::Type inType, in build()
186 mlir::ValueRange typeparams, mlir::ValueRange shape, in build()
187 llvm::ArrayRef<mlir::NamedAttribute> attributes) { in build()
194 void fir::AllocaOp::build(mlir::OpBuilder &builder, in build()
195 mlir::OperationState &result, mlir::Type inType, in build()
197 mlir::ValueRange typeparams, mlir::ValueRange shape, in build()
198 llvm::ArrayRef<mlir::NamedAttribute> attributes) { in build()
200 uniqName.empty() ? mlir::StringAttr{} : builder.getStringAttr(uniqName); in build()
202 bindcName.empty() ? mlir::StringAttr{} : builder.getStringAttr(bindcName); in build()
208 void fir::AllocaOp::build(mlir::OpBuilder &builder, in build()
209 mlir::OperationState &result, mlir::Type inType, in build()
211 bool pinned, mlir::ValueRange typeparams, in build()
212 mlir::ValueRange shape, in build()
213 llvm::ArrayRef<mlir::NamedAttribute> attributes) { in build()
215 uniqName.empty() ? mlir::StringAttr{} : builder.getStringAttr(uniqName); in build()
217 bindcName.empty() ? mlir::StringAttr{} : builder.getStringAttr(bindcName); in build()
223 void fir::AllocaOp::build(mlir::OpBuilder &builder, in build()
224 mlir::OperationState &result, mlir::Type inType, in build()
225 mlir::ValueRange typeparams, mlir::ValueRange shape, in build()
226 llvm::ArrayRef<mlir::NamedAttribute> attributes) { in build()
232 void fir::AllocaOp::build(mlir::OpBuilder &builder, in build()
233 mlir::OperationState &result, mlir::Type inType, in build()
234 bool pinned, mlir::ValueRange typeparams, in build()
235 mlir::ValueRange shape, in build()
236 llvm::ArrayRef<mlir::NamedAttribute> attributes) { in build()
242 mlir::ParseResult fir::AllocaOp::parse(mlir::OpAsmParser &parser, in parse()
243 mlir::OperationState &result) { in parse()
247 void fir::AllocaOp::print(mlir::OpAsmPrinter &p) { in print()
251 mlir::LogicalResult fir::AllocaOp::verify() { in verify()
257 mlir::Type outType = getType(); in verify()
262 return mlir::success(); in verify()
270 static mlir::Type wrapAllocMemResultType(mlir::Type intype) { in wrapAllocMemResultType()
275 mlir::FunctionType>()) in wrapAllocMemResultType()
280 mlir::Type fir::AllocMemOp::getAllocatedType() { in getAllocatedType()
284 mlir::Type fir::AllocMemOp::getRefTy(mlir::Type ty) { in getRefTy()
288 void fir::AllocMemOp::build(mlir::OpBuilder &builder, in build()
289 mlir::OperationState &result, mlir::Type inType, in build()
291 mlir::ValueRange typeparams, mlir::ValueRange shape, in build()
292 llvm::ArrayRef<mlir::NamedAttribute> attributes) { in build()
299 void fir::AllocMemOp::build(mlir::OpBuilder &builder, in build()
300 mlir::OperationState &result, mlir::Type inType, in build()
302 mlir::ValueRange typeparams, mlir::ValueRange shape, in build()
303 llvm::ArrayRef<mlir::NamedAttribute> attributes) { in build()
311 void fir::AllocMemOp::build(mlir::OpBuilder &builder, in build()
312 mlir::OperationState &result, mlir::Type inType, in build()
313 mlir::ValueRange typeparams, mlir::ValueRange shape, in build()
314 llvm::ArrayRef<mlir::NamedAttribute> attributes) { in build()
320 mlir::ParseResult fir::AllocMemOp::parse(mlir::OpAsmParser &parser, in parse()
321 mlir::OperationState &result) { in parse()
325 void fir::AllocMemOp::print(mlir::OpAsmPrinter &p) { in print()
329 mlir::LogicalResult fir::AllocMemOp::verify() { in verify()
335 mlir::Type outType = getType(); in verify()
340 return mlir::success(); in verify()
349 static bool validTypeParams(mlir::Type dynTy, mlir::ValueRange typeParams) { in validTypeParams()
365 mlir::LogicalResult fir::ArrayCoorOp::verify() { in verify()
392 if (auto sl = mlir::dyn_cast_or_null<fir::SliceOp>(sliceOp.getDefiningOp())) in verify()
402 return mlir::success(); in verify()
409 static mlir::Type adjustedElementType(mlir::Type t) { in adjustedElementType()
422 std::vector<mlir::Value> fir::ArrayLoadOp::getExtents() { in getExtents()
425 if (auto shOp = mlir::dyn_cast<fir::ShapeOp>(op)) { in getExtents()
429 return mlir::cast<fir::ShapeShiftOp>(op).getExtents(); in getExtents()
434 mlir::LogicalResult fir::ArrayLoadOp::verify() { in verify()
459 if (auto sl = mlir::dyn_cast_or_null<fir::SliceOp>(sliceOp.getDefiningOp())) in verify()
470 return mlir::success(); in verify()
477 mlir::LogicalResult fir::ArrayMergeStoreOp::verify() { in verify()
478 if (!mlir::isa<fir::ArrayLoadOp>(getOriginal().getDefiningOp())) in verify()
482 mlir::dyn_cast_or_null<fir::SliceOp>(sl.getDefiningOp())) { in verify()
499 return mlir::success(); in verify()
504 return mlir::success(); in verify()
513 return mlir::success(); in verify()
522 mlir::Type validArraySubobject(A op) { in validArraySubobject()
527 mlir::LogicalResult fir::ArrayFetchOp::verify() { in verify()
538 if (!mlir::isa<fir::ArrayLoadOp>(getSequence().getDefiningOp())) in verify()
542 return mlir::success(); in verify()
549 mlir::LogicalResult fir::ArrayAccessOp::verify() { in verify()
557 mlir::Type ty = validArraySubobject(*this); in verify()
562 return mlir::success(); in verify()
569 mlir::LogicalResult fir::ArrayUpdateOp::verify() { in verify()
584 return mlir::success(); in verify()
591 mlir::LogicalResult fir::ArrayModifyOp::verify() { in verify()
596 return mlir::success(); in verify()
603 mlir::OpFoldResult fir::BoxAddrOp::fold(llvm::ArrayRef<mlir::Attribute> opnds) { in fold()
605 if (auto box = mlir::dyn_cast<fir::EmboxOp>(v)) { in fold()
609 if (auto box = mlir::dyn_cast<fir::EmboxCharOp>(v)) in fold()
619 mlir::OpFoldResult
620 fir::BoxCharLenOp::fold(llvm::ArrayRef<mlir::Attribute> opnds) { in fold()
622 if (auto box = mlir::dyn_cast<fir::EmboxCharOp>(v)) in fold()
633 mlir::Type fir::BoxDimsOp::getTupleType() { in getTupleType()
635 llvm::SmallVector<mlir::Type> triple{ in getTupleType()
637 return mlir::TupleType::get(getContext(), triple); in getTupleType()
644 mlir::FunctionType fir::CallOp::getFunctionType() { in getFunctionType()
645 return mlir::FunctionType::get(getContext(), getOperandTypes(), in getFunctionType()
649 void fir::CallOp::print(mlir::OpAsmPrinter &p) { in print()
660 llvm::SmallVector<mlir::Type> argTypes( in print()
662 p << " : " << mlir::FunctionType::get(getContext(), argTypes, resultTypes); in print()
665 mlir::ParseResult fir::CallOp::parse(mlir::OpAsmParser &parser, in parse()
666 mlir::OperationState &result) { in parse()
667 llvm::SmallVector<mlir::OpAsmParser::UnresolvedOperand> operands; in parse()
669 return mlir::failure(); in parse()
671 mlir::NamedAttrList attrs; in parse()
672 mlir::SymbolRefAttr funcAttr; in parse()
677 return mlir::failure(); in parse()
679 mlir::Type type; in parse()
680 if (parser.parseOperandList(operands, mlir::OpAsmParser::Delimiter::Paren) || in parse()
683 return mlir::failure(); in parse()
685 auto funcType = type.dyn_cast<mlir::FunctionType>(); in parse()
691 return mlir::failure(); in parse()
694 llvm::ArrayRef<mlir::OpAsmParser::UnresolvedOperand>(operands) in parse()
699 return mlir::failure(); in parse()
703 return mlir::success(); in parse()
706 void fir::CallOp::build(mlir::OpBuilder &builder, mlir::OperationState &result, in build()
707 mlir::func::FuncOp callee, mlir::ValueRange operands) { in build()
709 result.addAttribute(getCalleeAttrNameStr(), mlir::SymbolRefAttr::get(callee)); in build()
713 void fir::CallOp::build(mlir::OpBuilder &builder, mlir::OperationState &result, in build()
714 mlir::SymbolRefAttr callee, in build()
715 llvm::ArrayRef<mlir::Type> results, in build()
716 mlir::ValueRange operands) { in build()
727 mlir::LogicalResult fir::CharConvertOp::verify() { in verify()
728 auto unwrap = [&](mlir::Type t) { in verify()
738 return mlir::success(); in verify()
746 static void printCmpOp(mlir::OpAsmPrinter &p, OPTY op) { in printCmpOp()
748 auto predSym = mlir::arith::symbolizeCmpFPredicate( in printCmpOp()
749 op->template getAttrOfType<mlir::IntegerAttr>( in printCmpOp()
753 p << '"' << mlir::arith::stringifyCmpFPredicate(predSym.value()) << '"' in printCmpOp()
764 static mlir::ParseResult parseCmpOp(mlir::OpAsmParser &parser, in parseCmpOp()
765 mlir::OperationState &result) { in parseCmpOp()
766 llvm::SmallVector<mlir::OpAsmParser::UnresolvedOperand> ops; in parseCmpOp()
767 mlir::NamedAttrList attrs; in parseCmpOp()
768 mlir::Attribute predicateNameAttr; in parseCmpOp()
769 mlir::Type type; in parseCmpOp()
775 return mlir::failure(); in parseCmpOp()
777 if (!predicateNameAttr.isa<mlir::StringAttr>()) in parseCmpOp()
783 predicateNameAttr.cast<mlir::StringAttr>().getValue(); in parseCmpOp()
786 mlir::Type i1Type = builder.getI1Type(); in parseCmpOp()
791 return mlir::success(); in parseCmpOp()
798 void fir::buildCmpCOp(mlir::OpBuilder &builder, mlir::OperationState &result, in buildCmpCOp()
799 mlir::arith::CmpFPredicate predicate, mlir::Value lhs, in buildCmpCOp()
800 mlir::Value rhs) { in buildCmpCOp()
808 mlir::arith::CmpFPredicate
810 auto pred = mlir::arith::symbolizeCmpFPredicate(name); in getPredicateByName()
815 void fir::CmpcOp::print(mlir::OpAsmPrinter &p) { printCmpOp(p, *this); } in print()
817 mlir::ParseResult fir::CmpcOp::parse(mlir::OpAsmParser &parser, in parse()
818 mlir::OperationState &result) { in parse()
826 mlir::ParseResult fir::ConstcOp::parse(mlir::OpAsmParser &parser, in parse()
827 mlir::OperationState &result) { in parse()
830 mlir::Type type; in parse()
839 return mlir::failure(); in parse()
840 return mlir::success(); in parse()
843 void fir::ConstcOp::print(mlir::OpAsmPrinter &p) { in print()
850 mlir::LogicalResult fir::ConstcOp::verify() { in verify()
853 return mlir::success(); in verify()
861 mlir::RewritePatternSet &results, mlir::MLIRContext *context) { in getCanonicalizationPatterns()
868 mlir::OpFoldResult fir::ConvertOp::fold(llvm::ArrayRef<mlir::Attribute> opnds) { in fold()
871 if (matchPattern(getValue(), mlir::m_Op<fir::ConvertOp>())) { in fold()
872 auto inner = mlir::cast<fir::ConvertOp>(getValue().getDefiningOp()); in fold()
876 if (inner.getType().isa<mlir::IntegerType>() && (toTy == fromTy)) in fold()
879 if (auto toTy = getType().dyn_cast<mlir::IntegerType>()) in fold()
881 inner.getValue().getType().dyn_cast<mlir::IntegerType>()) in fold()
889 bool fir::ConvertOp::isIntegerCompatible(mlir::Type ty) { in isIntegerCompatible()
890 return ty.isa<mlir::IntegerType, mlir::IndexType, fir::IntegerType, in isIntegerCompatible()
894 bool fir::ConvertOp::isFloatCompatible(mlir::Type ty) { in isFloatCompatible()
895 return ty.isa<mlir::FloatType, fir::RealType>(); in isFloatCompatible()
898 bool fir::ConvertOp::isPointerCompatible(mlir::Type ty) { in isPointerCompatible()
900 fir::LLVMPointerType, mlir::MemRefType, mlir::FunctionType, in isPointerCompatible()
904 mlir::LogicalResult fir::ConvertOp::verify() { in verify()
908 return mlir::success(); in verify()
919 return mlir::success(); in verify()
927 void fir::CoordinateOp::print(mlir::OpAsmPrinter &p) { in print()
934 mlir::ParseResult fir::CoordinateOp::parse(mlir::OpAsmParser &parser, in parse()
935 mlir::OperationState &result) { in parse()
936 mlir::OpAsmParser::UnresolvedOperand memref; in parse()
938 return mlir::failure(); in parse()
939 llvm::SmallVector<mlir::OpAsmParser::UnresolvedOperand> coorOperands; in parse()
941 return mlir::failure(); in parse()
942 llvm::SmallVector<mlir::OpAsmParser::UnresolvedOperand> allOperands; in parse()
945 mlir::FunctionType funcTy; in parse()
952 return mlir::failure(); in parse()
953 result.addAttribute("baseType", mlir::TypeAttr::get(funcTy.getInput(0))); in parse()
954 return mlir::success(); in parse()
957 mlir::LogicalResult fir::CoordinateOp::verify() { in verify()
958 const mlir::Type refTy = getRef().getType(); in verify()
982 if (auto index = mlir::dyn_cast<fir::LenParamIndexOp>(defOp)) { in verify()
995 return mlir::success(); in verify()
996 } else if (auto index = mlir::dyn_cast<fir::FieldIndexOp>(defOp)) { in verify()
1010 if (auto t = eleTy.dyn_cast<mlir::TupleType>()) { in verify()
1014 return mlir::success(); in verify()
1017 return mlir::success(); in verify()
1020 } else if (auto t = eleTy.dyn_cast<mlir::ComplexType>()) { in verify()
1033 return mlir::success(); in verify()
1040 mlir::FunctionType fir::DispatchOp::getFunctionType() { in getFunctionType()
1041 return mlir::FunctionType::get(getContext(), getOperandTypes(), in getFunctionType()
1045 mlir::ParseResult fir::DispatchOp::parse(mlir::OpAsmParser &parser, in parse()
1046 mlir::OperationState &result) { in parse()
1047 mlir::FunctionType calleeType; in parse()
1048 llvm::SmallVector<mlir::OpAsmParser::UnresolvedOperand> operands; in parse()
1052 mlir::StringAttr calleeAttr; in parse()
1056 return mlir::failure(); in parse()
1061 if (parser.parseOperandList(operands, mlir::OpAsmParser::Delimiter::Paren) || in parse()
1067 return mlir::failure(); in parse()
1068 return mlir::success(); in parse()
1071 void fir::DispatchOp::print(mlir::OpAsmPrinter &p) { in print()
1087 void fir::DispatchTableOp::appendTableEntry(mlir::Operation *op) { in appendTableEntry()
1088 assert(mlir::isa<fir::DTEntryOp>(*op) && "operation must be a DTEntryOp"); in appendTableEntry()
1093 mlir::ParseResult fir::DispatchTableOp::parse(mlir::OpAsmParser &parser, in parse()
1094 mlir::OperationState &result) { in parse()
1096 mlir::SymbolRefAttr nameAttr; in parse()
1097 if (parser.parseAttribute(nameAttr, mlir::SymbolTable::getSymbolAttrName(), in parse()
1099 return mlir::failure(); in parse()
1102 result.attributes.set(mlir::SymbolTable::getSymbolAttrName(), in parse()
1106 mlir::Region *body = result.addRegion(); in parse()
1107 mlir::OptionalParseResult parseResult = parser.parseOptionalRegion(*body); in parse()
1109 return mlir::failure(); in parse()
1113 return mlir::success(); in parse()
1116 void fir::DispatchTableOp::print(mlir::OpAsmPrinter &p) { in print()
1118 ->getAttrOfType<mlir::StringAttr>( in print()
1119 mlir::SymbolTable::getSymbolAttrName()) in print()
1123 mlir::Region &body = getOperation()->getRegion(0); in print()
1131 mlir::LogicalResult fir::DispatchTableOp::verify() { in verify()
1133 if (!mlir::isa<fir::DTEntryOp, fir::FirEndOp>(op)) in verify()
1135 return mlir::success(); in verify()
1142 mlir::LogicalResult fir::EmboxOp::verify() { in verify()
1169 return mlir::success(); in verify()
1176 mlir::LogicalResult fir::EmboxCharOp::verify() { in verify()
1179 return mlir::failure(); in verify()
1180 return mlir::success(); in verify()
1187 mlir::LogicalResult fir::EmboxProcOp::verify() { in verify()
1191 if (r.getEleTy().isa<mlir::TupleType>()) in verify()
1192 return mlir::success(); in verify()
1193 return mlir::failure(); in verify()
1195 return mlir::success(); in verify()
1202 void fir::GenTypeDescOp::build(mlir::OpBuilder &, mlir::OperationState &result, in build()
1203 mlir::TypeAttr inty) { in build()
1208 mlir::ParseResult fir::GenTypeDescOp::parse(mlir::OpAsmParser &parser, in parse()
1209 mlir::OperationState &result) { in parse()
1210 mlir::Type intype; in parse()
1212 return mlir::failure(); in parse()
1213 result.addAttribute("in_type", mlir::TypeAttr::get(intype)); in parse()
1214 mlir::Type restype = fir::TypeDescType::get(intype); in parse()
1216 return mlir::failure(); in parse()
1217 return mlir::success(); in parse()
1220 void fir::GenTypeDescOp::print(mlir::OpAsmPrinter &p) { in print()
1225 mlir::LogicalResult fir::GenTypeDescOp::verify() { in verify()
1226 mlir::Type resultTy = getType(); in verify()
1230 return mlir::success(); in verify()
1239 mlir::Type fir::GlobalOp::resultType() { in resultType()
1243 mlir::ParseResult fir::GlobalOp::parse(mlir::OpAsmParser &parser, in parse()
1244 mlir::OperationState &result) { in parse()
1248 if (mlir::succeeded(parser.parseOptionalKeyword(&linkage))) { in parse()
1250 return mlir::failure(); in parse()
1251 mlir::StringAttr linkAttr = builder.getStringAttr(linkage); in parse()
1256 mlir::SymbolRefAttr nameAttr; in parse()
1259 return mlir::failure(); in parse()
1260 result.addAttribute(mlir::SymbolTable::getSymbolAttrName(), in parse()
1264 if (mlir::succeeded(parser.parseOptionalLParen())) { in parse()
1265 mlir::Attribute attr; in parse()
1268 return mlir::failure(); in parse()
1277 mlir::Type globalType; in parse()
1279 return mlir::failure(); in parse()
1282 mlir::TypeAttr::get(globalType)); in parse()
1290 if (parseResult.hasValue() && mlir::failed(*parseResult)) in parse()
1291 return mlir::failure(); in parse()
1293 return mlir::success(); in parse()
1296 void fir::GlobalOp::print(mlir::OpAsmPrinter &p) { in print()
1315 void fir::GlobalOp::appendInitialValue(mlir::Operation *op) { in appendInitialValue()
1319 void fir::GlobalOp::build(mlir::OpBuilder &builder, in build()
1320 mlir::OperationState &result, llvm::StringRef name, in build()
1321 bool isConstant, mlir::Type type, in build()
1322 mlir::Attribute initialVal, mlir::StringAttr linkage, in build()
1323 llvm::ArrayRef<mlir::NamedAttribute> attrs) { in build()
1325 result.addAttribute(getTypeAttrName(result.name), mlir::TypeAttr::get(type)); in build()
1326 result.addAttribute(mlir::SymbolTable::getSymbolAttrName(), in build()
1329 mlir::SymbolRefAttr::get(builder.getContext(), name)); in build()
1340 void fir::GlobalOp::build(mlir::OpBuilder &builder, in build()
1341 mlir::OperationState &result, llvm::StringRef name, in build()
1342 mlir::Type type, mlir::Attribute initialVal, in build()
1343 mlir::StringAttr linkage, in build()
1344 llvm::ArrayRef<mlir::NamedAttribute> attrs) { in build()
1348 void fir::GlobalOp::build(mlir::OpBuilder &builder, in build()
1349 mlir::OperationState &result, llvm::StringRef name, in build()
1350 bool isConstant, mlir::Type type, in build()
1351 mlir::StringAttr linkage, in build()
1352 llvm::ArrayRef<mlir::NamedAttribute> attrs) { in build()
1356 void fir::GlobalOp::build(mlir::OpBuilder &builder, in build()
1357 mlir::OperationState &result, llvm::StringRef name, in build()
1358 mlir::Type type, mlir::StringAttr linkage, in build()
1359 llvm::ArrayRef<mlir::NamedAttribute> attrs) { in build()
1363 void fir::GlobalOp::build(mlir::OpBuilder &builder, in build()
1364 mlir::OperationState &result, llvm::StringRef name, in build()
1365 bool isConstant, mlir::Type type, in build()
1366 llvm::ArrayRef<mlir::NamedAttribute> attrs) { in build()
1367 build(builder, result, name, isConstant, type, mlir::StringAttr{}, attrs); in build()
1370 void fir::GlobalOp::build(mlir::OpBuilder &builder, in build()
1371 mlir::OperationState &result, llvm::StringRef name, in build()
1372 mlir::Type type, in build()
1373 llvm::ArrayRef<mlir::NamedAttribute> attrs) { in build()
1377 mlir::ParseResult fir::GlobalOp::verifyValidLinkage(llvm::StringRef linkage) { in verifyValidLinkage()
1381 return mlir::success(llvm::is_contained(validNames, linkage)); in verifyValidLinkage()
1388 mlir::ParseResult fir::GlobalLenOp::parse(mlir::OpAsmParser &parser, in parse()
1389 mlir::OperationState &result) { in parse()
1392 mlir::StringAttr fieldAttr; in parse()
1396 return mlir::failure(); in parse()
1401 mlir::IntegerAttr constant; in parse()
1405 return mlir::failure(); in parse()
1406 return mlir::success(); in parse()
1409 void fir::GlobalLenOp::print(mlir::OpAsmPrinter &p) { in print()
1419 mlir::ParseResult parseFieldLikeOp(mlir::OpAsmParser &parser, in parseFieldLikeOp()
1420 mlir::OperationState &result) { in parseFieldLikeOp()
1423 mlir::Type recty; in parseFieldLikeOp()
1426 return mlir::failure(); in parseFieldLikeOp()
1430 return mlir::failure(); in parseFieldLikeOp()
1432 mlir::TypeAttr::get(recty)); in parseFieldLikeOp()
1434 llvm::SmallVector<mlir::OpAsmParser::UnresolvedOperand> operands; in parseFieldLikeOp()
1435 llvm::SmallVector<mlir::Type> types; in parseFieldLikeOp()
1437 if (parser.parseOperandList(operands, mlir::OpAsmParser::Delimiter::None) || in parseFieldLikeOp()
1440 return mlir::failure(); in parseFieldLikeOp()
1442 mlir::Type fieldType = TY::get(builder.getContext()); in parseFieldLikeOp()
1444 return mlir::failure(); in parseFieldLikeOp()
1445 return mlir::success(); in parseFieldLikeOp()
1448 mlir::ParseResult fir::FieldIndexOp::parse(mlir::OpAsmParser &parser, in parse()
1449 mlir::OperationState &result) { in parse()
1454 void printFieldLikeOp(mlir::OpAsmPrinter &p, OP &op) { in printFieldLikeOp()
1457 ->template getAttrOfType<mlir::StringAttr>( in printFieldLikeOp()
1476 void fir::FieldIndexOp::print(mlir::OpAsmPrinter &p) { in print()
1480 void fir::FieldIndexOp::build(mlir::OpBuilder &builder, in build()
1481 mlir::OperationState &result, in build()
1482 llvm::StringRef fieldName, mlir::Type recTy, in build()
1483 mlir::ValueRange operands) { in build()
1485 result.addAttribute(getTypeAttrName(), mlir::TypeAttr::get(recTy)); in build()
1489 llvm::SmallVector<mlir::Attribute> fir::FieldIndexOp::getAttributes() { in getAttributes()
1490 llvm::SmallVector<mlir::Attribute> attrs; in getAttributes()
1500 static mlir::ParseResult
1501 parseCustomRangeSubscript(mlir::OpAsmParser &parser, in parseCustomRangeSubscript()
1502 mlir::DenseIntElementsAttr &coord) { in parseCustomRangeSubscript()
1507 mlir::AsmParser::Delimiter::Paren, in parseCustomRangeSubscript()
1510 parser.parseCommaSeparatedList(mlir::AsmParser::Delimiter::Paren, [&] { in parseCustomRangeSubscript()
1513 return mlir::failure(); in parseCustomRangeSubscript()
1519 coord = mlir::Builder(parser.getContext()).getIndexTensorAttr(zippedBounds); in parseCustomRangeSubscript()
1520 return mlir::success(); in parseCustomRangeSubscript()
1523 static void printCustomRangeSubscript(mlir::OpAsmPrinter &printer, in printCustomRangeSubscript()
1525 mlir::DenseIntElementsAttr coord) { in printCustomRangeSubscript()
1545 mlir::LogicalResult fir::InsertOnRangeOp::verify() { in verify()
1548 mlir::DenseIntElementsAttr coorAttr = getCoor(); in verify()
1565 return mlir::success(); in verify()
1572 static bool checkIsIntegerConstant(mlir::Attribute attr, std::int64_t conVal) { in checkIsIntegerConstant()
1573 if (auto iattr = attr.dyn_cast<mlir::IntegerAttr>()) in checkIsIntegerConstant()
1578 static bool isZero(mlir::Attribute a) { return checkIsIntegerConstant(a, 0); } in isZero()
1579 static bool isOne(mlir::Attribute a) { return checkIsIntegerConstant(a, 1); } in isOne()
1584 struct UndoComplexPattern : public mlir::RewritePattern {
1585 UndoComplexPattern(mlir::MLIRContext *ctx) in UndoComplexPattern()
1586 : mlir::RewritePattern("fir.insert_value", 2, ctx) {} in UndoComplexPattern()
1588 mlir::LogicalResult
1589 matchAndRewrite(mlir::Operation *op, in matchAndRewrite()
1590 mlir::PatternRewriter &rewriter) const override { in matchAndRewrite()
1591 auto insval = mlir::dyn_cast_or_null<fir::InsertValueOp>(op); in matchAndRewrite()
1593 return mlir::failure(); in matchAndRewrite()
1594 auto insval2 = mlir::dyn_cast_or_null<fir::InsertValueOp>( in matchAndRewrite()
1597 return mlir::failure(); in matchAndRewrite()
1598 auto binf = mlir::dyn_cast_or_null<FltOp>(insval.getVal().getDefiningOp()); in matchAndRewrite()
1600 mlir::dyn_cast_or_null<FltOp>(insval2.getVal().getDefiningOp()); in matchAndRewrite()
1604 return mlir::failure(); in matchAndRewrite()
1605 auto eai = mlir::dyn_cast_or_null<fir::ExtractValueOp>( in matchAndRewrite()
1607 auto ebi = mlir::dyn_cast_or_null<fir::ExtractValueOp>( in matchAndRewrite()
1609 auto ear = mlir::dyn_cast_or_null<fir::ExtractValueOp>( in matchAndRewrite()
1611 auto ebr = mlir::dyn_cast_or_null<fir::ExtractValueOp>( in matchAndRewrite()
1619 return mlir::failure(); in matchAndRewrite()
1621 return mlir::success(); in matchAndRewrite()
1626 mlir::RewritePatternSet &results, mlir::MLIRContext *context) { in getCanonicalizationPatterns()
1627 results.insert<UndoComplexPattern<mlir::arith::AddFOp, fir::AddcOp>, in getCanonicalizationPatterns()
1628 UndoComplexPattern<mlir::arith::SubFOp, fir::SubcOp>>(context); in getCanonicalizationPatterns()
1635 void fir::IterWhileOp::build(mlir::OpBuilder &builder, in build()
1636 mlir::OperationState &result, mlir::Value lb, in build()
1637 mlir::Value ub, mlir::Value step, in build()
1638 mlir::Value iterate, bool finalCountValue, in build()
1639 mlir::ValueRange iterArgs, in build()
1640 llvm::ArrayRef<mlir::NamedAttribute> attributes) { in build()
1650 mlir::Region *bodyRegion = result.addRegion(); in build()
1651 bodyRegion->push_back(new mlir::Block{}); in build()
1656 llvm::SmallVector<mlir::Location>(iterArgs.size(), result.location)); in build()
1660 mlir::ParseResult fir::IterWhileOp::parse(mlir::OpAsmParser &parser, in parse()
1661 mlir::OperationState &result) { in parse()
1663 mlir::OpAsmParser::Argument inductionVariable, iterateVar; in parse()
1664 mlir::OpAsmParser::UnresolvedOperand lb, ub, step, iterateInput; in parse()
1667 return mlir::failure(); in parse()
1683 return mlir::failure(); in parse()
1689 llvm::SmallVector<mlir::OpAsmParser::Argument> regionArgs; in parse()
1694 llvm::SmallVector<mlir::OpAsmParser::UnresolvedOperand> operands; in parse()
1695 llvm::SmallVector<mlir::Type> regionTypes; in parse()
1699 return mlir::failure(); in parse()
1702 llvm::ArrayRef<mlir::Type> resTypes = regionTypes; in parse()
1708 return mlir::failure(); in parse()
1716 llvm::SmallVector<mlir::Type> typeList; in parse()
1719 return mlir::failure(); in parse()
1721 if (typeList.size() != 2 || !typeList[0].isa<mlir::IndexType>() || in parse()
1723 return mlir::failure(); in parse()
1731 return mlir::failure(); in parse()
1733 llvm::SmallVector<mlir::Type> argTypes; in parse()
1753 return mlir::failure(); in parse()
1756 return mlir::success(); in parse()
1759 mlir::LogicalResult fir::IterWhileOp::verify() { in verify()
1775 if (!getResult(0).getType().isa<mlir::IndexType>()) in verify()
1787 return mlir::failure(); in verify()
1808 return mlir::success(); in verify()
1811 void fir::IterWhileOp::print(mlir::OpAsmPrinter &p) { in print()
1837 mlir::Region &fir::IterWhileOp::getLoopBody() { return getRegion(); } in getLoopBody()
1839 mlir::BlockArgument fir::IterWhileOp::iterArgToBlockArg(mlir::Value iterArg) { in iterArgToBlockArg()
1847 llvm::SmallVectorImpl<mlir::Value> &results, unsigned resultNum) { in resultToSourceOps()
1854 mlir::Value fir::IterWhileOp::blockArgToSourceOp(unsigned blockArgNum) { in blockArgToSourceOp()
1864 mlir::ParseResult fir::LenParamIndexOp::parse(mlir::OpAsmParser &parser, in parse()
1865 mlir::OperationState &result) { in parse()
1869 void fir::LenParamIndexOp::print(mlir::OpAsmPrinter &p) { in print()
1873 void fir::LenParamIndexOp::build(mlir::OpBuilder &builder, in build()
1874 mlir::OperationState &result, in build()
1875 llvm::StringRef fieldName, mlir::Type recTy, in build()
1876 mlir::ValueRange operands) { in build()
1878 result.addAttribute(getTypeAttrName(), mlir::TypeAttr::get(recTy)); in build()
1882 llvm::SmallVector<mlir::Attribute> fir::LenParamIndexOp::getAttributes() { in getAttributes()
1883 llvm::SmallVector<mlir::Attribute> attrs; in getAttributes()
1893 void fir::LoadOp::build(mlir::OpBuilder &builder, mlir::OperationState &result, in build()
1894 mlir::Value refVal) { in build()
1896 mlir::emitError(result.location, "LoadOp has null argument"); in build()
1901 mlir::emitError(result.location, "not a memory reference type"); in build()
1908 mlir::ParseResult fir::LoadOp::getElementOf(mlir::Type &ele, mlir::Type ref) { in getElementOf()
1910 return mlir::success(); in getElementOf()
1911 return mlir::failure(); in getElementOf()
1914 mlir::ParseResult fir::LoadOp::parse(mlir::OpAsmParser &parser, in parse()
1915 mlir::OperationState &result) { in parse()
1916 mlir::Type type; in parse()
1917 mlir::OpAsmParser::UnresolvedOperand oper; in parse()
1922 return mlir::failure(); in parse()
1923 mlir::Type eleTy; in parse()
1926 return mlir::failure(); in parse()
1927 return mlir::success(); in parse()
1930 void fir::LoadOp::print(mlir::OpAsmPrinter &p) { in print()
1941 void fir::DoLoopOp::build(mlir::OpBuilder &builder, in build()
1942 mlir::OperationState &result, mlir::Value lb, in build()
1943 mlir::Value ub, mlir::Value step, bool unordered, in build()
1944 bool finalCountValue, mlir::ValueRange iterArgs, in build()
1945 llvm::ArrayRef<mlir::NamedAttribute> attributes) { in build()
1955 mlir::Region *bodyRegion = result.addRegion(); in build()
1956 bodyRegion->push_back(new mlir::Block{}); in build()
1962 llvm::SmallVector<mlir::Location>(iterArgs.size(), result.location)); in build()
1969 mlir::ParseResult fir::DoLoopOp::parse(mlir::OpAsmParser &parser, in parse()
1970 mlir::OperationState &result) { in parse()
1972 mlir::OpAsmParser::Argument inductionVariable; in parse()
1973 mlir::OpAsmParser::UnresolvedOperand lb, ub, step; in parse()
1976 return mlir::failure(); in parse()
1986 return mlir::failure(); in parse()
1988 if (mlir::succeeded(parser.parseOptionalKeyword("unordered"))) in parse()
1992 llvm::SmallVector<mlir::OpAsmParser::Argument> regionArgs; in parse()
1993 llvm::SmallVector<mlir::OpAsmParser::UnresolvedOperand> operands; in parse()
1994 llvm::SmallVector<mlir::Type> argTypes; in parse()
2002 return mlir::failure(); in parse()
2006 llvm::ArrayRef<mlir::Type> resTypes = result.types; in parse()
2011 return mlir::failure(); in parse()
2014 return mlir::failure(); in parse()
2020 return mlir::failure(); in parse()
2040 return mlir::failure(); in parse()
2044 return mlir::success(); in parse()
2047 fir::DoLoopOp fir::getForInductionVarOwner(mlir::Value val) { in getForInductionVarOwner()
2048 auto ivArg = val.dyn_cast<mlir::BlockArgument>(); in getForInductionVarOwner()
2053 return mlir::dyn_cast_or_null<fir::DoLoopOp>(containingInst); in getForInductionVarOwner()
2057 mlir::LogicalResult fir::DoLoopOp::verify() { in verify()
2068 return mlir::success(); in verify()
2095 return mlir::success(); in verify()
2098 void fir::DoLoopOp::print(mlir::OpAsmPrinter &p) { in print()
2124 mlir::Region &fir::DoLoopOp::getLoopBody() { return getRegion(); } in getLoopBody()
2128 mlir::BlockArgument fir::DoLoopOp::iterArgToBlockArg(mlir::Value iterArg) { in iterArgToBlockArg()
2138 llvm::SmallVectorImpl<mlir::Value> &results, unsigned resultNum) { in resultToSourceOps()
2147 mlir::Value fir::DoLoopOp::blockArgToSourceOp(unsigned blockArgNum) { in blockArgToSourceOp()
2157 mlir::ParseResult fir::DTEntryOp::parse(mlir::OpAsmParser &parser, in parse()
2158 mlir::OperationState &result) { in parse()
2162 mlir::StringAttr methodAttr; in parse()
2166 return mlir::failure(); in parse()
2171 mlir::SymbolRefAttr calleeAttr; in parse()
2175 return mlir::failure(); in parse()
2176 return mlir::success(); in parse()
2179 void fir::DTEntryOp::print(mlir::OpAsmPrinter &p) { in print()
2189 static mlir::Type getBoxScalarEleTy(mlir::Type boxTy) { in getBoxScalarEleTy()
2197 static unsigned getBoxRank(mlir::Type boxTy) { in getBoxRank()
2206 static bool areCompatibleCharacterTypes(mlir::Type t1, mlir::Type t2) { in areCompatibleCharacterTypes()
2216 mlir::LogicalResult fir::ReboxOp::verify() { in verify()
2243 auto slicedRank = mlir::cast<fir::SliceOp>(sliceOp).getOutRank(); in verify()
2284 return mlir::success(); in verify()
2291 mlir::LogicalResult fir::ResultOp::verify() { in verify()
2301 return mlir::success(); in verify()
2308 mlir::LogicalResult fir::SaveResultOp::verify() { in verify()
2319 return mlir::success(); in verify()
2357 return mlir::success(); in verify()
2372 static mlir::LogicalResult verifyIntegralSwitchTerminator(OpT op) { in verifyIntegralSwitchTerminator()
2375 .template isa<mlir::IntegerType, mlir::IndexType, in verifyIntegralSwitchTerminator()
2379 op->template getAttrOfType<mlir::ArrayAttr>(op.getCasesAttr()).getValue(); in verifyIntegralSwitchTerminator()
2388 if (!cases[i].template isa<mlir::IntegerAttr, mlir::UnitAttr>()) in verifyIntegralSwitchTerminator()
2391 return mlir::success(); in verifyIntegralSwitchTerminator()
2394 static mlir::ParseResult parseIntegralSwitchTerminator( in parseIntegralSwitchTerminator()
2395 mlir::OpAsmParser &parser, mlir::OperationState &result, in parseIntegralSwitchTerminator()
2397 mlir::OpAsmParser::UnresolvedOperand selector; in parseIntegralSwitchTerminator()
2398 mlir::Type type; in parseIntegralSwitchTerminator()
2400 return mlir::failure(); in parseIntegralSwitchTerminator()
2402 llvm::SmallVector<mlir::Attribute> ivalues; in parseIntegralSwitchTerminator()
2403 llvm::SmallVector<mlir::Block *> dests; in parseIntegralSwitchTerminator()
2404 llvm::SmallVector<llvm::SmallVector<mlir::Value>> destArgs; in parseIntegralSwitchTerminator()
2406 mlir::Attribute ivalue; // Integer or Unit in parseIntegralSwitchTerminator()
2407 mlir::Block *dest; in parseIntegralSwitchTerminator()
2408 llvm::SmallVector<mlir::Value> destArg; in parseIntegralSwitchTerminator()
2409 mlir::NamedAttrList temp; in parseIntegralSwitchTerminator()
2412 return mlir::failure(); in parseIntegralSwitchTerminator()
2419 return mlir::failure(); in parseIntegralSwitchTerminator()
2436 return mlir::success(); in parseIntegralSwitchTerminator()
2440 static void printIntegralSwitchTerminator(OpT op, mlir::OpAsmPrinter &p) { in printIntegralSwitchTerminator()
2445 op->template getAttrOfType<mlir::ArrayAttr>(op.getCasesAttr()).getValue(); in printIntegralSwitchTerminator()
2451 if (auto intAttr = attr.template dyn_cast_or_null<mlir::IntegerAttr>()) in printIntegralSwitchTerminator()
2468 mlir::LogicalResult fir::SelectOp::verify() { in verify()
2472 mlir::ParseResult fir::SelectOp::parse(mlir::OpAsmParser &parser, in parse()
2473 mlir::OperationState &result) { in parse()
2478 void fir::SelectOp::print(mlir::OpAsmPrinter &p) { in print()
2484 mlir::DenseIntElementsAttr ranges, in getSubOperands()
2493 static mlir::MutableOperandRange
2494 getMutableSuccessorOperands(unsigned pos, mlir::MutableOperandRange operands, in getMutableSuccessorOperands()
2496 mlir::Operation *owner = operands.getOwner(); in getMutableSuccessorOperands()
2497 mlir::NamedAttribute targetOffsetAttr = in getMutableSuccessorOperands()
2501 targetOffsetAttr.getValue().cast<mlir::DenseIntElementsAttr>(), in getMutableSuccessorOperands()
2502 mlir::MutableOperandRange::OperandSegment(pos, targetOffsetAttr)); in getMutableSuccessorOperands()
2505 static unsigned denseElementsSize(mlir::DenseIntElementsAttr attr) { in denseElementsSize()
2509 llvm::Optional<mlir::OperandRange> fir::SelectOp::getCompareOperands(unsigned) { in getCompareOperands()
2513 llvm::Optional<llvm::ArrayRef<mlir::Value>>
2514 fir::SelectOp::getCompareOperands(llvm::ArrayRef<mlir::Value>, unsigned) { in getCompareOperands()
2518 mlir::SuccessorOperands fir::SelectOp::getSuccessorOperands(unsigned oper) { in getSuccessorOperands()
2519 return mlir::SuccessorOperands(::getMutableSuccessorOperands( in getSuccessorOperands()
2523 llvm::Optional<llvm::ArrayRef<mlir::Value>>
2524 fir::SelectOp::getSuccessorOperands(llvm::ArrayRef<mlir::Value> operands, in getSuccessorOperands()
2527 (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr()); in getSuccessorOperands()
2528 auto segments = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>( in getSuccessorOperands()
2533 llvm::Optional<mlir::ValueRange>
2534 fir::SelectOp::getSuccessorOperands(mlir::ValueRange operands, unsigned oper) { in getSuccessorOperands()
2536 (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr()); in getSuccessorOperands()
2537 auto segments = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>( in getSuccessorOperands()
2543 return denseElementsSize((*this)->getAttrOfType<mlir::DenseIntElementsAttr>( in targetOffsetSize()
2551 llvm::Optional<mlir::OperandRange>
2553 auto a = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>( in getCompareOperands()
2558 llvm::Optional<llvm::ArrayRef<mlir::Value>>
2559 fir::SelectCaseOp::getCompareOperands(llvm::ArrayRef<mlir::Value> operands, in getCompareOperands()
2561 auto a = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>( in getCompareOperands()
2563 auto segments = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>( in getCompareOperands()
2568 llvm::Optional<mlir::ValueRange>
2569 fir::SelectCaseOp::getCompareOperands(mlir::ValueRange operands, in getCompareOperands()
2571 auto a = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>( in getCompareOperands()
2573 auto segments = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>( in getCompareOperands()
2578 mlir::SuccessorOperands fir::SelectCaseOp::getSuccessorOperands(unsigned oper) { in getSuccessorOperands()
2579 return mlir::SuccessorOperands(::getMutableSuccessorOperands( in getSuccessorOperands()
2583 llvm::Optional<llvm::ArrayRef<mlir::Value>>
2584 fir::SelectCaseOp::getSuccessorOperands(llvm::ArrayRef<mlir::Value> operands, in getSuccessorOperands()
2587 (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr()); in getSuccessorOperands()
2588 auto segments = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>( in getSuccessorOperands()
2593 llvm::Optional<mlir::ValueRange>
2594 fir::SelectCaseOp::getSuccessorOperands(mlir::ValueRange operands, in getSuccessorOperands()
2597 (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr()); in getSuccessorOperands()
2598 auto segments = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>( in getSuccessorOperands()
2604 mlir::ParseResult fir::SelectCaseOp::parse(mlir::OpAsmParser &parser, in parse()
2605 mlir::OperationState &result) { in parse()
2606 mlir::OpAsmParser::UnresolvedOperand selector; in parse()
2607 mlir::Type type; in parse()
2609 return mlir::failure(); in parse()
2611 llvm::SmallVector<mlir::Attribute> attrs; in parse()
2612 llvm::SmallVector<mlir::OpAsmParser::UnresolvedOperand> opers; in parse()
2613 llvm::SmallVector<mlir::Block *> dests; in parse()
2614 llvm::SmallVector<llvm::SmallVector<mlir::Value>> destArgs; in parse()
2618 mlir::Attribute attr; in parse()
2619 mlir::Block *dest; in parse()
2620 llvm::SmallVector<mlir::Value> destArg; in parse()
2621 mlir::NamedAttrList temp; in parse()
2624 return mlir::failure(); in parse()
2626 if (attr.dyn_cast_or_null<mlir::UnitAttr>()) { in parse()
2629 mlir::OpAsmParser::UnresolvedOperand oper1; in parse()
2630 mlir::OpAsmParser::UnresolvedOperand oper2; in parse()
2633 return mlir::failure(); in parse()
2639 mlir::OpAsmParser::UnresolvedOperand oper; in parse()
2641 return mlir::failure(); in parse()
2647 return mlir::failure(); in parse()
2650 if (mlir::succeeded(parser.parseOptionalRSquare())) in parse()
2653 return mlir::failure(); in parse()
2658 return mlir::failure(); in parse()
2674 return mlir::success(); in parse()
2677 void fir::SelectCaseOp::print(mlir::OpAsmPrinter &p) { in print()
2682 getOperation()->getAttrOfType<mlir::ArrayAttr>(getCasesAttr()).getValue(); in print()
2688 if (!cases[i].isa<mlir::UnitAttr>()) { in print()
2706 return denseElementsSize((*this)->getAttrOfType<mlir::DenseIntElementsAttr>( in compareOffsetSize()
2711 return denseElementsSize((*this)->getAttrOfType<mlir::DenseIntElementsAttr>( in targetOffsetSize()
2715 void fir::SelectCaseOp::build(mlir::OpBuilder &builder, in build()
2716 mlir::OperationState &result, in build()
2717 mlir::Value selector, in build()
2718 llvm::ArrayRef<mlir::Attribute> compareAttrs, in build()
2719 llvm::ArrayRef<mlir::ValueRange> cmpOperands, in build()
2720 llvm::ArrayRef<mlir::Block *> destinations, in build()
2721 llvm::ArrayRef<mlir::ValueRange> destOperands, in build()
2722 llvm::ArrayRef<mlir::NamedAttribute> attributes) { in build()
2731 } else if (attr.isa<mlir::UnitAttr>()) { in build()
2768 void fir::SelectCaseOp::build(mlir::OpBuilder &builder, in build()
2769 mlir::OperationState &result, in build()
2770 mlir::Value selector, in build()
2771 llvm::ArrayRef<mlir::Attribute> compareAttrs, in build()
2772 llvm::ArrayRef<mlir::Value> cmpOpList, in build()
2773 llvm::ArrayRef<mlir::Block *> destinations, in build()
2774 llvm::ArrayRef<mlir::ValueRange> destOperands, in build()
2775 llvm::ArrayRef<mlir::NamedAttribute> attributes) { in build()
2776 llvm::SmallVector<mlir::ValueRange> cmpOpers; in build()
2780 cmpOpers.push_back(mlir::ValueRange({iter, iter + 2})); in build()
2782 } else if (attr.isa<mlir::UnitAttr>()) { in build()
2783 cmpOpers.push_back(mlir::ValueRange{}); in build()
2785 cmpOpers.push_back(mlir::ValueRange({iter, iter + 1})); in build()
2793 mlir::LogicalResult fir::SelectCaseOp::verify() { in verify()
2796 .isa<mlir::IntegerType, mlir::IndexType, fir::IntegerType, in verify()
2800 getOperation()->getAttrOfType<mlir::ArrayAttr>(getCasesAttr()).getValue(); in verify()
2814 attr.isa<fir::ClosedIntervalAttr>() || attr.isa<mlir::UnitAttr>())) in verify()
2817 return mlir::success(); in verify()
2824 mlir::LogicalResult fir::SelectRankOp::verify() { in verify()
2828 mlir::ParseResult fir::SelectRankOp::parse(mlir::OpAsmParser &parser, in parse()
2829 mlir::OperationState &result) { in parse()
2834 void fir::SelectRankOp::print(mlir::OpAsmPrinter &p) { in print()
2838 llvm::Optional<mlir::OperandRange>
2843 llvm::Optional<llvm::ArrayRef<mlir::Value>>
2844 fir::SelectRankOp::getCompareOperands(llvm::ArrayRef<mlir::Value>, unsigned) { in getCompareOperands()
2848 mlir::SuccessorOperands fir::SelectRankOp::getSuccessorOperands(unsigned oper) { in getSuccessorOperands()
2849 return mlir::SuccessorOperands(::getMutableSuccessorOperands( in getSuccessorOperands()
2853 llvm::Optional<llvm::ArrayRef<mlir::Value>>
2854 fir::SelectRankOp::getSuccessorOperands(llvm::ArrayRef<mlir::Value> operands, in getSuccessorOperands()
2857 (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr()); in getSuccessorOperands()
2858 auto segments = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>( in getSuccessorOperands()
2863 llvm::Optional<mlir::ValueRange>
2864 fir::SelectRankOp::getSuccessorOperands(mlir::ValueRange operands, in getSuccessorOperands()
2867 (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr()); in getSuccessorOperands()
2868 auto segments = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>( in getSuccessorOperands()
2874 return denseElementsSize((*this)->getAttrOfType<mlir::DenseIntElementsAttr>( in targetOffsetSize()
2882 llvm::Optional<mlir::OperandRange>
2887 llvm::Optional<llvm::ArrayRef<mlir::Value>>
2888 fir::SelectTypeOp::getCompareOperands(llvm::ArrayRef<mlir::Value>, unsigned) { in getCompareOperands()
2892 mlir::SuccessorOperands fir::SelectTypeOp::getSuccessorOperands(unsigned oper) { in getSuccessorOperands()
2893 return mlir::SuccessorOperands(::getMutableSuccessorOperands( in getSuccessorOperands()
2897 llvm::Optional<llvm::ArrayRef<mlir::Value>>
2898 fir::SelectTypeOp::getSuccessorOperands(llvm::ArrayRef<mlir::Value> operands, in getSuccessorOperands()
2901 (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr()); in getSuccessorOperands()
2902 auto segments = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>( in getSuccessorOperands()
2907 mlir::ParseResult fir::SelectTypeOp::parse(mlir::OpAsmParser &parser, in parse()
2908 mlir::OperationState &result) { in parse()
2909 mlir::OpAsmParser::UnresolvedOperand selector; in parse()
2910 mlir::Type type; in parse()
2912 return mlir::failure(); in parse()
2914 llvm::SmallVector<mlir::Attribute> attrs; in parse()
2915 llvm::SmallVector<mlir::Block *> dests; in parse()
2916 llvm::SmallVector<llvm::SmallVector<mlir::Value>> destArgs; in parse()
2918 mlir::Attribute attr; in parse()
2919 mlir::Block *dest; in parse()
2920 llvm::SmallVector<mlir::Value> destArg; in parse()
2921 mlir::NamedAttrList temp; in parse()
2924 return mlir::failure(); in parse()
2928 if (mlir::succeeded(parser.parseOptionalRSquare())) in parse()
2931 return mlir::failure(); in parse()
2949 return mlir::success(); in parse()
2953 return denseElementsSize((*this)->getAttrOfType<mlir::DenseIntElementsAttr>( in targetOffsetSize()
2957 void fir::SelectTypeOp::print(mlir::OpAsmPrinter &p) { in print()
2962 getOperation()->getAttrOfType<mlir::ArrayAttr>(getCasesAttr()).getValue(); in print()
2977 mlir::LogicalResult fir::SelectTypeOp::verify() { in verify()
2981 getOperation()->getAttrOfType<mlir::ArrayAttr>(getCasesAttr()).getValue(); in verify()
2992 attr.isa<mlir::UnitAttr>())) in verify()
2995 return mlir::success(); in verify()
2998 void fir::SelectTypeOp::build(mlir::OpBuilder &builder, in build()
2999 mlir::OperationState &result, in build()
3000 mlir::Value selector, in build()
3001 llvm::ArrayRef<mlir::Attribute> typeOperands, in build()
3002 llvm::ArrayRef<mlir::Block *> destinations, in build()
3003 llvm::ArrayRef<mlir::ValueRange> destOperands, in build()
3004 llvm::ArrayRef<mlir::NamedAttribute> attributes) { in build()
3008 for (mlir::Block *dest : destinations) in build()
3033 mlir::LogicalResult fir::ShapeOp::verify() { in verify()
3039 return mlir::success(); in verify()
3046 mlir::LogicalResult fir::ShapeShiftOp::verify() { in verify()
3056 return mlir::success(); in verify()
3063 mlir::LogicalResult fir::ShiftOp::verify() { in verify()
3069 return mlir::success(); in verify()
3076 void fir::SliceOp::build(mlir::OpBuilder &builder, mlir::OperationState &result, in build()
3077 mlir::ValueRange trips, mlir::ValueRange path, in build()
3078 mlir::ValueRange substr) { in build()
3086 unsigned fir::SliceOp::getOutputRank(mlir::ValueRange triples) { in getOutputRank()
3091 if (!mlir::isa_and_nonnull<fir::UndefOp>(op)) in getOutputRank()
3099 mlir::LogicalResult fir::SliceOp::verify() { in verify()
3109 return mlir::success(); in verify()
3116 mlir::Type fir::StoreOp::elementType(mlir::Type refType) { in elementType()
3120 mlir::ParseResult fir::StoreOp::parse(mlir::OpAsmParser &parser, in parse()
3121 mlir::OperationState &result) { in parse()
3122 mlir::Type type; in parse()
3123 mlir::OpAsmParser::UnresolvedOperand oper; in parse()
3124 mlir::OpAsmParser::UnresolvedOperand store; in parse()
3132 return mlir::failure(); in parse()
3133 return mlir::success(); in parse()
3136 void fir::StoreOp::print(mlir::OpAsmPrinter &p) { in print()
3145 mlir::LogicalResult fir::StoreOp::verify() { in verify()
3150 return mlir::success(); in verify()
3164 static mlir::NamedAttribute
3165 mkNamedIntegerAttr(mlir::OpBuilder &builder, llvm::StringRef name, int64_t v) { in mkNamedIntegerAttr()
3171 void fir::StringLitOp::build(mlir::OpBuilder &builder, in build()
3172 mlir::OperationState &result, in build()
3183 static mlir::ArrayAttr convertToArrayAttr(mlir::OpBuilder &builder, in convertToArrayAttr()
3185 llvm::SmallVector<mlir::Attribute> attrs; in convertToArrayAttr()
3192 void fir::StringLitOp::build(mlir::OpBuilder &builder, in build()
3193 mlir::OperationState &result, in build()
3205 void fir::StringLitOp::build(mlir::OpBuilder &builder, in build()
3206 mlir::OperationState &result, in build()
3218 void fir::StringLitOp::build(mlir::OpBuilder &builder, in build()
3219 mlir::OperationState &result, in build()
3231 mlir::ParseResult fir::StringLitOp::parse(mlir::OpAsmParser &parser, in parse()
3232 mlir::OperationState &result) { in parse()
3234 mlir::Attribute val; in parse()
3235 mlir::NamedAttrList attrs; in parse()
3238 return mlir::failure(); in parse()
3239 if (auto v = val.dyn_cast<mlir::StringAttr>()) in parse()
3242 else if (auto v = val.dyn_cast<mlir::DenseElementsAttr>()) in parse()
3245 else if (auto v = val.dyn_cast<mlir::ArrayAttr>()) in parse()
3251 mlir::IntegerAttr sz; in parse()
3252 mlir::Type type; in parse()
3257 return mlir::failure(); in parse()
3264 return mlir::failure(); in parse()
3265 return mlir::success(); in parse()
3268 void fir::StringLitOp::print(mlir::OpAsmPrinter &p) { in print()
3270 p << getSize().cast<mlir::IntegerAttr>().getValue() << ") : "; in print()
3274 mlir::LogicalResult fir::StringLitOp::verify() { in verify()
3275 if (getSize().cast<mlir::IntegerAttr>().getValue().isNegative()) in verify()
3278 if (auto xList = xl.dyn_cast<mlir::ArrayAttr>()) { in verify()
3280 if (!a.isa<mlir::IntegerAttr>()) in verify()
3282 } else if (xl.isa<mlir::DenseElementsAttr>()) { in verify()
3288 return mlir::success(); in verify()
3295 mlir::LogicalResult fir::UnboxProcOp::verify() { in verify()
3297 if (eleTy.isa<mlir::TupleType>()) in verify()
3298 return mlir::success(); in verify()
3306 void fir::IfOp::build(mlir::OpBuilder &builder, mlir::OperationState &result, in build()
3307 mlir::Value cond, bool withElseRegion) { in build()
3311 void fir::IfOp::build(mlir::OpBuilder &builder, mlir::OperationState &result, in build()
3312 mlir::TypeRange resultTypes, mlir::Value cond, in build()
3317 mlir::Region *thenRegion = result.addRegion(); in build()
3318 thenRegion->push_back(new mlir::Block()); in build()
3322 mlir::Region *elseRegion = result.addRegion(); in build()
3324 elseRegion->push_back(new mlir::Block()); in build()
3330 mlir::ParseResult fir::IfOp::parse(mlir::OpAsmParser &parser, in parse()
3331 mlir::OperationState &result) { in parse()
3333 mlir::Region *thenRegion = result.addRegion(); in parse()
3334 mlir::Region *elseRegion = result.addRegion(); in parse()
3337 mlir::OpAsmParser::UnresolvedOperand cond; in parse()
3338 mlir::Type i1Type = builder.getIntegerType(1); in parse()
3341 return mlir::failure(); in parse()
3344 return mlir::failure(); in parse()
3347 return mlir::failure(); in parse()
3351 if (mlir::succeeded(parser.parseOptionalKeyword("else"))) { in parse()
3353 return mlir::failure(); in parse()
3360 return mlir::failure(); in parse()
3361 return mlir::success(); in parse()
3364 mlir::LogicalResult fir::IfOp::verify() { in verify()
3368 return mlir::success(); in verify()
3371 void fir::IfOp::print(mlir::OpAsmPrinter &p) { in print()
3392 void fir::IfOp::resultToSourceOps(llvm::SmallVectorImpl<mlir::Value> &results, in resultToSourceOps()
3404 mlir::ParseResult fir::isValidCaseAttr(mlir::Attribute attr) { in isValidCaseAttr()
3405 if (attr.isa<mlir::UnitAttr, fir::ClosedIntervalAttr, fir::PointIntervalAttr, in isValidCaseAttr()
3407 return mlir::success(); in isValidCaseAttr()
3408 return mlir::failure(); in isValidCaseAttr()
3411 unsigned fir::getCaseArgumentOffset(llvm::ArrayRef<mlir::Attribute> cases, in getCaseArgumentOffset()
3416 if (!attr.dyn_cast_or_null<mlir::UnitAttr>()) { in getCaseArgumentOffset()
3425 mlir::ParseResult
3426 fir::parseSelector(mlir::OpAsmParser &parser, mlir::OperationState &result, in parseSelector()
3427 mlir::OpAsmParser::UnresolvedOperand &selector, in parseSelector()
3428 mlir::Type &type) { in parseSelector()
3432 return mlir::failure(); in parseSelector()
3433 return mlir::success(); in parseSelector()
3436 mlir::func::FuncOp
3437 fir::createFuncOp(mlir::Location loc, mlir::ModuleOp module, in createFuncOp()
3438 llvm::StringRef name, mlir::FunctionType type, in createFuncOp()
3439 llvm::ArrayRef<mlir::NamedAttribute> attrs) { in createFuncOp()
3440 if (auto f = module.lookupSymbol<mlir::func::FuncOp>(name)) in createFuncOp()
3442 mlir::OpBuilder modBuilder(module.getBodyRegion()); in createFuncOp()
3444 auto result = modBuilder.create<mlir::func::FuncOp>(loc, name, type, attrs); in createFuncOp()
3445 result.setVisibility(mlir::SymbolTable::Visibility::Private); in createFuncOp()
3449 fir::GlobalOp fir::createGlobalOp(mlir::Location loc, mlir::ModuleOp module, in createGlobalOp()
3450 llvm::StringRef name, mlir::Type type, in createGlobalOp()
3451 llvm::ArrayRef<mlir::NamedAttribute> attrs) { in createGlobalOp()
3454 mlir::OpBuilder modBuilder(module.getBodyRegion()); in createGlobalOp()
3456 result.setVisibility(mlir::SymbolTable::Visibility::Private); in createGlobalOp()
3460 bool fir::hasHostAssociationArgument(mlir::func::FuncOp func) { in hasHostAssociationArgument()
3463 if (auto dict = attr.template dyn_cast_or_null<mlir::DictionaryAttr>()) in hasHostAssociationArgument()
3469 bool fir::valueHasFirAttribute(mlir::Value value, in valueHasFirAttribute()
3475 if (auto loadOp = mlir::dyn_cast<fir::LoadOp>(definingOp)) in valueHasFirAttribute()
3478 if (auto blockArg = value.dyn_cast<mlir::BlockArgument>()) { in valueHasFirAttribute()
3480 if (auto funcOp = mlir::dyn_cast<mlir::func::FuncOp>( in valueHasFirAttribute()
3489 if (mlir::isa<fir::AllocMemOp>(definingOp) || in valueHasFirAttribute()
3490 mlir::isa<AllocaOp>(definingOp)) in valueHasFirAttribute()
3496 if (auto addressOfOp = mlir::dyn_cast<fir::AddrOfOp>(definingOp)) { in valueHasFirAttribute()
3499 if (auto module = definingOp->getParentOfType<mlir::ModuleOp>()) in valueHasFirAttribute()
3510 bool fir::anyFuncArgsHaveAttr(mlir::func::FuncOp func, llvm::StringRef attr) { in anyFuncArgsHaveAttr()
3517 mlir::Type fir::applyPathToType(mlir::Type eleTy, mlir::ValueRange path) { in applyPathToType()
3519 eleTy = llvm::TypeSwitch<mlir::Type, mlir::Type>(eleTy) in applyPathToType()
3522 if (auto off = mlir::dyn_cast<fir::FieldIndexOp>(op)) in applyPathToType()
3524 if (auto off = mlir::dyn_cast<mlir::arith::ConstantOp>(op)) in applyPathToType()
3527 return mlir::Type{}; in applyPathToType()
3535 return valid ? ty.getEleTy() : mlir::Type{}; in applyPathToType()
3537 .Case<mlir::TupleType>([&](mlir::TupleType ty) { in applyPathToType()
3539 if (auto off = mlir::dyn_cast<mlir::arith::ConstantOp>(op)) in applyPathToType()
3541 return mlir::Type{}; in applyPathToType()
3548 op->getParentOfType<mlir::ModuleOp>())); in applyPathToType()
3549 return mlir::Type{}; in applyPathToType()
3551 .Case<mlir::ComplexType>([&](mlir::ComplexType ty) { in applyPathToType()
3554 return mlir::Type{}; in applyPathToType()
3556 .Default([&](const auto &) { return mlir::Type{}; }); in applyPathToType()