summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lld/em_asm64.cpp8
-rw-r--r--test/lld/em_asm64.wat68
-rw-r--r--test/lld/em_asm64.wat.out99
3 files changed, 175 insertions, 0 deletions
diff --git a/test/lld/em_asm64.cpp b/test/lld/em_asm64.cpp
new file mode 100644
index 000000000..ed89783f8
--- /dev/null
+++ b/test/lld/em_asm64.cpp
@@ -0,0 +1,8 @@
+#include <emscripten/em_asm.h>
+
+int main() {
+ EM_ASM({ Module.print("Hello world"); });
+ int x = EM_ASM_INT({ return $0 + $1; }, 13, 27);
+ EM_ASM_({ Module.print("Got " + $0); }, x);
+ return 0;
+}
diff --git a/test/lld/em_asm64.wat b/test/lld/em_asm64.wat
new file mode 100644
index 000000000..2c41c31b7
--- /dev/null
+++ b/test/lld/em_asm64.wat
@@ -0,0 +1,68 @@
+(module
+ (type $none_=>_none (func))
+ (type $none_=>_i32 (func (result i32)))
+ (type $i32_i64_=>_i32 (func (param i32 i64) (result i32)))
+ (type $i64_i64_i64_=>_i32 (func (param i64 i64 i64) (result i32)))
+ (import "env" "emscripten_asm_const_int" (func $emscripten_asm_const_int (param i64 i64 i64) (result i32)))
+ (memory $0 i64 2)
+ (data (i32.const 568) "{ Module.print(\"Hello world\"); }\00\00{ return $0 + $1; }\00ii\00{ Module.print(\"Got \" + $0); }\00i\00")
+ (table $0 1 1 funcref)
+ (global $__stack_pointer (mut i64) (i64.const 66208))
+ (export "memory" (memory $0))
+ (export "__wasm_call_ctors" (func $__wasm_call_ctors))
+ (export "main" (func $main))
+ (func $__wasm_call_ctors
+ )
+ (func $__original_main (result i32)
+ (local $0 i64)
+ (global.set $__stack_pointer
+ (local.tee $0
+ (i64.sub
+ (global.get $__stack_pointer)
+ (i64.const 32)
+ )
+ )
+ )
+ (drop
+ (call $emscripten_asm_const_int
+ (i64.const 568)
+ (i64.const 601)
+ (i64.const 0)
+ )
+ )
+ (i64.store offset=16
+ (local.get $0)
+ (i64.const 115964117005)
+ )
+ (i32.store
+ (local.get $0)
+ (call $emscripten_asm_const_int
+ (i64.const 602)
+ (i64.const 622)
+ (i64.add
+ (local.get $0)
+ (i64.const 16)
+ )
+ )
+ )
+ (drop
+ (call $emscripten_asm_const_int
+ (i64.const 625)
+ (i64.const 656)
+ (local.get $0)
+ )
+ )
+ (global.set $__stack_pointer
+ (i64.add
+ (local.get $0)
+ (i64.const 32)
+ )
+ )
+ (i32.const 0)
+ )
+ (func $main (param $0 i32) (param $1 i64) (result i32)
+ (call $__original_main)
+ )
+ ;; custom section "producers", size 112
+)
+
diff --git a/test/lld/em_asm64.wat.out b/test/lld/em_asm64.wat.out
new file mode 100644
index 000000000..727dc7267
--- /dev/null
+++ b/test/lld/em_asm64.wat.out
@@ -0,0 +1,99 @@
+(module
+ (type $none_=>_none (func))
+ (type $none_=>_i32 (func (result i32)))
+ (type $i32_i64_=>_i32 (func (param i32 i64) (result i32)))
+ (type $i64_i64_i64_=>_i32 (func (param i64 i64 i64) (result i32)))
+ (import "env" "emscripten_asm_const_int" (func $emscripten_asm_const_int (param i64 i64 i64) (result i32)))
+ (memory $0 i64 2)
+ (data (i32.const 568) "{ Module.print(\"Hello world\"); }\00\00{ return $0 + $1; }\00ii\00{ Module.print(\"Got \" + $0); }\00i\00")
+ (table $0 1 1 funcref)
+ (global $__stack_pointer (mut i64) (i64.const 66208))
+ (export "memory" (memory $0))
+ (export "__wasm_call_ctors" (func $__wasm_call_ctors))
+ (export "main" (func $main))
+ (func $__wasm_call_ctors
+ (nop)
+ )
+ (func $__original_main (result i32)
+ (local $0 i64)
+ (global.set $__stack_pointer
+ (local.tee $0
+ (i64.sub
+ (global.get $__stack_pointer)
+ (i64.const 32)
+ )
+ )
+ )
+ (drop
+ (call $emscripten_asm_const_int
+ (i64.const 568)
+ (i64.const 601)
+ (i64.const 0)
+ )
+ )
+ (i64.store offset=16
+ (local.get $0)
+ (i64.const 115964117005)
+ )
+ (i32.store
+ (local.get $0)
+ (call $emscripten_asm_const_int
+ (i64.const 602)
+ (i64.const 622)
+ (i64.add
+ (local.get $0)
+ (i64.const 16)
+ )
+ )
+ )
+ (drop
+ (call $emscripten_asm_const_int
+ (i64.const 625)
+ (i64.const 656)
+ (local.get $0)
+ )
+ )
+ (global.set $__stack_pointer
+ (i64.add
+ (local.get $0)
+ (i64.const 32)
+ )
+ )
+ (i32.const 0)
+ )
+ (func $main (param $0 i32) (param $1 i64) (result i32)
+ (call $__original_main)
+ )
+)
+(;
+--BEGIN METADATA --
+{
+ "asmConsts": {
+ "568": ["{ Module.print(\"Hello world\"); }", ["ijj"], [""]],
+ "602": ["{ return $0 + $1; }", ["ijj"], [""]],
+ "625": ["{ Module.print(\"Got \" + $0); }", ["ijj"], [""]]
+ },
+ "tableSize": 1,
+ "initializers": [
+ "__wasm_call_ctors"
+ ],
+ "declares": [
+ "emscripten_asm_const_int"
+ ],
+ "externs": [
+ ],
+ "exports": [
+ "__wasm_call_ctors",
+ "main"
+ ],
+ "namedGlobals": {
+ },
+ "invokeFuncs": [
+ ],
+ "mainReadsParams": 0,
+ "features": [
+ "--enable-memory64"
+ ]
+}
+-- END METADATA --
+;)