2021-04-29 01:42:08 +08:00
|
|
|
# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
|
2020-04-30 04:26:27 +08:00
|
|
|
# RUN: wasm-ld %t.o -o %t.wasm
|
|
|
|
# RUN: obj2yaml %t.wasm | FileCheck %s
|
|
|
|
|
|
|
|
.globl _start
|
|
|
|
.globl read_global
|
|
|
|
.globl write_global
|
|
|
|
|
|
|
|
.globaltype foo_global, i32
|
|
|
|
.globaltype bar_global, f32
|
2020-09-11 22:20:40 +08:00
|
|
|
.globaltype immutable_global, i32, immutable
|
2020-04-30 04:26:27 +08:00
|
|
|
|
|
|
|
read_global:
|
|
|
|
.functype read_global () -> (i32)
|
2020-09-11 22:20:40 +08:00
|
|
|
global.get immutable_global
|
2020-04-30 04:26:27 +08:00
|
|
|
end_function
|
|
|
|
|
|
|
|
write_global:
|
|
|
|
.functype write_global (i32) -> ()
|
|
|
|
local.get 0
|
|
|
|
global.set foo_global
|
|
|
|
f32.const 1.0
|
|
|
|
global.set bar_global
|
|
|
|
end_function
|
|
|
|
|
|
|
|
_start:
|
|
|
|
.functype _start () -> ()
|
|
|
|
i32.const 1
|
|
|
|
call write_global
|
2020-09-11 22:20:40 +08:00
|
|
|
call read_global
|
|
|
|
drop
|
2020-04-30 04:26:27 +08:00
|
|
|
end_function
|
|
|
|
|
|
|
|
foo_global:
|
|
|
|
bar_global:
|
2020-09-11 22:20:40 +08:00
|
|
|
immutable_global:
|
2020-04-30 04:26:27 +08:00
|
|
|
|
|
|
|
# CHECK: - Type: GLOBAL
|
|
|
|
# CHECK-NEXT: Globals:
|
|
|
|
# CHECK-NEXT: - Index: 0
|
|
|
|
# CHECK-NEXT: Type: I32
|
|
|
|
# CHECK-NEXT: Mutable: true
|
|
|
|
# CHECK-NEXT: InitExpr:
|
|
|
|
# CHECK-NEXT: Opcode: I32_CONST
|
|
|
|
# CHECK-NEXT: Value: 66560
|
2020-09-11 22:20:40 +08:00
|
|
|
# CHECK-NEXT: - Index: 1
|
|
|
|
# CHECK-NEXT: Type: I32
|
|
|
|
# CHECK-NEXT: Mutable: false
|
|
|
|
# CHECK-NEXT: InitExpr:
|
|
|
|
# CHECK-NEXT: Opcode: I32_CONST
|
|
|
|
# CHECK-NEXT: Value: 0
|
|
|
|
# CHECK-NEXT: - Index: 2
|
2020-04-30 04:26:27 +08:00
|
|
|
# CHECK-NEXT: Type: I32
|
|
|
|
# CHECK-NEXT: Mutable: true
|
|
|
|
# CHECK-NEXT: InitExpr:
|
|
|
|
# CHECK-NEXT: Opcode: I32_CONST
|
|
|
|
# CHECK-NEXT: Value: 0
|
2020-09-11 22:20:40 +08:00
|
|
|
# CHECK-NEXT: - Index: 3
|
2020-04-30 04:26:27 +08:00
|
|
|
# CHECK-NEXT: Type: F32
|
|
|
|
# CHECK-NEXT: Mutable: true
|
|
|
|
# CHECK-NEXT: InitExpr:
|
|
|
|
# CHECK-NEXT: Opcode: F32_CONST
|
|
|
|
# CHECK-NEXT: Value: 0
|