llvm-project
44 строки · 1.2 Кб
1# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -o %t.o %s
2# RUN: wasm-ld %t.o -o %t.wasm
3# RUN: obj2yaml %t.wasm | FileCheck %s
4
5# Tests use of externref type, including storing it in a global
6
7.globaltype my_global, externref
8
9.globl read_externref
10read_externref:
11.functype read_externref () -> (externref)
12global.get my_global
13end_function
14
15.globl write_externref
16write_externref:
17.functype write_externref (externref) -> ()
18local.get 0
19global.set my_global
20end_function
21
22my_global:
23
24.globl _start
25_start:
26.functype _start () -> ()
27call read_externref
28call write_externref
29end_function
30
31# CHECK: - Type: GLOBAL
32# CHECK-NEXT: Globals:
33# CHECK-NEXT: - Index: 0
34# CHECK-NEXT: Type: I32
35# CHECK-NEXT: Mutable: true
36# CHECK-NEXT: InitExpr:
37# CHECK-NEXT: Opcode: I32_CONST
38# CHECK-NEXT: Value: 66560
39# CHECK-NEXT: - Index: 1
40# CHECK-NEXT: Type: EXTERNREF
41# CHECK-NEXT: Mutable: true
42# CHECK-NEXT: InitExpr:
43# CHECK-NEXT: Opcode: REF_NULL
44# CHECK-NEXT: Type: EXTERNREF
45