================
@@ -1200,6 +1225,36 @@ void Writer::createSyntheticInitFunctions() {
   }
 }
 
+void Writer::createMemoryGrowFunction() {
+  LLVM_DEBUG(dbgs() << "createMemoryGrowFunction\n");
+  assert(ctx.sym.memoryGrow);
+  std::string bodyContent;
+  {
+    raw_string_ostream os(bodyContent);
+    writeUleb128(os, 0, "num locals");
+    writeU8(os, WASM_OPCODE_LOCAL_GET, "local.get");
+    writeUleb128(os, 0, "local 0");
+    writeU8(os, WASM_OPCODE_MEMORY_GROW, "memory grow");
+    writeUleb128(os, 0, "reserved memory byte");
+    writeU8(os, WASM_OPCODE_END, "END");
+  }
+  createFunction(ctx.sym.memoryGrow, bodyContent);
+}
+
+void Writer::createMemorySizeFunction() {
+  LLVM_DEBUG(dbgs() << "createMemorySizeFunction\n");
+  assert(ctx.sym.memorySize);
+  std::string bodyContent;
+  {
+    raw_string_ostream os(bodyContent);
+    writeUleb128(os, 0, "num locals");
+    writeU8(os, WASM_OPCODE_MEMORY_SIZE, "memory size");
+    writeUleb128(os, 0, "reserved memory byte");
+    writeU8(os, WASM_OPCODE_END, "END");
+  }
+  createFunction(ctx.sym.memorySize, bodyContent);
----------------
arjunr2 wrote:

Good point. Moved everything out of the linker, which now has no changes.

https://github.com/llvm/llvm-project/pull/156087
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to