@@ -1033,6 +1033,7 @@ void CallOp::build(OpBuilder &builder, OperationState &state, TypeRange results,
10331033 /* memory_effects=*/ nullptr ,
10341034 /* convergent=*/ nullptr , /* no_unwind=*/ nullptr , /* will_return=*/ nullptr ,
10351035 /* op_bundle_operands=*/ {}, /* op_bundle_tags=*/ {},
1036+ /* arg_attrs=*/ nullptr , /* res_attrs=*/ nullptr ,
10361037 /* access_groups=*/ nullptr , /* alias_scopes=*/ nullptr ,
10371038 /* noalias_scopes=*/ nullptr , /* tbaa=*/ nullptr );
10381039}
@@ -1060,6 +1061,7 @@ void CallOp::build(OpBuilder &builder, OperationState &state,
10601061 /* convergent=*/ nullptr ,
10611062 /* no_unwind=*/ nullptr , /* will_return=*/ nullptr ,
10621063 /* op_bundle_operands=*/ {}, /* op_bundle_tags=*/ {},
1064+ /* arg_attrs=*/ nullptr , /* res_attrs=*/ nullptr ,
10631065 /* access_groups=*/ nullptr ,
10641066 /* alias_scopes=*/ nullptr , /* noalias_scopes=*/ nullptr , /* tbaa=*/ nullptr );
10651067}
@@ -1073,6 +1075,7 @@ void CallOp::build(OpBuilder &builder, OperationState &state,
10731075 /* CConv=*/ nullptr , /* TailCallKind=*/ nullptr , /* memory_effects=*/ nullptr ,
10741076 /* convergent=*/ nullptr , /* no_unwind=*/ nullptr , /* will_return=*/ nullptr ,
10751077 /* op_bundle_operands=*/ {}, /* op_bundle_tags=*/ {},
1078+ /* arg_attrs=*/ nullptr , /* res_attrs=*/ nullptr ,
10761079 /* access_groups=*/ nullptr , /* alias_scopes=*/ nullptr ,
10771080 /* noalias_scopes=*/ nullptr , /* tbaa=*/ nullptr );
10781081}
@@ -1087,6 +1090,7 @@ void CallOp::build(OpBuilder &builder, OperationState &state, LLVMFuncOp func,
10871090 /* convergent=*/ nullptr , /* no_unwind=*/ nullptr , /* will_return=*/ nullptr ,
10881091 /* op_bundle_operands=*/ {}, /* op_bundle_tags=*/ {},
10891092 /* access_groups=*/ nullptr , /* alias_scopes=*/ nullptr ,
1093+ /* arg_attrs=*/ nullptr , /* res_attrs=*/ nullptr ,
10901094 /* noalias_scopes=*/ nullptr , /* tbaa=*/ nullptr );
10911095}
10921096
@@ -1331,55 +1335,65 @@ void CallOp::print(OpAsmPrinter &p) {
13311335 getVarCalleeTypeAttrName (), getCConvAttrName (),
13321336 getOperandSegmentSizesAttrName (),
13331337 getOpBundleSizesAttrName (),
1334- getOpBundleTagsAttrName ()});
1338+ getOpBundleTagsAttrName (), getArgAttrsAttrName (),
1339+ getResAttrsAttrName ()});
13351340
13361341 p << " : " ;
13371342 if (!isDirect)
13381343 p << getOperand (0 ).getType () << " , " ;
13391344
13401345 // Reconstruct the function MLIR function type from operand and result types.
1341- p.printFunctionalType (args.getTypes (), getResultTypes ());
1346+ call_interface_impl::printFunctionSignature (
1347+ p, *this , args.getTypes (), /* isVariadic=*/ false , getResultTypes ());
13421348}
13431349
13441350// / Parses the type of a call operation and resolves the operands if the parsing
13451351// / succeeds. Returns failure otherwise.
13461352static ParseResult parseCallTypeAndResolveOperands (
13471353 OpAsmParser &parser, OperationState &result, bool isDirect,
1348- ArrayRef<OpAsmParser::UnresolvedOperand> operands) {
1354+ ArrayRef<OpAsmParser::UnresolvedOperand> operands,
1355+ SmallVectorImpl<DictionaryAttr> &argAttrs,
1356+ SmallVectorImpl<DictionaryAttr> &resultAttrs) {
13491357 SMLoc trailingTypesLoc = parser.getCurrentLocation ();
13501358 SmallVector<Type> types;
1351- if (parser.parseColonTypeList (types ))
1359+ if (parser.parseColon ( ))
13521360 return failure ();
1353-
1354- if (isDirect && types.size () != 1 )
1355- return parser.emitError (trailingTypesLoc,
1356- " expected direct call to have 1 trailing type" );
1357- if (!isDirect && types.size () != 2 )
1358- return parser.emitError (trailingTypesLoc,
1359- " expected indirect call to have 2 trailing types" );
1360-
1361- auto funcType = llvm::dyn_cast<FunctionType>(types.pop_back_val ());
1362- if (!funcType)
1361+ if (!isDirect) {
1362+ types.emplace_back ();
1363+ if (parser.parseType (types.back ()))
1364+ return failure ();
1365+ if (parser.parseOptionalComma ())
1366+ return parser.emitError (
1367+ trailingTypesLoc, " expected indirect call to have 2 trailing types" );
1368+ }
1369+ SmallVector<Type> argTypes;
1370+ SmallVector<Type> resTypes;
1371+ if (call_interface_impl::parseFunctionSignature (parser, argTypes, argAttrs,
1372+ resTypes, resultAttrs)) {
1373+ if (isDirect)
1374+ return parser.emitError (trailingTypesLoc,
1375+ " expected direct call to have 1 trailing types" );
13631376 return parser.emitError (trailingTypesLoc,
13641377 " expected trailing function type" );
1365- if (funcType.getNumResults () > 1 )
1378+ }
1379+
1380+ if (resTypes.size () > 1 )
13661381 return parser.emitError (trailingTypesLoc,
13671382 " expected function with 0 or 1 result" );
1368- if (funcType.getNumResults () == 1 &&
1369- llvm::isa<LLVM::LLVMVoidType>(funcType.getResult (0 )))
1383+ if (resTypes.size () == 1 && llvm::isa<LLVM::LLVMVoidType>(resTypes[0 ]))
13701384 return parser.emitError (trailingTypesLoc,
13711385 " expected a non-void result type" );
13721386
13731387 // The head element of the types list matches the callee type for
13741388 // indirect calls, while the types list is emtpy for direct calls.
13751389 // Append the function input types to resolve the call operation
13761390 // operands.
1377- llvm::append_range (types, funcType. getInputs () );
1391+ llvm::append_range (types, argTypes );
13781392 if (parser.resolveOperands (operands, types, parser.getNameLoc (),
13791393 result.operands ))
13801394 return failure ();
1381- if (funcType. getNumResults () != 0 )
1382- result.addTypes (funcType. getResults () );
1395+ if (resTypes. size () != 0 )
1396+ result.addTypes (resTypes );
13831397
13841398 return success ();
13851399}
@@ -1493,8 +1507,14 @@ ParseResult CallOp::parse(OpAsmParser &parser, OperationState &result) {
14931507 return failure ();
14941508
14951509 // Parse the trailing type list and resolve the operands.
1496- if (parseCallTypeAndResolveOperands (parser, result, isDirect, operands))
1510+ SmallVector<DictionaryAttr> argAttrs;
1511+ SmallVector<DictionaryAttr> resultAttrs;
1512+ if (parseCallTypeAndResolveOperands (parser, result, isDirect, operands,
1513+ argAttrs, resultAttrs))
14971514 return failure ();
1515+ call_interface_impl::addArgAndResultAttrs (
1516+ parser.getBuilder (), result, argAttrs, resultAttrs,
1517+ getArgAttrsAttrName (result.name ), getResAttrsAttrName (result.name ));
14981518 if (resolveOpBundleOperands (parser, opBundlesLoc, result, opBundleOperands,
14991519 opBundleOperandTypes,
15001520 getOpBundleSizesAttrName (result.name )))
@@ -1714,7 +1734,10 @@ ParseResult InvokeOp::parse(OpAsmParser &parser, OperationState &result) {
17141734 return failure ();
17151735
17161736 // Parse the trailing type list and resolve the function operands.
1717- if (parseCallTypeAndResolveOperands (parser, result, isDirect, operands))
1737+ SmallVector<DictionaryAttr> argAttrs;
1738+ SmallVector<DictionaryAttr> resultAttrs;
1739+ if (parseCallTypeAndResolveOperands (parser, result, isDirect, operands,
1740+ argAttrs, resultAttrs))
17181741 return failure ();
17191742 if (resolveOpBundleOperands (parser, opBundlesLoc, result, opBundleOperands,
17201743 opBundleOperandTypes,
0 commit comments