1# Copyright (c) 2021-2022 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14definitions: 15 - name: PandaAssembly 16 template: | 17 .language PandaAssembly 18 - name: aoobe_p 19 template: | 20 .record panda.ArrayIndexOutOfBoundsException<external> 21 - name: aoobe_j 22 template: | 23 .record panda.ArrayIndexOutOfBoundsException<external> 24 - name: npe_p 25 template: | 26 .record panda.NullPointerException <external> 27 - name: npe_j 28 template: | 29 .record panda.NullPointerException <external> 30tests: 31 - file-name: "ldarr.64" 32 isa: 33 title: Load from array 34 description: > 35 Load an element from array using accumulator as an index and puts it into accumulator. 36 commands: 37 - file-name: "read_arr_p" 38 isa: 39 instructions: 40 - sig: ldarr.64 v:in:i64[] 41 acc: inout:i32->i64 42 format: [op_v_8] 43 description: Check ldarr.64 reads items from array of different size and type in Panda Assembly context. 44 code-template: | 45 # 46 movi v0, *s 47 newarr v0, v0, %s 48 ldai 0 49 ldarr.64 v0 50 check-type: exit-positive 51 template-cases: 52 - values: ['u64[]'] 53 - values: ['i64[]'] 54 cases: 55 - values: ['1'] 56 - values: ['255'] 57 tags: ['tsan'] 58 - values: ['65536'] 59 60 - file-name: "read_arr_j" 61 isa: 62 instructions: 63 - sig: ldarr.64 v:in:i64[] 64 acc: inout:i32->i64 65 format: [op_v_8] 66 description: Check ldarr.64 reads items from array of different size and type in PandaAssembly context. 67 header-template: [PandaAssembly, main] 68 code-template: | 69 # 70 movi v0, %s 71 newarr v0, v0, i64[] 72 ldai 0 73 ldarr.64 v0 74 check-type: exit-positive 75 runner-options: ['use-pa'] 76 cases: 77 - values: ['1'] 78 - values: ['255'] 79 tags: ['tsan'] 80 - values: ['65536'] 81 82 - file-name: "primitive_types_p" 83 isa: 84 instructions: 85 - sig: ldarr.64 v:in:i64[] 86 acc: inout:i32 87 format: [op_v_8] 88 tags: ['tsan', 'verifier'] 89 bugid: ['3052'] 90 description: Check array of primitive types for 'ldarr.64' instruction in Panda Assembly context. 91 header-template: [] 92 code-template: | 93 .array arr_u1 u1 1 { 1 } 94 .array arr_i8 i8 1 { 1 } 95 .array arr_u8 u8 1 { 1 } 96 .array arr_i16 i16 1 { 1 } 97 .array arr_u16 u16 1 { 1 } 98 .array arr_i32 i32 1 { 1 } 99 .array arr_u32 u32 1 { 1 } 100 .array arr_i64 i64 1 { 1 } 101 .array arr_u64 u64 1 { 1 } 102 .array arr_f32 f32 1 { 1 } 103 .array arr_f64 f64 1 { 1 } 104 .function i32 main() { 105 %s 106 ldai 0 107 ldarr.64 v0 108 check-type: exit-positive 109 runner-options: [verifier-failure, verifier-config] 110 template-cases: 111 - values: 112 - | 113 # 114 movi v0, 1 115 newarr v0, v0, %s[] 116 - values: 117 - | 118 # 119 lda.const v0, arr_%s 120 cases: 121 - values: [u1] 122 - values: [i8] 123 - values: [u8] 124 - values: [i16] 125 - values: [u16] 126 - values: [i32] 127 - values: [u32] 128 - values: [i64] 129 runner-options: [verifier-only, verifier-config] 130 - values: [u64] 131 runner-options: [verifier-only, verifier-config] 132 - values: [f32] 133 - values: [f64] 134 135 - file-name: "primitive_types_j" 136 isa: 137 instructions: 138 - sig: ldarr.64 v:in:i64[] 139 acc: inout:i32 140 format: [op_v_8] 141 tags: ['tsan', 'verifier', 'pa-verifier'] 142 bugid: ['3052'] 143 description: Check array of primitive types for 'ldarr.64' instruction in PandaAssembly context. 144 header-template: [PandaAssembly] 145 code-template: | 146 .array arr_u1 u1 1 { 1 } 147 .array arr_i8 i8 1 { 1 } 148 .array arr_i16 i16 1 { 1 } 149 .array arr_u16 u16 1 { 1 } 150 .array arr_i32 i32 1 { 1 } 151 .array arr_i64 i64 1 { 1 } 152 .array arr_f32 f32 1 { 1 } 153 .array arr_f64 f64 1 { 1 } 154 .function i32 main() { 155 %s 156 ldai 0 157 ldarr.64 v0 158 check-type: exit-positive 159 runner-options: [verifier-failure, verifier-config, use-pa] 160 template-cases: 161 - values: 162 - | 163 # 164 movi v0, 1 165 newarr v0, v0, %s[] 166 - values: 167 - | 168 # 169 lda.const v0, arr_%s 170 cases: 171 - values: [u1] 172 - values: [i8] 173 - values: [i16] 174 - values: [u16] 175 - values: [i32] 176 - values: [i64] 177 runner-options: [verifier-only, verifier-config, use-pa] 178 - values: [f32] 179 - values: [f64] 180 181 - file-name: "read_values" 182 isa: 183 instructions: 184 - sig: ldarr.64 v:in:i64[] 185 acc: inout:i32->i64 186 format: [op_v_8] 187 description: Check ldarr.64 reads correct items from array of primitives. 188 header-template: [xorshift32, main] 189 code-template: | 190 # 191 movi v3, 10000 # iterations 192 movi v2, *s # index 193 movi v0, *s 194 # array size 195 newarr v1, v0, %s # v1 - testable array 196 197 movi v0, 1 # initial random number 198 loop: 199 call.short nextRand, v0 200 sta v0 # v0 - next random number 201 # 202 i32toi64 203 starr.64 v1, v2 # save random number in v1[v2] 204 lda v2 205 ldarr.64 v1 # get v1[v2] 206 i64toi32 207 sta v4 # v4 = v1[v2] 208 209 lda v0 210 ucmp v4 # Compare random number and stored value from array 211 jeqz passed 212 ldai 1 213 return 214 passed: 215 inci v3, -1 216 lda v3 217 jnez loop 218 check-type: exit-positive 219 template-cases: 220 - values: ['u64[]'] 221 bugid: ['2921'] 222 - values: ['i64[]'] 223 cases: 224 - values: ['0', '1'] 225 - values: ['254', '255'] 226 - values: ['65535', '65536'] 227 - values: ['7', '16'] 228 - values: ['123', '255'] 229 - values: ['49151', '65536'] 230 231 - file-name: "read_all_values" 232 isa: 233 instructions: 234 - sig: ldarr.64 v:in:i64[] 235 acc: inout:i32->i64 236 format: [op_v_8] 237 description: Check ldarr.64 reads correct items from array of primitives. Inspect different indexes and values. 238 code-template: | 239 # 240 movi v1, 0 # v1 - index 241 movi v0, *s 242 # v0 is array size 243 mov v2, v0 # v2 is size too 244 newarr v0, v0, %s # v0 - testable array 245 fill_array: 246 lda v1 247 i32toi64 248 249 starr.64 v0, v1 # v0[v1] = v1 250 inci v1, 1 # v1 = v1 + 1 251 lda v1 252 jne v2, fill_array 253 254 movi v1, 0 # index 255 check_array: 256 lda v1 257 ldarr.64 v0 258 i64toi32 259 sta v3 260 lda v1 261 ucmp v3 262 jeqz ok 263 ldai 1 264 return 265 ok: 266 inci v1, 1 267 lda v1 268 jne v2, check_array 269 check-type: exit-positive 270 template-cases: 271 - values: ['u64[]'] 272 bugid: ['2921'] 273 - values: ['i64[]'] 274 cases: 275 - values: ['100'] 276 - values: ['255'] 277 tags: ['tsan'] 278 - values: ['65535'] 279 tags: ['tsan'] 280 281 - file-name: "reg_number" 282 isa: 283 instructions: 284 - sig: ldarr.64 v:in:i64[] 285 acc: inout:i32->i64 286 format: [op_v_8] 287 check-type: empty 288 runner-options: [compile-only] 289 description: Check 'ldarr.64' instruction with different registers numbers. 290 header-template: [] 291 code-template: | 292 # 293 .function i32 main() { 294 ldarr.64 %s 295 } 296 cases: 297 - values: [v0] 298 - values: [v16] 299 - values: [v128] 300 - values: [v255] 301 - values: [v256] 302 runner-options: [compile-failure] 303 - values: [v65535] 304 runner-options: [compile-failure] 305 - case-template: | 306 # 307 .function void f1(i32 a0) { 308 ldarr.64 a0 # valid name of register 309 } 310 311 .function i32 main() { 312 movi v0, 0 313 call.short f1, v0 314 } 315 - case-template: | 316 # 317 .function void f1(i32 a0) { 318 ldarr.64 a1 # invalid name of register 319 } 320 321 .function i32 main() { 322 movi v0, 0 323 call.short f1, v0 324 } 325 runner-options: [compile-failure] 326 - values: [a0] 327 runner-options: [compile-failure] 328 - values: [a255] 329 runner-options: [compile-failure] 330 - values: ['null'] 331 runner-options: [compile-failure] 332 - values: [0] 333 runner-options: [compile-failure] 334 - values: [1.1] 335 runner-options: [compile-failure] 336 - values: ['2.2'] 337 runner-options: [compile-failure] 338 339 - file-name: "arr_type" 340 isa: 341 instructions: 342 - sig: ldarr.64 v:in:i64[] 343 acc: inout:i32->i64 344 format: [op_v_8] 345 verification: 346 - v1_array_type 347 tags: ['verifier'] 348 bugid: ['2816'] 349 runner-options: ['verifier-failure', 'verifier-config'] 350 header-template: [] 351 code-template: | 352 # 353 .record A {} 354 .record panda.String <external> 355 .record panda.Object <external> 356 .function i32 main() { 357 %s 358 ldai 0 359 ldarr.64 v0 360 check-type: exit-positive 361 description: Check 'ldarr.64' with incorrect array type. See also "rejectable_primitive_types" tests. 362 cases: 363 - values: 364 - movi v0, 0 365 - values: 366 - movi.64 v0, 0 367 - values: 368 - fmovi v0, 0 369 - values: 370 - fmovi.64 v0, 0 371 - values: 372 - | 373 # 374 lda.type A 375 sta.obj v0 376 - values: 377 - | 378 # 379 lda.type A[] 380 sta.obj v0 381 - values: 382 - | 383 # 384 lda.type panda.String 385 sta.obj v0 386 - values: 387 - | 388 # 389 lda.type panda.String[] 390 sta.obj v0 391 - values: 392 - | 393 # 394 lda.type panda.Object 395 sta.obj v0 396 - values: 397 - | 398 # 399 lda.type panda.Object[] 400 sta.obj v0 401 - values: 402 - | 403 # 404 lda.str "string" 405 sta.obj v0 406 - values: 407 - | 408 # 409 movi v0, 1 410 newarr v0, v0, panda.Object[] 411 - values: 412 - | 413 # 414 movi v0, 1 415 newarr v0, v0, panda.String[] 416 417 - file-name: "acc_type" 418 isa: 419 instructions: 420 - sig: ldarr.64 v:in:i64[] 421 acc: inout:i32->i64 422 format: [op_v_8] 423 verification: 424 - acc_i32 425 tags: ['verifier'] 426 bugid: ['2817'] 427 runner-options: ['verifier-failure', 'verifier-config'] 428 header-template: [] 429 code-template: | 430 # 431 .record A {} 432 .record panda.String <external> 433 .record panda.Object <external> 434 .function i32 main() { 435 movi v0, 1 436 newarr v0, v0, i64[] 437 %s 438 ldarr.64 v0 439 check-type: exit-positive 440 description: Check 'ldarr.64' with incorrect index type. 441 cases: 442 - values: 443 - ldai.64 0 444 - values: 445 - fldai 0 446 - values: 447 - fldai.64 0 448 - values: 449 - lda.null 450 - values: 451 - | 452 # 453 lda.type A 454 - values: 455 - | 456 # 457 lda.type A[] 458 - values: 459 - | 460 # 461 lda.type panda.String 462 463 - values: 464 - | 465 # 466 lda.type panda.String[] 467 - values: 468 - | 469 # 470 lda.type panda.Object 471 - values: 472 - | 473 # 474 lda.type panda.Object[] 475 - values: 476 - | 477 # 478 lda.str "string" 479 - values: 480 - | 481 # 482 movi v1, 1 483 newarr v1, v1, panda.Object[] 484 lda.obj v1 485 - values: 486 - | 487 # 488 movi v1, 1 489 newarr v1, v1, panda.String[] 490 lda.obj v1 491 492 - file-name: "arr_acc_type" 493 isa: 494 instructions: 495 - sig: ldarr.64 v:in:i64[] 496 acc: inout:i32->i64 497 format: [op_v_8] 498 verification: 499 - v1_array_type 500 tags: ['verifier'] 501 bugid: ['2816', '2817'] 502 runner-options: ['verifier-failure', 'verifier-config'] 503 header-template: [] 504 code-template: | 505 # 506 .record A {} 507 .record panda.String <external> 508 .record panda.Object <external> 509 .function i32 main() { 510 %s 511 *s 512 ldarr.64 v0 513 check-type: exit-positive 514 description: Check 'ldarr.64' with incorrect register and accumulator types. 515 template-cases: 516 - values: 517 - movi v0, 0 518 - values: 519 - movi.64 v0, 0 520 - values: 521 - fmovi v0, 0 522 - values: 523 - fmovi.64 v0, 0 524 - values: 525 - | 526 # 527 lda.type A 528 sta.obj v0 529 - values: 530 - | 531 # 532 lda.type A[] 533 sta.obj v0 534 - values: 535 - | 536 # 537 lda.type panda.String 538 sta.obj v0 539 - values: 540 - | 541 # 542 lda.type panda.String[] 543 sta.obj v0 544 - values: 545 - | 546 # 547 lda.type panda.Object 548 sta.obj v0 549 - values: 550 - | 551 # 552 lda.type panda.Object[] 553 sta.obj v0 554 - values: 555 - | 556 # 557 lda.str "string" 558 sta.obj v0 559 - values: 560 - | 561 # 562 movi v0, 1 563 newarr v0, v0, panda.Object[] 564 - values: 565 - | 566 # 567 movi v0, 1 568 newarr v0, v0, panda.String[] 569 cases: 570 - values: 571 - ldai 0 572 - values: 573 - ldai.64 0 574 - values: 575 - fldai 0 576 - values: 577 - fldai.64 0 578 - values: 579 - lda.null 580 - values: 581 - | 582 # 583 lda.type A 584 - values: 585 - | 586 # 587 lda.type A[] 588 - values: 589 - | 590 # 591 lda.type panda.String 592 - values: 593 - | 594 # 595 lda.type panda.String[] 596 - values: 597 - | 598 # 599 lda.type panda.Object 600 - values: 601 - | 602 # 603 lda.type panda.Object[] 604 - values: 605 - | 606 # 607 lda.str "string" 608 - values: 609 - | 610 # 611 movi v1, 1 612 newarr v1, v1, panda.Object[] 613 lda.obj v1 614 - values: 615 - | 616 # 617 movi v1, 1 618 newarr v1, v1, panda.String[] 619 lda.obj v1 620 621 - file-name: uninitialized_acc_regs 622 isa: 623 instructions: 624 - sig: ldarr.64 v:in:i64[] 625 acc: inout:i32->i64 626 format: [op_v_8] 627 description: Check 'ldarr.64' with uninitialized register and accumulator. 628 tags: ['verifier'] 629 bugid: ['2818'] 630 runner-options: ['verifier-failure', 'verifier-config'] 631 code-template: | 632 # 633 %s 634 ldarr.64 v0 635 check-type: exit-positive 636 cases: 637 - values: ['ldai 0'] 638 - values: 639 - | 640 # 641 movi v0, 1 642 newarr v0, v0, i64[] 643 - values: [''] 644 645 - file-name: array_out_of_bound_exception_p 646 isa: 647 instructions: 648 - sig: ldarr.64 v:in:i64[] 649 acc: inout:i32->i64 650 format: [op_v_8] 651 exceptions: 652 - x_bounds 653 description: Check 'ldarr.64' behavior when index is out of array bounds. 654 tags: ['irtoc_ignore'] 655 header-template: [aoobe_p, main] 656 code-template: | 657 # 658 movi v0, *s 659 newarr v0, v0, %s 660 ldai *s 661 begin: 662 ldarr.64 v0 663 end: 664 ldai 1 # Should not reach this line 665 return 666 667 catch_AOOBE: 668 ldai 0 # Expected panda.ArrayIndexOutOfBoundsException 669 return 670 671 catch_all: 672 ldai 2 # Unexpected exception, test failed 673 return 674 675 .catch panda.ArrayIndexOutOfBoundsException, begin, end, catch_AOOBE 676 .catchall begin, end, catch_all 677 check-type: none 678 template-cases: 679 - values: ['u64[]'] 680 - values: ['i64[]'] 681 cases: 682 - values: [0, 0] 683 tags: ['tsan'] 684 - values: [0, 1] 685 - values: [10, 10] 686 - values: [10, 128] 687 - values: [255, 255] 688 - values: [254, 255] 689 - values: [65535, 65535] 690 tags: ['tsan'] 691 - values: [65535, 65536] 692 - values: [10, 0xFFFFFFFF] 693 - values: [256, 0xFFFFFFFE] 694 - values: [65536, 0xFFFFFFFD] 695 tags: ['tsan'] 696 - values: [0x100000, 0xFFFFFFFC] 697 - values: [10, 0x80000000] 698 - values: [256, 0x80000001] 699 - values: [65536, 0x80000002] 700 tags: ['tsan'] 701 - values: [0x100000, 0x80000003] 702 703 - file-name: array_out_of_bound_exception_j 704 isa: 705 instructions: 706 - sig: ldarr.64 v:in:i64[] 707 acc: inout:i32->i64 708 format: [op_v_8] 709 exceptions: 710 - x_bounds 711 description: Check 'ldarr.64' behavior when index is out of array bounds. 712 tags: ['irtoc_ignore'] 713 runner-options: [use-pa] 714 header-template: [PandaAssembly, aoobe_j, main] 715 code-template: | 716 # 717 movi v0, %s 718 newarr v0, v0, i64[] 719 ldai %s 720 begin: 721 ldarr.64 v0 722 end: 723 ldai 1 # Should not reach this line 724 return 725 726 catch_AOOBE: 727 ldai 0 # Expected panda.ArrayIndexOutOfBoundsException 728 return 729 730 catch_all: 731 ldai 2 # Unexpected exception, test failed 732 return 733 734 .catch panda.ArrayIndexOutOfBoundsException, begin, end, catch_AOOBE 735 .catchall begin, end, catch_all 736 check-type: none 737 cases: 738 - values: [0, 0] 739 tags: ['tsan'] 740 - values: [0, 1] 741 - values: [10, 10] 742 - values: [10, 128] 743 - values: [255, 255] 744 - values: [254, 255] 745 - values: [65535, 65535] 746 tags: ['tsan'] 747 - values: [65535, 65536] 748 - values: [10, 0xFFFFFFFF] 749 - values: [256, 0xFFFFFFFE] 750 - values: [65536, 0xFFFFFFFD] 751 tags: ['tsan'] 752 - values: [0x100000, 0xFFFFFFFC] 753 - values: [10, 0x80000000] 754 - values: [256, 0x80000001] 755 - values: [65536, 0x80000002] 756 tags: ['tsan'] 757 - values: [0x100000, 0x80000003] 758 759 - file-name: null_pointer_p 760 isa: 761 instructions: 762 - sig: ldarr.64 v:in:i64[] 763 acc: inout:i32->i64 764 format: [op_v_8] 765 exceptions: 766 - x_null 767 description: Check 'ldarr.64' behavior when array is null reference. 768 tags: ['irtoc_ignore'] 769 header-template: [npe_p] 770 code-template: | 771 .function %s get_null() { 772 lda.null 773 return.obj 774 } 775 776 .function i32 main() { 777 call.short get_null 778 sta.obj v0 779 ldai *s 780 begin: 781 ldarr.64 v0 782 end: 783 ldai 1 # Should not reach this line 784 return 785 786 catch_NPE: 787 ldai 0 # Expected panda.NullPointerException 788 return 789 790 catch_all: 791 ldai 2 # Unexpected exception, test failed 792 return 793 794 .catch panda.NullPointerException, begin, end, catch_NPE 795 .catchall begin, end, catch_all 796 check-type: none 797 template-cases: 798 - values: ['u64[]'] 799 - values: ['i64[]'] 800 cases: 801 - values: [0] 802 tags: ['tsan'] 803 - values: [1] 804 - values: [10] 805 - values: [128] 806 - values: [255] 807 - values: [65535] 808 tags: ['tsan'] 809 - values: [0x7FFFFFFF] 810 - values: [0xFFFFFFFF] 811 - values: [0x80000000] 812 813 - file-name: null_pointer_j 814 isa: 815 instructions: 816 - sig: ldarr.64 v:in:i64[] 817 acc: inout:i32->i64 818 format: [op_v_8] 819 exceptions: 820 - x_null 821 description: Check 'ldarr.64' behavior when array is null reference. 822 tags: ['irtoc_ignore'] 823 header-template: [PandaAssembly, npe_j] 824 runner-options: [use-pa] 825 bugid: ['3047'] 826 code-template: | 827 .function i64[] get_null() { 828 lda.null 829 return.obj 830 } 831 832 .function i32 main() { 833 call.short get_null 834 sta.obj v0 835 ldai %s 836 begin: 837 ldarr.64 v0 838 end: 839 ldai 1 # Should not reach this line 840 return 841 842 catch_NPE: 843 ldai 0 # Expected panda.NullPointerException 844 return 845 846 catch_all: 847 ldai 2 # Unexpected exception, test failed 848 return 849 850 .catch panda.NullPointerException, begin, end, catch_NPE 851 .catchall begin, end, catch_all 852 check-type: none 853 cases: 854 - values: [0] 855 tags: ['tsan'] 856 - values: [1] 857 - values: [10] 858 - values: [128] 859 - values: [255] 860 - values: [65535] 861 tags: ['tsan'] 862 - values: [0x7FFFFFFF] 863 - values: [0xFFFFFFFF] 864 - values: [0x80000000] 865