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