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(); });
45 using KeyTy = std::tuple<::mlir::Type, ::llvm::ArrayRef<::mlir::Attribute>, ::llvm::ArrayRef<int64_t>>;
57 return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey));
61 auto elementType = std::move(std::get<0>(tblgenKey));
63 auto shape = std::move(std::get<2>(tblgenKey));
71 ::llvm::ArrayRef<int64_t>
shape;
83 const ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError =
nullptr;
86 assert(elementType &&
"element type cannot be null");
87 ::mlir::MLIRContext *ctx = elementType.getContext();
90 if(::mlir::failed(dimSizesRes)) {
return ArrayType(); }
91 ::llvm::SmallVector<::mlir::Attribute> dimSizes = *dimSizesRes;
92 ::llvm::SmallVector<int64_t> shape;
94 if(::mlir::failed(res)) {
return ArrayType(); }
95 return Base::get(ctx, elementType, dimSizes, shape);
98ArrayType ArrayType::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::Type elementType, ::llvm::ArrayRef<::mlir::Attribute> dimensionSizes) {
99 assert(elementType &&
"element type cannot be null");
100 ::mlir::MLIRContext *ctx = elementType.getContext();
103 if(::mlir::failed(dimSizesRes)) {
return ArrayType(); }
104 ::llvm::SmallVector<::mlir::Attribute> dimSizes = *dimSizesRes;
105 ::llvm::SmallVector<int64_t> shape;
107 if(::mlir::failed(res)) {
return ArrayType(); }
108 return Base::getChecked(emitError, ctx, elementType, dimSizes, shape);
112 assert(elementType &&
"element type cannot be null");
113 ::mlir::MLIRContext *ctx = elementType.getContext();
114 ::llvm::SmallVector<::mlir::Attribute> dimSizes;
116 if(::mlir::failed(res)) {
return ArrayType(); }
117 return Base::get(ctx, elementType, dimSizes, shape);
121 assert(elementType &&
"element type cannot be null");
122 ::mlir::MLIRContext *ctx = elementType.getContext();
123 ::llvm::SmallVector<::mlir::Attribute> dimSizes;
125 if(::mlir::failed(res)) {
return ArrayType(); }
126 return Base::getChecked(emitError, ctx, elementType, dimSizes, shape);
129::llvm::LogicalResult
ArrayType::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::Type elementType, ::llvm::ArrayRef<::mlir::Attribute> dimensionSizes, ::llvm::ArrayRef<int64_t> shape) {
130 if (::mlir::failed(
verify(emitError, elementType, dimensionSizes, shape)))
131 return ::mlir::failure();
132 return ::mlir::success();
136 ::mlir::Builder odsBuilder(odsParser.getContext());
137 ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
139 ::mlir::FailureOr<::mlir::Type> _result_elementType;
140 ::mlir::FailureOr<::llvm::SmallVector<::mlir::Attribute>> _result_dimensionSizes;
141 ::mlir::FailureOr<::llvm::SmallVector<int64_t>> _result_shape;
143 if (odsParser.parseLess())
return {};
145 auto odsCustomLoc = odsParser.getCurrentLocation();
148 ::mlir::detail::unwrapForCustomParse(_result_dimensionSizes));
149 if (::mlir::failed(odsCustomResult))
return {};
150 if (::mlir::failed(_result_dimensionSizes)) {
151 odsParser.emitError(odsCustomLoc,
"custom parser failed to parse parameter 'dimensionSizes'");
156 auto odsCustomLoc = odsParser.getCurrentLocation();
159 ::mlir::detail::unwrapForCustomParse(_result_shape),
160 *_result_dimensionSizes);
161 if (::mlir::failed(odsCustomResult))
return {};
162 if (::mlir::failed(_result_shape)) {
163 odsParser.emitError(odsCustomLoc,
"custom parser failed to parse parameter 'shape'");
168 if (odsParser.parseKeyword(
"x"))
return {};
172 if (::mlir::failed(_result_elementType)) {
173 odsParser.emitError(odsParser.getCurrentLocation(),
"failed to parse LLZK_ArrayType parameter 'elementType' which is to be a `::mlir::Type`");
177 if (odsParser.parseGreater())
return {};
178 assert(::mlir::succeeded(_result_elementType));
179 assert(::mlir::succeeded(_result_dimensionSizes));
180 assert(::mlir::succeeded(_result_shape));
181 return odsParser.getChecked<
ArrayType>(odsLoc, odsParser.getContext(),
182 ::mlir::Type((*_result_elementType)),
183 ::llvm::ArrayRef<::mlir::Attribute>((*_result_dimensionSizes)),
184 ::llvm::ArrayRef<int64_t>((*_result_shape)));
188 ::mlir::Builder odsBuilder(getContext());
195 odsPrinter <<
' ' <<
"x";
202 return getImpl()->elementType;
206 return getImpl()->dimensionSizes;
210 return getImpl()->shape;
221 ::llvm::SMLoc typeLoc = parser.getCurrentLocation();
222 ::llvm::StringRef mnemonic;
223 ::mlir::Type genType;
224 auto parseResult = generatedTypeParser(parser, &mnemonic, genType);
225 if (parseResult.has_value())
228 parser.emitError(typeLoc) <<
"unknown type `"
229 << mnemonic <<
"` in dialect `" << getNamespace() <<
"`";
234 ::mlir::DialectAsmPrinter &printer)
const {
235 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
Common interface for operations that reference an array value.
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)