Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / test / MC / WebAssembly / wasm64.s
blob0c939b47db4f291f298cd42234366a032986caa8
1 # RUN: llvm-mc -triple=wasm64-unknown-unknown -mattr=+atomics,+simd128,+nontrapping-fptoint,+exception-handling < %s | FileCheck %s
2 # RUN: llvm-mc -triple=wasm64-unknown-unknown -filetype=obj -mattr=+atomics,+simd128,+nontrapping-fptoint,+exception-handling -o - < %s | obj2yaml | FileCheck %s -check-prefix=BIN
4 # Most of our other tests are for wasm32, this one adds some wasm64 specific tests.
6 .globaltype myglob64, i64
7 .globaltype __stack_pointer, i64
9 test:
10 .functype test (i64) -> ()
11 .local i64
13 ### basic loads
15 i64.const 0 # get i64 from constant.
16 f32.load 0
17 drop
19 local.get 0 # get i64 from local.
20 f32.load 0
21 drop
23 i64.const .L.str # get i64 relocatable.
24 f32.load 0
25 drop
27 global.get myglob64 # get i64 from global
28 f32.load 0
29 drop
31 i64.const 0
32 f32.load .L.str # relocatable offset!
33 drop
35 ### basic stores
37 i64.const 0 # get i64 from constant.
38 f32.const 0.0
39 f32.store 0
41 local.get 0 # get i64 from local.
42 f32.const 0.0
43 f32.store 0
45 i64.const .L.str # get i64 relocatable.
46 f32.const 0.0
47 f32.store 0
49 global.get myglob64 # get i64 from global
50 f32.const 0.0
51 f32.store 0
53 i64.const 0
54 f32.const 0.0
55 f32.store .L.str # relocatable offset!
57 ### 64-bit SP
59 global.get __stack_pointer
60 drop
62 end_function
64 .section .rodata..L.str,"",@
65 .hidden .L.str
66 .type .L.str,@object
67 .L.str:
68 .asciz "Hello, World!!!"
69 .int64 .L.str # relocatable inside data.
70 .size .L.str, 24
73 # CHECK: .globaltype myglob64, i64
75 # CHECK: .functype test (i64) -> ()
76 # CHECK-NEXT: .local i64
79 # CHECK: i64.const 0
80 # CHECK-NEXT: f32.load 0
81 # CHECK-NEXT: drop
83 # CHECK: local.get 0
84 # CHECK-NEXT: f32.load 0
85 # CHECK-NEXT: drop
87 # CHECK: i64.const .L.str
88 # CHECK-NEXT: f32.load 0
89 # CHECK-NEXT: drop
91 # CHECK: global.get myglob64
92 # CHECK-NEXT: f32.load 0
93 # CHECK-NEXT: drop
95 # CHECK: i64.const 0
96 # CHECK-NEXT: f32.load .L.str
97 # CHECK-NEXT: drop
100 # CHECK: i64.const 0
101 # CHECK-NEXT: f32.const 0x0p0
102 # CHECK-NEXT: f32.store 0
104 # CHECK: local.get 0
105 # CHECK-NEXT: f32.const 0x0p0
106 # CHECK-NEXT: f32.store 0
108 # CHECK: i64.const .L.str
109 # CHECK-NEXT: f32.const 0x0p0
110 # CHECK-NEXT: f32.store 0
112 # CHECK: global.get myglob64
113 # CHECK-NEXT: f32.const 0x0p0
114 # CHECK-NEXT: f32.store 0
116 # CHECK: i64.const 0
117 # CHECK-NEXT: f32.const 0x0p0
118 # CHECK-NEXT: f32.store .L.str
121 # CHECK: end_function
123 # CHECK: .section .rodata..L.str,"",@
124 # CHECK-NEXT: .hidden .L.str
125 # CHECK-NEXT: .L.str:
126 # CHECK-NEXT: .asciz "Hello, World!!!"
127 # CHECK-NEXT: .int64 .L.str
128 # CHECK-NEXT: .size .L.str, 24
132 # BIN: --- !WASM
133 # BIN-NEXT: FileHeader:
134 # BIN-NEXT: Version: 0x1
135 # BIN-NEXT: Sections:
136 # BIN-NEXT: - Type: TYPE
137 # BIN-NEXT: Signatures:
138 # BIN-NEXT: - Index: 0
139 # BIN-NEXT: ParamTypes:
140 # BIN-NEXT: - I64
141 # BIN-NEXT: ReturnTypes: []
142 # BIN-NEXT: - Type: IMPORT
143 # BIN-NEXT: Imports:
144 # BIN-NEXT: - Module: env
145 # BIN-NEXT: Field: __linear_memory
146 # BIN-NEXT: Kind: MEMORY
147 # BIN-NEXT: Memory:
148 # BIN-NEXT: Flags: [ IS_64 ]
149 # BIN-NEXT: Minimum: 0x1
150 # BIN-NEXT: - Module: env
151 # BIN-NEXT: Field: myglob64
152 # BIN-NEXT: Kind: GLOBAL
153 # BIN-NEXT: GlobalType: I64
154 # BIN-NEXT: GlobalMutable: true
155 # BIN-NEXT: - Module: env
156 # BIN-NEXT: Field: __stack_pointer
157 # BIN-NEXT: Kind: GLOBAL
158 # BIN-NEXT: GlobalType: I64
159 # BIN-NEXT: GlobalMutable: true
160 # BIN-NEXT: - Type: FUNCTION
161 # BIN-NEXT: FunctionTypes: [ 0 ]
162 # BIN-NEXT: - Type: DATACOUNT
163 # BIN-NEXT: Count: 1
164 # BIN-NEXT: - Type: CODE
165 # BIN-NEXT: Relocations:
166 # BIN-NEXT: - Type: R_WASM_MEMORY_ADDR_SLEB64
167 # BIN-NEXT: Index: 1
168 # BIN-NEXT: Offset: 0x13
169 # BIN-NEXT: - Type: R_WASM_GLOBAL_INDEX_LEB
170 # BIN-NEXT: Index: 2
171 # BIN-NEXT: Offset: 0x22
172 # BIN-NEXT: - Type: R_WASM_MEMORY_ADDR_LEB64
173 # BIN-NEXT: Index: 1
174 # BIN-NEXT: Offset: 0x2F
175 # BIN-NEXT: - Type: R_WASM_MEMORY_ADDR_SLEB64
176 # BIN-NEXT: Index: 1
177 # BIN-NEXT: Offset: 0x4F
178 # BIN-NEXT: - Type: R_WASM_GLOBAL_INDEX_LEB
179 # BIN-NEXT: Index: 2
180 # BIN-NEXT: Offset: 0x62
181 # BIN-NEXT: - Type: R_WASM_MEMORY_ADDR_LEB64
182 # BIN-NEXT: Index: 1
183 # BIN-NEXT: Offset: 0x78
184 # BIN-NEXT: - Type: R_WASM_GLOBAL_INDEX_LEB
185 # BIN-NEXT: Index: 3
186 # BIN-NEXT: Offset: 0x83
187 # BIN-NEXT: Functions:
188 # BIN-NEXT: - Index: 0
189 # BIN-NEXT: Locals:
190 # BIN-NEXT: - Type: I64
191 # BIN-NEXT: Count: 1
192 # BIN-NEXT: Body: 42002A02001A20002A02001A42808080808080808080002A02001A2380808080002A02001A42002A02808080808080808080001A4200430000000038020020004300000000380200428080808080808080800043000000003802002380808080004300000000380200420043000000003802808080808080808080002381808080001A0B
193 # BIN-NEXT: - Type: DATA
194 # BIN-NEXT: Relocations:
195 # BIN-NEXT: - Type: R_WASM_MEMORY_ADDR_I64
196 # BIN-NEXT: Index: 1
197 # BIN-NEXT: Offset: 0x16
198 # BIN-NEXT: Segments:
199 # BIN-NEXT: - SectionOffset: 6
200 # BIN-NEXT: InitFlags: 0
201 # BIN-NEXT: Offset:
202 # BIN-NEXT: Opcode: I64_CONST
203 # BIN-NEXT: Value: 0
204 # BIN-NEXT: Content: 48656C6C6F2C20576F726C64212121000000000000000000
205 # BIN-NEXT: - Type: CUSTOM
206 # BIN-NEXT: Name: linking
207 # BIN-NEXT: Version: 2
208 # BIN-NEXT: SymbolTable:
209 # BIN-NEXT: - Index: 0
210 # BIN-NEXT: Kind: FUNCTION
211 # BIN-NEXT: Name: test
212 # BIN-NEXT: Flags: [ BINDING_LOCAL ]
213 # BIN-NEXT: Function: 0
214 # BIN-NEXT: - Index: 1
215 # BIN-NEXT: Kind: DATA
216 # BIN-NEXT: Name: .L.str
217 # BIN-NEXT: Flags: [ BINDING_LOCAL, VISIBILITY_HIDDEN ]
218 # BIN-NEXT: Segment: 0
219 # BIN-NEXT: Size: 24
220 # BIN-NEXT: - Index: 2
221 # BIN-NEXT: Kind: GLOBAL
222 # BIN-NEXT: Name: myglob64
223 # BIN-NEXT: Flags: [ UNDEFINED ]
224 # BIN-NEXT: Global: 0
225 # BIN-NEXT: - Index: 3
226 # BIN-NEXT: Kind: GLOBAL
227 # BIN-NEXT: Name: __stack_pointer
228 # BIN-NEXT: Flags: [ UNDEFINED ]
229 # BIN-NEXT: Global: 1
230 # BIN-NEXT: SegmentInfo:
231 # BIN-NEXT: - Index: 0
232 # BIN-NEXT: Name: .rodata..L.str
233 # BIN-NEXT: Alignment: 0
234 # BIN-NEXT: Flags: [ ]
235 # BIN-NEXT: ...