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: [] 15tests: 16 - file-name: "fdiv2" 17 isa: 18 title: Two address floating-point binary operation on accumulator 19 description: > 20 Perform specified floating-point binary operation on accumulator and register and store result into accumulator. 21 The results of instructions correspond IEEE-754 arithmetic rules. 22 exceptions: 23 - x_none 24 commands: 25 - file-name: "op_vs_8_nan" 26 isa: 27 instructions: 28 - sig: fdiv2 v:in:f32 29 acc: inout:f32 30 format: [op_v_8] 31 description: Any operation with NaN results to NaN value. 32 check-type: check-acc-nan-f32 33 tags: ['irtoc_ignore'] 34 code-template: | 35 # 36 fldai %s 37 fmovi v0, *s 38 fdiv2 v0 39 description: > 40 Check fdiv2 results in NaN when acc or v0 is NaN 41 template-cases: 42 - values: 43 # NaN 44 - "0x7fc00000" 45 - values: 46 # NaN representation 47 - "0xFFFFFFFF" 48 - values: 49 # Positive zero 50 - "0" 51 bugid: ["966", "965"] 52 exclude: [hasval] 53 - values: 54 # Negative zero 55 - "0x80000000" 56 bugid: ["966", "965"] 57 exclude: [hasval] 58 - values: 59 # 1d 60 - "1.0" 61 bugid: ["966", "965"] 62 exclude: [hasval] 63 - values: 64 - "-1" 65 exclude: [hasval] 66 - values: 67 # +Inf 68 - "0x7f800000" 69 exclude: [hasval] 70 - values: 71 # -Inf 72 - "0xff800000" 73 exclude: [hasval] 74 - values: 75 # +max 76 - "0x7f7fffff" 77 exclude: [hasval] 78 - values: 79 # -max 80 - "0xff7fffff" 81 exclude: [hasval] 82 - values: 83 # +min 84 - "0x00000001" 85 exclude: [hasval] 86 - values: 87 # -min 88 - "0x80000001" 89 exclude: [hasval] 90 - values: 91 # Some FP value, 3.14159265358979323846 92 - "0x40490fdb" 93 exclude: [hasval] 94 - values: 95 # Some FP value 96 - "1234567890" 97 exclude: [hasval] 98 cases: 99 - values: 100 # NaN 101 - "0x7fc00000" 102 - values: 103 # NaN representation 104 - "0xFFFFFFFF" 105 - values: 106 # Positive zero 107 - "0" 108 bugid: ["966", "965"] 109 id: hasval 110 - values: 111 # Negative zero 112 - "0x8000000" 113 bugid: ["966", "965"] 114 id: hasval 115 - values: 116 # 1d 117 - "1.0" 118 bugid: ["966", "965"] 119 id: hasval 120 - values: 121 - "-1" 122 id: hasval 123 - values: 124 # +Inf 125 - "0x7f800000" 126 id: hasval 127 - values: 128 # -Inf 129 - "0xff800000" 130 id: hasval 131 - values: 132 # +max 133 - "0x7f7ffffff" 134 id: hasval 135 - values: 136 # -max 137 - "0xff7ffffff" 138 id: hasval 139 - values: 140 # +min 141 - "0x000000001" 142 id: hasval 143 - values: 144 # -min 145 - "0x800000001" 146 id: hasval 147 - values: 148 # Some FP value, 3.1415927 149 - "0x40490fdb" 150 id: hasval 151 - values: 152 # Some FP value 153 - "1234567890" 154 id: hasval 155 156 - file-name: "op_vs_8_pinf" 157 isa: 158 instructions: 159 - sig: fdiv2 v:in:f32 160 acc: inout:f32 161 format: [op_v_8] 162 description: Division is infinity if any non zero value is divided by zero. 163 check-type: check-positive 164 tags: ['irtoc_ignore'] 165 code-template: | 166 # 167 fldai 0x7f800000 # +Inf 168 fmovi v0, %s 169 # Div of +Inf and value 170 fdiv2 v0 171 fmovi v1, %s 172 fcmpg v1 173 description: Check fdiv2 with positive Inf and various values (NaN, Inf, min, max, numbers). 174 cases: 175 - values: 176 - "0" 177 # Inf 178 - "0x7f800000" 179 bugid: ["966", "965"] 180 - values: 181 # -0.0d 182 - "0x80000000" 183 # -Inf 184 - "0xFF800000" 185 bugid: ["966", "965"] 186 - values: 187 # 1d 188 - "1" 189 # Inf 190 - "0x7f800000" 191 - values: 192 - "-1" 193 # -Inf 194 - "0xFF800000" 195 - values: 196 # +max 197 - "0x7f7fffff" 198 # Inf 199 - "0x7F800000" 200 - values: 201 # -max 202 - "0xff7fffff" 203 # -Inf 204 - "0xFF800000" 205 - values: 206 # +min 207 - "0x00000001" 208 # Inf 209 - "0x7F800000" 210 - values: 211 # -min 212 - "0x80000001" 213 # -Inf 214 - "0xFF800000" 215 - values: 216 # Some FP value, 3.1415927 217 - "0x40490fdb" 218 # Inf 219 - "0x7F800000" 220 - values: 221 - "1234567890" 222 # Inf 223 - "0x7F800000" 224 225 - file-name: "op_vs_8_ninf" 226 isa: 227 instructions: 228 - sig: fdiv2 v:in:f32 229 acc: inout:f32 230 format: [op_v_8] 231 description: Division is infinity if any non zero value is divided by zero. 232 check-type: check-positive 233 tags: ['irtoc_ignore'] 234 code-template: | 235 # 236 fldai 0xff800000 # -Inf 237 fmovi v0, %s 238 # Div of -Inf and value 239 fdiv2 v0 240 fmovi v1, %s 241 fcmpg v1 242 description: Check fdiv2 with negative Inf and various values (NaN, Inf, min, max, numbers). 243 cases: 244 - values: 245 - "0" 246 # -Inf 247 - "0xff800000" 248 bugid: ["966", "965"] 249 - values: 250 # -0.0d 251 - "0x80000000" 252 # +Inf 253 - "0x7F800000" 254 bugid: ["966", "965"] 255 - values: 256 # 1d 257 - "1" 258 # -Inf 259 - "0xff800000" 260 - values: 261 - "-1" 262 # +Inf 263 - "0x7F800000" 264 - values: 265 # +max 266 - "0x7f7fffff" 267 # -Inf 268 - "0xff800000" 269 - values: 270 # -max 271 - "0xff7fffff" 272 # +Inf 273 - "0x7F800000" 274 - values: 275 # +min 276 # - "0x00000001" 277 - "1" 278 # -Inf 279 - "0xff800000" 280 - values: 281 # -min 282 - "0x80000001" 283 # +Inf 284 - "0x7F800000" 285 - values: 286 # Some FP value, 3.14159265358979323846 287 - "0x40490fdb" 288 # -Inf 289 - "0xff800000" 290 291 - values: 292 - "1234567890" 293 # -Inf 294 - "0xff800000" 295 296 - file-name: "op_vs_8_inf_nan" 297 isa: 298 instructions: 299 - sig: fdiv2 v:in:f32 300 acc: inout:f32 301 format: [op_v_8] 302 description: > 303 Division is NaN if Infinity is divided by Infinity. 304 check-type: check-acc-nan-f32 305 tags: ['irtoc_ignore'] 306 code-template: | 307 # 308 fldai %s 309 fmovi v0, *s 310 # Div of Inf by Inf 311 fdiv2 v0 312 description: > 313 Check fdiv2 of Inf by Inf is NaN. 314 template-cases: 315 - values: ["0x7f800000"] 316 - values: ["0xff800000"] 317 cases: 318 - values: ["0x7f800000"] 319 - values: ["0xff800000"] 320 321 - file-name: "op_vs_8_pzero" 322 isa: 323 instructions: 324 - sig: fdiv2 v:in:f32 325 acc: inout:f32 326 format: [op_v_8] 327 check-type: check-positive 328 tags: ['irtoc_ignore'] 329 code-template: | 330 # 331 fldai 0.0 # 332 fmovi v0, %s 333 # Div of +0.0 and value 334 fdiv2 v0 335 fmovi v1, %s 336 fcmpg v1 337 description: Check fdiv2 with +0 and various values (NaN, Inf, min, max, numbers). 338 cases: 339 - values: 340 # +Inf 341 - "0x7f800000" 342 - "0" 343 - values: 344 # -Inf 345 - "0xff800000" 346 # -0.0 347 - "0x80000000" 348 - values: 349 # 1d 350 - "1" 351 - "0" 352 - values: 353 # -1d 354 - "-1" 355 - "-0.0" 356 - values: 357 # +max 358 - "0x7f7fffff" 359 - "0" 360 - values: 361 # -max 362 - "0xff7fffff" 363 # -0.0 364 - "0x80000000" 365 - values: 366 # +min 367 - "0x00000001" 368 - "0" 369 - values: 370 # -min 371 - "0x80000001" 372 # -0.0 373 - "0x80000000" 374 - values: 375 # Some FP value, 376 - "3.1415927" 377 - "0" 378 379 - file-name: "op_vs_8_nzero" 380 isa: 381 instructions: 382 - sig: fdiv2 v:in:f32 383 acc: inout:f32 384 format: [op_v_8] 385 check-type: check-positive 386 tags: ['irtoc_ignore'] 387 code-template: | 388 # 389 fldai -0.0 # 390 fmovi v0, %s 391 # Div of -0.0 and value 392 fdiv2 v0 393 fmovi v1, %s 394 fcmpg v1 395 description: Check fdiv2 with -0 and various values (NaN, Inf, min, max, numbers). 396 cases: 397 - values: 398 # +Inf 399 - "0x7f800000" 400 # -0.0d 401 - "0x80000000" 402 - values: 403 # -Inf 404 - "0xff800000" 405 - "0" 406 - values: 407 # 1d 408 - "1" 409 - "0" 410 - values: 411 - "-1" 412 - "0" 413 - values: 414 # +max 415 - "0x7f7fffff" 416 - "0" 417 - values: 418 # -max 419 - "0xff7fffff" 420 - "0" 421 - values: 422 # +min 423 - "0x00000001" 424 # -0.0d 425 - "0x80000000" 426 - values: 427 # -min 428 - "0x80000001" 429 - "0" 430 - values: 431 - "3.1415927" 432 - "0" 433 - values: 434 # Some FP value, 435 - "-3.1415927" 436 - "0" 437 - file-name: "op_vs_8_pone" 438 isa: 439 instructions: 440 - sig: fdiv2 v:in:f32 441 acc: inout:f32 442 format: [op_v_8] 443 description: Division is infinity if any non zero value is divided by zero. 444 check-type: check-positive 445 tags: ['irtoc_ignore'] 446 code-template: | 447 # 448 fldai 1.0 # 449 fmovi v0, %s 450 # Div of 1.0 and value 451 fdiv2 v0 452 fmovi v1, %s 453 fcmpg v1 454 description: Check fdiv2 with +1 and various values (NaN, Inf, min, max, numbers). 455 cases: 456 - values: 457 # +0.0d 458 - "0" 459 # +Inf 460 - "0x7f800000" 461 bugid: ["966", "965"] 462 - values: 463 # -0.0d 464 - "0x80000000" 465 # -Inf 466 - "0xff800000" 467 bugid: ["966", "965"] 468 - values: 469 - "1" 470 - "1" 471 - values: 472 - "-1" 473 - "-1" 474 - values: 475 # +Inf 476 - "0x7f800000" 477 - "0" 478 - values: 479 # -Inf 480 - "0xff800000" 481 # -0.0d 482 - "0x80000000" 483 - values: 484 # +max 485 - "0x7f7fffff" 486 - "0x00200000" 487 - values: 488 # -max 489 - "0xff7fffff" 490 - "0x80200000" 491 - values: 492 # +min 493 - "0x00000001" 494 # +Inf 495 - "0x7F800000" 496 - values: 497 # -min 498 - "0x80000001" 499 # -Inf 500 - "0xFF800000" 501 - values: 502 - "3.1415927" 503 - "0x3ea2f983" 504 - values: 505 - "-3.1415927" 506 - "0xbea2f983" 507 508 - values: 509 # Some FP value 510 - "1234.9876" 511 - "0x3a5443b5" 512 513 - file-name: "op_vs_8_none" 514 isa: 515 instructions: 516 - sig: fdiv2 v:in:f32 517 acc: inout:f32 518 format: [op_v_8] 519 description: Division is infinity if any non zero value is divided by zero. 520 check-type: check-positive 521 tags: ['irtoc_ignore'] 522 code-template: | 523 # 524 fldai -1.0 # 525 fmovi v0, %s 526 # Div of -1.0 and value 527 fdiv2 v0 528 fmovi v1, %s 529 fcmpg v1 530 description: Check fdiv2 with -1 and various values (NaN, Inf, min, max, numbers). 531 cases: 532 - values: 533 # +0.0d 534 - "0" 535 # -Inf 536 - "0xFF800000" 537 bugid: ["966", "965"] 538 - values: 539 # -0.0d 540 - "0x80000000" 541 # +Inf 542 - "0x7F800000" 543 bugid: ["966", "965"] 544 - values: 545 # 1d 546 - "1" 547 - "-1" 548 - values: 549 - "-1" 550 - "1" 551 bugid: ["966", "965"] 552 - values: 553 # +Inf 554 - "0x7f800000" 555 - "0x80000000" 556 - values: 557 # -Inf 558 - "0xFF800000" 559 - "0" 560 - values: 561 # +max 562 - "0x7f7fffff" 563 - "0x80200000" 564 - values: 565 # -max 566 - "0xff7fffff" 567 - "0x00200000" 568 - values: 569 # +min 570 - "0x00000001" 571 # -Inf 572 - "0xFF800000" 573 - values: 574 # -min 575 - "0x80000001" 576 # +Inf 577 - "0x7F800000" 578 - values: 579 # Some FP value, 3.1415927 580 - "0x40490fdb" 581 - "0xbea2f983" 582 - values: 583 # Some FP value, -3.1415927 584 - "0xc0490fdb" 585 - "0x3ea2f983" 586 - values: 587 # Some FP value 588 - "1234.9876" 589 - "0xba5443b5" 590 591 - file-name: "op_vs_8" 592 isa: 593 instructions: 594 - sig: fdiv2 v:in:f32 595 acc: inout:f32 596 format: [op_v_8] 597 check-type: check-positive 598 tags: ['irtoc_ignore'] 599 code-template: | 600 # 601 fldai %s # 602 fmovi v0, %s 603 # Div of -1.0 and value 604 fdiv2 v0 605 fmovi v1, %s 606 fcmpg v1 607 description: Check fdiv2 with various values. 608 cases: 609 - values: 610 - "1.0" 611 - "-1.0" 612 - "-1.0" 613 - values: 614 - "1.0" 615 - "1.0" 616 - "1.0" 617 - values: 618 - "-1.0" 619 - "1.0" 620 - "-1.0" 621 - values: 622 - "1.0e10" 623 - "1.0e10" 624 - "1.0" 625 - values: 626 - "1.0e10" 627 - "-1.0e10" 628 - "-1.0" 629 - values: 630 - "1.0e+10" 631 - "1.0e-10" 632 - "1.0e+20" 633 - values: 634 - "-1.0e10" 635 - "1.0e10" 636 - "-1.0" 637 - values: 638 - "-1.0e-10" 639 - "1.0e-10" 640 - "-1.0" 641 - values: 642 - "-1.0e+10" 643 - "-1.0e-10" 644 - "1.0e+20" 645 - values: 646 - "3.1415927" 647 - "-3.1415927" 648 - "-1.0" 649 - values: 650 - "3.1415927e10" 651 - "-3.1415927e10" 652 - "-1.0" 653# - values: 654# # TODO add test cases for maximal and minimal FP value in decimal scientific literal 655 - file-name: "op_vs_8_max" 656 isa: 657 instructions: 658 - sig: fdiv2 v:in:f32 659 acc: inout:f32 660 format: [op_v_8] 661 check-type: check-positive 662 tags: ['irtoc_ignore'] 663 code-template: | 664 # 665 fldai %s 666 fmovi v0, %s 667 # Div of two values 668 fdiv2 v0 669 fmovi v1, %s 670 fcmpg v1 671 description: Check fdiv2 with various max values. 672 cases: 673 - values: 674 # +max 675 - "0x7f7fffff" 676 # +max 677 - "0x7f7fffff" 678 - "1" 679 - values: 680 # -max 681 - "0xff7fffff" 682 # -max 683 - "0xff7fffff" 684 - "1" 685 - values: 686 # +max 687 - "0x7f7fffff" 688 # -max 689 - "0xff7fffff" 690 - "-1" 691 - values: 692 # -max 693 - "0xff7fffff" 694 # +max 695 - "0x7f7fffff" 696 - "-1" 697 698 - values: 699 # +max 700 - "0x7f7fffff" 701 # 1d 702 - "1" 703 # +max 704 - "0x7f7fffff" 705 706 - values: 707 # +max 708 - "0x7f7fffff" 709 - "-1" 710 # -max 711 - "0xff7fffff" 712 - values: 713 # -max 714 - "0xff7fffff" 715 # 1d 716 - "1" 717 # -max 718 - "0xff7fffff" 719 - values: 720 # -max 721 - "0xff7fffff" 722 - "-1" 723 # +max 724 - "0x7f7fffff" 725 726 - file-name: "op_vs_8_zeroes_nan" 727 bugid: ["966", "965"] 728 isa: 729 instructions: 730 - sig: fdiv2 v:in:f32 731 acc: inout:f32 732 format: [op_v_8] 733 description: Division is NaN if zero is divided by zero. 734 check-type: check-acc-nan-f32 735 tags: ['irtoc_ignore'] 736 code-template: | 737 # 738 fldai %s # 739 fmovi v0, %s 740 # Div of zero by zero 741 fdiv2 v0 742 cases: 743 - values: 744 - "0.0" 745 - "0.0" 746 - values: 747 - "0.0" 748 - "-0.0" 749 - values: 750 - "-0.0" 751 - "0.0" 752 - values: 753 - "-0.0" 754 - "-0.0" 755 756 - file-name: "incorrect_reg" 757 isa: 758 instructions: 759 - sig: fdiv2 v:in:f32 760 acc: inout:f32 761 format: [op_v_8] 762 check-type: none 763 runner-options: [compile-failure] 764 description: Check fdiv2 with incorrect register numbers. 765 code-template: | 766 # 767 fdiv2 %s 768 cases: 769 - values: [v256] 770 - values: [v65535] 771 - values: [a0] 772 - values: [a255] 773 - values: ['null'] 774 - values: [0] 775 - values: [1.1] 776 - values: ['2.2'] 777 778 - file-name: "reg_number" 779 isa: 780 instructions: 781 - sig: fdiv2 v:in:f32 782 acc: inout:f32 783 format: [op_v_8] 784 check-type: none 785 runner-options: [compile-only] 786 description: Check fdiv2 with correct register numbers. 787 code-template: | 788 # 789 fdiv2 %s 790 cases: 791 - values: [v0] 792 - values: [v16] 793 - values: [v128] 794 - values: [v255] 795 796 - file-name: "calc" 797 isa: 798 instructions: 799 - sig: fdiv2 v:in:f32 800 acc: inout:f32 801 format: [op_v_8] 802 check-type: check-positive 803 code-template: | 804 # 805 fldai %s # 806 fmovi v0, %s 807 fdiv2 v0 808 fmovi v1, %s 809 fcmpg v1 810 description: Check fdiv2 with various values. 811 tags: ['tsan', 'irtoc_ignore'] 812 cases: 813 - values: 814 - "0.2163294" 815 - "-0.3406104" 816 - "-0.63512266" 817 - values: 818 - "0.3657011" 819 - "0.0702997" 820 - "5.202029" 821 - values: 822 - "0.4505041" 823 - "0.2904757" 824 - "1.5509183" 825 - values: 826 - "0.2148952" 827 - "0.3347885" 828 - "0.6418835" 829 - values: 830 - "0.3553113" 831 - "0.4460468" 832 - "0.7965785" 833 - values: 834 - "-0.2411176" 835 - "-0.3790812" 836 - "0.6360579" 837 - values: 838 - "-0.2518421" 839 - "-0.3539177" 840 - "0.71158385" 841 - values: 842 - "0.0714281" 843 - "0.3986848" 844 - "0.17915931" 845 - values: 846 - "-0.0423414" 847 - "-0.3715421" 848 - "0.11396124" 849 - values: 850 - "0.39756609" 851 - "0.10346800" 852 - "3.842406" 853 - values: 854 - "5.6565e-19" 855 - "2751435.14" 856 - "2.0558361e-25" 857 - file-name: "type" 858 isa: 859 instructions: 860 - sig: fdiv2 v:in:f32 861 acc: inout:f32 862 format: [op_v_8] 863 verification: 864 - acc_type 865 - v1_type 866 tags: ['verifier'] 867 runner-options: ['verifier-failure', 'verifier-config'] 868 header-template: [] 869 code-template: | 870 # 871 .record A {} 872 .record B {} 873 .record panda.String <external> 874 .record panda.Object <external> 875 .function i32 main() { 876 %s 877 *s 878 fdiv2 v0 879 check-type: exit-positive 880 description: Check 'fdiv2' with incorrect register and accumulator type. 881 template-cases: 882 - values: 883 - movi v0, 0 884 - values: 885 - movi.64 v0, 0 886 - values: 887 - fmovi v0, 0 888 exclude: [val] 889 - values: 890 - fmovi.64 v0, 0 891 - values: 892 - | 893 # 894 lda.type B 895 sta.obj v0 896 - values: 897 - | 898 # 899 lda.type B[] 900 sta.obj v0 901 - values: 902 - | 903 # 904 lda.type panda.String 905 sta.obj v0 906 - values: 907 - | 908 # 909 lda.str "string" 910 sta.obj v0 911 - values: 912 - | 913 # 914 movi v0, 10 915 newarr v0, v0, i32[] 916 - values: 917 - mov.null v0 918 919 cases: 920 - values: 921 - ldai 0 922 - values: 923 - ldai.64 0 924 - values: 925 - fldai 0 926 id: val 927 - values: 928 - fldai.64 0 929 - values: 930 - | 931 # 932 lda.type A 933 - values: 934 - | 935 # 936 lda.type A[] 937 - values: 938 - | 939 # 940 lda.type panda.String 941 - values: 942 - | 943 # 944 lda.str "string" 945 - values: 946 - | 947 # 948 movi v1, 10 949 newarr v1, v1, f32[] 950 lda.obj v1 951 - values: 952 - lda.null 953 954 - file-name: uninitialized_regs 955 isa: 956 instructions: 957 - sig: fdiv2 v:in:f32 958 acc: inout:f32 959 format: [op_v_8] 960 description: Check 'fdiv2' with uninitialized register and accumulator. 961 tags: ['verifier'] 962 runner-options: ['verifier-failure', 'verifier-config'] 963 code-template: | 964 # 965 %s 966 *s 967 fdiv2 %s 968 check-type: exit-positive 969 template-cases: 970 - values: 971 - '' 972 - v0 973 - values: 974 - fmovi v0, 0 975 - v0 976 exclude: [init] 977 - values: 978 - '' 979 - v7 980 - values: 981 - '' 982 - v15 983 - values: 984 - fmovi v15, 0 985 - v15 986 exclude: [init] 987 - values: 988 - '' 989 - v128 990 - values: 991 - fmovi v128, 0 992 - v128 993 exclude: [init] 994 - values: 995 - '' 996 - v255 997 - values: 998 - fmovi v255, 0 999 - v255 1000 exclude: [init] 1001 cases: 1002 - values: 1003 - '' 1004 - values: 1005 - fldai 0 1006 id: init 1007