Add more inline-assembler-ish builtins; Update Binaryen

This commit is contained in:
dcodeIO
2018-04-27 19:12:25 +02:00
parent 06f99406be
commit 2aea14b518
15 changed files with 3452 additions and 2964 deletions

14
std/assembly.d.ts vendored
View File

@ -265,23 +265,23 @@ declare function alignof<T>(): usize;
declare function offsetof<T>(fieldName?: string): usize;
/** Changes the type of any value of `usize` kind to another one of `usize` kind. Useful for casting class instances to their pointer values and vice-versa. Beware that this is unsafe.*/
declare function changetype<T>(value: any): T;
/** Explicitly requests no bounds checks on the provided expression. */
/** Explicitly requests no bounds checks on the provided expression. Useful for array accesses. */
declare function unchecked<T>(value: T): T;
/** Tests if a 32-bit or 64-bit float is `NaN`. */
declare function isNaN<T = f32 | f64>(value: T): bool;
/** Tests if a 32-bit or 64-bit float is finite, that is not `NaN` or +/-`Infinity`. */
declare function isFinite<T = f32 | f64>(value: T): bool;
/** Tests if the specified expression is of an integer type and not a reference. Compiles to a constant. */
/** Tests if the specified type *or* expression is of an integer type and not a reference. Compiles to a constant. */
declare function isInteger<T>(value?: any): value is number;
/** Tests if the specified expression is of a float type. Compiles to a constant. */
/** Tests if the specified type *or* expression is of a float type. Compiles to a constant. */
declare function isFloat<T>(value?: any): value is number;
/** Tests if the specified expression can represent negative numbers. Compiles to a constant. */
/** Tests if the specified type *or* expression can represent negative numbers. Compiles to a constant. */
declare function isSigned<T>(value?: any): value is number;
/** Tests if the specified expression is of a reference type. Compiles to a constant. */
/** Tests if the specified type *or* expression is of a reference type. Compiles to a constant. */
declare function isReference<T>(value?: any): value is object | string;
/** Tests if the specified expression can be used ass a string. Compiles to a constant. */
/** Tests if the specified type *or* expression can be used as a string. Compiles to a constant. */
declare function isString<T>(value?: any): value is string | String;
/** Tests if the specified expression can be used as an array. Compiles to a constant. */
/** Tests if the specified type *or* expression can be used as an array. Compiles to a constant. */
declare function isArray<T>(value?: any): value is Array<any>;
/** Traps if the specified value is not true-ish, otherwise returns the (non-nullable) value. */
declare function assert<T>(isTrueish: T, message?: string): T & object; // any better way to model `: T != null`?

View File

@ -103,6 +103,12 @@ export declare function i32(value: void): i32;
export namespace i32 {
export const MIN_VALUE: i32 = -2147483648;
export const MAX_VALUE: i32 = 2147483647;
export declare function clz(value: i32): i32;
export declare function ctz(value: i32): i32;
export declare function popcnt(value: i32): i32;
export declare function rotl(value: i32, shift: i32): i32;
export declare function rotr(value: i32, shift: i32): i32;
export declare function reinterpret_f32(value: f32): i32;
export declare function load8_s(offset: usize, constantOffset?: usize): i32;
export declare function load8_u(offset: usize, constantOffset?: usize): i32;
export declare function load16_s(offset: usize, constantOffset?: usize): i32;
@ -117,6 +123,8 @@ export declare function i64(value: void): i64;
export namespace i64 {
export const MIN_VALUE: i64 = -9223372036854775808;
export const MAX_VALUE: i64 = 9223372036854775807;
export declare function clz(value: i64): i64;
export declare function ctz(value: i64): i64;
export declare function load8_s(offset: usize, constantOffset?: usize): i64;
export declare function load8_u(offset: usize, constantOffset?: usize): u64;
export declare function load16_s(offset: usize, constantOffset?: usize): i64;
@ -124,6 +132,10 @@ export namespace i64 {
export declare function load32_s(offset: usize, constantOffset?: usize): i64;
export declare function load32_u(offset: usize, constantOffset?: usize): u64;
export declare function load(offset: usize, constantOffset?: usize): i64;
export declare function popcnt(value: i64): i64;
export declare function rotl(value: i64, shift: i64): i64;
export declare function rotr(value: i64, shift: i64): i64;
export declare function reinterpret_f64(value: f64): i64;
export declare function store8(offset: usize, value: i64, constantOffset?: usize): void;
export declare function store16(offset: usize, value: i64, constantOffset?: usize): void;
export declare function store32(offset: usize, value: i64, constantOffset?: usize): void;
@ -186,8 +198,18 @@ export namespace f32 {
export const MIN_SAFE_INTEGER: f32 = -16777215;
export const MAX_SAFE_INTEGER: f32 = 16777215;
export const EPSILON = reinterpret<f32>(0x34000000); // 0x1p-23f
export declare function abs(value: f32): f32;
export declare function ceil(value: f32): f32;
export declare function copysign(x: f32, y: f32): f32;
export declare function floor(value: f32): f32;
export declare function load(offset: usize, constantOffset?: usize): f32;
export declare function max(left: f32, right: f32): f32;
export declare function min(left: f32, right: f32): f32;
export declare function nearest(value: f32): f32;
export declare function reinterpret_i32(value: i32): f32;
export declare function sqrt(value: f32): f32;
export declare function store(offset: usize, value: f32, constantOffset?: usize): void;
export declare function trunc(value: f32): f32;
}
export declare function f64(value: void): f64;
@ -198,8 +220,18 @@ export namespace f64 {
export const MIN_SAFE_INTEGER: f64 = -9007199254740991;
export const MAX_SAFE_INTEGER: f64 = 9007199254740991;
export const EPSILON = reinterpret<f64>(0x3CB0000000000000); // 0x1p-52
export declare function abs(value: f64): f64;
export declare function ceil(value: f64): f64;
export declare function copysign(x: f64, y: f64): f64;
export declare function floor(value: f64): f64;
export declare function load(offset: usize, constantOffset?: usize): f64;
export declare function max(left: f64, right: f64): f64;
export declare function min(left: f64, right: f64): f64;
export declare function nearest(value: f64): f64;
export declare function reinterpret_i64(value: i64): f64;
export declare function sqrt(value: f64): f64;
export declare function store(offset: usize, value: f64, constantOffset?: usize): void;
export declare function trunc(value: f64): f64;
}
export declare const HEAP_BASE: usize;