blob: 9433cf6a783b80e1a0a4e2fefba1635d82eeb999 [file] [log] [blame]
Derek Schuffd3d84fd2017-03-30 19:44:09 +00001//===- WasmYAML.cpp - Wasm YAMLIO implementation --------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines classes for handling the YAML representation of wasm.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm/ObjectYAML/WasmYAML.h"
Eugene Zelenko28082ab2017-07-01 01:35:55 +000015#include "llvm/ADT/StringRef.h"
Derek Schuffd3d84fd2017-03-30 19:44:09 +000016#include "llvm/Support/Casting.h"
Eugene Zelenko28082ab2017-07-01 01:35:55 +000017#include "llvm/Support/ErrorHandling.h"
18#include "llvm/Support/YAMLTraits.h"
Derek Schuffd3d84fd2017-03-30 19:44:09 +000019
20namespace llvm {
Derek Schuffc5b472f2017-03-31 22:14:14 +000021
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
Eugene Zelenko28082ab2017-07-01 01:35:55 +000026Section::~Section() = default;
Derek Schuffc5b472f2017-03-31 22:14:14 +000027
28} // end namespace WasmYAML
29
Derek Schuffd3d84fd2017-03-30 19:44:09 +000030namespace yaml {
31
32void MappingTraits<WasmYAML::FileHeader>::mapping(
33 IO &IO, WasmYAML::FileHeader &FileHdr) {
34 IO.mapRequired("Version", FileHdr.Version);
35}
36
37void MappingTraits<WasmYAML::Object>::mapping(IO &IO,
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}
50
Sam Cleggb7787fd2017-06-20 04:04:59 +000051static void sectionMapping(IO &IO, WasmYAML::NameSection &Section) {
52 commonSectionMapping(IO, Section);
53 IO.mapRequired("Name", Section.Name);
54 IO.mapOptional("FunctionNames", Section.FunctionNames);
55}
56
57static void sectionMapping(IO &IO, WasmYAML::LinkingSection &Section) {
58 commonSectionMapping(IO, Section);
59 IO.mapRequired("Name", Section.Name);
Sam Clegg9e1ade92017-06-27 20:27:59 +000060 IO.mapRequired("DataSize", Section.DataSize);
Sam Clegg6c899ba2018-02-23 05:08:34 +000061 IO.mapOptional("SymbolTable", Section.SymbolTable);
Sam Clegg63ebb812017-09-29 16:50:08 +000062 IO.mapOptional("SegmentInfo", Section.SegmentInfos);
Sam Clegg42739982017-12-14 21:10:03 +000063 IO.mapOptional("InitFunctions", Section.InitFunctions);
Sam Cleggea7cace2018-01-09 23:43:14 +000064 IO.mapOptional("Comdats", Section.Comdats);
Sam Cleggb7787fd2017-06-20 04:04:59 +000065}
66
Derek Schuffd3d84fd2017-03-30 19:44:09 +000067static void sectionMapping(IO &IO, WasmYAML::CustomSection &Section) {
68 commonSectionMapping(IO, Section);
69 IO.mapRequired("Name", Section.Name);
Sam Cleggb7787fd2017-06-20 04:04:59 +000070 IO.mapRequired("Payload", Section.Payload);
Derek Schuffd3d84fd2017-03-30 19:44:09 +000071}
72
73static void sectionMapping(IO &IO, WasmYAML::TypeSection &Section) {
74 commonSectionMapping(IO, Section);
75 IO.mapOptional("Signatures", Section.Signatures);
76}
77
78static void sectionMapping(IO &IO, WasmYAML::ImportSection &Section) {
79 commonSectionMapping(IO, Section);
80 IO.mapOptional("Imports", Section.Imports);
81}
82
83static void sectionMapping(IO &IO, WasmYAML::FunctionSection &Section) {
84 commonSectionMapping(IO, Section);
85 IO.mapOptional("FunctionTypes", Section.FunctionTypes);
86}
87
88static void sectionMapping(IO &IO, WasmYAML::TableSection &Section) {
89 commonSectionMapping(IO, Section);
90 IO.mapOptional("Tables", Section.Tables);
91}
92
93static void sectionMapping(IO &IO, WasmYAML::MemorySection &Section) {
94 commonSectionMapping(IO, Section);
95 IO.mapOptional("Memories", Section.Memories);
96}
97
98static void sectionMapping(IO &IO, WasmYAML::GlobalSection &Section) {
99 commonSectionMapping(IO, Section);
100 IO.mapOptional("Globals", Section.Globals);
101}
102
103static void sectionMapping(IO &IO, WasmYAML::ExportSection &Section) {
104 commonSectionMapping(IO, Section);
105 IO.mapOptional("Exports", Section.Exports);
106}
107
108static void sectionMapping(IO &IO, WasmYAML::StartSection &Section) {
109 commonSectionMapping(IO, Section);
110 IO.mapOptional("StartFunction", Section.StartFunction);
111}
112
113static void sectionMapping(IO &IO, WasmYAML::ElemSection &Section) {
114 commonSectionMapping(IO, Section);
115 IO.mapOptional("Segments", Section.Segments);
116}
117
118static void sectionMapping(IO &IO, WasmYAML::CodeSection &Section) {
119 commonSectionMapping(IO, Section);
120 IO.mapRequired("Functions", Section.Functions);
121}
122
123static void sectionMapping(IO &IO, WasmYAML::DataSection &Section) {
124 commonSectionMapping(IO, Section);
125 IO.mapRequired("Segments", Section.Segments);
126}
127
128void MappingTraits<std::unique_ptr<WasmYAML::Section>>::mapping(
129 IO &IO, std::unique_ptr<WasmYAML::Section> &Section) {
130 WasmYAML::SectionType SectionType;
131 if (IO.outputting())
132 SectionType = Section->Type;
133 else
134 IO.mapRequired("Type", SectionType);
135
136 switch (SectionType) {
Sam Cleggb7787fd2017-06-20 04:04:59 +0000137 case wasm::WASM_SEC_CUSTOM: {
138 StringRef SectionName;
139 if (IO.outputting()) {
140 auto CustomSection = cast<WasmYAML::CustomSection>(Section.get());
141 SectionName = CustomSection->Name;
142 } else {
143 IO.mapRequired("Name", SectionName);
144 }
145 if (SectionName == "linking") {
146 if (!IO.outputting())
147 Section.reset(new WasmYAML::LinkingSection());
148 sectionMapping(IO, *cast<WasmYAML::LinkingSection>(Section.get()));
149 } else if (SectionName == "name") {
150 if (!IO.outputting())
151 Section.reset(new WasmYAML::NameSection());
152 sectionMapping(IO, *cast<WasmYAML::NameSection>(Section.get()));
153 } else {
154 if (!IO.outputting())
155 Section.reset(new WasmYAML::CustomSection(SectionName));
156 sectionMapping(IO, *cast<WasmYAML::CustomSection>(Section.get()));
157 }
Derek Schuffd3d84fd2017-03-30 19:44:09 +0000158 break;
Sam Cleggb7787fd2017-06-20 04:04:59 +0000159 }
Derek Schuffd3d84fd2017-03-30 19:44:09 +0000160 case wasm::WASM_SEC_TYPE:
161 if (!IO.outputting())
162 Section.reset(new WasmYAML::TypeSection());
163 sectionMapping(IO, *cast<WasmYAML::TypeSection>(Section.get()));
164 break;
165 case wasm::WASM_SEC_IMPORT:
166 if (!IO.outputting())
167 Section.reset(new WasmYAML::ImportSection());
168 sectionMapping(IO, *cast<WasmYAML::ImportSection>(Section.get()));
169 break;
170 case wasm::WASM_SEC_FUNCTION:
171 if (!IO.outputting())
172 Section.reset(new WasmYAML::FunctionSection());
173 sectionMapping(IO, *cast<WasmYAML::FunctionSection>(Section.get()));
174 break;
175 case wasm::WASM_SEC_TABLE:
176 if (!IO.outputting())
177 Section.reset(new WasmYAML::TableSection());
178 sectionMapping(IO, *cast<WasmYAML::TableSection>(Section.get()));
179 break;
180 case wasm::WASM_SEC_MEMORY:
181 if (!IO.outputting())
182 Section.reset(new WasmYAML::MemorySection());
183 sectionMapping(IO, *cast<WasmYAML::MemorySection>(Section.get()));
184 break;
185 case wasm::WASM_SEC_GLOBAL:
186 if (!IO.outputting())
187 Section.reset(new WasmYAML::GlobalSection());
188 sectionMapping(IO, *cast<WasmYAML::GlobalSection>(Section.get()));
189 break;
190 case wasm::WASM_SEC_EXPORT:
191 if (!IO.outputting())
192 Section.reset(new WasmYAML::ExportSection());
193 sectionMapping(IO, *cast<WasmYAML::ExportSection>(Section.get()));
194 break;
195 case wasm::WASM_SEC_START:
196 if (!IO.outputting())
197 Section.reset(new WasmYAML::StartSection());
198 sectionMapping(IO, *cast<WasmYAML::StartSection>(Section.get()));
199 break;
200 case wasm::WASM_SEC_ELEM:
201 if (!IO.outputting())
202 Section.reset(new WasmYAML::ElemSection());
203 sectionMapping(IO, *cast<WasmYAML::ElemSection>(Section.get()));
204 break;
205 case wasm::WASM_SEC_CODE:
206 if (!IO.outputting())
207 Section.reset(new WasmYAML::CodeSection());
208 sectionMapping(IO, *cast<WasmYAML::CodeSection>(Section.get()));
209 break;
210 case wasm::WASM_SEC_DATA:
211 if (!IO.outputting())
212 Section.reset(new WasmYAML::DataSection());
213 sectionMapping(IO, *cast<WasmYAML::DataSection>(Section.get()));
214 break;
215 default:
216 llvm_unreachable("Unknown section type");
217 }
218}
219
220void ScalarEnumerationTraits<WasmYAML::SectionType>::enumeration(
221 IO &IO, WasmYAML::SectionType &Type) {
222#define ECase(X) IO.enumCase(Type, #X, wasm::WASM_SEC_##X);
223 ECase(CUSTOM);
224 ECase(TYPE);
225 ECase(IMPORT);
226 ECase(FUNCTION);
227 ECase(TABLE);
228 ECase(MEMORY);
229 ECase(GLOBAL);
230 ECase(EXPORT);
231 ECase(START);
232 ECase(ELEM);
233 ECase(CODE);
234 ECase(DATA);
235#undef ECase
236}
237
238void MappingTraits<WasmYAML::Signature>::mapping(
239 IO &IO, WasmYAML::Signature &Signature) {
Sam Clegge53af7f2018-01-09 21:38:53 +0000240 IO.mapRequired("Index", Signature.Index);
Derek Schuffd3d84fd2017-03-30 19:44:09 +0000241 IO.mapRequired("ReturnType", Signature.ReturnType);
242 IO.mapRequired("ParamTypes", Signature.ParamTypes);
243}
244
245void MappingTraits<WasmYAML::Table>::mapping(IO &IO, WasmYAML::Table &Table) {
246 IO.mapRequired("ElemType", Table.ElemType);
247 IO.mapRequired("Limits", Table.TableLimits);
248}
249
250void MappingTraits<WasmYAML::Function>::mapping(IO &IO,
251 WasmYAML::Function &Function) {
Sam Clegge53af7f2018-01-09 21:38:53 +0000252 IO.mapRequired("Index", Function.Index);
Derek Schuffd3d84fd2017-03-30 19:44:09 +0000253 IO.mapRequired("Locals", Function.Locals);
254 IO.mapRequired("Body", Function.Body);
255}
256
257void MappingTraits<WasmYAML::Relocation>::mapping(
258 IO &IO, WasmYAML::Relocation &Relocation) {
259 IO.mapRequired("Type", Relocation.Type);
260 IO.mapRequired("Index", Relocation.Index);
261 IO.mapRequired("Offset", Relocation.Offset);
Sam Cleggcc182aa2017-04-26 00:02:31 +0000262 IO.mapOptional("Addend", Relocation.Addend, 0);
Derek Schuffd3d84fd2017-03-30 19:44:09 +0000263}
264
Sam Clegg03cdd122017-05-05 18:12:34 +0000265void MappingTraits<WasmYAML::NameEntry>::mapping(
266 IO &IO, WasmYAML::NameEntry &NameEntry) {
267 IO.mapRequired("Index", NameEntry.Index);
268 IO.mapRequired("Name", NameEntry.Name);
269}
270
Sam Clegg63ebb812017-09-29 16:50:08 +0000271void MappingTraits<WasmYAML::SegmentInfo>::mapping(
272 IO &IO, WasmYAML::SegmentInfo &SegmentInfo) {
273 IO.mapRequired("Index", SegmentInfo.Index);
274 IO.mapRequired("Name", SegmentInfo.Name);
275 IO.mapRequired("Alignment", SegmentInfo.Alignment);
276 IO.mapRequired("Flags", SegmentInfo.Flags);
277}
278
Derek Schuffd3d84fd2017-03-30 19:44:09 +0000279void MappingTraits<WasmYAML::LocalDecl>::mapping(
280 IO &IO, WasmYAML::LocalDecl &LocalDecl) {
281 IO.mapRequired("Type", LocalDecl.Type);
282 IO.mapRequired("Count", LocalDecl.Count);
283}
284
285void MappingTraits<WasmYAML::Limits>::mapping(IO &IO,
286 WasmYAML::Limits &Limits) {
287 if (!IO.outputting() || Limits.Flags)
288 IO.mapOptional("Flags", Limits.Flags);
289 IO.mapRequired("Initial", Limits.Initial);
290 if (!IO.outputting() || Limits.Flags & wasm::WASM_LIMITS_FLAG_HAS_MAX)
291 IO.mapOptional("Maximum", Limits.Maximum);
292}
293
294void MappingTraits<WasmYAML::ElemSegment>::mapping(
295 IO &IO, WasmYAML::ElemSegment &Segment) {
296 IO.mapRequired("Offset", Segment.Offset);
297 IO.mapRequired("Functions", Segment.Functions);
298}
299
300void MappingTraits<WasmYAML::Import>::mapping(IO &IO,
301 WasmYAML::Import &Import) {
302 IO.mapRequired("Module", Import.Module);
303 IO.mapRequired("Field", Import.Field);
304 IO.mapRequired("Kind", Import.Kind);
305 if (Import.Kind == wasm::WASM_EXTERNAL_FUNCTION) {
306 IO.mapRequired("SigIndex", Import.SigIndex);
307 } else if (Import.Kind == wasm::WASM_EXTERNAL_GLOBAL) {
Sam Clegg41db5192017-05-10 00:14:04 +0000308 IO.mapRequired("GlobalType", Import.GlobalImport.Type);
309 IO.mapRequired("GlobalMutable", Import.GlobalImport.Mutable);
Sam Clegg2ffff5a2017-05-09 23:48:41 +0000310 } else if (Import.Kind == wasm::WASM_EXTERNAL_TABLE) {
Sam Clegg41db5192017-05-10 00:14:04 +0000311 IO.mapRequired("Table", Import.TableImport);
Sam Clegg2ffff5a2017-05-09 23:48:41 +0000312 } else if (Import.Kind == wasm::WASM_EXTERNAL_MEMORY ) {
313 IO.mapRequired("Memory", Import.Memory);
Derek Schuffd3d84fd2017-03-30 19:44:09 +0000314 } else {
315 llvm_unreachable("unhandled import type");
316 }
317}
318
319void MappingTraits<WasmYAML::Export>::mapping(IO &IO,
320 WasmYAML::Export &Export) {
321 IO.mapRequired("Name", Export.Name);
322 IO.mapRequired("Kind", Export.Kind);
323 IO.mapRequired("Index", Export.Index);
324}
325
326void MappingTraits<WasmYAML::Global>::mapping(IO &IO,
327 WasmYAML::Global &Global) {
Sam Clegge53af7f2018-01-09 21:38:53 +0000328 IO.mapRequired("Index", Global.Index);
Derek Schuffd3d84fd2017-03-30 19:44:09 +0000329 IO.mapRequired("Type", Global.Type);
330 IO.mapRequired("Mutable", Global.Mutable);
331 IO.mapRequired("InitExpr", Global.InitExpr);
332}
333
334void MappingTraits<wasm::WasmInitExpr>::mapping(IO &IO,
335 wasm::WasmInitExpr &Expr) {
336 WasmYAML::Opcode Op = Expr.Opcode;
337 IO.mapRequired("Opcode", Op);
338 Expr.Opcode = Op;
339 switch (Expr.Opcode) {
340 case wasm::WASM_OPCODE_I32_CONST:
341 IO.mapRequired("Value", Expr.Value.Int32);
342 break;
343 case wasm::WASM_OPCODE_I64_CONST:
344 IO.mapRequired("Value", Expr.Value.Int64);
345 break;
346 case wasm::WASM_OPCODE_F32_CONST:
347 IO.mapRequired("Value", Expr.Value.Float32);
348 break;
349 case wasm::WASM_OPCODE_F64_CONST:
350 IO.mapRequired("Value", Expr.Value.Float64);
351 break;
Sam Clegg7fb391f2017-04-25 17:11:56 +0000352 case wasm::WASM_OPCODE_GET_GLOBAL:
353 IO.mapRequired("Index", Expr.Value.Global);
354 break;
Derek Schuffd3d84fd2017-03-30 19:44:09 +0000355 }
356}
357
358void MappingTraits<WasmYAML::DataSegment>::mapping(
359 IO &IO, WasmYAML::DataSegment &Segment) {
Sam Clegg9c07f942017-07-12 00:24:54 +0000360 IO.mapOptional("SectionOffset", Segment.SectionOffset);
361 IO.mapRequired("MemoryIndex", Segment.MemoryIndex);
Derek Schuffd3d84fd2017-03-30 19:44:09 +0000362 IO.mapRequired("Offset", Segment.Offset);
363 IO.mapRequired("Content", Segment.Content);
364}
365
Sam Clegg42739982017-12-14 21:10:03 +0000366void MappingTraits<WasmYAML::InitFunction>::mapping(
367 IO &IO, WasmYAML::InitFunction &Init) {
368 IO.mapRequired("Priority", Init.Priority);
Sam Clegg6c899ba2018-02-23 05:08:34 +0000369 IO.mapRequired("Symbol", Init.Symbol);
Sam Clegg42739982017-12-14 21:10:03 +0000370}
371
Sam Cleggea7cace2018-01-09 23:43:14 +0000372void ScalarEnumerationTraits<WasmYAML::ComdatKind>::enumeration(
373 IO &IO, WasmYAML::ComdatKind &Kind) {
374#define ECase(X) IO.enumCase(Kind, #X, wasm::WASM_COMDAT_##X);
375 ECase(FUNCTION);
376 ECase(DATA);
377#undef ECase
378}
379
380void MappingTraits<WasmYAML::ComdatEntry>::mapping(
381 IO &IO, WasmYAML::ComdatEntry &ComdatEntry) {
382 IO.mapRequired("Kind", ComdatEntry.Kind);
383 IO.mapRequired("Index", ComdatEntry.Index);
384}
385
386void MappingTraits<WasmYAML::Comdat>::mapping(
387 IO &IO, WasmYAML::Comdat &Comdat) {
388 IO.mapRequired("Name", Comdat.Name);
389 IO.mapRequired("Entries", Comdat.Entries);
390}
391
Sam Cleggb7787fd2017-06-20 04:04:59 +0000392void MappingTraits<WasmYAML::SymbolInfo>::mapping(IO &IO,
393 WasmYAML::SymbolInfo &Info) {
Sam Clegg6c899ba2018-02-23 05:08:34 +0000394 IO.mapRequired("Index", Info.Index);
395 IO.mapRequired("Kind", Info.Kind);
Sam Cleggb7787fd2017-06-20 04:04:59 +0000396 IO.mapRequired("Name", Info.Name);
397 IO.mapRequired("Flags", Info.Flags);
Sam Clegg6c899ba2018-02-23 05:08:34 +0000398 if (Info.Kind == wasm::WASM_SYMBOL_TYPE_FUNCTION) {
399 IO.mapRequired("Function", Info.ElementIndex);
400 } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_GLOBAL) {
401 IO.mapRequired("Global", Info.ElementIndex);
402 } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_DATA) {
403 if ((Info.Flags & wasm::WASM_SYMBOL_UNDEFINED) == 0) {
404 IO.mapRequired("Segment", Info.DataRef.Segment);
405 IO.mapOptional("Offset", Info.DataRef.Offset, 0u);
406 IO.mapRequired("Size", Info.DataRef.Size);
407 }
408 } else {
409 llvm_unreachable("unsupported symbol kind");
410 }
Sam Cleggb7787fd2017-06-20 04:04:59 +0000411}
412
Sam Clegg0fc55992017-12-13 22:02:25 +0000413void ScalarBitSetTraits<WasmYAML::LimitFlags>::bitset(
414 IO &IO, WasmYAML::LimitFlags &Value) {
415#define BCase(X) IO.bitSetCase(Value, #X, wasm::WASM_LIMITS_FLAG_##X)
416 BCase(HAS_MAX);
417#undef BCase
418}
419
420void ScalarBitSetTraits<WasmYAML::SegmentFlags>::bitset(
421 IO &IO, WasmYAML::SegmentFlags &Value) {
422}
423
424void ScalarBitSetTraits<WasmYAML::SymbolFlags>::bitset(
425 IO &IO, WasmYAML::SymbolFlags &Value) {
426#define BCaseMask(M, X) IO.maskedBitSetCase(Value, #X, wasm::WASM_SYMBOL_##X, wasm::WASM_SYMBOL_##M)
427 //BCaseMask(BINDING_MASK, BINDING_GLOBAL);
428 BCaseMask(BINDING_MASK, BINDING_WEAK);
429 BCaseMask(BINDING_MASK, BINDING_LOCAL);
430 //BCaseMask(VISIBILITY_MASK, VISIBILITY_DEFAULT);
431 BCaseMask(VISIBILITY_MASK, VISIBILITY_HIDDEN);
Sam Clegg6c899ba2018-02-23 05:08:34 +0000432 BCaseMask(UNDEFINED, UNDEFINED);
Sam Clegg0fc55992017-12-13 22:02:25 +0000433#undef BCaseMask
434}
435
Sam Clegg6c899ba2018-02-23 05:08:34 +0000436void ScalarEnumerationTraits<WasmYAML::SymbolKind>::enumeration(
437 IO &IO, WasmYAML::SymbolKind &Kind) {
438#define ECase(X) IO.enumCase(Kind, #X, wasm::WASM_SYMBOL_TYPE_##X);
439 ECase(FUNCTION);
440 ECase(DATA);
441 ECase(GLOBAL);
442#undef ECase
443}
444
Derek Schuffd3d84fd2017-03-30 19:44:09 +0000445void ScalarEnumerationTraits<WasmYAML::ValueType>::enumeration(
446 IO &IO, WasmYAML::ValueType &Type) {
447#define ECase(X) IO.enumCase(Type, #X, wasm::WASM_TYPE_##X);
448 ECase(I32);
449 ECase(I64);
450 ECase(F32);
451 ECase(F64);
452 ECase(ANYFUNC);
453 ECase(FUNC);
454 ECase(NORESULT);
455#undef ECase
456}
457
458void ScalarEnumerationTraits<WasmYAML::ExportKind>::enumeration(
459 IO &IO, WasmYAML::ExportKind &Kind) {
460#define ECase(X) IO.enumCase(Kind, #X, wasm::WASM_EXTERNAL_##X);
461 ECase(FUNCTION);
462 ECase(TABLE);
463 ECase(MEMORY);
464 ECase(GLOBAL);
465#undef ECase
466}
467
468void ScalarEnumerationTraits<WasmYAML::Opcode>::enumeration(
469 IO &IO, WasmYAML::Opcode &Code) {
470#define ECase(X) IO.enumCase(Code, #X, wasm::WASM_OPCODE_##X);
471 ECase(END);
472 ECase(I32_CONST);
473 ECase(I64_CONST);
474 ECase(F64_CONST);
475 ECase(F32_CONST);
476 ECase(GET_GLOBAL);
477#undef ECase
478}
479
480void ScalarEnumerationTraits<WasmYAML::TableType>::enumeration(
481 IO &IO, WasmYAML::TableType &Type) {
482#define ECase(X) IO.enumCase(Type, #X, wasm::WASM_TYPE_##X);
483 ECase(ANYFUNC);
484#undef ECase
485}
486
487void ScalarEnumerationTraits<WasmYAML::RelocType>::enumeration(
488 IO &IO, WasmYAML::RelocType &Type) {
489#define WASM_RELOC(name, value) IO.enumCase(Type, #name, wasm::name);
Sam Cleggc5d8bc82017-12-21 03:16:34 +0000490#include "llvm/BinaryFormat/WasmRelocs.def"
Derek Schuffd3d84fd2017-03-30 19:44:09 +0000491#undef WASM_RELOC
492}
493
494} // end namespace yaml
Eugene Zelenko28082ab2017-07-01 01:35:55 +0000495
Derek Schuffd3d84fd2017-03-30 19:44:09 +0000496} // end namespace llvm