LCOV - code coverage report
Current view: top level - lib/ObjectYAML - WasmYAML.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 327 337 97.0 %
Date: 2018-06-17 00:07:59 Functions: 47 47 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- 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"
      15             : #include "llvm/ADT/StringRef.h"
      16             : #include "llvm/Support/Casting.h"
      17             : #include "llvm/Support/ErrorHandling.h"
      18             : #include "llvm/Support/YAMLTraits.h"
      19             : 
      20             : namespace llvm {
      21             : 
      22             : namespace 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
      26             : Section::~Section() = default;
      27             : 
      28             : } // end namespace WasmYAML
      29             : 
      30             : namespace yaml {
      31             : 
      32         115 : void MappingTraits<WasmYAML::FileHeader>::mapping(
      33             :     IO &IO, WasmYAML::FileHeader &FileHdr) {
      34         115 :   IO.mapRequired("Version", FileHdr.Version);
      35         115 : }
      36             : 
      37         115 : void MappingTraits<WasmYAML::Object>::mapping(IO &IO,
      38             :                                               WasmYAML::Object &Object) {
      39         115 :   IO.setContext(&Object);
      40         230 :   IO.mapTag("!WASM", true);
      41         115 :   IO.mapRequired("FileHeader", Object.Header);
      42         115 :   IO.mapOptional("Sections", Object.Sections);
      43         115 :   IO.setContext(nullptr);
      44         115 : }
      45             : 
      46         653 : static void commonSectionMapping(IO &IO, WasmYAML::Section &Section) {
      47         653 :   IO.mapRequired("Type", Section.Type);
      48         653 :   IO.mapOptional("Relocations", Section.Relocations);
      49         653 : }
      50             : 
      51          54 : static void sectionMapping(IO &IO, WasmYAML::NameSection &Section) {
      52          54 :   commonSectionMapping(IO, Section);
      53          54 :   IO.mapRequired("Name", Section.Name);
      54          54 :   IO.mapOptional("FunctionNames", Section.FunctionNames);
      55          54 : }
      56             : 
      57          41 : static void sectionMapping(IO &IO, WasmYAML::LinkingSection &Section) {
      58          41 :   commonSectionMapping(IO, Section);
      59          41 :   IO.mapRequired("Name", Section.Name);
      60          41 :   IO.mapRequired("Version", Section.Version);
      61          41 :   IO.mapOptional("SymbolTable", Section.SymbolTable);
      62          41 :   IO.mapOptional("SegmentInfo", Section.SegmentInfos);
      63          41 :   IO.mapOptional("InitFunctions", Section.InitFunctions);
      64          41 :   IO.mapOptional("Comdats", Section.Comdats);
      65          41 : }
      66             : 
      67           4 : static void sectionMapping(IO &IO, WasmYAML::CustomSection &Section) {
      68           4 :   commonSectionMapping(IO, Section);
      69           4 :   IO.mapRequired("Name", Section.Name);
      70           4 :   IO.mapRequired("Payload", Section.Payload);
      71           4 : }
      72             : 
      73          89 : static void sectionMapping(IO &IO, WasmYAML::TypeSection &Section) {
      74          89 :   commonSectionMapping(IO, Section);
      75          89 :   IO.mapOptional("Signatures", Section.Signatures);
      76          89 : }
      77             : 
      78          41 : static void sectionMapping(IO &IO, WasmYAML::ImportSection &Section) {
      79          41 :   commonSectionMapping(IO, Section);
      80          41 :   IO.mapOptional("Imports", Section.Imports);
      81          41 : }
      82             : 
      83          77 : static void sectionMapping(IO &IO, WasmYAML::FunctionSection &Section) {
      84          77 :   commonSectionMapping(IO, Section);
      85          77 :   IO.mapOptional("FunctionTypes", Section.FunctionTypes);
      86          77 : }
      87             : 
      88          57 : static void sectionMapping(IO &IO, WasmYAML::TableSection &Section) {
      89          57 :   commonSectionMapping(IO, Section);
      90          57 :   IO.mapOptional("Tables", Section.Tables);
      91          57 : }
      92             : 
      93          56 : static void sectionMapping(IO &IO, WasmYAML::MemorySection &Section) {
      94          56 :   commonSectionMapping(IO, Section);
      95          56 :   IO.mapOptional("Memories", Section.Memories);
      96          56 : }
      97             : 
      98          53 : static void sectionMapping(IO &IO, WasmYAML::GlobalSection &Section) {
      99          53 :   commonSectionMapping(IO, Section);
     100          53 :   IO.mapOptional("Globals", Section.Globals);
     101          53 : }
     102             : 
     103          49 : static void sectionMapping(IO &IO, WasmYAML::ExportSection &Section) {
     104          49 :   commonSectionMapping(IO, Section);
     105          49 :   IO.mapOptional("Exports", Section.Exports);
     106          49 : }
     107             : 
     108           3 : static void sectionMapping(IO &IO, WasmYAML::StartSection &Section) {
     109           3 :   commonSectionMapping(IO, Section);
     110           3 :   IO.mapOptional("StartFunction", Section.StartFunction);
     111           3 : }
     112             : 
     113          18 : static void sectionMapping(IO &IO, WasmYAML::ElemSection &Section) {
     114          18 :   commonSectionMapping(IO, Section);
     115          18 :   IO.mapOptional("Segments", Section.Segments);
     116          18 : }
     117             : 
     118          77 : static void sectionMapping(IO &IO, WasmYAML::CodeSection &Section) {
     119          77 :   commonSectionMapping(IO, Section);
     120          77 :   IO.mapRequired("Functions", Section.Functions);
     121          77 : }
     122             : 
     123          34 : static void sectionMapping(IO &IO, WasmYAML::DataSection &Section) {
     124          34 :   commonSectionMapping(IO, Section);
     125          34 :   IO.mapRequired("Segments", Section.Segments);
     126          34 : }
     127             : 
     128         653 : void MappingTraits<std::unique_ptr<WasmYAML::Section>>::mapping(
     129             :     IO &IO, std::unique_ptr<WasmYAML::Section> &Section) {
     130             :   WasmYAML::SectionType SectionType;
     131         653 :   if (IO.outputting())
     132         578 :     SectionType = Section->Type;
     133             :   else
     134             :     IO.mapRequired("Type", SectionType);
     135             : 
     136         653 :   switch (SectionType) {
     137          99 :   case wasm::WASM_SEC_CUSTOM: {
     138          99 :     StringRef SectionName;
     139          99 :     if (IO.outputting()) {
     140             :       auto CustomSection = cast<WasmYAML::CustomSection>(Section.get());
     141          85 :       SectionName = CustomSection->Name;
     142             :     } else {
     143             :       IO.mapRequired("Name", SectionName);
     144             :     }
     145             :     if (SectionName == "linking") {
     146          41 :       if (!IO.outputting())
     147          11 :         Section.reset(new WasmYAML::LinkingSection());
     148          41 :       sectionMapping(IO, *cast<WasmYAML::LinkingSection>(Section.get()));
     149             :     } else if (SectionName == "name") {
     150          54 :       if (!IO.outputting())
     151           2 :         Section.reset(new WasmYAML::NameSection());
     152          54 :       sectionMapping(IO, *cast<WasmYAML::NameSection>(Section.get()));
     153             :     } else {
     154           4 :       if (!IO.outputting())
     155           1 :         Section.reset(new WasmYAML::CustomSection(SectionName));
     156           4 :       sectionMapping(IO, *cast<WasmYAML::CustomSection>(Section.get()));
     157             :     }
     158             :     break;
     159             :   }
     160          89 :   case wasm::WASM_SEC_TYPE:
     161          89 :     if (!IO.outputting())
     162          15 :       Section.reset(new WasmYAML::TypeSection());
     163          89 :     sectionMapping(IO, *cast<WasmYAML::TypeSection>(Section.get()));
     164          89 :     break;
     165          41 :   case wasm::WASM_SEC_IMPORT:
     166          41 :     if (!IO.outputting())
     167           8 :       Section.reset(new WasmYAML::ImportSection());
     168          41 :     sectionMapping(IO, *cast<WasmYAML::ImportSection>(Section.get()));
     169          41 :     break;
     170          77 :   case wasm::WASM_SEC_FUNCTION:
     171          77 :     if (!IO.outputting())
     172           9 :       Section.reset(new WasmYAML::FunctionSection());
     173          77 :     sectionMapping(IO, *cast<WasmYAML::FunctionSection>(Section.get()));
     174          77 :     break;
     175          57 :   case wasm::WASM_SEC_TABLE:
     176          57 :     if (!IO.outputting())
     177           2 :       Section.reset(new WasmYAML::TableSection());
     178          57 :     sectionMapping(IO, *cast<WasmYAML::TableSection>(Section.get()));
     179          57 :     break;
     180          56 :   case wasm::WASM_SEC_MEMORY:
     181          56 :     if (!IO.outputting())
     182           2 :       Section.reset(new WasmYAML::MemorySection());
     183          56 :     sectionMapping(IO, *cast<WasmYAML::MemorySection>(Section.get()));
     184          56 :     break;
     185          53 :   case wasm::WASM_SEC_GLOBAL:
     186          53 :     if (!IO.outputting())
     187           6 :       Section.reset(new WasmYAML::GlobalSection());
     188          53 :     sectionMapping(IO, *cast<WasmYAML::GlobalSection>(Section.get()));
     189          53 :     break;
     190          49 :   case wasm::WASM_SEC_EXPORT:
     191          49 :     if (!IO.outputting())
     192           3 :       Section.reset(new WasmYAML::ExportSection());
     193          49 :     sectionMapping(IO, *cast<WasmYAML::ExportSection>(Section.get()));
     194          49 :     break;
     195           3 :   case wasm::WASM_SEC_START:
     196           3 :     if (!IO.outputting())
     197           2 :       Section.reset(new WasmYAML::StartSection());
     198           3 :     sectionMapping(IO, *cast<WasmYAML::StartSection>(Section.get()));
     199           3 :     break;
     200          18 :   case wasm::WASM_SEC_ELEM:
     201          18 :     if (!IO.outputting())
     202           1 :       Section.reset(new WasmYAML::ElemSection());
     203          18 :     sectionMapping(IO, *cast<WasmYAML::ElemSection>(Section.get()));
     204          18 :     break;
     205          77 :   case wasm::WASM_SEC_CODE:
     206          77 :     if (!IO.outputting())
     207           9 :       Section.reset(new WasmYAML::CodeSection());
     208          77 :     sectionMapping(IO, *cast<WasmYAML::CodeSection>(Section.get()));
     209          77 :     break;
     210          34 :   case wasm::WASM_SEC_DATA:
     211          34 :     if (!IO.outputting())
     212           4 :       Section.reset(new WasmYAML::DataSection());
     213          34 :     sectionMapping(IO, *cast<WasmYAML::DataSection>(Section.get()));
     214          34 :     break;
     215           0 :   default:
     216           0 :     llvm_unreachable("Unknown section type");
     217             :   }
     218         653 : }
     219             : 
     220         728 : void ScalarEnumerationTraits<WasmYAML::SectionType>::enumeration(
     221             :     IO &IO, WasmYAML::SectionType &Type) {
     222             : #define ECase(X) IO.enumCase(Type, #X, wasm::WASM_SEC_##X);
     223         728 :   ECase(CUSTOM);
     224         728 :   ECase(TYPE);
     225         728 :   ECase(IMPORT);
     226         728 :   ECase(FUNCTION);
     227         728 :   ECase(TABLE);
     228         728 :   ECase(MEMORY);
     229         728 :   ECase(GLOBAL);
     230         728 :   ECase(EXPORT);
     231         728 :   ECase(START);
     232         728 :   ECase(ELEM);
     233         728 :   ECase(CODE);
     234         728 :   ECase(DATA);
     235             : #undef ECase
     236         728 : }
     237             : 
     238         145 : void MappingTraits<WasmYAML::Signature>::mapping(
     239             :     IO &IO, WasmYAML::Signature &Signature) {
     240         145 :   IO.mapRequired("Index", Signature.Index);
     241         145 :   IO.mapRequired("ReturnType", Signature.ReturnType);
     242         145 :   IO.mapRequired("ParamTypes", Signature.ParamTypes);
     243         145 : }
     244             : 
     245          76 : void MappingTraits<WasmYAML::Table>::mapping(IO &IO, WasmYAML::Table &Table) {
     246          76 :   IO.mapRequired("ElemType", Table.ElemType);
     247          76 :   IO.mapRequired("Limits", Table.TableLimits);
     248          76 : }
     249             : 
     250         410 : void MappingTraits<WasmYAML::Function>::mapping(IO &IO,
     251             :                                                 WasmYAML::Function &Function) {
     252         410 :   IO.mapRequired("Index", Function.Index);
     253         410 :   IO.mapRequired("Locals", Function.Locals);
     254         410 :   IO.mapRequired("Body", Function.Body);
     255         410 : }
     256             : 
     257         235 : void MappingTraits<WasmYAML::Relocation>::mapping(
     258             :     IO &IO, WasmYAML::Relocation &Relocation) {
     259         235 :   IO.mapRequired("Type", Relocation.Type);
     260         235 :   IO.mapRequired("Index", Relocation.Index);
     261         235 :   IO.mapRequired("Offset", Relocation.Offset);
     262         470 :   IO.mapOptional("Addend", Relocation.Addend, 0);
     263         235 : }
     264             : 
     265         375 : void MappingTraits<WasmYAML::NameEntry>::mapping(
     266             :     IO &IO, WasmYAML::NameEntry &NameEntry) {
     267         375 :   IO.mapRequired("Index", NameEntry.Index);
     268         375 :   IO.mapRequired("Name", NameEntry.Name);
     269         375 : }
     270             : 
     271          48 : void MappingTraits<WasmYAML::SegmentInfo>::mapping(
     272             :     IO &IO, WasmYAML::SegmentInfo &SegmentInfo) {
     273          48 :   IO.mapRequired("Index", SegmentInfo.Index);
     274          48 :   IO.mapRequired("Name", SegmentInfo.Name);
     275          48 :   IO.mapRequired("Alignment", SegmentInfo.Alignment);
     276          48 :   IO.mapRequired("Flags", SegmentInfo.Flags);
     277          48 : }
     278             : 
     279          13 : void MappingTraits<WasmYAML::LocalDecl>::mapping(
     280             :     IO &IO, WasmYAML::LocalDecl &LocalDecl) {
     281          13 :   IO.mapRequired("Type", LocalDecl.Type);
     282          13 :   IO.mapRequired("Count", LocalDecl.Count);
     283          13 : }
     284             : 
     285         154 : void MappingTraits<WasmYAML::Limits>::mapping(IO &IO,
     286             :                                               WasmYAML::Limits &Limits) {
     287         154 :   if (!IO.outputting() || Limits.Flags)
     288          68 :     IO.mapOptional("Flags", Limits.Flags);
     289         154 :   IO.mapRequired("Initial", Limits.Initial);
     290         154 :   if (!IO.outputting() || Limits.Flags & wasm::WASM_LIMITS_FLAG_HAS_MAX)
     291          68 :     IO.mapOptional("Maximum", Limits.Maximum);
     292         154 : }
     293             : 
     294          20 : void MappingTraits<WasmYAML::ElemSegment>::mapping(
     295             :     IO &IO, WasmYAML::ElemSegment &Segment) {
     296          20 :   IO.mapRequired("Offset", Segment.Offset);
     297          20 :   IO.mapRequired("Functions", Segment.Functions);
     298          20 : }
     299             : 
     300          90 : void MappingTraits<WasmYAML::Import>::mapping(IO &IO,
     301             :                                               WasmYAML::Import &Import) {
     302          90 :   IO.mapRequired("Module", Import.Module);
     303          90 :   IO.mapRequired("Field", Import.Field);
     304          90 :   IO.mapRequired("Kind", Import.Kind);
     305          90 :   if (Import.Kind == wasm::WASM_EXTERNAL_FUNCTION) {
     306          37 :     IO.mapRequired("SigIndex", Import.SigIndex);
     307          53 :   } else if (Import.Kind == wasm::WASM_EXTERNAL_GLOBAL) {
     308          14 :     IO.mapRequired("GlobalType", Import.GlobalImport.Type);
     309          14 :     IO.mapRequired("GlobalMutable", Import.GlobalImport.Mutable);
     310          39 :   } else if (Import.Kind == wasm::WASM_EXTERNAL_TABLE) {
     311          19 :     IO.mapRequired("Table", Import.TableImport);
     312          20 :   } else if (Import.Kind == wasm::WASM_EXTERNAL_MEMORY ) {
     313          20 :     IO.mapRequired("Memory", Import.Memory);
     314             :   } else {
     315           0 :     llvm_unreachable("unhandled import type");
     316             :   }
     317          90 : }
     318             : 
     319         254 : void MappingTraits<WasmYAML::Export>::mapping(IO &IO,
     320             :                                               WasmYAML::Export &Export) {
     321         254 :   IO.mapRequired("Name", Export.Name);
     322         254 :   IO.mapRequired("Kind", Export.Kind);
     323         254 :   IO.mapRequired("Index", Export.Index);
     324         254 : }
     325             : 
     326         158 : void MappingTraits<WasmYAML::Global>::mapping(IO &IO,
     327             :                                               WasmYAML::Global &Global) {
     328         158 :   IO.mapRequired("Index", Global.Index);
     329         158 :   IO.mapRequired("Type", Global.Type);
     330         158 :   IO.mapRequired("Mutable", Global.Mutable);
     331         158 :   IO.mapRequired("InitExpr", Global.InitExpr);
     332         158 : }
     333             : 
     334         248 : void MappingTraits<wasm::WasmInitExpr>::mapping(IO &IO,
     335             :                                                 wasm::WasmInitExpr &Expr) {
     336         248 :   WasmYAML::Opcode Op = Expr.Opcode;
     337             :   IO.mapRequired("Opcode", Op);
     338         248 :   Expr.Opcode = Op;
     339         248 :   switch (Expr.Opcode) {
     340         233 :   case wasm::WASM_OPCODE_I32_CONST:
     341         233 :     IO.mapRequired("Value", Expr.Value.Int32);
     342             :     break;
     343          13 :   case wasm::WASM_OPCODE_I64_CONST:
     344          13 :     IO.mapRequired("Value", Expr.Value.Int64);
     345             :     break;
     346           0 :   case wasm::WASM_OPCODE_F32_CONST:
     347           0 :     IO.mapRequired("Value", Expr.Value.Float32);
     348             :     break;
     349           0 :   case wasm::WASM_OPCODE_F64_CONST:
     350           0 :     IO.mapRequired("Value", Expr.Value.Float64);
     351             :     break;
     352           2 :   case wasm::WASM_OPCODE_GET_GLOBAL:
     353           2 :     IO.mapRequired("Index", Expr.Value.Global);
     354             :     break;
     355             :   }
     356         248 : }
     357             : 
     358          70 : void MappingTraits<WasmYAML::DataSegment>::mapping(
     359             :     IO &IO, WasmYAML::DataSegment &Segment) {
     360          70 :   IO.mapOptional("SectionOffset", Segment.SectionOffset);
     361          70 :   IO.mapRequired("MemoryIndex", Segment.MemoryIndex);
     362          70 :   IO.mapRequired("Offset", Segment.Offset);
     363          70 :   IO.mapRequired("Content", Segment.Content);
     364          70 : }
     365             : 
     366          19 : void MappingTraits<WasmYAML::InitFunction>::mapping(
     367             :     IO &IO, WasmYAML::InitFunction &Init) {
     368          19 :   IO.mapRequired("Priority", Init.Priority);
     369          19 :   IO.mapRequired("Symbol", Init.Symbol);
     370          19 : }
     371             : 
     372           5 : void ScalarEnumerationTraits<WasmYAML::ComdatKind>::enumeration(
     373             :     IO &IO, WasmYAML::ComdatKind &Kind) {
     374             : #define ECase(X) IO.enumCase(Kind, #X, wasm::WASM_COMDAT_##X);
     375           5 :   ECase(FUNCTION);
     376           5 :   ECase(DATA);
     377             : #undef ECase
     378           5 : }
     379             : 
     380           5 : void MappingTraits<WasmYAML::ComdatEntry>::mapping(
     381             :     IO &IO, WasmYAML::ComdatEntry &ComdatEntry) {
     382           5 :   IO.mapRequired("Kind", ComdatEntry.Kind);
     383           5 :   IO.mapRequired("Index", ComdatEntry.Index);
     384           5 : }
     385             : 
     386           3 : void MappingTraits<WasmYAML::Comdat>::mapping(
     387             :     IO &IO, WasmYAML::Comdat &Comdat) {
     388           3 :   IO.mapRequired("Name", Comdat.Name);
     389           3 :   IO.mapRequired("Entries", Comdat.Entries);
     390           3 : }
     391             : 
     392         310 : void MappingTraits<WasmYAML::SymbolInfo>::mapping(IO &IO,
     393             :                                                   WasmYAML::SymbolInfo &Info) {
     394         310 :   IO.mapRequired("Index", Info.Index);
     395         310 :   IO.mapRequired("Kind", Info.Kind);
     396         310 :   IO.mapRequired("Name", Info.Name);
     397         310 :   IO.mapRequired("Flags", Info.Flags);
     398         310 :   if (Info.Kind == wasm::WASM_SYMBOL_TYPE_FUNCTION) {
     399         237 :     IO.mapRequired("Function", Info.ElementIndex);
     400          73 :   } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_GLOBAL) {
     401          15 :     IO.mapRequired("Global", Info.ElementIndex);
     402          58 :   } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_DATA) {
     403          58 :     if ((Info.Flags & wasm::WASM_SYMBOL_UNDEFINED) == 0) {
     404          51 :       IO.mapRequired("Segment", Info.DataRef.Segment);
     405         102 :       IO.mapOptional("Offset", Info.DataRef.Offset, 0u);
     406          51 :       IO.mapRequired("Size", Info.DataRef.Size);
     407             :     }
     408           0 :   } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_SECTION) {
     409           0 :     IO.mapRequired("Section", Info.ElementIndex);
     410             :   } else {
     411           0 :     llvm_unreachable("unsupported symbol kind");
     412             :   }
     413         310 : }
     414             : 
     415          66 : void ScalarBitSetTraits<WasmYAML::LimitFlags>::bitset(
     416             :     IO &IO, WasmYAML::LimitFlags &Value) {
     417             : #define BCase(X) IO.bitSetCase(Value, #X, wasm::WASM_LIMITS_FLAG_##X)
     418          66 :   BCase(HAS_MAX);
     419             : #undef BCase
     420          66 : }
     421             : 
     422          48 : void ScalarBitSetTraits<WasmYAML::SegmentFlags>::bitset(
     423             :     IO &IO, WasmYAML::SegmentFlags &Value) {
     424          48 : }
     425             : 
     426         310 : void ScalarBitSetTraits<WasmYAML::SymbolFlags>::bitset(
     427             :     IO &IO, WasmYAML::SymbolFlags &Value) {
     428             : #define BCaseMask(M, X) IO.maskedBitSetCase(Value, #X, wasm::WASM_SYMBOL_##X, wasm::WASM_SYMBOL_##M)
     429             :   //BCaseMask(BINDING_MASK, BINDING_GLOBAL);
     430         310 :   BCaseMask(BINDING_MASK, BINDING_WEAK);
     431         310 :   BCaseMask(BINDING_MASK, BINDING_LOCAL);
     432             :   //BCaseMask(VISIBILITY_MASK, VISIBILITY_DEFAULT);
     433         310 :   BCaseMask(VISIBILITY_MASK, VISIBILITY_HIDDEN);
     434         310 :   BCaseMask(UNDEFINED, UNDEFINED);
     435             : #undef BCaseMask
     436         310 : }
     437             : 
     438         310 : void ScalarEnumerationTraits<WasmYAML::SymbolKind>::enumeration(
     439             :     IO &IO, WasmYAML::SymbolKind &Kind) {
     440             : #define ECase(X) IO.enumCase(Kind, #X, wasm::WASM_SYMBOL_TYPE_##X);
     441         310 :   ECase(FUNCTION);
     442         310 :   ECase(DATA);
     443         310 :   ECase(GLOBAL);
     444         310 :   ECase(SECTION);
     445             : #undef ECase
     446         310 : }
     447             : 
     448         393 : void ScalarEnumerationTraits<WasmYAML::ValueType>::enumeration(
     449             :     IO &IO, WasmYAML::ValueType &Type) {
     450             : #define ECase(X) IO.enumCase(Type, #X, wasm::WASM_TYPE_##X);
     451         393 :   ECase(I32);
     452         393 :   ECase(I64);
     453         393 :   ECase(F32);
     454         393 :   ECase(F64);
     455         393 :   ECase(ANYFUNC);
     456         393 :   ECase(FUNC);
     457         393 :   ECase(NORESULT);
     458             : #undef ECase
     459         393 : }
     460             : 
     461         344 : void ScalarEnumerationTraits<WasmYAML::ExportKind>::enumeration(
     462             :     IO &IO, WasmYAML::ExportKind &Kind) {
     463             : #define ECase(X) IO.enumCase(Kind, #X, wasm::WASM_EXTERNAL_##X);
     464         344 :   ECase(FUNCTION);
     465         344 :   ECase(TABLE);
     466         344 :   ECase(MEMORY);
     467         344 :   ECase(GLOBAL);
     468             : #undef ECase
     469         344 : }
     470             : 
     471         248 : void ScalarEnumerationTraits<WasmYAML::Opcode>::enumeration(
     472             :     IO &IO, WasmYAML::Opcode &Code) {
     473             : #define ECase(X) IO.enumCase(Code, #X, wasm::WASM_OPCODE_##X);
     474         248 :   ECase(END);
     475         248 :   ECase(I32_CONST);
     476         248 :   ECase(I64_CONST);
     477         248 :   ECase(F64_CONST);
     478         248 :   ECase(F32_CONST);
     479         248 :   ECase(GET_GLOBAL);
     480             : #undef ECase
     481         248 : }
     482             : 
     483          76 : void ScalarEnumerationTraits<WasmYAML::TableType>::enumeration(
     484             :     IO &IO, WasmYAML::TableType &Type) {
     485             : #define ECase(X) IO.enumCase(Type, #X, wasm::WASM_TYPE_##X);
     486          76 :   ECase(ANYFUNC);
     487             : #undef ECase
     488          76 : }
     489             : 
     490         235 : void ScalarEnumerationTraits<WasmYAML::RelocType>::enumeration(
     491             :     IO &IO, WasmYAML::RelocType &Type) {
     492             : #define WASM_RELOC(name, value) IO.enumCase(Type, #name, wasm::name);
     493             : #include "llvm/BinaryFormat/WasmRelocs.def"
     494             : #undef WASM_RELOC
     495         235 : }
     496             : 
     497             : } // end namespace yaml
     498             : 
     499             : } // end namespace llvm

Generated by: LCOV version 1.13