From cfca06d7963fa0909f90483b42a6d7d194d01e08 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 26 Jul 2020 19:36:28 +0000 Subject: Vendor import of llvm-project master 2e10b7a39b9, the last commit before the llvmorg-12-init tag, from which release/11.x was branched. --- llvm/lib/ObjectYAML/WasmEmitter.cpp | 39 ++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'llvm/lib/ObjectYAML/WasmEmitter.cpp') diff --git a/llvm/lib/ObjectYAML/WasmEmitter.cpp b/llvm/lib/ObjectYAML/WasmEmitter.cpp index debc040587a8..cbb062d87ae6 100644 --- a/llvm/lib/ObjectYAML/WasmEmitter.cpp +++ b/llvm/lib/ObjectYAML/WasmEmitter.cpp @@ -41,8 +41,8 @@ private: void writeSectionContent(raw_ostream &OS, WasmYAML::FunctionSection &Section); void writeSectionContent(raw_ostream &OS, WasmYAML::TableSection &Section); void writeSectionContent(raw_ostream &OS, WasmYAML::MemorySection &Section); - void writeSectionContent(raw_ostream &OS, WasmYAML::GlobalSection &Section); void writeSectionContent(raw_ostream &OS, WasmYAML::EventSection &Section); + void writeSectionContent(raw_ostream &OS, WasmYAML::GlobalSection &Section); void writeSectionContent(raw_ostream &OS, WasmYAML::ExportSection &Section); void writeSectionContent(raw_ostream &OS, WasmYAML::StartSection &Section); void writeSectionContent(raw_ostream &OS, WasmYAML::ElemSection &Section); @@ -414,6 +414,21 @@ void WasmWriter::writeSectionContent(raw_ostream &OS, writeLimits(Mem, OS); } +void WasmWriter::writeSectionContent(raw_ostream &OS, + WasmYAML::EventSection &Section) { + encodeULEB128(Section.Events.size(), OS); + uint32_t ExpectedIndex = NumImportedEvents; + for (auto &Event : Section.Events) { + if (Event.Index != ExpectedIndex) { + reportError("unexpected event index: " + Twine(Event.Index)); + return; + } + ++ExpectedIndex; + encodeULEB128(Event.Attribute, OS); + encodeULEB128(Event.SigIndex, OS); + } +} + void WasmWriter::writeSectionContent(raw_ostream &OS, WasmYAML::GlobalSection &Section) { encodeULEB128(Section.Globals.size(), OS); @@ -430,21 +445,6 @@ void WasmWriter::writeSectionContent(raw_ostream &OS, } } -void WasmWriter::writeSectionContent(raw_ostream &OS, - WasmYAML::EventSection &Section) { - encodeULEB128(Section.Events.size(), OS); - uint32_t ExpectedIndex = NumImportedEvents; - for (auto &Event : Section.Events) { - if (Event.Index != ExpectedIndex) { - reportError("unexpected event index: " + Twine(Event.Index)); - return; - } - ++ExpectedIndex; - encodeULEB128(Event.Attribute, OS); - encodeULEB128(Event.SigIndex, OS); - } -} - void WasmWriter::writeSectionContent(raw_ostream &OS, WasmYAML::ElemSection &Section) { encodeULEB128(Section.Segments.size(), OS); @@ -532,8 +532,11 @@ void WasmWriter::writeRelocSection(raw_ostream &OS, WasmYAML::Section &Sec, encodeULEB128(Reloc.Index, OS); switch (Reloc.Type) { case wasm::R_WASM_MEMORY_ADDR_LEB: + case wasm::R_WASM_MEMORY_ADDR_LEB64: case wasm::R_WASM_MEMORY_ADDR_SLEB: + case wasm::R_WASM_MEMORY_ADDR_SLEB64: case wasm::R_WASM_MEMORY_ADDR_I32: + case wasm::R_WASM_MEMORY_ADDR_I64: case wasm::R_WASM_FUNCTION_OFFSET_I32: case wasm::R_WASM_SECTION_OFFSET_I32: encodeULEB128(Reloc.Addend, OS); @@ -571,10 +574,10 @@ bool WasmWriter::writeWasm(raw_ostream &OS) { writeSectionContent(StringStream, *S); else if (auto S = dyn_cast(Sec.get())) writeSectionContent(StringStream, *S); - else if (auto S = dyn_cast(Sec.get())) - writeSectionContent(StringStream, *S); else if (auto S = dyn_cast(Sec.get())) writeSectionContent(StringStream, *S); + else if (auto S = dyn_cast(Sec.get())) + writeSectionContent(StringStream, *S); else if (auto S = dyn_cast(Sec.get())) writeSectionContent(StringStream, *S); else if (auto S = dyn_cast(Sec.get())) -- cgit v1.2.3