• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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"
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 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              fmod2 v0
39        description: >
40          Check fmod2 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            - "0"
50            exclude: [hasval]
51          - values:
52              # Negative zero
53              # -0.0d
54              - "0x80000000"
55            exclude: [hasval]
56          - values:
57            - "1"
58            exclude: [hasval]
59          - values:
60            - "-1"
61            exclude: [hasval]
62          - values:
63            # +Inf
64            - "0x7f800000"
65            exclude: [hasval]
66          - values:
67            # -Inf
68            - "0xff800000"
69            exclude: [hasval]
70          - values:
71            # +max
72            - "0x7f7ffffff"
73            exclude: [hasval]
74          - values:
75            # -max
76            - "0xff7ffffff"
77            exclude: [hasval]
78          - values:
79            # +min
80            - "0x000000001"
81            exclude: [hasval]
82          - values:
83            # -min
84            - "0x800000001"
85            exclude: [hasval]
86          - values:
87            - "3.1415927"
88            exclude: [hasval]
89          - values:
90            - "1234567890"
91            exclude: [hasval]
92        cases:
93          - values:
94              # NaN
95              - "0x7fc00000"
96          - values:
97              # NaN
98              - "0xFFFFFFFF"
99          - values:
100              - "0"
101            id: hasval
102            bugid: ['3846']
103          - values:
104              # Negative zero
105              # -0.0d
106              - "0x80000000"
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              - "0x7f800000"
118            id: hasval
119          - values:
120              # -Inf
121              - "0xff800000"
122            id: hasval
123          - values:
124              # +max
125              - "0x7f7fffff"
126            id: hasval
127          - values:
128              # -max
129              - "0xff7fffff"
130            id: hasval
131          - values:
132              # +min
133              - "0x00000001"
134            id: hasval
135          - values:
136              # -min
137              - "0x80000001"
138            id: hasval
139          - values:
140              - "3.1415927"
141            id: hasval
142          - values:
143              - "1234567890"
144            id: hasval
145
146      - file-name: "op_vs_8_pinf"
147        isa:
148          instructions:
149            - sig: fmod2 v:in:f32
150              acc: inout:f32
151              format: [op_v_8]
152        check-type: check-acc-nan-f32
153        tags: ['irtoc_ignore']
154        code-template: |
155            #
156                fldai 0x7f800000 # +Inf
157                fmovi v0, %s
158            # Mod of +Inf and value
159                fmod2 v0
160        description: Check fmod2 with positive Inf and various values (NaN, Inf, min, max, numbers).
161        cases:
162          - values:
163              # NaN
164              - "0x7fc00000"
165          - values:
166              # NaN
167              - "0xFFFFFFFF"
168          - values:
169              - "0"
170            bugid: ['3846']
171          - values:
172              # -0.0
173              - "0x80000000"
174            bugid: ['3846']
175          - values:
176              - "1"
177          - values:
178             - "-1"
179          - values:
180              # +Inf
181              - "0x7f800000"
182          - values:
183              # -Inf
184              - "0xff800000"
185          - values:
186              # +max
187              - "0x7f7fffff"
188          - values:
189              # -max
190              - "0xff7fffff"
191          - values:
192              # +min
193              - "0x00000001"
194          - values:
195              # -min
196              - "0x80000001"
197          - values:
198              - "3.1415927"
199          - values:
200              - "1234567890"
201
202      - file-name: "op_vs_8_ninf"
203        isa:
204          instructions:
205            - sig: fmod2 v:in:f32
206              acc: inout:f32
207              format: [op_v_8]
208        check-type: check-acc-nan-f32
209        tags: ['irtoc_ignore']
210
211        code-template: |
212            #
213                fldai 0xff800000 # -Inf
214                fmovi v0, %s
215            # Mod of -Inf and value
216                fmod2 v0
217        description: Check fmod2 with negative Inf and various values (NaN, Inf, min, max, numbers).
218        cases:
219          - values:
220              # NaN
221              - "0x7fc00000"
222          - values:
223              # NaN
224              - "0xFFFFFFFF"
225          - values:
226              - "0"
227            bugid: ['3846']
228          - values:
229              # -0.0d
230              - "0x80000000"
231            bugid: ['3846']
232          - values:
233              - "1"
234          - values:
235              - "-1"
236          - values:
237              # +Inf
238              - "0x7f800000"
239          - values:
240              # -Inf
241              - "0xff800000"
242          - values:
243              # +max
244              - "0x7f7fffff"
245          - values:
246              # -max
247              - "0xff7fffff"
248          - values:
249              # +min
250              - "0x00000001"
251          - values:
252              # -min
253              - "0x80000001"
254          - values:
255              - "3.1415927"
256          - values:
257              - "1234567890"
258
259      - file-name: "op_vs_8_inf_nan"
260        isa:
261          instructions:
262            - sig: fmod2 v:in:f32
263              acc: inout:f32
264              format: [op_v_8]
265          description: >
266            Division is NaN if Infinity is divided by Infinity.
267        check-type: check-acc-nan-f32
268        tags: ['irtoc_ignore']
269        code-template: |
270            #
271                fldai %s
272                fmovi v0, *s
273            # Modulo of Inf by Inf
274                fmod2 v0
275        description: >
276          Check fmod2 of Inf by Inf is NaN. (Case of Modulo)
277        template-cases:
278          - values: ["0x7f800000"]
279          - values: ["0xff800000"]
280        cases:
281          - values: ["0x7f800000"]
282          - values: ["0xff800000"]
283
284      - file-name: "op_vs_8_pzero"
285        isa:
286          instructions:
287            - sig: fmod2 v:in:f32
288              acc: inout:f32
289              format: [op_v_8]
290        check-type: check-positive
291        tags: ['irtoc_ignore']
292        code-template: |
293            #
294                fldai 0.0 #
295                fmovi v0, %s
296            # Mod of +0.0 and value
297                fmod2 v0
298                fmovi v1, %s
299                fcmpg v1
300        description: Check fmod2 with +0 and various values (NaN, Inf, min, max, numbers).
301        cases:
302            - values:
303                # +Inf
304                - "0x7f800000"
305                - "0"
306            - values:
307                # -Inf
308                - "0xff800000"
309                - "0"
310            - values:
311                # 1d
312                - "1"
313                - "0"
314            - values:
315                - "-1"
316                # -0.0
317                - "0x80000000"
318
319            - values:
320                # +max
321                - "0x7f7fffff"
322                - "0"
323            - values:
324                # -max
325                - "0xff7fffff"
326                # -0.0
327                - "0x80000000"
328            - values:
329                # +min
330                - "0x00000001"
331                - "0"
332            - values:
333                # -min
334                - "0x80000001"
335                # -0.0
336                - "0x80000000"
337            - values:
338                # Some FP value, 3.1415927
339                - "3.1415927"
340                - "0"
341
342      - file-name: "op_vs_8_nzero"
343        isa:
344          instructions:
345            - sig: fmod2 v:in:f32
346              acc: inout:f32
347              format: [op_v_8]
348        check-type: check-positive
349        tags: ['irtoc_ignore']
350        code-template: |
351            #
352                fldai -0.0 #
353                fmovi v0, %s
354            # Mod of -0.0 and value
355                fmod2 v0
356                fmovi v1, %s
357                fcmpg v1
358        description: Check fmod2 with -0 and various values (NaN, Inf, min, max, numbers).
359        cases:
360          - values:
361              # +Inf
362              - "0x7f800000"
363              - "0"
364          - values:
365              # -Inf
366              - "0xff800000"
367              - "0"
368          - values:
369              - "1"
370              # -0.0d
371              - "0x80000000"
372          - values:
373              - "-1"
374              - "0"
375          - values:
376              # +max
377              - "0x7f7fffff"
378              # -0.0d
379              - "0x80000000"
380          - values:
381              # -max
382              - "0xff7fffff"
383              - "0"
384          - values:
385              # +min
386              - "0x00000001"
387              # -0.0d
388              - "0x80000000"
389          - values:
390              # -min
391              - "0x80000001"
392              - "0"
393          - values:
394              - "3.1415927"
395              # -0.0d
396              - "0x80000000"
397          - values:
398              # Some FP value,
399              - "-3.1415927"
400              - "0"
401
402      - file-name: "op_vs_8_pone"
403        isa:
404          instructions:
405            - sig: fmod2 v:in:f32
406              acc: inout:f32
407              format: [op_v_8]
408        check-type: check-positive
409        tags: ['irtoc_ignore']
410        code-template: |
411            #
412                fldai 1.0 #
413                fmovi v0, %s
414            # Mod of 1.0 and value
415                fmod2 v0
416                fmovi v1, %s
417                fcmpg v1
418        description: Check fmod2 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              - "0x7f800000"
429              - "1"
430          - values:
431              # -Inf
432              - "0xff800000"
433              - "1"
434          - values:
435              # +max
436              - "0x7f7fffff"
437              - "1"
438          - values:
439              # -max
440              - "0xff7fffff"
441              - "1"
442          - values:
443              # +min
444              - "0x00000001"
445              - "0"
446          - values:
447              # -min
448              - "0x80000001"
449              - "0"
450          - values:
451              # Some FP value,
452              - "3.1415927"
453              - "1"
454          - values:
455              - "-3.1415927"
456              - "1"
457          - values:
458              - "1234.9876"
459              - "1"
460
461      - file-name: "op_vs_8_none"
462        isa:
463          instructions:
464            - sig: fmod2 v:in:f32
465              acc: inout:f32
466              format: [op_v_8]
467        check-type: check-positive
468        tags: ['irtoc_ignore']
469        code-template: |
470            #
471                fldai -1.0 #
472                fmovi v0, %s
473            # Mod of -1.0 and value
474                fmod2 v0
475                fmovi v1, %s
476                fcmpg v1
477        description: Check fmod2 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              - "0x7f800000"
488              - "-1"
489          - values:
490              # -Inf
491              - "0xFF800000"
492              - "-1"
493          - values:
494              # +max
495              - "0x7f7fffff"
496              - "-1"
497          - values:
498              # -max
499              - "0xff7fffff"
500              - "-1"
501          - values:
502              # +min
503              - "0x00000001"
504              - "-0.0"
505          - values:
506              # -min
507              - "0x80000001"
508              - "-0.0"
509          - values:
510              # Some FP value,
511              - "3.1415927"
512              - "-1"
513          - values:
514              - "-3.1415927"
515              - "-1"
516          - values:
517              - "1234.9876"
518              - "-1"
519
520      - file-name: "op_vs_8"
521        isa:
522          instructions:
523            - sig: fmod2 v:in:f32
524              acc: inout:f32
525              format: [op_v_8]
526        check-type: check-positive
527        tags: ['irtoc_ignore']
528        code-template: |
529            #
530                fldai %s #
531                fmovi v0, %s
532            # Mod of -1.0 and value
533                fmod2 v0
534                fmovi v1, %s
535                fcmpg v1
536        description: Check fmod2 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.0e10"
552                - "1.0e10"
553                - "0.0"
554            - values:
555                - "1.0e10"
556                - "-1.0e10"
557                - "-0.0"
558            - values:
559                - "1.0e+10"
560                - "1.0e-10"
561                - "2.6432634e-11"
562            - values:
563                - "-1.0e10"
564                - "1.0e10"
565                - "-0.0"
566            - values:
567                - "-1.0e-10"
568                - "1.0e-10"
569                - "-0.0"
570            - values:
571                - "-1.0e+10"
572                - "-1.0e-10"
573                - "-2.6432634e-11"
574            - values:
575                - "3.1415927"
576                - "-3.1415927"
577                - "0.0"
578            - values:
579                - "3.1415927e10"
580                - "-3.1415927e10"
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 v:in:f32
589              acc: inout:f32
590              format: [op_v_8]
591        check-type: check-positive
592        tags: ['irtoc_ignore']
593        code-template: |
594            #
595                fldai %s
596                fmovi v0, %s
597            # Mod of two values
598                fmod2 v0
599                fmovi v1, 0
600                fcmpg v1
601        description: Check fmod2 with various maximal values.
602        cases:
603          - values:
604              # +max
605              - "0x7f7fffff"
606              # +max
607              - "0x7f7fffff"
608          - values:
609              # -max
610              - "0xff7fffff"
611              - "0xff7fffff"
612          - values:
613              # +max
614              - "0x7f7fffff"
615              # -max
616              - "0xff7fffff"
617          - values:
618              # +max
619              - "0x7f7fffff"
620              - "1"
621          - values:
622              # +max
623              - "0x7f7fffff"
624              - "-1"
625          - values:
626              # -max
627              - "0xff7fffff"
628              - "1"
629          - values:
630              # -max
631              - "0xff7fffff"
632              - "-1"
633
634      - file-name: "op_vs_8_zeroes_nan"
635        isa:
636          instructions:
637            - sig: fmod2 v:in:f32
638              acc: inout:f32
639              format: [op_v_8]
640        check-type: check-acc-nan-f32
641        tags: ['irtoc_ignore']
642        code-template: |
643            #
644                fldai %s #
645                fmovi v0, %s
646            # Mod of -1.0 and value
647                fmod2 v0
648        description: Check fmod2 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 v:in:f32
668              acc: inout:f32
669              format: [op_v_8]
670        check-type: none
671        runner-options: [compile-failure]
672        description: Check fmod2 with incorrect register numbers.
673        code-template: |
674          #
675              fmod2 %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 v:in:f32
690              acc: inout:f32
691              format: [op_v_8]
692        check-type: none
693        runner-options: [compile-only]
694        description: Check fmod2 with correct register numbers.
695        code-template: |
696          #
697              fmod2 %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 v:in:f32
708              acc: inout:f32
709              format: [op_v_8]
710        check-type: check-positive
711        code-template: |
712            #
713                fldai %s #
714                fmovi v0, %s
715                fmod2 v0
716                fmovi v1, %s
717                fcmpg v1
718        description: Check fmod2 with various values.
719        tags: ['tsan', 'irtoc_ignore']
720        cases:
721          - values:
722              - "0.1201831"
723              - "-0.0251311"
724              - "0.0196587"
725          - values:
726              - "0.2244025"
727              - "0.2947366"
728              - "0.2244025"
729          - values:
730              - "0.3033862"
731              - "-0.375601"
732              - "0.3033862"
733          - values:
734              - "0.2936997"
735              - "-0.1764426"
736              - "0.11725712"
737          - values:
738              - "-0.0995693"
739              - "-0.3877892"
740              - "-0.0995693"
741          - values:
742              - "0.33149309"
743              - "-0.13506203"
744              - "0.06136903"
745          - values:
746              - "0.12451977"
747              - "-0.39010722"
748              - "0.12451977"
749          - values:
750              - "0.2255692"
751              - "-0.3969391"
752              - "0.2255692"
753          - values:
754              - "-0.3573151"
755              - "0.3968803"
756              - "-0.3573151"
757          - values:
758              - "0.16934379"
759              - "0.40037033"
760              - "0.16934379"
761
762      - file-name: "type"
763        isa:
764            instructions:
765              - sig: fmod2 v:in:f32
766                acc: inout:f32
767                format: [op_v_8]
768            verification:
769              - acc_type
770              - v1_type
771        tags: ['verifier']
772        runner-options: ['verifier-failure', 'verifier-config']
773        header-template: []
774        code-template: |
775          #
776          .record A {}
777          .record B {}
778          .record panda.String <external>
779          .record panda.Object <external>
780          .function i32 main() {
781              %s
782              *s
783              fmod2 v0
784        check-type: exit-positive
785        description: Check 'fmod2' with incorrect register and accumulator type.
786        template-cases:
787          - values:
788              - movi v0, 0
789          - values:
790              - movi.64 v0, 0
791          - values:
792              - fmovi v0, 0
793            exclude: [val]
794          - values:
795              - fmovi.64 v0, 0
796          - values:
797              - |
798                #
799                    lda.type B
800                    sta.obj v0
801          - values:
802              - |
803                #
804                    lda.type B[]
805                    sta.obj v0
806          - values:
807              - |
808                #
809                    lda.type panda.String
810                    sta.obj v0
811          - values:
812              - |
813                #
814                    lda.str "string"
815                    sta.obj v0
816          - values:
817              - |
818                #
819                    movi v0, 10
820                    newarr v0, v0, i32[]
821          - values:
822              - mov.null v0
823
824        cases:
825          - values:
826              - ldai 0
827          - values:
828              - ldai.64 0
829          - values:
830              - fldai 0
831            id: val
832          - values:
833              - fldai.64 0
834          - values:
835              - |
836                #
837                    lda.type A
838          - values:
839              - |
840                #
841                    lda.type A[]
842          - values:
843              - |
844                #
845                    lda.type panda.String
846          - values:
847              - |
848                #
849                    lda.str "string"
850          - values:
851              - |
852                #
853                    movi v1, 10
854                    newarr v1, v1, f32[]
855                    lda.obj v1
856          - values:
857              - lda.null
858
859      - file-name: uninitialized_regs
860        isa:
861          instructions:
862            - sig: fmod2 v:in:f32
863              acc: inout:f32
864              format: [op_v_8]
865        description: Check 'fmod2' with uninitialized register and accumulator.
866        tags: ['verifier']
867        runner-options: ['verifier-failure', 'verifier-config']
868        code-template: |
869            #
870                %s
871                *s
872                fmod2 %s
873        check-type: exit-positive
874        template-cases:
875          - values:
876              - ''
877              - v0
878          - values:
879              - fmovi v0, 0
880              - v0
881            exclude: [init]
882          - values:
883              - ''
884              - v7
885          - values:
886              - ''
887              - v15
888          - values:
889              - fmovi v15, 0
890              - v15
891            exclude: [init]
892          - values:
893              - ''
894              - v128
895          - values:
896              - fmovi v128, 0
897              - v128
898            exclude: [init]
899          - values:
900              - ''
901              - v255
902          - values:
903              - fmovi v255, 0
904              - v255
905            exclude: [init]
906        cases:
907          - values:
908              - ''
909          - values:
910              - fldai 0
911            id: init
912