test(asm): global asm runs under the JIT (sx run), not just AOT
Adds examples/1653-platform-asm-global-jit.sx — a module-scope asm { … }
block executed via `sx run` (no `aot`). sx run compiles the module to an
in-memory object (the integrated assembler assembles the `module asm`
into it), then ORC relocates and runs it, so a module-asm symbol IS
resolvable at JIT main execution — the long-assumed "AOT only" limit was
stale. Sibling of 1648 (same feature via AOT). Locks current behavior
(exit 42); no compiler change.
This commit is contained in:
22
examples/1653-platform-asm-global-jit.sx
Normal file
22
examples/1653-platform-asm-global-jit.sx
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
// ASM stream — global (module-scope) `asm { … }` executed via the JIT (`sx run`),
|
||||||
|
// NOT AOT. `sx run` compiles the whole module to an in-memory object (the
|
||||||
|
// integrated assembler assembles the `module asm` block into it), then ORC
|
||||||
|
// relocates and runs it — so a module-asm symbol IS resolvable at JIT main
|
||||||
|
// execution, just like a normal symbol. The only path that can't see it is a
|
||||||
|
// COMPILE-TIME `#run` call (the interpreter resolves externs via host dlsym; the
|
||||||
|
// symbol isn't linked yet — see 1654). Sibling of 1648 (which exercises the same
|
||||||
|
// feature via AOT). aarch64-macos-pinned; ir-only elsewhere.
|
||||||
|
asm {
|
||||||
|
#string ASM
|
||||||
|
.global _my_sub
|
||||||
|
_my_sub:
|
||||||
|
sub x0, x0, x1
|
||||||
|
ret
|
||||||
|
ASM,
|
||||||
|
};
|
||||||
|
|
||||||
|
my_sub :: (a: i64, b: i64) -> i64 extern;
|
||||||
|
|
||||||
|
main :: () -> i64 {
|
||||||
|
return my_sub(44, 2); // 42, computed by the global-asm routine, under JIT
|
||||||
|
}
|
||||||
1
examples/expected/1653-platform-asm-global-jit.build
Normal file
1
examples/expected/1653-platform-asm-global-jit.build
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{ "target": "macos" }
|
||||||
1
examples/expected/1653-platform-asm-global-jit.exit
Normal file
1
examples/expected/1653-platform-asm-global-jit.exit
Normal file
@@ -0,0 +1 @@
|
|||||||
|
42
|
||||||
16
examples/expected/1653-platform-asm-global-jit.ir
Normal file
16
examples/expected/1653-platform-asm-global-jit.ir
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
module asm ".global _my_sub"
|
||||||
|
module asm "_my_sub:"
|
||||||
|
module asm " sub x0, x0, x1"
|
||||||
|
module asm " ret"
|
||||||
|
|
||||||
|
; Function Attrs: nounwind
|
||||||
|
declare i64 @my_sub(i64, i64) #0
|
||||||
|
|
||||||
|
; Function Attrs: nounwind
|
||||||
|
define i32 @main() #0 {
|
||||||
|
entry:
|
||||||
|
%call = call i64 @my_sub(i64 44, i64 2)
|
||||||
|
%ca.tr = trunc i64 %call to i32
|
||||||
|
ret i32 %ca.tr
|
||||||
|
}
|
||||||
1
examples/expected/1653-platform-asm-global-jit.stderr
Normal file
1
examples/expected/1653-platform-asm-global-jit.stderr
Normal file
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
1
examples/expected/1653-platform-asm-global-jit.stdout
Normal file
1
examples/expected/1653-platform-asm-global-jit.stdout
Normal file
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
Reference in New Issue
Block a user