LLVM 23.0.0git
WebAssemblyMCTargetDesc.h
Go to the documentation of this file.
1//==- WebAssemblyMCTargetDesc.h - WebAssembly Target Descriptions -*- C++ -*-=//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file provides WebAssembly-specific target descriptions.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_MCTARGETDESC_WEBASSEMBLYMCTARGETDESC_H
15#define LLVM_LIB_TARGET_WEBASSEMBLY_MCTARGETDESC_WEBASSEMBLYMCTARGETDESC_H
16
18#include "llvm/MC/MCContext.h"
19#include "llvm/MC/MCInstrDesc.h"
22#include <memory>
23
24namespace llvm {
25
26class MCAsmBackend;
27class MCCodeEmitter;
28class MCInstrInfo;
30class Triple;
31
33 MCContext &Ctx);
34
36
37std::unique_ptr<MCObjectTargetWriter>
38createWebAssemblyWasmObjectWriter(bool Is64Bit, bool IsEmscripten);
39
40namespace WebAssembly {
41
43 /// Basic block label in a branch construct.
45 /// Local index.
47 /// Global index.
49 /// 32-bit integer immediates.
51 /// 64-bit integer immediates.
53 /// 32-bit floating-point immediates.
55 /// 64-bit floating-point immediates.
57 /// 8-bit vector lane immediate
59 /// 16-bit vector lane immediate
61 /// 32-bit vector lane immediate
63 /// 64-bit vector lane immediate
65 /// 32-bit unsigned function indices.
67 /// 32-bit unsigned memory offsets.
69 /// 64-bit unsigned memory offsets.
71 /// p2align immediate for load and store address alignment.
73 /// signature immediate for block/loop.
75 /// type signature immediate for call_indirect.
77 /// Tag index.
79 /// A list of branch targets for br_list.
81 /// 32-bit unsigned table number.
83 /// A list of catch clauses for try_table.
85 /// Memory ordering immediate for atomic instructions.
87};
88} // end namespace WebAssembly
89
90namespace WebAssemblyII {
91
92/// Target Operand Flag enum.
93enum TOF {
95
96 // On a symbol operand this indicates that the immediate is a wasm global
97 // index. The value of the wasm global will be set to the symbol address at
98 // runtime. This adds a level of indirection similar to the GOT on native
99 // platforms.
101
102 // Same as MO_GOT but the address stored in the global is a TLS address.
104
105 // On a symbol operand this indicates that the immediate is the symbol
106 // address relative the __memory_base wasm global.
107 // Only applicable to data symbols.
109
110 // On a symbol operand this indicates that the immediate is the symbol
111 // address relative the __tls_base wasm global.
112 // Only applicable to data symbols.
114
115 // On a symbol operand this indicates that the immediate is the symbol
116 // address relative the __table_base wasm global.
117 // Only applicable to function symbols.
119
120 // On a block signature operand this indicates that this is a destination
121 // block of a (catch_ref) clause in try_table.
123};
124
125} // end namespace WebAssemblyII
126
127} // end namespace llvm
128
129// Defines symbolic names for WebAssembly registers. This defines a mapping from
130// register name to register number.
131//
132#define GET_REGINFO_ENUM
133#include "WebAssemblyGenRegisterInfo.inc"
134
135// Defines symbolic names for the WebAssembly instructions.
136//
137#define GET_INSTRINFO_ENUM
138#define GET_INSTRINFO_MC_HELPER_DECLS
139#include "WebAssemblyGenInstrInfo.inc"
140
141namespace llvm {
142namespace WebAssembly {
143
144/// Instruction opcodes emitted via means other than CodeGen.
145static const unsigned Nop = 0x01;
146static const unsigned End = 0x0b;
147
148/// Return the default p2align value for a load or store with the given opcode.
149inline unsigned GetDefaultP2AlignAny(unsigned Opc) {
150 switch (Opc) {
151#define WASM_LOAD_STORE(NAME) \
152 case WebAssembly::NAME##_A32: \
153 case WebAssembly::NAME##_A64: \
154 case WebAssembly::NAME##_A32_S: \
155 case WebAssembly::NAME##_A64_S:
156 WASM_LOAD_STORE(LOAD8_S_I32)
157 WASM_LOAD_STORE(LOAD8_U_I32)
158 WASM_LOAD_STORE(LOAD8_S_I64)
159 WASM_LOAD_STORE(LOAD8_U_I64)
160 WASM_LOAD_STORE(ATOMIC_LOAD8_U_I32)
161 WASM_LOAD_STORE(ATOMIC_LOAD8_U_I64)
162 WASM_LOAD_STORE(STORE8_I32)
163 WASM_LOAD_STORE(STORE8_I64)
164 WASM_LOAD_STORE(ATOMIC_STORE8_I32)
165 WASM_LOAD_STORE(ATOMIC_STORE8_I64)
166 WASM_LOAD_STORE(ATOMIC_RMW8_U_ADD_I32)
167 WASM_LOAD_STORE(ATOMIC_RMW8_U_ADD_I64)
168 WASM_LOAD_STORE(ATOMIC_RMW8_U_SUB_I32)
169 WASM_LOAD_STORE(ATOMIC_RMW8_U_SUB_I64)
170 WASM_LOAD_STORE(ATOMIC_RMW8_U_AND_I32)
171 WASM_LOAD_STORE(ATOMIC_RMW8_U_AND_I64)
172 WASM_LOAD_STORE(ATOMIC_RMW8_U_OR_I32)
173 WASM_LOAD_STORE(ATOMIC_RMW8_U_OR_I64)
174 WASM_LOAD_STORE(ATOMIC_RMW8_U_XOR_I32)
175 WASM_LOAD_STORE(ATOMIC_RMW8_U_XOR_I64)
176 WASM_LOAD_STORE(ATOMIC_RMW8_U_XCHG_I32)
177 WASM_LOAD_STORE(ATOMIC_RMW8_U_XCHG_I64)
178 WASM_LOAD_STORE(ATOMIC_RMW8_U_CMPXCHG_I32)
179 WASM_LOAD_STORE(ATOMIC_RMW8_U_CMPXCHG_I64)
180 WASM_LOAD_STORE(LOAD8_SPLAT)
181 WASM_LOAD_STORE(LOAD_LANE_8)
182 WASM_LOAD_STORE(STORE_LANE_I8x16)
183 return 0;
184 WASM_LOAD_STORE(LOAD16_S_I32)
185 WASM_LOAD_STORE(LOAD16_U_I32)
186 WASM_LOAD_STORE(LOAD16_S_I64)
187 WASM_LOAD_STORE(LOAD16_U_I64)
188 WASM_LOAD_STORE(ATOMIC_LOAD16_U_I32)
189 WASM_LOAD_STORE(ATOMIC_LOAD16_U_I64)
190 WASM_LOAD_STORE(STORE16_I32)
191 WASM_LOAD_STORE(STORE16_I64)
192 WASM_LOAD_STORE(ATOMIC_STORE16_I32)
193 WASM_LOAD_STORE(ATOMIC_STORE16_I64)
194 WASM_LOAD_STORE(ATOMIC_RMW16_U_ADD_I32)
195 WASM_LOAD_STORE(ATOMIC_RMW16_U_ADD_I64)
196 WASM_LOAD_STORE(ATOMIC_RMW16_U_SUB_I32)
197 WASM_LOAD_STORE(ATOMIC_RMW16_U_SUB_I64)
198 WASM_LOAD_STORE(ATOMIC_RMW16_U_AND_I32)
199 WASM_LOAD_STORE(ATOMIC_RMW16_U_AND_I64)
200 WASM_LOAD_STORE(ATOMIC_RMW16_U_OR_I32)
201 WASM_LOAD_STORE(ATOMIC_RMW16_U_OR_I64)
202 WASM_LOAD_STORE(ATOMIC_RMW16_U_XOR_I32)
203 WASM_LOAD_STORE(ATOMIC_RMW16_U_XOR_I64)
204 WASM_LOAD_STORE(ATOMIC_RMW16_U_XCHG_I32)
205 WASM_LOAD_STORE(ATOMIC_RMW16_U_XCHG_I64)
206 WASM_LOAD_STORE(ATOMIC_RMW16_U_CMPXCHG_I32)
207 WASM_LOAD_STORE(ATOMIC_RMW16_U_CMPXCHG_I64)
208 WASM_LOAD_STORE(LOAD16_SPLAT)
209 WASM_LOAD_STORE(LOAD_LANE_16)
210 WASM_LOAD_STORE(STORE_LANE_I16x8)
211 WASM_LOAD_STORE(LOAD_F16_F32)
212 WASM_LOAD_STORE(STORE_F16_F32)
213 return 1;
214 WASM_LOAD_STORE(LOAD_I32)
215 WASM_LOAD_STORE(LOAD_F32)
216 WASM_LOAD_STORE(STORE_I32)
217 WASM_LOAD_STORE(STORE_F32)
218 WASM_LOAD_STORE(LOAD32_S_I64)
219 WASM_LOAD_STORE(LOAD32_U_I64)
220 WASM_LOAD_STORE(STORE32_I64)
221 WASM_LOAD_STORE(ATOMIC_LOAD_I32)
222 WASM_LOAD_STORE(ATOMIC_LOAD32_U_I64)
223 WASM_LOAD_STORE(ATOMIC_STORE_I32)
224 WASM_LOAD_STORE(ATOMIC_STORE32_I64)
225 WASM_LOAD_STORE(ATOMIC_RMW_ADD_I32)
226 WASM_LOAD_STORE(ATOMIC_RMW32_U_ADD_I64)
227 WASM_LOAD_STORE(ATOMIC_RMW_SUB_I32)
228 WASM_LOAD_STORE(ATOMIC_RMW32_U_SUB_I64)
229 WASM_LOAD_STORE(ATOMIC_RMW_AND_I32)
230 WASM_LOAD_STORE(ATOMIC_RMW32_U_AND_I64)
231 WASM_LOAD_STORE(ATOMIC_RMW_OR_I32)
232 WASM_LOAD_STORE(ATOMIC_RMW32_U_OR_I64)
233 WASM_LOAD_STORE(ATOMIC_RMW_XOR_I32)
234 WASM_LOAD_STORE(ATOMIC_RMW32_U_XOR_I64)
235 WASM_LOAD_STORE(ATOMIC_RMW_XCHG_I32)
236 WASM_LOAD_STORE(ATOMIC_RMW32_U_XCHG_I64)
237 WASM_LOAD_STORE(ATOMIC_RMW_CMPXCHG_I32)
238 WASM_LOAD_STORE(ATOMIC_RMW32_U_CMPXCHG_I64)
239 WASM_LOAD_STORE(MEMORY_ATOMIC_NOTIFY)
240 WASM_LOAD_STORE(MEMORY_ATOMIC_WAIT32)
241 WASM_LOAD_STORE(LOAD32_SPLAT)
242 WASM_LOAD_STORE(LOAD_ZERO_32)
243 WASM_LOAD_STORE(LOAD_LANE_32)
244 WASM_LOAD_STORE(STORE_LANE_I32x4)
245 return 2;
246 WASM_LOAD_STORE(LOAD_I64)
247 WASM_LOAD_STORE(LOAD_F64)
248 WASM_LOAD_STORE(STORE_I64)
249 WASM_LOAD_STORE(STORE_F64)
250 WASM_LOAD_STORE(ATOMIC_LOAD_I64)
251 WASM_LOAD_STORE(ATOMIC_STORE_I64)
252 WASM_LOAD_STORE(ATOMIC_RMW_ADD_I64)
253 WASM_LOAD_STORE(ATOMIC_RMW_SUB_I64)
254 WASM_LOAD_STORE(ATOMIC_RMW_AND_I64)
255 WASM_LOAD_STORE(ATOMIC_RMW_OR_I64)
256 WASM_LOAD_STORE(ATOMIC_RMW_XOR_I64)
257 WASM_LOAD_STORE(ATOMIC_RMW_XCHG_I64)
258 WASM_LOAD_STORE(ATOMIC_RMW_CMPXCHG_I64)
259 WASM_LOAD_STORE(MEMORY_ATOMIC_WAIT64)
260 WASM_LOAD_STORE(LOAD64_SPLAT)
261 WASM_LOAD_STORE(LOAD_EXTEND_S_I16x8)
262 WASM_LOAD_STORE(LOAD_EXTEND_U_I16x8)
263 WASM_LOAD_STORE(LOAD_EXTEND_S_I32x4)
264 WASM_LOAD_STORE(LOAD_EXTEND_U_I32x4)
265 WASM_LOAD_STORE(LOAD_EXTEND_S_I64x2)
266 WASM_LOAD_STORE(LOAD_EXTEND_U_I64x2)
267 WASM_LOAD_STORE(LOAD_ZERO_64)
268 WASM_LOAD_STORE(LOAD_LANE_64)
269 WASM_LOAD_STORE(STORE_LANE_I64x2)
270 return 3;
271 WASM_LOAD_STORE(LOAD_V128)
272 WASM_LOAD_STORE(STORE_V128)
273 return 4;
274 default:
275 return -1;
276 }
277#undef WASM_LOAD_STORE
278}
279
280inline unsigned GetDefaultP2Align(unsigned Opc) {
282 if (Align == -1U) {
283 llvm_unreachable("Only loads and stores have p2align values");
284 }
285 return Align;
286}
287
288inline bool isConst(unsigned Opc) {
289 switch (Opc) {
290 case WebAssembly::CONST_I32:
291 case WebAssembly::CONST_I32_S:
292 case WebAssembly::CONST_I64:
293 case WebAssembly::CONST_I64_S:
294 case WebAssembly::CONST_F32:
295 case WebAssembly::CONST_F32_S:
296 case WebAssembly::CONST_F64:
297 case WebAssembly::CONST_F64_S:
298 case WebAssembly::CONST_V128_I8x16:
299 case WebAssembly::CONST_V128_I8x16_S:
300 case WebAssembly::CONST_V128_I16x8:
301 case WebAssembly::CONST_V128_I16x8_S:
302 case WebAssembly::CONST_V128_I32x4:
303 case WebAssembly::CONST_V128_I32x4_S:
304 case WebAssembly::CONST_V128_I64x2:
305 case WebAssembly::CONST_V128_I64x2_S:
306 case WebAssembly::CONST_V128_F32x4:
307 case WebAssembly::CONST_V128_F32x4_S:
308 case WebAssembly::CONST_V128_F64x2:
309 case WebAssembly::CONST_V128_F64x2_S:
310 return true;
311 default:
312 return false;
313 }
314}
315
316inline bool isScalarConst(unsigned Opc) {
317 switch (Opc) {
318 case WebAssembly::CONST_I32:
319 case WebAssembly::CONST_I32_S:
320 case WebAssembly::CONST_I64:
321 case WebAssembly::CONST_I64_S:
322 case WebAssembly::CONST_F32:
323 case WebAssembly::CONST_F32_S:
324 case WebAssembly::CONST_F64:
325 case WebAssembly::CONST_F64_S:
326 return true;
327 default:
328 return false;
329 }
330}
331
332inline bool isArgument(unsigned Opc) {
333 switch (Opc) {
334 case WebAssembly::ARGUMENT_i32:
335 case WebAssembly::ARGUMENT_i32_S:
336 case WebAssembly::ARGUMENT_i64:
337 case WebAssembly::ARGUMENT_i64_S:
338 case WebAssembly::ARGUMENT_f32:
339 case WebAssembly::ARGUMENT_f32_S:
340 case WebAssembly::ARGUMENT_f64:
341 case WebAssembly::ARGUMENT_f64_S:
342 case WebAssembly::ARGUMENT_v16i8:
343 case WebAssembly::ARGUMENT_v16i8_S:
344 case WebAssembly::ARGUMENT_v8i16:
345 case WebAssembly::ARGUMENT_v8i16_S:
346 case WebAssembly::ARGUMENT_v4i32:
347 case WebAssembly::ARGUMENT_v4i32_S:
348 case WebAssembly::ARGUMENT_v2i64:
349 case WebAssembly::ARGUMENT_v2i64_S:
350 case WebAssembly::ARGUMENT_v8f16:
351 case WebAssembly::ARGUMENT_v8f16_S:
352 case WebAssembly::ARGUMENT_v4f32:
353 case WebAssembly::ARGUMENT_v4f32_S:
354 case WebAssembly::ARGUMENT_v2f64:
355 case WebAssembly::ARGUMENT_v2f64_S:
356 case WebAssembly::ARGUMENT_funcref:
357 case WebAssembly::ARGUMENT_funcref_S:
358 case WebAssembly::ARGUMENT_externref:
359 case WebAssembly::ARGUMENT_externref_S:
360 case WebAssembly::ARGUMENT_exnref:
361 case WebAssembly::ARGUMENT_exnref_S:
362 return true;
363 default:
364 return false;
365 }
366}
367
368inline bool isCopy(unsigned Opc) {
369 switch (Opc) {
370 case WebAssembly::COPY_I32:
371 case WebAssembly::COPY_I32_S:
372 case WebAssembly::COPY_I64:
373 case WebAssembly::COPY_I64_S:
374 case WebAssembly::COPY_F32:
375 case WebAssembly::COPY_F32_S:
376 case WebAssembly::COPY_F64:
377 case WebAssembly::COPY_F64_S:
378 case WebAssembly::COPY_V128:
379 case WebAssembly::COPY_V128_S:
380 case WebAssembly::COPY_FUNCREF:
381 case WebAssembly::COPY_FUNCREF_S:
382 case WebAssembly::COPY_EXTERNREF:
383 case WebAssembly::COPY_EXTERNREF_S:
384 case WebAssembly::COPY_EXNREF:
385 case WebAssembly::COPY_EXNREF_S:
386 return true;
387 default:
388 return false;
389 }
390}
391
392inline bool isTee(unsigned Opc) {
393 switch (Opc) {
394 case WebAssembly::TEE_I32:
395 case WebAssembly::TEE_I32_S:
396 case WebAssembly::TEE_I64:
397 case WebAssembly::TEE_I64_S:
398 case WebAssembly::TEE_F32:
399 case WebAssembly::TEE_F32_S:
400 case WebAssembly::TEE_F64:
401 case WebAssembly::TEE_F64_S:
402 case WebAssembly::TEE_V128:
403 case WebAssembly::TEE_V128_S:
404 case WebAssembly::TEE_FUNCREF:
405 case WebAssembly::TEE_FUNCREF_S:
406 case WebAssembly::TEE_EXTERNREF:
407 case WebAssembly::TEE_EXTERNREF_S:
408 case WebAssembly::TEE_EXNREF:
409 case WebAssembly::TEE_EXNREF_S:
410 return true;
411 default:
412 return false;
413 }
414}
415
416inline bool isCallDirect(unsigned Opc) {
417 switch (Opc) {
418 case WebAssembly::CALL:
419 case WebAssembly::CALL_S:
420 case WebAssembly::RET_CALL:
421 case WebAssembly::RET_CALL_S:
422 return true;
423 default:
424 return false;
425 }
426}
427
428inline bool isCallIndirect(unsigned Opc) {
429 switch (Opc) {
430 case WebAssembly::CALL_INDIRECT:
431 case WebAssembly::CALL_INDIRECT_S:
432 case WebAssembly::RET_CALL_INDIRECT:
433 case WebAssembly::RET_CALL_INDIRECT_S:
434 return true;
435 default:
436 return false;
437 }
438}
439
440inline bool isBrTable(unsigned Opc) {
441 switch (Opc) {
442 case WebAssembly::BR_TABLE_I32:
443 case WebAssembly::BR_TABLE_I32_S:
444 case WebAssembly::BR_TABLE_I64:
445 case WebAssembly::BR_TABLE_I64_S:
446 return true;
447 default:
448 return false;
449 }
450}
451
452inline bool isMarker(unsigned Opc) {
453 switch (Opc) {
454 case WebAssembly::BLOCK:
455 case WebAssembly::BLOCK_S:
456 case WebAssembly::END_BLOCK:
457 case WebAssembly::END_BLOCK_S:
458 case WebAssembly::LOOP:
459 case WebAssembly::LOOP_S:
460 case WebAssembly::END_LOOP:
461 case WebAssembly::END_LOOP_S:
462 case WebAssembly::TRY:
463 case WebAssembly::TRY_S:
464 case WebAssembly::END_TRY:
465 case WebAssembly::END_TRY_S:
466 case WebAssembly::TRY_TABLE:
467 case WebAssembly::TRY_TABLE_S:
468 case WebAssembly::END_TRY_TABLE:
469 case WebAssembly::END_TRY_TABLE_S:
470 return true;
471 default:
472 return false;
473 }
474}
475
476inline bool isEndMarker(unsigned Opc) {
477 switch (Opc) {
478 case WebAssembly::END_BLOCK:
479 case WebAssembly::END_BLOCK_S:
480 case WebAssembly::END_LOOP:
481 case WebAssembly::END_LOOP_S:
482 case WebAssembly::END_TRY:
483 case WebAssembly::END_TRY_S:
484 case WebAssembly::END_TRY_TABLE:
485 case WebAssembly::END_TRY_TABLE_S:
486 return true;
487 default:
488 return false;
489 }
490}
491
492inline bool isTry(unsigned Opc) {
493 switch (Opc) {
494 case WebAssembly::TRY:
495 case WebAssembly::TRY_S:
496 case WebAssembly::TRY_TABLE:
497 case WebAssembly::TRY_TABLE_S:
498 return true;
499 default:
500 return false;
501 }
502}
503
504inline bool isCatch(unsigned Opc) {
505 switch (Opc) {
506 case WebAssembly::CATCH_LEGACY:
507 case WebAssembly::CATCH_LEGACY_S:
508 case WebAssembly::CATCH_ALL_LEGACY:
509 case WebAssembly::CATCH_ALL_LEGACY_S:
510 case WebAssembly::CATCH:
511 case WebAssembly::CATCH_S:
512 case WebAssembly::CATCH_REF:
513 case WebAssembly::CATCH_REF_S:
514 case WebAssembly::CATCH_ALL:
515 case WebAssembly::CATCH_ALL_S:
516 case WebAssembly::CATCH_ALL_REF:
517 case WebAssembly::CATCH_ALL_REF_S:
518 return true;
519 default:
520 return false;
521 }
522}
523
524inline bool isCatchAll(unsigned Opc) {
525 switch (Opc) {
526 case WebAssembly::CATCH_ALL_LEGACY:
527 case WebAssembly::CATCH_ALL_LEGACY_S:
528 case WebAssembly::CATCH_ALL:
529 case WebAssembly::CATCH_ALL_S:
530 case WebAssembly::CATCH_ALL_REF:
531 case WebAssembly::CATCH_ALL_REF_S:
532 return true;
533 default:
534 return false;
535 }
536}
537
538inline bool isLocalGet(unsigned Opc) {
539 switch (Opc) {
540 case WebAssembly::LOCAL_GET_I32:
541 case WebAssembly::LOCAL_GET_I32_S:
542 case WebAssembly::LOCAL_GET_I64:
543 case WebAssembly::LOCAL_GET_I64_S:
544 case WebAssembly::LOCAL_GET_F32:
545 case WebAssembly::LOCAL_GET_F32_S:
546 case WebAssembly::LOCAL_GET_F64:
547 case WebAssembly::LOCAL_GET_F64_S:
548 case WebAssembly::LOCAL_GET_V128:
549 case WebAssembly::LOCAL_GET_V128_S:
550 case WebAssembly::LOCAL_GET_FUNCREF:
551 case WebAssembly::LOCAL_GET_FUNCREF_S:
552 case WebAssembly::LOCAL_GET_EXTERNREF:
553 case WebAssembly::LOCAL_GET_EXTERNREF_S:
554 case WebAssembly::LOCAL_GET_EXNREF:
555 case WebAssembly::LOCAL_GET_EXNREF_S:
556 return true;
557 default:
558 return false;
559 }
560}
561
562inline bool isLocalSet(unsigned Opc) {
563 switch (Opc) {
564 case WebAssembly::LOCAL_SET_I32:
565 case WebAssembly::LOCAL_SET_I32_S:
566 case WebAssembly::LOCAL_SET_I64:
567 case WebAssembly::LOCAL_SET_I64_S:
568 case WebAssembly::LOCAL_SET_F32:
569 case WebAssembly::LOCAL_SET_F32_S:
570 case WebAssembly::LOCAL_SET_F64:
571 case WebAssembly::LOCAL_SET_F64_S:
572 case WebAssembly::LOCAL_SET_V128:
573 case WebAssembly::LOCAL_SET_V128_S:
574 case WebAssembly::LOCAL_SET_FUNCREF:
575 case WebAssembly::LOCAL_SET_FUNCREF_S:
576 case WebAssembly::LOCAL_SET_EXTERNREF:
577 case WebAssembly::LOCAL_SET_EXTERNREF_S:
578 case WebAssembly::LOCAL_SET_EXNREF:
579 case WebAssembly::LOCAL_SET_EXNREF_S:
580 return true;
581 default:
582 return false;
583 }
584}
585
586inline bool isLocalTee(unsigned Opc) {
587 switch (Opc) {
588 case WebAssembly::LOCAL_TEE_I32:
589 case WebAssembly::LOCAL_TEE_I32_S:
590 case WebAssembly::LOCAL_TEE_I64:
591 case WebAssembly::LOCAL_TEE_I64_S:
592 case WebAssembly::LOCAL_TEE_F32:
593 case WebAssembly::LOCAL_TEE_F32_S:
594 case WebAssembly::LOCAL_TEE_F64:
595 case WebAssembly::LOCAL_TEE_F64_S:
596 case WebAssembly::LOCAL_TEE_V128:
597 case WebAssembly::LOCAL_TEE_V128_S:
598 case WebAssembly::LOCAL_TEE_FUNCREF:
599 case WebAssembly::LOCAL_TEE_FUNCREF_S:
600 case WebAssembly::LOCAL_TEE_EXTERNREF:
601 case WebAssembly::LOCAL_TEE_EXTERNREF_S:
602 case WebAssembly::LOCAL_TEE_EXNREF:
603 case WebAssembly::LOCAL_TEE_EXNREF_S:
604 return true;
605 default:
606 return false;
607 }
608}
609
610static const unsigned UnusedReg = -1u;
611
612// For a given stackified WAReg, return the id number to print with push/pop.
614 assert(Reg.id() & INT32_MIN);
615 return Reg.id() & INT32_MAX;
616}
617
618} // end namespace WebAssembly
619} // end namespace llvm
620
621#define GET_SUBTARGETINFO_ENUM
622#include "WebAssemblyGenSubtargetInfo.inc"
623
624#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Register Reg
#define WASM_LOAD_STORE(NAME)
Generic interface to target specific assembler backends.
MCCodeEmitter - Generic instruction encoding interface.
Context object for machine code objects.
Definition MCContext.h:83
Interface to description of machine instruction set.
Definition MCInstrInfo.h:27
Base class for classes that define behaviour that is specific to both the target and the object forma...
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ OPERAND_FIRST_TARGET
Definition MCInstrDesc.h:79
TOF
Target Operand Flag enum.
bool isLocalTee(unsigned Opc)
bool isArgument(unsigned Opc)
bool isCallIndirect(unsigned Opc)
unsigned GetDefaultP2Align(unsigned Opc)
bool isCatchAll(unsigned Opc)
bool isMarker(unsigned Opc)
bool isBrTable(unsigned Opc)
bool isEndMarker(unsigned Opc)
bool isCatch(unsigned Opc)
static const unsigned UnusedReg
static const unsigned Nop
Instruction opcodes emitted via means other than CodeGen.
bool isCopy(unsigned Opc)
static const unsigned End
bool isConst(unsigned Opc)
@ OPERAND_CATCH_LIST
A list of catch clauses for try_table.
@ OPERAND_OFFSET64
64-bit unsigned memory offsets.
@ OPERAND_MEMORDER
Memory ordering immediate for atomic instructions.
@ OPERAND_I32IMM
32-bit integer immediates.
@ OPERAND_P2ALIGN
p2align immediate for load and store address alignment.
@ OPERAND_TABLE
32-bit unsigned table number.
@ OPERAND_VEC_I64IMM
64-bit vector lane immediate
@ OPERAND_VEC_I16IMM
16-bit vector lane immediate
@ OPERAND_TYPEINDEX
type signature immediate for call_indirect.
@ OPERAND_FUNCTION32
32-bit unsigned function indices.
@ OPERAND_F32IMM
32-bit floating-point immediates.
@ OPERAND_BASIC_BLOCK
Basic block label in a branch construct.
@ OPERAND_VEC_I32IMM
32-bit vector lane immediate
@ OPERAND_BRLIST
A list of branch targets for br_list.
@ OPERAND_F64IMM
64-bit floating-point immediates.
@ OPERAND_VEC_I8IMM
8-bit vector lane immediate
@ OPERAND_SIGNATURE
signature immediate for block/loop.
@ OPERAND_I64IMM
64-bit integer immediates.
@ OPERAND_OFFSET32
32-bit unsigned memory offsets.
unsigned GetDefaultP2AlignAny(unsigned Opc)
Return the default p2align value for a load or store with the given opcode.
unsigned getWARegStackId(MCRegister Reg)
bool isCallDirect(unsigned Opc)
bool isScalarConst(unsigned Opc)
bool isLocalSet(unsigned Opc)
bool isLocalGet(unsigned Opc)
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
MCCodeEmitter * createWebAssemblyMCCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)
MCAsmBackend * createWebAssemblyAsmBackend(const Triple &TT)
std::unique_ptr< MCObjectTargetWriter > createWebAssemblyWasmObjectWriter(bool Is64Bit, bool IsEmscripten)
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39