llvm.org GIT mirror llvm / cef9a05
[WebAssembly] TableGen backend for stackifying instructions Summary: The new stackification backend generates the giant switch statement used to translate instructions to their stackified forms. I did this because it was more interesting than adding all the different vector versions of the various SIMD instructions to the switch statment manually. Reviewers: aardappel, aheejin, dschuff Subscribers: mgorny, sbc100, jgravelle-google, sunfish, jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D51318 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340781 91177308-0d34-0410-b5e6-96231b3b80d8 Thomas Lively 1 year, 1 month ago
6 changed file(s) with 48 addition(s) and 359 deletion(s). Raw diff Collapse all Expand all
88 tablegen(LLVM WebAssemblyGenMCCodeEmitter.inc -gen-emitter)
99 tablegen(LLVM WebAssemblyGenRegisterInfo.inc -gen-register-info)
1010 tablegen(LLVM WebAssemblyGenSubtargetInfo.inc -gen-subtarget)
11 tablegen(LLVM WebAssemblyGenStackifier.inc -gen-wasm-stackifier)
1112
1213 add_public_tablegen_target(WebAssemblyCommonTableGen)
1314
282282 }
283283
284284 static unsigned regInstructionToStackInstruction(unsigned OpCode) {
285 // For most opcodes, this function could have been implemented as "return
286 // OpCode + 1", but since table-gen alphabetically sorts them, this cannot be
287 // guaranteed (see e.g. BR and BR_IF), so we table-gen a giant switch
288 // statement instead.
285289 switch (OpCode) {
286290 default:
287 // You may hit this if you add new instructions, please add them below.
288 // For most of these opcodes, this function could have been implemented
289 // as "return OpCode + 1", but since table-gen alphabetically sorts them,
290 // this cannot be guaranteed (see e.g. BR and BR_IF).
291 // The approach below is the same as what the x87 backend does.
292 // TODO(wvo): to make this code cleaner, create a custom tablegen
293 // code generator that emits the table below automatically.
294291 llvm_unreachable(
295292 "unknown WebAssembly instruction in Explicit Locals pass");
296 case WebAssembly::ABS_F32: return WebAssembly::ABS_F32_S;
297 case WebAssembly::ABS_F64: return WebAssembly::ABS_F64_S;
298 case WebAssembly::ADD_F32: return WebAssembly::ADD_F32_S;
299 case WebAssembly::ADD_F64: return WebAssembly::ADD_F64_S;
300 case WebAssembly::ADD_I32: return WebAssembly::ADD_I32_S;
301 case WebAssembly::ADD_I64: return WebAssembly::ADD_I64_S;
302 case WebAssembly::ADD_v16i8: return WebAssembly::ADD_v16i8_S;
303 case WebAssembly::ADD_v2f64: return WebAssembly::ADD_v2f64_S;
304 case WebAssembly::ADD_v2i64: return WebAssembly::ADD_v2i64_S;
305 case WebAssembly::ADD_v4f32: return WebAssembly::ADD_v4f32_S;
306 case WebAssembly::ADD_v4i32: return WebAssembly::ADD_v4i32_S;
307 case WebAssembly::ADD_v8i16: return WebAssembly::ADD_v8i16_S;
308 case WebAssembly::ADJCALLSTACKDOWN: return WebAssembly::ADJCALLSTACKDOWN_S;
309 case WebAssembly::ADJCALLSTACKUP: return WebAssembly::ADJCALLSTACKUP_S;
310 case WebAssembly::AND_I32: return WebAssembly::AND_I32_S;
311 case WebAssembly::AND_I64: return WebAssembly::AND_I64_S;
312 case WebAssembly::ARGUMENT_EXCEPT_REF: return WebAssembly::ARGUMENT_EXCEPT_REF_S;
313 case WebAssembly::ARGUMENT_F32: return WebAssembly::ARGUMENT_F32_S;
314 case WebAssembly::ARGUMENT_F64: return WebAssembly::ARGUMENT_F64_S;
315 case WebAssembly::ARGUMENT_I32: return WebAssembly::ARGUMENT_I32_S;
316 case WebAssembly::ARGUMENT_I64: return WebAssembly::ARGUMENT_I64_S;
317 case WebAssembly::ARGUMENT_v16i8: return WebAssembly::ARGUMENT_v16i8_S;
318 case WebAssembly::ARGUMENT_v4f32: return WebAssembly::ARGUMENT_v4f32_S;
319 case WebAssembly::ARGUMENT_v4i32: return WebAssembly::ARGUMENT_v4i32_S;
320 case WebAssembly::ARGUMENT_v8i16: return WebAssembly::ARGUMENT_v8i16_S;
321 case WebAssembly::ARGUMENT_v2f64: return WebAssembly::ARGUMENT_v2f64_S;
322 case WebAssembly::ARGUMENT_v2i64: return WebAssembly::ARGUMENT_v2i64_S;
323 case WebAssembly::ATOMIC_LOAD16_U_I32: return WebAssembly::ATOMIC_LOAD16_U_I32_S;
324 case WebAssembly::ATOMIC_LOAD16_U_I64: return WebAssembly::ATOMIC_LOAD16_U_I64_S;
325 case WebAssembly::ATOMIC_LOAD32_U_I64: return WebAssembly::ATOMIC_LOAD32_U_I64_S;
326 case WebAssembly::ATOMIC_LOAD8_U_I32: return WebAssembly::ATOMIC_LOAD8_U_I32_S;
327 case WebAssembly::ATOMIC_LOAD8_U_I64: return WebAssembly::ATOMIC_LOAD8_U_I64_S;
328 case WebAssembly::ATOMIC_LOAD_I32: return WebAssembly::ATOMIC_LOAD_I32_S;
329 case WebAssembly::ATOMIC_LOAD_I64: return WebAssembly::ATOMIC_LOAD_I64_S;
330 case WebAssembly::ATOMIC_STORE16_I32: return WebAssembly::ATOMIC_STORE16_I32_S;
331 case WebAssembly::ATOMIC_STORE16_I64: return WebAssembly::ATOMIC_STORE16_I64_S;
332 case WebAssembly::ATOMIC_STORE32_I64: return WebAssembly::ATOMIC_STORE32_I64_S;
333 case WebAssembly::ATOMIC_STORE8_I32: return WebAssembly::ATOMIC_STORE8_I32_S;
334 case WebAssembly::ATOMIC_STORE8_I64: return WebAssembly::ATOMIC_STORE8_I64_S;
335 case WebAssembly::ATOMIC_STORE_I32: return WebAssembly::ATOMIC_STORE_I32_S;
336 case WebAssembly::ATOMIC_STORE_I64: return WebAssembly::ATOMIC_STORE_I64_S;
337 case WebAssembly::BLOCK: return WebAssembly::BLOCK_S;
338 case WebAssembly::BR: return WebAssembly::BR_S;
339 case WebAssembly::BR_IF: return WebAssembly::BR_IF_S;
340 case WebAssembly::BR_TABLE_I32: return WebAssembly::BR_TABLE_I32_S;
341 case WebAssembly::BR_TABLE_I64: return WebAssembly::BR_TABLE_I64_S;
342 case WebAssembly::BR_UNLESS: return WebAssembly::BR_UNLESS_S;
343 case WebAssembly::CALL_EXCEPT_REF: return WebAssembly::CALL_EXCEPT_REF_S;
344 case WebAssembly::CALL_F32: return WebAssembly::CALL_F32_S;
345 case WebAssembly::CALL_F64: return WebAssembly::CALL_F64_S;
346 case WebAssembly::CALL_I32: return WebAssembly::CALL_I32_S;
347 case WebAssembly::CALL_I64: return WebAssembly::CALL_I64_S;
348 case WebAssembly::CALL_INDIRECT_EXCEPT_REF: return WebAssembly::CALL_INDIRECT_EXCEPT_REF_S;
349 case WebAssembly::CALL_INDIRECT_F32: return WebAssembly::CALL_INDIRECT_F32_S;
350 case WebAssembly::CALL_INDIRECT_F64: return WebAssembly::CALL_INDIRECT_F64_S;
351 case WebAssembly::CALL_INDIRECT_I32: return WebAssembly::CALL_INDIRECT_I32_S;
352 case WebAssembly::CALL_INDIRECT_I64: return WebAssembly::CALL_INDIRECT_I64_S;
353 case WebAssembly::CALL_INDIRECT_VOID: return WebAssembly::CALL_INDIRECT_VOID_S;
354 case WebAssembly::CALL_INDIRECT_v16i8: return WebAssembly::CALL_INDIRECT_v16i8_S;
355 case WebAssembly::CALL_INDIRECT_v4f32: return WebAssembly::CALL_INDIRECT_v4f32_S;
356 case WebAssembly::CALL_INDIRECT_v4i32: return WebAssembly::CALL_INDIRECT_v4i32_S;
357 case WebAssembly::CALL_INDIRECT_v8i16: return WebAssembly::CALL_INDIRECT_v8i16_S;
358 case WebAssembly::CALL_VOID: return WebAssembly::CALL_VOID_S;
359 case WebAssembly::CALL_v16i8: return WebAssembly::CALL_v16i8_S;
360 case WebAssembly::CALL_v4f32: return WebAssembly::CALL_v4f32_S;
361 case WebAssembly::CALL_v4i32: return WebAssembly::CALL_v4i32_S;
362 case WebAssembly::CALL_v8i16: return WebAssembly::CALL_v8i16_S;
363 case WebAssembly::CATCHRET: return WebAssembly::CATCHRET_S;
364 case WebAssembly::CATCH_ALL: return WebAssembly::CATCH_ALL_S;
365 case WebAssembly::CATCH_I32: return WebAssembly::CATCH_I32_S;
366 case WebAssembly::CATCH_I64: return WebAssembly::CATCH_I64_S;
367 case WebAssembly::CEIL_F32: return WebAssembly::CEIL_F32_S;
368 case WebAssembly::CEIL_F64: return WebAssembly::CEIL_F64_S;
369 case WebAssembly::CLEANUPRET: return WebAssembly::CLEANUPRET_S;
370 case WebAssembly::CLZ_I32: return WebAssembly::CLZ_I32_S;
371 case WebAssembly::CLZ_I64: return WebAssembly::CLZ_I64_S;
372 case WebAssembly::CONST_F32: return WebAssembly::CONST_F32_S;
373 case WebAssembly::CONST_F64: return WebAssembly::CONST_F64_S;
374 case WebAssembly::CONST_I32: return WebAssembly::CONST_I32_S;
375 case WebAssembly::CONST_I64: return WebAssembly::CONST_I64_S;
376 case WebAssembly::COPYSIGN_F32: return WebAssembly::COPYSIGN_F32_S;
377 case WebAssembly::COPYSIGN_F64: return WebAssembly::COPYSIGN_F64_S;
378 case WebAssembly::COPY_EXCEPT_REF: return WebAssembly::COPY_EXCEPT_REF_S;
379 case WebAssembly::COPY_F32: return WebAssembly::COPY_F32_S;
380 case WebAssembly::COPY_F64: return WebAssembly::COPY_F64_S;
381 case WebAssembly::COPY_I32: return WebAssembly::COPY_I32_S;
382 case WebAssembly::COPY_I64: return WebAssembly::COPY_I64_S;
383 case WebAssembly::COPY_V128: return WebAssembly::COPY_V128_S;
384 case WebAssembly::CTZ_I32: return WebAssembly::CTZ_I32_S;
385 case WebAssembly::CTZ_I64: return WebAssembly::CTZ_I64_S;
386 case WebAssembly::CURRENT_MEMORY_I32: return WebAssembly::CURRENT_MEMORY_I32_S;
387 case WebAssembly::DIV_F32: return WebAssembly::DIV_F32_S;
388 case WebAssembly::DIV_F64: return WebAssembly::DIV_F64_S;
389 case WebAssembly::DIV_S_I32: return WebAssembly::DIV_S_I32_S;
390 case WebAssembly::DIV_S_I64: return WebAssembly::DIV_S_I64_S;
391 case WebAssembly::DIV_U_I32: return WebAssembly::DIV_U_I32_S;
392 case WebAssembly::DIV_U_I64: return WebAssembly::DIV_U_I64_S;
393 case WebAssembly::DROP_EXCEPT_REF: return WebAssembly::DROP_EXCEPT_REF_S;
394 case WebAssembly::DROP_F32: return WebAssembly::DROP_F32_S;
395 case WebAssembly::DROP_F64: return WebAssembly::DROP_F64_S;
396 case WebAssembly::DROP_I32: return WebAssembly::DROP_I32_S;
397 case WebAssembly::DROP_I64: return WebAssembly::DROP_I64_S;
398 case WebAssembly::DROP_V128: return WebAssembly::DROP_V128_S;
399 case WebAssembly::END_BLOCK: return WebAssembly::END_BLOCK_S;
400 case WebAssembly::END_FUNCTION: return WebAssembly::END_FUNCTION_S;
401 case WebAssembly::END_LOOP: return WebAssembly::END_LOOP_S;
402 case WebAssembly::END_TRY: return WebAssembly::END_TRY_S;
403 case WebAssembly::EQZ_I32: return WebAssembly::EQZ_I32_S;
404 case WebAssembly::EQZ_I64: return WebAssembly::EQZ_I64_S;
405 case WebAssembly::EQ_F32: return WebAssembly::EQ_F32_S;
406 case WebAssembly::EQ_F64: return WebAssembly::EQ_F64_S;
407 case WebAssembly::EQ_I32: return WebAssembly::EQ_I32_S;
408 case WebAssembly::EQ_I64: return WebAssembly::EQ_I64_S;
409 case WebAssembly::F32_CONVERT_S_I32: return WebAssembly::F32_CONVERT_S_I32_S;
410 case WebAssembly::F32_CONVERT_S_I64: return WebAssembly::F32_CONVERT_S_I64_S;
411 case WebAssembly::F32_CONVERT_U_I32: return WebAssembly::F32_CONVERT_U_I32_S;
412 case WebAssembly::F32_CONVERT_U_I64: return WebAssembly::F32_CONVERT_U_I64_S;
413 case WebAssembly::F32_DEMOTE_F64: return WebAssembly::F32_DEMOTE_F64_S;
414 case WebAssembly::F32_REINTERPRET_I32: return WebAssembly::F32_REINTERPRET_I32_S;
415 case WebAssembly::F64_CONVERT_S_I32: return WebAssembly::F64_CONVERT_S_I32_S;
416 case WebAssembly::F64_CONVERT_S_I64: return WebAssembly::F64_CONVERT_S_I64_S;
417 case WebAssembly::F64_CONVERT_U_I32: return WebAssembly::F64_CONVERT_U_I32_S;
418 case WebAssembly::F64_CONVERT_U_I64: return WebAssembly::F64_CONVERT_U_I64_S;
419 case WebAssembly::F64_PROMOTE_F32: return WebAssembly::F64_PROMOTE_F32_S;
420 case WebAssembly::F64_REINTERPRET_I64: return WebAssembly::F64_REINTERPRET_I64_S;
421 case WebAssembly::FALLTHROUGH_RETURN_EXCEPT_REF: return WebAssembly::FALLTHROUGH_RETURN_EXCEPT_REF_S;
422 case WebAssembly::FALLTHROUGH_RETURN_F32: return WebAssembly::FALLTHROUGH_RETURN_F32_S;
423 case WebAssembly::FALLTHROUGH_RETURN_F64: return WebAssembly::FALLTHROUGH_RETURN_F64_S;
424 case WebAssembly::FALLTHROUGH_RETURN_I32: return WebAssembly::FALLTHROUGH_RETURN_I32_S;
425 case WebAssembly::FALLTHROUGH_RETURN_I64: return WebAssembly::FALLTHROUGH_RETURN_I64_S;
426 case WebAssembly::FALLTHROUGH_RETURN_VOID: return WebAssembly::FALLTHROUGH_RETURN_VOID_S;
427 case WebAssembly::FALLTHROUGH_RETURN_v16i8: return WebAssembly::FALLTHROUGH_RETURN_v16i8_S;
428 case WebAssembly::FALLTHROUGH_RETURN_v4f32: return WebAssembly::FALLTHROUGH_RETURN_v4f32_S;
429 case WebAssembly::FALLTHROUGH_RETURN_v4i32: return WebAssembly::FALLTHROUGH_RETURN_v4i32_S;
430 case WebAssembly::FALLTHROUGH_RETURN_v8i16: return WebAssembly::FALLTHROUGH_RETURN_v8i16_S;
431 case WebAssembly::FALLTHROUGH_RETURN_v2f64: return WebAssembly::FALLTHROUGH_RETURN_v2f64_S;
432 case WebAssembly::FALLTHROUGH_RETURN_v2i64: return WebAssembly::FALLTHROUGH_RETURN_v2i64_S;
433 case WebAssembly::FLOOR_F32: return WebAssembly::FLOOR_F32_S;
434 case WebAssembly::FLOOR_F64: return WebAssembly::FLOOR_F64_S;
435 case WebAssembly::FP_TO_SINT_I32_F32: return WebAssembly::FP_TO_SINT_I32_F32_S;
436 case WebAssembly::FP_TO_SINT_I32_F64: return WebAssembly::FP_TO_SINT_I32_F64_S;
437 case WebAssembly::FP_TO_SINT_I64_F32: return WebAssembly::FP_TO_SINT_I64_F32_S;
438 case WebAssembly::FP_TO_SINT_I64_F64: return WebAssembly::FP_TO_SINT_I64_F64_S;
439 case WebAssembly::FP_TO_UINT_I32_F32: return WebAssembly::FP_TO_UINT_I32_F32_S;
440 case WebAssembly::FP_TO_UINT_I32_F64: return WebAssembly::FP_TO_UINT_I32_F64_S;
441 case WebAssembly::FP_TO_UINT_I64_F32: return WebAssembly::FP_TO_UINT_I64_F32_S;
442 case WebAssembly::FP_TO_UINT_I64_F64: return WebAssembly::FP_TO_UINT_I64_F64_S;
443 case WebAssembly::GET_GLOBAL_EXCEPT_REF: return WebAssembly::GET_GLOBAL_EXCEPT_REF_S;
444 case WebAssembly::GET_GLOBAL_F32: return WebAssembly::GET_GLOBAL_F32_S;
445 case WebAssembly::GET_GLOBAL_F64: return WebAssembly::GET_GLOBAL_F64_S;
446 case WebAssembly::GET_GLOBAL_I32: return WebAssembly::GET_GLOBAL_I32_S;
447 case WebAssembly::GET_GLOBAL_I64: return WebAssembly::GET_GLOBAL_I64_S;
448 case WebAssembly::GET_GLOBAL_V128: return WebAssembly::GET_GLOBAL_V128_S;
449 case WebAssembly::GET_LOCAL_EXCEPT_REF: return WebAssembly::GET_LOCAL_EXCEPT_REF_S;
450 case WebAssembly::GET_LOCAL_F32: return WebAssembly::GET_LOCAL_F32_S;
451 case WebAssembly::GET_LOCAL_F64: return WebAssembly::GET_LOCAL_F64_S;
452 case WebAssembly::GET_LOCAL_I32: return WebAssembly::GET_LOCAL_I32_S;
453 case WebAssembly::GET_LOCAL_I64: return WebAssembly::GET_LOCAL_I64_S;
454 case WebAssembly::GET_LOCAL_V128: return WebAssembly::GET_LOCAL_V128_S;
455 case WebAssembly::GE_F32: return WebAssembly::GE_F32_S;
456 case WebAssembly::GE_F64: return WebAssembly::GE_F64_S;
457 case WebAssembly::GE_S_I32: return WebAssembly::GE_S_I32_S;
458 case WebAssembly::GE_S_I64: return WebAssembly::GE_S_I64_S;
459 case WebAssembly::GE_U_I32: return WebAssembly::GE_U_I32_S;
460 case WebAssembly::GE_U_I64: return WebAssembly::GE_U_I64_S;
461 case WebAssembly::GROW_MEMORY_I32: return WebAssembly::GROW_MEMORY_I32_S;
462 case WebAssembly::GT_F32: return WebAssembly::GT_F32_S;
463 case WebAssembly::GT_F64: return WebAssembly::GT_F64_S;
464 case WebAssembly::GT_S_I32: return WebAssembly::GT_S_I32_S;
465 case WebAssembly::GT_S_I64: return WebAssembly::GT_S_I64_S;
466 case WebAssembly::GT_U_I32: return WebAssembly::GT_U_I32_S;
467 case WebAssembly::GT_U_I64: return WebAssembly::GT_U_I64_S;
468 case WebAssembly::I32_EXTEND16_S_I32: return WebAssembly::I32_EXTEND16_S_I32_S;
469 case WebAssembly::I32_EXTEND8_S_I32: return WebAssembly::I32_EXTEND8_S_I32_S;
470 case WebAssembly::I32_REINTERPRET_F32: return WebAssembly::I32_REINTERPRET_F32_S;
471 case WebAssembly::I32_TRUNC_S_F32: return WebAssembly::I32_TRUNC_S_F32_S;
472 case WebAssembly::I32_TRUNC_S_F64: return WebAssembly::I32_TRUNC_S_F64_S;
473 case WebAssembly::I32_TRUNC_S_SAT_F32: return WebAssembly::I32_TRUNC_S_SAT_F32_S;
474 case WebAssembly::I32_TRUNC_S_SAT_F64: return WebAssembly::I32_TRUNC_S_SAT_F64_S;
475 case WebAssembly::I32_TRUNC_U_F32: return WebAssembly::I32_TRUNC_U_F32_S;
476 case WebAssembly::I32_TRUNC_U_F64: return WebAssembly::I32_TRUNC_U_F64_S;
477 case WebAssembly::I32_TRUNC_U_SAT_F32: return WebAssembly::I32_TRUNC_U_SAT_F32_S;
478 case WebAssembly::I32_TRUNC_U_SAT_F64: return WebAssembly::I32_TRUNC_U_SAT_F64_S;
479 case WebAssembly::I32_WRAP_I64: return WebAssembly::I32_WRAP_I64_S;
480 case WebAssembly::I64_EXTEND16_S_I64: return WebAssembly::I64_EXTEND16_S_I64_S;
481 case WebAssembly::I64_EXTEND32_S_I64: return WebAssembly::I64_EXTEND32_S_I64_S;
482 case WebAssembly::I64_EXTEND8_S_I64: return WebAssembly::I64_EXTEND8_S_I64_S;
483 case WebAssembly::I64_EXTEND_S_I32: return WebAssembly::I64_EXTEND_S_I32_S;
484 case WebAssembly::I64_EXTEND_U_I32: return WebAssembly::I64_EXTEND_U_I32_S;
485 case WebAssembly::I64_REINTERPRET_F64: return WebAssembly::I64_REINTERPRET_F64_S;
486 case WebAssembly::I64_TRUNC_S_F32: return WebAssembly::I64_TRUNC_S_F32_S;
487 case WebAssembly::I64_TRUNC_S_F64: return WebAssembly::I64_TRUNC_S_F64_S;
488 case WebAssembly::I64_TRUNC_S_SAT_F32: return WebAssembly::I64_TRUNC_S_SAT_F32_S;
489 case WebAssembly::I64_TRUNC_S_SAT_F64: return WebAssembly::I64_TRUNC_S_SAT_F64_S;
490 case WebAssembly::I64_TRUNC_U_F32: return WebAssembly::I64_TRUNC_U_F32_S;
491 case WebAssembly::I64_TRUNC_U_F64: return WebAssembly::I64_TRUNC_U_F64_S;
492 case WebAssembly::I64_TRUNC_U_SAT_F32: return WebAssembly::I64_TRUNC_U_SAT_F32_S;
493 case WebAssembly::I64_TRUNC_U_SAT_F64: return WebAssembly::I64_TRUNC_U_SAT_F64_S;
494 case WebAssembly::LE_F32: return WebAssembly::LE_F32_S;
495 case WebAssembly::LE_F64: return WebAssembly::LE_F64_S;
496 case WebAssembly::LE_S_I32: return WebAssembly::LE_S_I32_S;
497 case WebAssembly::LE_S_I64: return WebAssembly::LE_S_I64_S;
498 case WebAssembly::LE_U_I32: return WebAssembly::LE_U_I32_S;
499 case WebAssembly::LE_U_I64: return WebAssembly::LE_U_I64_S;
500 case WebAssembly::LOAD16_S_I32: return WebAssembly::LOAD16_S_I32_S;
501 case WebAssembly::LOAD16_S_I64: return WebAssembly::LOAD16_S_I64_S;
502 case WebAssembly::LOAD16_U_I32: return WebAssembly::LOAD16_U_I32_S;
503 case WebAssembly::LOAD16_U_I64: return WebAssembly::LOAD16_U_I64_S;
504 case WebAssembly::LOAD32_S_I64: return WebAssembly::LOAD32_S_I64_S;
505 case WebAssembly::LOAD32_U_I64: return WebAssembly::LOAD32_U_I64_S;
506 case WebAssembly::LOAD8_S_I32: return WebAssembly::LOAD8_S_I32_S;
507 case WebAssembly::LOAD8_S_I64: return WebAssembly::LOAD8_S_I64_S;
508 case WebAssembly::LOAD8_U_I32: return WebAssembly::LOAD8_U_I32_S;
509 case WebAssembly::LOAD8_U_I64: return WebAssembly::LOAD8_U_I64_S;
510 case WebAssembly::LOAD_F32: return WebAssembly::LOAD_F32_S;
511 case WebAssembly::LOAD_F64: return WebAssembly::LOAD_F64_S;
512 case WebAssembly::LOAD_I32: return WebAssembly::LOAD_I32_S;
513 case WebAssembly::LOAD_I64: return WebAssembly::LOAD_I64_S;
514 case WebAssembly::LOOP: return WebAssembly::LOOP_S;
515 case WebAssembly::LT_F32: return WebAssembly::LT_F32_S;
516 case WebAssembly::LT_F64: return WebAssembly::LT_F64_S;
517 case WebAssembly::LT_S_I32: return WebAssembly::LT_S_I32_S;
518 case WebAssembly::LT_S_I64: return WebAssembly::LT_S_I64_S;
519 case WebAssembly::LT_U_I32: return WebAssembly::LT_U_I32_S;
520 case WebAssembly::LT_U_I64: return WebAssembly::LT_U_I64_S;
521 case WebAssembly::MAX_F32: return WebAssembly::MAX_F32_S;
522 case WebAssembly::MAX_F64: return WebAssembly::MAX_F64_S;
523 case WebAssembly::MEMORY_GROW_I32: return WebAssembly::MEMORY_GROW_I32_S;
524 case WebAssembly::MEMORY_SIZE_I32: return WebAssembly::MEMORY_SIZE_I32_S;
525 case WebAssembly::MEM_GROW_I32: return WebAssembly::MEM_GROW_I32_S;
526 case WebAssembly::MEM_SIZE_I32: return WebAssembly::MEM_SIZE_I32_S;
527 case WebAssembly::MIN_F32: return WebAssembly::MIN_F32_S;
528 case WebAssembly::MIN_F64: return WebAssembly::MIN_F64_S;
529 case WebAssembly::MUL_F32: return WebAssembly::MUL_F32_S;
530 case WebAssembly::MUL_F64: return WebAssembly::MUL_F64_S;
531 case WebAssembly::MUL_I32: return WebAssembly::MUL_I32_S;
532 case WebAssembly::MUL_I64: return WebAssembly::MUL_I64_S;
533 case WebAssembly::MUL_v16i8: return WebAssembly::MUL_v16i8_S;
534 case WebAssembly::MUL_v2f64: return WebAssembly::MUL_v2f64_S;
535 case WebAssembly::MUL_v4f32: return WebAssembly::MUL_v4f32_S;
536 case WebAssembly::MUL_v4i32: return WebAssembly::MUL_v4i32_S;
537 case WebAssembly::MUL_v8i16: return WebAssembly::MUL_v8i16_S;
538 case WebAssembly::NEAREST_F32: return WebAssembly::NEAREST_F32_S;
539 case WebAssembly::NEAREST_F64: return WebAssembly::NEAREST_F64_S;
540 case WebAssembly::NEG_F32: return WebAssembly::NEG_F32_S;
541 case WebAssembly::NEG_F64: return WebAssembly::NEG_F64_S;
542 case WebAssembly::NE_F32: return WebAssembly::NE_F32_S;
543 case WebAssembly::NE_F64: return WebAssembly::NE_F64_S;
544 case WebAssembly::NE_I32: return WebAssembly::NE_I32_S;
545 case WebAssembly::NE_I64: return WebAssembly::NE_I64_S;
546 case WebAssembly::NOP: return WebAssembly::NOP_S;
547 case WebAssembly::OR_I32: return WebAssembly::OR_I32_S;
548 case WebAssembly::OR_I64: return WebAssembly::OR_I64_S;
549 case WebAssembly::PCALL_INDIRECT_EXCEPT_REF: return WebAssembly::PCALL_INDIRECT_EXCEPT_REF_S;
550 case WebAssembly::PCALL_INDIRECT_F32: return WebAssembly::PCALL_INDIRECT_F32_S;
551 case WebAssembly::PCALL_INDIRECT_F64: return WebAssembly::PCALL_INDIRECT_F64_S;
552 case WebAssembly::PCALL_INDIRECT_I32: return WebAssembly::PCALL_INDIRECT_I32_S;
553 case WebAssembly::PCALL_INDIRECT_I64: return WebAssembly::PCALL_INDIRECT_I64_S;
554 case WebAssembly::PCALL_INDIRECT_VOID: return WebAssembly::PCALL_INDIRECT_VOID_S;
555 case WebAssembly::PCALL_INDIRECT_v16i8: return WebAssembly::PCALL_INDIRECT_v16i8_S;
556 case WebAssembly::PCALL_INDIRECT_v4f32: return WebAssembly::PCALL_INDIRECT_v4f32_S;
557 case WebAssembly::PCALL_INDIRECT_v4i32: return WebAssembly::PCALL_INDIRECT_v4i32_S;
558 case WebAssembly::PCALL_INDIRECT_v8i16: return WebAssembly::PCALL_INDIRECT_v8i16_S;
559 case WebAssembly::POPCNT_I32: return WebAssembly::POPCNT_I32_S;
560 case WebAssembly::POPCNT_I64: return WebAssembly::POPCNT_I64_S;
561 case WebAssembly::REM_S_I32: return WebAssembly::REM_S_I32_S;
562 case WebAssembly::REM_S_I64: return WebAssembly::REM_S_I64_S;
563 case WebAssembly::REM_U_I32: return WebAssembly::REM_U_I32_S;
564 case WebAssembly::REM_U_I64: return WebAssembly::REM_U_I64_S;
565 case WebAssembly::RETHROW: return WebAssembly::RETHROW_S;
566 case WebAssembly::RETHROW_TO_CALLER: return WebAssembly::RETHROW_TO_CALLER_S;
567 case WebAssembly::RETURN_EXCEPT_REF: return WebAssembly::RETURN_EXCEPT_REF_S;
568 case WebAssembly::RETURN_F32: return WebAssembly::RETURN_F32_S;
569 case WebAssembly::RETURN_F64: return WebAssembly::RETURN_F64_S;
570 case WebAssembly::RETURN_I32: return WebAssembly::RETURN_I32_S;
571 case WebAssembly::RETURN_I64: return WebAssembly::RETURN_I64_S;
572 case WebAssembly::RETURN_VOID: return WebAssembly::RETURN_VOID_S;
573 case WebAssembly::RETURN_v16i8: return WebAssembly::RETURN_v16i8_S;
574 case WebAssembly::RETURN_v4f32: return WebAssembly::RETURN_v4f32_S;
575 case WebAssembly::RETURN_v4i32: return WebAssembly::RETURN_v4i32_S;
576 case WebAssembly::RETURN_v8i16: return WebAssembly::RETURN_v8i16_S;
577 case WebAssembly::ROTL_I32: return WebAssembly::ROTL_I32_S;
578 case WebAssembly::ROTL_I64: return WebAssembly::ROTL_I64_S;
579 case WebAssembly::ROTR_I32: return WebAssembly::ROTR_I32_S;
580 case WebAssembly::ROTR_I64: return WebAssembly::ROTR_I64_S;
581 case WebAssembly::SELECT_EXCEPT_REF: return WebAssembly::SELECT_EXCEPT_REF_S;
582 case WebAssembly::SELECT_F32: return WebAssembly::SELECT_F32_S;
583 case WebAssembly::SELECT_F64: return WebAssembly::SELECT_F64_S;
584 case WebAssembly::SELECT_I32: return WebAssembly::SELECT_I32_S;
585 case WebAssembly::SELECT_I64: return WebAssembly::SELECT_I64_S;
586 case WebAssembly::SET_GLOBAL_EXCEPT_REF: return WebAssembly::SET_GLOBAL_EXCEPT_REF_S;
587 case WebAssembly::SET_GLOBAL_F32: return WebAssembly::SET_GLOBAL_F32_S;
588 case WebAssembly::SET_GLOBAL_F64: return WebAssembly::SET_GLOBAL_F64_S;
589 case WebAssembly::SET_GLOBAL_I32: return WebAssembly::SET_GLOBAL_I32_S;
590 case WebAssembly::SET_GLOBAL_I64: return WebAssembly::SET_GLOBAL_I64_S;
591 case WebAssembly::SET_GLOBAL_V128: return WebAssembly::SET_GLOBAL_V128_S;
592 case WebAssembly::SET_LOCAL_EXCEPT_REF: return WebAssembly::SET_LOCAL_EXCEPT_REF_S;
593 case WebAssembly::SET_LOCAL_F32: return WebAssembly::SET_LOCAL_F32_S;
594 case WebAssembly::SET_LOCAL_F64: return WebAssembly::SET_LOCAL_F64_S;
595 case WebAssembly::SET_LOCAL_I32: return WebAssembly::SET_LOCAL_I32_S;
596 case WebAssembly::SET_LOCAL_I64: return WebAssembly::SET_LOCAL_I64_S;
597 case WebAssembly::SET_LOCAL_V128: return WebAssembly::SET_LOCAL_V128_S;
598 case WebAssembly::SHL_I32: return WebAssembly::SHL_I32_S;
599 case WebAssembly::SHL_I64: return WebAssembly::SHL_I64_S;
600 case WebAssembly::SHR_S_I32: return WebAssembly::SHR_S_I32_S;
601 case WebAssembly::SHR_S_I64: return WebAssembly::SHR_S_I64_S;
602 case WebAssembly::SHR_U_I32: return WebAssembly::SHR_U_I32_S;
603 case WebAssembly::SHR_U_I64: return WebAssembly::SHR_U_I64_S;
604 case WebAssembly::SQRT_F32: return WebAssembly::SQRT_F32_S;
605 case WebAssembly::SQRT_F64: return WebAssembly::SQRT_F64_S;
606 case WebAssembly::STORE16_I32: return WebAssembly::STORE16_I32_S;
607 case WebAssembly::STORE16_I64: return WebAssembly::STORE16_I64_S;
608 case WebAssembly::STORE32_I64: return WebAssembly::STORE32_I64_S;
609 case WebAssembly::STORE8_I32: return WebAssembly::STORE8_I32_S;
610 case WebAssembly::STORE8_I64: return WebAssembly::STORE8_I64_S;
611 case WebAssembly::STORE_F32: return WebAssembly::STORE_F32_S;
612 case WebAssembly::STORE_F64: return WebAssembly::STORE_F64_S;
613 case WebAssembly::STORE_I32: return WebAssembly::STORE_I32_S;
614 case WebAssembly::STORE_I64: return WebAssembly::STORE_I64_S;
615 case WebAssembly::SUB_F32: return WebAssembly::SUB_F32_S;
616 case WebAssembly::SUB_F64: return WebAssembly::SUB_F64_S;
617 case WebAssembly::SUB_I32: return WebAssembly::SUB_I32_S;
618 case WebAssembly::SUB_I64: return WebAssembly::SUB_I64_S;
619 case WebAssembly::SUB_v16i8: return WebAssembly::SUB_v16i8_S;
620 case WebAssembly::SUB_v2f64: return WebAssembly::SUB_v2f64_S;
621 case WebAssembly::SUB_v2i64: return WebAssembly::SUB_v2i64_S;
622 case WebAssembly::SUB_v4f32: return WebAssembly::SUB_v4f32_S;
623 case WebAssembly::SUB_v4i32: return WebAssembly::SUB_v4i32_S;
624 case WebAssembly::SUB_v8i16: return WebAssembly::SUB_v8i16_S;
625 case WebAssembly::TEE_EXCEPT_REF: return WebAssembly::TEE_EXCEPT_REF_S;
626 case WebAssembly::TEE_F32: return WebAssembly::TEE_F32_S;
627 case WebAssembly::TEE_F64: return WebAssembly::TEE_F64_S;
628 case WebAssembly::TEE_I32: return WebAssembly::TEE_I32_S;
629 case WebAssembly::TEE_I64: return WebAssembly::TEE_I64_S;
630 case WebAssembly::TEE_LOCAL_EXCEPT_REF: return WebAssembly::TEE_LOCAL_EXCEPT_REF_S;
631 case WebAssembly::TEE_LOCAL_F32: return WebAssembly::TEE_LOCAL_F32_S;
632 case WebAssembly::TEE_LOCAL_F64: return WebAssembly::TEE_LOCAL_F64_S;
633 case WebAssembly::TEE_LOCAL_I32: return WebAssembly::TEE_LOCAL_I32_S;
634 case WebAssembly::TEE_LOCAL_I64: return WebAssembly::TEE_LOCAL_I64_S;
635 case WebAssembly::TEE_LOCAL_V128: return WebAssembly::TEE_LOCAL_V128_S;
636 case WebAssembly::TEE_V128: return WebAssembly::TEE_V128_S;
637 case WebAssembly::THROW_I32: return WebAssembly::THROW_I32_S;
638 case WebAssembly::THROW_I64: return WebAssembly::THROW_I64_S;
639 case WebAssembly::TRUNC_F32: return WebAssembly::TRUNC_F32_S;
640 case WebAssembly::TRUNC_F64: return WebAssembly::TRUNC_F64_S;
641 case WebAssembly::TRY: return WebAssembly::TRY_S;
642 case WebAssembly::UNREACHABLE: return WebAssembly::UNREACHABLE_S;
643 case WebAssembly::XOR_I32: return WebAssembly::XOR_I32_S;
644 case WebAssembly::XOR_I64: return WebAssembly::XOR_I64_S;
645 }
646 }
293 #include "WebAssemblyGenStackifier.inc"
294 }
295 }
4545 X86ModRMFilters.cpp
4646 X86RecognizableInstr.cpp
4747 WebAssemblyDisassemblerEmitter.cpp
48 WebAssemblyStackifierEmitter.cpp
4849 CTagsEmitter.cpp
4950 )
5051 set_target_properties(llvm-tblgen PROPERTIES FOLDER "Tablegenning")
5252 GenX86EVEX2VEXTables,
5353 GenX86FoldTables,
5454 GenRegisterBank,
55 GenWebAssemblyStackifier,
5556 };
5657
5758 namespace {
116117 clEnumValN(GenX86FoldTables, "gen-x86-fold-tables",
117118 "Generate X86 fold tables"),
118119 clEnumValN(GenRegisterBank, "gen-register-bank",
119 "Generate registers bank descriptions")));
120 "Generate registers bank descriptions"),
121 clEnumValN(GenWebAssemblyStackifier, "gen-wasm-stackifier",
122 "Generate WebAssembly stackification cases")));
120123
121124 cl::OptionCategory PrintEnumsCat("Options for -print-enums");
122125 cl::opt
230233 case GenX86FoldTables:
231234 EmitX86FoldTables(Records, OS);
232235 break;
236 case GenWebAssemblyStackifier:
237 EmitWebAssemblyStackifier(Records, OS);
238 break;
233239 }
234240
235241 return false;
8888 void EmitX86EVEX2VEXTables(RecordKeeper &RK, raw_ostream &OS);
8989 void EmitX86FoldTables(RecordKeeper &RK, raw_ostream &OS);
9090 void EmitRegisterBank(RecordKeeper &RK, raw_ostream &OS);
91 void EmitWebAssemblyStackifier(RecordKeeper &RK, raw_ostream &OS);
9192
9293 } // End llvm namespace
9394
0 //===- WebAssemblyStackifierEmitter.cpp - Stackifier cases ------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file emits the switch statement cases to translate WebAssembly
10 // instructions to their stack forms.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "WebAssemblyDisassemblerEmitter.h"
15 #include "llvm/TableGen/Record.h"
16
17 namespace llvm {
18
19 void EmitWebAssemblyStackifier(RecordKeeper &RK, raw_ostream &OS) {
20 Record *InstrClass = RK.getClass("WebAssemblyInst");
21 for (auto &RecordPair : RK.getDefs()) {
22 if (!RecordPair.second->isSubClassOf(InstrClass)) continue;
23 bool IsStackBased = RecordPair.second->getValueAsBit("StackBased");
24 if (IsStackBased) continue;
25 OS << " case WebAssembly::" << RecordPair.first << ": return "
26 << "WebAssembly::" << RecordPair.first << "_S; break;\n";
27 }
28 }
29
30 } // namespace llvm