-
-
Save acuna-public/4185d78fb47b5626b83ced5eb6b40c58 to your computer and use it in GitHub Desktop.
Revisions
-
yurydelendik revised this gist
Feb 28, 2018 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ NOTE: the content is out-of-date. All development is moved to the https://github.com/yurydelendik/wasmception # Using WebAssembly in LLVM ## Compiling -
yurydelendik revised this gist
Nov 21, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,7 @@ cd $WORKDIR/llvm/tools svn co http://llvm.org/svn/llvm-project/cfe/trunk clang # checkout lld svn co http://llvm.org/svn/llvm-project/lld/trunk lld # build folder (~14 min; ~1 hour /wo -j) mkdir $WORKDIR/llvm-build -
yurydelendik revised this gist
Nov 16, 2017 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,6 +15,9 @@ svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm cd $WORKDIR/llvm/tools svn co http://llvm.org/svn/llvm-project/cfe/trunk clang # checkout lld git clone https://github.com/WebAssembly/lld.git -b wasm # build folder (~14 min; ~1 hour /wo -j) mkdir $WORKDIR/llvm-build cd $WORKDIR/llvm-build -
yurydelendik revised this gist
Feb 7, 2017 . 1 changed file with 2 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,16 +15,12 @@ svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm cd $WORKDIR/llvm/tools svn co http://llvm.org/svn/llvm-project/cfe/trunk clang # build folder (~14 min; ~1 hour /wo -j) mkdir $WORKDIR/llvm-build cd $WORKDIR/llvm-build # For Debug build: # cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$INSTALLDIR -DLLVM_TARGETS_TO_BUILD= -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Debug $WORKDIR/llvm cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$INSTALLDIR -DLLVM_TARGETS_TO_BUILD= -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly $WORKDIR/llvm make -j 8 # install llvm -
yurydelendik revised this gist
Nov 10, 2016 . 1 changed file with 58 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,58 @@ ROOT_DIR=$(shell pwd) LLVM_WORKDIR=$(ROOT_DIR)/src/llvm LLVM_BUILDDIR=$(ROOT_DIR)/build/llvm BINARYEN_WORKDIR=$(ROOT_DIR)/src/binaryen BINARYEN_BUILDDIR=$(ROOT_DIR)/build/binaryen INSTALLDIR=$(ROOT_DIR)/bin build: build-llvm build-binaryen clean: clean-llvm clean-binaryen rm -rf $(INSTALLDIR) install: install-llvm install-binaryen $(LLVM_WORKDIR)/.svn: rm -rf $(LLVM_WORKDIR) mkdir -p $(LLVM_WORKDIR) svn co http://llvm.org/svn/llvm-project/llvm/trunk $(LLVM_WORKDIR) svn co http://llvm.org/svn/llvm-project/cfe/trunk $(LLVM_WORKDIR)/tools/clang svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk $(LLVM_WORKDIR)/projects/compiler-rt $(LLVM_BUILDDIR)/Makefile: $(LLVM_WORKDIR)/.svn mkdir -p $(LLVM_BUILDDIR) cd $(LLVM_BUILDDIR); cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$(INSTALLDIR) -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DLLVM_TARGETS_TO_BUILD= -DCMAKE_BUILD_TYPE=Release $(LLVM_WORKDIR) build-llvm: $(LLVM_BUILDDIR)/Makefile $(MAKE) -C $(LLVM_BUILDDIR) -j 8 clang llc llvm-lib clean-llvm: rm -rf $(LLVM_WORKDIR) rm -rf $(LLVM_BUILDDIR) install-llvm: mkdir -p $(INSTALLDIR) $(MAKE) -C $(LLVM_BUILDDIR) install-clang install-llc install-llvm-lib $(BINARYEN_WORKDIR)/.git: rm -rf $(BINARYEN_WORKDIR) mkdir -p $(BINARYEN_WORKDIR) git clone https://github.com/WebAssembly/binaryen $(BINARYEN_WORKDIR) $(BINARYEN_BUILDDIR)/Makefile: $(BINARYEN_WORKDIR)/.git mkdir -p $(BINARYEN_BUILDDIR) cd $(BINARYEN_BUILDDIR); cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$(INSTALLDIR) -DCMAKE_BUILD_TYPE=Release $(BINARYEN_WORKDIR) build-binaryen: $(BINARYEN_BUILDDIR)/Makefile $(MAKE) -C $(BINARYEN_BUILDDIR) -j 8 wasm-as wasm-dis s2wasm clean-binaryen: rm -rf $(BINARYEN_WORKDIR) rm -rf $(BINARYEN_BUILDDIR) install-binaryen: mkdir -p $(INSTALLDIR) cp $(addprefix $(BINARYEN_BUILDDIR)/bin/, wasm-as wasm-dis s2wasm) $(INSTALLDIR) .PHONY: build clean install build-llvm clean-llvm install-llvm build-binaryen clean-binaryen install-binaryen -
yurydelendik revised this gist
May 27, 2016 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,6 +22,8 @@ svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt # build folder (~14 min; ~1 hour /wo -j) mkdir $WORKDIR/llvm-build cd $WORKDIR/llvm-build # For Debug build: # cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$INSTALLDIR -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Debug $WORKDIR/llvm cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$INSTALLDIR -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly $WORKDIR/llvm make -j 8 @@ -38,7 +40,7 @@ $INSTALLDIR/bin/clang -emit-llvm --target=wasm32 -Oz fib.c -c -o fib.bc $INSTALLDIR/bin/llc -asm-verbose=false -o fib.s fib.bc ``` See output at fib.s. Convert to WebAssebly s-expressions (needs binaryen s2wasm tool): -
yurydelendik revised this gist
May 27, 2016 . 1 changed file with 3 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,10 +27,6 @@ make -j 8 # install llvm make install ``` ## Example @@ -39,15 +35,15 @@ Let's create "fib.c" and compile it, first to LLVM bitcode, then to WebAssembly- ``` $INSTALLDIR/bin/clang -emit-llvm --target=wasm32 -Oz fib.c -c -o fib.bc $INSTALLDIR/bin/llc -asm-verbose=false -o fib.s fib.bc ``` See output at fib.wasm0. Convert to WebAssebly s-expressions (needs binaryen s2wasm tool): ``` $BINARYENDIR/bin/s2wasm fib.s > fib.wast ``` See output at fib.wast. -
yurydelendik revised this gist
May 18, 2016 . 1 changed file with 23 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ #/bin/bash llvm_root=~/llvmwasm/llvm-build/bin binaryen_root=~/llvmwasm/binaryen/bin cfile=$1 bcfile=${cfile%.*}.bc sfile=${cfile%.*}.s wastfile=${cfile%.*}.wast $llvm_root/clang -emit-llvm --target=wasm32 -Oz "$cfile" -c -o "$bcfile" if [ $? != 0 ];then exit 1 fi $llvm_root/llc -asm-verbose=false -o "$sfile" "$bcfile" if [ $? != 0 ];then exit 2 fi $binaryen_root/s2wasm "$sfile" > "$wastfile" if [ $? != 0 ];then exit 3 fi -
yurydelendik revised this gist
Oct 8, 2015 . 1 changed file with 24 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,40 +3,51 @@ ## Compiling ``` # locations, e.g. export WORKDIR=~/llvmwasm; mkdir -p $WORKDIR export INSTALLDIR=$WORKDIR # checkout LLVM cd $WORKDIR svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm # checkout clang cd $WORKDIR/llvm/tools svn co http://llvm.org/svn/llvm-project/cfe/trunk clang # sanitizers cd $WORKDIR/llvm/projects svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt # build folder (~14 min; ~1 hour /wo -j) mkdir $WORKDIR/llvm-build cd $WORKDIR/llvm-build cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$INSTALLDIR -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly $WORKDIR/llvm make -j 8 # install llvm make install # install scaffolding tools (optional) cd $WORKDIR git clone https://github.com/WebAssembly/experimental.git ``` ## Example Let's create "fib.c" and compile it, first to LLVM bitcode, then to WebAssembly-like file. (Notice -O2 or above near clang to avoid failure during `llc` run.) ``` $INSTALLDIR/bin/clang -emit-llvm --target=wasm32 -Oz fib.c -c -o fib.bc $INSTALLDIR/bin/llc -asm-verbose=false -o fib.wasm0 fib.bc ``` See output at fib.wasm0. Convert to WebAssebly s-expressions (needs the wasmate scaffolding tools): ``` python $WORKDIR/experimental/prototype-wasmate/wasmate.py < fib.wasm0 > fib.wast ``` See output at fib.wast. -
yurydelendik revised this gist
Oct 8, 2015 . 1 changed file with 0 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +0,0 @@ -
yurydelendik revised this gist
Oct 7, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,7 +28,7 @@ Let's create "fib.c" and compile it first to LLVM bitcode then to WebAssebly-lik ``` $PREFIX/bin/clang -emit-llvm --target=wasm32 -Oz fib.c -c -o fib.bc $PREFIX/bin/llc -asm-verbose=false -o fib.wasm0 fib.bc ``` See output at fib.wasm0. -
yurydelendik revised this gist
Oct 7, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,7 @@ make Let's create "fib.c" and compile it first to LLVM bitcode then to WebAssebly-like file. ``` $PREFIX/bin/clang -emit-llvm --target=wasm32 -Oz fib.c -c -o fib.bc $PREFIX/bin/llc -march=wasm32 -mcpu=mvp -asm-verbose=false -o fib.wasm0 fib.bc ``` -
yurydelendik revised this gist
Oct 7, 2015 . 3 changed files with 75 additions and 40 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -33,6 +33,14 @@ $PREFIX/bin/llc -march=wasm32 -mcpu=mvp -asm-verbose=false -o fib.wasm0 fib.bc See output at fib.wasm0. Convert to WebAssebly s-expressions (needs scaffolding tools installed by `cd $WORK; git clone https://github.com/WebAssembly/experimental.git`): ``` python $WORK/experimental/prototype-wasmate/wasmate.py < fib.wasm0 > fib.wast ``` See output at fib.wast. ## References * http://llvm.org/docs/GettingStarted.html This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,41 +1,36 @@ .text .file "fib.bc" .globl fib .type fib,@function fib: .param i32 .result i32 block $BB0_3 i32.const 1 set_local @9, pop i32.const 0 set_local @13, pop i32.const -1 set_local @12, pop @0 set_local @6, pop @9 set_local @14, pop BB0_1: loop $BB0_3 add @12, @9 set_local @12, pop sge @12, @6 set_local @11, pop brif $BB0_3, @11 add @14, @13 set_local @5, pop @14 set_local @13, pop @5 set_local @14, pop br $BB0_1 BB0_3: return @14 func_end0: .size fib, func_end0-fib This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ (module (import $print_i32 "stdio" "print" (param i32)) (import $print_f32 "stdio" "print" (param f32)) (import $print_i64 "stdio" "print" (param i64)) (import $print_f64 "stdio" "print" (param f64)) (func $fib (param i32) (result i32) (block $BB0_3 (set_local @9 (i32.const 1)) (set_local @13 (i32.const 0)) (set_local @12 (i32.const -1)) (set_local @6 (@0)) (set_local @14 (@9)) (loop $BB0_1 (set_local @12 (add @12 @9)) (set_local @11 (sge @12 @6)) (brif $BB0_3 @11) (set_local @5 (add @14 @13)) (set_local @13 (@14)) (set_local @14 (@5)) (br $BB0_1) ) ) (return @14) ) (memory 0 0 (segment 0 "" ) ) ) -
yurydelendik revised this gist
Oct 7, 2015 . 1 changed file with 3 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,12 +15,10 @@ svn co http://llvm.org/svn/llvm-project/cfe/trunk clang cd $WORK/llvm/projects svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt # build folder (~1 hour /wo threads) mkdir $WORK/llvm-build cd $WORK/llvm-build cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$PREFIX -DEXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly $WORK/llvm make ``` @@ -38,4 +36,5 @@ See output at fib.wasm0. ## References * http://llvm.org/docs/GettingStarted.html * http://llvm.org/svn/llvm-project/llvm/trunk/lib/Target/WebAssembly/ * https://github.com/llvm-mirror/llvm/tree/master/test/CodeGen/WebAssembly -
yurydelendik revised this gist
Oct 7, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,7 +30,7 @@ Let's create "fib.c" and compile it first to LLVM bitcode then to WebAssebly-lik ``` $PREFIX/bin/clang -emit-llvm -Oz fib.c -c -o fib.bc $PREFIX/bin/llc -march=wasm32 -mcpu=mvp -asm-verbose=false -o fib.wasm0 fib.bc ``` See output at fib.wasm0. -
yurydelendik renamed this gist
Oct 7, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
yurydelendik created this gist
Oct 7, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ --- CMakeLists.txt (revision 249591) +++ CMakeLists.txt (working copy) @@ -194,6 +194,7 @@ SystemZ X86 XCore + WebAssembly ) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ int fib(int n) { int i, t, a = 0, b = 1; for (i = 0; i < n; i++) { t = a + b; a = b; b = t; } return b; } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ .text .macosx_version_min 10, 10 .file "fib.bc" .globl fib .type fib,@function fib: # @fib .param i32 .result i32 # BB#0: # %entry block $BB0_3 i32.const 1 set_local @9, pop i32.const 0 set_local @13, pop i32.const -1 set_local @12, pop @0 set_local @6, pop @9 set_local @14, pop BB0_1: # %for.cond # =>This Inner Loop Header: Depth=1 loop $BB0_3 add @12, @9 set_local @12, pop sge @12, @6 set_local @11, pop brif $BB0_3, @11 # BB#2: # %for.body # in Loop: Header=BB0_1 Depth=1 add @14, @13 set_local @5, pop @14 set_local @13, pop @5 set_local @14, pop br $BB0_1 BB0_3: # %for.end return @14 func_end0: .size fib, func_end0-fib This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ # Using WebAssembly in LLVM ## Compiling ``` # checkout LLVM cd $WORK svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm # checkout clang cd $WORK/llvm/tools svn co http://llvm.org/svn/llvm-project/cfe/trunk clang # sanitizers cd $WORK/llvm/projects svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt # !! Changed CMakeList.txt file to add WebAssembly (see add-cmake-wasm.patch below) # build folder (~1 hour /wo threads) mkdir $WORK/llvm-build cd $WORK/llvm-build cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$PREFIX $WORK/llvm make ``` ## Example Let's create "fib.c" and compile it first to LLVM bitcode then to WebAssebly-like file. ``` $PREFIX/bin/clang -emit-llvm -Oz fib.c -c -o fib.bc $PREFIX/bin/llc -march=wasm32 -mcpu=mvp -o fib.wasm0 fib.bc ``` See output at fib.wasm0. ## References * http://llvm.org/docs/GettingStarted.html * http://llvm.org/svn/llvm-project/llvm/trunk/lib/Target/WebAssembly/