From 7977ad58a367f49555c70ea5f0f0f6ab06b28903 Mon Sep 17 00:00:00 2001 From: Wouter van Oortmerssen Date: Thu, 25 Feb 2021 13:18:34 -0800 Subject: Support 64-bit data segment init-exps in Memory64 (#3593) This as a consequence of https://reviews.llvm.org/D95651 --- src/wasm/wasm-s-parser.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/wasm/wasm-s-parser.cpp') diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 169470181..339d3a04e 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -2615,7 +2615,12 @@ void SExpressionWasmBuilder::parseMemory(Element& s, bool preParseImport) { } // (memory (data ..)) format auto j = parseMemoryIndex(inner, 1); - auto offset = allocator.alloc()->set(Literal(int32_t(0))); + auto offset = allocator.alloc(); + if (wasm.memory.is64()) { + offset->set(Literal(int64_t(0))); + } else { + offset->set(Literal(int32_t(0))); + } parseInnerData(inner, j, {}, offset, false); wasm.memory.initial = wasm.memory.segments[0].data.size(); return; @@ -2641,8 +2646,13 @@ void SExpressionWasmBuilder::parseMemory(Element& s, bool preParseImport) { } const char* input = curr[j]->c_str(); auto* offset = allocator.alloc(); - offset->type = Type::i32; - offset->value = Literal(int32_t(offsetValue)); + if (wasm.memory.is64()) { + offset->type = Type::i64; + offset->value = Literal(offsetValue); + } else { + offset->type = Type::i32; + offset->value = Literal(int32_t(offsetValue)); + } if (auto size = strlen(input)) { std::vector data; stringToBinary(input, size, data); -- cgit v1.2.3