diff options
author | Alon Zakai <azakai@google.com> | 2019-11-11 17:19:37 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-11 17:19:37 -0800 |
commit | 485de15c5233e2fbfc14e27f1ec0cfdecd6fb630 (patch) | |
tree | 76c26111242c3d4de20c5a29226ee9cb001dbac4 | |
parent | e83a9e2a21b35f19fe56a0d375191369b9b67148 (diff) | |
download | binaryen-485de15c5233e2fbfc14e27f1ec0cfdecd6fb630.tar.gz binaryen-485de15c5233e2fbfc14e27f1ec0cfdecd6fb630.tar.bz2 binaryen-485de15c5233e2fbfc14e27f1ec0cfdecd6fb630.zip |
Support --pass-arg in ToolOptions. (#2429)
This will allow us to pass pass args to
wasm-emscripten-finalize, which runs
legalize-js-interface internally, which recently
added an optional argument.
-rw-r--r-- | src/pass.h | 1 | ||||
-rw-r--r-- | src/tools/optimization-options.h | 17 | ||||
-rw-r--r-- | src/tools/tool-options.h | 17 | ||||
-rw-r--r-- | src/tools/wasm-emscripten-finalize.cpp | 1 |
4 files changed, 19 insertions, 17 deletions
diff --git a/src/pass.h b/src/pass.h index a9b14907b..0d0b14883 100644 --- a/src/pass.h +++ b/src/pass.h @@ -153,6 +153,7 @@ struct PassRunner { PassRunner(const PassRunner&) = delete; PassRunner& operator=(const PassRunner&) = delete; + void setOptions(PassOptions newOptions) { options = newOptions; } void setDebug(bool debug) { options.debug = debug; // validate everything by default if debugging diff --git a/src/tools/optimization-options.h b/src/tools/optimization-options.h index 9d8259077..ef5a7d67a 100644 --- a/src/tools/optimization-options.h +++ b/src/tools/optimization-options.h @@ -180,23 +180,6 @@ struct OptimizationOptions : public ToolOptions { Options::Arguments::Zero, [this](Options*, const std::string&) { passOptions.lowMemoryUnused = true; - }) - .add("--pass-arg", - "-pa", - "An argument passed along to optimization passes being run. Must be " - "in the form KEY@VALUE", - Options::Arguments::N, - [this](Options*, const std::string& argument) { - std::string key, value; - auto colon = argument.find('@'); - if (colon == std::string::npos) { - key = argument; - value = "1"; - } else { - key = argument.substr(0, colon); - value = argument.substr(colon + 1); - } - passOptions.arguments[key] = value; }); // add passes in registry for (const auto& p : PassRegistry::get()->getRegisteredNames()) { diff --git a/src/tools/tool-options.h b/src/tools/tool-options.h index 0de42ad13..33a631975 100644 --- a/src/tools/tool-options.h +++ b/src/tools/tool-options.h @@ -78,6 +78,23 @@ struct ToolOptions : public Options { Options::Arguments::Zero, [this](Options* o, const std::string& argument) { passOptions.validate = false; + }) + .add("--pass-arg", + "-pa", + "An argument passed along to optimization passes being run. Must be " + "in the form KEY@VALUE", + Options::Arguments::N, + [this](Options*, const std::string& argument) { + std::string key, value; + auto colon = argument.find('@'); + if (colon == std::string::npos) { + key = argument; + value = "1"; + } else { + key = argument.substr(0, colon); + value = argument.substr(colon + 1); + } + passOptions.arguments[key] = value; }); } diff --git a/src/tools/wasm-emscripten-finalize.cpp b/src/tools/wasm-emscripten-finalize.cpp index 234438460..38904df12 100644 --- a/src/tools/wasm-emscripten-finalize.cpp +++ b/src/tools/wasm-emscripten-finalize.cpp @@ -261,6 +261,7 @@ int main(int argc, const char* argv[]) { // Legalize the wasm. { PassRunner passRunner(&wasm); + passRunner.setOptions(options.passOptions); passRunner.setDebug(options.debug); passRunner.setDebugInfo(debugInfo); passRunner.add(ABI::getLegalizationPass( |