github.com/bananabytelabs/wazero@v0.0.0-20240105073314-54b22a776da8/internal/engine/wazevo/backend/backend_test.go (about) 1 package backend_test 2 3 import ( 4 "context" 5 "fmt" 6 "os" 7 "runtime" 8 "testing" 9 10 "github.com/bananabytelabs/wazero/internal/engine/wazevo/backend" 11 "github.com/bananabytelabs/wazero/internal/engine/wazevo/backend/isa/arm64" 12 "github.com/bananabytelabs/wazero/internal/engine/wazevo/frontend" 13 "github.com/bananabytelabs/wazero/internal/engine/wazevo/ssa" 14 "github.com/bananabytelabs/wazero/internal/engine/wazevo/testcases" 15 "github.com/bananabytelabs/wazero/internal/engine/wazevo/wazevoapi" 16 "github.com/bananabytelabs/wazero/internal/testing/require" 17 "github.com/bananabytelabs/wazero/internal/wasm" 18 ) 19 20 func TestMain(m *testing.M) { 21 if runtime.GOARCH != "arm64" { 22 os.Exit(0) 23 } 24 os.Exit(m.Run()) 25 } 26 27 func newMachine() backend.Machine { 28 switch runtime.GOARCH { 29 case "arm64": 30 return arm64.NewBackend() 31 default: 32 panic("unsupported architecture") 33 } 34 } 35 36 func TestE2E(t *testing.T) { 37 const verbose = false 38 39 type testCase struct { 40 name string 41 m *wasm.Module 42 targetIndex uint32 43 afterLoweringARM64, afterFinalizeARM64 string 44 // TODO: amd64. 45 } 46 47 for _, tc := range []testCase{ 48 { 49 name: "empty", m: testcases.Empty.Module, 50 afterLoweringARM64: ` 51 L1 (SSA Block: blk0): 52 ret 53 `, 54 afterFinalizeARM64: ` 55 L1 (SSA Block: blk0): 56 stp x30, xzr, [sp, #-0x10]! 57 str xzr, [sp, #-0x10]! 58 add sp, sp, #0x10 59 ldr x30, [sp], #0x10 60 ret 61 `, 62 }, 63 { 64 name: "selects", m: testcases.Selects.Module, 65 afterFinalizeARM64: ` 66 L1 (SSA Block: blk0): 67 stp x30, xzr, [sp, #-0x10]! 68 str xzr, [sp, #-0x10]! 69 subs xzr, x4, x5 70 csel w8, w2, w3, eq 71 subs wzr, w3, wzr 72 csel x9, x4, x5, ne 73 fcmp d2, d3 74 fcsel s8, s0, s1, gt 75 fcmp s0, s1 76 fcsel d9, d2, d3, ne 77 mov v1.8b, v9.8b 78 mov v0.8b, v8.8b 79 mov x1, x9 80 mov x0, x8 81 add sp, sp, #0x10 82 ldr x30, [sp], #0x10 83 ret 84 `, 85 }, 86 { 87 name: "consts", m: testcases.Constants.Module, 88 afterLoweringARM64: ` 89 L1 (SSA Block: blk0): 90 ldr d133?, #8; b 16; data.f64 64.000000 91 mov v1.8b, v133?.8b 92 ldr s132?, #8; b 8; data.f32 32.000000 93 mov v0.8b, v132?.8b 94 orr x131?, xzr, #0x2 95 mov x1, x131? 96 orr w130?, wzr, #0x1 97 mov x0, x130? 98 ret 99 `, 100 afterFinalizeARM64: ` 101 L1 (SSA Block: blk0): 102 stp x30, xzr, [sp, #-0x10]! 103 str xzr, [sp, #-0x10]! 104 ldr d8, #8; b 16; data.f64 64.000000 105 mov v1.8b, v8.8b 106 ldr s8, #8; b 8; data.f32 32.000000 107 mov v0.8b, v8.8b 108 orr x8, xzr, #0x2 109 mov x1, x8 110 orr w8, wzr, #0x1 111 mov x0, x8 112 add sp, sp, #0x10 113 ldr x30, [sp], #0x10 114 ret 115 `, 116 }, 117 { 118 name: "add sub params return", m: testcases.AddSubParamsReturn.Module, 119 afterLoweringARM64: ` 120 L1 (SSA Block: blk0): 121 mov x130?, x2 122 mov x131?, x3 123 add w132?, w130?, w131? 124 sub w133?, w132?, w130? 125 mov x0, x133? 126 ret 127 `, 128 afterFinalizeARM64: ` 129 L1 (SSA Block: blk0): 130 stp x30, xzr, [sp, #-0x10]! 131 str xzr, [sp, #-0x10]! 132 add w8, w2, w3 133 sub w8, w8, w2 134 mov x0, x8 135 add sp, sp, #0x10 136 ldr x30, [sp], #0x10 137 ret 138 `, 139 }, 140 { 141 name: "locals params", m: testcases.LocalsParams.Module, 142 afterLoweringARM64: ` 143 L1 (SSA Block: blk0): 144 mov x130?, x2 145 mov v131?.8b, v0.8b 146 mov v132?.8b, v1.8b 147 add x133?, x130?, x130? 148 sub x134?, x133?, x130? 149 fadd s135?, s131?, s131? 150 fsub s136?, s135?, s131? 151 fmul s137?, s136?, s131? 152 fdiv s138?, s137?, s131? 153 fmax s139?, s138?, s131? 154 fmin s140?, s139?, s131? 155 fadd d141?, d132?, d132? 156 fsub d142?, d141?, d132? 157 fmul d143?, d142?, d132? 158 fdiv d144?, d143?, d132? 159 fmax d145?, d144?, d132? 160 fmin d146?, d145?, d132? 161 mov v1.8b, v146?.8b 162 mov v0.8b, v140?.8b 163 mov x0, x134? 164 ret 165 `, 166 afterFinalizeARM64: ` 167 L1 (SSA Block: blk0): 168 stp x30, xzr, [sp, #-0x10]! 169 str xzr, [sp, #-0x10]! 170 add x8, x2, x2 171 sub x8, x8, x2 172 fadd s8, s0, s0 173 fsub s8, s8, s0 174 fmul s8, s8, s0 175 fdiv s8, s8, s0 176 fmax s8, s8, s0 177 fmin s8, s8, s0 178 fadd d9, d1, d1 179 fsub d9, d9, d1 180 fmul d9, d9, d1 181 fdiv d9, d9, d1 182 fmax d9, d9, d1 183 fmin d9, d9, d1 184 mov v1.8b, v9.8b 185 mov v0.8b, v8.8b 186 mov x0, x8 187 add sp, sp, #0x10 188 ldr x30, [sp], #0x10 189 ret 190 `, 191 }, 192 { 193 name: "local_param_return", m: testcases.LocalParamReturn.Module, 194 afterLoweringARM64: ` 195 L1 (SSA Block: blk0): 196 mov x130?, x2 197 mov x131?, xzr 198 mov x1, x131? 199 mov x0, x130? 200 ret 201 `, 202 afterFinalizeARM64: ` 203 L1 (SSA Block: blk0): 204 stp x30, xzr, [sp, #-0x10]! 205 str xzr, [sp, #-0x10]! 206 mov x8, xzr 207 mov x1, x8 208 mov x0, x2 209 add sp, sp, #0x10 210 ldr x30, [sp], #0x10 211 ret 212 `, 213 }, 214 { 215 name: "swap_param_and_return", m: testcases.SwapParamAndReturn.Module, 216 afterLoweringARM64: ` 217 L1 (SSA Block: blk0): 218 mov x130?, x2 219 mov x131?, x3 220 mov x1, x130? 221 mov x0, x131? 222 ret 223 `, 224 afterFinalizeARM64: ` 225 L1 (SSA Block: blk0): 226 stp x30, xzr, [sp, #-0x10]! 227 str xzr, [sp, #-0x10]! 228 mov x1, x2 229 mov x0, x3 230 add sp, sp, #0x10 231 ldr x30, [sp], #0x10 232 ret 233 `, 234 }, 235 { 236 name: "swap_params_and_return", m: testcases.SwapParamsAndReturn.Module, 237 afterLoweringARM64: ` 238 L1 (SSA Block: blk0): 239 mov x130?, x2 240 mov x131?, x3 241 L2 (SSA Block: blk1): 242 mov x1, x130? 243 mov x0, x131? 244 ret 245 `, 246 afterFinalizeARM64: ` 247 L1 (SSA Block: blk0): 248 stp x30, xzr, [sp, #-0x10]! 249 str xzr, [sp, #-0x10]! 250 L2 (SSA Block: blk1): 251 mov x1, x2 252 mov x0, x3 253 add sp, sp, #0x10 254 ldr x30, [sp], #0x10 255 ret 256 `, 257 }, 258 { 259 name: "block_br", m: testcases.BlockBr.Module, 260 afterLoweringARM64: ` 261 L1 (SSA Block: blk0): 262 L2 (SSA Block: blk1): 263 ret 264 `, 265 afterFinalizeARM64: ` 266 L1 (SSA Block: blk0): 267 stp x30, xzr, [sp, #-0x10]! 268 str xzr, [sp, #-0x10]! 269 L2 (SSA Block: blk1): 270 add sp, sp, #0x10 271 ldr x30, [sp], #0x10 272 ret 273 `, 274 }, 275 { 276 name: "block_br_if", m: testcases.BlockBrIf.Module, 277 afterLoweringARM64: ` 278 L1 (SSA Block: blk0): 279 mov x128?, x0 280 mov x131?, xzr 281 cbnz w131?, L2 282 L3 (SSA Block: blk2): 283 movz x132?, #0x3, lsl 0 284 str w132?, [x128?] 285 mov x133?, sp 286 str x133?, [x128?, #0x38] 287 adr x134?, #0x0 288 str x134?, [x128?, #0x30] 289 exit_sequence x128? 290 L2 (SSA Block: blk1): 291 ret 292 `, 293 afterFinalizeARM64: ` 294 L1 (SSA Block: blk0): 295 stp x30, xzr, [sp, #-0x10]! 296 str xzr, [sp, #-0x10]! 297 mov x8, xzr 298 cbnz w8, #0x34 (L2) 299 L3 (SSA Block: blk2): 300 movz x8, #0x3, lsl 0 301 str w8, [x0] 302 mov x8, sp 303 str x8, [x0, #0x38] 304 adr x8, #0x0 305 str x8, [x0, #0x30] 306 exit_sequence x0 307 L2 (SSA Block: blk1): 308 add sp, sp, #0x10 309 ldr x30, [sp], #0x10 310 ret 311 `, 312 }, 313 { 314 name: "loop_br", m: testcases.LoopBr.Module, 315 afterLoweringARM64: ` 316 L1 (SSA Block: blk0): 317 L2 (SSA Block: blk1): 318 b L2 319 `, 320 afterFinalizeARM64: ` 321 L1 (SSA Block: blk0): 322 stp x30, xzr, [sp, #-0x10]! 323 str xzr, [sp, #-0x10]! 324 L2 (SSA Block: blk1): 325 b #0x0 (L2) 326 `, 327 }, 328 { 329 name: "loop_with_param_results", m: testcases.LoopBrWithParamResults.Module, 330 afterLoweringARM64: ` 331 L1 (SSA Block: blk0): 332 mov x130?, x2 333 L2 (SSA Block: blk1): 334 orr w133?, wzr, #0x1 335 cbz w133?, (L3) 336 L4 (SSA Block: blk4): 337 b L2 338 L3 (SSA Block: blk3): 339 L5 (SSA Block: blk2): 340 mov x0, x130? 341 ret 342 `, 343 afterFinalizeARM64: ` 344 L1 (SSA Block: blk0): 345 stp x30, xzr, [sp, #-0x10]! 346 str xzr, [sp, #-0x10]! 347 L2 (SSA Block: blk1): 348 orr w8, wzr, #0x1 349 cbz w8, #0x8 L3 350 L4 (SSA Block: blk4): 351 b #-0x8 (L2) 352 L3 (SSA Block: blk3): 353 L5 (SSA Block: blk2): 354 mov x0, x2 355 add sp, sp, #0x10 356 ldr x30, [sp], #0x10 357 ret 358 `, 359 }, 360 { 361 name: "loop_br_if", m: testcases.LoopBrIf.Module, 362 afterLoweringARM64: ` 363 L1 (SSA Block: blk0): 364 L2 (SSA Block: blk1): 365 orr w131?, wzr, #0x1 366 cbz w131?, (L3) 367 L4 (SSA Block: blk4): 368 b L2 369 L3 (SSA Block: blk3): 370 ret 371 `, 372 afterFinalizeARM64: ` 373 L1 (SSA Block: blk0): 374 stp x30, xzr, [sp, #-0x10]! 375 str xzr, [sp, #-0x10]! 376 L2 (SSA Block: blk1): 377 orr w8, wzr, #0x1 378 cbz w8, #0x8 L3 379 L4 (SSA Block: blk4): 380 b #-0x8 (L2) 381 L3 (SSA Block: blk3): 382 add sp, sp, #0x10 383 ldr x30, [sp], #0x10 384 ret 385 `, 386 }, 387 { 388 name: "block_block_br", m: testcases.BlockBlockBr.Module, 389 afterLoweringARM64: ` 390 L1 (SSA Block: blk0): 391 L2 (SSA Block: blk1): 392 ret 393 `, 394 afterFinalizeARM64: ` 395 L1 (SSA Block: blk0): 396 stp x30, xzr, [sp, #-0x10]! 397 str xzr, [sp, #-0x10]! 398 L2 (SSA Block: blk1): 399 add sp, sp, #0x10 400 ldr x30, [sp], #0x10 401 ret 402 `, 403 }, 404 { 405 name: "if_without_else", m: testcases.IfWithoutElse.Module, 406 // Note: The block of "b L4" seems redundant, but it is needed when we need to insert return value preparations. 407 // So we cannot have the general optimization on this kind of redundant branch elimination before register allocations. 408 // Instead, we can do it during the code generation phase where we actually resolve the label offsets. 409 afterLoweringARM64: ` 410 L1 (SSA Block: blk0): 411 mov x131?, xzr 412 cbz w131?, (L2) 413 L3 (SSA Block: blk1): 414 b L4 415 L2 (SSA Block: blk2): 416 L4 (SSA Block: blk3): 417 ret 418 `, 419 afterFinalizeARM64: ` 420 L1 (SSA Block: blk0): 421 stp x30, xzr, [sp, #-0x10]! 422 str xzr, [sp, #-0x10]! 423 mov x8, xzr 424 cbz w8, #0x8 L2 425 L3 (SSA Block: blk1): 426 b #0x4 (L4) 427 L2 (SSA Block: blk2): 428 L4 (SSA Block: blk3): 429 add sp, sp, #0x10 430 ldr x30, [sp], #0x10 431 ret 432 `, 433 }, 434 { 435 name: "if_else", m: testcases.IfElse.Module, 436 afterLoweringARM64: ` 437 L1 (SSA Block: blk0): 438 mov x131?, xzr 439 cbz w131?, (L2) 440 L3 (SSA Block: blk1): 441 L4 (SSA Block: blk3): 442 ret 443 L2 (SSA Block: blk2): 444 ret 445 `, 446 afterFinalizeARM64: ` 447 L1 (SSA Block: blk0): 448 stp x30, xzr, [sp, #-0x10]! 449 str xzr, [sp, #-0x10]! 450 mov x8, xzr 451 cbz w8, #0x10 L2 452 L3 (SSA Block: blk1): 453 L4 (SSA Block: blk3): 454 add sp, sp, #0x10 455 ldr x30, [sp], #0x10 456 ret 457 L2 (SSA Block: blk2): 458 add sp, sp, #0x10 459 ldr x30, [sp], #0x10 460 ret 461 `, 462 }, 463 { 464 name: "single_predecessor_local_refs", m: testcases.SinglePredecessorLocalRefs.Module, 465 afterLoweringARM64: ` 466 L1 (SSA Block: blk0): 467 mov x132?, xzr 468 cbz w132?, (L2) 469 L3 (SSA Block: blk1): 470 mov x131?, xzr 471 mov x0, x131? 472 ret 473 L2 (SSA Block: blk2): 474 L4 (SSA Block: blk3): 475 mov x130?, xzr 476 mov x0, x130? 477 ret 478 `, 479 afterFinalizeARM64: ` 480 L1 (SSA Block: blk0): 481 stp x30, xzr, [sp, #-0x10]! 482 str xzr, [sp, #-0x10]! 483 mov x8, xzr 484 cbz w8, #0x18 L2 485 L3 (SSA Block: blk1): 486 mov x8, xzr 487 mov x0, x8 488 add sp, sp, #0x10 489 ldr x30, [sp], #0x10 490 ret 491 L2 (SSA Block: blk2): 492 L4 (SSA Block: blk3): 493 mov x8, xzr 494 mov x0, x8 495 add sp, sp, #0x10 496 ldr x30, [sp], #0x10 497 ret 498 `, 499 }, 500 { 501 name: "multi_predecessor_local_ref", m: testcases.MultiPredecessorLocalRef.Module, 502 afterLoweringARM64: ` 503 L1 (SSA Block: blk0): 504 mov x130?, x2 505 mov x131?, x3 506 cbz w130?, (L2) 507 L3 (SSA Block: blk1): 508 mov x132?, x130? 509 b L4 510 L2 (SSA Block: blk2): 511 mov x132?, x131? 512 L4 (SSA Block: blk3): 513 mov x0, x132? 514 ret 515 `, 516 afterFinalizeARM64: ` 517 L1 (SSA Block: blk0): 518 stp x30, xzr, [sp, #-0x10]! 519 str xzr, [sp, #-0x10]! 520 cbz w2, #0x8 L2 521 L3 (SSA Block: blk1): 522 b #0x8 (L4) 523 L2 (SSA Block: blk2): 524 mov x2, x3 525 L4 (SSA Block: blk3): 526 mov x0, x2 527 add sp, sp, #0x10 528 ldr x30, [sp], #0x10 529 ret 530 `, 531 }, 532 { 533 name: "reference_value_from_unsealed_block", m: testcases.ReferenceValueFromUnsealedBlock.Module, 534 afterLoweringARM64: ` 535 L1 (SSA Block: blk0): 536 mov x130?, x2 537 L2 (SSA Block: blk1): 538 mov x0, x130? 539 ret 540 `, 541 afterFinalizeARM64: ` 542 L1 (SSA Block: blk0): 543 stp x30, xzr, [sp, #-0x10]! 544 str xzr, [sp, #-0x10]! 545 L2 (SSA Block: blk1): 546 mov x0, x2 547 add sp, sp, #0x10 548 ldr x30, [sp], #0x10 549 ret 550 `, 551 }, 552 { 553 name: "reference_value_from_unsealed_block2", m: testcases.ReferenceValueFromUnsealedBlock2.Module, 554 afterLoweringARM64: ` 555 L1 (SSA Block: blk0): 556 mov x130?, x2 557 L2 (SSA Block: blk1): 558 cbz w130?, (L3) 559 L4 (SSA Block: blk5): 560 b L2 561 L3 (SSA Block: blk4): 562 L5 (SSA Block: blk3): 563 L6 (SSA Block: blk2): 564 mov x131?, xzr 565 mov x0, x131? 566 ret 567 `, 568 afterFinalizeARM64: ` 569 L1 (SSA Block: blk0): 570 stp x30, xzr, [sp, #-0x10]! 571 str xzr, [sp, #-0x10]! 572 L2 (SSA Block: blk1): 573 cbz w2, #0x8 L3 574 L4 (SSA Block: blk5): 575 b #-0x4 (L2) 576 L3 (SSA Block: blk4): 577 L5 (SSA Block: blk3): 578 L6 (SSA Block: blk2): 579 mov x8, xzr 580 mov x0, x8 581 add sp, sp, #0x10 582 ldr x30, [sp], #0x10 583 ret 584 `, 585 }, 586 { 587 name: "reference_value_from_unsealed_block3", m: testcases.ReferenceValueFromUnsealedBlock3.Module, 588 // TODO: we should be able to invert cbnz in so that L2 can end with fallthrough. investigate builder.LayoutBlocks function. 589 afterLoweringARM64: ` 590 L1 (SSA Block: blk0): 591 mov x130?, x2 592 mov x131?, x130? 593 L2 (SSA Block: blk1): 594 cbnz w131?, L4 595 b L3 596 L4 (SSA Block: blk5): 597 ret 598 L3 (SSA Block: blk4): 599 L5 (SSA Block: blk3): 600 orr w131?, wzr, #0x1 601 b L2 602 `, 603 afterFinalizeARM64: ` 604 L1 (SSA Block: blk0): 605 stp x30, xzr, [sp, #-0x10]! 606 str xzr, [sp, #-0x10]! 607 L2 (SSA Block: blk1): 608 cbnz w2, #0x8 (L4) 609 b #0x10 (L3) 610 L4 (SSA Block: blk5): 611 add sp, sp, #0x10 612 ldr x30, [sp], #0x10 613 ret 614 L3 (SSA Block: blk4): 615 L5 (SSA Block: blk3): 616 orr w8, wzr, #0x1 617 mov x2, x8 618 b #-0x1c (L2) 619 `, 620 }, 621 { 622 name: "call", m: testcases.Call.Module, 623 afterLoweringARM64: ` 624 L1 (SSA Block: blk0): 625 mov x128?, x0 626 mov x129?, x1 627 str x129?, [x128?, #0x8] 628 mov x0, x128? 629 mov x1, x129? 630 bl f1 631 mov x130?, x0 632 str x129?, [x128?, #0x8] 633 mov x0, x128? 634 mov x1, x129? 635 mov x2, x130? 636 movz w131?, #0x5, lsl 0 637 mov x3, x131? 638 bl f2 639 mov x132?, x0 640 str x129?, [x128?, #0x8] 641 mov x0, x128? 642 mov x1, x129? 643 mov x2, x132? 644 bl f3 645 mov x133?, x0 646 mov x134?, x1 647 mov x1, x134? 648 mov x0, x133? 649 ret 650 `, 651 afterFinalizeARM64: ` 652 L1 (SSA Block: blk0): 653 stp x30, xzr, [sp, #-0x10]! 654 sub sp, sp, #0x20 655 orr x27, xzr, #0x20 656 str x27, [sp, #-0x10]! 657 str x0, [sp, #0x18] 658 str x1, [sp, #0x10] 659 str x1, [x0, #0x8] 660 bl f1 661 str w0, [sp, #0x20] 662 ldr x8, [sp, #0x10] 663 ldr x9, [sp, #0x18] 664 str x8, [x9, #0x8] 665 mov x0, x9 666 mov x1, x8 667 ldr w10, [sp, #0x20] 668 mov x2, x10 669 movz w10, #0x5, lsl 0 670 mov x3, x10 671 bl f2 672 str w0, [sp, #0x24] 673 ldr x8, [sp, #0x10] 674 ldr x9, [sp, #0x18] 675 str x8, [x9, #0x8] 676 mov x0, x9 677 mov x1, x8 678 ldr w8, [sp, #0x24] 679 mov x2, x8 680 bl f3 681 add sp, sp, #0x10 682 add sp, sp, #0x20 683 ldr x30, [sp], #0x10 684 ret 685 `, 686 }, 687 { 688 name: "call_many_params", m: testcases.CallManyParams.Module, 689 afterLoweringARM64: ` 690 L1 (SSA Block: blk0): 691 mov x128?, x0 692 mov x129?, x1 693 mov x130?, x2 694 mov x131?, x3 695 mov v132?.8b, v0.8b 696 mov v133?.8b, v1.8b 697 str x129?, [x128?, #0x8] 698 mov x0, x128? 699 mov x1, x129? 700 mov x2, x130? 701 mov x3, x131? 702 mov v0.8b, v132?.8b 703 mov v1.8b, v133?.8b 704 mov x4, x130? 705 mov x5, x131? 706 mov v2.8b, v132?.8b 707 mov v3.8b, v133?.8b 708 mov x6, x130? 709 mov x7, x131? 710 mov v4.8b, v132?.8b 711 mov v5.8b, v133?.8b 712 str w130?, [sp, #-0xd0] 713 str x131?, [sp, #-0xc8] 714 mov v6.8b, v132?.8b 715 mov v7.8b, v133?.8b 716 str w130?, [sp, #-0xc0] 717 str x131?, [sp, #-0xb8] 718 str s132?, [sp, #-0xb0] 719 str d133?, [sp, #-0xa8] 720 str w130?, [sp, #-0xa0] 721 str x131?, [sp, #-0x98] 722 str s132?, [sp, #-0x90] 723 str d133?, [sp, #-0x88] 724 str w130?, [sp, #-0x80] 725 str x131?, [sp, #-0x78] 726 str s132?, [sp, #-0x70] 727 str d133?, [sp, #-0x68] 728 str w130?, [sp, #-0x60] 729 str x131?, [sp, #-0x58] 730 str s132?, [sp, #-0x50] 731 str d133?, [sp, #-0x48] 732 str w130?, [sp, #-0x40] 733 str x131?, [sp, #-0x38] 734 str s132?, [sp, #-0x30] 735 str d133?, [sp, #-0x28] 736 str w130?, [sp, #-0x20] 737 str x131?, [sp, #-0x18] 738 str s132?, [sp, #-0x10] 739 str d133?, [sp, #-0x8] 740 bl f1 741 ret 742 `, 743 afterFinalizeARM64: ` 744 L1 (SSA Block: blk0): 745 stp x30, xzr, [sp, #-0x10]! 746 sub sp, sp, #0x20 747 orr x27, xzr, #0x20 748 str x27, [sp, #-0x10]! 749 str w2, [sp, #0x10] 750 str x3, [sp, #0x14] 751 str s0, [sp, #0x1c] 752 str d1, [sp, #0x20] 753 str x1, [x0, #0x8] 754 ldr w8, [sp, #0x10] 755 mov x4, x8 756 ldr x9, [sp, #0x14] 757 mov x5, x9 758 ldr s8, [sp, #0x1c] 759 mov v2.8b, v8.8b 760 ldr d9, [sp, #0x20] 761 mov v3.8b, v9.8b 762 mov x6, x8 763 mov x7, x9 764 mov v4.8b, v8.8b 765 mov v5.8b, v9.8b 766 str w8, [sp, #-0xd0] 767 str x9, [sp, #-0xc8] 768 mov v6.8b, v8.8b 769 mov v7.8b, v9.8b 770 str w8, [sp, #-0xc0] 771 str x9, [sp, #-0xb8] 772 str s8, [sp, #-0xb0] 773 str d9, [sp, #-0xa8] 774 str w8, [sp, #-0xa0] 775 str x9, [sp, #-0x98] 776 str s8, [sp, #-0x90] 777 str d9, [sp, #-0x88] 778 str w8, [sp, #-0x80] 779 str x9, [sp, #-0x78] 780 str s8, [sp, #-0x70] 781 str d9, [sp, #-0x68] 782 str w8, [sp, #-0x60] 783 str x9, [sp, #-0x58] 784 str s8, [sp, #-0x50] 785 str d9, [sp, #-0x48] 786 str w8, [sp, #-0x40] 787 str x9, [sp, #-0x38] 788 str s8, [sp, #-0x30] 789 str d9, [sp, #-0x28] 790 str w8, [sp, #-0x20] 791 str x9, [sp, #-0x18] 792 str s8, [sp, #-0x10] 793 str d9, [sp, #-0x8] 794 bl f1 795 add sp, sp, #0x10 796 add sp, sp, #0x20 797 ldr x30, [sp], #0x10 798 ret 799 `, 800 }, 801 { 802 name: "call_many_returns", m: testcases.CallManyReturns.Module, 803 afterLoweringARM64: ` 804 L1 (SSA Block: blk0): 805 mov x128?, x0 806 mov x129?, x1 807 mov x130?, x2 808 mov x131?, x3 809 mov v132?.8b, v0.8b 810 mov v133?.8b, v1.8b 811 str x129?, [x128?, #0x8] 812 mov x0, x128? 813 mov x1, x129? 814 mov x2, x130? 815 mov x3, x131? 816 mov v0.8b, v132?.8b 817 mov v1.8b, v133?.8b 818 bl f1 819 mov x134?, x0 820 mov x135?, x1 821 mov v136?.8b, v0.8b 822 mov v137?.8b, v1.8b 823 mov x138?, x2 824 mov x139?, x3 825 mov v140?.8b, v2.8b 826 mov v141?.8b, v3.8b 827 mov x142?, x4 828 mov x143?, x5 829 mov v144?.8b, v4.8b 830 mov v145?.8b, v5.8b 831 mov x146?, x6 832 mov x147?, x7 833 mov v148?.8b, v6.8b 834 mov v149?.8b, v7.8b 835 ldr w150?, [sp, #-0xc0] 836 ldr x151?, [sp, #-0xb8] 837 ldr s152?, [sp, #-0xb0] 838 ldr d153?, [sp, #-0xa8] 839 ldr w154?, [sp, #-0xa0] 840 ldr x155?, [sp, #-0x98] 841 ldr s156?, [sp, #-0x90] 842 ldr d157?, [sp, #-0x88] 843 ldr w158?, [sp, #-0x80] 844 ldr x159?, [sp, #-0x78] 845 ldr s160?, [sp, #-0x70] 846 ldr d161?, [sp, #-0x68] 847 ldr w162?, [sp, #-0x60] 848 ldr x163?, [sp, #-0x58] 849 ldr s164?, [sp, #-0x50] 850 ldr d165?, [sp, #-0x48] 851 ldr w166?, [sp, #-0x40] 852 ldr x167?, [sp, #-0x38] 853 ldr s168?, [sp, #-0x30] 854 ldr d169?, [sp, #-0x28] 855 ldr w170?, [sp, #-0x20] 856 ldr x171?, [sp, #-0x18] 857 ldr s172?, [sp, #-0x10] 858 ldr d173?, [sp, #-0x8] 859 str d173?, [#ret_space, #0xb8] 860 str s172?, [#ret_space, #0xb0] 861 str x171?, [#ret_space, #0xa8] 862 str w170?, [#ret_space, #0xa0] 863 str d169?, [#ret_space, #0x98] 864 str s168?, [#ret_space, #0x90] 865 str x167?, [#ret_space, #0x88] 866 str w166?, [#ret_space, #0x80] 867 str d165?, [#ret_space, #0x78] 868 str s164?, [#ret_space, #0x70] 869 str x163?, [#ret_space, #0x68] 870 str w162?, [#ret_space, #0x60] 871 str d161?, [#ret_space, #0x58] 872 str s160?, [#ret_space, #0x50] 873 str x159?, [#ret_space, #0x48] 874 str w158?, [#ret_space, #0x40] 875 str d157?, [#ret_space, #0x38] 876 str s156?, [#ret_space, #0x30] 877 str x155?, [#ret_space, #0x28] 878 str w154?, [#ret_space, #0x20] 879 str d153?, [#ret_space, #0x18] 880 str s152?, [#ret_space, #0x10] 881 str x151?, [#ret_space, #0x8] 882 str w150?, [#ret_space, #0x0] 883 mov v7.8b, v149?.8b 884 mov v6.8b, v148?.8b 885 mov x7, x147? 886 mov x6, x146? 887 mov v5.8b, v145?.8b 888 mov v4.8b, v144?.8b 889 mov x5, x143? 890 mov x4, x142? 891 mov v3.8b, v141?.8b 892 mov v2.8b, v140?.8b 893 mov x3, x139? 894 mov x2, x138? 895 mov v1.8b, v137?.8b 896 mov v0.8b, v136?.8b 897 mov x1, x135? 898 mov x0, x134? 899 ret 900 `, 901 afterFinalizeARM64: ` 902 L1 (SSA Block: blk0): 903 orr x27, xzr, #0xc0 904 sub sp, sp, x27 905 stp x30, x27, [sp, #-0x10]! 906 str x19, [sp, #-0x10]! 907 str x20, [sp, #-0x10]! 908 str q18, [sp, #-0x10]! 909 str q19, [sp, #-0x10]! 910 orr x27, xzr, #0x40 911 str x27, [sp, #-0x10]! 912 str x1, [x0, #0x8] 913 bl f1 914 ldr w8, [sp, #-0xc0] 915 ldr x9, [sp, #-0xb8] 916 ldr s8, [sp, #-0xb0] 917 ldr d9, [sp, #-0xa8] 918 ldr w10, [sp, #-0xa0] 919 ldr x11, [sp, #-0x98] 920 ldr s10, [sp, #-0x90] 921 ldr d11, [sp, #-0x88] 922 ldr w12, [sp, #-0x80] 923 ldr x13, [sp, #-0x78] 924 ldr s12, [sp, #-0x70] 925 ldr d13, [sp, #-0x68] 926 ldr w14, [sp, #-0x60] 927 ldr x15, [sp, #-0x58] 928 ldr s14, [sp, #-0x50] 929 ldr d15, [sp, #-0x48] 930 ldr w16, [sp, #-0x40] 931 ldr x17, [sp, #-0x38] 932 ldr s16, [sp, #-0x30] 933 ldr d17, [sp, #-0x28] 934 ldr w19, [sp, #-0x20] 935 ldr x20, [sp, #-0x18] 936 ldr s18, [sp, #-0x10] 937 ldr d19, [sp, #-0x8] 938 str d19, [sp, #0x118] 939 str s18, [sp, #0x110] 940 str x20, [sp, #0x108] 941 str w19, [sp, #0x100] 942 str d17, [sp, #0xf8] 943 str s16, [sp, #0xf0] 944 str x17, [sp, #0xe8] 945 str w16, [sp, #0xe0] 946 str d15, [sp, #0xd8] 947 str s14, [sp, #0xd0] 948 str x15, [sp, #0xc8] 949 str w14, [sp, #0xc0] 950 str d13, [sp, #0xb8] 951 str s12, [sp, #0xb0] 952 str x13, [sp, #0xa8] 953 str w12, [sp, #0xa0] 954 str d11, [sp, #0x98] 955 str s10, [sp, #0x90] 956 str x11, [sp, #0x88] 957 str w10, [sp, #0x80] 958 str d9, [sp, #0x78] 959 str s8, [sp, #0x70] 960 str x9, [sp, #0x68] 961 str w8, [sp, #0x60] 962 add sp, sp, #0x10 963 ldr q19, [sp], #0x10 964 ldr q18, [sp], #0x10 965 ldr x20, [sp], #0x10 966 ldr x19, [sp], #0x10 967 ldr x30, [sp], #0x10 968 add sp, sp, #0xc0 969 ret 970 `, 971 }, 972 { 973 name: "integer_extensions", 974 m: testcases.IntegerExtensions.Module, 975 afterLoweringARM64: ` 976 L1 (SSA Block: blk0): 977 mov x130?, x2 978 mov x131?, x3 979 sxtw x132?, w130? 980 uxtw x133?, w130? 981 sxtb x134?, w131? 982 sxth x135?, w131? 983 sxtw x136?, w131? 984 sxtb w137?, w130? 985 sxth w138?, w130? 986 mov x6, x138? 987 mov x5, x137? 988 mov x4, x136? 989 mov x3, x135? 990 mov x2, x134? 991 mov x1, x133? 992 mov x0, x132? 993 ret 994 `, 995 afterFinalizeARM64: ` 996 L1 (SSA Block: blk0): 997 stp x30, xzr, [sp, #-0x10]! 998 str xzr, [sp, #-0x10]! 999 sxtw x8, w2 1000 uxtw x9, w2 1001 sxtb x10, w3 1002 sxth x11, w3 1003 sxtw x12, w3 1004 sxtb w13, w2 1005 sxth w14, w2 1006 mov x6, x14 1007 mov x5, x13 1008 mov x4, x12 1009 mov x3, x11 1010 mov x2, x10 1011 mov x1, x9 1012 mov x0, x8 1013 add sp, sp, #0x10 1014 ldr x30, [sp], #0x10 1015 ret 1016 `, 1017 }, 1018 { 1019 name: "integer bit counts", m: testcases.IntegerBitCounts.Module, 1020 afterLoweringARM64: ` 1021 L1 (SSA Block: blk0): 1022 mov x130?, x2 1023 mov x131?, x3 1024 clz w132?, w130? 1025 rbit w145?, w130? 1026 clz w133?, w145? 1027 ins v142?.d[0], x130? 1028 cnt v143?.16b, v142?.16b 1029 uaddlv h144?, v143?.8b 1030 mov x134?, v144?.d[0] 1031 clz x135?, x131? 1032 rbit x141?, x131? 1033 clz x136?, x141? 1034 ins v138?.d[0], x131? 1035 cnt v139?.16b, v138?.16b 1036 uaddlv h140?, v139?.8b 1037 mov x137?, v140?.d[0] 1038 mov x5, x137? 1039 mov x4, x136? 1040 mov x3, x135? 1041 mov x2, x134? 1042 mov x1, x133? 1043 mov x0, x132? 1044 ret 1045 `, 1046 afterFinalizeARM64: ` 1047 L1 (SSA Block: blk0): 1048 stp x30, xzr, [sp, #-0x10]! 1049 str xzr, [sp, #-0x10]! 1050 clz w8, w2 1051 rbit w9, w2 1052 clz w9, w9 1053 ins v8.d[0], x2 1054 cnt v8.16b, v8.16b 1055 uaddlv h8, v8.8b 1056 mov x10, v8.d[0] 1057 clz x11, x3 1058 rbit x12, x3 1059 clz x12, x12 1060 ins v8.d[0], x3 1061 cnt v8.16b, v8.16b 1062 uaddlv h8, v8.8b 1063 mov x13, v8.d[0] 1064 mov x5, x13 1065 mov x4, x12 1066 mov x3, x11 1067 mov x2, x10 1068 mov x1, x9 1069 mov x0, x8 1070 add sp, sp, #0x10 1071 ldr x30, [sp], #0x10 1072 ret 1073 `, 1074 }, 1075 { 1076 name: "float_comparisons", 1077 m: testcases.FloatComparisons.Module, 1078 afterFinalizeARM64: ` 1079 L1 (SSA Block: blk0): 1080 orr x27, xzr, #0x20 1081 sub sp, sp, x27 1082 stp x30, x27, [sp, #-0x10]! 1083 str x19, [sp, #-0x10]! 1084 str x20, [sp, #-0x10]! 1085 orr x27, xzr, #0x20 1086 str x27, [sp, #-0x10]! 1087 fcmp s0, s1 1088 cset x8, eq 1089 fcmp s0, s1 1090 cset x9, ne 1091 fcmp s0, s1 1092 cset x10, mi 1093 fcmp s0, s1 1094 cset x11, gt 1095 fcmp s0, s1 1096 cset x12, ls 1097 fcmp s0, s1 1098 cset x13, ge 1099 fcmp d2, d3 1100 cset x14, eq 1101 fcmp d2, d3 1102 cset x15, ne 1103 fcmp d2, d3 1104 cset x16, mi 1105 fcmp d2, d3 1106 cset x17, gt 1107 fcmp d2, d3 1108 cset x19, ls 1109 fcmp d2, d3 1110 cset x20, ge 1111 str w20, [sp, #0x58] 1112 str w19, [sp, #0x50] 1113 str w17, [sp, #0x48] 1114 str w16, [sp, #0x40] 1115 mov x7, x15 1116 mov x6, x14 1117 mov x5, x13 1118 mov x4, x12 1119 mov x3, x11 1120 mov x2, x10 1121 mov x1, x9 1122 mov x0, x8 1123 add sp, sp, #0x10 1124 ldr x20, [sp], #0x10 1125 ldr x19, [sp], #0x10 1126 ldr x30, [sp], #0x10 1127 add sp, sp, #0x20 1128 ret 1129 `, 1130 }, 1131 { 1132 name: "float_conversions", 1133 m: testcases.FloatConversions.Module, 1134 afterFinalizeARM64: ` 1135 L1 (SSA Block: blk0): 1136 stp x30, xzr, [sp, #-0x10]! 1137 str xzr, [sp, #-0x10]! 1138 msr fpsr, xzr 1139 fcvtzs x8, d0 1140 mrs x9 fpsr 1141 mov x10, x0 1142 mov v8.16b, v0.16b 1143 subs xzr, x9, #0x1 1144 b.ne #0x70, (L17) 1145 fcmp d8, d8 1146 mov x9, x10 1147 b.vc #0x34, (L16) 1148 movz x11, #0xc, lsl 0 1149 str w11, [x9] 1150 mov x11, sp 1151 str x11, [x9, #0x38] 1152 adr x11, #0x0 1153 str x11, [x9, #0x30] 1154 exit_sequence x9 1155 L16: 1156 movz x9, #0xb, lsl 0 1157 str w9, [x10] 1158 mov x9, sp 1159 str x9, [x10, #0x38] 1160 adr x9, #0x0 1161 str x9, [x10, #0x30] 1162 exit_sequence x10 1163 L17: 1164 msr fpsr, xzr 1165 fcvtzs x9, s1 1166 mrs x10 fpsr 1167 mov x11, x0 1168 mov v8.16b, v1.16b 1169 subs xzr, x10, #0x1 1170 b.ne #0x70, (L15) 1171 fcmp s8, s8 1172 mov x10, x11 1173 b.vc #0x34, (L14) 1174 movz x12, #0xc, lsl 0 1175 str w12, [x10] 1176 mov x12, sp 1177 str x12, [x10, #0x38] 1178 adr x12, #0x0 1179 str x12, [x10, #0x30] 1180 exit_sequence x10 1181 L14: 1182 movz x10, #0xb, lsl 0 1183 str w10, [x11] 1184 mov x10, sp 1185 str x10, [x11, #0x38] 1186 adr x10, #0x0 1187 str x10, [x11, #0x30] 1188 exit_sequence x11 1189 L15: 1190 msr fpsr, xzr 1191 fcvtzs w10, d0 1192 mrs x11 fpsr 1193 mov x12, x0 1194 mov v8.16b, v0.16b 1195 subs xzr, x11, #0x1 1196 b.ne #0x70, (L13) 1197 fcmp d8, d8 1198 mov x11, x12 1199 b.vc #0x34, (L12) 1200 movz x13, #0xc, lsl 0 1201 str w13, [x11] 1202 mov x13, sp 1203 str x13, [x11, #0x38] 1204 adr x13, #0x0 1205 str x13, [x11, #0x30] 1206 exit_sequence x11 1207 L12: 1208 movz x11, #0xb, lsl 0 1209 str w11, [x12] 1210 mov x11, sp 1211 str x11, [x12, #0x38] 1212 adr x11, #0x0 1213 str x11, [x12, #0x30] 1214 exit_sequence x12 1215 L13: 1216 msr fpsr, xzr 1217 fcvtzs w11, s1 1218 mrs x12 fpsr 1219 mov x13, x0 1220 mov v8.16b, v1.16b 1221 subs xzr, x12, #0x1 1222 b.ne #0x70, (L11) 1223 fcmp s8, s8 1224 mov x12, x13 1225 b.vc #0x34, (L10) 1226 movz x14, #0xc, lsl 0 1227 str w14, [x12] 1228 mov x14, sp 1229 str x14, [x12, #0x38] 1230 adr x14, #0x0 1231 str x14, [x12, #0x30] 1232 exit_sequence x12 1233 L10: 1234 movz x12, #0xb, lsl 0 1235 str w12, [x13] 1236 mov x12, sp 1237 str x12, [x13, #0x38] 1238 adr x12, #0x0 1239 str x12, [x13, #0x30] 1240 exit_sequence x13 1241 L11: 1242 msr fpsr, xzr 1243 fcvtzu x12, d0 1244 mrs x13 fpsr 1245 mov x14, x0 1246 mov v8.16b, v0.16b 1247 subs xzr, x13, #0x1 1248 b.ne #0x70, (L9) 1249 fcmp d8, d8 1250 mov x13, x14 1251 b.vc #0x34, (L8) 1252 movz x15, #0xc, lsl 0 1253 str w15, [x13] 1254 mov x15, sp 1255 str x15, [x13, #0x38] 1256 adr x15, #0x0 1257 str x15, [x13, #0x30] 1258 exit_sequence x13 1259 L8: 1260 movz x13, #0xb, lsl 0 1261 str w13, [x14] 1262 mov x13, sp 1263 str x13, [x14, #0x38] 1264 adr x13, #0x0 1265 str x13, [x14, #0x30] 1266 exit_sequence x14 1267 L9: 1268 msr fpsr, xzr 1269 fcvtzu x13, s1 1270 mrs x14 fpsr 1271 mov x15, x0 1272 mov v8.16b, v1.16b 1273 subs xzr, x14, #0x1 1274 b.ne #0x70, (L7) 1275 fcmp s8, s8 1276 mov x14, x15 1277 b.vc #0x34, (L6) 1278 movz x16, #0xc, lsl 0 1279 str w16, [x14] 1280 mov x16, sp 1281 str x16, [x14, #0x38] 1282 adr x16, #0x0 1283 str x16, [x14, #0x30] 1284 exit_sequence x14 1285 L6: 1286 movz x14, #0xb, lsl 0 1287 str w14, [x15] 1288 mov x14, sp 1289 str x14, [x15, #0x38] 1290 adr x14, #0x0 1291 str x14, [x15, #0x30] 1292 exit_sequence x15 1293 L7: 1294 msr fpsr, xzr 1295 fcvtzu w14, d0 1296 mrs x15 fpsr 1297 mov x16, x0 1298 mov v8.16b, v0.16b 1299 subs xzr, x15, #0x1 1300 b.ne #0x70, (L5) 1301 fcmp d8, d8 1302 mov x15, x16 1303 b.vc #0x34, (L4) 1304 movz x17, #0xc, lsl 0 1305 str w17, [x15] 1306 mov x17, sp 1307 str x17, [x15, #0x38] 1308 adr x17, #0x0 1309 str x17, [x15, #0x30] 1310 exit_sequence x15 1311 L4: 1312 movz x15, #0xb, lsl 0 1313 str w15, [x16] 1314 mov x15, sp 1315 str x15, [x16, #0x38] 1316 adr x15, #0x0 1317 str x15, [x16, #0x30] 1318 exit_sequence x16 1319 L5: 1320 msr fpsr, xzr 1321 fcvtzu w15, s1 1322 mrs x16 fpsr 1323 mov v8.16b, v1.16b 1324 subs xzr, x16, #0x1 1325 b.ne #0x70, (L3) 1326 fcmp s8, s8 1327 mov x16, x0 1328 b.vc #0x34, (L2) 1329 movz x17, #0xc, lsl 0 1330 str w17, [x16] 1331 mov x17, sp 1332 str x17, [x16, #0x38] 1333 adr x17, #0x0 1334 str x17, [x16, #0x30] 1335 exit_sequence x16 1336 L2: 1337 movz x16, #0xb, lsl 0 1338 str w16, [x0] 1339 mov x16, sp 1340 str x16, [x0, #0x38] 1341 adr x16, #0x0 1342 str x16, [x0, #0x30] 1343 exit_sequence x0 1344 L3: 1345 fcvt s8, d0 1346 fcvt d9, s1 1347 mov v1.8b, v9.8b 1348 mov v0.8b, v8.8b 1349 mov x7, x15 1350 mov x6, x14 1351 mov x5, x13 1352 mov x4, x12 1353 mov x3, x11 1354 mov x2, x10 1355 mov x1, x9 1356 mov x0, x8 1357 add sp, sp, #0x10 1358 ldr x30, [sp], #0x10 1359 ret 1360 `, 1361 }, 1362 { 1363 name: "nontrapping_float_conversions", 1364 m: testcases.NonTrappingFloatConversions.Module, 1365 afterFinalizeARM64: ` 1366 L1 (SSA Block: blk0): 1367 stp x30, xzr, [sp, #-0x10]! 1368 str xzr, [sp, #-0x10]! 1369 fcvtzs x8, d0 1370 fcvtzs x9, s1 1371 fcvtzs w10, d0 1372 fcvtzs w11, s1 1373 fcvtzu x12, d0 1374 fcvtzu x13, s1 1375 fcvtzu w14, d0 1376 fcvtzu w15, s1 1377 mov x7, x15 1378 mov x6, x14 1379 mov x5, x13 1380 mov x4, x12 1381 mov x3, x11 1382 mov x2, x10 1383 mov x1, x9 1384 mov x0, x8 1385 add sp, sp, #0x10 1386 ldr x30, [sp], #0x10 1387 ret 1388 `, 1389 }, 1390 { 1391 name: "many_middle_values", 1392 m: testcases.ManyMiddleValues.Module, 1393 afterLoweringARM64: ` 1394 L1 (SSA Block: blk0): 1395 mov x130?, x2 1396 mov v131?.8b, v0.8b 1397 orr w289?, wzr, #0x1 1398 madd w133?, w130?, w289?, wzr 1399 orr w288?, wzr, #0x2 1400 madd w135?, w130?, w288?, wzr 1401 orr w287?, wzr, #0x3 1402 madd w137?, w130?, w287?, wzr 1403 orr w286?, wzr, #0x4 1404 madd w139?, w130?, w286?, wzr 1405 movz w285?, #0x5, lsl 0 1406 madd w141?, w130?, w285?, wzr 1407 orr w284?, wzr, #0x6 1408 madd w143?, w130?, w284?, wzr 1409 orr w283?, wzr, #0x7 1410 madd w145?, w130?, w283?, wzr 1411 orr w282?, wzr, #0x8 1412 madd w147?, w130?, w282?, wzr 1413 movz w281?, #0x9, lsl 0 1414 madd w149?, w130?, w281?, wzr 1415 movz w280?, #0xa, lsl 0 1416 madd w151?, w130?, w280?, wzr 1417 movz w279?, #0xb, lsl 0 1418 madd w153?, w130?, w279?, wzr 1419 orr w278?, wzr, #0xc 1420 madd w155?, w130?, w278?, wzr 1421 movz w277?, #0xd, lsl 0 1422 madd w157?, w130?, w277?, wzr 1423 orr w276?, wzr, #0xe 1424 madd w159?, w130?, w276?, wzr 1425 orr w275?, wzr, #0xf 1426 madd w161?, w130?, w275?, wzr 1427 orr w274?, wzr, #0x10 1428 madd w163?, w130?, w274?, wzr 1429 movz w273?, #0x11, lsl 0 1430 madd w165?, w130?, w273?, wzr 1431 movz w272?, #0x12, lsl 0 1432 madd w167?, w130?, w272?, wzr 1433 movz w271?, #0x13, lsl 0 1434 madd w169?, w130?, w271?, wzr 1435 movz w270?, #0x14, lsl 0 1436 madd w171?, w130?, w270?, wzr 1437 add w172?, w169?, w171? 1438 add w173?, w167?, w172? 1439 add w174?, w165?, w173? 1440 add w175?, w163?, w174? 1441 add w176?, w161?, w175? 1442 add w177?, w159?, w176? 1443 add w178?, w157?, w177? 1444 add w179?, w155?, w178? 1445 add w180?, w153?, w179? 1446 add w181?, w151?, w180? 1447 add w182?, w149?, w181? 1448 add w183?, w147?, w182? 1449 add w184?, w145?, w183? 1450 add w185?, w143?, w184? 1451 add w186?, w141?, w185? 1452 add w187?, w139?, w186? 1453 add w188?, w137?, w187? 1454 add w189?, w135?, w188? 1455 add w190?, w133?, w189? 1456 ldr s269?, #8; b 8; data.f32 1.000000 1457 fmul s192?, s131?, s269? 1458 ldr s268?, #8; b 8; data.f32 2.000000 1459 fmul s194?, s131?, s268? 1460 ldr s267?, #8; b 8; data.f32 3.000000 1461 fmul s196?, s131?, s267? 1462 ldr s266?, #8; b 8; data.f32 4.000000 1463 fmul s198?, s131?, s266? 1464 ldr s265?, #8; b 8; data.f32 5.000000 1465 fmul s200?, s131?, s265? 1466 ldr s264?, #8; b 8; data.f32 6.000000 1467 fmul s202?, s131?, s264? 1468 ldr s263?, #8; b 8; data.f32 7.000000 1469 fmul s204?, s131?, s263? 1470 ldr s262?, #8; b 8; data.f32 8.000000 1471 fmul s206?, s131?, s262? 1472 ldr s261?, #8; b 8; data.f32 9.000000 1473 fmul s208?, s131?, s261? 1474 ldr s260?, #8; b 8; data.f32 10.000000 1475 fmul s210?, s131?, s260? 1476 ldr s259?, #8; b 8; data.f32 11.000000 1477 fmul s212?, s131?, s259? 1478 ldr s258?, #8; b 8; data.f32 12.000000 1479 fmul s214?, s131?, s258? 1480 ldr s257?, #8; b 8; data.f32 13.000000 1481 fmul s216?, s131?, s257? 1482 ldr s256?, #8; b 8; data.f32 14.000000 1483 fmul s218?, s131?, s256? 1484 ldr s255?, #8; b 8; data.f32 15.000000 1485 fmul s220?, s131?, s255? 1486 ldr s254?, #8; b 8; data.f32 16.000000 1487 fmul s222?, s131?, s254? 1488 ldr s253?, #8; b 8; data.f32 17.000000 1489 fmul s224?, s131?, s253? 1490 ldr s252?, #8; b 8; data.f32 18.000000 1491 fmul s226?, s131?, s252? 1492 ldr s251?, #8; b 8; data.f32 19.000000 1493 fmul s228?, s131?, s251? 1494 ldr s250?, #8; b 8; data.f32 20.000000 1495 fmul s230?, s131?, s250? 1496 fadd s231?, s228?, s230? 1497 fadd s232?, s226?, s231? 1498 fadd s233?, s224?, s232? 1499 fadd s234?, s222?, s233? 1500 fadd s235?, s220?, s234? 1501 fadd s236?, s218?, s235? 1502 fadd s237?, s216?, s236? 1503 fadd s238?, s214?, s237? 1504 fadd s239?, s212?, s238? 1505 fadd s240?, s210?, s239? 1506 fadd s241?, s208?, s240? 1507 fadd s242?, s206?, s241? 1508 fadd s243?, s204?, s242? 1509 fadd s244?, s202?, s243? 1510 fadd s245?, s200?, s244? 1511 fadd s246?, s198?, s245? 1512 fadd s247?, s196?, s246? 1513 fadd s248?, s194?, s247? 1514 fadd s249?, s192?, s248? 1515 mov v0.8b, v249?.8b 1516 mov x0, x190? 1517 ret 1518 `, 1519 afterFinalizeARM64: ` 1520 L1 (SSA Block: blk0): 1521 stp x30, xzr, [sp, #-0x10]! 1522 str x19, [sp, #-0x10]! 1523 str x20, [sp, #-0x10]! 1524 str x21, [sp, #-0x10]! 1525 str x22, [sp, #-0x10]! 1526 str x23, [sp, #-0x10]! 1527 str x24, [sp, #-0x10]! 1528 str x25, [sp, #-0x10]! 1529 str x26, [sp, #-0x10]! 1530 str q18, [sp, #-0x10]! 1531 str q19, [sp, #-0x10]! 1532 str q20, [sp, #-0x10]! 1533 str q21, [sp, #-0x10]! 1534 str q22, [sp, #-0x10]! 1535 str q23, [sp, #-0x10]! 1536 str q24, [sp, #-0x10]! 1537 str q25, [sp, #-0x10]! 1538 str q26, [sp, #-0x10]! 1539 str q27, [sp, #-0x10]! 1540 movz x27, #0x120, lsl 0 1541 str x27, [sp, #-0x10]! 1542 orr w8, wzr, #0x1 1543 madd w8, w2, w8, wzr 1544 orr w9, wzr, #0x2 1545 madd w9, w2, w9, wzr 1546 orr w10, wzr, #0x3 1547 madd w10, w2, w10, wzr 1548 orr w11, wzr, #0x4 1549 madd w11, w2, w11, wzr 1550 movz w12, #0x5, lsl 0 1551 madd w12, w2, w12, wzr 1552 orr w13, wzr, #0x6 1553 madd w13, w2, w13, wzr 1554 orr w14, wzr, #0x7 1555 madd w14, w2, w14, wzr 1556 orr w15, wzr, #0x8 1557 madd w15, w2, w15, wzr 1558 movz w16, #0x9, lsl 0 1559 madd w16, w2, w16, wzr 1560 movz w17, #0xa, lsl 0 1561 madd w17, w2, w17, wzr 1562 movz w19, #0xb, lsl 0 1563 madd w19, w2, w19, wzr 1564 orr w20, wzr, #0xc 1565 madd w20, w2, w20, wzr 1566 movz w21, #0xd, lsl 0 1567 madd w21, w2, w21, wzr 1568 orr w22, wzr, #0xe 1569 madd w22, w2, w22, wzr 1570 orr w23, wzr, #0xf 1571 madd w23, w2, w23, wzr 1572 orr w24, wzr, #0x10 1573 madd w24, w2, w24, wzr 1574 movz w25, #0x11, lsl 0 1575 madd w25, w2, w25, wzr 1576 movz w26, #0x12, lsl 0 1577 madd w26, w2, w26, wzr 1578 movz w29, #0x13, lsl 0 1579 madd w29, w2, w29, wzr 1580 movz w30, #0x14, lsl 0 1581 madd w30, w2, w30, wzr 1582 add w29, w29, w30 1583 add w26, w26, w29 1584 add w25, w25, w26 1585 add w24, w24, w25 1586 add w23, w23, w24 1587 add w22, w22, w23 1588 add w21, w21, w22 1589 add w20, w20, w21 1590 add w19, w19, w20 1591 add w17, w17, w19 1592 add w16, w16, w17 1593 add w15, w15, w16 1594 add w14, w14, w15 1595 add w13, w13, w14 1596 add w12, w12, w13 1597 add w11, w11, w12 1598 add w10, w10, w11 1599 add w9, w9, w10 1600 add w8, w8, w9 1601 ldr s8, #8; b 8; data.f32 1.000000 1602 fmul s8, s0, s8 1603 ldr s9, #8; b 8; data.f32 2.000000 1604 fmul s9, s0, s9 1605 ldr s10, #8; b 8; data.f32 3.000000 1606 fmul s10, s0, s10 1607 ldr s11, #8; b 8; data.f32 4.000000 1608 fmul s11, s0, s11 1609 ldr s12, #8; b 8; data.f32 5.000000 1610 fmul s12, s0, s12 1611 ldr s13, #8; b 8; data.f32 6.000000 1612 fmul s13, s0, s13 1613 ldr s14, #8; b 8; data.f32 7.000000 1614 fmul s14, s0, s14 1615 ldr s15, #8; b 8; data.f32 8.000000 1616 fmul s15, s0, s15 1617 ldr s16, #8; b 8; data.f32 9.000000 1618 fmul s16, s0, s16 1619 ldr s17, #8; b 8; data.f32 10.000000 1620 fmul s17, s0, s17 1621 ldr s18, #8; b 8; data.f32 11.000000 1622 fmul s18, s0, s18 1623 ldr s19, #8; b 8; data.f32 12.000000 1624 fmul s19, s0, s19 1625 ldr s20, #8; b 8; data.f32 13.000000 1626 fmul s20, s0, s20 1627 ldr s21, #8; b 8; data.f32 14.000000 1628 fmul s21, s0, s21 1629 ldr s22, #8; b 8; data.f32 15.000000 1630 fmul s22, s0, s22 1631 ldr s23, #8; b 8; data.f32 16.000000 1632 fmul s23, s0, s23 1633 ldr s24, #8; b 8; data.f32 17.000000 1634 fmul s24, s0, s24 1635 ldr s25, #8; b 8; data.f32 18.000000 1636 fmul s25, s0, s25 1637 ldr s26, #8; b 8; data.f32 19.000000 1638 fmul s26, s0, s26 1639 ldr s27, #8; b 8; data.f32 20.000000 1640 fmul s27, s0, s27 1641 fadd s26, s26, s27 1642 fadd s25, s25, s26 1643 fadd s24, s24, s25 1644 fadd s23, s23, s24 1645 fadd s22, s22, s23 1646 fadd s21, s21, s22 1647 fadd s20, s20, s21 1648 fadd s19, s19, s20 1649 fadd s18, s18, s19 1650 fadd s17, s17, s18 1651 fadd s16, s16, s17 1652 fadd s15, s15, s16 1653 fadd s14, s14, s15 1654 fadd s13, s13, s14 1655 fadd s12, s12, s13 1656 fadd s11, s11, s12 1657 fadd s10, s10, s11 1658 fadd s9, s9, s10 1659 fadd s8, s8, s9 1660 mov v0.8b, v8.8b 1661 mov x0, x8 1662 add sp, sp, #0x10 1663 ldr q27, [sp], #0x10 1664 ldr q26, [sp], #0x10 1665 ldr q25, [sp], #0x10 1666 ldr q24, [sp], #0x10 1667 ldr q23, [sp], #0x10 1668 ldr q22, [sp], #0x10 1669 ldr q21, [sp], #0x10 1670 ldr q20, [sp], #0x10 1671 ldr q19, [sp], #0x10 1672 ldr q18, [sp], #0x10 1673 ldr x26, [sp], #0x10 1674 ldr x25, [sp], #0x10 1675 ldr x24, [sp], #0x10 1676 ldr x23, [sp], #0x10 1677 ldr x22, [sp], #0x10 1678 ldr x21, [sp], #0x10 1679 ldr x20, [sp], #0x10 1680 ldr x19, [sp], #0x10 1681 ldr x30, [sp], #0x10 1682 ret 1683 `, 1684 }, 1685 { 1686 name: "imported_function_call", m: testcases.ImportedFunctionCall.Module, 1687 afterLoweringARM64: ` 1688 L1 (SSA Block: blk0): 1689 mov x128?, x0 1690 mov x129?, x1 1691 mov x130?, x2 1692 str x129?, [x128?, #0x8] 1693 ldr x131?, [x129?, #0x8] 1694 ldr x132?, [x129?, #0x10] 1695 mov x0, x128? 1696 mov x1, x132? 1697 mov x2, x130? 1698 mov x3, x130? 1699 bl x131? 1700 mov x133?, x0 1701 mov x0, x133? 1702 ret 1703 `, 1704 afterFinalizeARM64: ` 1705 L1 (SSA Block: blk0): 1706 stp x30, xzr, [sp, #-0x10]! 1707 sub sp, sp, #0x10 1708 orr x27, xzr, #0x10 1709 str x27, [sp, #-0x10]! 1710 str w2, [sp, #0x10] 1711 str x1, [x0, #0x8] 1712 ldr x8, [x1, #0x8] 1713 ldr x9, [x1, #0x10] 1714 mov x1, x9 1715 ldr w9, [sp, #0x10] 1716 mov x3, x9 1717 bl x8 1718 add sp, sp, #0x10 1719 add sp, sp, #0x10 1720 ldr x30, [sp], #0x10 1721 ret 1722 `, 1723 }, 1724 { 1725 name: "memory_load_basic", m: testcases.MemoryLoadBasic.Module, 1726 afterLoweringARM64: ` 1727 L1 (SSA Block: blk0): 1728 mov x128?, x0 1729 mov x129?, x1 1730 mov x130?, x2 1731 uxtw x132?, w130? 1732 ldr w133?, [x129?, #0x10] 1733 add x134?, x132?, #0x4 1734 subs xzr, x133?, x134? 1735 mov x140?, x128? 1736 b.hs L2 1737 movz x141?, #0x4, lsl 0 1738 str w141?, [x140?] 1739 mov x142?, sp 1740 str x142?, [x140?, #0x38] 1741 adr x143?, #0x0 1742 str x143?, [x140?, #0x30] 1743 exit_sequence x140? 1744 L2: 1745 ldr x136?, [x129?, #0x8] 1746 add x139?, x136?, x132? 1747 ldr w138?, [x139?] 1748 mov x0, x138? 1749 ret 1750 `, 1751 afterFinalizeARM64: ` 1752 L1 (SSA Block: blk0): 1753 stp x30, xzr, [sp, #-0x10]! 1754 str xzr, [sp, #-0x10]! 1755 uxtw x8, w2 1756 ldr w9, [x1, #0x10] 1757 add x10, x8, #0x4 1758 subs xzr, x9, x10 1759 b.hs #0x34, (L2) 1760 movz x9, #0x4, lsl 0 1761 str w9, [x0] 1762 mov x9, sp 1763 str x9, [x0, #0x38] 1764 adr x9, #0x0 1765 str x9, [x0, #0x30] 1766 exit_sequence x0 1767 L2: 1768 ldr x9, [x1, #0x8] 1769 add x8, x9, x8 1770 ldr w8, [x8] 1771 mov x0, x8 1772 add sp, sp, #0x10 1773 ldr x30, [sp], #0x10 1774 ret 1775 `, 1776 }, 1777 { 1778 name: "memory_stores", m: testcases.MemoryStores.Module, 1779 afterFinalizeARM64: ` 1780 L1 (SSA Block: blk0): 1781 stp x30, xzr, [sp, #-0x10]! 1782 str xzr, [sp, #-0x10]! 1783 mov x8, xzr 1784 uxtw x8, w8 1785 ldr w9, [x1, #0x10] 1786 add x10, x8, #0x4 1787 subs xzr, x9, x10 1788 mov x10, x0 1789 b.hs #0x34, (L10) 1790 movz x11, #0x4, lsl 0 1791 str w11, [x10] 1792 mov x11, sp 1793 str x11, [x10, #0x38] 1794 adr x11, #0x0 1795 str x11, [x10, #0x30] 1796 exit_sequence x10 1797 L10: 1798 ldr x10, [x1, #0x8] 1799 add x8, x10, x8 1800 str w2, [x8] 1801 orr w8, wzr, #0x8 1802 uxtw x8, w8 1803 add x11, x8, #0x8 1804 subs xzr, x9, x11 1805 mov x11, x0 1806 b.hs #0x34, (L9) 1807 movz x12, #0x4, lsl 0 1808 str w12, [x11] 1809 mov x12, sp 1810 str x12, [x11, #0x38] 1811 adr x12, #0x0 1812 str x12, [x11, #0x30] 1813 exit_sequence x11 1814 L9: 1815 add x8, x10, x8 1816 str x3, [x8] 1817 orr w8, wzr, #0x10 1818 uxtw x8, w8 1819 add x11, x8, #0x4 1820 subs xzr, x9, x11 1821 mov x11, x0 1822 b.hs #0x34, (L8) 1823 movz x12, #0x4, lsl 0 1824 str w12, [x11] 1825 mov x12, sp 1826 str x12, [x11, #0x38] 1827 adr x12, #0x0 1828 str x12, [x11, #0x30] 1829 exit_sequence x11 1830 L8: 1831 add x8, x10, x8 1832 str s0, [x8] 1833 orr w8, wzr, #0x18 1834 uxtw x8, w8 1835 add x11, x8, #0x8 1836 subs xzr, x9, x11 1837 mov x11, x0 1838 b.hs #0x34, (L7) 1839 movz x12, #0x4, lsl 0 1840 str w12, [x11] 1841 mov x12, sp 1842 str x12, [x11, #0x38] 1843 adr x12, #0x0 1844 str x12, [x11, #0x30] 1845 exit_sequence x11 1846 L7: 1847 add x8, x10, x8 1848 str d1, [x8] 1849 orr w8, wzr, #0x20 1850 uxtw x8, w8 1851 add x11, x8, #0x1 1852 subs xzr, x9, x11 1853 mov x11, x0 1854 b.hs #0x34, (L6) 1855 movz x12, #0x4, lsl 0 1856 str w12, [x11] 1857 mov x12, sp 1858 str x12, [x11, #0x38] 1859 adr x12, #0x0 1860 str x12, [x11, #0x30] 1861 exit_sequence x11 1862 L6: 1863 add x8, x10, x8 1864 strb w2, [x8] 1865 movz w8, #0x28, lsl 0 1866 uxtw x8, w8 1867 add x11, x8, #0x2 1868 subs xzr, x9, x11 1869 mov x11, x0 1870 b.hs #0x34, (L5) 1871 movz x12, #0x4, lsl 0 1872 str w12, [x11] 1873 mov x12, sp 1874 str x12, [x11, #0x38] 1875 adr x12, #0x0 1876 str x12, [x11, #0x30] 1877 exit_sequence x11 1878 L5: 1879 add x8, x10, x8 1880 strh w2, [x8] 1881 orr w8, wzr, #0x30 1882 uxtw x8, w8 1883 add x11, x8, #0x1 1884 subs xzr, x9, x11 1885 mov x11, x0 1886 b.hs #0x34, (L4) 1887 movz x12, #0x4, lsl 0 1888 str w12, [x11] 1889 mov x12, sp 1890 str x12, [x11, #0x38] 1891 adr x12, #0x0 1892 str x12, [x11, #0x30] 1893 exit_sequence x11 1894 L4: 1895 add x8, x10, x8 1896 strb w3, [x8] 1897 orr w8, wzr, #0x38 1898 uxtw x8, w8 1899 add x11, x8, #0x2 1900 subs xzr, x9, x11 1901 mov x11, x0 1902 b.hs #0x34, (L3) 1903 movz x12, #0x4, lsl 0 1904 str w12, [x11] 1905 mov x12, sp 1906 str x12, [x11, #0x38] 1907 adr x12, #0x0 1908 str x12, [x11, #0x30] 1909 exit_sequence x11 1910 L3: 1911 add x8, x10, x8 1912 strh w3, [x8] 1913 orr w8, wzr, #0x40 1914 uxtw x8, w8 1915 add x11, x8, #0x4 1916 subs xzr, x9, x11 1917 b.hs #0x34, (L2) 1918 movz x9, #0x4, lsl 0 1919 str w9, [x0] 1920 mov x9, sp 1921 str x9, [x0, #0x38] 1922 adr x9, #0x0 1923 str x9, [x0, #0x30] 1924 exit_sequence x0 1925 L2: 1926 add x8, x10, x8 1927 str w3, [x8] 1928 add sp, sp, #0x10 1929 ldr x30, [sp], #0x10 1930 ret 1931 `, 1932 }, 1933 { 1934 name: "globals_mutable[0]", 1935 m: testcases.GlobalsMutable.Module, 1936 afterLoweringARM64: ` 1937 L1 (SSA Block: blk0): 1938 mov x128?, x0 1939 mov x129?, x1 1940 ldr w130?, [x129?, #0x8] 1941 ldr x131?, [x129?, #0x18] 1942 ldr s132?, [x129?, #0x28] 1943 ldr d133?, [x129?, #0x38] 1944 str x129?, [x128?, #0x8] 1945 mov x0, x128? 1946 mov x1, x129? 1947 bl f1 1948 ldr w134?, [x129?, #0x8] 1949 ldr x135?, [x129?, #0x18] 1950 ldr s136?, [x129?, #0x28] 1951 ldr d137?, [x129?, #0x38] 1952 mov v3.8b, v137?.8b 1953 mov v2.8b, v136?.8b 1954 mov x3, x135? 1955 mov x2, x134? 1956 mov v1.8b, v133?.8b 1957 mov v0.8b, v132?.8b 1958 mov x1, x131? 1959 mov x0, x130? 1960 ret 1961 `, 1962 afterFinalizeARM64: ` 1963 L1 (SSA Block: blk0): 1964 stp x30, xzr, [sp, #-0x10]! 1965 sub sp, sp, #0x20 1966 orr x27, xzr, #0x20 1967 str x27, [sp, #-0x10]! 1968 str x1, [sp, #0x10] 1969 ldr w8, [x1, #0x8] 1970 str w8, [sp, #0x2c] 1971 ldr x9, [x1, #0x18] 1972 str x9, [sp, #0x24] 1973 ldr s8, [x1, #0x28] 1974 str s8, [sp, #0x20] 1975 ldr d9, [x1, #0x38] 1976 str d9, [sp, #0x18] 1977 str x1, [x0, #0x8] 1978 bl f1 1979 ldr x8, [sp, #0x10] 1980 ldr w9, [x8, #0x8] 1981 ldr x10, [x8, #0x18] 1982 ldr s8, [x8, #0x28] 1983 ldr d9, [x8, #0x38] 1984 mov v3.8b, v9.8b 1985 mov v2.8b, v8.8b 1986 mov x3, x10 1987 mov x2, x9 1988 ldr d8, [sp, #0x18] 1989 mov v1.8b, v8.8b 1990 ldr s8, [sp, #0x20] 1991 mov v0.8b, v8.8b 1992 ldr x8, [sp, #0x24] 1993 mov x1, x8 1994 ldr w8, [sp, #0x2c] 1995 mov x0, x8 1996 add sp, sp, #0x10 1997 add sp, sp, #0x20 1998 ldr x30, [sp], #0x10 1999 ret 2000 `, 2001 }, 2002 { 2003 name: "globals_mutable[1]", 2004 m: testcases.GlobalsMutable.Module, 2005 targetIndex: 1, 2006 afterLoweringARM64: ` 2007 L1 (SSA Block: blk0): 2008 mov x129?, x1 2009 orr w137?, wzr, #0x1 2010 str w137?, [x129?, #0x8] 2011 orr x136?, xzr, #0x2 2012 str x136?, [x129?, #0x18] 2013 ldr s135?, #8; b 8; data.f32 3.000000 2014 str s135?, [x129?, #0x28] 2015 ldr d134?, #8; b 16; data.f64 4.000000 2016 str d134?, [x129?, #0x38] 2017 ret 2018 `, 2019 afterFinalizeARM64: ` 2020 L1 (SSA Block: blk0): 2021 stp x30, xzr, [sp, #-0x10]! 2022 str xzr, [sp, #-0x10]! 2023 orr w8, wzr, #0x1 2024 str w8, [x1, #0x8] 2025 orr x8, xzr, #0x2 2026 str x8, [x1, #0x18] 2027 ldr s8, #8; b 8; data.f32 3.000000 2028 str s8, [x1, #0x28] 2029 ldr d8, #8; b 16; data.f64 4.000000 2030 str d8, [x1, #0x38] 2031 add sp, sp, #0x10 2032 ldr x30, [sp], #0x10 2033 ret 2034 `, 2035 }, 2036 { 2037 name: "br_table", 2038 m: testcases.BrTable.Module, 2039 targetIndex: 0, 2040 afterLoweringARM64: ` 2041 L1 (SSA Block: blk0): 2042 mov x130?, x2 2043 orr w137?, wzr, #0x6 2044 subs wzr, w130?, w137? 2045 csel w138?, w137?, w130?, hs 2046 br_table_sequence x138?, [L2, L3, L4, L5, L6, L7, L8] 2047 L2 (SSA Block: blk7): 2048 b L9 2049 L3 (SSA Block: blk8): 2050 L10 (SSA Block: blk5): 2051 orr w131?, wzr, #0xc 2052 mov x0, x131? 2053 ret 2054 L4 (SSA Block: blk9): 2055 L11 (SSA Block: blk4): 2056 movz w132?, #0xd, lsl 0 2057 mov x0, x132? 2058 ret 2059 L5 (SSA Block: blk10): 2060 L12 (SSA Block: blk3): 2061 orr w133?, wzr, #0xe 2062 mov x0, x133? 2063 ret 2064 L6 (SSA Block: blk11): 2065 L13 (SSA Block: blk2): 2066 orr w134?, wzr, #0xf 2067 mov x0, x134? 2068 ret 2069 L7 (SSA Block: blk12): 2070 L14 (SSA Block: blk1): 2071 orr w135?, wzr, #0x10 2072 mov x0, x135? 2073 ret 2074 L8 (SSA Block: blk13): 2075 L9 (SSA Block: blk6): 2076 movz w136?, #0xb, lsl 0 2077 mov x0, x136? 2078 ret 2079 `, 2080 afterFinalizeARM64: ` 2081 L1 (SSA Block: blk0): 2082 stp x30, xzr, [sp, #-0x10]! 2083 str xzr, [sp, #-0x10]! 2084 orr w8, wzr, #0x6 2085 subs wzr, w2, w8 2086 csel w8, w8, w2, hs 2087 adr x27, #16; ldrsw x8, [x27, x8, UXTW 2]; add x27, x27, x8; br x27; [0x1c 0x20 0x34 0x48 0x5c 0x70 0x84] 2088 L2 (SSA Block: blk7): 2089 b #0x68 (L9) 2090 L3 (SSA Block: blk8): 2091 L10 (SSA Block: blk5): 2092 orr w8, wzr, #0xc 2093 mov x0, x8 2094 add sp, sp, #0x10 2095 ldr x30, [sp], #0x10 2096 ret 2097 L4 (SSA Block: blk9): 2098 L11 (SSA Block: blk4): 2099 movz w8, #0xd, lsl 0 2100 mov x0, x8 2101 add sp, sp, #0x10 2102 ldr x30, [sp], #0x10 2103 ret 2104 L5 (SSA Block: blk10): 2105 L12 (SSA Block: blk3): 2106 orr w8, wzr, #0xe 2107 mov x0, x8 2108 add sp, sp, #0x10 2109 ldr x30, [sp], #0x10 2110 ret 2111 L6 (SSA Block: blk11): 2112 L13 (SSA Block: blk2): 2113 orr w8, wzr, #0xf 2114 mov x0, x8 2115 add sp, sp, #0x10 2116 ldr x30, [sp], #0x10 2117 ret 2118 L7 (SSA Block: blk12): 2119 L14 (SSA Block: blk1): 2120 orr w8, wzr, #0x10 2121 mov x0, x8 2122 add sp, sp, #0x10 2123 ldr x30, [sp], #0x10 2124 ret 2125 L8 (SSA Block: blk13): 2126 L9 (SSA Block: blk6): 2127 movz w8, #0xb, lsl 0 2128 mov x0, x8 2129 add sp, sp, #0x10 2130 ldr x30, [sp], #0x10 2131 ret 2132 `, 2133 }, 2134 { 2135 name: "VecShuffle", 2136 m: testcases.VecShuffle.Module, 2137 afterFinalizeARM64: ` 2138 L1 (SSA Block: blk0): 2139 stp x30, xzr, [sp, #-0x10]! 2140 str q29, [sp, #-0x10]! 2141 str q30, [sp, #-0x10]! 2142 orr x27, xzr, #0x20 2143 str x27, [sp, #-0x10]! 2144 mov v29.16b, v0.16b 2145 mov v30.16b, v1.16b 2146 ldr q8, #8; b 32; data.v128 0706050403020100 1f1e1d1c1b1a1918 2147 tbl v8.16b, { v29.16b, v30.16b }, v8.16b 2148 mov v0.16b, v8.16b 2149 add sp, sp, #0x10 2150 ldr q30, [sp], #0x10 2151 ldr q29, [sp], #0x10 2152 ldr x30, [sp], #0x10 2153 ret 2154 `, 2155 }, 2156 } { 2157 t.Run(tc.name, func(t *testing.T) { 2158 ssab := ssa.NewBuilder() 2159 offset := wazevoapi.NewModuleContextOffsetData(tc.m, false) 2160 fc := frontend.NewFrontendCompiler(tc.m, ssab, &offset, false, false, false) 2161 machine := newMachine() 2162 machine.DisableStackCheck() 2163 be := backend.NewCompiler(context.Background(), machine, ssab) 2164 2165 // Lowers the Wasm to SSA. 2166 typeIndex := tc.m.FunctionSection[tc.targetIndex] 2167 code := &tc.m.CodeSection[tc.targetIndex] 2168 fc.Init(tc.targetIndex, typeIndex, &tc.m.TypeSection[typeIndex], code.LocalTypes, code.Body, false, 0) 2169 fc.LowerToSSA() 2170 if verbose { 2171 fmt.Println("============ SSA before passes ============") 2172 fmt.Println(ssab.Format()) 2173 } 2174 2175 // Need to run passes before lowering to machine code. 2176 ssab.RunPasses() 2177 if verbose { 2178 fmt.Println("============ SSA after passes ============") 2179 fmt.Println(ssab.Format()) 2180 } 2181 2182 ssab.LayoutBlocks() 2183 if verbose { 2184 fmt.Println("============ SSA after block layout ============") 2185 fmt.Println(ssab.Format()) 2186 } 2187 2188 // Lowers the SSA to ISA specific code. 2189 be.Lower() 2190 if verbose { 2191 fmt.Println("============ lowering result ============") 2192 fmt.Println(be.Format()) 2193 } 2194 2195 switch runtime.GOARCH { 2196 case "arm64": 2197 if tc.afterLoweringARM64 != "" { 2198 require.Equal(t, tc.afterLoweringARM64, be.Format()) 2199 } 2200 default: 2201 t.Fail() 2202 } 2203 2204 be.RegAlloc() 2205 if verbose { 2206 fmt.Println("============ regalloc result ============") 2207 fmt.Println(be.Format()) 2208 } 2209 2210 be.Finalize(context.Background()) 2211 if verbose { 2212 fmt.Println("============ finalization result ============") 2213 fmt.Println(be.Format()) 2214 } 2215 2216 switch runtime.GOARCH { 2217 case "arm64": 2218 require.Equal(t, tc.afterFinalizeARM64, be.Format()) 2219 default: 2220 t.Fail() 2221 } 2222 2223 // Sanity check on the final binary encoding. 2224 be.Encode() 2225 }) 2226 } 2227 }