diff options
author | Alon Zakai <alonzakai@gmail.com> | 2017-06-13 16:05:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-13 16:05:01 -0700 |
commit | b5b40c9ab0c35ed74e97a6491e15651382091b2e (patch) | |
tree | d2ec6c2006089d8385b850a730af4be936874314 /src/tools | |
parent | 61b409bc845f385f1d7ea7ac81d1649b63435828 (diff) | |
download | binaryen-b5b40c9ab0c35ed74e97a6491e15651382091b2e.tar.gz binaryen-b5b40c9ab0c35ed74e97a6491e15651382091b2e.tar.bz2 binaryen-b5b40c9ab0c35ed74e97a6491e15651382091b2e.zip |
SSA pass (#1049)
* Add SSA pass which ensures a single assign for each local, except for merged locals where we ensure exactly a single assign from one of the paths leading to that use
* Also add InstrumentLocals pass, useful for debugging locals (similar to InstrumentMemory but for locals)
* Fix a PickLoadSigns bug with tees not being ignored, which was not noticed until now because we ran it on flatter output by default, but the ssa pass uncovered the bug
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/tool-utils.h | 37 | ||||
-rw-r--r-- | src/tools/wasm-as.cpp | 7 |
2 files changed, 44 insertions, 0 deletions
diff --git a/src/tools/tool-utils.h b/src/tools/tool-utils.h new file mode 100644 index 000000000..a897e01f0 --- /dev/null +++ b/src/tools/tool-utils.h @@ -0,0 +1,37 @@ +/* + * Copyright 2017 WebAssembly Community Group participants + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// +// Shared utilities for commandline tools +// + +#include <string> + +namespace wasm { + +// Removes a specific suffix if it is present, otherwise no-op +inline std::string removeSpecificSuffix(std::string str, std::string suffix) { + if (str.size() <= suffix.size()) { + return str; + } + if (str.substr(str.size() - suffix.size()).compare(suffix) == 0) { + return str.substr(0, str.size() - suffix.size()); + } + return str; +} + +} // namespace wasm + diff --git a/src/tools/wasm-as.cpp b/src/tools/wasm-as.cpp index e8003a5ca..d4b495562 100644 --- a/src/tools/wasm-as.cpp +++ b/src/tools/wasm-as.cpp @@ -24,6 +24,8 @@ #include "wasm-binary.h" #include "wasm-s-parser.h" +#include "tool-utils.h" + using namespace cashew; using namespace wasm; @@ -68,6 +70,11 @@ int main(int argc, const char *argv[]) { }); options.parse(argc, argv); + // default output is infile with changed suffix + if (options.extra.find("output") == options.extra.end()) { + options.extra["output"] = removeSpecificSuffix(options.extra["infile"], ".wast") + ".wasm"; + } + auto input(read_file<std::string>(options.extra["infile"], Flags::Text, options.debug ? Flags::Debug : Flags::Release)); Module wasm; |