1# Copyright (c) 2021 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: java 16 template: | 17 .language Java 18 - name: aoobe_p 19 template: | 20 .record panda.ArrayIndexOutOfBoundsException<external> 21 - name: aoobe_j 22 template: | 23 .record java.lang.ArrayIndexOutOfBoundsException<external> 24 - name: npe_p 25 template: | 26 .record panda.NullPointerException <external> 27 - name: npe_j 28 template: | 29 .record java.lang.NullPointerException <external> 30 31tests: 32 - file-name: "fstarr.64" 33 isa: 34 title: Store to array 35 description: > 36 Store accumulator content into array slot pointed by index. 37 instructions: 38 - sig: fstarr.64 v1:in:f64[], v2:in:i32 39 acc: in:f64 40 format: [op_v1_4_v2_4] 41 properties: [acc_read, float] 42 commands: 43 44 45 - file-name: "reg_valid" 46 isa: 47 instructions: 48 - sig: fstarr.64 v1:in:f64[], v2:in:i32 49 acc: in:f64 50 format: [op_v1_4_v2_4] 51 properties: [acc_read, float] 52 check-type: empty 53 runner-options: [compile-only] 54 description: Check 'fstarr.64' instruction with valid register numbers. 55 header-template: [] 56 code-template: | 57 # 58 .function i32 main() { 59 fstarr.64 %s, %s 60 ldai 0 61 return 62 } 63 cases: 64 - values: [v0, v15] 65 - values: [v15, v0] 66 - values: [v15, v15] 67 - case-template: | 68 # 69 .function i32 f1(f64[] a0, i32 a1) { 70 fstarr.64 a0, a1 # valid registers 71 ldai 0 72 return 73 } 74 75 .function i32 main() { 76 call.short f1, v1, v2 77 return 78 } 79 80 81 - file-name: "reg_v_invalid" 82 isa: 83 instructions: 84 - sig: fstarr.64 v1:in:f64[], v2:in:i32 85 acc: in:f64 86 format: [op_v1_4_v2_4] 87 properties: [acc_read, float] 88 runner-options: [compile-failure] 89 description: Check 'fstarr.64' instruction with invalid register numbers. 90 code-template: | 91 # 92 fstarr.64 %s, *s 93 check-type: exit-positive 94 template-cases: 95 - values: [v0] 96 exclude: [v0, v15] 97 - values: [v15] 98 exclude: [v0, v15] 99 - values: [v255] 100 - values: [v256] 101 - values: [v65536] 102 - values: [a0] 103 - values: ['V1'] 104 - values: [null] 105 - values: [0] 106 cases: 107 - values: [v0] 108 id: v0 109 - values: [v15] 110 id: v15 111 - values: [v255] 112 - values: [v256] 113 - values: [v65536] 114 - values: [a0] 115 - values: ['V1'] 116 - values: [null] 117 - values: [0] 118 119 120 - file-name: "reg_a_invalid" 121 isa: 122 instructions: 123 - sig: fstarr.64 v1:in:f64[], v2:in:i32 124 acc: in:f64 125 format: [op_v1_4_v2_4] 126 properties: [acc_read, float] 127 runner-options: [compile-failure] 128 description: Check 'fstarr.64' instruction with invalid register numbers. 129 header-template: [] 130 code-template: | 131 # 132 .function void f1(f64[] a0, i32 a1) { 133 fstarr.64 %s 134 return.void 135 } 136 137 .function i32 main() { 138 call.short f1, v1, v2 139 check-type: exit-positive 140 cases: 141 - values: 142 - 'a0, a2' 143 - values: 144 - 'a2, a1' 145 146 147 - file-name: null_pointer_p 148 isa: 149 exceptions: 150 - x_null 151 description: Check 'fstarr.64' behavior when array is null reference. 152 header-template: [npe_p] 153 code-template: | 154 .function f64[] get_null() { 155 lda.null 156 return.obj 157 } 158 .function i32 main() { 159 call.short get_null 160 sta.obj v0 161 movi v1, %s 162 fldai.64 0 163 begin: 164 fstarr.64 v0, v1 165 end: 166 ldai 1 # Should not reach this line 167 return 168 169 catch_NPE: 170 ldai 0 # Expected panda.NullPointerException 171 return 172 173 catch_all: 174 ldai 2 # Unexpected exception, test failed 175 return 176 177 .catch panda.NullPointerException, begin, end, catch_NPE 178 .catchall begin, end, catch_all 179 check-type: none 180 cases: 181 - values: [0] 182 tags: ['tsan'] 183 - values: [1] 184 - values: [10] 185 - values: [128] 186 - values: [255] 187 - values: [65535] 188 tags: ['tsan'] 189 - values: [0x7FFFFFFF] 190 - values: [0xFFFFFFFF] 191 - values: [0x80000000] 192 193 194 - file-name: array_out_of_bounds_exception_p 195 isa: 196 exceptions: 197 - x_bounds 198 description: Check 'fstarr.64' behavior when index is out of array bounds. 199 header-template: [aoobe_p, main] 200 code-template: | 201 # 202 movi v0, %s 203 newarr v0, v0, f64[] 204 movi v1, %s 205 fldai.64 0 206 begin: 207 fstarr.64 v0, v1 208 end: 209 ldai 1 # Should not reach this line 210 return 211 212 catch_AOOBE: 213 ldai 0 # Expected panda.ArrayIndexOutOfBoundsException 214 return 215 216 catch_all: 217 ldai 2 # Unexpected exception, test failed 218 return 219 220 .catch panda.ArrayIndexOutOfBoundsException, begin, end, catch_AOOBE 221 .catchall begin, end, catch_all 222 check-type: none 223 cases: 224 - values: [0, 0] 225 tags: ['tsan'] 226 - values: [0, 1] 227 - values: [10, -10] 228 - values: [10, 128] 229 - values: [255, 255] 230 - values: [254, 255] 231 - values: [65535, 65535] 232 tags: ['tsan'] 233 - values: [65535, 65536] 234 - values: [10, 0xFFFFFFFF] 235 - values: [256, 0xFFFFFFFE] 236 - values: [65536, 0xFFFFFFFD] 237 tags: ['tsan'] 238 - values: [0x100000, 0xFFFFFFFC] 239 - values: [10, 0x80000000] 240 - values: [256, 0x80000001] 241 - values: [65536, 0x80000002] 242 tags: ['tsan'] 243 - values: [0x100000, 0x80000003] 244 245 246 - file-name: uninitialized_regs 247 isa: 248 verification: 249 - v1_array_type 250 - v2_i32 251 - acc_type 252 description: Check 'fstarr.64' with uninitialized registers 253 tags: ['verifier'] 254 runner-options: ['verifier-failure', 'verifier-debug-config'] 255 header-template: [] 256 code-template: | 257 # 258 .function i32 main() { 259 %s 260 fstarr.64 v1, v2 261 check-type: exit-positive 262 cases: 263 - values: 264 - | 265 # acc is not initialized 266 movi v0, 10 267 newarr v1, v0, f64[] 268 movi v2, 0 269 - values: 270 - | 271 # v1 is not initialized 272 movi v2, 0 273 fldai.64 0 274 - values: 275 - | 276 # v2 is not initialized 277 movi v0, 10 278 newarr v1, v0, f64[] 279 fldai.64 0 280 - values: 281 - | 282 # all regs are not initialized 283 284 285 - file-name: "acceptable_primitive_types_p" 286 isa: 287 verification: 288 - v1_array_type 289 description: Check acceptable array of primitive types for fstarr.64 instruction in Panda Assembly context. 290 runner-options: ['verifier-only', 'verifier-debug-config'] 291 tags: ['verifier'] 292 header-template: [main] 293 code-template: | 294 # 295 movi v0, 1 296 newarr v1, v0, f64[] 297 movi v2, 0 298 fldai.64 0 299 fstarr.64 v1, v2 300 check-type: exit-positive 301 302 303 - file-name: "rejectable_primitive_types_p" 304 isa: 305 verification: 306 - v1_array_type 307 description: Check rejectable array of primitive types for fstarr.64 instruction in Panda Assembly context. 308 runner-options: ['verifier-failure', 'verifier-debug-config'] 309 tags: ['verifier'] 310 header-template: [main] 311 code-template: | 312 # 313 movi v0, 1 314 newarr v1, v0, %s 315 movi v2, 0 316 fldai.64 0 317 fstarr.64 v1, v2 318 check-type: exit-positive 319 cases: 320 - values: ['u1[]'] 321 - values: ['i8[]'] 322 - values: ['u8[]'] 323 - values: ['i16[]'] 324 - values: ['u16[]'] 325 - values: ['i32[]'] 326 - values: ['u32[]'] 327 - values: ['i64[]'] 328 - values: ['u64[]'] 329 - values: ['f32[]'] 330 331 332 - file-name: "arr_type_p" 333 isa: 334 verification: 335 - v1_array_type 336 description: Check 'fstarr.64' with incorrect array type in Panda Assembly context. See also "rejectable_primitive_types" tests. 337 runner-options: ['verifier-failure', 'verifier-debug-config'] 338 tags: ['verifier'] 339 header-template: [] 340 code-template: | 341 # 342 .record A {} 343 .function void A.ctor(A a0) <ctor> { 344 return.void 345 } 346 .record panda.String <external> 347 .record panda.Object <external> 348 .function i32 main() { 349 %s 350 movi v1, 0 351 fldai.64 0 352 fstarr.64 v0, v1 353 check-type: exit-positive 354 cases: 355 - values: 356 - movi v0, 0 357 - values: 358 - movi.64 v0, 0 359 - values: 360 - fmovi.64 v0, 0 361 - values: 362 - | 363 # 364 initobj A.ctor 365 sta.obj v0 366 - values: 367 - | 368 # 369 movi v0, 1 370 newarr v0, v0, A[] 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 418 - file-name: "index_type_p" 419 isa: 420 verification: 421 - v2_i32 422 description: Check 'fstarr.64' with incorrect array index type in Panda Assembly context. 423 runner-options: ['verifier-failure', 'verifier-debug-config'] 424 tags: ['verifier'] 425 header-template: [] 426 code-template: | 427 # 428 .record A {} 429 .function void A.ctor(A a0) <ctor> { 430 return.void 431 } 432 .record panda.String <external> 433 .record panda.Object <external> 434 .function i32 main() { 435 movi v0, 1 436 newarr v1, v0, *s 437 %s 438 fldai.64 0 439 fstarr.64 v1, v2 440 check-type: exit-positive 441 cases: 442 - values: ['f64[]'] 443 template-cases: 444 - values: 445 - mov.null v2 446 - values: 447 - movi.64 v2, 0 448 - values: 449 - fmovi.64 v2, 0 450 - values: 451 - | 452 # 453 initobj A.ctor 454 sta.obj v1 455 - values: 456 - | 457 # 458 movi v0, 1 459 newarr v2, v0, A[] 460 - values: 461 - | 462 # 463 lda.type A 464 sta.obj v2 465 - values: 466 - | 467 # 468 lda.type A[] 469 sta.obj v2 470 - values: 471 - | 472 # 473 lda.type panda.String 474 sta.obj v2 475 - values: 476 - | 477 # 478 lda.type panda.String[] 479 sta.obj v2 480 - values: 481 - | 482 # 483 lda.type panda.Object 484 sta.obj v2 485 - values: 486 - | 487 # 488 lda.type panda.Object[] 489 sta.obj v2 490 - values: 491 - | 492 # 493 lda.str "string" 494 sta.obj v2 495 - values: 496 - | 497 # 498 movi v0, 1 499 newarr v2, v0, panda.Object[] 500 - values: 501 - | 502 # 503 movi v0, 1 504 newarr v2, v0, panda.String[] 505 506 507 - file-name: "acc_type_p" 508 isa: 509 verification: 510 - acc_type 511 description: Check 'fstarr.64' with incorrect accumulator type in Panda Assembly context. 512 runner-options: ['verifier-failure', 'verifier-debug-config'] 513 tags: ['verifier'] 514 header-template: [] 515 code-template: | 516 # 517 .record A {} 518 .function void A.ctor(A a0) <ctor> { 519 return.void 520 } 521 .record panda.String <external> 522 .record panda.Object <external> 523 .function i32 main() { 524 movi v0, 1 525 newarr v1, v0, *s 526 movi v2, 0 527 %s 528 fstarr.64 v1, v2 529 check-type: exit-positive 530 cases: 531 - values: ['f64[]'] 532 template-cases: 533 - values: 534 - lda.null 535 - values: 536 - ldai.64 0 537 - values: 538 - ldai 0 539 - values: 540 - | 541 # 542 initobj A.ctor 543 - values: 544 - | 545 # 546 lda.type A 547 - values: 548 - | 549 # 550 lda.type panda.String 551 - values: 552 - | 553 # 554 lda.type panda.String[] 555 - values: 556 - | 557 # 558 lda.type panda.Object 559 - values: 560 - | 561 # 562 lda.type panda.Object[] 563 - values: 564 - | 565 # 566 lda.str "string" 567 - values: 568 - | 569 # 570 movi v0, 1 571 newarr v0, v0, panda.Object[] 572 lda.obj v0 573 - values: 574 - | 575 # 576 movi v0, 1 577 newarr v0, v0, panda.String[] 578 lda.obj v0 579 580 581 - file-name: "mult_regs_types_p" 582 isa: 583 verification: 584 - v1_array_type 585 - v2_i32 586 - acc_type 587 description: Check 'fstarr.64' with multiple incorrect register types in Panda Assembly context. 588 runner-options: ['verifier-failure', 'verifier-debug-config'] 589 tags: ['verifier'] 590 header-template: [] 591 code-template: | 592 # 593 .record A {} 594 .function void A.ctor(A a0) <ctor> { 595 return.void 596 } 597 .record panda.String <external> 598 .record panda.Object <external> 599 .function void panda.Object.ctor(panda.Object a0) <external,ctor> 600 .function i32 main() { 601 %s 602 fstarr.64 v1, v2 603 check-type: exit-positive 604 cases: 605 - values: 606 - | 607 # all registers invalid 608 initobj panda.Object.ctor 609 sta.obj v1 610 movi.64 v2, 0 611 lda.str "test string" 612 - values: 613 - | 614 # v1 and v2 invalid 615 lda.str "test string" 616 sta.obj v1 617 fmovi.64 v2, 1 618 ldai 0 619 - values: 620 - | 621 # v1 and acc invalid 622 lda.type panda.Object 623 sta.obj v1 624 movi v2, 0 625 lda.str "test string" 626 - values: 627 - | 628 # v2 and acc invalid 629 movi v0, 1 630 newarr v1, v0, f64[] 631 sta.obj v2 632 initobj A.ctor 633 634 635 - file-name: "store_arr_p" 636 isa: 637 instructions: 638 - sig: fstarr.64 v1:in:f64[], v2:in:i32 639 acc: in:f64 640 format: [op_v1_4_v2_4] 641 properties: [acc_read, float] 642 description: Check fstarr.64 stores items to array of different size and type in Panda Assembly context. 643 code-template: | 644 # 645 movi v0, *s 646 newarr v1, v0, %s 647 movi v2, *s 648 fldai.64 1234567890.0 649 fstarr.64 v1, v2 650 check-type: exit-positive 651 template-cases: 652 - values: ['f64[]'] 653 cases: 654 - values: ['1', '0'] 655 - values: ['255', '254'] 656 tags: ['tsan'] 657 - values: ['65536', '65535'] 658 659 660 - file-name: "store_all_elements" 661 isa: 662 description: > 663 Store accumulator content into array slot pointed by index. 664 description: Check fstarr.64 stores correct items into array of primitives. 665 header-template: [] 666 code-template: | 667 .function i32 main() { 668 movi v7, *s # v7 is array size 669 newarr v1, v7, %s # v1 - testable array 670 671 movi v2, 0 # array index 672 fill_array: 673 lda v2 674 i32tof64 675 fstarr.64 v1, v2 # v1[v2] = acc 676 inci v2, 1 # v2 = v2 + 1 677 lda v2 678 jne v7, fill_array 679 inci v2, -1 680 check_array: 681 lda v2 682 i32tof64 683 sta.64 v3 # value to compare with 684 lda v2 685 fldarr.64 v1 686 fcmpg.64 v3 687 jeqz ok 688 ldai 2 689 return 690 ok: 691 inci v2, -1 692 lda v2 693 jgez check_array 694 check-type: exit-positive 695 template-cases: 696 - values: 697 - f64[] 698 cases: 699 - values: [10000] 700 tags: ['tsan'] 701