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 ::mlir::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 ::llzk::EmitErrorFn emitError =
nullptr;
84 assert(elementType &&
"element type cannot be null");
85 ::llvm::SmallVector<::mlir::Attribute> dimSizes =
forceIntAttrTypes(dimensionSizes);
86 ::mlir::MLIRContext *ctx = elementType.getContext();
87 ::llvm::SmallVector<int64_t> shape;
89 if(::mlir::failed(res)) {
return ArrayType(); }
90 return Base::get(ctx, elementType, dimSizes, shape);
93ArrayType ArrayType::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::Type elementType, ::llvm::ArrayRef<::mlir::Attribute> dimensionSizes) {
94 assert(elementType &&
"element type cannot be null");
95 ::llvm::SmallVector<::mlir::Attribute> dimSizes =
forceIntAttrTypes(dimensionSizes);
96 ::mlir::MLIRContext *ctx = elementType.getContext();
97 ::llvm::SmallVector<int64_t> shape;
99 if(::mlir::failed(res)) {
return ArrayType(); }
100 return Base::getChecked(emitError, ctx, elementType, dimSizes, shape);
104 assert(elementType &&
"element type cannot be null");
105 ::mlir::MLIRContext *ctx = elementType.getContext();
106 ::llvm::SmallVector<::mlir::Attribute> dimSizes;
108 if(::mlir::failed(res)) {
return ArrayType(); }
109 return Base::get(ctx, elementType, dimSizes, shape);
113 assert(elementType &&
"element type cannot be null");
114 ::mlir::MLIRContext *ctx = elementType.getContext();
115 ::llvm::SmallVector<::mlir::Attribute> dimSizes;
117 if(::mlir::failed(res)) {
return ArrayType(); }
118 return Base::getChecked(emitError, ctx, elementType, dimSizes, shape);
122 ::mlir::Builder odsBuilder(odsParser.getContext());
123 ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
125 ::mlir::FailureOr<::mlir::Type> _result_elementType;
126 ::mlir::FailureOr<::llvm::SmallVector<::mlir::Attribute>> _result_dimensionSizes;
127 ::mlir::FailureOr<::llvm::SmallVector<int64_t>> _result_shape;
129 if (odsParser.parseLess())
return {};
131 auto odsCustomLoc = odsParser.getCurrentLocation();
134 ::mlir::detail::unwrapForCustomParse(_result_dimensionSizes));
135 if (::mlir::failed(odsCustomResult))
return {};
136 if (::mlir::failed(_result_dimensionSizes)) {
137 odsParser.emitError(odsCustomLoc,
"custom parser failed to parse parameter 'dimensionSizes'");
142 auto odsCustomLoc = odsParser.getCurrentLocation();
145 ::mlir::detail::unwrapForCustomParse(_result_shape),
146 *_result_dimensionSizes);
147 if (::mlir::failed(odsCustomResult))
return {};
148 if (::mlir::failed(_result_shape)) {
149 odsParser.emitError(odsCustomLoc,
"custom parser failed to parse parameter 'shape'");
154 if (odsParser.parseKeyword(
"x"))
return {};
158 if (::mlir::failed(_result_elementType)) {
159 odsParser.emitError(odsParser.getCurrentLocation(),
"failed to parse LLZK_ArrayType parameter 'elementType' which is to be a `::mlir::Type`");
163 if (odsParser.parseGreater())
return {};
164 assert(::mlir::succeeded(_result_elementType));
165 assert(::mlir::succeeded(_result_dimensionSizes));
166 assert(::mlir::succeeded(_result_shape));
167 return odsParser.getChecked<
ArrayType>(odsLoc, odsParser.getContext(),
168 ::mlir::Type((*_result_elementType)),
169 ::llvm::ArrayRef<::mlir::Attribute>((*_result_dimensionSizes)),
170 ::llvm::ArrayRef<int64_t>((*_result_shape)));
174 ::mlir::Builder odsBuilder(getContext());
181 odsPrinter <<
' ' <<
"x";
188 return getImpl()->elementType;
192 return getImpl()->dimensionSizes;
196 return getImpl()->shape;
207 ::llvm::SMLoc typeLoc = parser.getCurrentLocation();
208 ::llvm::StringRef mnemonic;
209 ::mlir::Type genType;
210 auto parseResult = generatedTypeParser(parser, &mnemonic, genType);
211 if (parseResult.has_value())
214 parser.emitError(typeLoc) <<
"unknown type `"
215 << mnemonic <<
"` in dialect `" << getNamespace() <<
"`";
220 ::mlir::DialectAsmPrinter &printer)
const {
221 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()
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::ArrayRef<::mlir::Attribute > getDimensionSizes() const
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)
LogicalResult computeShapeFromDims(EmitErrorFn emitError, MLIRContext *ctx, ArrayRef< Attribute > dimensionSizes, SmallVector< int64_t > &shape)
ParseResult parseDerivedShape(AsmParser &parser, SmallVector< int64_t > &shape, SmallVector< Attribute > dimensionSizes)
SmallVector< Attribute > forceIntAttrTypes(ArrayRef< Attribute > attrList)
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)