diff options
author | Wouter van Oortmerssen <aardappel@gmail.com> | 2020-07-06 13:34:16 -0700 |
---|---|---|
committer | Wouter van Oortmerssen <aardappel@gmail.com> | 2020-07-16 12:01:10 -0700 |
commit | 29f8c9f6c25d50fd21e255060ea36eb0025ca2eb (patch) | |
tree | 068c14607c000244109e7b2d0d63829ca2a0e914 /llvm/lib/Object/WasmObjectFile.cpp | |
parent | 7bfaa40086359ed7e41c862ab0a65e0bb1be0aeb (diff) | |
download | llvm-29f8c9f6c25d50fd21e255060ea36eb0025ca2eb.zip llvm-29f8c9f6c25d50fd21e255060ea36eb0025ca2eb.tar.gz llvm-29f8c9f6c25d50fd21e255060ea36eb0025ca2eb.tar.bz2 |
[WebAssembly] Triple::wasm64 related cleanup
Differential Revision: https://reviews.llvm.org/D83713
Diffstat (limited to 'llvm/lib/Object/WasmObjectFile.cpp')
-rw-r--r-- | llvm/lib/Object/WasmObjectFile.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp index bb2e81d..47c68ab 100644 --- a/llvm/lib/Object/WasmObjectFile.cpp +++ b/llvm/lib/Object/WasmObjectFile.cpp @@ -957,6 +957,8 @@ Error WasmObjectFile::parseImportSection(ReadContext &Ctx) { break; case wasm::WASM_EXTERNAL_MEMORY: Im.Memory = readLimits(Ctx); + if (Im.Memory.Flags & wasm::WASM_LIMITS_FLAG_IS_64) + HasMemory64 = true; break; case wasm::WASM_EXTERNAL_TABLE: Im.Table = readTable(Ctx); @@ -1019,7 +1021,10 @@ Error WasmObjectFile::parseMemorySection(ReadContext &Ctx) { uint32_t Count = readVaruint32(Ctx); Memories.reserve(Count); while (Count--) { - Memories.push_back(readLimits(Ctx)); + auto Limits = readLimits(Ctx); + if (Limits.Flags & wasm::WASM_LIMITS_FLAG_IS_64) + HasMemory64 = true; + Memories.push_back(Limits); } if (Ctx.Ptr != Ctx.End) return make_error<GenericBinaryError>("Memory section ended prematurely", @@ -1576,11 +1581,15 @@ section_iterator WasmObjectFile::section_end() const { return section_iterator(SectionRef(Ref, this)); } -uint8_t WasmObjectFile::getBytesInAddress() const { return 4; } +uint8_t WasmObjectFile::getBytesInAddress() const { + return HasMemory64 ? 8 : 4; +} StringRef WasmObjectFile::getFileFormatName() const { return "WASM"; } -Triple::ArchType WasmObjectFile::getArch() const { return Triple::wasm32; } +Triple::ArchType WasmObjectFile::getArch() const { + return HasMemory64 ? Triple::wasm64 : Triple::wasm32; +} SubtargetFeatures WasmObjectFile::getFeatures() const { return SubtargetFeatures(); |