MLIR  21.0.0git
Functions
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. More...
 
ParseResult parseFunctionResultList (OpAsmParser &parser, SmallVectorImpl< Type > &resultTypes, SmallVectorImpl< DictionaryAttr > &resultAttrs)
 Parse a function or call result list. More...
 
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. More...
 
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. More...
 
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. More...
 
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(), and mlir::Builder::getDictionaryAttr().

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().

◆ 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(), and parseTypeAndAttrList().

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(), and parseTypeAndAttrList().

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::printFunctionOp(), and 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::SymbolTableCollection::lookupNearestSymbolFrom().