LLVM 22.0.0git
WasmYAML.cpp
Go to the documentation of this file.
1//===- WasmYAML.cpp - Wasm YAMLIO implementation --------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines classes for handling the YAML representation of wasm.
10//
11//===----------------------------------------------------------------------===//
12
14#include "llvm/ADT/StringRef.h"
19
20namespace llvm {
21
22namespace WasmYAML {
23
24// Declared here rather than in the header to comply with:
25// http://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-for-classes-in-headers
26Section::~Section() = default;
27
28} // end namespace WasmYAML
29
30namespace yaml {
31
33 IO &IO, WasmYAML::FileHeader &FileHdr) {
34 IO.mapRequired("Version", FileHdr.Version);
35}
36
38 WasmYAML::Object &Object) {
39 IO.setContext(&Object);
40 IO.mapTag("!WASM", true);
41 IO.mapRequired("FileHeader", Object.Header);
42 IO.mapOptional("Sections", Object.Sections);
43 IO.setContext(nullptr);
44}
45
46static void commonSectionMapping(IO &IO, WasmYAML::Section &Section) {
47 IO.mapRequired("Type", Section.Type);
48 IO.mapOptional("Relocations", Section.Relocations);
49 IO.mapOptional("HeaderSecSizeEncodingLen", Section.HeaderSecSizeEncodingLen);
50}
51
52static void sectionMapping(IO &IO, WasmYAML::DylinkSection &Section) {
53 commonSectionMapping(IO, Section);
54 IO.mapRequired("Name", Section.Name);
55 IO.mapRequired("MemorySize", Section.MemorySize);
56 IO.mapRequired("MemoryAlignment", Section.MemoryAlignment);
57 IO.mapRequired("TableSize", Section.TableSize);
58 IO.mapRequired("TableAlignment", Section.TableAlignment);
59 IO.mapRequired("Needed", Section.Needed);
60 IO.mapOptional("ImportInfo", Section.ImportInfo);
61 IO.mapOptional("ExportInfo", Section.ExportInfo);
62 IO.mapOptional("RuntimePath", Section.RuntimePath);
63}
64
65static void sectionMapping(IO &IO, WasmYAML::NameSection &Section) {
66 commonSectionMapping(IO, Section);
67 IO.mapRequired("Name", Section.Name);
68 IO.mapOptional("FunctionNames", Section.FunctionNames);
69 IO.mapOptional("GlobalNames", Section.GlobalNames);
70 IO.mapOptional("DataSegmentNames", Section.DataSegmentNames);
71}
72
73static void sectionMapping(IO &IO, WasmYAML::LinkingSection &Section) {
74 commonSectionMapping(IO, Section);
75 IO.mapRequired("Name", Section.Name);
76 IO.mapRequired("Version", Section.Version);
77 IO.mapOptional("SymbolTable", Section.SymbolTable);
78 IO.mapOptional("SegmentInfo", Section.SegmentInfos);
79 IO.mapOptional("InitFunctions", Section.InitFunctions);
80 IO.mapOptional("Comdats", Section.Comdats);
81}
82
83static void sectionMapping(IO &IO, WasmYAML::ProducersSection &Section) {
84 commonSectionMapping(IO, Section);
85 IO.mapRequired("Name", Section.Name);
86 IO.mapOptional("Languages", Section.Languages);
87 IO.mapOptional("Tools", Section.Tools);
88 IO.mapOptional("SDKs", Section.SDKs);
89}
90
91static void sectionMapping(IO &IO, WasmYAML::TargetFeaturesSection &Section) {
92 commonSectionMapping(IO, Section);
93 IO.mapRequired("Name", Section.Name);
94 IO.mapRequired("Features", Section.Features);
95}
96
97static void sectionMapping(IO &IO, WasmYAML::CustomSection &Section) {
98 commonSectionMapping(IO, Section);
99 IO.mapRequired("Name", Section.Name);
100 IO.mapRequired("Payload", Section.Payload);
101}
102
103static void sectionMapping(IO &IO, WasmYAML::TypeSection &Section) {
104 commonSectionMapping(IO, Section);
105 IO.mapOptional("Signatures", Section.Signatures);
106}
107
108static void sectionMapping(IO &IO, WasmYAML::ImportSection &Section) {
109 commonSectionMapping(IO, Section);
110 IO.mapOptional("Imports", Section.Imports);
111}
112
113static void sectionMapping(IO &IO, WasmYAML::FunctionSection &Section) {
114 commonSectionMapping(IO, Section);
115 IO.mapOptional("FunctionTypes", Section.FunctionTypes);
116}
117
118static void sectionMapping(IO &IO, WasmYAML::TableSection &Section) {
119 commonSectionMapping(IO, Section);
120 IO.mapOptional("Tables", Section.Tables);
121}
122
123static void sectionMapping(IO &IO, WasmYAML::MemorySection &Section) {
124 commonSectionMapping(IO, Section);
125 IO.mapOptional("Memories", Section.Memories);
126}
127
128static void sectionMapping(IO &IO, WasmYAML::TagSection &Section) {
129 commonSectionMapping(IO, Section);
130 IO.mapOptional("TagTypes", Section.TagTypes);
131}
132
133static void sectionMapping(IO &IO, WasmYAML::GlobalSection &Section) {
134 commonSectionMapping(IO, Section);
135 IO.mapOptional("Globals", Section.Globals);
136}
137
138static void sectionMapping(IO &IO, WasmYAML::ExportSection &Section) {
139 commonSectionMapping(IO, Section);
140 IO.mapOptional("Exports", Section.Exports);
141}
142
143static void sectionMapping(IO &IO, WasmYAML::StartSection &Section) {
144 commonSectionMapping(IO, Section);
145 IO.mapOptional("StartFunction", Section.StartFunction);
146}
147
148static void sectionMapping(IO &IO, WasmYAML::ElemSection &Section) {
149 commonSectionMapping(IO, Section);
150 IO.mapOptional("Segments", Section.Segments);
151}
152
153static void sectionMapping(IO &IO, WasmYAML::CodeSection &Section) {
154 commonSectionMapping(IO, Section);
155 IO.mapRequired("Functions", Section.Functions);
156}
157
158static void sectionMapping(IO &IO, WasmYAML::DataSection &Section) {
159 commonSectionMapping(IO, Section);
160 IO.mapRequired("Segments", Section.Segments);
161}
162
163static void sectionMapping(IO &IO, WasmYAML::DataCountSection &Section) {
164 commonSectionMapping(IO, Section);
165 IO.mapRequired("Count", Section.Count);
166}
167
169 IO &IO, std::unique_ptr<WasmYAML::Section> &Section) {
170 WasmYAML::SectionType SectionType;
171 if (IO.outputting())
172 SectionType = Section->Type;
173 else
174 IO.mapRequired("Type", SectionType);
175
176 switch (SectionType) {
179 if (IO.outputting()) {
180 auto CustomSection = cast<WasmYAML::CustomSection>(Section.get());
181 SectionName = CustomSection->Name;
182 } else {
183 IO.mapRequired("Name", SectionName);
184 }
185 if (SectionName == "dylink" || SectionName == "dylink.0") {
186 if (!IO.outputting())
187 Section.reset(new WasmYAML::DylinkSection());
188 sectionMapping(IO, *cast<WasmYAML::DylinkSection>(Section.get()));
189 } else if (SectionName == "linking") {
190 if (!IO.outputting())
191 Section.reset(new WasmYAML::LinkingSection());
192 sectionMapping(IO, *cast<WasmYAML::LinkingSection>(Section.get()));
193 } else if (SectionName == "name") {
194 if (!IO.outputting())
195 Section.reset(new WasmYAML::NameSection());
196 sectionMapping(IO, *cast<WasmYAML::NameSection>(Section.get()));
197 } else if (SectionName == "producers") {
198 if (!IO.outputting())
199 Section.reset(new WasmYAML::ProducersSection());
200 sectionMapping(IO, *cast<WasmYAML::ProducersSection>(Section.get()));
201 } else if (SectionName == "target_features") {
202 if (!IO.outputting())
203 Section.reset(new WasmYAML::TargetFeaturesSection());
204 sectionMapping(IO, *cast<WasmYAML::TargetFeaturesSection>(Section.get()));
205 } else {
206 if (!IO.outputting())
207 Section.reset(new WasmYAML::CustomSection(SectionName));
208 sectionMapping(IO, *cast<WasmYAML::CustomSection>(Section.get()));
209 }
210 break;
211 }
213 if (!IO.outputting())
214 Section.reset(new WasmYAML::TypeSection());
215 sectionMapping(IO, *cast<WasmYAML::TypeSection>(Section.get()));
216 break;
218 if (!IO.outputting())
219 Section.reset(new WasmYAML::ImportSection());
220 sectionMapping(IO, *cast<WasmYAML::ImportSection>(Section.get()));
221 break;
223 if (!IO.outputting())
224 Section.reset(new WasmYAML::FunctionSection());
225 sectionMapping(IO, *cast<WasmYAML::FunctionSection>(Section.get()));
226 break;
228 if (!IO.outputting())
229 Section.reset(new WasmYAML::TableSection());
230 sectionMapping(IO, *cast<WasmYAML::TableSection>(Section.get()));
231 break;
233 if (!IO.outputting())
234 Section.reset(new WasmYAML::MemorySection());
235 sectionMapping(IO, *cast<WasmYAML::MemorySection>(Section.get()));
236 break;
238 if (!IO.outputting())
239 Section.reset(new WasmYAML::TagSection());
240 sectionMapping(IO, *cast<WasmYAML::TagSection>(Section.get()));
241 break;
243 if (!IO.outputting())
244 Section.reset(new WasmYAML::GlobalSection());
245 sectionMapping(IO, *cast<WasmYAML::GlobalSection>(Section.get()));
246 break;
248 if (!IO.outputting())
249 Section.reset(new WasmYAML::ExportSection());
250 sectionMapping(IO, *cast<WasmYAML::ExportSection>(Section.get()));
251 break;
253 if (!IO.outputting())
254 Section.reset(new WasmYAML::StartSection());
255 sectionMapping(IO, *cast<WasmYAML::StartSection>(Section.get()));
256 break;
258 if (!IO.outputting())
259 Section.reset(new WasmYAML::ElemSection());
260 sectionMapping(IO, *cast<WasmYAML::ElemSection>(Section.get()));
261 break;
263 if (!IO.outputting())
264 Section.reset(new WasmYAML::CodeSection());
265 sectionMapping(IO, *cast<WasmYAML::CodeSection>(Section.get()));
266 break;
268 if (!IO.outputting())
269 Section.reset(new WasmYAML::DataSection());
270 sectionMapping(IO, *cast<WasmYAML::DataSection>(Section.get()));
271 break;
273 if (!IO.outputting())
274 Section.reset(new WasmYAML::DataCountSection());
275 sectionMapping(IO, *cast<WasmYAML::DataCountSection>(Section.get()));
276 break;
277 default:
278 llvm_unreachable("Unknown section type");
279 }
280}
281
282void ScalarEnumerationTraits<WasmYAML::SectionType>::enumeration(
283 IO &IO, WasmYAML::SectionType &Type) {
284#define ECase(X) IO.enumCase(Type, #X, wasm::WASM_SEC_##X);
285 ECase(CUSTOM);
286 ECase(TYPE);
287 ECase(IMPORT);
289 ECase(TABLE);
290 ECase(MEMORY);
291 ECase(GLOBAL);
292 ECase(TAG);
293 ECase(EXPORT);
294 ECase(START);
295 ECase(ELEM);
296 ECase(CODE);
297 ECase(DATA);
298 ECase(DATACOUNT);
299#undef ECase
300}
301
303 IO &IO, WasmYAML::Signature &Signature) {
304 IO.mapRequired("Index", Signature.Index);
305 IO.mapRequired("ParamTypes", Signature.ParamTypes);
306 IO.mapRequired("ReturnTypes", Signature.ReturnTypes);
307}
308
310 IO.mapRequired("Index", Table.Index);
311 IO.mapRequired("ElemType", Table.ElemType);
312 IO.mapRequired("Limits", Table.TableLimits);
313}
314
317 IO.mapRequired("Index", Function.Index);
318 IO.mapRequired("Locals", Function.Locals);
319 IO.mapRequired("Body", Function.Body);
320}
321
323 IO &IO, WasmYAML::Relocation &Relocation) {
324 IO.mapRequired("Type", Relocation.Type);
325 IO.mapRequired("Index", Relocation.Index);
326 IO.mapRequired("Offset", Relocation.Offset);
327 IO.mapOptional("Addend", Relocation.Addend, 0);
328}
329
331 IO &IO, WasmYAML::NameEntry &NameEntry) {
332 IO.mapRequired("Index", NameEntry.Index);
333 IO.mapRequired("Name", NameEntry.Name);
334}
335
337 IO &IO, WasmYAML::ProducerEntry &ProducerEntry) {
338 IO.mapRequired("Name", ProducerEntry.Name);
339 IO.mapRequired("Version", ProducerEntry.Version);
340}
341
342void ScalarEnumerationTraits<WasmYAML::FeaturePolicyPrefix>::enumeration(
343 IO &IO, WasmYAML::FeaturePolicyPrefix &Kind) {
344#define ECase(X) IO.enumCase(Kind, #X, wasm::WASM_FEATURE_PREFIX_##X);
345 ECase(USED);
346 ECase(DISALLOWED);
347#undef ECase
348}
349
351 IO &IO, WasmYAML::FeatureEntry &FeatureEntry) {
352 IO.mapRequired("Prefix", FeatureEntry.Prefix);
353 IO.mapRequired("Name", FeatureEntry.Name);
354}
355
357 IO &IO, WasmYAML::SegmentInfo &SegmentInfo) {
358 IO.mapRequired("Index", SegmentInfo.Index);
359 IO.mapRequired("Name", SegmentInfo.Name);
360 IO.mapRequired("Alignment", SegmentInfo.Alignment);
361 IO.mapRequired("Flags", SegmentInfo.Flags);
362}
363
365 IO &IO, WasmYAML::LocalDecl &LocalDecl) {
366 IO.mapRequired("Type", LocalDecl.Type);
367 IO.mapRequired("Count", LocalDecl.Count);
368}
369
371 WasmYAML::Limits &Limits) {
372 IO.mapOptional("Flags", Limits.Flags, 0);
373 IO.mapRequired("Minimum", Limits.Minimum);
374 if (!IO.outputting() || Limits.Flags & wasm::WASM_LIMITS_FLAG_HAS_MAX)
375 IO.mapOptional("Maximum", Limits.Maximum);
376 if (!IO.outputting() || Limits.Flags & wasm::WASM_LIMITS_FLAG_HAS_PAGE_SIZE)
377 IO.mapOptional("PageSize", Limits.PageSize);
378}
379
381 IO &IO, WasmYAML::ElemSegment &Segment) {
382 IO.mapOptional("Flags", Segment.Flags, 0);
383 if (!IO.outputting() ||
385 IO.mapOptional("TableNumber", Segment.TableNumber);
386 if (!IO.outputting() ||
388 IO.mapOptional("ElemKind", Segment.ElemKind);
389 // TODO: Omit "offset" for passive segments? It's neither meaningful nor
390 // encoded.
391 IO.mapRequired("Offset", Segment.Offset);
392 IO.mapRequired("Functions", Segment.Functions);
393}
394
397 IO.mapRequired("Module", Import.Module);
398 IO.mapRequired("Field", Import.Field);
399 IO.mapRequired("Kind", Import.Kind);
402 IO.mapRequired("SigIndex", Import.SigIndex);
403 } else if (Import.Kind == wasm::WASM_EXTERNAL_GLOBAL) {
404 IO.mapRequired("GlobalType", Import.GlobalImport.Type);
405 IO.mapRequired("GlobalMutable", Import.GlobalImport.Mutable);
406 } else if (Import.Kind == wasm::WASM_EXTERNAL_TABLE) {
407 IO.mapRequired("Table", Import.TableImport);
408 } else if (Import.Kind == wasm::WASM_EXTERNAL_MEMORY) {
409 IO.mapRequired("Memory", Import.Memory);
410 } else {
411 llvm_unreachable("unhandled import type");
412 }
413}
414
417 IO.mapRequired("Name", Export.Name);
418 IO.mapRequired("Kind", Export.Kind);
419 IO.mapRequired("Index", Export.Index);
420}
421
424 IO.mapRequired("Index", Global.Index);
425 IO.mapRequired("Type", Global.Type);
426 IO.mapRequired("Mutable", Global.Mutable);
427 IO.mapRequired("InitExpr", Global.Init);
428}
429
431 WasmYAML::InitExpr &Expr) {
432 IO.mapOptional("Extended", Expr.Extended, false);
433 if (Expr.Extended) {
434 IO.mapRequired("Body", Expr.Body);
435 } else {
436 WasmYAML::Opcode Op = Expr.Inst.Opcode;
437 IO.mapRequired("Opcode", Op);
438 Expr.Inst.Opcode = Op;
439 switch (Expr.Inst.Opcode) {
441 IO.mapRequired("Value", Expr.Inst.Value.Int32);
442 break;
444 IO.mapRequired("Value", Expr.Inst.Value.Int64);
445 break;
447 IO.mapRequired("Value", Expr.Inst.Value.Float32);
448 break;
450 IO.mapRequired("Value", Expr.Inst.Value.Float64);
451 break;
453 IO.mapRequired("Index", Expr.Inst.Value.Global);
454 break;
456 WasmYAML::ValueType Ty = wasm::WASM_TYPE_EXTERNREF;
457 IO.mapRequired("Type", Ty);
458 break;
459 }
460 }
461 }
462}
463
465 IO &IO, WasmYAML::DataSegment &Segment) {
466 IO.mapOptional("SectionOffset", Segment.SectionOffset);
467 IO.mapRequired("InitFlags", Segment.InitFlags);
469 IO.mapRequired("MemoryIndex", Segment.MemoryIndex);
470 } else {
471 Segment.MemoryIndex = 0;
472 }
473 if ((Segment.InitFlags & wasm::WASM_DATA_SEGMENT_IS_PASSIVE) == 0) {
474 IO.mapRequired("Offset", Segment.Offset);
475 } else {
477 Segment.Offset.Inst.Value.Int32 = 0;
478 }
479 IO.mapRequired("Content", Segment.Content);
480}
481
483 IO &IO, WasmYAML::InitFunction &Init) {
484 IO.mapRequired("Priority", Init.Priority);
485 IO.mapRequired("Symbol", Init.Symbol);
486}
487
488void ScalarEnumerationTraits<WasmYAML::ComdatKind>::enumeration(
489 IO &IO, WasmYAML::ComdatKind &Kind) {
490#define ECase(X) IO.enumCase(Kind, #X, wasm::WASM_COMDAT_##X);
492 ECase(DATA);
493 ECase(SECTION);
494#undef ECase
495}
496
498 IO &IO, WasmYAML::ComdatEntry &ComdatEntry) {
499 IO.mapRequired("Kind", ComdatEntry.Kind);
500 IO.mapRequired("Index", ComdatEntry.Index);
501}
502
505 IO.mapRequired("Name", Comdat.Name);
506 IO.mapRequired("Entries", Comdat.Entries);
507}
508
511 IO.mapRequired("Index", Info.Index);
512 IO.mapRequired("Kind", Info.Kind);
514 IO.mapRequired("Name", Info.Name);
515 IO.mapRequired("Flags", Info.Flags);
517 IO.mapRequired("Function", Info.ElementIndex);
518 } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_GLOBAL) {
519 IO.mapRequired("Global", Info.ElementIndex);
520 } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_TABLE) {
521 IO.mapRequired("Table", Info.ElementIndex);
522 } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_TAG) {
523 IO.mapRequired("Tag", Info.ElementIndex);
524 } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_DATA) {
525 if ((Info.Flags & wasm::WASM_SYMBOL_UNDEFINED) == 0) {
526 if ((Info.Flags & wasm::WASM_SYMBOL_ABSOLUTE) == 0) {
527 IO.mapRequired("Segment", Info.DataRef.Segment);
528 }
529 IO.mapOptional("Offset", Info.DataRef.Offset, 0u);
530 IO.mapRequired("Size", Info.DataRef.Size);
531 }
532 } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_SECTION) {
533 IO.mapRequired("Section", Info.ElementIndex);
534 } else {
535 llvm_unreachable("unsupported symbol kind");
536 }
537}
538
541 IO.mapRequired("Module", Info.Module);
542 IO.mapRequired("Field", Info.Field);
543 IO.mapRequired("Flags", Info.Flags);
544}
545
548 IO.mapRequired("Name", Info.Name);
549 IO.mapRequired("Flags", Info.Flags);
550}
551
552void ScalarBitSetTraits<WasmYAML::LimitFlags>::bitset(
553 IO &IO, WasmYAML::LimitFlags &Value) {
554#define BCase(X) IO.bitSetCase(Value, #X, wasm::WASM_LIMITS_FLAG_##X)
555 BCase(HAS_MAX);
556 BCase(IS_SHARED);
557 BCase(IS_64);
558 BCase(HAS_PAGE_SIZE);
559#undef BCase
560}
561
562void ScalarBitSetTraits<WasmYAML::SegmentFlags>::bitset(
563 IO &IO, WasmYAML::SegmentFlags &Value) {
564#define BCase(X) IO.bitSetCase(Value, #X, wasm::WASM_SEG_FLAG_##X)
565 BCase(STRINGS);
566 BCase(TLS);
567 BCase(RETAIN);
568#undef BCase
569}
570
571void ScalarBitSetTraits<WasmYAML::SymbolFlags>::bitset(
572 IO &IO, WasmYAML::SymbolFlags &Value) {
573#define BCaseMask(M, X) \
574 IO.maskedBitSetCase(Value, #X, wasm::WASM_SYMBOL_##X, wasm::WASM_SYMBOL_##M)
575 // BCaseMask(BINDING_MASK, BINDING_GLOBAL);
576 BCaseMask(BINDING_MASK, BINDING_WEAK);
577 BCaseMask(BINDING_MASK, BINDING_LOCAL);
578 // BCaseMask(VISIBILITY_MASK, VISIBILITY_DEFAULT);
579 BCaseMask(VISIBILITY_MASK, VISIBILITY_HIDDEN);
581 BCaseMask(EXPORTED, EXPORTED);
582 BCaseMask(EXPLICIT_NAME, EXPLICIT_NAME);
583 BCaseMask(NO_STRIP, NO_STRIP);
584 BCaseMask(TLS, TLS);
585 BCaseMask(ABSOLUTE, ABSOLUTE);
586#undef BCaseMask
587}
588
589void ScalarEnumerationTraits<WasmYAML::SymbolKind>::enumeration(
590 IO &IO, WasmYAML::SymbolKind &Kind) {
591#define ECase(X) IO.enumCase(Kind, #X, wasm::WASM_SYMBOL_TYPE_##X);
593 ECase(DATA);
594 ECase(GLOBAL);
595 ECase(TABLE);
596 ECase(SECTION);
597 ECase(TAG);
598#undef ECase
599}
600
601void ScalarEnumerationTraits<WasmYAML::ValueType>::enumeration(
602 IO &IO, WasmYAML::ValueType &Type) {
603#define CONCAT(X) (uint32_t) wasm::ValType::X
604#define ECase(X) IO.enumCase(Type, #X, CONCAT(X));
605 ECase(I32);
606 ECase(I64);
607 ECase(F32);
608 ECase(F64);
609 ECase(V128);
610 ECase(FUNCREF);
611 ECase(EXTERNREF);
612 ECase(EXNREF);
613 ECase(OTHERREF);
614#undef ECase
615}
616
617void ScalarEnumerationTraits<WasmYAML::ExportKind>::enumeration(
618 IO &IO, WasmYAML::ExportKind &Kind) {
619#define ECase(X) IO.enumCase(Kind, #X, wasm::WASM_EXTERNAL_##X);
621 ECase(TABLE);
622 ECase(MEMORY);
623 ECase(GLOBAL);
624 ECase(TAG);
625#undef ECase
626}
627
628void ScalarEnumerationTraits<WasmYAML::Opcode>::enumeration(
629 IO &IO, WasmYAML::Opcode &Code) {
630#define ECase(X) IO.enumCase(Code, #X, wasm::WASM_OPCODE_##X);
631 ECase(END);
632 ECase(I32_CONST);
633 ECase(I64_CONST);
634 ECase(F64_CONST);
635 ECase(F32_CONST);
636 ECase(GLOBAL_GET);
637 ECase(REF_NULL);
638#undef ECase
639}
640
641void ScalarEnumerationTraits<WasmYAML::TableType>::enumeration(
642 IO &IO, WasmYAML::TableType &Type) {
643#define CONCAT(X) (uint32_t) wasm::ValType::X
644#define ECase(X) IO.enumCase(Type, #X, CONCAT(X));
645 ECase(FUNCREF);
646 ECase(EXTERNREF);
647 ECase(EXNREF);
648 ECase(OTHERREF);
649#undef ECase
650}
651
652void ScalarEnumerationTraits<WasmYAML::RelocType>::enumeration(
653 IO &IO, WasmYAML::RelocType &Type) {
654#define WASM_RELOC(name, value) IO.enumCase(Type, #name, wasm::name);
655#include "llvm/BinaryFormat/WasmRelocs.def"
656#undef WASM_RELOC
657 IO.enumFallback<Hex32>(Type);
658}
659
660} // end namespace yaml
661
662} // end namespace llvm
constexpr LLT F64
constexpr LLT F32
#define BCase(X)
Definition: COFFYAML.cpp:267
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
#define BCaseMask(X, M)
#define FUNCTION(NAME, NARG, ROUND_MODE, INTRINSIC)
static constexpr auto TAG
Definition: OpenMPOpt.cpp:185
This file declares classes for handling the YAML representation of wasm binaries.
#define ECase(X)
@ UNDEFINED
This class represents an Operation in the Expression.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
LLVM Value Representation.
Definition: Value.h:75
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr uint16_t VISIBILITY_MASK
Definition: XCOFF.h:260
@ WASM_TYPE_EXTERNREF
Definition: Wasm.h:66
const unsigned WASM_SYMBOL_UNDEFINED
Definition: Wasm.h:247
@ WASM_DATA_SEGMENT_IS_PASSIVE
Definition: Wasm.h:166
@ WASM_DATA_SEGMENT_HAS_MEMINDEX
Definition: Wasm.h:167
@ WASM_OPCODE_F64_CONST
Definition: Wasm.h:107
@ WASM_OPCODE_REF_NULL
Definition: Wasm.h:114
@ WASM_OPCODE_F32_CONST
Definition: Wasm.h:106
@ WASM_OPCODE_GLOBAL_GET
Definition: Wasm.h:100
@ WASM_OPCODE_I64_CONST
Definition: Wasm.h:105
@ WASM_OPCODE_I32_CONST
Definition: Wasm.h:104
@ WASM_LIMITS_FLAG_HAS_MAX
Definition: Wasm.h:159
@ WASM_LIMITS_FLAG_HAS_PAGE_SIZE
Definition: Wasm.h:162
@ WASM_SEC_CODE
Definition: Wasm.h:47
@ WASM_SEC_MEMORY
Definition: Wasm.h:42
@ WASM_SEC_IMPORT
Definition: Wasm.h:39
@ WASM_SEC_EXPORT
Definition: Wasm.h:44
@ WASM_SEC_DATACOUNT
Definition: Wasm.h:49
@ WASM_SEC_CUSTOM
Definition: Wasm.h:37
@ WASM_SEC_FUNCTION
Definition: Wasm.h:40
@ WASM_SEC_ELEM
Definition: Wasm.h:46
@ WASM_SEC_START
Definition: Wasm.h:45
@ WASM_SEC_TABLE
Definition: Wasm.h:41
@ WASM_SEC_TYPE
Definition: Wasm.h:38
@ WASM_SEC_TAG
Definition: Wasm.h:50
@ WASM_SEC_GLOBAL
Definition: Wasm.h:43
@ WASM_SEC_DATA
Definition: Wasm.h:48
@ WASM_ELEM_SEGMENT_HAS_TABLE_NUMBER
Definition: Wasm.h:173
@ WASM_SYMBOL_TYPE_GLOBAL
Definition: Wasm.h:222
@ WASM_SYMBOL_TYPE_DATA
Definition: Wasm.h:221
@ WASM_SYMBOL_TYPE_TAG
Definition: Wasm.h:224
@ WASM_SYMBOL_TYPE_TABLE
Definition: Wasm.h:225
@ WASM_SYMBOL_TYPE_SECTION
Definition: Wasm.h:223
@ WASM_SYMBOL_TYPE_FUNCTION
Definition: Wasm.h:220
@ WASM_EXTERNAL_TABLE
Definition: Wasm.h:87
@ WASM_EXTERNAL_FUNCTION
Definition: Wasm.h:86
@ WASM_EXTERNAL_TAG
Definition: Wasm.h:90
@ WASM_EXTERNAL_MEMORY
Definition: Wasm.h:88
@ WASM_EXTERNAL_GLOBAL
Definition: Wasm.h:89
const unsigned WASM_SYMBOL_ABSOLUTE
Definition: Wasm.h:252
const unsigned WASM_ELEM_SEGMENT_MASK_HAS_ELEM_DESC
Definition: Wasm.h:176
static void sectionMapping(IO &IO, ELFYAML::DynamicSection &Section)
Definition: ELFYAML.cpp:1420
static void commonSectionMapping(IO &IO, ELFYAML::Section &Section)
Definition: ELFYAML.cpp:1393
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Export
Export information to summary.
@ Import
Import information from summary.
@ Global
Append to llvm.global_dtors.
DWARFExpression::Operation Op
yaml::BinaryRef Content
Definition: WasmYAML.h:129
std::vector< uint32_t > Functions
Definition: WasmYAML.h:80
FeaturePolicyPrefix Prefix
Definition: WasmYAML.h:143
wasm::WasmInitExprMVP Inst
Definition: WasmYAML.h:70
yaml::BinaryRef Body
Definition: WasmYAML.h:71
yaml::Hex32 Minimum
Definition: WasmYAML.h:49
yaml::Hex32 PageSize
Definition: WasmYAML.h:51
LimitFlags Flags
Definition: WasmYAML.h:48
yaml::Hex32 Maximum
Definition: WasmYAML.h:50
std::vector< ValueType > ReturnTypes
Definition: WasmYAML.h:158
std::vector< ValueType > ParamTypes
Definition: WasmYAML.h:157
TableType ElemType
Definition: WasmYAML.h:55
union llvm::wasm::WasmInitExprMVP::@188 Value