Update internal ABI to zero/sign-extend where necessary only (#87)

This commit is contained in:
Daniel Wirtz
2018-05-06 00:00:54 +02:00
committed by GitHub
parent ce2bf00d62
commit 50f6c1c460
72 changed files with 8846 additions and 9459 deletions

View File

@ -2,6 +2,9 @@
declare type I64 = { __Long__: true }; // opaque
declare const i64_zero: I64;
declare const i64_one: I64;
declare function i64_new(lo: i32, hi?: i32): I64;
declare function i64_low(value: I64): i32;
declare function i64_high(value: I64): i32;
@ -21,6 +24,9 @@ declare function i64_shr(left: I64, right: I64): I64;
declare function i64_shr_u(left: I64, right: I64): I64;
declare function i64_not(value: I64): I64;
declare function i64_eq(left: I64, right: I64): bool;
declare function i64_ne(left: I64, right: I64): bool;
declare function i64_align(value: I64, alignment: i32): I64;
declare function i64_is_i8(value: I64): bool;

View File

@ -1,5 +1,9 @@
const Long = global.Long || require("long");
global.i64_zero = Long.ZERO;
global.i64_one = Long.ONE;
global.i64_new = function(lo, hi) {
return Long.fromBits(lo, hi);
};
@ -68,6 +72,14 @@ global.i64_not = function(value) {
return value.not();
};
global.i64_eq = function(left, right) {
return left.eq(right);
};
global.i64_ne = function(left, right) {
return left.ne(right);
};
global.i64_align = function(value, alignment) {
assert(alignment && (alignment & (alignment - 1)) == 0);
var mask = Long.fromInt(alignment - 1);

View File

@ -2,6 +2,12 @@
type I64 = i64;
@global
const i64_zero: I64 = 0;
@global
const i64_one: I64 = 1;
@global
function i64_new(lo: i32, hi: i32 = 0): I64 {
return lo | (hi << 32);
@ -87,6 +93,16 @@ function i64_not(value: I64): I64 {
return ~value;
}
@global
function i64_eq(left: I64, right: I64): bool {
return left == right;
}
@global
function i64_ne(left: I64, right: I64): bool {
return left != right;
}
@global
function i64_align(value: I64, alignment: i64): I64 {
var mask: i64 = alignment - 1;