MLIR 24.0.0git
mlir::call_interface_impl Namespace Reference

Functions

OperationresolveCallable (CallOpInterface call, SymbolTableCollection *symbolTable=nullptr)
 Resolve the callable operation for given callee to a CallableOpInterface, or nullptr if a valid callable was not resolved.
LogicalResult verifyCallOpInterface (CallOpInterface call, TypeRange argumentTypes, TypeRange resultTypes)
 Verify that the forwarded operands and results of call are in a 1:1 relationship with the given argument and result types of its callee: the numbers must match and corresponding types must be equal.
LogicalResult verifyCallOpInterface (CallOpInterface call, CallableOpInterface callable)
 Same as above, taking the argument and result types from callable.
LogicalResult verifyCallOpInterface (CallOpInterface call, SymbolTableCollection &symbolTable)
 Same as above, but resolve the callee of call first.
LogicalResult verifyCallOpInterface (CallOpInterface call)
ParseResult parseFunctionResultList (OpAsmParser &parser, SmallVectorImpl< Type > &resultTypes, SmallVectorImpl< DictionaryAttr > &resultAttrs)
 Parse a function or call result list.
ParseResult parseFunctionSignature (OpAsmParser &parser, SmallVectorImpl< Type > &argTypes, SmallVectorImpl< DictionaryAttr > &argAttrs, SmallVectorImpl< Type > &resultTypes, SmallVectorImpl< DictionaryAttr > &resultAttrs, bool mustParseEmptyResult=true)
 Parses a function signature using parser.
void printFunctionSignature (OpAsmPrinter &p, TypeRange argTypes, ArrayAttr argAttrs, bool isVariadic, TypeRange resultTypes, ArrayAttr resultAttrs, Region *body=nullptr, bool printEmptyResult=true)
 Print a function signature for a call or callable operation.
void addArgAndResultAttrs (Builder &builder, OperationState &result, ArrayRef< DictionaryAttr > argAttrs, ArrayRef< DictionaryAttr > resultAttrs, StringAttr argAttrsName, StringAttr resAttrsName)
 Adds argument and result attributes, provided as argAttrs and resultAttrs arguments, to the list of operation attributes in result.
void addArgAndResultAttrs (Builder &builder, OperationState &result, ArrayRef< OpAsmParser::Argument > args, ArrayRef< DictionaryAttr > resultAttrs, StringAttr argAttrsName, StringAttr resAttrsName)

Function Documentation

◆ addArgAndResultAttrs() [1/2]

void mlir::call_interface_impl::addArgAndResultAttrs ( Builder & builder,
OperationState & result,
ArrayRef< DictionaryAttr > argAttrs,
ArrayRef< DictionaryAttr > resultAttrs,
StringAttr argAttrsName,
StringAttr resAttrsName )

Adds argument and result attributes, provided as argAttrs and resultAttrs arguments, to the list of operation attributes in result.

Internally, argument and result attributes are stored as dict attributes with special names given by getResultAttrName, getArgumentAttrName.

Definition at line 146 of file CallInterfaces.cpp.

References mlir::Builder::getArrayAttr(), mlir::Builder::getDictionaryAttr(), and result.

Referenced by addArgAndResultAttrs(), and mlir::function_interface_impl::parseFunctionOp().

◆ addArgAndResultAttrs() [2/2]

void mlir::call_interface_impl::addArgAndResultAttrs ( Builder & builder,
OperationState & result,
ArrayRef< OpAsmParser::Argument > args,
ArrayRef< DictionaryAttr > resultAttrs,
StringAttr argAttrsName,
StringAttr resAttrsName )

Definition at line 171 of file CallInterfaces.cpp.

References addArgAndResultAttrs(), and result.

◆ parseFunctionResultList()

ParseResult mlir::call_interface_impl::parseFunctionResultList ( OpAsmParser & parser,
SmallVectorImpl< Type > & resultTypes,
SmallVectorImpl< DictionaryAttr > & resultAttrs )

Parse a function or call result list.

function-result-list ::= function-result-list-parens | non-function-type function-result-list-parens ::= ( ) | ( function-result-list-no-parens ) function-result-list-no-parens ::= function-result (, function-result)* function-result ::= type attribute-dict?

Definition at line 34 of file CallInterfaces.cpp.

References mlir::AsmParser::parseOptionalLParen(), mlir::AsmParser::parseOptionalRParen(), mlir::AsmParser::parseRParen(), mlir::AsmParser::parseType(), parseTypeAndAttrList(), and success().

Referenced by parseFunctionSignature(), and mlir::function_interface_impl::parseFunctionSignatureWithArguments().

◆ parseFunctionSignature()

