wasm64.s
8.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# RUN: llvm-mc -triple=wasm64-unknown-unknown -mattr=+atomics,+unimplemented-simd128,+nontrapping-fptoint,+exception-handling < %s | FileCheck %s
# RUN: llvm-mc -triple=wasm64-unknown-unknown -filetype=obj -mattr=+atomics,+unimplemented-simd128,+nontrapping-fptoint,+exception-handling -o - < %s | obj2yaml | FileCheck %s -check-prefix=BIN
# Most of our other tests are for wasm32, this one adds some wasm64 specific tests.
test:
.functype test (i64) -> ()
.local i64
### basic loads
i64.const 0 # get i64 from constant.
f32.load 0
drop
local.get 0 # get i64 from local.
f32.load 0
drop
i64.const .L.str # get i64 relocatable.
f32.load 0
drop
global.get myglob64 # get i64 from global
f32.load 0
drop
i64.const 0
f32.load .L.str # relocatable offset!
drop
### basic stores
f32.const 0.0
i64.const 0 # get i64 from constant.
f32.store 0
f32.const 0.0
local.get 0 # get i64 from local.
f32.store 0
f32.const 0.0
i64.const .L.str # get i64 relocatable.
f32.store 0
f32.const 0.0
global.get myglob64 # get i64 from global
f32.store 0
f32.const 0.0
i64.const 0
f32.store .L.str # relocatable offset!
### 64-bit SP
global.get __stack_pointer
drop
end_function
.section .rodata..L.str,"",@
.hidden .L.str
.type .L.str,@object
.L.str:
.asciz "Hello, World!!!"
.int64 .L.str # relocatable inside data.
.size .L.str, 24
.globaltype myglob64, i64
.globaltype __stack_pointer, i64
# CHECK: .functype test (i64) -> ()
# CHECK-NEXT: .local i64
# CHECK: i64.const 0
# CHECK-NEXT: f32.load 0
# CHECK-NEXT: drop
# CHECK: local.get 0
# CHECK-NEXT: f32.load 0
# CHECK-NEXT: drop
# CHECK: i64.const .L.str
# CHECK-NEXT: f32.load 0
# CHECK-NEXT: drop
# CHECK: global.get myglob64
# CHECK-NEXT: f32.load 0
# CHECK-NEXT: drop
# CHECK: i64.const 0
# CHECK-NEXT: f32.load .L.str
# CHECK-NEXT: drop
# CHECK: f32.const 0x0p0
# CHECK-NEXT: i64.const 0
# CHECK-NEXT: f32.store 0
# CHECK: f32.const 0x0p0
# CHECK-NEXT: local.get 0
# CHECK-NEXT: f32.store 0
# CHECK: f32.const 0x0p0
# CHECK-NEXT: i64.const .L.str
# CHECK-NEXT: f32.store 0
# CHECK: f32.const 0x0p0
# CHECK-NEXT: global.get myglob64
# CHECK-NEXT: f32.store 0
# CHECK: f32.const 0x0p0
# CHECK-NEXT: i64.const 0
# CHECK-NEXT: f32.store .L.str
# CHECK: end_function
# CHECK-NEXT: .Ltmp0:
# CHECK-NEXT: .size test, .Ltmp0-test
# CHECK: .section .rodata..L.str,"",@
# CHECK-NEXT: .hidden .L.str
# CHECK-NEXT: .L.str:
# CHECK-NEXT: .asciz "Hello, World!!!"
# CHECK-NEXT: .int64 .L.str
# CHECK-NEXT: .size .L.str, 24
# CHECK: .globaltype myglob64, i64
# BIN: --- !WASM
# BIN-NEXT: FileHeader:
# BIN-NEXT: Version: 0x00000001
# BIN-NEXT: Sections:
# BIN-NEXT: - Type: TYPE
# BIN-NEXT: Signatures:
# BIN-NEXT: - Index: 0
# BIN-NEXT: ParamTypes:
# BIN-NEXT: - I64
# BIN-NEXT: ReturnTypes: []
# BIN-NEXT: - Type: IMPORT
# BIN-NEXT: Imports:
# BIN-NEXT: - Module: env
# BIN-NEXT: Field: __linear_memory
# BIN-NEXT: Kind: MEMORY
# BIN-NEXT: Memory:
# BIN-NEXT: Flags: [ IS_64 ]
# BIN-NEXT: Initial: 0x00000001
# BIN-NEXT: - Module: env
# BIN-NEXT: Field: __indirect_function_table
# BIN-NEXT: Kind: TABLE
# BIN-NEXT: Table:
# BIN-NEXT: ElemType: FUNCREF
# BIN-NEXT: Limits:
# BIN-NEXT: Initial: 0x00000000
# BIN-NEXT: - Module: env
# BIN-NEXT: Field: myglob64
# BIN-NEXT: Kind: GLOBAL
# BIN-NEXT: GlobalType: I64
# BIN-NEXT: GlobalMutable: true
# BIN-NEXT: - Module: env
# BIN-NEXT: Field: __stack_pointer
# BIN-NEXT: Kind: GLOBAL
# BIN-NEXT: GlobalType: I64
# BIN-NEXT: GlobalMutable: true
# BIN-NEXT: - Type: FUNCTION
# BIN-NEXT: FunctionTypes: [ 0 ]
# BIN-NEXT: - Type: DATACOUNT
# BIN-NEXT: Count: 1
# BIN-NEXT: - Type: CODE
# BIN-NEXT: Relocations:
# BIN-NEXT: - Type: R_WASM_MEMORY_ADDR_SLEB64
# BIN-NEXT: Index: 1
# BIN-NEXT: Offset: 0x00000013
# BIN-NEXT: - Type: R_WASM_GLOBAL_INDEX_LEB
# BIN-NEXT: Index: 2
# BIN-NEXT: Offset: 0x00000022
# BIN-NEXT: - Type: R_WASM_MEMORY_ADDR_LEB64
# BIN-NEXT: Index: 1
# BIN-NEXT: Offset: 0x0000002F
# BIN-NEXT: - Type: R_WASM_MEMORY_ADDR_SLEB64
# BIN-NEXT: Index: 1
# BIN-NEXT: Offset: 0x00000054
# BIN-NEXT: - Type: R_WASM_GLOBAL_INDEX_LEB
# BIN-NEXT: Index: 2
# BIN-NEXT: Offset: 0x00000067
# BIN-NEXT: - Type: R_WASM_MEMORY_ADDR_LEB64
# BIN-NEXT: Index: 1
# BIN-NEXT: Offset: 0x00000078
# BIN-NEXT: - Type: R_WASM_GLOBAL_INDEX_LEB
# BIN-NEXT: Index: 3
# BIN-NEXT: Offset: 0x00000083
# BIN-NEXT: Functions:
# BIN-NEXT: - Index: 0
# BIN-NEXT: Locals:
# BIN-NEXT: - Type: I64
# BIN-NEXT: Count: 1
# BIN-NEXT: Body: 42002A02001A20002A02001A42808080808080808080002A02001A2380808080002A02001A42002A02808080808080808080001A4300000000420038020043000000002000380200430000000042808080808080808080003802004300000000238080808000380200430000000042003802808080808080808080002381808080001A0B
# BIN-NEXT: - Type: DATA
# BIN-NEXT: Relocations:
# BIN-NEXT: - Type: R_WASM_MEMORY_ADDR_I64
# BIN-NEXT: Index: 1
# BIN-NEXT: Offset: 0x00000016
# BIN-NEXT: Segments:
# BIN-NEXT: - SectionOffset: 6
# BIN-NEXT: InitFlags: 0
# BIN-NEXT: Offset:
# BIN-NEXT: Opcode: I32_CONST
# BIN-NEXT: Value: 0
# BIN-NEXT: Content: 48656C6C6F2C20576F726C64212121000000000000000000
# BIN-NEXT: - Type: CUSTOM
# BIN-NEXT: Name: linking
# BIN-NEXT: Version: 2
# BIN-NEXT: SymbolTable:
# BIN-NEXT: - Index: 0
# BIN-NEXT: Kind: FUNCTION
# BIN-NEXT: Name: test
# BIN-NEXT: Flags: [ BINDING_LOCAL ]
# BIN-NEXT: Function: 0
# BIN-NEXT: - Index: 1
# BIN-NEXT: Kind: DATA
# BIN-NEXT: Name: .L.str
# BIN-NEXT: Flags: [ BINDING_LOCAL, VISIBILITY_HIDDEN ]
# BIN-NEXT: Segment: 0
# BIN-NEXT: Size: 24
# BIN-NEXT: - Index: 2
# BIN-NEXT: Kind: GLOBAL
# BIN-NEXT: Name: myglob64
# BIN-NEXT: Flags: [ UNDEFINED ]
# BIN-NEXT: Global: 0
# BIN-NEXT: - Index: 3
# BIN-NEXT: Kind: GLOBAL
# BIN-NEXT: Name: __stack_pointer
# BIN-NEXT: Flags: [ UNDEFINED ]
# BIN-NEXT: Global: 1
# BIN-NEXT: SegmentInfo:
# BIN-NEXT: - Index: 0
# BIN-NEXT: Name: .rodata..L.str
# BIN-NEXT: Alignment: 0
# BIN-NEXT: Flags: [ ]
# BIN-NEXT: ...