10#undef GET_TYPEDEF_LIST
16#ifdef GET_TYPEDEF_CLASSES
17#undef GET_TYPEDEF_CLASSES
19static ::mlir::OptionalParseResult generatedTypeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type &value) {
20 return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser)
23 return ::mlir::success(!!value);
25 .Default([&](llvm::StringRef keyword, llvm::SMLoc) {
31static ::llvm::LogicalResult generatedTypePrinter(::mlir::Type def, ::mlir::AsmPrinter &printer) {
35 return ::mlir::success();
37 .Default([](
auto) { return ::mlir::failure(); });
44 using KeyTy = std::tuple<::mlir::Type, ::llvm::ArrayRef<::mlir::Attribute>, ::llvm::ArrayRef<int64_t>>;
56 return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey));
60 auto elementType = std::move(std::get<0>(tblgenKey));
62 auto shape = std::move(std::get<2>(tblgenKey));
70 ::llvm::ArrayRef<int64_t>
shape;
81 const ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError =
nullptr;
84 assert(elementType &&
"element type cannot be null");
85 ::mlir::MLIRContext *ctx = elementType.getContext();
88 if(::mlir::failed(dimSizesRes)) {
return ArrayType(); }
89 ::llvm::SmallVector<::mlir::Attribute> dimSizes = *dimSizesRes;
90 ::llvm::SmallVector<int64_t> shape;
92 if(::mlir::failed(res)) {
return ArrayType(); }
93 return Base::get(ctx, elementType, dimSizes, shape);
96ArrayType ArrayType::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::Type elementType, ::llvm::ArrayRef<::mlir::Attribute> dimensionSizes) {
97 assert(elementType &&
"element type cannot be null");
98 ::mlir::MLIRContext *ctx = elementType.getContext();
101 if(::mlir::failed(dimSizesRes)) {
return ArrayType(); }
102 ::llvm::SmallVector<::mlir::Attribute> dimSizes = *dimSizesRes;
103 ::llvm::SmallVector<int64_t> shape;
105 if(::mlir::failed(res)) {
return ArrayType(); }
106 return Base::getChecked(emitError, ctx, elementType, dimSizes, shape);
110 assert(elementType &&
"element type cannot be null");
111 ::mlir::MLIRContext *ctx = elementType.getContext();
112 ::llvm::SmallVector<::mlir::Attribute> dimSizes;
114 if(::mlir::failed(res)) {
return ArrayType(); }
115 return Base::get(ctx, elementType, dimSizes, shape);
119 assert(elementType &&
"element type cannot be null");
120 ::mlir::MLIRContext *ctx = elementType.getContext();
121 ::llvm::SmallVector<::mlir::Attribute> dimSizes;
123 if(::mlir::failed(res)) {
return ArrayType(); }
124 return Base::getChecked(emitError, ctx, elementType, dimSizes, shape);
127::llvm::LogicalResult
ArrayType::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::Type elementType, ::llvm::ArrayRef<::mlir::Attribute> dimensionSizes, ::llvm::ArrayRef<int64_t> shape) {
128 if (::mlir::failed(
verify(emitError, elementType, dimensionSizes, shape)))
129 return ::mlir::failure();
130 return ::mlir::success();
134 ::mlir::Builder odsBuilder(odsParser.getContext());
135 ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
137 ::mlir::FailureOr<::mlir::Type> _result_elementType;
138 ::mlir::FailureOr<::llvm::SmallVector<::mlir::Attribute>> _result_dimensionSizes;
139 ::mlir::FailureOr<::llvm::SmallVector<int64_t>> _result_shape;
141 if (odsParser.parseLess())
return {};
143 auto odsCustomLoc = odsParser.getCurrentLocation();
146 ::mlir::detail::unwrapForCustomParse(_result_dimensionSizes));
147 if (::mlir::failed(odsCustomResult))
return {};
148 if (::mlir::failed(_result_dimensionSizes)) {
149 odsParser.emitError(odsCustomLoc,
"custom parser failed to parse parameter 'dimensionSizes'");
154 auto odsCustomLoc = odsParser.getCurrentLocation();
157 ::mlir::detail::unwrapForCustomParse(_result_shape),
158 *_result_dimensionSizes);
159 if (::mlir::failed(odsCustomResult))
return {};
160 if (::mlir::failed(_result_shape)) {
161 odsParser.emitError(odsCustomLoc,
"custom parser failed to parse parameter 'shape'");
166 if (odsParser.parseKeyword(
"x"))
return {};
170 if (::mlir::failed(_result_elementType)) {
171 odsParser.emitError(odsParser.getCurrentLocation(),
"failed to parse LLZK_ArrayType parameter 'elementType' which is to be a `::mlir::Type`");
175 if (odsParser.parseGreater())
return {};
176 assert(::mlir::succeeded(_result_elementType));
177 assert(::mlir::succeeded(_result_dimensionSizes));
178 assert(::mlir::succeeded(_result_shape));
179 return odsParser.getChecked<
ArrayType>(odsLoc, odsParser.getContext(),
180 ::mlir::Type((*_result_elementType)),
181 ::llvm::ArrayRef<::mlir::Attribute>((*_result_dimensionSizes)),
182 ::llvm::ArrayRef<int64_t>((*_result_shape)));
186 ::mlir::Builder odsBuilder(getContext());
193 odsPrinter <<
' ' <<
"x";
200 return getImpl()->elementType;
204 return getImpl()->dimensionSizes;
208 return getImpl()->shape;
219 ::llvm::SMLoc typeLoc = parser.getCurrentLocation();
220 ::llvm::StringRef mnemonic;
221 ::mlir::Type genType;
222 auto parseResult = generatedTypeParser(parser, &mnemonic, genType);
223 if (parseResult.has_value())
226 parser.emitError(typeLoc) <<
"unknown type `"
227 << mnemonic <<
"` in dialect `" << getNamespace() <<
"`";
232 ::mlir::DialectAsmPrinter &printer)
const {
233 if (::mlir::succeeded(generatedTypePrinter(type, printer)))
::mlir::Type parseType(::mlir::DialectAsmParser &parser) const override
Parse a type registered to this dialect.
void printType(::mlir::Type type, ::mlir::DialectAsmPrinter &os) const override
Print a type registered to this dialect.
::mlir::Type parse(::mlir::AsmParser &odsParser)
static constexpr ::llvm::StringLiteral getMnemonic()
::llvm::LogicalResult verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::Type elementType, ::llvm::ArrayRef<::mlir::Attribute > dimensionSizes, ::llvm::ArrayRef< int64_t > shape)
void print(::mlir::AsmPrinter &odsPrinter) const
::llvm::ArrayRef< int64_t > getShape() const
::mlir::Type getElementType() const
static ArrayType get(::mlir::Type elementType, ::llvm::ArrayRef<::mlir::Attribute > dimensionSizes)
static ArrayType getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::Type elementType, ::llvm::ArrayRef<::mlir::Attribute > dimensionSizes)
::llvm::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::Type elementType, ::llvm::ArrayRef<::mlir::Attribute > dimensionSizes, ::llvm::ArrayRef< int64_t > shape)
::llvm::ArrayRef<::mlir::Attribute > getDimensionSizes() const
LogicalResult computeShapeFromDims(EmitErrorFn emitError, ArrayRef< Attribute > dimensionSizes, SmallVector< int64_t > &shape)
ParseResult parseAttrVec(AsmParser &parser, SmallVector< Attribute > &value)
void printDerivedShape(AsmPrinter &, ArrayRef< int64_t >, ArrayRef< Attribute >)
LogicalResult computeDimsFromShape(MLIRContext *ctx, ArrayRef< int64_t > shape, SmallVector< Attribute > &dimensionSizes)
void printAttrVec(AsmPrinter &printer, ArrayRef< Attribute > value)
ParseResult parseDerivedShape(AsmParser &parser, SmallVector< int64_t > &shape, SmallVector< Attribute > dimensionSizes)
FailureOr< SmallVector< Attribute > > forceIntAttrTypes(ArrayRef< Attribute > attrList, EmitErrorFn emitError)
std::function< InFlightDiagnosticWrapper()> OwningEmitErrorFn
This type is required in cases like the functions below to take ownership of the lambda so it is not ...
OwningEmitErrorFn wrapNullableInFlightDiagnostic(llvm::function_ref< mlir::InFlightDiagnostic()> emitError, mlir::MLIRContext *ctx)
If the given emitError is non-null, return it.
std::tuple<::mlir::Type, ::llvm::ArrayRef<::mlir::Attribute >, ::llvm::ArrayRef< int64_t > > KeyTy
static ArrayTypeStorage * construct(::mlir::TypeStorageAllocator &allocator, KeyTy &&tblgenKey)
::llvm::ArrayRef<::mlir::Attribute > dimensionSizes
bool operator==(const KeyTy &tblgenKey) const
ArrayTypeStorage(::mlir::Type elementType, ::llvm::ArrayRef<::mlir::Attribute > dimensionSizes, ::llvm::ArrayRef< int64_t > shape)
::llvm::ArrayRef< int64_t > shape
::llvm::hash_code hashKey(const KeyTy &tblgenKey)