LLVM  15.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"
15 #include "llvm/Support/Casting.h"
18 
19 namespace llvm {
20 
21 namespace WasmYAML {
22 
23 // Declared here rather than in the header to comply with:
24 // http://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-for-classes-in-headers
25 Section::~Section() = default;
26 
27 } // end namespace WasmYAML
28 
29 namespace yaml {
30 
32  IO &IO, WasmYAML::FileHeader &FileHdr) {
33  IO.mapRequired("Version", FileHdr.Version);
34 }
35 
37  WasmYAML::Object &Object) {
38  IO.setContext(&Object);
39  IO.mapTag("!WASM", true);
40  IO.mapRequired("FileHeader", Object.Header);
41  IO.mapOptional("Sections", Object.Sections);
42  IO.setContext(nullptr);
43 }
44 
45 static void commonSectionMapping(IO &IO, WasmYAML::Section &Section) {
46  IO.mapRequired("Type", Section.Type);
47  IO.mapOptional("Relocations", Section.Relocations);
48 }
49 
50 static void sectionMapping(IO &IO, WasmYAML::DylinkSection &Section) {
51  commonSectionMapping(IO, Section);
52  IO.mapRequired("Name", Section.Name);
53  IO.mapRequired("MemorySize", Section.MemorySize);
54  IO.mapRequired("MemoryAlignment", Section.MemoryAlignment);
55  IO.mapRequired("TableSize", Section.TableSize);
56  IO.mapRequired("TableAlignment", Section.TableAlignment);
57  IO.mapRequired("Needed", Section.Needed);
58  IO.mapOptional("ImportInfo", Section.ImportInfo);
59  IO.mapOptional("ExportInfo", Section.ExportInfo);
60 }
61 
62 static void sectionMapping(IO &IO, WasmYAML::NameSection &Section) {
63  commonSectionMapping(IO, Section);
64  IO.mapRequired("Name", Section.Name);
65  IO.mapOptional("FunctionNames", Section.FunctionNames);
66  IO.mapOptional("GlobalNames", Section.GlobalNames);
67  IO.mapOptional("DataSegmentNames", Section.DataSegmentNames);
68 }
69 
70 static void sectionMapping(IO &IO, WasmYAML::LinkingSection &Section) {
71  commonSectionMapping(IO, Section);
72  IO.mapRequired("Name", Section.Name);
73  IO.mapRequired("Version", Section.Version);
74  IO.mapOptional("SymbolTable", Section.SymbolTable);
75  IO.mapOptional("SegmentInfo", Section.SegmentInfos);
76  IO.mapOptional("InitFunctions", Section.InitFunctions);
77  IO.mapOptional("Comdats", Section.Comdats);
78 }
79 
80 static void sectionMapping(IO &IO, WasmYAML::ProducersSection &Section) {
81  commonSectionMapping(IO, Section);
82  IO.mapRequired("Name", Section.Name);
83  IO.mapOptional("Languages", Section.Languages);
84  IO.mapOptional("Tools", Section.Tools);
85  IO.mapOptional("SDKs", Section.SDKs);
86 }
87 
88 static void sectionMapping(IO &IO, WasmYAML::TargetFeaturesSection &Section) {
89  commonSectionMapping(IO, Section);
90  IO.mapRequired("Name", Section.Name);
91  IO.mapRequired("Features", Section.Features);
92 }
93 
94 static void sectionMapping(IO &IO, WasmYAML::CustomSection &Section) {
95  commonSectionMapping(IO, Section);
96  IO.mapRequired("Name", Section.Name);
97  IO.mapRequired("Payload", Section.Payload);
98 }
99 
100 static void sectionMapping(IO &IO, WasmYAML::TypeSection &Section) {
101  commonSectionMapping(IO, Section);
102  IO.mapOptional("Signatures", Section.Signatures);
103 }
104 
105 static void sectionMapping(IO &IO, WasmYAML::ImportSection &Section) {
106  commonSectionMapping(IO, Section);
107  IO.mapOptional("Imports", Section.Imports);
108 }
109 
110 static void sectionMapping(IO &IO, WasmYAML::FunctionSection &Section) {
111  commonSectionMapping(IO, Section);
112  IO.mapOptional("FunctionTypes", Section.FunctionTypes);
113 }
114 
115 static void sectionMapping(IO &IO, WasmYAML::TableSection &Section) {
116  commonSectionMapping(IO, Section);
117  IO.mapOptional("Tables", Section.Tables);
118 }
119 
120 static void sectionMapping(IO &IO, WasmYAML::MemorySection &Section) {
121  commonSectionMapping(IO, Section);
122  IO.mapOptional("Memories", Section.Memories);
123 }
124 
125 static void sectionMapping(IO &IO, WasmYAML::TagSection &Section) {
126  commonSectionMapping(IO, Section);
127  IO.mapOptional("TagTypes", Section.TagTypes);
128 }
129 
130 static void sectionMapping(IO &IO, WasmYAML::GlobalSection &Section) {
131  commonSectionMapping(IO, Section);
132  IO.mapOptional("Globals", Section.Globals);
133 }
134 
135 static void sectionMapping(IO &IO, WasmYAML::ExportSection &Section) {
136  commonSectionMapping(IO, Section);
137  IO.mapOptional("Exports", Section.Exports);
138 }
139 
140 static void sectionMapping(IO &IO, WasmYAML::StartSection &Section) {
141  commonSectionMapping(IO, Section);
142  IO.mapOptional("StartFunction", Section.StartFunction);
143 }
144 
145 static void sectionMapping(IO &IO, WasmYAML::ElemSection &Section) {
146  commonSectionMapping(IO, Section);
147  IO.mapOptional("Segments", Section.Segments);
148 }
149 
150 static void sectionMapping(IO &IO, WasmYAML::CodeSection &Section) {
151  commonSectionMapping(IO, Section);
152  IO.mapRequired("Functions", Section.Functions);
153 }
154 
155 static void sectionMapping(IO &IO, WasmYAML::DataSection &Section) {
156  commonSectionMapping(IO, Section);
157  IO.mapRequired("Segments", Section.Segments);
158 }
159 
160 static void sectionMapping(IO &IO, WasmYAML::DataCountSection &Section) {
161  commonSectionMapping(IO, Section);
162  IO.mapRequired("Count", Section.Count);
163 }
164 
166  IO &IO, std::unique_ptr<WasmYAML::Section> &Section) {
168  if (IO.outputting())
169  SectionType = Section->Type;
170  else
171  IO.mapRequired("Type", SectionType);
172 
173  switch (SectionType) {
174  case wasm::WASM_SEC_CUSTOM: {
176  if (IO.outputting()) {
177  auto CustomSection = cast<WasmYAML::CustomSection>(Section.get());
178  SectionName = CustomSection->Name;
179  } else {
180  IO.mapRequired("Name", SectionName);
181  }
182  if (SectionName == "dylink" || SectionName == "dylink.0") {
183  if (!IO.outputting())
184  Section.reset(new WasmYAML::DylinkSection());
185  sectionMapping(IO, *cast<WasmYAML::DylinkSection>(Section.get()));
186  } else if (SectionName == "linking") {
187  if (!IO.outputting())
188  Section.reset(new WasmYAML::LinkingSection());
189  sectionMapping(IO, *cast<WasmYAML::LinkingSection>(Section.get()));
190  } else if (SectionName == "name") {
191  if (!IO.outputting())
192  Section.reset(new WasmYAML::NameSection());
193  sectionMapping(IO, *cast<WasmYAML::NameSection>(Section.get()));
194  } else if (SectionName == "producers") {
195  if (!IO.outputting())
196  Section.reset(new WasmYAML::ProducersSection());
197  sectionMapping(IO, *cast<WasmYAML::ProducersSection>(Section.get()));
198  } else if (SectionName == "target_features") {
199  if (!IO.outputting())
200  Section.reset(new WasmYAML::TargetFeaturesSection());
201  sectionMapping(IO, *cast<WasmYAML::TargetFeaturesSection>(Section.get()));
202  } else {
203  if (!IO.outputting())
204  Section.reset(new WasmYAML::CustomSection(SectionName));
205  sectionMapping(IO, *cast<WasmYAML::CustomSection>(Section.get()));
206  }
207  break;
208  }
209  case wasm::WASM_SEC_TYPE:
210  if (!IO.outputting())
211  Section.reset(new WasmYAML::TypeSection());
212  sectionMapping(IO, *cast<WasmYAML::TypeSection>(Section.get()));
213  break;
215  if (!IO.outputting())
216  Section.reset(new WasmYAML::ImportSection());
217  sectionMapping(IO, *cast<WasmYAML::ImportSection>(Section.get()));
218  break;
220  if (!IO.outputting())
221  Section.reset(new WasmYAML::FunctionSection());
222  sectionMapping(IO, *cast<WasmYAML::FunctionSection>(Section.get()));
223  break;
225  if (!IO.outputting())
226  Section.reset(new WasmYAML::TableSection());
227  sectionMapping(IO, *cast<WasmYAML::TableSection>(Section.get()));
228  break;
230  if (!IO.outputting())
231  Section.reset(new WasmYAML::MemorySection());
232  sectionMapping(IO, *cast<WasmYAML::MemorySection>(Section.get()));
233  break;
234  case wasm::WASM_SEC_TAG:
235  if (!IO.outputting())
236  Section.reset(new WasmYAML::TagSection());
237  sectionMapping(IO, *cast<WasmYAML::TagSection>(Section.get()));
238  break;
240  if (!IO.outputting())
241  Section.reset(new WasmYAML::GlobalSection());
242  sectionMapping(IO, *cast<WasmYAML::GlobalSection>(Section.get()));
243  break;
245  if (!IO.outputting())
246  Section.reset(new WasmYAML::ExportSection());
247  sectionMapping(IO, *cast<WasmYAML::ExportSection>(Section.get()));
248  break;
250  if (!IO.outputting())
251  Section.reset(new WasmYAML::StartSection());
252  sectionMapping(IO, *cast<WasmYAML::StartSection>(Section.get()));
253  break;
254  case wasm::WASM_SEC_ELEM:
255  if (!IO.outputting())
256  Section.reset(new WasmYAML::ElemSection());
257  sectionMapping(IO, *cast<WasmYAML::ElemSection>(Section.get()));
258  break;
259  case wasm::WASM_SEC_CODE:
260  if (!IO.outputting())
261  Section.reset(new WasmYAML::CodeSection());
262  sectionMapping(IO, *cast<WasmYAML::CodeSection>(Section.get()));
263  break;
264  case wasm::WASM_SEC_DATA:
265  if (!IO.outputting())
266  Section.reset(new WasmYAML::DataSection());
267  sectionMapping(IO, *cast<WasmYAML::DataSection>(Section.get()));
268  break;
270  if (!IO.outputting())
271  Section.reset(new WasmYAML::DataCountSection());
272  sectionMapping(IO, *cast<WasmYAML::DataCountSection>(Section.get()));
273  break;
274  default:
275  llvm_unreachable("Unknown section type");
276  }
277 }
278 
280  IO &IO, WasmYAML::SectionType &Type) {
281 #define ECase(X) IO.enumCase(Type, #X, wasm::WASM_SEC_##X);
282  ECase(CUSTOM);
283  ECase(TYPE);
284  ECase(IMPORT);
285  ECase(FUNCTION);
286  ECase(TABLE);
287  ECase(MEMORY);
288  ECase(GLOBAL);
289  ECase(TAG);
290  ECase(EXPORT);
291  ECase(START);
292  ECase(ELEM);
293  ECase(CODE);
294  ECase(DATA);
295  ECase(DATACOUNT);
296 #undef ECase
297 }
298 
300  IO &IO, WasmYAML::Signature &Signature) {
301  IO.mapRequired("Index", Signature.Index);
302  IO.mapRequired("ParamTypes", Signature.ParamTypes);
303  IO.mapRequired("ReturnTypes", Signature.ReturnTypes);
304 }
305 
307  IO.mapRequired("Index", Table.Index);
308  IO.mapRequired("ElemType", Table.ElemType);
309  IO.mapRequired("Limits", Table.TableLimits);
310 }
311 
314  IO.mapRequired("Index", Function.Index);
315  IO.mapRequired("Locals", Function.Locals);
316  IO.mapRequired("Body", Function.Body);
317 }
318 
320  IO &IO, WasmYAML::Relocation &Relocation) {
321  IO.mapRequired("Type", Relocation.Type);
322  IO.mapRequired("Index", Relocation.Index);
323  IO.mapRequired("Offset", Relocation.Offset);
324  IO.mapOptional("Addend", Relocation.Addend, 0);
325 }
326 
328  IO &IO, WasmYAML::NameEntry &NameEntry) {
329  IO.mapRequired("Index", NameEntry.Index);
330  IO.mapRequired("Name", NameEntry.Name);
331 }
332 
334  IO &IO, WasmYAML::ProducerEntry &ProducerEntry) {
335  IO.mapRequired("Name", ProducerEntry.Name);
336  IO.mapRequired("Version", ProducerEntry.Version);
337 }
338 
340  IO &IO, WasmYAML::FeaturePolicyPrefix &Kind) {
341 #define ECase(X) IO.enumCase(Kind, #X, wasm::WASM_FEATURE_PREFIX_##X);
342  ECase(USED);
343  ECase(REQUIRED);
344  ECase(DISALLOWED);
345 #undef ECase
346 }
347 
349  IO &IO, WasmYAML::FeatureEntry &FeatureEntry) {
350  IO.mapRequired("Prefix", FeatureEntry.Prefix);
351  IO.mapRequired("Name", FeatureEntry.Name);
352 }
353 
355  IO &IO, WasmYAML::SegmentInfo &SegmentInfo) {
356  IO.mapRequired("Index", SegmentInfo.Index);
357  IO.mapRequired("Name", SegmentInfo.Name);
358  IO.mapRequired("Alignment", SegmentInfo.Alignment);
359  IO.mapRequired("Flags", SegmentInfo.Flags);
360 }
361 
363  IO &IO, WasmYAML::LocalDecl &LocalDecl) {
364  IO.mapRequired("Type", LocalDecl.Type);
365  IO.mapRequired("Count", LocalDecl.Count);
366 }
367 
369  WasmYAML::Limits &Limits) {
370  IO.mapOptional("Flags", Limits.Flags, 0);
371  IO.mapRequired("Minimum", Limits.Minimum);
372  if (!IO.outputting() || Limits.Flags & wasm::WASM_LIMITS_FLAG_HAS_MAX)
373  IO.mapOptional("Maximum", Limits.Maximum);
374 }
375 
377  IO &IO, WasmYAML::ElemSegment &Segment) {
378  IO.mapOptional("Flags", Segment.Flags, 0);
379  if (!IO.outputting() ||
381  IO.mapOptional("TableNumber", Segment.TableNumber);
382  if (!IO.outputting() ||
384  IO.mapOptional("ElemKind", Segment.ElemKind);
385  IO.mapRequired("Offset", Segment.Offset);
386  IO.mapRequired("Functions", Segment.Functions);
387 }
388 
390  WasmYAML::Import &Import) {
391  IO.mapRequired("Module", Import.Module);
392  IO.mapRequired("Field", Import.Field);
393  IO.mapRequired("Kind", Import.Kind);
394  if (Import.Kind == wasm::WASM_EXTERNAL_FUNCTION ||
396  IO.mapRequired("SigIndex", Import.SigIndex);
397  } else if (Import.Kind == wasm::WASM_EXTERNAL_GLOBAL) {
398  IO.mapRequired("GlobalType", Import.GlobalImport.Type);
399  IO.mapRequired("GlobalMutable", Import.GlobalImport.Mutable);
400  } else if (Import.Kind == wasm::WASM_EXTERNAL_TABLE) {
401  IO.mapRequired("Table", Import.TableImport);
402  } else if (Import.Kind == wasm::WASM_EXTERNAL_MEMORY) {
403  IO.mapRequired("Memory", Import.Memory);
404  } else {
405  llvm_unreachable("unhandled import type");
406  }
407 }
408 
410  WasmYAML::Export &Export) {
411  IO.mapRequired("Name", Export.Name);
412  IO.mapRequired("Kind", Export.Kind);
413  IO.mapRequired("Index", Export.Index);
414 }
415 
417  WasmYAML::Global &Global) {
418  IO.mapRequired("Index", Global.Index);
419  IO.mapRequired("Type", Global.Type);
420  IO.mapRequired("Mutable", Global.Mutable);
421  IO.mapRequired("InitExpr", Global.Init);
422 }
423 
425  WasmYAML::InitExpr &Expr) {
426  IO.mapOptional("Extended", Expr.Extended, false);
427  if (Expr.Extended) {
428  IO.mapRequired("Body", Expr.Body);
429  } else {
430  WasmYAML::Opcode Op = Expr.Inst.Opcode;
431  IO.mapRequired("Opcode", Op);
432  Expr.Inst.Opcode = Op;
433  switch (Expr.Inst.Opcode) {
435  IO.mapRequired("Value", Expr.Inst.Value.Int32);
436  break;
438  IO.mapRequired("Value", Expr.Inst.Value.Int64);
439  break;
441  IO.mapRequired("Value", Expr.Inst.Value.Float32);
442  break;
444  IO.mapRequired("Value", Expr.Inst.Value.Float64);
445  break;
447  IO.mapRequired("Index", Expr.Inst.Value.Global);
448  break;
451  IO.mapRequired("Type", Ty);
452  break;
453  }
454  }
455  }
456 }
457 
459  IO &IO, WasmYAML::DataSegment &Segment) {
460  IO.mapOptional("SectionOffset", Segment.SectionOffset);
461  IO.mapRequired("InitFlags", Segment.InitFlags);
463  IO.mapRequired("MemoryIndex", Segment.MemoryIndex);
464  } else {
465  Segment.MemoryIndex = 0;
466  }
467  if ((Segment.InitFlags & wasm::WASM_DATA_SEGMENT_IS_PASSIVE) == 0) {
468  IO.mapRequired("Offset", Segment.Offset);
469  } else {
471  Segment.Offset.Inst.Value.Int32 = 0;
472  }
473  IO.mapRequired("Content", Segment.Content);
474 }
475 
477  IO &IO, WasmYAML::InitFunction &Init) {
478  IO.mapRequired("Priority", Init.Priority);
479  IO.mapRequired("Symbol", Init.Symbol);
480 }
481 
483  IO &IO, WasmYAML::ComdatKind &Kind) {
484 #define ECase(X) IO.enumCase(Kind, #X, wasm::WASM_COMDAT_##X);
485  ECase(FUNCTION);
486  ECase(DATA);
487  ECase(SECTION);
488 #undef ECase
489 }
490 
492  IO &IO, WasmYAML::ComdatEntry &ComdatEntry) {
493  IO.mapRequired("Kind", ComdatEntry.Kind);
494  IO.mapRequired("Index", ComdatEntry.Index);
495 }
496 
499  IO.mapRequired("Name", Comdat.Name);
500  IO.mapRequired("Entries", Comdat.Entries);
501 }
502 
505  IO.mapRequired("Index", Info.Index);
506  IO.mapRequired("Kind", Info.Kind);
508  IO.mapRequired("Name", Info.Name);
509  IO.mapRequired("Flags", Info.Flags);
511  IO.mapRequired("Function", Info.ElementIndex);
512  } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_GLOBAL) {
513  IO.mapRequired("Global", Info.ElementIndex);
514  } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_TABLE) {
515  IO.mapRequired("Table", Info.ElementIndex);
516  } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_TAG) {
517  IO.mapRequired("Tag", Info.ElementIndex);
518  } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_DATA) {
519  if ((Info.Flags & wasm::WASM_SYMBOL_UNDEFINED) == 0) {
520  IO.mapRequired("Segment", Info.DataRef.Segment);
521  IO.mapOptional("Offset", Info.DataRef.Offset, 0u);
522  IO.mapRequired("Size", Info.DataRef.Size);
523  }
524  } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_SECTION) {
525  IO.mapRequired("Section", Info.ElementIndex);
526  } else {
527  llvm_unreachable("unsupported symbol kind");
528  }
529 }
530 
532  IO &IO, WasmYAML::DylinkImportInfo &Info) {
533  IO.mapRequired("Module", Info.Module);
534  IO.mapRequired("Field", Info.Field);
535  IO.mapRequired("Flags", Info.Flags);
536 }
537 
539  IO &IO, WasmYAML::DylinkExportInfo &Info) {
540  IO.mapRequired("Name", Info.Name);
541  IO.mapRequired("Flags", Info.Flags);
542 }
543 
545  IO &IO, WasmYAML::LimitFlags &Value) {
546 #define BCase(X) IO.bitSetCase(Value, #X, wasm::WASM_LIMITS_FLAG_##X)
547  BCase(HAS_MAX);
548  BCase(IS_SHARED);
549  BCase(IS_64);
550 #undef BCase
551 }
552 
554  IO &IO, WasmYAML::SegmentFlags &Value) {
555 #define BCase(X) IO.bitSetCase(Value, #X, wasm::WASM_SEG_FLAG_##X)
556  BCase(STRINGS);
557  BCase(TLS);
558 #undef BCase
559 }
560 
562  IO &IO, WasmYAML::SymbolFlags &Value) {
563 #define BCaseMask(M, X) \
564  IO.maskedBitSetCase(Value, #X, wasm::WASM_SYMBOL_##X, wasm::WASM_SYMBOL_##M)
565  // BCaseMask(BINDING_MASK, BINDING_GLOBAL);
566  BCaseMask(BINDING_MASK, BINDING_WEAK);
567  BCaseMask(BINDING_MASK, BINDING_LOCAL);
568  // BCaseMask(VISIBILITY_MASK, VISIBILITY_DEFAULT);
569  BCaseMask(VISIBILITY_MASK, VISIBILITY_HIDDEN);
571  BCaseMask(EXPORTED, EXPORTED);
572  BCaseMask(EXPLICIT_NAME, EXPLICIT_NAME);
573  BCaseMask(NO_STRIP, NO_STRIP);
574  BCaseMask(TLS, TLS);
575 #undef BCaseMask
576 }
577 
579  IO &IO, WasmYAML::SymbolKind &Kind) {
580 #define ECase(X) IO.enumCase(Kind, #X, wasm::WASM_SYMBOL_TYPE_##X);
581  ECase(FUNCTION);
582  ECase(DATA);
583  ECase(GLOBAL);
584  ECase(TABLE);
585  ECase(SECTION);
586  ECase(TAG);
587 #undef ECase
588 }
589 
591  IO &IO, WasmYAML::ValueType &Type) {
592 #define ECase(X) IO.enumCase(Type, #X, wasm::WASM_TYPE_##X);
593  ECase(I32);
594  ECase(I64);
595  ECase(F32);
596  ECase(F64);
597  ECase(V128);
598  ECase(FUNCREF);
599  ECase(EXTERNREF);
600  ECase(FUNC);
601 #undef ECase
602 }
603 
605  IO &IO, WasmYAML::ExportKind &Kind) {
606 #define ECase(X) IO.enumCase(Kind, #X, wasm::WASM_EXTERNAL_##X);
607  ECase(FUNCTION);
608  ECase(TABLE);
609  ECase(MEMORY);
610  ECase(GLOBAL);
611  ECase(TAG);
612 #undef ECase
613 }
614 
616  IO &IO, WasmYAML::Opcode &Code) {
617 #define ECase(X) IO.enumCase(Code, #X, wasm::WASM_OPCODE_##X);
618  ECase(END);
619  ECase(I32_CONST);
620  ECase(I64_CONST);
621  ECase(F64_CONST);
622  ECase(F32_CONST);
623  ECase(GLOBAL_GET);
624  ECase(REF_NULL);
625 #undef ECase
626 }
627 
629  IO &IO, WasmYAML::TableType &Type) {
630 #define ECase(X) IO.enumCase(Type, #X, wasm::WASM_TYPE_##X);
631  ECase(FUNCREF);
632  ECase(EXTERNREF);
633 #undef ECase
634 }
635 
637  IO &IO, WasmYAML::RelocType &Type) {
638 #define WASM_RELOC(name, value) IO.enumCase(Type, #name, wasm::name);
639 #include "llvm/BinaryFormat/WasmRelocs.def"
640 #undef WASM_RELOC
641  IO.enumFallback<Hex32>(Type);
642 }
643 
644 } // end namespace yaml
645 
646 } // end namespace llvm
llvm::wasm::WASM_SYMBOL_TYPE_SECTION
@ WASM_SYMBOL_TYPE_SECTION
Definition: Wasm.h:384
llvm::wasm::WasmInitExprMVP::Float64
uint64_t Float64
Definition: Wasm.h:100
llvm::WasmYAML::GlobalSection
Definition: WasmYAML.h:346
llvm::WasmYAML::FileHeader
Definition: WasmYAML.h:43
llvm::WasmYAML::ProducerEntry::Name
std::string Name
Definition: WasmYAML.h:137
llvm::WasmYAML::FeatureEntry::Name
std::string Name
Definition: WasmYAML.h:143
llvm::wasm::WASM_EXTERNAL_TAG
@ WASM_EXTERNAL_TAG
Definition: Wasm.h:277
llvm::WasmYAML::InitFunction
Definition: WasmYAML.h:171
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::WasmYAML::Section::~Section
virtual ~Section()
llvm::yaml::ScalarEnumerationTraits< WasmYAML::FeaturePolicyPrefix >::enumeration
static void enumeration(IO &IO, WasmYAML::FeaturePolicyPrefix &Prefix)
Definition: WasmYAML.cpp:339
llvm::WasmYAML::ProducersSection
Definition: WasmYAML.h:262
UNDEFINED
@ UNDEFINED
Definition: blake3_dispatch.c:73
llvm::wasm::WASM_ELEM_SEGMENT_MASK_HAS_ELEM_KIND
const unsigned WASM_ELEM_SEGMENT_MASK_HAS_ELEM_KIND
Definition: Wasm.h:338
llvm::WasmYAML::NameEntry::Index
uint32_t Index
Definition: WasmYAML.h:132
llvm::WasmYAML::FileHeader::Version
yaml::Hex32 Version
Definition: WasmYAML.h:44
llvm::yaml::ScalarEnumerationTraits< WasmYAML::TableType >::enumeration
static void enumeration(IO &IO, WasmYAML::TableType &Type)
Definition: WasmYAML.cpp:628
llvm::WasmYAML::LocalDecl
Definition: WasmYAML.h:103
llvm::yaml::ScalarEnumerationTraits< WasmYAML::ValueType >::enumeration
static void enumeration(IO &IO, WasmYAML::ValueType &Type)
Definition: WasmYAML.cpp:590
llvm::Function
Definition: Function.h:60
StringRef.h
llvm::yaml::ScalarEnumerationTraits< WasmYAML::Opcode >::enumeration
static void enumeration(IO &IO, WasmYAML::Opcode &Opcode)
Definition: WasmYAML.cpp:615
llvm::wasm::WASM_TYPE_EXTERNREF
@ WASM_TYPE_EXTERNREF
Definition: Wasm.h:266
llvm::WasmYAML::Comdat
Definition: WasmYAML.h:181
llvm::codeview::SymbolKind
SymbolKind
Duplicate copy of the above enum, but using the official CV names.
Definition: CodeView.h:47
TAG
static constexpr auto TAG
Definition: OpenMPOpt.cpp:173
llvm::wasm::WASM_OPCODE_REF_NULL
@ WASM_OPCODE_REF_NULL
Definition: Wasm.h:300
llvm::yaml::ScalarEnumerationTraits< WasmYAML::SectionType >::enumeration
static void enumeration(IO &IO, WasmYAML::SectionType &Type)
Definition: WasmYAML.cpp:279
ErrorHandling.h
llvm::WasmYAML::DylinkExportInfo
Definition: WasmYAML.h:212
llvm::wasm::WASM_SYMBOL_TYPE_TABLE
@ WASM_SYMBOL_TYPE_TABLE
Definition: Wasm.h:386
llvm::wasm::WASM_SYMBOL_TYPE_GLOBAL
@ WASM_SYMBOL_TYPE_GLOBAL
Definition: Wasm.h:383
llvm::WasmYAML::DataSection
Definition: WasmYAML.h:396
llvm::yaml::ScalarEnumerationTraits< WasmYAML::ExportKind >::enumeration
static void enumeration(IO &IO, WasmYAML::ExportKind &Kind)
Definition: WasmYAML.cpp:604
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::WasmYAML::TableSection
Definition: WasmYAML.h:316
llvm::wasm::WASM_SEC_EXPORT
@ WASM_SEC_EXPORT
Definition: Wasm.h:249
llvm::WasmYAML::ElemSection
Definition: WasmYAML.h:376
llvm::WasmYAML::SegmentInfo::Name
StringRef Name
Definition: WasmYAML.h:148
FUNCTION
#define FUNCTION(NAME, NARG, ROUND_MODE, INTRINSIC)
I64
@ I64
Definition: DXILOpLowering.cpp:41
llvm::wasm::WASM_SYMBOL_UNDEFINED
const unsigned WASM_SYMBOL_UNDEFINED
Definition: Wasm.h:407
llvm::WasmYAML::ElemSegment
Definition: WasmYAML.h:74
llvm::wasm::WASM_ELEM_SEGMENT_HAS_TABLE_NUMBER
@ WASM_ELEM_SEGMENT_HAS_TABLE_NUMBER
Definition: Wasm.h:335
llvm::wasm::WASM_OPCODE_I64_CONST
@ WASM_OPCODE_I64_CONST
Definition: Wasm.h:291
llvm::WasmYAML::Relocation::Offset
yaml::Hex32 Offset
Definition: WasmYAML.h:119
llvm::WasmYAML::MemorySection
Definition: WasmYAML.h:326
llvm::wasm::WASM_OPCODE_F32_CONST
@ WASM_OPCODE_F32_CONST
Definition: Wasm.h:292
llvm::yaml::MappingTraits
Definition: ModuleSummaryIndex.h:51
llvm::wasm::WASM_SEC_TABLE
@ WASM_SEC_TABLE
Definition: Wasm.h:246
llvm::WasmYAML::ProducerEntry
Definition: WasmYAML.h:136
llvm::MachO::SymbolFlags
SymbolFlags
Symbol flags.
Definition: Symbol.h:24
llvm::wasm::WASM_DATA_SEGMENT_HAS_MEMINDEX
@ WASM_DATA_SEGMENT_HAS_MEMINDEX
Definition: Wasm.h:330
llvm::WasmYAML::Import
Definition: WasmYAML.h:89
llvm::WasmYAML::CustomSection
Definition: WasmYAML.h:194
llvm::WasmYAML::ProducerEntry::Version
std::string Version
Definition: WasmYAML.h:138
llvm::wasm::WASM_SEC_MEMORY
@ WASM_SEC_MEMORY
Definition: Wasm.h:247
llvm::WasmYAML::ComdatEntry::Index
uint32_t Index
Definition: WasmYAML.h:178
llvm::WasmYAML::InitExpr::Inst
wasm::WasmInitExprMVP Inst
Definition: WasmYAML.h:69
llvm::WasmYAML::SegmentInfo::Index
uint32_t Index
Definition: WasmYAML.h:147
llvm::wasm::WASM_LIMITS_FLAG_HAS_MAX
@ WASM_LIMITS_FLAG_HAS_MAX
Definition: Wasm.h:323
llvm::WasmYAML::NameSection
Definition: WasmYAML.h:234
llvm::WasmYAML::DataSegment::Content
yaml::BinaryRef Content
Definition: WasmYAML.h:128
llvm::WasmYAML::Section
Definition: WasmYAML.h:186
llvm::WasmYAML::Relocation::Type
RelocType Type
Definition: WasmYAML.h:115
llvm::WasmYAML::FunctionSection
Definition: WasmYAML.h:306
llvm::wasm::WASM_EXTERNAL_GLOBAL
@ WASM_EXTERNAL_GLOBAL
Definition: Wasm.h:276
llvm::WasmYAML::Limits::Maximum
yaml::Hex32 Maximum
Definition: WasmYAML.h:50
llvm::yaml::ScalarBitSetTraits< WasmYAML::SymbolFlags >::bitset
static void bitset(IO &IO, WasmYAML::SymbolFlags &Value)
Definition: WasmYAML.cpp:561
llvm::WasmYAML::ComdatEntry
Definition: WasmYAML.h:176
llvm::WasmYAML::Signature::ReturnTypes
std::vector< ValueType > ReturnTypes
Definition: WasmYAML.h:157
llvm::WasmYAML::CodeSection
Definition: WasmYAML.h:386
llvm::WasmYAML::NameEntry
Definition: WasmYAML.h:131
llvm::WasmYAML::Table::TableLimits
Limits TableLimits
Definition: WasmYAML.h:55
llvm::wasm::WasmInitExprMVP::Int64
int64_t Int64
Definition: Wasm.h:98
llvm::AMDGPU::ElfNote::SectionName
const char SectionName[]
Definition: AMDGPUPTNote.h:24
llvm::WasmYAML::SegmentInfo::Flags
SegmentFlags Flags
Definition: WasmYAML.h:150
llvm::XCOFF::VISIBILITY_MASK
constexpr uint16_t VISIBILITY_MASK
Definition: XCOFF.h:243
llvm::wasm::WASM_SYMBOL_TYPE_FUNCTION
@ WASM_SYMBOL_TYPE_FUNCTION
Definition: Wasm.h:381
llvm::WasmYAML::SymbolInfo
Definition: WasmYAML.h:160
llvm::WasmYAML::Function
Definition: WasmYAML.h:108
Info
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
llvm::WasmYAML::Limits
Definition: WasmYAML.h:47
llvm::WasmYAML::DylinkImportInfo
Definition: WasmYAML.h:206
llvm::Comdat
Definition: Comdat.h:33
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::PassSummaryAction::Import
@ Import
Import information from summary.
llvm::wasm::WASM_SEC_FUNCTION
@ WASM_SEC_FUNCTION
Definition: Wasm.h:245
llvm::WasmYAML::ExportSection
Definition: WasmYAML.h:356
llvm::wasm::WASM_OPCODE_I32_CONST
@ WASM_OPCODE_I32_CONST
Definition: Wasm.h:290
llvm::WasmYAML::Signature::Index
uint32_t Index
Definition: WasmYAML.h:154
llvm::WasmYAML::DataSegment::Offset
InitExpr Offset
Definition: WasmYAML.h:127
llvm::WasmYAML::ElemSegment::Functions
std::vector< uint32_t > Functions
Definition: WasmYAML.h:79
llvm::WasmYAML::ElemSegment::Flags
uint32_t Flags
Definition: WasmYAML.h:75
llvm::WasmYAML::SegmentInfo
Definition: WasmYAML.h:146
llvm::OutputFileType::Object
@ Object
llvm::WasmYAML::InitExpr::Body
yaml::BinaryRef Body
Definition: WasmYAML.h:70
WasmYAML.h
llvm::wasm::WASM_OPCODE_GLOBAL_GET
@ WASM_OPCODE_GLOBAL_GET
Definition: Wasm.h:286
llvm::WasmYAML::Relocation::Index
uint32_t Index
Definition: WasmYAML.h:116
ECase
#define ECase(X)
llvm::DepClassTy::REQUIRED
@ REQUIRED
The target cannot be valid if the source is not.
llvm::WasmYAML::Table::Index
uint32_t Index
Definition: WasmYAML.h:56
llvm::WasmYAML::Table
Definition: WasmYAML.h:53
llvm::WasmYAML::StartSection
Definition: WasmYAML.h:366
llvm::WasmYAML::InitExpr
Definition: WasmYAML.h:65
llvm::wasm::WASM_SEC_DATACOUNT
@ WASM_SEC_DATACOUNT
Definition: Wasm.h:254
llvm::SectionName::Name
StringRef Name
Definition: DWARFSection.h:22
llvm::WasmYAML::TargetFeaturesSection
Definition: WasmYAML.h:275
llvm::wasm::WASM_SEC_IMPORT
@ WASM_SEC_IMPORT
Definition: Wasm.h:244
llvm::wasm::WASM_SEC_GLOBAL
@ WASM_SEC_GLOBAL
Definition: Wasm.h:248
llvm::yaml::ScalarBitSetTraits< WasmYAML::SegmentFlags >::bitset
static void bitset(IO &IO, WasmYAML::SegmentFlags &Value)
Definition: WasmYAML.cpp:553
llvm::wasm::WASM_SYMBOL_TYPE_TAG
@ WASM_SYMBOL_TYPE_TAG
Definition: Wasm.h:385
llvm::wasm::WASM_DATA_SEGMENT_IS_PASSIVE
@ WASM_DATA_SEGMENT_IS_PASSIVE
Definition: Wasm.h:329
llvm::wasm::WASM_EXTERNAL_FUNCTION
@ WASM_EXTERNAL_FUNCTION
Definition: Wasm.h:273
llvm::AMDGPU::HSAMD::ValueType
ValueType
Value types.
Definition: AMDGPUMetadata.h:100
llvm::WasmYAML::FeatureEntry
Definition: WasmYAML.h:141
llvm::WasmYAML::Table::ElemType
TableType ElemType
Definition: WasmYAML.h:54
llvm::WasmYAML::FeatureEntry::Prefix
FeaturePolicyPrefix Prefix
Definition: WasmYAML.h:142
llvm::wasm::WASM_SEC_START
@ WASM_SEC_START
Definition: Wasm.h:250
llvm::yaml::ScalarEnumerationTraits< WasmYAML::ComdatKind >::enumeration
static void enumeration(IO &IO, WasmYAML::ComdatKind &Kind)
Definition: WasmYAML.cpp:482
llvm::wasm::WasmInitExprMVP::Global
uint32_t Global
Definition: Wasm.h:101
llvm::yaml::sectionMapping
static void sectionMapping(IO &IO, ELFYAML::DynamicSection &Section)
Definition: ELFYAML.cpp:1317
llvm::wasm::WasmInitExprMVP::Value
union llvm::wasm::WasmInitExprMVP::@171 Value
BCase
#define BCase(X)
YAMLTraits.h
llvm::wasm::WASM_EXTERNAL_TABLE
@ WASM_EXTERNAL_TABLE
Definition: Wasm.h:274
llvm::WasmYAML::ElemSegment::TableNumber
uint32_t TableNumber
Definition: WasmYAML.h:76
llvm::wasm::WASM_SEC_TYPE
@ WASM_SEC_TYPE
Definition: Wasm.h:243
llvm::WasmYAML::Signature
Definition: WasmYAML.h:153
llvm::WasmYAML::ComdatEntry::Kind
ComdatKind Kind
Definition: WasmYAML.h:177
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::wasm::WASM_SEC_CUSTOM
@ WASM_SEC_CUSTOM
Definition: Wasm.h:242
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
llvm::WasmYAML::Relocation::Addend
int64_t Addend
Definition: WasmYAML.h:120
llvm::wasm::WasmInitExprMVP::Int32
int32_t Int32
Definition: Wasm.h:97
llvm::yaml::commonSectionMapping
static void commonSectionMapping(IO &IO, ELFYAML::Section &Section)
Definition: ELFYAML.cpp:1290
llvm::WasmYAML::LocalDecl::Count
uint32_t Count
Definition: WasmYAML.h:105
llvm::WasmYAML::Relocation
Definition: WasmYAML.h:114
llvm::Init
Definition: Record.h:281
llvm::WasmYAML::Object
Definition: WasmYAML.h:416
I32
@ I32
Definition: DXILOpLowering.cpp:40
llvm::wasm::WASM_SEC_CODE
@ WASM_SEC_CODE
Definition: Wasm.h:252
llvm::wasm::WASM_SEC_TAG
@ WASM_SEC_TAG
Definition: Wasm.h:255
llvm::WasmYAML::DataCountSection
Definition: WasmYAML.h:406
llvm::WasmYAML::DataSegment::InitFlags
uint32_t InitFlags
Definition: WasmYAML.h:125
llvm::WasmYAML::TagSection
Definition: WasmYAML.h:336
llvm::wasm::WASM_OPCODE_F64_CONST
@ WASM_OPCODE_F64_CONST
Definition: Wasm.h:293
llvm::WasmYAML::DataSegment
Definition: WasmYAML.h:123
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:341
llvm::WasmYAML::DataSegment::MemoryIndex
uint32_t MemoryIndex
Definition: WasmYAML.h:126
llvm::WasmYAML::Limits::Flags
LimitFlags Flags
Definition: WasmYAML.h:48
llvm::WasmYAML::SegmentInfo::Alignment
uint32_t Alignment
Definition: WasmYAML.h:149
llvm::SectionName
Definition: DWARFSection.h:21
Casting.h
llvm::WasmYAML::LinkingSection
Definition: WasmYAML.h:247
llvm::WasmYAML::Global
Definition: WasmYAML.h:82
llvm::wasm::WASM_SEC_ELEM
@ WASM_SEC_ELEM
Definition: Wasm.h:251
llvm::yaml::ScalarEnumerationTraits< WasmYAML::RelocType >::enumeration
static void enumeration(IO &IO, WasmYAML::RelocType &Kind)
Definition: WasmYAML.cpp:636
llvm::yaml::ScalarBitSetTraits< WasmYAML::LimitFlags >::bitset
static void bitset(IO &IO, WasmYAML::LimitFlags &Value)
Definition: WasmYAML.cpp:544
llvm::WasmYAML::InitExpr::Extended
bool Extended
Definition: WasmYAML.h:67
llvm::WasmYAML::NameEntry::Name
StringRef Name
Definition: WasmYAML.h:133
llvm::WasmYAML::Limits::Minimum
yaml::Hex32 Minimum
Definition: WasmYAML.h:49
llvm::WasmYAML::Export
Definition: WasmYAML.h:59
BCaseMask
#define BCaseMask(M, X)
llvm::WasmYAML::TypeSection
Definition: WasmYAML.h:286
llvm::yaml::ScalarEnumerationTraits< WasmYAML::SymbolKind >::enumeration
static void enumeration(IO &IO, WasmYAML::SymbolKind &Kind)
Definition: WasmYAML.cpp:578
llvm::WasmYAML::Signature::ParamTypes
std::vector< ValueType > ParamTypes
Definition: WasmYAML.h:156
llvm::wasm::WASM_SEC_DATA
@ WASM_SEC_DATA
Definition: Wasm.h:253
llvm::WasmYAML::ElemSegment::Offset
InitExpr Offset
Definition: WasmYAML.h:78
llvm::WasmYAML::ElemSegment::ElemKind
ValueType ElemKind
Definition: WasmYAML.h:77
llvm::wasm::WasmInitExprMVP::Opcode
uint8_t Opcode
Definition: Wasm.h:95
llvm::WasmYAML::LocalDecl::Type
ValueType Type
Definition: WasmYAML.h:104
llvm::WasmYAML::DataSegment::SectionOffset
uint32_t SectionOffset
Definition: WasmYAML.h:124
llvm::wasm::WASM_EXTERNAL_MEMORY
@ WASM_EXTERNAL_MEMORY
Definition: Wasm.h:275
llvm::WasmYAML::ImportSection
Definition: WasmYAML.h:296
llvm::wasm::WasmInitExprMVP::Float32
uint32_t Float32
Definition: Wasm.h:99
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::wasm::WASM_SYMBOL_TYPE_DATA
@ WASM_SYMBOL_TYPE_DATA
Definition: Wasm.h:382
llvm::MachO::SectionType
SectionType
These are the section type and attributes fields.
Definition: MachO.h:120