1#include "llvm/ADT/TypeSwitch.h"
2#include "mlir/Bytecode/BytecodeImplementation.h"
3
4static ::mlir::Attribute readBoolAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
5 bool value;
6 if (::mlir::succeeded(Result: reader.readBool(result&: value))) {
7 return get<::cir::BoolAttr>(context, params: cir::BoolType::get(ctx: context), params&: value);
8 }
9 return ::cir::BoolAttr();
10}
11
12static ::llvm::LogicalResult write(::cir::BoolAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
13 writer.writeVarInt(/* BoolAttr */ value: 7);
14 writer.writeOwnedBool(value: attribute.getValue());
15 return ::mlir::success();
16 return ::mlir::failure();
17}
18
19static ::mlir::Attribute readAddressPointAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
20 int32_t index, offset;
21 if (succeeded(Result: readCheckedInt(reader, result&: index)) &&
22 succeeded(Result: readCheckedInt(reader, result&: offset))) {
23 return ::mlir::getChecked<AddressPointAttr>(emitError: [&]() { return reader.emitError(); }, context, params&: index, params&: offset);
24 }
25 return AddressPointAttr();
26}
27
28static ::llvm::LogicalResult write(AddressPointAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
29 writer.writeVarInt(/* AddressPointAttr */ value: 1);
30 writer.writeSignedVarInt(value: attribute.getIndex());
31 writer.writeSignedVarInt(value: attribute.getOffset());
32 return ::mlir::success();
33 return ::mlir::failure();
34}
35
36static ::mlir::Attribute readBitFieldDeclAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
37 ::mlir::Type declared_type;
38 uint64_t width;
39 bool is_unnamed;
40 if (::mlir::succeeded(Result: reader.readType(result&: declared_type)) &&
41 ::mlir::succeeded(Result: reader.readVarInt(result&: width)) &&
42 ::mlir::succeeded(Result: reader.readBool(result&: is_unnamed))) {
43 return BitFieldDeclAttr::getChecked(emitError: [&]() { return reader.emitError(); }, context, declared_type, width, is_unnamed);
44 }
45 return BitFieldDeclAttr();
46}
47
48static ::llvm::LogicalResult write(BitFieldDeclAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
49 writer.writeVarInt(/* BitFieldDeclAttr */ value: 28);
50 writer.writeType(type: attribute.getDeclaredType());
51 writer.writeVarInt(value: attribute.getWidth());
52 writer.writeOwnedBool(value: attribute.getIsUnnamed());
53 return ::mlir::success();
54 return ::mlir::failure();
55}
56
57static ::mlir::Attribute readBitfieldInfoAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
58 mlir::StringAttr name;
59 ::mlir::Type storage_type;
60 uint64_t size, offset;
61 bool is_signed;
62 if (::mlir::succeeded(Result: reader.readAttribute(result&: name)) &&
63 ::mlir::succeeded(Result: reader.readType(result&: storage_type)) &&
64 ::mlir::succeeded(Result: reader.readVarInt(result&: size)) &&
65 ::mlir::succeeded(Result: reader.readVarInt(result&: offset)) &&
66 ::mlir::succeeded(Result: reader.readBool(result&: is_signed))) {
67 return ::mlir::getChecked<BitfieldInfoAttr>(emitError: [&]() { return reader.emitError(); }, context, params&: name, params&: storage_type, params&: size, params&: offset, params&: is_signed);
68 }
69 return BitfieldInfoAttr();
70}
71
72static ::llvm::LogicalResult write(BitfieldInfoAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
73 writer.writeVarInt(/* BitfieldInfoAttr */ value: 4);
74 writer.writeAttribute(attr: attribute.getName());
75 writer.writeType(type: attribute.getStorageType());
76 writer.writeVarInt(value: attribute.getSize());
77 writer.writeVarInt(value: attribute.getOffset());
78 writer.writeOwnedBool(value: attribute.getIsSigned());
79 return ::mlir::success();
80 return ::mlir::failure();
81}
82
83static ::mlir::Attribute readBlockAddrDiffAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
84 cir::IntType type;
85 mlir::FlatSymbolRefAttr func;
86 mlir::StringAttr lhs_label, rhs_label;
87 if (::mlir::succeeded(Result: reader.readType(result&: type)) &&
88 ::mlir::succeeded(Result: reader.readAttribute(result&: func)) &&
89 ::mlir::succeeded(Result: reader.readAttribute(result&: lhs_label)) &&
90 ::mlir::succeeded(Result: reader.readAttribute(result&: rhs_label))) {
91 return ::mlir::getChecked<BlockAddrDiffAttr>(emitError: [&]() { return reader.emitError(); }, context, params&: type, params&: func, params&: lhs_label, params&: rhs_label);
92 }
93 return BlockAddrDiffAttr();
94}
95
96static ::llvm::LogicalResult write(BlockAddrDiffAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
97 writer.writeVarInt(/* BlockAddrDiffAttr */ value: 17);
98 writer.writeType(type: attribute.getType());
99 writer.writeAttribute(attr: attribute.getFunc());
100 writer.writeAttribute(attr: attribute.getLhsLabel());
101 writer.writeAttribute(attr: attribute.getRhsLabel());
102 return ::mlir::success();
103 return ::mlir::failure();
104}
105
106static ::mlir::Attribute readBlockAddrInfoAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
107 cir::PointerType type;
108 mlir::FlatSymbolRefAttr func;
109 mlir::StringAttr label;
110 if (::mlir::succeeded(Result: reader.readType(result&: type)) &&
111 ::mlir::succeeded(Result: reader.readAttribute(result&: func)) &&
112 ::mlir::succeeded(Result: reader.readAttribute(result&: label))) {
113 return ::mlir::getChecked<BlockAddrInfoAttr>(emitError: [&]() { return reader.emitError(); }, context, params&: type, params&: func, params&: label);
114 }
115 return BlockAddrInfoAttr();
116}
117
118static ::llvm::LogicalResult write(BlockAddrInfoAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
119 writer.writeVarInt(/* BlockAddrInfoAttr */ value: 3);
120 writer.writeType(type: attribute.getType());
121 writer.writeAttribute(attr: attribute.getFunc());
122 writer.writeAttribute(attr: attribute.getLabel());
123 return ::mlir::success();
124 return ::mlir::failure();
125}
126
127static ::mlir::Attribute readCXXAssignAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
128 ::mlir::Type type;
129 cir::AssignKind assignKind;
130 bool isTrivial;
131 if (::mlir::succeeded(Result: reader.readType(result&: type)) &&
132 succeeded(Result: readEnum(reader, result&: assignKind, symbolize: cir::symbolizeAssignKind, enumName: "AssignKind")) &&
133 ::mlir::succeeded(Result: reader.readBool(result&: isTrivial))) {
134 return ::mlir::getChecked<CXXAssignAttr>(emitError: [&]() { return reader.emitError(); }, context, params&: type, params&: assignKind, params&: isTrivial);
135 }
136 return CXXAssignAttr();
137}
138
139static ::llvm::LogicalResult write(CXXAssignAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
140 writer.writeVarInt(/* CXXAssignAttr */ value: 20);
141 writer.writeType(type: attribute.getType());
142 writer.writeVarInt(value: static_cast<uint64_t>(attribute.getAssignKind()));
143 writer.writeOwnedBool(value: attribute.getIsTrivial());
144 return ::mlir::success();
145 return ::mlir::failure();
146}
147
148static ::mlir::Attribute readCXXCtorAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
149 ::mlir::Type type;
150 cir::CtorKind ctorKind;
151 bool isTrivial;
152 if (::mlir::succeeded(Result: reader.readType(result&: type)) &&
153 succeeded(Result: readEnum(reader, result&: ctorKind, symbolize: cir::symbolizeCtorKind, enumName: "CtorKind")) &&
154 ::mlir::succeeded(Result: reader.readBool(result&: isTrivial))) {
155 return ::mlir::getChecked<CXXCtorAttr>(emitError: [&]() { return reader.emitError(); }, context, params&: type, params&: ctorKind, params&: isTrivial);
156 }
157 return CXXCtorAttr();
158}
159
160static ::llvm::LogicalResult write(CXXCtorAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
161 writer.writeVarInt(/* CXXCtorAttr */ value: 18);
162 writer.writeType(type: attribute.getType());
163 writer.writeVarInt(value: static_cast<uint64_t>(attribute.getCtorKind()));
164 writer.writeOwnedBool(value: attribute.getIsTrivial());
165 return ::mlir::success();
166 return ::mlir::failure();
167}
168
169static ::mlir::Attribute readCXXDtorAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
170 ::mlir::Type type;
171 bool isTrivial;
172 if (::mlir::succeeded(Result: reader.readType(result&: type)) &&
173 ::mlir::succeeded(Result: reader.readBool(result&: isTrivial))) {
174 return ::mlir::getChecked<CXXDtorAttr>(emitError: [&]() { return reader.emitError(); }, context, params&: type, params&: isTrivial);
175 }
176 return CXXDtorAttr();
177}
178
179static ::llvm::LogicalResult write(CXXDtorAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
180 writer.writeVarInt(/* CXXDtorAttr */ value: 19);
181 writer.writeType(type: attribute.getType());
182 writer.writeOwnedBool(value: attribute.getIsTrivial());
183 return ::mlir::success();
184 return ::mlir::failure();
185}
186
187static ::mlir::Attribute readCatchAllAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
188 return ::mlir::getChecked<CatchAllAttr>(emitError: [&]() { return reader.emitError(); }, context);
189}
190
191static ::llvm::LogicalResult write(CatchAllAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
192 writer.writeVarInt(/* CatchAllAttr */ value: 9);
193 return ::mlir::success();
194 return ::mlir::failure();
195}
196
197static ::mlir::Attribute readConstArrayAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
198 ::mlir::Type type;
199 ::mlir::Attribute elts;
200 int trailingZerosNum;
201 if (::mlir::succeeded(Result: reader.readType(result&: type)) &&
202 ::mlir::succeeded(Result: reader.readAttribute(result&: elts)) &&
203 succeeded(Result: readCheckedInt(reader, result&: trailingZerosNum))) {
204 return ConstArrayAttr::getChecked(emitError: [&]() { return reader.emitError(); }, context, type, elts, trailingZerosNum);
205 }
206 return ConstArrayAttr();
207}
208
209static ::llvm::LogicalResult write(ConstArrayAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
210 writer.writeVarInt(/* ConstArrayAttr */ value: 14);
211 writer.writeType(type: attribute.getType());
212 writer.writeAttribute(attr: attribute.getElts());
213 writer.writeSignedVarInt(value: attribute.getTrailingZerosNum());
214 return ::mlir::success();
215 return ::mlir::failure();
216}
217
218static ::mlir::Attribute readConstComplexAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
219 cir::ComplexType type;
220 mlir::TypedAttr real, imag;
221 if (::mlir::succeeded(Result: reader.readType(result&: type)) &&
222 ::mlir::succeeded(Result: reader.readAttribute(result&: real)) &&
223 ::mlir::succeeded(Result: reader.readAttribute(result&: imag))) {
224 return ::mlir::getChecked<ConstComplexAttr>(emitError: [&]() { return reader.emitError(); }, context, params&: type, params&: real, params&: imag);
225 }
226 return ConstComplexAttr();
227}
228
229static ::llvm::LogicalResult write(ConstComplexAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
230 writer.writeVarInt(/* ConstComplexAttr */ value: 25);
231 writer.writeType(type: attribute.getType());
232 writer.writeAttribute(attr: attribute.getReal());
233 writer.writeAttribute(attr: attribute.getImag());
234 return ::mlir::success();
235 return ::mlir::failure();
236}
237
238static ::mlir::Attribute readConstPtrAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
239 cir::PointerType type;
240 mlir::IntegerAttr value;
241 if (::mlir::succeeded(Result: reader.readType(result&: type)) &&
242 ::mlir::succeeded(Result: reader.readAttribute(result&: value))) {
243 return ::mlir::getChecked<ConstPtrAttr>(emitError: [&]() { return reader.emitError(); }, context, params&: type, params&: value);
244 }
245 return ConstPtrAttr();
246}
247
248static ::llvm::LogicalResult write(ConstPtrAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
249 writer.writeVarInt(/* ConstPtrAttr */ value: 8);
250 writer.writeType(type: attribute.getType());
251 writer.writeAttribute(attr: attribute.getValue());
252 return ::mlir::success();
253 return ::mlir::failure();
254}
255
256static ::mlir::Attribute readConstRecordAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
257 ::mlir::Type type;
258 mlir::ArrayAttr members;
259 if (::mlir::succeeded(Result: reader.readType(result&: type)) &&
260 ::mlir::succeeded(Result: reader.readAttribute(result&: members))) {
261 return ConstRecordAttr::getChecked(emitError: [&]() { return reader.emitError(); }, context, type, members);
262 }
263 return ConstRecordAttr();
264}
265
266static ::llvm::LogicalResult write(ConstRecordAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
267 writer.writeVarInt(/* ConstRecordAttr */ value: 15);
268 writer.writeType(type: attribute.getType());
269 writer.writeAttribute(attr: attribute.getMembers());
270 return ::mlir::success();
271 return ::mlir::failure();
272}
273
274static ::mlir::Attribute readConstVectorAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
275 ::mlir::Type type;
276 mlir::ArrayAttr elts;
277 if (::mlir::succeeded(Result: reader.readType(result&: type)) &&
278 ::mlir::succeeded(Result: reader.readAttribute(result&: elts))) {
279 return ::mlir::getChecked<ConstVectorAttr>(emitError: [&]() { return reader.emitError(); }, context, params&: type, params&: elts);
280 }
281 return ConstVectorAttr();
282}
283
284static ::llvm::LogicalResult write(ConstVectorAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
285 writer.writeVarInt(/* ConstVectorAttr */ value: 24);
286 writer.writeType(type: attribute.getType());
287 writer.writeAttribute(attr: attribute.getElts());
288 return ::mlir::success();
289 return ::mlir::failure();
290}
291
292static ::mlir::Attribute readDataMemberAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
293 cir::DataMemberType type;
294 mlir::DenseI32ArrayAttr member_path;
295 if (::mlir::succeeded(Result: reader.readType(result&: type)) &&
296 succeeded(Result: reader.readOptionalAttribute(result&: member_path))) {
297 return ::mlir::getChecked<DataMemberAttr>(emitError: [&]() { return reader.emitError(); }, context, params&: type, params&: member_path);
298 }
299 return DataMemberAttr();
300}
301
302static ::llvm::LogicalResult write(DataMemberAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
303 writer.writeVarInt(/* DataMemberAttr */ value: 26);
304 writer.writeType(type: attribute.getType());
305 writer.writeOptionalAttribute(attr: attribute.getMemberPath());
306 return ::mlir::success();
307 return ::mlir::failure();
308}
309
310static ::mlir::Attribute readDynamicCastInfoAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
311 cir::GlobalViewAttr src_rtti, dest_rtti;
312 mlir::FlatSymbolRefAttr runtime_func, bad_cast_func;
313 cir::IntAttr offset_hint;
314 if (::mlir::succeeded(Result: reader.readAttribute(result&: src_rtti)) &&
315 ::mlir::succeeded(Result: reader.readAttribute(result&: dest_rtti)) &&
316 ::mlir::succeeded(Result: reader.readAttribute(result&: runtime_func)) &&
317 ::mlir::succeeded(Result: reader.readAttribute(result&: bad_cast_func)) &&
318 ::mlir::succeeded(Result: reader.readAttribute(result&: offset_hint))) {
319 return ::mlir::getChecked<DynamicCastInfoAttr>(emitError: [&]() { return reader.emitError(); }, context, params&: src_rtti, params&: dest_rtti, params&: runtime_func, params&: bad_cast_func, params&: offset_hint);
320 }
321 return DynamicCastInfoAttr();
322}
323
324static ::llvm::LogicalResult write(DynamicCastInfoAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
325 writer.writeVarInt(/* DynamicCastInfoAttr */ value: 23);
326 writer.writeAttribute(attr: attribute.getSrcRtti());
327 writer.writeAttribute(attr: attribute.getDestRtti());
328 writer.writeAttribute(attr: attribute.getRuntimeFunc());
329 writer.writeAttribute(attr: attribute.getBadCastFunc());
330 writer.writeAttribute(attr: attribute.getOffsetHint());
331 return ::mlir::success();
332 return ::mlir::failure();
333}
334
335static ::mlir::Attribute readFPAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
336 ::mlir::Type type;
337 ::mlir::FailureOr<::llvm::APFloat> value;
338 if (::mlir::succeeded(Result: reader.readType(result&: type)) &&
339 ::mlir::succeeded(Result: readAPFloatWithKnownSemantics(reader, type, val&: value))) {
340 return get<FPAttr>(context, params: mlir::cast<cir::FPTypeInterface>(Val&: type), params&: *value);
341 }
342 return FPAttr();
343}
344
345static ::llvm::LogicalResult write(FPAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
346 writer.writeVarInt(/* FPAttr */ value: 6);
347 writer.writeType(type: attribute.getType());
348 writer.writeAPFloatWithKnownSemantics(value: attribute.getValue());
349 return ::mlir::success();
350 return ::mlir::failure();
351}
352
353static ::mlir::Attribute readGlobalViewAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
354 ::mlir::Type type;
355 mlir::FlatSymbolRefAttr symbol;
356 mlir::ArrayAttr indices;
357 bool address_point;
358 if (::mlir::succeeded(Result: reader.readType(result&: type)) &&
359 ::mlir::succeeded(Result: reader.readAttribute(result&: symbol)) &&
360 succeeded(Result: reader.readOptionalAttribute(result&: indices)) &&
361 ::mlir::succeeded(Result: reader.readBool(result&: address_point))) {
362 return ::mlir::getChecked<GlobalViewAttr>(emitError: [&]() { return reader.emitError(); }, context, params&: type, params&: symbol, params&: indices, params&: address_point);
363 }
364 return GlobalViewAttr();
365}
366
367static ::llvm::LogicalResult write(GlobalViewAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
368 writer.writeVarInt(/* GlobalViewAttr */ value: 21);
369 writer.writeType(type: attribute.getType());
370 writer.writeAttribute(attr: attribute.getSymbol());
371 writer.writeOptionalAttribute(attr: attribute.getIndices());
372 writer.writeOwnedBool(value: attribute.getAddressPoint());
373 return ::mlir::success();
374 return ::mlir::failure();
375}
376
377static ::mlir::Attribute readIntAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
378 ::mlir::Type type;
379 ::mlir::FailureOr<::llvm::APInt> value;
380 if (::mlir::succeeded(Result: reader.readType(result&: type)) &&
381 ::mlir::succeeded(Result: readAPIntWithKnownWidth(reader, type, val&: value))) {
382 return get<IntAttr>(context, params: mlir::cast<cir::IntTypeInterface>(Val&: type), params&: *value);
383 }
384 return IntAttr();
385}
386
387static ::llvm::LogicalResult write(IntAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
388 writer.writeVarInt(/* IntAttr */ value: 5);
389 writer.writeType(type: attribute.getType());
390 writer.writeAPIntWithKnownWidth(value: attribute.getValue());
391 return ::mlir::success();
392 return ::mlir::failure();
393}
394
395static ::mlir::Attribute readMethodAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
396 cir::MethodType type;
397 std::optional<mlir::FlatSymbolRefAttr> symbol;
398 std::optional<uint64_t> vtable_index;
399 if (::mlir::succeeded(Result: reader.readType(result&: type)) &&
400 succeeded(Result: readStdOptionalAttribute(reader, storage&: symbol)) &&
401 succeeded(Result: readOptionalInt(reader, storage&: vtable_index))) {
402 return MethodAttr::getChecked(emitError: [&]() { return reader.emitError(); }, context, type, symbol, vtable_index);
403 }
404 return MethodAttr();
405}
406
407static ::llvm::LogicalResult write(MethodAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
408 writer.writeVarInt(/* MethodAttr */ value: 27);
409 writer.writeType(type: attribute.getType());
410 writeStdOptionalAttribute(writer, storage: attribute.getSymbol());
411 writeOptionalInt(writer, storage: attribute.getVtableIndex());
412 return ::mlir::success();
413 return ::mlir::failure();
414}
415
416static ::mlir::Attribute readOpenCLVersionAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
417 int32_t majorVersion, minorVersion;
418 if (succeeded(Result: readCheckedInt(reader, result&: majorVersion)) &&
419 succeeded(Result: readCheckedInt(reader, result&: minorVersion))) {
420 return ::mlir::getChecked<OpenCLVersionAttr>(emitError: [&]() { return reader.emitError(); }, context, params&: majorVersion, params&: minorVersion);
421 }
422 return OpenCLVersionAttr();
423}
424
425static ::llvm::LogicalResult write(OpenCLVersionAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
426 writer.writeVarInt(/* OpenCLVersionAttr */ value: 2);
427 writer.writeSignedVarInt(value: attribute.getMajorVersion());
428 writer.writeSignedVarInt(value: attribute.getMinorVersion());
429 return ::mlir::success();
430 return ::mlir::failure();
431}
432
433static ::mlir::Attribute readOptInfoAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
434 unsigned level, size;
435 if (succeeded(Result: readCheckedInt(reader, result&: level)) &&
436 succeeded(Result: readCheckedInt(reader, result&: size))) {
437 return OptInfoAttr::getChecked(emitError: [&]() { return reader.emitError(); }, context, level, size);
438 }
439 return OptInfoAttr();
440}
441
442static ::llvm::LogicalResult write(OptInfoAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
443 writer.writeVarInt(/* OptInfoAttr */ value: 0);
444 writer.writeVarInt(value: attribute.getLevel());
445 writer.writeVarInt(value: attribute.getSize());
446 return ::mlir::success();
447 return ::mlir::failure();
448}
449
450static ::mlir::Attribute readPoisonAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
451 ::mlir::Type type;
452 if (::mlir::succeeded(Result: reader.readType(result&: type))) {
453 return ::mlir::getChecked<PoisonAttr>(emitError: [&]() { return reader.emitError(); }, context, params&: type);
454 }
455 return PoisonAttr();
456}
457
458static ::llvm::LogicalResult write(PoisonAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
459 writer.writeVarInt(/* PoisonAttr */ value: 13);
460 writer.writeType(type: attribute.getType());
461 return ::mlir::success();
462 return ::mlir::failure();
463}
464
465static ::mlir::Attribute readTypeInfoAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
466 ::mlir::Type type;
467 mlir::ArrayAttr data;
468 if (::mlir::succeeded(Result: reader.readType(result&: type)) &&
469 ::mlir::succeeded(Result: reader.readAttribute(result&: data))) {
470 return ::mlir::getChecked<TypeInfoAttr>(emitError: [&]() { return reader.emitError(); }, context, params&: type, params&: data);
471 }
472 return TypeInfoAttr();
473}
474
475static ::llvm::LogicalResult write(TypeInfoAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
476 writer.writeVarInt(/* TypeInfoAttr */ value: 22);
477 writer.writeType(type: attribute.getType());
478 writer.writeAttribute(attr: attribute.getData());
479 return ::mlir::success();
480 return ::mlir::failure();
481}
482
483static ::mlir::Attribute readUndefAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
484 ::mlir::Type type;
485 if (::mlir::succeeded(Result: reader.readType(result&: type))) {
486 return ::mlir::getChecked<UndefAttr>(emitError: [&]() { return reader.emitError(); }, context, params&: type);
487 }
488 return UndefAttr();
489}
490
491static ::llvm::LogicalResult write(UndefAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
492 writer.writeVarInt(/* UndefAttr */ value: 12);
493 writer.writeType(type: attribute.getType());
494 return ::mlir::success();
495 return ::mlir::failure();
496}
497
498static ::mlir::Attribute readUnwindAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
499 return ::mlir::getChecked<UnwindAttr>(emitError: [&]() { return reader.emitError(); }, context);
500}
501
502static ::llvm::LogicalResult write(UnwindAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
503 writer.writeVarInt(/* UnwindAttr */ value: 10);
504 return ::mlir::success();
505 return ::mlir::failure();
506}
507
508static ::mlir::Attribute readVTableAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
509 ::mlir::Type type;
510 mlir::ArrayAttr data, address_points;
511 if (::mlir::succeeded(Result: reader.readType(result&: type)) &&
512 ::mlir::succeeded(Result: reader.readAttribute(result&: data)) &&
513 ::mlir::succeeded(Result: reader.readAttribute(result&: address_points))) {
514 return ::mlir::getChecked<VTableAttr>(emitError: [&]() { return reader.emitError(); }, context, params&: type, params&: data, params&: address_points);
515 }
516 return VTableAttr();
517}
518
519static ::llvm::LogicalResult write(VTableAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
520 writer.writeVarInt(/* VTableAttr */ value: 16);
521 writer.writeType(type: attribute.getType());
522 writer.writeAttribute(attr: attribute.getData());
523 writer.writeAttribute(attr: attribute.getAddressPoints());
524 return ::mlir::success();
525 return ::mlir::failure();
526}
527
528static ::mlir::Attribute readZeroAttr(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
529 ::mlir::Type type;
530 if (::mlir::succeeded(Result: reader.readType(result&: type))) {
531 return ::mlir::getChecked<ZeroAttr>(emitError: [&]() { return reader.emitError(); }, context, params&: type);
532 }
533 return ZeroAttr();
534}
535
536static ::llvm::LogicalResult write(ZeroAttr attribute, ::mlir::DialectBytecodeWriter &writer) {
537 writer.writeVarInt(/* ZeroAttr */ value: 11);
538 writer.writeType(type: attribute.getType());
539 return ::mlir::success();
540 return ::mlir::failure();
541}
542
543static ::mlir::Attribute readAttribute(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
544 uint64_t kind;
545 if (::mlir::failed(Result: reader.readVarInt(result&: kind)))
546 return ::mlir::Attribute();
547 switch (kind) {
548 case 0:
549 return readOptInfoAttr(context, reader);
550 case 1:
551 return readAddressPointAttr(context, reader);
552 case 2:
553 return readOpenCLVersionAttr(context, reader);
554 case 3:
555 return readBlockAddrInfoAttr(context, reader);
556 case 4:
557 return readBitfieldInfoAttr(context, reader);
558 case 5:
559 return readIntAttr(context, reader);
560 case 6:
561 return readFPAttr(context, reader);
562 case 7:
563 return readBoolAttr(context, reader);
564 case 8:
565 return readConstPtrAttr(context, reader);
566 case 9:
567 return readCatchAllAttr(context, reader);
568 case 10:
569 return readUnwindAttr(context, reader);
570 case 11:
571 return readZeroAttr(context, reader);
572 case 12:
573 return readUndefAttr(context, reader);
574 case 13:
575 return readPoisonAttr(context, reader);
576 case 14:
577 return readConstArrayAttr(context, reader);
578 case 15:
579 return readConstRecordAttr(context, reader);
580 case 16:
581 return readVTableAttr(context, reader);
582 case 17:
583 return readBlockAddrDiffAttr(context, reader);
584 case 18:
585 return readCXXCtorAttr(context, reader);
586 case 19:
587 return readCXXDtorAttr(context, reader);
588 case 20:
589 return readCXXAssignAttr(context, reader);
590 case 21:
591 return readGlobalViewAttr(context, reader);
592 case 22:
593 return readTypeInfoAttr(context, reader);
594 case 23:
595 return readDynamicCastInfoAttr(context, reader);
596 case 24:
597 return readConstVectorAttr(context, reader);
598 case 25:
599 return readConstComplexAttr(context, reader);
600 case 26:
601 return readDataMemberAttr(context, reader);
602 case 27:
603 return readMethodAttr(context, reader);
604 case 28:
605 return readBitFieldDeclAttr(context, reader);
606 default:
607 reader.emitError() << "unknown attribute code: " << kind;
608 return ::mlir::Attribute();
609 }
610 return ::mlir::Attribute();
611}
612
613static ::llvm::LogicalResult writeAttribute(::mlir::Attribute attribute,
614 ::mlir::DialectBytecodeWriter &writer) {
615 return ::llvm::TypeSwitch<::mlir::Attribute, ::llvm::LogicalResult>(attribute)
616 .Case(caseFn: [&](::cir::BoolAttr t) {
617 return write(attribute: t, writer);
618 })
619 .Case(caseFn: [&](AddressPointAttr t) {
620 return write(attribute: t, writer);
621 })
622 .Case(caseFn: [&](BitFieldDeclAttr t) {
623 return write(attribute: t, writer);
624 })
625 .Case(caseFn: [&](BitfieldInfoAttr t) {
626 return write(attribute: t, writer);
627 })
628 .Case(caseFn: [&](BlockAddrDiffAttr t) {
629 return write(attribute: t, writer);
630 })
631 .Case(caseFn: [&](BlockAddrInfoAttr t) {
632 return write(attribute: t, writer);
633 })
634 .Case(caseFn: [&](CXXAssignAttr t) {
635 return write(attribute: t, writer);
636 })
637 .Case(caseFn: [&](CXXCtorAttr t) {
638 return write(attribute: t, writer);
639 })
640 .Case(caseFn: [&](CXXDtorAttr t) {
641 return write(attribute: t, writer);
642 })
643 .Case(caseFn: [&](CatchAllAttr t) {
644 return write(attribute: t, writer);
645 })
646 .Case(caseFn: [&](ConstArrayAttr t) {
647 return write(attribute: t, writer);
648 })
649 .Case(caseFn: [&](ConstComplexAttr t) {
650 return write(attribute: t, writer);
651 })
652 .Case(caseFn: [&](ConstPtrAttr t) {
653 return write(attribute: t, writer);
654 })
655 .Case(caseFn: [&](ConstRecordAttr t) {
656 return write(attribute: t, writer);
657 })
658 .Case(caseFn: [&](ConstVectorAttr t) {
659 return write(attribute: t, writer);
660 })
661 .Case(caseFn: [&](DataMemberAttr t) {
662 return write(attribute: t, writer);
663 })
664 .Case(caseFn: [&](DynamicCastInfoAttr t) {
665 return write(attribute: t, writer);
666 })
667 .Case(caseFn: [&](FPAttr t) {
668 return write(attribute: t, writer);
669 })
670 .Case(caseFn: [&](GlobalViewAttr t) {
671 return write(attribute: t, writer);
672 })
673 .Case(caseFn: [&](IntAttr t) {
674 return write(attribute: t, writer);
675 })
676 .Case(caseFn: [&](MethodAttr t) {
677 return write(attribute: t, writer);
678 })
679 .Case(caseFn: [&](OpenCLVersionAttr t) {
680 return write(attribute: t, writer);
681 })
682 .Case(caseFn: [&](OptInfoAttr t) {
683 return write(attribute: t, writer);
684 })
685 .Case(caseFn: [&](PoisonAttr t) {
686 return write(attribute: t, writer);
687 })
688 .Case(caseFn: [&](TypeInfoAttr t) {
689 return write(attribute: t, writer);
690 })
691 .Case(caseFn: [&](UndefAttr t) {
692 return write(attribute: t, writer);
693 })
694 .Case(caseFn: [&](UnwindAttr t) {
695 return write(attribute: t, writer);
696 })
697 .Case(caseFn: [&](VTableAttr t) {
698 return write(attribute: t, writer);
699 })
700 .Case(caseFn: [&](ZeroAttr t) {
701 return write(attribute: t, writer);
702 })
703 .Default(defaultFn: [&](::mlir::Attribute) { return ::mlir::failure(); });
704}
705
706static ::mlir::Type readComplexType(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
707 ::mlir::Type elementType;
708 if (::mlir::succeeded(Result: reader.readType(result&: elementType))) {
709 return ::cir::ComplexType::getChecked(emitError: [&]() { return reader.emitError(); }, context, elementType);
710 }
711 return ::cir::ComplexType();
712}
713
714static ::llvm::LogicalResult write(::cir::ComplexType type, ::mlir::DialectBytecodeWriter &writer) {
715 writer.writeVarInt(/* ComplexType */ value: 13);
716 writer.writeType(type: type.getElementType());
717 return ::mlir::success();
718 return ::mlir::failure();
719}
720
721static ::mlir::Type readVectorType(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
722 ::mlir::Type element_type;
723 unsigned size;
724 bool scalable;
725 if (::mlir::succeeded(Result: reader.readType(result&: element_type)) &&
726 succeeded(Result: readCheckedInt(reader, result&: size)) &&
727 ::mlir::succeeded(Result: reader.readBool(result&: scalable))) {
728 return ::cir::VectorType::getChecked(emitError: [&]() { return reader.emitError(); }, element_type, size: llvm::ElementCount::get(MinVal: size, Scalable: scalable));
729 }
730 return ::cir::VectorType();
731}
732
733static ::llvm::LogicalResult write(::cir::VectorType type, ::mlir::DialectBytecodeWriter &writer) {
734 writer.writeVarInt(/* VectorType */ value: 15);
735 writer.writeType(type: type.getElementType());
736 writer.writeVarInt(value: type.getSize().getKnownMinValue());
737 writer.writeOwnedBool(value: type.isScalable());
738 return ::mlir::success();
739 return ::mlir::failure();
740}
741
742static ::mlir::Type readArrayType(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
743 ::mlir::Type elementType;
744 uint64_t size;
745 if (::mlir::succeeded(Result: reader.readType(result&: elementType)) &&
746 ::mlir::succeeded(Result: reader.readVarInt(result&: size))) {
747 return ArrayType::getChecked(emitError: [&]() { return reader.emitError(); }, context, elementType, size);
748 }
749 return ArrayType();
750}
751
752static ::llvm::LogicalResult write(ArrayType type, ::mlir::DialectBytecodeWriter &writer) {
753 writer.writeVarInt(/* ArrayType */ value: 12);
754 writer.writeType(type: type.getElementType());
755 writer.writeVarInt(value: type.getSize());
756 return ::mlir::success();
757 return ::mlir::failure();
758}
759
760static ::mlir::Type readBF16Type(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
761 return ::mlir::getChecked<BF16Type>(emitError: [&]() { return reader.emitError(); }, context);
762}
763
764static ::llvm::LogicalResult write(BF16Type type, ::mlir::DialectBytecodeWriter &writer) {
765 writer.writeVarInt(/* BF16Type */ value: 4);
766 return ::mlir::success();
767 return ::mlir::failure();
768}
769
770static ::mlir::Type readBitFieldType(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
771 mlir::Type storage_type;
772 ::llvm::SmallVector<cir::BitFieldDeclAttr> fields;
773 auto readFields = [&]() -> ::mlir::FailureOr<cir::BitFieldDeclAttr> {
774 cir::BitFieldDeclAttr temp;
775 if (::mlir::succeeded(Result: reader.readAttribute(result&: temp))) {
776 return temp;
777 }
778 return ::mlir::failure();
779 };
780 if (succeeded(Result: readOptionalType(reader, result&: storage_type)) &&
781 ::mlir::succeeded(Result: reader.readList(result&: fields, callback&: readFields))) {
782 return BitFieldType::getChecked(emitError: [&]() { return reader.emitError(); }, context, storage_type, fields: llvm::ArrayRef<cir::BitFieldDeclAttr>(fields));
783 }
784 return BitFieldType();
785}
786
787static ::llvm::LogicalResult write(BitFieldType type, ::mlir::DialectBytecodeWriter &writer) {
788 writer.writeVarInt(/* BitFieldType */ value: 19);
789 writeOptionalType(writer, type: type.getStorageType());
790 writer.writeList(range: type.getFields(), callback: [&](cir::BitFieldDeclAttr type) {
791 writer.writeAttribute(attr: type);
792 });
793 return ::mlir::success();
794 return ::mlir::failure();
795}
796
797static ::mlir::Type readBoolType(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
798 return ::mlir::getChecked<BoolType>(emitError: [&]() { return reader.emitError(); }, context);
799}
800
801static ::llvm::LogicalResult write(BoolType type, ::mlir::DialectBytecodeWriter &writer) {
802 writer.writeVarInt(/* BoolType */ value: 8);
803 return ::mlir::success();
804 return ::mlir::failure();
805}
806
807static ::mlir::Type readCUDADeviceSurfaceType(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
808 return ::mlir::getChecked<CUDADeviceSurfaceType>(emitError: [&]() { return reader.emitError(); }, context);
809}
810
811static ::llvm::LogicalResult write(CUDADeviceSurfaceType type, ::mlir::DialectBytecodeWriter &writer) {
812 writer.writeVarInt(/* CUDADeviceSurfaceType */ value: 20);
813 return ::mlir::success();
814 return ::mlir::failure();
815}
816
817static ::mlir::Type readCUDADeviceTextureType(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
818 return ::mlir::getChecked<CUDADeviceTextureType>(emitError: [&]() { return reader.emitError(); }, context);
819}
820
821static ::llvm::LogicalResult write(CUDADeviceTextureType type, ::mlir::DialectBytecodeWriter &writer) {
822 writer.writeVarInt(/* CUDADeviceTextureType */ value: 21);
823 return ::mlir::success();
824 return ::mlir::failure();
825}
826
827static ::mlir::Type readCatchTokenType(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
828 return ::mlir::getChecked<CatchTokenType>(emitError: [&]() { return reader.emitError(); }, context);
829}
830
831static ::llvm::LogicalResult write(CatchTokenType type, ::mlir::DialectBytecodeWriter &writer) {
832 writer.writeVarInt(/* CatchTokenType */ value: 24);
833 return ::mlir::success();
834 return ::mlir::failure();
835}
836
837static ::mlir::Type readCleanupTokenType(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
838 return ::mlir::getChecked<CleanupTokenType>(emitError: [&]() { return reader.emitError(); }, context);
839}
840
841static ::llvm::LogicalResult write(CleanupTokenType type, ::mlir::DialectBytecodeWriter &writer) {
842 writer.writeVarInt(/* CleanupTokenType */ value: 23);
843 return ::mlir::success();
844 return ::mlir::failure();
845}
846
847static ::mlir::Type readDataMemberType(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
848 ::mlir::Type member_ty;
849 cir::RecordType class_ty;
850 if (::mlir::succeeded(Result: reader.readType(result&: member_ty)) &&
851 ::mlir::succeeded(Result: reader.readType(result&: class_ty))) {
852 return DataMemberType::getChecked(emitError: [&]() { return reader.emitError(); }, context, member_ty, class_ty);
853 }
854 return DataMemberType();
855}
856
857static ::llvm::LogicalResult write(DataMemberType type, ::mlir::DialectBytecodeWriter &writer) {
858 writer.writeVarInt(/* DataMemberType */ value: 17);
859 writer.writeType(type: type.getMemberTy());
860 writer.writeType(type: type.getClassTy());
861 return ::mlir::success();
862 return ::mlir::failure();
863}
864
865static ::mlir::Type readDoubleType(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
866 return ::mlir::getChecked<DoubleType>(emitError: [&]() { return reader.emitError(); }, context);
867}
868
869static ::llvm::LogicalResult write(DoubleType type, ::mlir::DialectBytecodeWriter &writer) {
870 writer.writeVarInt(/* DoubleType */ value: 2);
871 return ::mlir::success();
872 return ::mlir::failure();
873}
874
875static ::mlir::Type readEhTokenType(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
876 return ::mlir::getChecked<EhTokenType>(emitError: [&]() { return reader.emitError(); }, context);
877}
878
879static ::llvm::LogicalResult write(EhTokenType type, ::mlir::DialectBytecodeWriter &writer) {
880 writer.writeVarInt(/* EhTokenType */ value: 22);
881 return ::mlir::success();
882 return ::mlir::failure();
883}
884
885static ::mlir::Type readFP128Type(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
886 return ::mlir::getChecked<FP128Type>(emitError: [&]() { return reader.emitError(); }, context);
887}
888
889static ::llvm::LogicalResult write(FP128Type type, ::mlir::DialectBytecodeWriter &writer) {
890 writer.writeVarInt(/* FP128Type */ value: 6);
891 return ::mlir::success();
892 return ::mlir::failure();
893}
894
895static ::mlir::Type readFP16Type(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
896 return ::mlir::getChecked<FP16Type>(emitError: [&]() { return reader.emitError(); }, context);
897}
898
899static ::llvm::LogicalResult write(FP16Type type, ::mlir::DialectBytecodeWriter &writer) {
900 writer.writeVarInt(/* FP16Type */ value: 3);
901 return ::mlir::success();
902 return ::mlir::failure();
903}
904
905static ::mlir::Type readFP80Type(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
906 return ::mlir::getChecked<FP80Type>(emitError: [&]() { return reader.emitError(); }, context);
907}
908
909static ::llvm::LogicalResult write(FP80Type type, ::mlir::DialectBytecodeWriter &writer) {
910 writer.writeVarInt(/* FP80Type */ value: 5);
911 return ::mlir::success();
912 return ::mlir::failure();
913}
914
915static ::mlir::Type readFuncType(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
916 ::llvm::SmallVector<::mlir::Type> inputs;
917 mlir::Type optionalReturnType;
918 bool varArg;
919 if (::mlir::succeeded(Result: reader.readTypes(types&: inputs)) &&
920 succeeded(Result: readOptionalType(reader, result&: optionalReturnType)) &&
921 ::mlir::succeeded(Result: reader.readBool(result&: varArg))) {
922 return FuncType::getChecked(emitError: [&]() { return reader.emitError(); }, context, inputs: llvm::ArrayRef<mlir::Type>(inputs), optionalReturnType, varArg);
923 }
924 return FuncType();
925}
926
927static ::llvm::LogicalResult write(FuncType type, ::mlir::DialectBytecodeWriter &writer) {
928 writer.writeVarInt(/* FuncType */ value: 14);
929 writer.writeTypes(types: type.getInputs());
930 writeOptionalType(writer, type: type.getOptionalReturnType());
931 writer.writeOwnedBool(value: type.getVarArg());
932 return ::mlir::success();
933 return ::mlir::failure();
934}
935
936static ::mlir::Type readIntType(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
937 unsigned width;
938 bool is_signed, is_bit_int;
939 if (succeeded(Result: readCheckedInt(reader, result&: width)) &&
940 ::mlir::succeeded(Result: reader.readBool(result&: is_signed)) &&
941 ::mlir::succeeded(Result: reader.readBool(result&: is_bit_int))) {
942 return IntType::getChecked(emitError: [&]() { return reader.emitError(); }, context, width, is_signed, is_bit_int);
943 }
944 return IntType();
945}
946
947static ::llvm::LogicalResult write(IntType type, ::mlir::DialectBytecodeWriter &writer) {
948 writer.writeVarInt(/* IntType */ value: 0);
949 writer.writeVarInt(value: type.getWidth());
950 writer.writeOwnedBool(value: type.getIsSigned());
951 writer.writeOwnedBool(value: type.getIsBitInt());
952 return ::mlir::success();
953 return ::mlir::failure();
954}
955
956static ::mlir::Type readLongDoubleType(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
957 ::mlir::Type underlying;
958 if (::mlir::succeeded(Result: reader.readType(result&: underlying))) {
959 return LongDoubleType::getChecked(emitError: [&]() { return reader.emitError(); }, context, underlying);
960 }
961 return LongDoubleType();
962}
963
964static ::llvm::LogicalResult write(LongDoubleType type, ::mlir::DialectBytecodeWriter &writer) {
965 writer.writeVarInt(/* LongDoubleType */ value: 7);
966 writer.writeType(type: type.getUnderlying());
967 return ::mlir::success();
968 return ::mlir::failure();
969}
970
971static ::mlir::Type readMatrixType(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
972 ::mlir::Type element_type;
973 uint64_t num_rows, num_columns;
974 if (::mlir::succeeded(Result: reader.readType(result&: element_type)) &&
975 ::mlir::succeeded(Result: reader.readVarInt(result&: num_rows)) &&
976 ::mlir::succeeded(Result: reader.readVarInt(result&: num_columns))) {
977 return MatrixType::getChecked(emitError: [&]() { return reader.emitError(); }, context, element_type, num_rows, num_columns);
978 }
979 return MatrixType();
980}
981
982static ::llvm::LogicalResult write(MatrixType type, ::mlir::DialectBytecodeWriter &writer) {
983 writer.writeVarInt(/* MatrixType */ value: 16);
984 writer.writeType(type: type.getElementType());
985 writer.writeVarInt(value: type.getNumRows());
986 writer.writeVarInt(value: type.getNumColumns());
987 return ::mlir::success();
988 return ::mlir::failure();
989}
990
991static ::mlir::Type readMethodType(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
992 cir::FuncType member_func_ty;
993 cir::RecordType class_ty;
994 if (::mlir::succeeded(Result: reader.readType(result&: member_func_ty)) &&
995 ::mlir::succeeded(Result: reader.readType(result&: class_ty))) {
996 return ::mlir::getChecked<MethodType>(emitError: [&]() { return reader.emitError(); }, context, params&: member_func_ty, params&: class_ty);
997 }
998 return MethodType();
999}
1000
1001static ::llvm::LogicalResult write(MethodType type, ::mlir::DialectBytecodeWriter &writer) {
1002 writer.writeVarInt(/* MethodType */ value: 18);
1003 writer.writeType(type: type.getMemberFuncTy());
1004 writer.writeType(type: type.getClassTy());
1005 return ::mlir::success();
1006 return ::mlir::failure();
1007}
1008
1009static ::mlir::Type readPointerType(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
1010 ::mlir::Type pointee;
1011 mlir::ptr::MemorySpaceAttrInterface addrSpace;
1012 if (::mlir::succeeded(Result: reader.readType(result&: pointee)) &&
1013 succeeded(Result: reader.readOptionalAttribute(result&: addrSpace))) {
1014 return PointerType::getChecked(emitError: [&]() { return reader.emitError(); }, context, pointee, addrSpace);
1015 }
1016 return PointerType();
1017}
1018
1019static ::llvm::LogicalResult write(PointerType type, ::mlir::DialectBytecodeWriter &writer) {
1020 writer.writeVarInt(/* PointerType */ value: 11);
1021 writer.writeType(type: type.getPointee());
1022 writer.writeOptionalAttribute(attr: type.getAddrSpace());
1023 return ::mlir::success();
1024 return ::mlir::failure();
1025}
1026
1027static ::mlir::Type readSingleType(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
1028 return ::mlir::getChecked<SingleType>(emitError: [&]() { return reader.emitError(); }, context);
1029}
1030
1031static ::llvm::LogicalResult write(SingleType type, ::mlir::DialectBytecodeWriter &writer) {
1032 writer.writeVarInt(/* SingleType */ value: 1);
1033 return ::mlir::success();
1034 return ::mlir::failure();
1035}
1036
1037static ::mlir::Type readVPtrType(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
1038 return ::mlir::getChecked<VPtrType>(emitError: [&]() { return reader.emitError(); }, context);
1039}
1040
1041static ::llvm::LogicalResult write(VPtrType type, ::mlir::DialectBytecodeWriter &writer) {
1042 writer.writeVarInt(/* VPtrType */ value: 10);
1043 return ::mlir::success();
1044 return ::mlir::failure();
1045}
1046
1047static ::mlir::Type readVoidType(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
1048 return ::mlir::getChecked<VoidType>(emitError: [&]() { return reader.emitError(); }, context);
1049}
1050
1051static ::llvm::LogicalResult write(VoidType type, ::mlir::DialectBytecodeWriter &writer) {
1052 writer.writeVarInt(/* VoidType */ value: 9);
1053 return ::mlir::success();
1054 return ::mlir::failure();
1055}
1056
1057static ::mlir::Type readType(::mlir::MLIRContext* context, ::mlir::DialectBytecodeReader &reader) {
1058 uint64_t kind;
1059 if (::mlir::failed(Result: reader.readVarInt(result&: kind)))
1060 return ::mlir::Type();
1061 switch (kind) {
1062 case 0:
1063 return readIntType(context, reader);
1064 case 1:
1065 return readSingleType(context, reader);
1066 case 2:
1067 return readDoubleType(context, reader);
1068 case 3:
1069 return readFP16Type(context, reader);
1070 case 4:
1071 return readBF16Type(context, reader);
1072 case 5:
1073 return readFP80Type(context, reader);
1074 case 6:
1075 return readFP128Type(context, reader);
1076 case 7:
1077 return readLongDoubleType(context, reader);
1078 case 8:
1079 return readBoolType(context, reader);
1080 case 9:
1081 return readVoidType(context, reader);
1082 case 10:
1083 return readVPtrType(context, reader);
1084 case 11:
1085 return readPointerType(context, reader);
1086 case 12:
1087 return readArrayType(context, reader);
1088 case 13:
1089 return readComplexType(context, reader);
1090 case 14:
1091 return readFuncType(context, reader);
1092 case 15:
1093 return readVectorType(context, reader);
1094 case 16:
1095 return readMatrixType(context, reader);
1096 case 17:
1097 return readDataMemberType(context, reader);
1098 case 18:
1099 return readMethodType(context, reader);
1100 case 19:
1101 return readBitFieldType(context, reader);
1102 case 20:
1103 return readCUDADeviceSurfaceType(context, reader);
1104 case 21:
1105 return readCUDADeviceTextureType(context, reader);
1106 case 22:
1107 return readEhTokenType(context, reader);
1108 case 23:
1109 return readCleanupTokenType(context, reader);
1110 case 24:
1111 return readCatchTokenType(context, reader);
1112 default:
1113 reader.emitError() << "unknown type code: " << kind;
1114 return ::mlir::Type();
1115 }
1116 return ::mlir::Type();
1117}
1118
1119static ::llvm::LogicalResult writeType(::mlir::Type type,
1120 ::mlir::DialectBytecodeWriter &writer) {
1121 return ::llvm::TypeSwitch<::mlir::Type, ::llvm::LogicalResult>(type)
1122 .Case(caseFn: [&](::cir::ComplexType t) {
1123 return write(type: t, writer);
1124 })
1125 .Case(caseFn: [&](::cir::VectorType t) {
1126 return write(type: t, writer);
1127 })
1128 .Case(caseFn: [&](ArrayType t) {
1129 return write(type: t, writer);
1130 })
1131 .Case(caseFn: [&](BF16Type t) {
1132 return write(type: t, writer);
1133 })
1134 .Case(caseFn: [&](BitFieldType t) {
1135 return write(type: t, writer);
1136 })
1137 .Case(caseFn: [&](BoolType t) {
1138 return write(type: t, writer);
1139 })
1140 .Case(caseFn: [&](CUDADeviceSurfaceType t) {
1141 return write(type: t, writer);
1142 })
1143 .Case(caseFn: [&](CUDADeviceTextureType t) {
1144 return write(type: t, writer);
1145 })
1146 .Case(caseFn: [&](CatchTokenType t) {
1147 return write(type: t, writer);
1148 })
1149 .Case(caseFn: [&](CleanupTokenType t) {
1150 return write(type: t, writer);
1151 })
1152 .Case(caseFn: [&](DataMemberType t) {
1153 return write(type: t, writer);
1154 })
1155 .Case(caseFn: [&](DoubleType t) {
1156 return write(type: t, writer);
1157 })
1158 .Case(caseFn: [&](EhTokenType t) {
1159 return write(type: t, writer);
1160 })
1161 .Case(caseFn: [&](FP128Type t) {
1162 return write(type: t, writer);
1163 })
1164 .Case(caseFn: [&](FP16Type t) {
1165 return write(type: t, writer);
1166 })
1167 .Case(caseFn: [&](FP80Type t) {
1168 return write(type: t, writer);
1169 })
1170 .Case(caseFn: [&](FuncType t) {
1171 return write(type: t, writer);
1172 })
1173 .Case(caseFn: [&](IntType t) {
1174 return write(type: t, writer);
1175 })
1176 .Case(caseFn: [&](LongDoubleType t) {
1177 return write(type: t, writer);
1178 })
1179 .Case(caseFn: [&](MatrixType t) {
1180 return write(type: t, writer);
1181 })
1182 .Case(caseFn: [&](MethodType t) {
1183 return write(type: t, writer);
1184 })
1185 .Case(caseFn: [&](PointerType t) {
1186 return write(type: t, writer);
1187 })
1188 .Case(caseFn: [&](SingleType t) {
1189 return write(type: t, writer);
1190 })
1191 .Case(caseFn: [&](VPtrType t) {
1192 return write(type: t, writer);
1193 })
1194 .Case(caseFn: [&](VoidType t) {
1195 return write(type: t, writer);
1196 })
1197 .Default(defaultFn: [&](::mlir::Type) { return ::mlir::failure(); });
1198}
1199
1200