FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: Add trueish conversion for v128 types by MaxGraey · Pull Request #2135 · AssemblyScript/assemblyscript · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ts  (3) .wat  (2) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
7 changes: 7 additions & 0 deletions src/compiler.ts
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 characters
Original file line number Diff line number Diff line change
Expand Up @@ -3771,6 +3771,10 @@ export class Compiler extends DiagnosticEmitter {
}
}

// v128 to bool
} else if (fromType == Type.v128 && toType.isBooleanValue) {
expr = this.makeIsTrueish(expr, Type.v128, reportNode);

// int to int
} else {
// i64 to ...
Expand Down Expand Up @@ -10299,6 +10303,9 @@ export class Compiler extends DiagnosticEmitter {
module.i64(0xFFFFFFFE, 0xFFDFFFFF) // (0x7FF0000000000000 - 1) << 1
);
}
case TypeKind.V128: {
return module.unary(UnaryOp.AnyTrueV128, expr);
}
case TypeKind.FUNCREF:
case TypeKind.EXTERNREF:
case TypeKind.ANYREF:
Expand Down
3 changes: 2 additions & 1 deletion src/flow.ts
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 characters
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ export class Flow {
let key = _keys[i];
let leftFlags = changetype<FieldFlags>(leftFieldFlags.get(key));
if (
(leftFlags & FieldFlags.INITIALIZED) != 0 && rightFieldFlags.has(key) &&
(leftFlags & FieldFlags.INITIALIZED) != 0 && rightFieldFlags.has(key) &&
(changetype<FieldFlags>(rightFieldFlags.get(key)) & FieldFlags.INITIALIZED)
) {
newFieldFlags.set(key, FieldFlags.INITIALIZED);
Expand Down Expand Up @@ -1396,6 +1396,7 @@ export class Flow {
case <u32>TypeRef.I64: { value = getConstValueI64Low(expr); break; } // discards upper bits
case <u32>TypeRef.F32: { value = i32(getConstValueF32(expr)); break; }
case <u32>TypeRef.F64: { value = i32(getConstValueF64(expr)); break; }
case <u32>TypeRef.V128: return false;
default: assert(false);
}
switch (type.kind) {
Expand Down
14 changes: 7 additions & 7 deletions tests/compiler/features/simd.optimized.wat
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 characters
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@
if
i32.const 0
i32.const 1184
i32.const 59
i32.const 67
i32.const 5
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -1044,7 +1044,7 @@
if
i32.const 0
i32.const 1184
i32.const 69
i32.const 77
i32.const 5
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -1073,7 +1073,7 @@
if
i32.const 0
i32.const 1184
i32.const 79
i32.const 87
i32.const 5
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -1102,7 +1102,7 @@
if
i32.const 0
i32.const 1184
i32.const 89
i32.const 97
i32.const 5
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -1131,7 +1131,7 @@
if
i32.const 0
i32.const 1184
i32.const 99
i32.const 107
i32.const 5
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -1160,7 +1160,7 @@
if
i32.const 0
i32.const 1184
i32.const 109
i32.const 117
i32.const 5
call $~lib/builtins/abort
unreachable
Expand All @@ -1169,7 +1169,7 @@
call $~lib/rt/tlsf/__free
i32.const 0
i32.const 1184
i32.const 255
i32.const 263
i32.const 3
call $~lib/builtins/abort
unreachable
Expand Down
8 changes: 8 additions & 0 deletions tests/compiler/features/simd.ts
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 characters
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
// hint: asc tests/compiler/simd --enable simd

function test_v128(): void {
// check trueish
// @ts-ignore
assert(<bool>v128(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) == true);
// @ts-ignore
assert(<bool>v128(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1) == true);
// @ts-ignore
assert(<bool>v128(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) == false);

// equality and inequality
assert(
v128(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
Expand Down
Loading

Back | FazBrowse Home | New Git URL