@@ -3547,30 +3547,127 @@ void CallIntrinsicOp::build(OpBuilder &builder, OperationState &state,
35473547 mlir::StringAttr intrin, mlir::ValueRange args) {
35483548 build (builder, state, /* resultTypes=*/ TypeRange{}, intrin, args,
35493549 FastmathFlagsAttr{},
3550- /* op_bundle_operands=*/ {}, /* op_bundle_tags=*/ {});
3550+ /* op_bundle_operands=*/ {}, /* op_bundle_tags=*/ {}, /* arg_attrs=*/ {},
3551+ /* res_attrs=*/ {});
35513552}
35523553
35533554void CallIntrinsicOp::build (OpBuilder &builder, OperationState &state,
35543555 mlir::StringAttr intrin, mlir::ValueRange args,
35553556 mlir::LLVM::FastmathFlagsAttr fastMathFlags) {
35563557 build (builder, state, /* resultTypes=*/ TypeRange{}, intrin, args,
35573558 fastMathFlags,
3558- /* op_bundle_operands=*/ {}, /* op_bundle_tags=*/ {});
3559+ /* op_bundle_operands=*/ {}, /* op_bundle_tags=*/ {}, /* arg_attrs=*/ {},
3560+ /* res_attrs=*/ {});
35593561}
35603562
35613563void CallIntrinsicOp::build (OpBuilder &builder, OperationState &state,
35623564 mlir::Type resultType, mlir::StringAttr intrin,
35633565 mlir::ValueRange args) {
35643566 build (builder, state, {resultType}, intrin, args, FastmathFlagsAttr{},
3565- /* op_bundle_operands=*/ {}, /* op_bundle_tags=*/ {});
3567+ /* op_bundle_operands=*/ {}, /* op_bundle_tags=*/ {}, /* arg_attrs=*/ {},
3568+ /* res_attrs=*/ {});
35663569}
35673570
35683571void CallIntrinsicOp::build (OpBuilder &builder, OperationState &state,
35693572 mlir::TypeRange resultTypes,
35703573 mlir::StringAttr intrin, mlir::ValueRange args,
35713574 mlir::LLVM::FastmathFlagsAttr fastMathFlags) {
35723575 build (builder, state, resultTypes, intrin, args, fastMathFlags,
3573- /* op_bundle_operands=*/ {}, /* op_bundle_tags=*/ {});
3576+ /* op_bundle_operands=*/ {}, /* op_bundle_tags=*/ {}, /* arg_attrs=*/ {},
3577+ /* res_attrs=*/ {});
3578+ }
3579+
3580+ ParseResult CallIntrinsicOp::parse (OpAsmParser &parser,
3581+ OperationState &result) {
3582+ StringAttr intrinAttr;
3583+ SmallVector<OpAsmParser::UnresolvedOperand, 4 > operands;
3584+ SmallVector<SmallVector<OpAsmParser::UnresolvedOperand>> opBundleOperands;
3585+ SmallVector<SmallVector<Type>> opBundleOperandTypes;
3586+ ArrayAttr opBundleTags;
3587+
3588+ // Parse intrinsic name.
3589+ if (parser.parseCustomAttributeWithFallback (
3590+ intrinAttr, parser.getBuilder ().getType <NoneType>()))
3591+ return failure ();
3592+ result.addAttribute (CallIntrinsicOp::getIntrinAttrName (result.name ),
3593+ intrinAttr);
3594+
3595+ if (parser.parseLParen ())
3596+ return failure ();
3597+
3598+ // Parse the function arguments.
3599+ if (parser.parseOperandList (operands))
3600+ return mlir::failure ();
3601+
3602+ if (parser.parseRParen ())
3603+ return mlir::failure ();
3604+
3605+ // Handle bundles.
3606+ SMLoc opBundlesLoc = parser.getCurrentLocation ();
3607+ if (std::optional<ParseResult> result = parseOpBundles (
3608+ parser, opBundleOperands, opBundleOperandTypes, opBundleTags);
3609+ result && failed (*result))
3610+ return failure ();
3611+ if (opBundleTags && !opBundleTags.empty ())
3612+ result.addAttribute (
3613+ CallIntrinsicOp::getOpBundleTagsAttrName (result.name ).getValue (),
3614+ opBundleTags);
3615+
3616+ if (parser.parseOptionalAttrDict (result.attributes ))
3617+ return mlir::failure ();
3618+
3619+ SmallVector<DictionaryAttr> argAttrs;
3620+ SmallVector<DictionaryAttr> resultAttrs;
3621+ if (parseCallTypeAndResolveOperands (parser, result, /* isDirect=*/ true ,
3622+ operands, argAttrs, resultAttrs))
3623+ return failure ();
3624+ call_interface_impl::addArgAndResultAttrs (
3625+ parser.getBuilder (), result, argAttrs, resultAttrs,
3626+ getArgAttrsAttrName (result.name ), getResAttrsAttrName (result.name ));
3627+
3628+ if (resolveOpBundleOperands (parser, opBundlesLoc, result, opBundleOperands,
3629+ opBundleOperandTypes,
3630+ getOpBundleSizesAttrName (result.name )))
3631+ return failure ();
3632+
3633+ int32_t numOpBundleOperands = 0 ;
3634+ for (const auto &operands : opBundleOperands)
3635+ numOpBundleOperands += operands.size ();
3636+
3637+ result.addAttribute (
3638+ CallIntrinsicOp::getOperandSegmentSizeAttr (),
3639+ parser.getBuilder ().getDenseI32ArrayAttr (
3640+ {static_cast <int32_t >(operands.size ()), numOpBundleOperands}));
3641+
3642+ return mlir::success ();
3643+ }
3644+
3645+ void CallIntrinsicOp::print (OpAsmPrinter &p) {
3646+ p << ' ' ;
3647+ p.printAttributeWithoutType (getIntrinAttr ());
3648+
3649+ OperandRange args = getArgs ();
3650+ p << " (" << args << " )" ;
3651+
3652+ // Operand bundles.
3653+ if (!getOpBundleOperands ().empty ()) {
3654+ p << ' ' ;
3655+ printOpBundles (p, *this , getOpBundleOperands (),
3656+ getOpBundleOperands ().getTypes (), getOpBundleTagsAttr ());
3657+ }
3658+
3659+ p.printOptionalAttrDict (processFMFAttr ((*this )->getAttrs ()),
3660+ {getOperandSegmentSizesAttrName (),
3661+ getOpBundleSizesAttrName (), getIntrinAttrName (),
3662+ getOpBundleTagsAttrName (), getArgAttrsAttrName (),
3663+ getResAttrsAttrName ()});
3664+
3665+ p << " : " ;
3666+
3667+ // Reconstruct the MLIR function type from operand and result types.
3668+ call_interface_impl::printFunctionSignature (
3669+ p, args.getTypes (), getArgAttrsAttr (),
3670+ /* isVariadic=*/ false , getResultTypes (), getResAttrsAttr ());
35743671}
35753672
35763673// ===----------------------------------------------------------------------===//
0 commit comments