diff options
author | Thomas Lively <tlively@google.com> | 2019-01-17 02:29:55 +0000 |
---|---|---|
committer | Thomas Lively <tlively@google.com> | 2019-01-17 02:29:55 +0000 |
commit | cbda16eb8ebf52e10a44bd6f15e2743d69e9632a (patch) | |
tree | 43a795712422a63a3f60e732ac9131ceaa0bfd32 /llvm/tools/yaml2obj/yaml2wasm.cpp | |
parent | 2a0868ff48cbf9b3b57858c0f95b89607b69aac9 (diff) | |
download | bcm5719-llvm-cbda16eb8ebf52e10a44bd6f15e2743d69e9632a.tar.gz bcm5719-llvm-cbda16eb8ebf52e10a44bd6f15e2743d69e9632a.zip |
[WebAssembly] Parse llvm.ident into producers section
llvm-svn: 351413
Diffstat (limited to 'llvm/tools/yaml2obj/yaml2wasm.cpp')
-rw-r--r-- | llvm/tools/yaml2obj/yaml2wasm.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/tools/yaml2obj/yaml2wasm.cpp b/llvm/tools/yaml2obj/yaml2wasm.cpp index 2d3e3b71f08..242bc6b6442 100644 --- a/llvm/tools/yaml2obj/yaml2wasm.cpp +++ b/llvm/tools/yaml2obj/yaml2wasm.cpp @@ -49,6 +49,7 @@ private: int writeSectionContent(raw_ostream &OS, WasmYAML::DylinkSection &Section); int writeSectionContent(raw_ostream &OS, WasmYAML::NameSection &Section); int writeSectionContent(raw_ostream &OS, WasmYAML::LinkingSection &Section); + int writeSectionContent(raw_ostream &OS, WasmYAML::ProducersSection &Section); WasmYAML::Object &Obj; uint32_t NumImportedFunctions = 0; uint32_t NumImportedGlobals = 0; @@ -256,6 +257,29 @@ int WasmWriter::writeSectionContent(raw_ostream &OS, } int WasmWriter::writeSectionContent(raw_ostream &OS, + WasmYAML::ProducersSection &Section) { + writeStringRef(Section.Name, OS); + int Fields = int(!Section.Languages.empty()) + int(!Section.Tools.empty()) + + int(!Section.SDKs.empty()); + if (Fields == 0) + return 0; + encodeULEB128(Fields, OS); + for (auto &Field : {std::make_pair(StringRef("language"), &Section.Languages), + std::make_pair(StringRef("processed-by"), &Section.Tools), + std::make_pair(StringRef("sdk"), &Section.SDKs)}) { + if (Field.second->empty()) + continue; + writeStringRef(Field.first, OS); + encodeULEB128(Field.second->size(), OS); + for (auto &Entry : *Field.second) { + writeStringRef(Entry.Name, OS); + writeStringRef(Entry.Version, OS); + } + } + return 0; +} + +int WasmWriter::writeSectionContent(raw_ostream &OS, WasmYAML::CustomSection &Section) { if (auto S = dyn_cast<WasmYAML::DylinkSection>(&Section)) { if (auto Err = writeSectionContent(OS, *S)) @@ -266,6 +290,9 @@ int WasmWriter::writeSectionContent(raw_ostream &OS, } else if (auto S = dyn_cast<WasmYAML::LinkingSection>(&Section)) { if (auto Err = writeSectionContent(OS, *S)) return Err; + } else if (auto S = dyn_cast<WasmYAML::ProducersSection>(&Section)) { + if (auto Err = writeSectionContent(OS, *S)) + return Err; } else { writeStringRef(Section.Name, OS); Section.Payload.writeAsBinary(OS); |