From 23b7d65fe5b93bf7161b3d7ebd54eb9b1f41e291 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Thu, 2 Jun 2016 21:34:18 +0000 Subject: [WebAssembly] Emit type signatures for declared functions Under emscripten, C code can take the address of a function implemented in Javascript (which is exposed via an import in wasm). Because imports do not have linear memory address in wasm, we need to generate a thunk to be the target of the indirect call; it call the import directly. To make this possible, LLVM needs to emit the type signatures for these functions, because they may not be called directly or referred to other than where the address is taken. This uses s new .s directive (.functype) which specifies the signature. Differential Revision: http://reviews.llvm.org/D20891 llvm-svn: 271599 --- .../Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h') diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h index c66a51574ef..51354ef22d7 100644 --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h @@ -37,6 +37,12 @@ public: virtual void emitLocal(ArrayRef Types) = 0; /// .endfunc virtual void emitEndFunc() = 0; + /// .functype + virtual void emitIndirectFunctionType(StringRef name, + SmallVectorImpl &SignatureVTs, + size_t NumResults) { + llvm_unreachable("emitIndirectFunctionType not implemented"); + } }; /// This part is for ascii assembly output @@ -50,6 +56,9 @@ public: void emitResult(ArrayRef Types) override; void emitLocal(ArrayRef Types) override; void emitEndFunc() override; + void emitIndirectFunctionType(StringRef name, + SmallVectorImpl &SignatureVTs, + size_t NumResults) override; }; /// This part is for ELF object output -- cgit v1.2.3