diff options
Diffstat (limited to 'gnu/llvm/lib/ObjectYAML/WasmYAML.cpp')
| -rw-r--r-- | gnu/llvm/lib/ObjectYAML/WasmYAML.cpp | 59 |
1 files changed, 55 insertions, 4 deletions
diff --git a/gnu/llvm/lib/ObjectYAML/WasmYAML.cpp b/gnu/llvm/lib/ObjectYAML/WasmYAML.cpp index b2411395dc0..3c20bb74d50 100644 --- a/gnu/llvm/lib/ObjectYAML/WasmYAML.cpp +++ b/gnu/llvm/lib/ObjectYAML/WasmYAML.cpp @@ -57,10 +57,11 @@ static void sectionMapping(IO &IO, WasmYAML::NameSection &Section) { static void sectionMapping(IO &IO, WasmYAML::LinkingSection &Section) { commonSectionMapping(IO, Section); IO.mapRequired("Name", Section.Name); - IO.mapRequired("DataSize", Section.DataSize); - IO.mapOptional("SymbolInfo", Section.SymbolInfos); + IO.mapRequired("Version", Section.Version); + IO.mapOptional("SymbolTable", Section.SymbolTable); IO.mapOptional("SegmentInfo", Section.SegmentInfos); IO.mapOptional("InitFunctions", Section.InitFunctions); + IO.mapOptional("Comdats", Section.Comdats); } static void sectionMapping(IO &IO, WasmYAML::CustomSection &Section) { @@ -236,7 +237,7 @@ void ScalarEnumerationTraits<WasmYAML::SectionType>::enumeration( void MappingTraits<WasmYAML::Signature>::mapping( IO &IO, WasmYAML::Signature &Signature) { - IO.mapOptional("Index", Signature.Index); + IO.mapRequired("Index", Signature.Index); IO.mapRequired("ReturnType", Signature.ReturnType); IO.mapRequired("ParamTypes", Signature.ParamTypes); } @@ -248,6 +249,7 @@ void MappingTraits<WasmYAML::Table>::mapping(IO &IO, WasmYAML::Table &Table) { void MappingTraits<WasmYAML::Function>::mapping(IO &IO, WasmYAML::Function &Function) { + IO.mapRequired("Index", Function.Index); IO.mapRequired("Locals", Function.Locals); IO.mapRequired("Body", Function.Body); } @@ -323,6 +325,7 @@ void MappingTraits<WasmYAML::Export>::mapping(IO &IO, void MappingTraits<WasmYAML::Global>::mapping(IO &IO, WasmYAML::Global &Global) { + IO.mapRequired("Index", Global.Index); IO.mapRequired("Type", Global.Type); IO.mapRequired("Mutable", Global.Mutable); IO.mapRequired("InitExpr", Global.InitExpr); @@ -363,13 +366,50 @@ void MappingTraits<WasmYAML::DataSegment>::mapping( void MappingTraits<WasmYAML::InitFunction>::mapping( IO &IO, WasmYAML::InitFunction &Init) { IO.mapRequired("Priority", Init.Priority); - IO.mapRequired("FunctionIndex", Init.FunctionIndex); + IO.mapRequired("Symbol", Init.Symbol); +} + +void ScalarEnumerationTraits<WasmYAML::ComdatKind>::enumeration( + IO &IO, WasmYAML::ComdatKind &Kind) { +#define ECase(X) IO.enumCase(Kind, #X, wasm::WASM_COMDAT_##X); + ECase(FUNCTION); + ECase(DATA); +#undef ECase +} + +void MappingTraits<WasmYAML::ComdatEntry>::mapping( + IO &IO, WasmYAML::ComdatEntry &ComdatEntry) { + IO.mapRequired("Kind", ComdatEntry.Kind); + IO.mapRequired("Index", ComdatEntry.Index); +} + +void MappingTraits<WasmYAML::Comdat>::mapping( + IO &IO, WasmYAML::Comdat &Comdat) { + IO.mapRequired("Name", Comdat.Name); + IO.mapRequired("Entries", Comdat.Entries); } void MappingTraits<WasmYAML::SymbolInfo>::mapping(IO &IO, WasmYAML::SymbolInfo &Info) { + IO.mapRequired("Index", Info.Index); + IO.mapRequired("Kind", Info.Kind); IO.mapRequired("Name", Info.Name); IO.mapRequired("Flags", Info.Flags); + if (Info.Kind == wasm::WASM_SYMBOL_TYPE_FUNCTION) { + IO.mapRequired("Function", Info.ElementIndex); + } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_GLOBAL) { + IO.mapRequired("Global", Info.ElementIndex); + } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_DATA) { + if ((Info.Flags & wasm::WASM_SYMBOL_UNDEFINED) == 0) { + IO.mapRequired("Segment", Info.DataRef.Segment); + IO.mapOptional("Offset", Info.DataRef.Offset, 0u); + IO.mapRequired("Size", Info.DataRef.Size); + } + } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_SECTION) { + IO.mapRequired("Section", Info.ElementIndex); + } else { + llvm_unreachable("unsupported symbol kind"); + } } void ScalarBitSetTraits<WasmYAML::LimitFlags>::bitset( @@ -391,9 +431,20 @@ void ScalarBitSetTraits<WasmYAML::SymbolFlags>::bitset( BCaseMask(BINDING_MASK, BINDING_LOCAL); //BCaseMask(VISIBILITY_MASK, VISIBILITY_DEFAULT); BCaseMask(VISIBILITY_MASK, VISIBILITY_HIDDEN); + BCaseMask(UNDEFINED, UNDEFINED); #undef BCaseMask } +void ScalarEnumerationTraits<WasmYAML::SymbolKind>::enumeration( + IO &IO, WasmYAML::SymbolKind &Kind) { +#define ECase(X) IO.enumCase(Kind, #X, wasm::WASM_SYMBOL_TYPE_##X); + ECase(FUNCTION); + ECase(DATA); + ECase(GLOBAL); + ECase(SECTION); +#undef ECase +} + void ScalarEnumerationTraits<WasmYAML::ValueType>::enumeration( IO &IO, WasmYAML::ValueType &Type) { #define ECase(X) IO.enumCase(Type, #X, wasm::WASM_TYPE_##X); |