ParseResult mlir::call_interface_impl::parseFunctionSignature ( OpAsmParser & parser,
SmallVectorImpl< Type > & argTypes,
SmallVectorImpl< DictionaryAttr > & argAttrs,
SmallVectorImpl< Type > & resultTypes,
SmallVectorImpl< DictionaryAttr > & resultAttrs,
bool mustParseEmptyResult = true )

Parses a function signature using parser.

This does not deal with function signatures containing SSA region arguments (to parse these signatures, use function_interface_impl::parseFunctionSignature). When mustParseEmptyResult, -> () is expected when there is no result type.

no-ssa-function-signature ::= ( no-ssa-function-arg-list ) -> function-result-list no-ssa-function-arg-list ::= no-ssa-function-arg (, no-ssa-function-arg)* no-ssa-function-arg ::= type attribute-dict?

Definition at line 56 of file CallInterfaces.cpp.

References parseFunctionResultList(), mlir::AsmParser::parseLParen(), mlir::AsmParser::parseOptionalArrow(), mlir::AsmParser::parseOptionalRParen(), mlir::AsmParser::parseRParen(), parseTypeAndAttrList(), and success().

Referenced by parseCallTypeAndResolveOperands().

◆ printFunctionSignature()

void mlir::call_interface_impl::printFunctionSignature ( OpAsmPrinter & p,
TypeRange argTypes,
ArrayAttr argAttrs,
bool isVariadic,
TypeRange resultTypes,
ArrayAttr resultAttrs,
Region * body = nullptr,
bool printEmptyResult = true )

Print a function signature for a call or callable operation.

If a body region is provided, the SSA arguments are printed in the signature. When printEmptyResult is false, -> function-result-list is omitted when resultTypes is empty.

function-signature ::= ssa-function-signature | no-ssa-function-signature ssa-function-signature ::= ( ssa-function-arg-list ) -> function-result-list ssa-function-arg-list ::= ssa-function-arg (, ssa-function-arg)* ssa-function-arg ::= %name : type attribute-dict?

Definition at line 101 of file CallInterfaces.cpp.

References mlir::Region::empty(), mlir::Region::getArgument(), mlir::OpAsmPrinter::printFunctionalType(), printFunctionResultList(), mlir::OpAsmPrinter::printOptionalAttrDict(), mlir::OpAsmPrinter::printRegionArgument(), and mlir::AsmPrinter::printType().

Referenced by mlir::function_interface_impl::printFunctionSignature().

◆ resolveCallable()

Operation * mlir::call_interface_impl::resolveCallable ( CallOpInterface call,
SymbolTableCollection * symbolTable = nullptr )

Resolve the callable operation for given callee to a CallableOpInterface, or nullptr if a valid callable was not resolved.

symbolTable is an optional parameter that will allow for using a cached symbol table for symbol lookups instead of performing an O(N) scan.

Definition at line 187 of file CallInterfaces.cpp.

References mlir::SymbolTable::lookupNearestSymbolFrom(), and mlir::SymbolTableCollection::lookupNearestSymbolFrom().

◆ verifyCallOpInterface() [1/4]

LogicalResult mlir::call_interface_impl::verifyCallOpInterface ( CallOpInterface call)

Definition at line 264 of file CallInterfaces.cpp.

References verifyResolvedCallee().

◆ verifyCallOpInterface() [2/4]

LogicalResult mlir::call_interface_impl::verifyCallOpInterface ( CallOpInterface call,
CallableOpInterface callable )

Same as above, taking the argument and result types from callable.

Definition at line 242 of file CallInterfaces.cpp.

References verifyCallOpInterface().

◆ verifyCallOpInterface() [3/4]

LogicalResult mlir::call_interface_impl::verifyCallOpInterface ( CallOpInterface call,
SymbolTableCollection & symbolTable )

Same as above, but resolve the callee of call first.

Returns success if the callee cannot be resolved or does not implement CallableOpInterface.

Definition at line 259 of file CallInterfaces.cpp.

References verifyResolvedCallee().

◆ verifyCallOpInterface() [4/4]

LogicalResult mlir::call_interface_impl::verifyCallOpInterface ( CallOpInterface call,
TypeRange argumentTypes,
TypeRange resultTypes )

Verify that the forwarded operands and results of call are in a 1:1 relationship with the given argument and result types of its callee: the numbers must match and corresponding types must be equal.

This overload is for call operations whose callee does not necessarily implement CallableOpInterface, e.g., llvm.call, which can also call an llvm.mlir.alias or an llvm.mlir.ifunc.

Definition at line 204 of file CallInterfaces.cpp.

References diag(), mlir::Operation::emitOpError(), mlir::getType(), mlir::OperandRange::getType(), mlir::ResultRange::getTypes(), and success().

Referenced by verifyCallOpInterface(), and verifyResolvedCallee().