diff --git a/.gitmodules b/.gitmodules index 088cc34f..1265cfaa 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "binaryen"] path = binaryen url = git://github.com/WebAssembly/binaryen.git +[submodule "wasmer"] + path = wasmer + url = https://github.com/wasmerio/wasmer diff --git a/utils/pipeline/README.md b/utils/pipeline/README.md index ae73776e..a3ccc8fe 100644 --- a/utils/pipeline/README.md +++ b/utils/pipeline/README.md @@ -63,6 +63,13 @@ cmake .. cmake --build . ``` +__wasmer__ + +``` +cd wasmer +make release-llvm +``` + __binaryen__ ``` @@ -77,6 +84,8 @@ Python3 >= 3.6 LLVM >= 8.0 +Rust (Nightly) + ### Note 1. current solution for __`.opt`__ → __`.ll`__ is not so reliable 2. for reference, my env is `llv=9.0.0`, `gcc=9.2.0`, `cmake=3.15.3` diff --git a/utils/pipeline/bc2opt2ll.py b/utils/pipeline/bc2opt2ll.py index 2b41681e..e11beb72 100644 --- a/utils/pipeline/bc2opt2ll.py +++ b/utils/pipeline/bc2opt2ll.py @@ -29,7 +29,9 @@ def batch_opt2ll(file_names): for file_name in file_names: try: result = subprocess.run( - f'python3 souper2llvm.py {file_name}.opt > {file_name}.ll', + # the former uses compiled script, the latter uses raw script + # ../../souper/build/souper2llvm ${name}.opt > ${name}.ll + f'python souper2llvm.py {file_name}.opt > {file_name}.ll', check=True, shell=True, stdout=subprocess.PIPE, diff --git a/utils/pipeline/pipeline.sh b/utils/pipeline/pipeline.sh index 72f963e8..54880b55 100644 --- a/utils/pipeline/pipeline.sh +++ b/utils/pipeline/pipeline.sh @@ -5,39 +5,56 @@ ext=$(echo $1 | sed 's/^.*\.//') # export BINARYEN_DEBUG_SOUPERIFY=0 +:< ${name}.opt +if [ "${ext}" == "wast" ]; then + echo "### step1 wast2wasm \c" + ../../wabt/bin/wat2wasm ${name}.wast -o ${name}.wasm + # ../../binaryen/bin/wasm-as ${name}.wast > ${name}.wasm + ext='wasm' echo "okay" fi if [ "${ext}" == "wasm" ]; then echo "### step2 wasm2opt \c" - ../../binaryen/bin/wasm-opt ${name}.wasm --flatten --souperify-single-use > ${name}.opt + ../../binaryen/bin/wasm-opt ${name}.wasm --flatten --simplify-locals-nonesting --reorder-locals --souperify > ${name}.opt + ext='opt' echo "okay" fi -echo "### step3 opt2ll \c" -python souper2llvm.py ${name}.opt > ${name}.ll -# ../../souper/build/souper2llvm ${name}.opt > ${name}.ll # it seems not so good -echo "okay" +if [ "${ext}" == "opt" ]; then + echo "### step3 opt2ll \c" + python souper2llvm.py ${name}.opt > ${name}.ll + # ../../souper/build/souper2llvm ${name}.opt > ${name}.ll + ext='ll' + echo "okay" +fi -echo "### step4 ll2bc \c" -llvm-as ${name}.ll -echo "okay" +if [ "${ext}" == "ll" ]; then + echo "### step4 ll2bc \c" + llvm-as ${name}.ll + ext='bc' + echo "okay" +fi -echo "### step5 bc2opt2ll \c" -sh bc2opt2ll.sh ${name}.bc ../../souper/build/souper -echo "okay" +if [ "${ext}" == "bc" ]; then + echo "### step5 bc2opt2ll \c" + sh bc2opt2ll.sh ${name}.bc ../../souper/build/souper + ext='ll' + echo "okay" +fi -echo "### extra ll2s \c" -llc -march=wasm32 -filetype=asm ${name}.ll -echo "okay" +# echo "### extra ll2s \c" +# llc -march=wasm32 -filetype=asm ${name}.ll +# echo "okay" -echo "### extra ll2o \c" -llc -march=wasm32 -filetype=obj ${name}.ll -echo "okay" +# echo "### extra ll2o \c" +# llc -march=wasm32 -filetype=obj ${name}.ll +# echo "okay" diff --git a/wasmer b/wasmer new file mode 160000 index 00000000..88f126a0 --- /dev/null +++ b/wasmer @@ -0,0 +1 @@ +Subproject commit 88f126a00b9eb867b36213c2530e3e6619f29dfe