MLIR
15.0.0git
|
Namespaces | |
detail | |
Classes | |
class | VariadicFlag |
A named class for passing around the variadic flag. More... | |
Typedefs | |
using | FuncTypeBuilder = function_ref< Type(Builder &, ArrayRef< Type >, ArrayRef< Type >, VariadicFlag, std::string &)> |
Callback type for parseFunctionOp , the callback should produce the type that will be associated with a function-like operation from lists of function arguments and results, VariadicFlag indicates whether the function should have variadic arguments; in case of error, it may populate the last argument with a message. More... | |
Functions | |
void | addArgAndResultAttrs (Builder &builder, OperationState &result, ArrayRef< DictionaryAttr > argAttrs, ArrayRef< DictionaryAttr > resultAttrs) |
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 > argAttrs, ArrayRef< DictionaryAttr > resultAttrs) |
ParseResult | parseFunctionSignature (OpAsmParser &parser, bool allowVariadic, SmallVectorImpl< OpAsmParser::Argument > &arguments, bool &isVariadic, SmallVectorImpl< Type > &resultTypes, SmallVectorImpl< DictionaryAttr > &resultAttrs) |
Parses a function signature using parser . More... | |
Type | getFunctionType (Builder &builder, ArrayRef< OpAsmParser::Argument > argAttrs, ArrayRef< Type > resultTypes) |
Get a function type corresponding to an array of arguments (which have types) and a set of result types. More... | |
ParseResult | parseFunctionOp (OpAsmParser &parser, OperationState &result, bool allowVariadic, FuncTypeBuilder funcTypeBuilder) |
Parser implementation for function-like operations. More... | |
void | printFunctionOp (OpAsmPrinter &p, FunctionOpInterface op, bool isVariadic) |
Printer implementation for function-like operations. More... | |
void | printFunctionSignature (OpAsmPrinter &p, Operation *op, ArrayRef< Type > argTypes, bool isVariadic, ArrayRef< Type > resultTypes) |
Prints the signature of the function-like operation op . More... | |
void | printFunctionAttributes (OpAsmPrinter &p, Operation *op, unsigned numInputs, unsigned numResults, ArrayRef< StringRef > elided={}) |
Prints the list of function prefixed with the "attributes" keyword. More... | |
StringRef | getTypeAttrName () |
Return the name of the attribute used for function types. More... | |
StringRef | getArgDictAttrName () |
Return the name of the attribute used for function argument attributes. More... | |
StringRef | getResultDictAttrName () |
Return the name of the attribute used for function argument attributes. More... | |
DictionaryAttr | getArgAttrDict (Operation *op, unsigned index) |
Returns the dictionary attribute corresponding to the argument at 'index'. More... | |
DictionaryAttr | getResultAttrDict (Operation *op, unsigned index) |
Returns the dictionary attribute corresponding to the result at 'index'. More... | |
void | setAllArgAttrDicts (Operation *op, ArrayRef< DictionaryAttr > attrs) |
Set all of the argument or result attribute dictionaries for a function. More... | |
void | setAllArgAttrDicts (Operation *op, ArrayRef< Attribute > attrs) |
void | setAllResultAttrDicts (Operation *op, ArrayRef< DictionaryAttr > attrs) |
void | setAllResultAttrDicts (Operation *op, ArrayRef< Attribute > attrs) |
ArrayRef< NamedAttribute > | getArgAttrs (Operation *op, unsigned index) |
Return all of the attributes for the argument at 'index'. More... | |
ArrayRef< NamedAttribute > | getResultAttrs (Operation *op, unsigned index) |
Return all of the attributes for the result at 'index'. More... | |
void | insertFunctionArguments (Operation *op, ArrayRef< unsigned > argIndices, TypeRange argTypes, ArrayRef< DictionaryAttr > argAttrs, ArrayRef< Location > argLocs, unsigned originalNumArgs, Type newType) |
Insert the specified arguments and update the function type attribute. More... | |
void | insertFunctionResults (Operation *op, ArrayRef< unsigned > resultIndices, TypeRange resultTypes, ArrayRef< DictionaryAttr > resultAttrs, unsigned originalNumResults, Type newType) |
Insert the specified results and update the function type attribute. More... | |
void | eraseFunctionArguments (Operation *op, const BitVector &argIndices, Type newType) |
Erase the specified arguments and update the function type attribute. More... | |
void | eraseFunctionResults (Operation *op, const BitVector &resultIndices, Type newType) |
Erase the specified results and update the function type attribute. More... | |
void | setFunctionType (Operation *op, Type newType) |
Set a FunctionOpInterface operation's type signature. More... | |
TypeRange | insertTypesInto (TypeRange oldTypes, ArrayRef< unsigned > indices, TypeRange newTypes, SmallVectorImpl< Type > &storage) |
Insert a set of newTypes into oldTypes at the given indices . More... | |
TypeRange | filterTypesOut (TypeRange types, const BitVector &indices, SmallVectorImpl< Type > &storage) |
Filters out any elements referenced by indices . More... | |
template<typename ConcreteType > | |
void | setArgAttrs (ConcreteType op, unsigned index, ArrayRef< NamedAttribute > attributes) |
Set the attributes held by the argument at 'index'. More... | |
template<typename ConcreteType > | |
void | setArgAttrs (ConcreteType op, unsigned index, DictionaryAttr attributes) |
template<typename ConcreteType > | |
void | setArgAttr (ConcreteType op, unsigned index, StringAttr name, Attribute value) |
If the an attribute exists with the specified name, change it to the new value. More... | |
template<typename ConcreteType > | |
Attribute | removeArgAttr (ConcreteType op, unsigned index, StringAttr name) |
Remove the attribute 'name' from the argument at 'index'. More... | |
template<typename ConcreteType > | |
void | setResultAttrs (ConcreteType op, unsigned index, ArrayRef< NamedAttribute > attributes) |
Set the attributes held by the result at 'index'. More... | |
template<typename ConcreteType > | |
void | setResultAttrs (ConcreteType op, unsigned index, DictionaryAttr attributes) |
template<typename ConcreteType > | |
void | setResultAttr (ConcreteType op, unsigned index, StringAttr name, Attribute value) |
If the an attribute exists with the specified name, change it to the new value. More... | |
template<typename ConcreteType > | |
Attribute | removeResultAttr (ConcreteType op, unsigned index, StringAttr name) |
Remove the attribute 'name' from the result at 'index'. More... | |
template<typename ConcreteOp > | |
LogicalResult | verifyTrait (ConcreteOp op) |
This function defines the internal implementation of the verifyTrait method on FunctionOpInterface::Trait. More... | |
using mlir::function_interface_impl::FuncTypeBuilder = typedef function_ref<Type( Builder &, ArrayRef<Type>, ArrayRef<Type>, VariadicFlag, std::string &)> |
Callback type for parseFunctionOp
, the callback should produce the type that will be associated with a function-like operation from lists of function arguments and results, VariadicFlag indicates whether the function should have variadic arguments; in case of error, it may populate the last argument with a message.
Definition at line 53 of file FunctionImplementation.h.
void mlir::function_interface_impl::addArgAndResultAttrs | ( | Builder & | builder, |
OperationState & | result, | ||
ArrayRef< DictionaryAttr > | argAttrs, | ||
ArrayRef< DictionaryAttr > | resultAttrs | ||
) |
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 128 of file FunctionImplementation.cpp.
References mlir::OperationState::addAttribute(), getArgDictAttrName(), mlir::Builder::getArrayAttr(), mlir::Builder::getDictionaryAttr(), and getResultDictAttrName().
Referenced by addArgAndResultAttrs(), buildLLVMFunctionType(), mlir::function_interface_impl::VariadicFlag::isVariadic(), isZeroAttribute(), parseAttributions(), parseFunctionOp(), and verifyConstantType().
void mlir::function_interface_impl::addArgAndResultAttrs | ( | Builder & | builder, |
OperationState & | result, | ||
ArrayRef< OpAsmParser::Argument > | argAttrs, | ||
ArrayRef< DictionaryAttr > | resultAttrs | ||
) |
Definition at line 154 of file FunctionImplementation.cpp.
References addArgAndResultAttrs().
void mlir::function_interface_impl::eraseFunctionArguments | ( | Operation * | op, |
const BitVector & | argIndices, | ||
Type | newType | ||
) |
Erase the specified arguments and update the function type attribute.
Definition at line 202 of file FunctionInterfaces.cpp.
References mlir::Block::eraseArguments(), mlir::Region::front(), getArgDictAttrName(), mlir::Operation::getAttrOfType(), mlir::Operation::getRegion(), getTypeAttrName(), setAllArgAttrDicts(), and mlir::Operation::setAttr().
Referenced by getResultAttrs().
void mlir::function_interface_impl::eraseFunctionResults | ( | Operation * | op, |
const BitVector & | resultIndices, | ||
Type | newType | ||
) |
Erase the specified results and update the function type attribute.
Definition at line 225 of file FunctionInterfaces.cpp.
References mlir::Operation::getAttrOfType(), getResultDictAttrName(), getTypeAttrName(), setAllResultAttrDicts(), and mlir::Operation::setAttr().
Referenced by getResultAttrs().
TypeRange mlir::function_interface_impl::filterTypesOut | ( | TypeRange | types, |
const BitVector & | indices, | ||
SmallVectorImpl< Type > & | storage | ||
) |
Filters out any elements referenced by indices
.
If any types are removed, storage
is used to hold the new type list. Returns the new type list.
Definition at line 265 of file FunctionInterfaces.cpp.
Referenced by mlir::FloatType::getFPMantissaWidth(), and getResultAttrs().
Returns the dictionary attribute corresponding to the argument at 'index'.
If there are no argument attributes at 'index', a null attribute is returned.
Definition at line 27 of file FunctionInterfaces.cpp.
References getArgDictAttrName(), and mlir::Operation::getAttrOfType().
Referenced by getArgAttrs(), and getResultDictAttrName().
|
inline |
Return all of the attributes for the argument at 'index'.
Definition at line 63 of file FunctionInterfaces.h.
References getArgAttrDict().
|
inline |
Return the name of the attribute used for function argument attributes.
Definition at line 32 of file FunctionInterfaces.h.
Referenced by addArgAndResultAttrs(), eraseFunctionArguments(), filterFuncAttributes(), getArgAttrDict(), insertFunctionArguments(), prependResAttrsToArgAttrs(), printFunctionAttributes(), printFunctionSignature(), setAllArgAttrDicts(), setArgAttrs(), setFunctionType(), verifyTrait(), and wrapExternalFunction().
Type mlir::function_interface_impl::getFunctionType | ( | Builder & | builder, |
ArrayRef< OpAsmParser::Argument > | argAttrs, | ||
ArrayRef< Type > | resultTypes | ||
) |
Get a function type corresponding to an array of arguments (which have types) and a set of result types.
Referenced by buildLLVMFunctionType(), forwardPassthroughAttributes(), isZeroAttribute(), printAttributions(), printLaunchFuncOperands(), verifyAttributions(), and verifyConstantType().
Returns the dictionary attribute corresponding to the result at 'index'.
If there are no result attributes at 'index', a null attribute is returned.
Definition at line 36 of file FunctionInterfaces.cpp.
References mlir::Operation::getAttrOfType(), and getResultDictAttrName().
Referenced by getResultAttrs(), and getResultDictAttrName().
|
inline |
Return all of the attributes for the result at 'index'.
Definition at line 69 of file FunctionInterfaces.h.
References eraseFunctionArguments(), eraseFunctionResults(), filterTypesOut(), getResultAttrDict(), insertFunctionArguments(), insertFunctionResults(), insertTypesInto(), and setFunctionType().
Referenced by buildLLVMFunctionType().
|
inline |
Return the name of the attribute used for function argument attributes.
Definition at line 35 of file FunctionInterfaces.h.
References getArgAttrDict(), and getResultAttrDict().
Referenced by addArgAndResultAttrs(), eraseFunctionResults(), filterFuncAttributes(), getResultAttrDict(), insertFunctionResults(), prependResAttrsToArgAttrs(), printFunctionAttributes(), printFunctionSignature(), setAllResultAttrDicts(), setFunctionType(), setResultAttrs(), verifyTrait(), and wrapExternalFunction().
|
inline |
Return the name of the attribute used for function types.
Definition at line 29 of file FunctionInterfaces.h.
Referenced by buildLLVMFunctionType(), eraseFunctionArguments(), eraseFunctionResults(), filterFuncAttributes(), insertFunctionArguments(), insertFunctionResults(), lowerAsEntryFunction(), mlir::GPUFuncOpLowering::matchAndRewrite(), parseAttributions(), parseFunctionOp(), printAttributions(), printFunctionAttributes(), printLaunchFuncOperands(), setFunctionType(), mlir::SPIRVTypeConverter::SPIRVTypeConverter(), verifyConstantType(), and verifyTrait().
void mlir::function_interface_impl::insertFunctionArguments | ( | Operation * | op, |
ArrayRef< unsigned > | argIndices, | ||
TypeRange | argTypes, | ||
ArrayRef< DictionaryAttr > | argAttrs, | ||
ArrayRef< Location > | argLocs, | ||
unsigned | originalNumArgs, | ||
Type | newType | ||
) |
Insert the specified arguments and update the function type attribute.
Definition at line 114 of file FunctionInterfaces.cpp.
References mlir::Region::front(), getArgDictAttrName(), mlir::Operation::getAttrOfType(), mlir::Operation::getRegion(), getTypeAttrName(), mlir::Block::insertArgument(), setAllArgAttrDicts(), and mlir::Operation::setAttr().
Referenced by getResultAttrs().
void mlir::function_interface_impl::insertFunctionResults | ( | Operation * | op, |
ArrayRef< unsigned > | resultIndices, | ||
TypeRange | resultTypes, | ||
ArrayRef< DictionaryAttr > | resultAttrs, | ||
unsigned | originalNumResults, | ||
Type | newType | ||
) |
Insert the specified results and update the function type attribute.
Definition at line 160 of file FunctionInterfaces.cpp.
References mlir::Operation::getAttrOfType(), getResultDictAttrName(), getTypeAttrName(), setAllResultAttrDicts(), and mlir::Operation::setAttr().
Referenced by getResultAttrs().
TypeRange mlir::function_interface_impl::insertTypesInto | ( | TypeRange | oldTypes, |
ArrayRef< unsigned > | indices, | ||
TypeRange | newTypes, | ||
SmallVectorImpl< Type > & | storage | ||
) |
Insert a set of newTypes
into oldTypes
at the given indices
.
If any types are inserted, storage
is used to hold the new type list. The new type list is returned. indices
must be sorted by increasing index.
Definition at line 245 of file FunctionInterfaces.cpp.
Referenced by mlir::FloatType::getFPMantissaWidth(), and getResultAttrs().
ParseResult mlir::function_interface_impl::parseFunctionOp | ( | OpAsmParser & | parser, |
OperationState & | result, | ||
bool | allowVariadic, | ||
FuncTypeBuilder | funcTypeBuilder | ||
) |
Parser implementation for function-like operations.
Uses funcTypeBuilder
to construct the custom function type given lists of input and output types. If allowVariadic
is set, the parser will accept trailing ellipsis in the function signature and indicate to the builder whether the function is variadic. If the builder returns a null type, result
will not contain the type
attribute. The caller can then add a type, report the error or delegate the reporting to the op's verifier.
Definition at line 164 of file FunctionImplementation.cpp.
References addArgAndResultAttrs(), mlir::OperationState::addAttribute(), mlir::OperationState::addRegion(), mlir::NamedAttrList::append(), mlir::OperationState::attributes, mlir::AsmParser::emitError(), mlir::failed(), mlir::failure(), mlir::NamedAttrList::get(), mlir::AsmParser::getBuilder(), mlir::AsmParser::getCurrentLocation(), mlir::SymbolTable::getSymbolAttrName(), getTypeAttrName(), mlir::SymbolTable::getVisibilityAttrName(), mlir::OptionalParseResult::hasValue(), parseFunctionSignature(), mlir::AsmParser::parseOptionalAttrDictWithKeyword(), mlir::OpAsmParser::parseOptionalRegion(), mlir::impl::parseOptionalVisibilityKeyword(), mlir::AsmParser::parseSymbolName(), and mlir::success().
Referenced by printCreateOperationOpResults().
ParseResult mlir::function_interface_impl::parseFunctionSignature | ( | OpAsmParser & | parser, |
bool | allowVariadic, | ||
SmallVectorImpl< OpAsmParser::Argument > & | arguments, | ||
bool & | isVariadic, | ||
SmallVectorImpl< Type > & | resultTypes, | ||
SmallVectorImpl< DictionaryAttr > & | resultAttrs | ||
) |
Parses a function signature using parser
.
The allowVariadic
argument indicates whether functions with variadic arguments are supported. The trailing arguments are populated by this function with names, types, attributes and locations of the arguments and those of the results.
Definition at line 116 of file FunctionImplementation.cpp.
References mlir::failure(), parseFunctionArgumentList(), parseFunctionResultList(), mlir::AsmParser::parseOptionalArrow(), mlir::succeeded(), and mlir::success().
Referenced by buildLLVMFunctionType(), parseAttributions(), parseFunctionOp(), and verifyConstantType().
void mlir::function_interface_impl::printFunctionAttributes | ( | OpAsmPrinter & | p, |
Operation * | op, | ||
unsigned | numInputs, | ||
unsigned | numResults, | ||
ArrayRef< StringRef > | elided = {} |
||
) |
Prints the list of function prefixed with the "attributes" keyword.
The attributes with names listed in "elided" as well as those used by the function-like operation internally are not printed. Nothing is printed if all attributes are elided. Assumes op
is a FunctionOpInterface and has passed verification.
Definition at line 303 of file FunctionImplementation.cpp.
References getArgDictAttrName(), mlir::Operation::getAttrs(), getResultDictAttrName(), mlir::SymbolTable::getSymbolAttrName(), getTypeAttrName(), and mlir::OpAsmPrinter::printOptionalAttrDictWithKeyword().
Referenced by buildLLVMFunctionType(), printAttributions(), printFunctionOp(), and verifyConstantType().
void mlir::function_interface_impl::printFunctionOp | ( | OpAsmPrinter & | p, |
FunctionOpInterface | op, | ||
bool | isVariadic | ||
) |
Printer implementation for function-like operations.
Definition at line 315 of file FunctionImplementation.cpp.
References mlir::SymbolTable::getSymbolAttrName(), mlir::SymbolTable::getVisibilityAttrName(), printFunctionAttributes(), printFunctionSignature(), mlir::OpAsmPrinter::printRegion(), and mlir::AsmPrinter::printSymbolName().
Referenced by printCreateOperationOpResults().
void mlir::function_interface_impl::printFunctionSignature | ( | OpAsmPrinter & | p, |
Operation * | op, | ||
ArrayRef< Type > | argTypes, | ||
bool | isVariadic, | ||
ArrayRef< Type > | resultTypes | ||
) |
Prints the signature of the function-like operation op
.
Assumes op
has is a FunctionOpInterface and has passed verification.
Definition at line 264 of file FunctionImplementation.cpp.
References mlir::Region::empty(), getArgDictAttrName(), mlir::Region::getArgument(), mlir::Operation::getAttrOfType(), mlir::Operation::getRegion(), getResultDictAttrName(), mlir::AsmPrinter::getStream(), printFunctionResultList(), mlir::OpAsmPrinter::printOptionalAttrDict(), mlir::OpAsmPrinter::printRegionArgument(), and mlir::AsmPrinter::printType().
Referenced by buildLLVMFunctionType(), printAttributions(), printFunctionOp(), and verifyConstantType().
Attribute mlir::function_interface_impl::removeArgAttr | ( | ConcreteType | op, |
unsigned | index, | ||
StringAttr | name | ||
) |
Remove the attribute 'name' from the argument at 'index'.
Returns the removed attribute, or nullptr if name
was not a valid attribute.
Definition at line 145 of file FunctionInterfaces.h.
Attribute mlir::function_interface_impl::removeResultAttr | ( | ConcreteType | op, |
unsigned | index, | ||
StringAttr | name | ||
) |
Remove the attribute 'name' from the result at 'index'.
Definition at line 194 of file FunctionInterfaces.h.
void mlir::function_interface_impl::setAllArgAttrDicts | ( | Operation * | op, |
ArrayRef< DictionaryAttr > | attrs | ||
) |
Set all of the argument or result attribute dictionaries for a function.
The size of attrs
is expected to match the number of arguments/results of the given op
.
Definition at line 88 of file FunctionInterfaces.cpp.
Referenced by eraseFunctionArguments(), insertFunctionArguments(), and setFunctionType().
void mlir::function_interface_impl::setAllArgAttrDicts | ( | Operation * | op, |
ArrayRef< Attribute > | attrs | ||
) |
Definition at line 92 of file FunctionInterfaces.cpp.
References getArgDictAttrName(), mlir::Operation::getContext(), and setAllArgResAttrDicts().
void mlir::function_interface_impl::setAllResultAttrDicts | ( | Operation * | op, |
ArrayRef< DictionaryAttr > | attrs | ||
) |
Definition at line 101 of file FunctionInterfaces.cpp.
Referenced by eraseFunctionResults(), insertFunctionResults(), and setFunctionType().
void mlir::function_interface_impl::setAllResultAttrDicts | ( | Operation * | op, |
ArrayRef< Attribute > | attrs | ||
) |
Definition at line 105 of file FunctionInterfaces.cpp.
References mlir::Operation::getContext(), getResultDictAttrName(), and setAllArgResAttrDicts().
void mlir::function_interface_impl::setArgAttr | ( | ConcreteType | op, |
unsigned | index, | ||
StringAttr | name, | ||
Attribute | value | ||
) |
If the an attribute exists with the specified name, change it to the new value.
Otherwise, add a new attribute with the specified name/value.
Definition at line 132 of file FunctionInterfaces.h.
References mlir::Attribute::getContext().
void mlir::function_interface_impl::setArgAttrs | ( | ConcreteType | op, |
unsigned | index, | ||
ArrayRef< NamedAttribute > | attributes | ||
) |
Set the attributes held by the argument at 'index'.
Definition at line 115 of file FunctionInterfaces.h.
References getArgDictAttrName(), and mlir::function_interface_impl::detail::setArgResAttrDict().
void mlir::function_interface_impl::setArgAttrs | ( | ConcreteType | op, |
unsigned | index, | ||
DictionaryAttr | attributes | ||
) |
Definition at line 123 of file FunctionInterfaces.h.
References getArgDictAttrName(), and mlir::function_interface_impl::detail::setArgResAttrDict().
Set a FunctionOpInterface operation's type signature.
Definition at line 281 of file FunctionInterfaces.cpp.
References getArgDictAttrName(), mlir::Operation::getAttrOfType(), getResultDictAttrName(), getTypeAttrName(), mlir::Operation::removeAttr(), setAllArgAttrDicts(), setAllResultAttrDicts(), and mlir::Operation::setAttr().
Referenced by getResultAttrs().
void mlir::function_interface_impl::setResultAttr | ( | ConcreteType | op, |
unsigned | index, | ||
StringAttr | name, | ||
Attribute | value | ||
) |
If the an attribute exists with the specified name, change it to the new value.
Otherwise, add a new attribute with the specified name/value.
Definition at line 182 of file FunctionInterfaces.h.
References mlir::Attribute::getContext().
void mlir::function_interface_impl::setResultAttrs | ( | ConcreteType | op, |
unsigned | index, | ||
ArrayRef< NamedAttribute > | attributes | ||
) |
Set the attributes held by the result at 'index'.
Definition at line 162 of file FunctionInterfaces.h.
References getResultDictAttrName(), and mlir::function_interface_impl::detail::setArgResAttrDict().
void mlir::function_interface_impl::setResultAttrs | ( | ConcreteType | op, |
unsigned | index, | ||
DictionaryAttr | attributes | ||
) |
Definition at line 171 of file FunctionInterfaces.h.
References getResultDictAttrName(), and mlir::function_interface_impl::detail::setArgResAttrDict().
LogicalResult mlir::function_interface_impl::verifyTrait | ( | ConcreteOp | op | ) |
This function defines the internal implementation of the verifyTrait
method on FunctionOpInterface::Trait.
Definition at line 209 of file FunctionInterfaces.h.
References mlir::failed(), mlir::failure(), getArgDictAttrName(), getResultDictAttrName(), and getTypeAttrName().