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