[PATCH] D62922: [WebAssembly] Implement "Reactor" mode
Dan Gohman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 5 11:03:39 PDT 2019
sunfish created this revision.
Herald added a subscriber: jgravelle-google.
Herald added a project: LLVM.
This is an experimental patch which adds a `-mexec-model=` command-line flag. The default value is "command" which is no change from the current behavior. The other option is "reactor" which enables an experimental Reactor ABI.
By default, clang/LLVM don't do much differently for Reactors -- it just picks a different crt1.o and entry point name -- so I won't go into detail here. I'll open a PR for wasi-libc to add the libc side of this, and I'll describe the ABI in detail there, and I expect most of the discussion will happen there.
Repository:
rL LLVM
https://reviews.llvm.org/D62922
Files:
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/WebAssembly.cpp
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===================================================================
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -67,8 +67,23 @@
Args.AddAllArgs(CmdArgs, options::OPT_u);
ToolChain.AddFilePathLibArgs(Args, CmdArgs);
- if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
- CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt1.o")));
+ if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+ const char *CrtO = "crt1.o";
+ const char *Entry = NULL;
+ if (const Arg *A = Args.getLastArg(options::OPT_mexec_model_EQ)) {
+ CrtO = llvm::StringSwitch<const char *>(A->getValue())
+ .Case("reactor", "reactor-crt1.o")
+ .Default(CrtO);
+ Entry = llvm::StringSwitch<const char *>(A->getValue())
+ .Case("reactor", "__wasi_unstable_reactor_start")
+ .Default(CrtO);
+ }
+ CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(CrtO)));
+ if (Entry) {
+ CmdArgs.push_back(Args.MakeArgString("--entry"));
+ CmdArgs.push_back(Args.MakeArgString(Entry));
+ }
+ }
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -148,6 +148,10 @@
Group<m_Group>, DocName<"PowerPC">;
def m_wasm_Features_Group : OptionGroup<"<wasm features group>">,
Group<m_Group>, DocName<"WebAssembly">;
+// The features added by this group will not be added to target features.
+// These are explicitly handled.
+def m_wasm_Features_Driver_Group : OptionGroup<"<wasm driver features group>">,
+ Group<m_Group>, DocName<"WebAssembly Driver">;
def m_x86_Features_Group : OptionGroup<"<x86 features group>">,
Group<m_Group>, Flags<[CoreOption]>, DocName<"X86">;
def m_riscv_Features_Group : OptionGroup<"<riscv features group>">,
@@ -2189,6 +2193,9 @@
def mno_multivalue : Flag<["-"], "mno-multivalue">, Group<m_wasm_Features_Group>;
def mtail_call : Flag<["-"], "mtail-call">, Group<m_wasm_Features_Group>;
def mno_tail_call : Flag<["-"], "mno-tail-call">, Group<m_wasm_Features_Group>;
+def mexec_model_EQ : Joined<["-"], "mexec-model=">, Group<m_wasm_Features_Driver_Group>,
+ Values<"command,reactor">,
+ HelpText<"Executable model (WebAssembly only)">;
def mamdgpu_debugger_abi : Joined<["-"], "mamdgpu-debugger-abi=">,
Flags<[HelpHidden]>,
Index: clang/docs/ClangCommandLineReference.rst
===================================================================
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -2599,6 +2599,12 @@
.. option:: -msimd128, -mno-simd128
+.. option:: -mexec-model=<arg>
+
+Select between "command" and "reactor" executable models. Commands have a main
+function which scopes the lifetime of the program. Reactors are activated and
+remain active until explicitly terminated.
+
X86
---
.. option:: -m3dnow, -mno-3dnow
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62922.203202.patch
Type: text/x-patch
Size: 3306 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190605/2c2127ef/attachment.bin>
More information about the llvm-commits
mailing list