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