-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* basic solution for souper2wasm * minor improvements
- Loading branch information
Jian GU
authored
Sep 16, 2019
1 parent
290aa68
commit f7bfdc9
Showing
7 changed files
with
562 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# from Souper IR to WASM | ||
|
||
__Souper IR → LLVM IR__ | ||
Souper's [souper-check.cpp](https://github.com/google/souper/blob/master/tools/souper-check.cpp) and [souper2llvm.in](https://github.com/google/souper/blob/master/utils/souper2llvm.in) | ||
|
||
__LLVM IR → WASM__ | ||
`llc -mtriple=wasm32-unknown-unknown` ([blog](https://medium.com/@richardanaya/write-web-assembly-with-llvm-fbee788b2817)) | ||
|
||
## run demo | ||
``` | ||
zsh run.sh | ||
``` | ||
|
||
## requirements | ||
Python >= 3.6 | ||
LLVM >= 8.0 | ||
|
||
## existing issues | ||
- In some cases (like `demo/negate.opt`), width info can not be identified correctly |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | ||
|
||
|
||
define i1 @foo(i1 %x1, i64 %x2) { | ||
entry: | ||
%0 = icmp ult i64 135637824071393761, %x2 | ||
%1 = or i1 %x1, %0 | ||
%2 = select i1 %1, i64 135637824071393761, i64 %x2 | ||
%3 = icmp ult i64 135637824071393761, %2 | ||
ret i1 %3 | ||
} |
Binary file not shown.
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
; REQUIRES: solver | ||
|
||
; RUN: %souper-check %solver -infer-rhs -print-replacement %s > %t1 | ||
; RUN: %FileCheck %s -check-prefix=SUCCESS < %t1 | ||
; RUN: %parser-test < %t1 | ||
; RUN: %souper-check %solver < %t1 | %FileCheck -check-prefix=LGTM %s | ||
; RUN: %souper-check %solver -infer-rhs %s > %t2 | ||
; RUN: cat %s %t2 | %souper-check %solver | %FileCheck -check-prefix=LGTM %s | ||
|
||
; SUCCESS: RHS inferred successfully | ||
; LGTM: LGTM | ||
|
||
%0:i1 = var | ||
%1:i64 = var | ||
%2:i1 = ult 135637824071393761:i64, %1 | ||
%3:i1 = or %0, %2 | ||
%4:i64 = select %3, 135637824071393761:i64, %1 | ||
%5:i1 = ult 135637824071393761:i64, %4 | ||
infer %5 | ||
|
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
; REQUIRES: solver | ||
|
||
; RUN: %souper-check %solver -print-replacement %s > %t1 | ||
; RUN: %FileCheck %s < %t1 | ||
; RUN: %parser-test < %t1 | ||
; RUN: %souper-check %solver %t1 | %FileCheck %s | ||
|
||
; RUN: %souper-check %solver -print-replacement-split %s > %t2 | ||
; RUN: %FileCheck %s < %t2 | ||
; RUN: %parser-test < %t2 | ||
; RUN: %souper-check %solver %t2 | %FileCheck %s | ||
|
||
; CHECK: LGTM | ||
|
||
%0:i64 = var | ||
%1:i64 = xor %0, -1:i64 | ||
%2:i64 = add %1, 1:i64 | ||
%3:i64 = sub 0:i64, %0 | ||
cand %2 %3 |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
echo "py ... \c" | ||
python3 souper2llvm.py demo/infer.opt | ||
echo "okay" | ||
|
||
echo "llc ... \c" | ||
llc -mtriple=wasm32-unknown-unknown -O3 -filetype=obj demo/infer.ll -o demo/infer.o | ||
echo "okay" |
Oops, something went wrong.