10b57cec5SDimitry Andric //===- WasmYAML.h - Wasm YAMLIO implementation ------------------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric /// 90b57cec5SDimitry Andric /// \file 100b57cec5SDimitry Andric /// This file declares classes for handling the YAML representation 110b57cec5SDimitry Andric /// of wasm binaries. 120b57cec5SDimitry Andric /// 130b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 140b57cec5SDimitry Andric 150b57cec5SDimitry Andric #ifndef LLVM_OBJECTYAML_WASMYAML_H 160b57cec5SDimitry Andric #define LLVM_OBJECTYAML_WASMYAML_H 170b57cec5SDimitry Andric 180b57cec5SDimitry Andric #include "llvm/ADT/StringRef.h" 190b57cec5SDimitry Andric #include "llvm/BinaryFormat/Wasm.h" 200b57cec5SDimitry Andric #include "llvm/ObjectYAML/YAML.h" 210b57cec5SDimitry Andric #include "llvm/Support/Casting.h" 220b57cec5SDimitry Andric #include <cstdint> 230b57cec5SDimitry Andric #include <memory> 240b57cec5SDimitry Andric #include <vector> 250b57cec5SDimitry Andric 260b57cec5SDimitry Andric namespace llvm { 270b57cec5SDimitry Andric namespace WasmYAML { 280b57cec5SDimitry Andric 290b57cec5SDimitry Andric LLVM_YAML_STRONG_TYPEDEF(uint32_t, SectionType) 300b57cec5SDimitry Andric LLVM_YAML_STRONG_TYPEDEF(uint32_t, ValueType) 310b57cec5SDimitry Andric LLVM_YAML_STRONG_TYPEDEF(uint32_t, TableType) 320b57cec5SDimitry Andric LLVM_YAML_STRONG_TYPEDEF(uint32_t, SignatureForm) 330b57cec5SDimitry Andric LLVM_YAML_STRONG_TYPEDEF(uint32_t, ExportKind) 340b57cec5SDimitry Andric LLVM_YAML_STRONG_TYPEDEF(uint32_t, Opcode) 350b57cec5SDimitry Andric LLVM_YAML_STRONG_TYPEDEF(uint32_t, RelocType) 360b57cec5SDimitry Andric LLVM_YAML_STRONG_TYPEDEF(uint32_t, SymbolFlags) 370b57cec5SDimitry Andric LLVM_YAML_STRONG_TYPEDEF(uint32_t, SymbolKind) 380b57cec5SDimitry Andric LLVM_YAML_STRONG_TYPEDEF(uint32_t, SegmentFlags) 390b57cec5SDimitry Andric LLVM_YAML_STRONG_TYPEDEF(uint32_t, LimitFlags) 400b57cec5SDimitry Andric LLVM_YAML_STRONG_TYPEDEF(uint32_t, ComdatKind) 410b57cec5SDimitry Andric LLVM_YAML_STRONG_TYPEDEF(uint32_t, FeaturePolicyPrefix) 420b57cec5SDimitry Andric 430b57cec5SDimitry Andric struct FileHeader { 440b57cec5SDimitry Andric yaml::Hex32 Version; 450b57cec5SDimitry Andric }; 460b57cec5SDimitry Andric 470b57cec5SDimitry Andric struct Limits { 480b57cec5SDimitry Andric LimitFlags Flags; 49*fe6060f1SDimitry Andric yaml::Hex32 Minimum; 500b57cec5SDimitry Andric yaml::Hex32 Maximum; 510b57cec5SDimitry Andric }; 520b57cec5SDimitry Andric 530b57cec5SDimitry Andric struct Table { 540b57cec5SDimitry Andric TableType ElemType; 550b57cec5SDimitry Andric Limits TableLimits; 56e8d8bef9SDimitry Andric uint32_t Index; 570b57cec5SDimitry Andric }; 580b57cec5SDimitry Andric 590b57cec5SDimitry Andric struct Export { 600b57cec5SDimitry Andric StringRef Name; 610b57cec5SDimitry Andric ExportKind Kind; 620b57cec5SDimitry Andric uint32_t Index; 630b57cec5SDimitry Andric }; 640b57cec5SDimitry Andric 650b57cec5SDimitry Andric struct ElemSegment { 66*fe6060f1SDimitry Andric uint32_t Flags; 67*fe6060f1SDimitry Andric uint32_t TableNumber; 68*fe6060f1SDimitry Andric ValueType ElemKind; 690b57cec5SDimitry Andric wasm::WasmInitExpr Offset; 700b57cec5SDimitry Andric std::vector<uint32_t> Functions; 710b57cec5SDimitry Andric }; 720b57cec5SDimitry Andric 730b57cec5SDimitry Andric struct Global { 740b57cec5SDimitry Andric uint32_t Index; 750b57cec5SDimitry Andric ValueType Type; 760b57cec5SDimitry Andric bool Mutable; 770b57cec5SDimitry Andric wasm::WasmInitExpr InitExpr; 780b57cec5SDimitry Andric }; 790b57cec5SDimitry Andric 80*fe6060f1SDimitry Andric struct Tag { 810b57cec5SDimitry Andric uint32_t Index; 820b57cec5SDimitry Andric uint32_t Attribute; 830b57cec5SDimitry Andric uint32_t SigIndex; 840b57cec5SDimitry Andric }; 850b57cec5SDimitry Andric 860b57cec5SDimitry Andric struct Import { 870b57cec5SDimitry Andric StringRef Module; 880b57cec5SDimitry Andric StringRef Field; 890b57cec5SDimitry Andric ExportKind Kind; 900b57cec5SDimitry Andric union { 910b57cec5SDimitry Andric uint32_t SigIndex; 920b57cec5SDimitry Andric Global GlobalImport; 930b57cec5SDimitry Andric Table TableImport; 940b57cec5SDimitry Andric Limits Memory; 95*fe6060f1SDimitry Andric Tag TagImport; 960b57cec5SDimitry Andric }; 970b57cec5SDimitry Andric }; 980b57cec5SDimitry Andric 990b57cec5SDimitry Andric struct LocalDecl { 1000b57cec5SDimitry Andric ValueType Type; 1010b57cec5SDimitry Andric uint32_t Count; 1020b57cec5SDimitry Andric }; 1030b57cec5SDimitry Andric 1040b57cec5SDimitry Andric struct Function { 1050b57cec5SDimitry Andric uint32_t Index; 1060b57cec5SDimitry Andric std::vector<LocalDecl> Locals; 1070b57cec5SDimitry Andric yaml::BinaryRef Body; 1080b57cec5SDimitry Andric }; 1090b57cec5SDimitry Andric 1100b57cec5SDimitry Andric struct Relocation { 1110b57cec5SDimitry Andric RelocType Type; 1120b57cec5SDimitry Andric uint32_t Index; 1135ffd83dbSDimitry Andric // TODO(wvo): this would strictly be better as Hex64, but that will change 1145ffd83dbSDimitry Andric // all existing obj2yaml output. 1150b57cec5SDimitry Andric yaml::Hex32 Offset; 1165ffd83dbSDimitry Andric int64_t Addend; 1170b57cec5SDimitry Andric }; 1180b57cec5SDimitry Andric 1190b57cec5SDimitry Andric struct DataSegment { 1200b57cec5SDimitry Andric uint32_t SectionOffset; 1210b57cec5SDimitry Andric uint32_t InitFlags; 1220b57cec5SDimitry Andric uint32_t MemoryIndex; 1230b57cec5SDimitry Andric wasm::WasmInitExpr Offset; 1240b57cec5SDimitry Andric yaml::BinaryRef Content; 1250b57cec5SDimitry Andric }; 1260b57cec5SDimitry Andric 1270b57cec5SDimitry Andric struct NameEntry { 1280b57cec5SDimitry Andric uint32_t Index; 1290b57cec5SDimitry Andric StringRef Name; 1300b57cec5SDimitry Andric }; 1310b57cec5SDimitry Andric 1320b57cec5SDimitry Andric struct ProducerEntry { 1330b57cec5SDimitry Andric std::string Name; 1340b57cec5SDimitry Andric std::string Version; 1350b57cec5SDimitry Andric }; 1360b57cec5SDimitry Andric 1370b57cec5SDimitry Andric struct FeatureEntry { 1380b57cec5SDimitry Andric FeaturePolicyPrefix Prefix; 1390b57cec5SDimitry Andric std::string Name; 1400b57cec5SDimitry Andric }; 1410b57cec5SDimitry Andric 1420b57cec5SDimitry Andric struct SegmentInfo { 1430b57cec5SDimitry Andric uint32_t Index; 1440b57cec5SDimitry Andric StringRef Name; 1450b57cec5SDimitry Andric uint32_t Alignment; 1460b57cec5SDimitry Andric SegmentFlags Flags; 1470b57cec5SDimitry Andric }; 1480b57cec5SDimitry Andric 1490b57cec5SDimitry Andric struct Signature { 1500b57cec5SDimitry Andric uint32_t Index; 1510b57cec5SDimitry Andric SignatureForm Form = wasm::WASM_TYPE_FUNC; 1520b57cec5SDimitry Andric std::vector<ValueType> ParamTypes; 1538bcb0991SDimitry Andric std::vector<ValueType> ReturnTypes; 1540b57cec5SDimitry Andric }; 1550b57cec5SDimitry Andric 1560b57cec5SDimitry Andric struct SymbolInfo { 1570b57cec5SDimitry Andric uint32_t Index; 1580b57cec5SDimitry Andric StringRef Name; 1590b57cec5SDimitry Andric SymbolKind Kind; 1600b57cec5SDimitry Andric SymbolFlags Flags; 1610b57cec5SDimitry Andric union { 1620b57cec5SDimitry Andric uint32_t ElementIndex; 1630b57cec5SDimitry Andric wasm::WasmDataReference DataRef; 1640b57cec5SDimitry Andric }; 1650b57cec5SDimitry Andric }; 1660b57cec5SDimitry Andric 1670b57cec5SDimitry Andric struct InitFunction { 1680b57cec5SDimitry Andric uint32_t Priority; 1690b57cec5SDimitry Andric uint32_t Symbol; 1700b57cec5SDimitry Andric }; 1710b57cec5SDimitry Andric 1720b57cec5SDimitry Andric struct ComdatEntry { 1730b57cec5SDimitry Andric ComdatKind Kind; 1740b57cec5SDimitry Andric uint32_t Index; 1750b57cec5SDimitry Andric }; 1760b57cec5SDimitry Andric 1770b57cec5SDimitry Andric struct Comdat { 1780b57cec5SDimitry Andric StringRef Name; 1790b57cec5SDimitry Andric std::vector<ComdatEntry> Entries; 1800b57cec5SDimitry Andric }; 1810b57cec5SDimitry Andric 1820b57cec5SDimitry Andric struct Section { 1830b57cec5SDimitry Andric explicit Section(SectionType SecType) : Type(SecType) {} 1840b57cec5SDimitry Andric virtual ~Section(); 1850b57cec5SDimitry Andric 1860b57cec5SDimitry Andric SectionType Type; 1870b57cec5SDimitry Andric std::vector<Relocation> Relocations; 1880b57cec5SDimitry Andric }; 1890b57cec5SDimitry Andric 1900b57cec5SDimitry Andric struct CustomSection : Section { 1910b57cec5SDimitry Andric explicit CustomSection(StringRef Name) 1920b57cec5SDimitry Andric : Section(wasm::WASM_SEC_CUSTOM), Name(Name) {} 1930b57cec5SDimitry Andric 1940b57cec5SDimitry Andric static bool classof(const Section *S) { 1950b57cec5SDimitry Andric return S->Type == wasm::WASM_SEC_CUSTOM; 1960b57cec5SDimitry Andric } 1970b57cec5SDimitry Andric 1980b57cec5SDimitry Andric StringRef Name; 1990b57cec5SDimitry Andric yaml::BinaryRef Payload; 2000b57cec5SDimitry Andric }; 2010b57cec5SDimitry Andric 2020b57cec5SDimitry Andric struct DylinkSection : CustomSection { 2030b57cec5SDimitry Andric DylinkSection() : CustomSection("dylink") {} 2040b57cec5SDimitry Andric 2050b57cec5SDimitry Andric static bool classof(const Section *S) { 2060b57cec5SDimitry Andric auto C = dyn_cast<CustomSection>(S); 2070b57cec5SDimitry Andric return C && C->Name == "dylink"; 2080b57cec5SDimitry Andric } 2090b57cec5SDimitry Andric 2100b57cec5SDimitry Andric uint32_t MemorySize; 2110b57cec5SDimitry Andric uint32_t MemoryAlignment; 2120b57cec5SDimitry Andric uint32_t TableSize; 2130b57cec5SDimitry Andric uint32_t TableAlignment; 2140b57cec5SDimitry Andric std::vector<StringRef> Needed; 2150b57cec5SDimitry Andric }; 2160b57cec5SDimitry Andric 2170b57cec5SDimitry Andric struct NameSection : CustomSection { 2180b57cec5SDimitry Andric NameSection() : CustomSection("name") {} 2190b57cec5SDimitry Andric 2200b57cec5SDimitry Andric static bool classof(const Section *S) { 2210b57cec5SDimitry Andric auto C = dyn_cast<CustomSection>(S); 2220b57cec5SDimitry Andric return C && C->Name == "name"; 2230b57cec5SDimitry Andric } 2240b57cec5SDimitry Andric 2250b57cec5SDimitry Andric std::vector<NameEntry> FunctionNames; 226e8d8bef9SDimitry Andric std::vector<NameEntry> GlobalNames; 227e8d8bef9SDimitry Andric std::vector<NameEntry> DataSegmentNames; 2280b57cec5SDimitry Andric }; 2290b57cec5SDimitry Andric 2300b57cec5SDimitry Andric struct LinkingSection : CustomSection { 2310b57cec5SDimitry Andric LinkingSection() : CustomSection("linking") {} 2320b57cec5SDimitry Andric 2330b57cec5SDimitry Andric static bool classof(const Section *S) { 2340b57cec5SDimitry Andric auto C = dyn_cast<CustomSection>(S); 2350b57cec5SDimitry Andric return C && C->Name == "linking"; 2360b57cec5SDimitry Andric } 2370b57cec5SDimitry Andric 2380b57cec5SDimitry Andric uint32_t Version; 2390b57cec5SDimitry Andric std::vector<SymbolInfo> SymbolTable; 2400b57cec5SDimitry Andric std::vector<SegmentInfo> SegmentInfos; 2410b57cec5SDimitry Andric std::vector<InitFunction> InitFunctions; 2420b57cec5SDimitry Andric std::vector<Comdat> Comdats; 2430b57cec5SDimitry Andric }; 2440b57cec5SDimitry Andric 2450b57cec5SDimitry Andric struct ProducersSection : CustomSection { 2460b57cec5SDimitry Andric ProducersSection() : CustomSection("producers") {} 2470b57cec5SDimitry Andric 2480b57cec5SDimitry Andric static bool classof(const Section *S) { 2490b57cec5SDimitry Andric auto C = dyn_cast<CustomSection>(S); 2500b57cec5SDimitry Andric return C && C->Name == "producers"; 2510b57cec5SDimitry Andric } 2520b57cec5SDimitry Andric 2530b57cec5SDimitry Andric std::vector<ProducerEntry> Languages; 2540b57cec5SDimitry Andric std::vector<ProducerEntry> Tools; 2550b57cec5SDimitry Andric std::vector<ProducerEntry> SDKs; 2560b57cec5SDimitry Andric }; 2570b57cec5SDimitry Andric 2580b57cec5SDimitry Andric struct TargetFeaturesSection : CustomSection { 2590b57cec5SDimitry Andric TargetFeaturesSection() : CustomSection("target_features") {} 2600b57cec5SDimitry Andric 2610b57cec5SDimitry Andric static bool classof(const Section *S) { 2620b57cec5SDimitry Andric auto C = dyn_cast<CustomSection>(S); 2630b57cec5SDimitry Andric return C && C->Name == "target_features"; 2640b57cec5SDimitry Andric } 2650b57cec5SDimitry Andric 2660b57cec5SDimitry Andric std::vector<FeatureEntry> Features; 2670b57cec5SDimitry Andric }; 2680b57cec5SDimitry Andric 2690b57cec5SDimitry Andric struct TypeSection : Section { 2700b57cec5SDimitry Andric TypeSection() : Section(wasm::WASM_SEC_TYPE) {} 2710b57cec5SDimitry Andric 2720b57cec5SDimitry Andric static bool classof(const Section *S) { 2730b57cec5SDimitry Andric return S->Type == wasm::WASM_SEC_TYPE; 2740b57cec5SDimitry Andric } 2750b57cec5SDimitry Andric 2760b57cec5SDimitry Andric std::vector<Signature> Signatures; 2770b57cec5SDimitry Andric }; 2780b57cec5SDimitry Andric 2790b57cec5SDimitry Andric struct ImportSection : Section { 2800b57cec5SDimitry Andric ImportSection() : Section(wasm::WASM_SEC_IMPORT) {} 2810b57cec5SDimitry Andric 2820b57cec5SDimitry Andric static bool classof(const Section *S) { 2830b57cec5SDimitry Andric return S->Type == wasm::WASM_SEC_IMPORT; 2840b57cec5SDimitry Andric } 2850b57cec5SDimitry Andric 2860b57cec5SDimitry Andric std::vector<Import> Imports; 2870b57cec5SDimitry Andric }; 2880b57cec5SDimitry Andric 2890b57cec5SDimitry Andric struct FunctionSection : Section { 2900b57cec5SDimitry Andric FunctionSection() : Section(wasm::WASM_SEC_FUNCTION) {} 2910b57cec5SDimitry Andric 2920b57cec5SDimitry Andric static bool classof(const Section *S) { 2930b57cec5SDimitry Andric return S->Type == wasm::WASM_SEC_FUNCTION; 2940b57cec5SDimitry Andric } 2950b57cec5SDimitry Andric 2960b57cec5SDimitry Andric std::vector<uint32_t> FunctionTypes; 2970b57cec5SDimitry Andric }; 2980b57cec5SDimitry Andric 2990b57cec5SDimitry Andric struct TableSection : Section { 3000b57cec5SDimitry Andric TableSection() : Section(wasm::WASM_SEC_TABLE) {} 3010b57cec5SDimitry Andric 3020b57cec5SDimitry Andric static bool classof(const Section *S) { 3030b57cec5SDimitry Andric return S->Type == wasm::WASM_SEC_TABLE; 3040b57cec5SDimitry Andric } 3050b57cec5SDimitry Andric 3060b57cec5SDimitry Andric std::vector<Table> Tables; 3070b57cec5SDimitry Andric }; 3080b57cec5SDimitry Andric 3090b57cec5SDimitry Andric struct MemorySection : Section { 3100b57cec5SDimitry Andric MemorySection() : Section(wasm::WASM_SEC_MEMORY) {} 3110b57cec5SDimitry Andric 3120b57cec5SDimitry Andric static bool classof(const Section *S) { 3130b57cec5SDimitry Andric return S->Type == wasm::WASM_SEC_MEMORY; 3140b57cec5SDimitry Andric } 3150b57cec5SDimitry Andric 3160b57cec5SDimitry Andric std::vector<Limits> Memories; 3170b57cec5SDimitry Andric }; 3180b57cec5SDimitry Andric 319*fe6060f1SDimitry Andric struct TagSection : Section { 320*fe6060f1SDimitry Andric TagSection() : Section(wasm::WASM_SEC_TAG) {} 3210b57cec5SDimitry Andric 3220b57cec5SDimitry Andric static bool classof(const Section *S) { 323*fe6060f1SDimitry Andric return S->Type == wasm::WASM_SEC_TAG; 3240b57cec5SDimitry Andric } 3250b57cec5SDimitry Andric 326*fe6060f1SDimitry Andric std::vector<Tag> Tags; 3270b57cec5SDimitry Andric }; 3280b57cec5SDimitry Andric 3295ffd83dbSDimitry Andric struct GlobalSection : Section { 3305ffd83dbSDimitry Andric GlobalSection() : Section(wasm::WASM_SEC_GLOBAL) {} 3315ffd83dbSDimitry Andric 3325ffd83dbSDimitry Andric static bool classof(const Section *S) { 3335ffd83dbSDimitry Andric return S->Type == wasm::WASM_SEC_GLOBAL; 3345ffd83dbSDimitry Andric } 3355ffd83dbSDimitry Andric 3365ffd83dbSDimitry Andric std::vector<Global> Globals; 3375ffd83dbSDimitry Andric }; 3385ffd83dbSDimitry Andric 3390b57cec5SDimitry Andric struct ExportSection : Section { 3400b57cec5SDimitry Andric ExportSection() : Section(wasm::WASM_SEC_EXPORT) {} 3410b57cec5SDimitry Andric 3420b57cec5SDimitry Andric static bool classof(const Section *S) { 3430b57cec5SDimitry Andric return S->Type == wasm::WASM_SEC_EXPORT; 3440b57cec5SDimitry Andric } 3450b57cec5SDimitry Andric 3460b57cec5SDimitry Andric std::vector<Export> Exports; 3470b57cec5SDimitry Andric }; 3480b57cec5SDimitry Andric 3490b57cec5SDimitry Andric struct StartSection : Section { 3500b57cec5SDimitry Andric StartSection() : Section(wasm::WASM_SEC_START) {} 3510b57cec5SDimitry Andric 3520b57cec5SDimitry Andric static bool classof(const Section *S) { 3530b57cec5SDimitry Andric return S->Type == wasm::WASM_SEC_START; 3540b57cec5SDimitry Andric } 3550b57cec5SDimitry Andric 3560b57cec5SDimitry Andric uint32_t StartFunction; 3570b57cec5SDimitry Andric }; 3580b57cec5SDimitry Andric 3590b57cec5SDimitry Andric struct ElemSection : Section { 3600b57cec5SDimitry Andric ElemSection() : Section(wasm::WASM_SEC_ELEM) {} 3610b57cec5SDimitry Andric 3620b57cec5SDimitry Andric static bool classof(const Section *S) { 3630b57cec5SDimitry Andric return S->Type == wasm::WASM_SEC_ELEM; 3640b57cec5SDimitry Andric } 3650b57cec5SDimitry Andric 3660b57cec5SDimitry Andric std::vector<ElemSegment> Segments; 3670b57cec5SDimitry Andric }; 3680b57cec5SDimitry Andric 3690b57cec5SDimitry Andric struct CodeSection : Section { 3700b57cec5SDimitry Andric CodeSection() : Section(wasm::WASM_SEC_CODE) {} 3710b57cec5SDimitry Andric 3720b57cec5SDimitry Andric static bool classof(const Section *S) { 3730b57cec5SDimitry Andric return S->Type == wasm::WASM_SEC_CODE; 3740b57cec5SDimitry Andric } 3750b57cec5SDimitry Andric 3760b57cec5SDimitry Andric std::vector<Function> Functions; 3770b57cec5SDimitry Andric }; 3780b57cec5SDimitry Andric 3790b57cec5SDimitry Andric struct DataSection : Section { 3800b57cec5SDimitry Andric DataSection() : Section(wasm::WASM_SEC_DATA) {} 3810b57cec5SDimitry Andric 3820b57cec5SDimitry Andric static bool classof(const Section *S) { 3830b57cec5SDimitry Andric return S->Type == wasm::WASM_SEC_DATA; 3840b57cec5SDimitry Andric } 3850b57cec5SDimitry Andric 3860b57cec5SDimitry Andric std::vector<DataSegment> Segments; 3870b57cec5SDimitry Andric }; 3880b57cec5SDimitry Andric 3890b57cec5SDimitry Andric struct DataCountSection : Section { 3900b57cec5SDimitry Andric DataCountSection() : Section(wasm::WASM_SEC_DATACOUNT) {} 3910b57cec5SDimitry Andric 3920b57cec5SDimitry Andric static bool classof(const Section *S) { 3930b57cec5SDimitry Andric return S->Type == wasm::WASM_SEC_DATACOUNT; 3940b57cec5SDimitry Andric } 3950b57cec5SDimitry Andric 3960b57cec5SDimitry Andric uint32_t Count; 3970b57cec5SDimitry Andric }; 3980b57cec5SDimitry Andric 3990b57cec5SDimitry Andric struct Object { 4000b57cec5SDimitry Andric FileHeader Header; 4010b57cec5SDimitry Andric std::vector<std::unique_ptr<Section>> Sections; 4020b57cec5SDimitry Andric }; 4030b57cec5SDimitry Andric 4040b57cec5SDimitry Andric } // end namespace WasmYAML 4050b57cec5SDimitry Andric } // end namespace llvm 4060b57cec5SDimitry Andric 4070b57cec5SDimitry Andric LLVM_YAML_IS_SEQUENCE_VECTOR(std::unique_ptr<llvm::WasmYAML::Section>) 4080b57cec5SDimitry Andric LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Signature) 4090b57cec5SDimitry Andric LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::ValueType) 4100b57cec5SDimitry Andric LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Table) 4110b57cec5SDimitry Andric LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Import) 4120b57cec5SDimitry Andric LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Export) 4130b57cec5SDimitry Andric LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::ElemSegment) 4140b57cec5SDimitry Andric LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Limits) 4150b57cec5SDimitry Andric LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::DataSegment) 4160b57cec5SDimitry Andric LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Global) 4170b57cec5SDimitry Andric LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Function) 4180b57cec5SDimitry Andric LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::LocalDecl) 4190b57cec5SDimitry Andric LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Relocation) 4200b57cec5SDimitry Andric LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::NameEntry) 4210b57cec5SDimitry Andric LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::ProducerEntry) 4220b57cec5SDimitry Andric LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::FeatureEntry) 4230b57cec5SDimitry Andric LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::SegmentInfo) 4240b57cec5SDimitry Andric LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::SymbolInfo) 4250b57cec5SDimitry Andric LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::InitFunction) 4260b57cec5SDimitry Andric LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::ComdatEntry) 4270b57cec5SDimitry Andric LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Comdat) 428*fe6060f1SDimitry Andric LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Tag) 4290b57cec5SDimitry Andric 4300b57cec5SDimitry Andric namespace llvm { 4310b57cec5SDimitry Andric namespace yaml { 4320b57cec5SDimitry Andric 4330b57cec5SDimitry Andric template <> struct MappingTraits<WasmYAML::FileHeader> { 4340b57cec5SDimitry Andric static void mapping(IO &IO, WasmYAML::FileHeader &FileHdr); 4350b57cec5SDimitry Andric }; 4360b57cec5SDimitry Andric 4370b57cec5SDimitry Andric template <> struct MappingTraits<std::unique_ptr<WasmYAML::Section>> { 4380b57cec5SDimitry Andric static void mapping(IO &IO, std::unique_ptr<WasmYAML::Section> &Section); 4390b57cec5SDimitry Andric }; 4400b57cec5SDimitry Andric 4410b57cec5SDimitry Andric template <> struct MappingTraits<WasmYAML::Object> { 4420b57cec5SDimitry Andric static void mapping(IO &IO, WasmYAML::Object &Object); 4430b57cec5SDimitry Andric }; 4440b57cec5SDimitry Andric 4450b57cec5SDimitry Andric template <> struct MappingTraits<WasmYAML::Import> { 4460b57cec5SDimitry Andric static void mapping(IO &IO, WasmYAML::Import &Import); 4470b57cec5SDimitry Andric }; 4480b57cec5SDimitry Andric 4490b57cec5SDimitry Andric template <> struct MappingTraits<WasmYAML::Export> { 4500b57cec5SDimitry Andric static void mapping(IO &IO, WasmYAML::Export &Export); 4510b57cec5SDimitry Andric }; 4520b57cec5SDimitry Andric 4530b57cec5SDimitry Andric template <> struct MappingTraits<WasmYAML::Global> { 4540b57cec5SDimitry Andric static void mapping(IO &IO, WasmYAML::Global &Global); 4550b57cec5SDimitry Andric }; 4560b57cec5SDimitry Andric 4570b57cec5SDimitry Andric template <> struct ScalarBitSetTraits<WasmYAML::LimitFlags> { 4580b57cec5SDimitry Andric static void bitset(IO &IO, WasmYAML::LimitFlags &Value); 4590b57cec5SDimitry Andric }; 4600b57cec5SDimitry Andric 4610b57cec5SDimitry Andric template <> struct ScalarBitSetTraits<WasmYAML::SymbolFlags> { 4620b57cec5SDimitry Andric static void bitset(IO &IO, WasmYAML::SymbolFlags &Value); 4630b57cec5SDimitry Andric }; 4640b57cec5SDimitry Andric 4650b57cec5SDimitry Andric template <> struct ScalarEnumerationTraits<WasmYAML::SymbolKind> { 4660b57cec5SDimitry Andric static void enumeration(IO &IO, WasmYAML::SymbolKind &Kind); 4670b57cec5SDimitry Andric }; 4680b57cec5SDimitry Andric 4690b57cec5SDimitry Andric template <> struct ScalarBitSetTraits<WasmYAML::SegmentFlags> { 4700b57cec5SDimitry Andric static void bitset(IO &IO, WasmYAML::SegmentFlags &Value); 4710b57cec5SDimitry Andric }; 4720b57cec5SDimitry Andric 4730b57cec5SDimitry Andric template <> struct ScalarEnumerationTraits<WasmYAML::SectionType> { 4740b57cec5SDimitry Andric static void enumeration(IO &IO, WasmYAML::SectionType &Type); 4750b57cec5SDimitry Andric }; 4760b57cec5SDimitry Andric 4770b57cec5SDimitry Andric template <> struct MappingTraits<WasmYAML::Signature> { 4780b57cec5SDimitry Andric static void mapping(IO &IO, WasmYAML::Signature &Signature); 4790b57cec5SDimitry Andric }; 4800b57cec5SDimitry Andric 4810b57cec5SDimitry Andric template <> struct MappingTraits<WasmYAML::Table> { 4820b57cec5SDimitry Andric static void mapping(IO &IO, WasmYAML::Table &Table); 4830b57cec5SDimitry Andric }; 4840b57cec5SDimitry Andric 4850b57cec5SDimitry Andric template <> struct MappingTraits<WasmYAML::Limits> { 4860b57cec5SDimitry Andric static void mapping(IO &IO, WasmYAML::Limits &Limits); 4870b57cec5SDimitry Andric }; 4880b57cec5SDimitry Andric 4890b57cec5SDimitry Andric template <> struct MappingTraits<WasmYAML::Function> { 4900b57cec5SDimitry Andric static void mapping(IO &IO, WasmYAML::Function &Function); 4910b57cec5SDimitry Andric }; 4920b57cec5SDimitry Andric 4930b57cec5SDimitry Andric template <> struct MappingTraits<WasmYAML::Relocation> { 4940b57cec5SDimitry Andric static void mapping(IO &IO, WasmYAML::Relocation &Relocation); 4950b57cec5SDimitry Andric }; 4960b57cec5SDimitry Andric 4970b57cec5SDimitry Andric template <> struct MappingTraits<WasmYAML::NameEntry> { 4980b57cec5SDimitry Andric static void mapping(IO &IO, WasmYAML::NameEntry &NameEntry); 4990b57cec5SDimitry Andric }; 5000b57cec5SDimitry Andric 5010b57cec5SDimitry Andric template <> struct MappingTraits<WasmYAML::ProducerEntry> { 5020b57cec5SDimitry Andric static void mapping(IO &IO, WasmYAML::ProducerEntry &ProducerEntry); 5030b57cec5SDimitry Andric }; 5040b57cec5SDimitry Andric 5050b57cec5SDimitry Andric template <> struct ScalarEnumerationTraits<WasmYAML::FeaturePolicyPrefix> { 5060b57cec5SDimitry Andric static void enumeration(IO &IO, WasmYAML::FeaturePolicyPrefix &Prefix); 5070b57cec5SDimitry Andric }; 5080b57cec5SDimitry Andric 5090b57cec5SDimitry Andric template <> struct MappingTraits<WasmYAML::FeatureEntry> { 5100b57cec5SDimitry Andric static void mapping(IO &IO, WasmYAML::FeatureEntry &FeatureEntry); 5110b57cec5SDimitry Andric }; 5120b57cec5SDimitry Andric 5130b57cec5SDimitry Andric template <> struct MappingTraits<WasmYAML::SegmentInfo> { 5140b57cec5SDimitry Andric static void mapping(IO &IO, WasmYAML::SegmentInfo &SegmentInfo); 5150b57cec5SDimitry Andric }; 5160b57cec5SDimitry Andric 5170b57cec5SDimitry Andric template <> struct MappingTraits<WasmYAML::LocalDecl> { 5180b57cec5SDimitry Andric static void mapping(IO &IO, WasmYAML::LocalDecl &LocalDecl); 5190b57cec5SDimitry Andric }; 5200b57cec5SDimitry Andric 5210b57cec5SDimitry Andric template <> struct MappingTraits<wasm::WasmInitExpr> { 5220b57cec5SDimitry Andric static void mapping(IO &IO, wasm::WasmInitExpr &Expr); 5230b57cec5SDimitry Andric }; 5240b57cec5SDimitry Andric 5250b57cec5SDimitry Andric template <> struct MappingTraits<WasmYAML::DataSegment> { 5260b57cec5SDimitry Andric static void mapping(IO &IO, WasmYAML::DataSegment &Segment); 5270b57cec5SDimitry Andric }; 5280b57cec5SDimitry Andric 5290b57cec5SDimitry Andric template <> struct MappingTraits<WasmYAML::ElemSegment> { 5300b57cec5SDimitry Andric static void mapping(IO &IO, WasmYAML::ElemSegment &Segment); 5310b57cec5SDimitry Andric }; 5320b57cec5SDimitry Andric 5330b57cec5SDimitry Andric template <> struct MappingTraits<WasmYAML::SymbolInfo> { 5340b57cec5SDimitry Andric static void mapping(IO &IO, WasmYAML::SymbolInfo &Info); 5350b57cec5SDimitry Andric }; 5360b57cec5SDimitry Andric 5370b57cec5SDimitry Andric template <> struct MappingTraits<WasmYAML::InitFunction> { 5380b57cec5SDimitry Andric static void mapping(IO &IO, WasmYAML::InitFunction &Init); 5390b57cec5SDimitry Andric }; 5400b57cec5SDimitry Andric 5410b57cec5SDimitry Andric template <> struct ScalarEnumerationTraits<WasmYAML::ComdatKind> { 5420b57cec5SDimitry Andric static void enumeration(IO &IO, WasmYAML::ComdatKind &Kind); 5430b57cec5SDimitry Andric }; 5440b57cec5SDimitry Andric 5450b57cec5SDimitry Andric template <> struct MappingTraits<WasmYAML::ComdatEntry> { 5460b57cec5SDimitry Andric static void mapping(IO &IO, WasmYAML::ComdatEntry &ComdatEntry); 5470b57cec5SDimitry Andric }; 5480b57cec5SDimitry Andric 5490b57cec5SDimitry Andric template <> struct MappingTraits<WasmYAML::Comdat> { 5500b57cec5SDimitry Andric static void mapping(IO &IO, WasmYAML::Comdat &Comdat); 5510b57cec5SDimitry Andric }; 5520b57cec5SDimitry Andric 5530b57cec5SDimitry Andric template <> struct ScalarEnumerationTraits<WasmYAML::ValueType> { 5540b57cec5SDimitry Andric static void enumeration(IO &IO, WasmYAML::ValueType &Type); 5550b57cec5SDimitry Andric }; 5560b57cec5SDimitry Andric 5570b57cec5SDimitry Andric template <> struct ScalarEnumerationTraits<WasmYAML::ExportKind> { 5580b57cec5SDimitry Andric static void enumeration(IO &IO, WasmYAML::ExportKind &Kind); 5590b57cec5SDimitry Andric }; 5600b57cec5SDimitry Andric 5610b57cec5SDimitry Andric template <> struct ScalarEnumerationTraits<WasmYAML::TableType> { 5620b57cec5SDimitry Andric static void enumeration(IO &IO, WasmYAML::TableType &Type); 5630b57cec5SDimitry Andric }; 5640b57cec5SDimitry Andric 5650b57cec5SDimitry Andric template <> struct ScalarEnumerationTraits<WasmYAML::Opcode> { 5660b57cec5SDimitry Andric static void enumeration(IO &IO, WasmYAML::Opcode &Opcode); 5670b57cec5SDimitry Andric }; 5680b57cec5SDimitry Andric 5690b57cec5SDimitry Andric template <> struct ScalarEnumerationTraits<WasmYAML::RelocType> { 5700b57cec5SDimitry Andric static void enumeration(IO &IO, WasmYAML::RelocType &Kind); 5710b57cec5SDimitry Andric }; 5720b57cec5SDimitry Andric 573*fe6060f1SDimitry Andric template <> struct MappingTraits<WasmYAML::Tag> { 574*fe6060f1SDimitry Andric static void mapping(IO &IO, WasmYAML::Tag &Tag); 5750b57cec5SDimitry Andric }; 5760b57cec5SDimitry Andric 5770b57cec5SDimitry Andric } // end namespace yaml 5780b57cec5SDimitry Andric } // end namespace llvm 5790b57cec5SDimitry Andric 5800b57cec5SDimitry Andric #endif // LLVM_OBJECTYAML_WASMYAML_H 581