Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / test / MC / WebAssembly / globals.s
blobb7e25cb9f0519178ecad4938ea095fabc488fe44
1 # RUN: llvm-mc -triple=wasm32-unknown-unknown < %s | FileCheck %s
2 # RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj < %s | obj2yaml | FileCheck -check-prefix=BIN %s
4 # Tests creating an accessing actual wasm globals
6 .globl read_global
7 .globl write_global
8 .globaltype foo_global, i32
9 .globaltype global2, i64, immutable
10 .globaltype global3, f32
11 .globaltype global4, f64
13 read_global:
14 .functype read_global () -> (i32)
15 global.get foo_global
16 end_function
18 write_global:
19 .functype write_global (i32, i64, f32, f64) -> ()
20 local.get 0
21 global.set foo_global
22 local.get 1
23 global.set global2
24 local.get 2
25 global.set global3
26 local.get 3
27 global.set global4
28 end_function
30 foo_global:
31 global2:
32 global3:
33 global4:
35 # CHECK: .globl read_global
36 # CNEXT: .globl write_global
37 # CHECK: .globaltype foo_global, i32
38 # CHECK: foo_global:
40 # BIN: - Type: GLOBAL
41 # BIN-NEXT: Globals:
42 # BIN-NEXT: - Index: 0
43 # BIN-NEXT: Type: I32
44 # BIN-NEXT: Mutable: true
45 # BIN-NEXT: InitExpr:
46 # BIN-NEXT: Opcode: I32_CONST
47 # BIN-NEXT: Value: 0
48 # BIN-NEXT: - Index: 1
49 # BIN-NEXT: Type: I64
50 # BIN-NEXT: Mutable: false
51 # BIN-NEXT: InitExpr:
52 # BIN-NEXT: Opcode: I64_CONST
53 # BIN-NEXT: Value: 0
55 # BIN: - Type: CUSTOM
56 # BIN-NEXT: Name: linking
57 # BIN-NEXT: Version: 2
58 # BIN-NEXT: SymbolTable:
59 # BIN-NEXT: - Index: 0
60 # BIN-NEXT: Kind: FUNCTION
61 # BIN-NEXT: Name: read_global
62 # BIN-NEXT: Flags: [ ]
63 # BIN-NEXT: Function: 0
64 # BIN-NEXT: - Index: 1
65 # BIN-NEXT: Kind: FUNCTION
66 # BIN-NEXT: Name: write_global
67 # BIN-NEXT: Flags: [ ]
68 # BIN-NEXT: Function: 1
69 # BIN-NEXT: - Index: 2
70 # BIN-NEXT: Kind: GLOBAL
71 # BIN-NEXT: Name: foo_global
72 # BIN-NEXT: Flags: [ BINDING_LOCAL ]
73 # BIN-NEXT: Global: 0
74 # BIN-NEXT: - Index: 3
75 # BIN-NEXT: Kind: GLOBAL
76 # BIN-NEXT: Name: global2
77 # BIN-NEXT: Flags: [ BINDING_LOCAL ]
78 # BIN-NEXT: Global: 1
79 # BIN-NEXT: - Index: 4
80 # BIN-NEXT: Kind: GLOBAL
81 # BIN-NEXT: Name: global3
82 # BIN-NEXT: Flags: [ BINDING_LOCAL ]
83 # BIN-NEXT: Global: 2
84 # BIN-NEXT: - Index: 5
85 # BIN-NEXT: Kind: GLOBAL
86 # BIN-NEXT: Name: global4
87 # BIN-NEXT: Flags: [ BINDING_LOCAL ]
88 # BIN-NEXT: Global: 3