• 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: "f64tou64"
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_vals"
25        isa:
26          instructions:
27            - sig: f64tou64
28              acc: inout:f64->u64
29              prefix: cast
30              format: [pref_op_none]
31        code-template: |
32          #
33              fldai.64 %s
34              f64tou64
35              movi.64 v0, %s
36              ucmp.64 v0
37        description: Check f64tou64 with various values.
38        tags: ['tsan']
39        cases:
40          - values:
41              - "0.0"
42              - "0"
43          - values:
44              - "1.0"
45              - "1"
46          - values:
47              - "2.147483647e9"
48              - "0x7fffffff"
49          - values:
50              - "9.223372036854776e18"
51              - "-9223372036854775808"
52          - values:
53            - "18446744073709551615.0"
54            - "-1"
55          - values:
56              - "-0.0"
57              - "0"
58          - values:
59              - "-1.0"
60              - "0"
61          - values:
62              - "-2.147483647e9"
63              - "0"
64          - values:
65              - "-9.223372036854776e18"
66              - "0"
67      - file-name: "op_none_round"
68        isa:
69          instructions:
70            - sig: f64tou64
71              acc: inout:f64->u64
72              prefix: cast
73              format: [pref_op_none]
74          description: It is rounding toward zero.
75        description: Check f64tou64 rounding with various values.
76        code-template: |
77          #
78              fldai.64 %s
79              f64tou64
80              movi.64 v0, %s
81              ucmp.64 v0
82        cases:
83          - values:
84              - "0.1"
85              - "0"
86          - values:
87              - "0.9"
88              - "0"
89          - values:
90              - "0.9999999999"
91              - "0"
92          - values:
93              - "1.1"
94              - "1"
95          - values:
96              - "2.14748364699999e9"
97              - "0x7ffffffe"
98          - values:
99              - "2.14748364799999e9"
100              - "0x7fffffff"
101          - values:
102              - "-0.1"
103              - "0"
104          - values:
105              - "-0.9"
106              - "0"
107
108      - file-name: "op_none_min"
109        isa:
110          instructions:
111            - sig: f64tou64
112              acc: inout:f64->u64
113              prefix: cast
114              format: [pref_op_none]
115          description: If converted integer is less than minimal value for destination type, the result is minimal value for that type.
116        code-template: |
117          #
118              fldai.64 %s
119              f64tou64
120              movi.64 v0, %s
121              ucmp.64 v0
122        description: Check f64tou64 conversion to 0.
123        cases:
124          - values:
125              - "-9.2233720368554776e18"
126              - "0"
127          - values:
128              - "-18446744073709551615.0"
129              - "0"
130          - values:
131              - "-6e100"
132              - "0"
133
134      - file-name: "op_none_max"
135        isa:
136          instructions:
137            - sig: f64tou64
138              acc: inout:f64->u64
139              prefix: cast
140              format: [pref_op_none]
141          description: If converted integer is greater than maximum value for destination type, the result is maximum value for that type.
142        description: Check f64tou64 conversion to 0xFFFFFFFFFFFFFFFF.
143        code-template: |
144          #
145              fldai.64 %s
146              f64tou64
147              movi.64 v0, %s
148              ucmp.64 v0
149        cases:
150          - values:
151              - "18446744073709551615.0"
152              - "-1"
153          - values:
154              - "18446744073709551616.0"
155              - "-1"
156          - values:
157              - "6e100"
158              - "-1"
159
160      - file-name: "op_none_pinf"
161        isa:
162          instructions:
163            - sig: f64tou64
164              acc: inout:f64->u64
165              prefix: cast
166              format: [pref_op_none]
167          description: If source is positive infinity, the result is maximum value for destination type.
168        description: Check f64tou64 conversion +inf to 0xFFFFFFFFFFFFFFFF.
169        code-template: |
170          #
171              fldai.64 0x7ff0000000000000 # +Inf
172              f64tou64
173              movi.64 v0, 0xffffffffffffffff
174              ucmp.64 v0
175
176      - file-name: "op_none_ninf"
177        isa:
178          instructions:
179            - sig: f64tou64
180              acc: inout:f64->u64
181              prefix: cast
182              format: [pref_op_none]
183          description: If source is negative infinity, the result is minimal value for destination type.
184        description: Check f64tou64 conversion -inf to 0.
185        code-template: |
186          #
187              fldai.64 0xfff0000000000000 # -Inf
188              f64tou64
189              movi.64 v0, 0
190              ucmp.64 v0
191
192      - file-name: "op_none_nan"
193        isa:
194          instructions:
195            - sig: f64tou64
196              acc: inout:f64->u64
197              prefix: cast
198              format: [pref_op_none]
199          description: If source is NaN, the result is equal to 0.
200        code-template: |
201          #
202              fldai.64 %s
203              f64tou64
204              movi.64 v0, 0
205              ucmp.64 v0
206        description: Check f64tou64 conversion of NaN to 0.
207        cases:
208          - values:
209              # NaN
210              - "0x7ff8000000000000"
211          - values:
212              # Other NaN representation
213              - "0xFFFFFFFFFFFFFFFF"
214
215      - file-name: "type"
216        isa:
217          instructions:
218            - sig: f64tou64
219              acc: inout:f64->u64
220              prefix: cast
221              format: [pref_op_none]
222          verification:
223              - acc_type
224        description: |
225          Check `f64tou64` with incorrect accumulator type.
226          Load different values (objects, strings, types, 32-bit values, 64-bit integer values) and invokes `f64tou64`.
227          Return 0 to indicate that negative test failed, because this line is unreachable and code will not be executed after verification error.
228        runner-options: ['verifier-failure', 'verifier-config']
229        bugid: ["964", "1653"]
230        tags: ["verifier"]
231        header-template: []
232        code-template: |
233            #
234            .record B {}
235            .record panda.String <external>
236            .record panda.Object <external>
237            .function i32 main() {
238                %s
239                f64tou64
240        check-type: exit-positive
241        cases:
242            - values:
243                - ldai 0
244            - values:
245                - ldai.64 0
246            - values:
247                - fldai 0
248              bugid: ['6094']
249            - values:
250                - lda.type B
251            - values:
252                - lda.type B[]
253            - values:
254                - lda.type panda.String
255            - values:
256                - lda.str "string"
257            - values:
258                - lda.type panda.Object
259            - values:
260                - |
261                  #
262                      movi v0, 10
263                      newarr v0, v0, i32[]
264                      lda.obj v0
265            - values:
266                - lda.null
267
268      - file-name: uninitialized_regs
269        isa:
270          instructions:
271            - sig: f64tou64
272              acc: inout:f64->u64
273              prefix: cast
274              format: [pref_op_none]
275        description: Check 'f64tou64' with uninitialized accumulator.
276        tags: ['verifier']
277        runner-options: ['verifier-failure', 'verifier-config']
278        code-template: |
279            #
280                f64tou64
281        check-type: exit-positive
282