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: "f32tof64"
17    isa:
18      title: Conversions between integer and floating point types
19      description: >
20        Perform specified primitive type conversion of accumulator.
21      exceptions:
22        - x_none
23    commands:
24      - file-name: "op_none"
25        isa:
26          instructions:
27            - sig: f32tof64
28              acc: inout:f32->f64
29              prefix: f32
30              format: [pref_op_none]
31        code-template: |
32          #
33              fldai %s
34              f32tof64
35              fmovi.64 v0, %s
36              fcmpg.64 v0
37        description: Check f32tof64 with various values.
38        tags: ['tsan', 'irtoc_ignore']
39        cases:
40            - values:
41                - "0.0"
42                - "0.0"
43            - values:
44                - "-0.0"
45                - "-0.0"
46            - values:
47                - "1.0"
48                - "1.0"
49            - values:
50                - "-1.0"
51                - "-1.0"
52            - values:
53                # +inf
54                - "0x7f800000"
55                - "0x7ff0000000000000"
56            - values:
57                # -inf
58                - "0xff800000"
59                - "0xfff0000000000000"
60            - values:
61                # +max -> 3.4028234663852886e38
62                - "0x7f7fffff"
63                - "0x47efffffe0000000"
64            - values:
65                # +min -> 1.401298464324817e-45
66                - "0x00000001"
67                - "0x36a0000000000000"
68            - values:
69                # -max -> -3.4028234663852886e38
70                - "0xff7fffff"
71                - "0xc7efffffe0000000"
72            - values:
73                # -min -> -1.401298464324817e-45
74                - "0x80000001"
75                - "0xb6a0000000000000"
76            - values:
77                - "3.1415927"
78                - "3.1415927410125732"
79            - values:
80                - "-3.1415927"
81                - "-3.1415927410125732"
82
83      - file-name: "type"
84        isa:
85          instructions:
86            - sig: f32tof64
87              acc: inout:f32->f64
88              prefix: f32
89              format: [pref_op_none]
90          verification:
91              - acc_type
92        description: |
93          Check `f32tof64` with incorrect accumulator type.
94          Load different values (objects, strings, types, 64-bit floating point values, 64-bit integer values) and invokes `f32tof64`.
95          Return 0 to indicate that negative test failed, because this line is unreachable and code will not be executed after verification error.
96        bugid: ["964", "1653"]
97        tags: ["verifier"]
98        runner-options: ['verifier-failure', 'verifier-config']
99        header-template: []
100        code-template: |
101            #
102            .record B {}
103            .record panda.String <external>
104            .record panda.Object <external>
105            .function i32 main() {
106                %s
107                f32tof64
108        check-type: exit-positive
109        cases:
110            - values:
111                - ldai 0
112            - values:
113                - ldai.64 0
114            - values:
115                - fldai.64 0
116            - values:
117                - lda.type B
118            - values:
119                - lda.type B[]
120            - values:
121                - lda.type panda.String
122            - values:
123                - lda.str "string"
124            - values:
125                - lda.type panda.Object
126            - values:
127                - |
128                  #
129                      movi v0, 10
130                      newarr v0, v0, i32[]
131                      lda.obj v0
132            - values:
133                - lda.null
134
135      - file-name: uninitialized_regs
136        isa:
137          instructions:
138            - sig: f32tof64
139              acc: inout:f32->f64
140              prefix: f32
141              format: [pref_op_none]
142        description: Check 'f32tof64' with uninitialized accumulator.
143        tags: ['verifier']
144        runner-options: ['verifier-failure', 'verifier-config']
145        code-template: |
146            #
147                f32tof64
148        check-type: exit-positive
149