summaryrefslogtreecommitdiff
path: root/src/ast_utils.h
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-09-30 17:04:25 -0700
committerGitHub <noreply@github.com>2016-09-30 17:04:25 -0700
commit58832ad0b8a197ece6165bfe163f634a21f8bd6d (patch)
treeb6f56bb970a53996d5bd6fabf1187a7139997f9f /src/ast_utils.h
parentcbe71a99f3b53db81cfd23f7a12f2010daeff65d (diff)
downloadbinaryen-58832ad0b8a197ece6165bfe163f634a21f8bd6d.tar.gz
binaryen-58832ad0b8a197ece6165bfe163f634a21f8bd6d.tar.bz2
binaryen-58832ad0b8a197ece6165bfe163f634a21f8bd6d.zip
asm2wasm i64 support (#723)
* support i64 intrinsics from fastcomp, adding --wasm-only flag * refactor callImport logic in asm2wasm to avoid recomputing wasm types again * legalize illegal i64 params in exports and imports * do safe i64 binary ops depending on precision * fix addVar, only assert on names if we are using a name
Diffstat (limited to 'src/ast_utils.h')
-rw-r--r--src/ast_utils.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/ast_utils.h b/src/ast_utils.h
index 9741faa25..8b2ae0d59 100644
--- a/src/ast_utils.h
+++ b/src/ast_utils.h
@@ -970,6 +970,54 @@ struct AutoDrop : public WalkerPass<ExpressionStackWalker<AutoDrop, Visitor<Auto
}
};
+struct I64Utilities {
+ static Expression* recreateI64(Builder& builder, Expression* low, Expression* high) {
+ return
+ builder.makeBinary(
+ OrInt64,
+ builder.makeUnary(
+ ExtendUInt32,
+ low
+ ),
+ builder.makeBinary(
+ ShlInt64,
+ builder.makeUnary(
+ ExtendUInt32,
+ high
+ ),
+ builder.makeConst(Literal(int64_t(32)))
+ )
+ )
+ ;
+ };
+
+ static Expression* recreateI64(Builder& builder, Index low, Index high) {
+ return recreateI64(builder, builder.makeGetLocal(low, i32), builder.makeGetLocal(high, i32));
+ };
+
+ static Expression* getI64High(Builder& builder, Index index) {
+ return
+ builder.makeUnary(
+ WrapInt64,
+ builder.makeBinary(
+ ShrUInt64,
+ builder.makeGetLocal(index, i64),
+ builder.makeConst(Literal(int64_t(32)))
+ )
+ )
+ ;
+ }
+
+ static Expression* getI64Low(Builder& builder, Index index) {
+ return
+ builder.makeUnary(
+ WrapInt64,
+ builder.makeGetLocal(index, i64)
+ )
+ ;
+ }
+};
+
} // namespace wasm
#endif // wasm_ast_utils_h