inline assembly :3

This commit is contained in:
nora 2023-12-15 22:31:13 +01:00
parent 3ab116d7f0
commit ba5d41674c
17 changed files with 448 additions and 45 deletions

10
ui-tests/asm/drop.nil Normal file
View file

@ -0,0 +1,10 @@
//@check-pass
function dropping(a: I32) =
___asm(
__locals(),
"local.get 0",
"drop",
);
function main() = ;

View file

@ -0,0 +1,7 @@
function a(a: I32) =
___asm(
__locals(),
0,
);
function main() = ;

View file

@ -0,0 +1,4 @@
error: inline assembly instruction must be string literal with instruction
--> $DIR/instr_not_string.nil:4
4 | 0,
^

View file

@ -0,0 +1,9 @@
//@check-pass
function dropping(a: I32) =
___asm(
__locals(),
"meow meow",
);
function main() = ;

View file

@ -0,0 +1,4 @@
error: unknown instruction: meow
--> $DIR/invalid_instr.nil:6
6 | "meow meow",
^^^^^^^^^^^

View file

@ -0,0 +1,9 @@
//@check-pass
function dropping(a: I32) =
___asm(
"local.get 0",
"drop",
);
function main() = ;

View file

@ -0,0 +1,4 @@
error: inline assembly must have __locals() as first argument
--> $DIR/missing_locals.nil:4
4 | ___asm(
^

View file

@ -0,0 +1,6 @@
function dropping(a: I32) = (
1;
___asm(__locals(), "drop");
);
function main() = ;

View file

@ -0,0 +1,16 @@
error: `___asm` cannot be used as a value
--> $DIR/not_toplevel.nil:3
3 | ___asm(__locals(), "drop");
^^^^^^
error: `__locals` cannot be used as a value
--> $DIR/not_toplevel.nil:3
3 | ___asm(__locals(), "drop");
^^^^^^^^
error: expression of type <ERROR> is not callable
--> $DIR/not_toplevel.nil:3
3 | ___asm(__locals(), "drop");
^^^^^^^^
error: expression of type <ERROR> is not callable
--> $DIR/not_toplevel.nil:3
3 | ___asm(__locals(), "drop");
^^^^^^

View file

@ -0,0 +1,17 @@
//@check-pass
function a(a: I32) =
___asm(
__locals(),
"local.get 0 0",
"drop",
);
function b(a: I32) =
___asm(
__locals(),
"local.get",
"drop",
);
function main() = ;

View file

@ -0,0 +1,8 @@
error: mismatched immediate lengths, expected 1, got 2
--> $DIR/wrong_imm.nil:6
6 | "local.get 0 0",
^^^^^^^^^^^^^^^
error: mismatched immediate lengths, expected 1, got 0
--> $DIR/wrong_imm.nil:13
13 | "local.get",
^^^^^^^^^^^

View file

@ -0,0 +1,17 @@
/home/nils/projects/riverdelta/target/ast.js:110
throw new Error(`substitution out of range, param index ${ty.idx} of param ${ty.name} out of range for length ${genericArgs.length}`);
^
Error: substitution out of range, param index 0 of param T out of range for length 0
at substituteTy (/home/nils/projects/riverdelta/target/ast.js:110:23)
at subst (/home/nils/projects/riverdelta/target/ast.js:106:27)
at Array.map (<anonymous>)
at substituteTy (/home/nils/projects/riverdelta/target/ast.js:125:45)
at typeOfItem (/home/nils/projects/riverdelta/target/typeck/item.js:193:33)
at Object.itemInner (/home/nils/projects/riverdelta/target/typeck/index.js:63:54)
at Object.item (/home/nils/projects/riverdelta/target/ast.js:146:34)
at /home/nils/projects/riverdelta/target/ast.js:164:55
at Array.map (<anonymous>)
at foldAst (/home/nils/projects/riverdelta/target/ast.js:164:34)
Node.js v18.18.2