14 #ifndef MLIR_IR_DIALECTIMPLEMENTATION_H
15 #define MLIR_IR_DIALECTIMPLEMENTATION_H
57 template <
typename T,
typename = T>
61 template <
typename AttributeT>
63 AttributeT, std::enable_if_t<std::is_base_of<Attribute, AttributeT>::value,
74 template <
typename TypeT>
76 TypeT, std::enable_if_t<std::is_base_of<Type, TypeT>::value, TypeT>> {
86 template <
typename IntT>
88 std::enable_if_t<std::is_integral<IntT>::value, IntT>> {
109 template <
typename AttributeT>
111 std::optional<AttributeT>,
112 std::enable_if_t<std::is_base_of<Attribute, AttributeT>::value,
113 std::optional<AttributeT>>> {
119 return {std::optional<AttributeT>(attr)};
122 return {std::nullopt};
127 template <
typename IntT>
130 std::enable_if_t<std::is_integral<IntT>::value, std::optional<IntT>>> {
136 return {std::optional<IntT>(value)};
139 return {std::nullopt};
144 template <
typename T>
146 std::declval<typename T::value_type &&>()));
150 template <
typename ContainerT>
152 std::enable_if_t<llvm::is_detected<detail::has_push_back_t,
158 auto elementParser = [&]() {
162 elements.push_back(std::move(*element));
A multi-dimensional affine map Affine map's are immutable like Type's, and they are uniqued.
This base class exposes generic asm parser hooks, usable across the various derived parsers.
virtual OptionalParseResult parseOptionalInteger(APInt &result)=0
Parse an optional integer value from the stream.
virtual ParseResult parseCommaSeparatedList(Delimiter delimiter, function_ref< ParseResult()> parseElementFn, StringRef contextMessage=StringRef())=0
Parse a list of comma-separated items with an optional delimiter.
ParseResult parseInteger(IntT &result)
Parse an integer value from the stream.
virtual ParseResult parseAffineMap(AffineMap &map)=0
Parse an affine map instance into 'map'.
virtual ParseResult parseCustomAttributeWithFallback(Attribute &result, Type type, function_ref< ParseResult(Attribute &result, Type type)> parseAttribute)=0
Parse a custom attribute with the provided callback, unless the next token is #, in which case the ge...
ParseResult parseString(std::string *string)
Parse a quoted string token.
virtual ParseResult parseCustomTypeWithFallback(Type &result, function_ref< ParseResult(Type &result)> parseType)=0
Parse a custom type with the provided callback, unless the next token is #, in which case the generic...
virtual OptionalParseResult parseOptionalAttribute(Attribute &result, Type type={})=0
Parse an arbitrary optional attribute of a given type and return it in result.
This base class exposes generic asm printer hooks, usable across the various derived printers.
AsmPrinter()=default
Initialize the printer with no internal implementation.
The DialectAsmParser has methods for interacting with the asm parser when parsing attributes and type...
virtual StringRef getFullSymbolSpec() const =0
Returns the full specification of the symbol being parsed.
~DialectAsmParser() override
This is a pure-virtual base class that exposes the asmprinter hooks necessary to implement a custom p...
~DialectAsmPrinter() override
This class provides support for representing a failure result, or a valid value of type T.
This class implements Optional functionality for ParseResult.
bool has_value() const
Returns true if we contain a valid ParseResult value.
decltype(std::declval< T >().push_back(std::declval< typename T::value_type && >())) has_push_back_t
This header declares functions that assist transformations in the MemRef dialect.
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
bool succeeded(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a success value.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value.
static FailureOr< AffineMap > parse(AsmParser &parser)
static FailureOr< AttributeT > parse(AsmParser &parser)
typename ContainerT::value_type ElementT
static FailureOr< ContainerT > parse(AsmParser &parser)
static FailureOr< IntT > parse(AsmParser &parser)
static FailureOr< TypeT > parse(AsmParser &parser)
static FailureOr< std::optional< AttributeT > > parse(AsmParser &parser)
static FailureOr< std::optional< IntT > > parse(AsmParser &parser)
static FailureOr< std::string > parse(AsmParser &parser)
Provide a template class that can be specialized by users to dispatch to parsers.