summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md16
-rw-r--r--src/binaryen-shell.cpp4
2 files changed, 20 insertions, 0 deletions
diff --git a/README.md b/README.md
index ed3194f84..f7aa7ccca 100644
--- a/README.md
+++ b/README.md
@@ -38,6 +38,22 @@ Run
bin/binaryen-shell [.wast file] [options] [passes, see --help] [--help]
````
+The binaryen shell receives a .wast file as input, and can run transformation passes on it, as well as print it (before and/or after the transformations). For example, try
+
+````
+bin/binaryen-shell test/if_else.wast -print-before
+````
+
+That will pretty-print out one of the testcases in the test suite. To run a transformation pass on it, try
+
+````
+bin/binaryen-shell test/if_else.wast -print-before -print-after -lower-if-else
+````
+
+The `lower-if-else` pass lowers if-else into a block and a break. You can see the difference the transformation between the print before versus after.
+
+Some more notes:
+
* See `bin/binaryen-shell --help` for the full list of options and passes.
* Setting `BINARYEN_DEBUG=1` in the env will emit some debugging info.
diff --git a/src/binaryen-shell.cpp b/src/binaryen-shell.cpp
index c7357e141..3ec9e684b 100644
--- a/src/binaryen-shell.cpp
+++ b/src/binaryen-shell.cpp
@@ -240,7 +240,9 @@ int main(int argc, char **argv) {
auto instance = new ModuleInstance(wasm, interface);
if (print_before) {
+ Colors::bold(std::cout);
std::cout << "printing before:\n";
+ Colors::normal(std::cout);
std::cout << wasm;
}
@@ -256,7 +258,9 @@ int main(int argc, char **argv) {
}
if (print_after) {
+ Colors::bold(std::cout);
std::cout << "printing after:\n";
+ Colors::normal(std::cout);
std::cout << wasm;
}