• 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: fcmpl
17    isa:
18      title: Floating-point comparison
19      description: Perform specified floating point comparison between register and accumulator.
20      exceptions:
21        - x_none
22    commands:
23      - file-name: zero
24        isa:
25          instructions:
26            - sig: fcmpl v:in:f32
27              acc: inout:f32->i32
28              prefix: f32
29              format: [pref_op_v_8]
30        description: Check fcmpl compares zero with other zero values.
31        tags: ['irtoc_ignore']
32        code-template: |
33          #
34              fldai %s
35              fmovi v0, %s
36              fcmpl v0
37        check-type: check-positive
38        cases:
39          - values:
40              - '0.0'
41              - '0.0'
42          - values:
43              - '-0.0'
44              - '-0.0'
45          - values:
46              - '-0.0'
47              - '0.0'
48          - values:
49              - '0.0'
50              - '-0.0'
51
52      - file-name: nan
53        isa:
54          instructions:
55            - sig: fcmpl v:in:f32
56              acc: inout:f32->i32
57              prefix: f32
58              format: [pref_op_v_8]
59        tags: ['irtoc_ignore']
60        code-template: |
61          #   test - check binary representation and comparison of FP literals - NaN
62              fldai 0x7fc00000
63              fmovi v0, %s
64              fcmpl v0
65        check-type: check-acc-minus-1
66        description: Check fcmpl compares NaN values.
67        cases:
68          - values:
69              - '0x7fc00000'
70          - values:
71              - '0x7fc00001'
72          - values:
73              - '0x7fc00010'
74          - values:
75              - '0x7fffffff'
76          - values:
77              - '0xffffffff'
78          - values:
79              - '0x7ff81234'
80          - values:
81              # +Inf
82              - '0x7f800000'
83            description: Check fcmpl compares NaN with +Inf
84          - values:
85              # -Inf
86              - '0xff800000'
87            description: Check fcmpl compares NaN with -Inf
88
89      - file-name: nan_numbers_1
90        isa:
91          instructions:
92            - sig: fcmpl v:in:f32
93              acc: inout:f32->i32
94              prefix: f32
95              format: [pref_op_v_8]
96        tags: ['irtoc_ignore']
97        description: Check fcmpl compares NaN with various values.
98        code-template: |
99          #   test - check comparison of NaN with values
100              fldai 0x7fc00000 # One of valid NaN values
101              fmovi v0, %s
102              fcmpl v0
103        check-type: check-acc-minus-1
104        cases:
105          - values:
106              - '4e30'
107          - values:
108              - '0.0'
109          - values:
110              - '-1.0e20'
111
112      - file-name: numbers_2
113        isa:
114          instructions:
115            - sig: fcmpl v:in:f32
116              acc: inout:f32->i32
117              prefix: f32
118              format: [pref_op_v_8]
119        code-template: |
120          #   test - check comparison of values
121              fldai %s
122              fmovi v0, %s
123              movi v1, %s
124              fcmpl v0
125              jne v1, set_failure
126              ldai 0
127              return
128          set_failure:
129              ldai 1
130              return
131        check-type: none
132        description: Check fcmpl compares various values.
133        tags: ['tsan', 'irtoc_ignore']
134        cases:
135          - values:
136              - '1.0'
137              - '0.0'
138              - '1'
139          - values:
140              - '12345679'
141              - '12345678'
142              - '1'
143          - values:
144              - '12345679'
145              - '-12345679'
146              - '1'
147          - values:
148              - '-1.0'
149              - '0.0'
150              - '-1'
151          - values:
152              - '-12345679'
153              - '0.0'
154              - '-1'
155          - values:
156              - '-12345679'
157              - '12345679'
158              - '-1'
159          - values:
160              - '-12345679'
161              - '12345679'
162              - '-1'
163
164      - file-name: pinf
165        isa:
166          instructions:
167            - sig: fcmpl v:in:f32
168              acc: inout:f32->i32
169              prefix: f32
170              format: [pref_op_v_8]
171        tags: ['irtoc_ignore']
172        description: Check fcmpl compares positive Inf with various values.
173        code-template: |
174          #   test - check comparison of values
175              # +Inf
176              fldai 0x7f800000
177              fmovi v0, %s
178              fcmpl v0
179        check-type: check-acc-1
180        cases:
181          - values:
182              - '1.0'
183          - values:
184              - '12345678'
185          - values:
186              - '-12345678'
187          - values:
188              - '-1.0'
189          - values:
190              - '4e30'
191          - values:
192              - '-4e30'
193
194      - file-name: ninf
195        isa:
196          instructions:
197            - sig: fcmpl v:in:f32
198              acc: inout:f32->i32
199              prefix: f32
200              format: [pref_op_v_8]
201        tags: ['irtoc_ignore']
202        description: Check fcmpl compares negative Inf with various values.
203        code-template: |
204          #   test - check comparison of values
205              # -Inf
206              fldai 0xff800000
207              fmovi v0, %s
208              fcmpl v0
209        check-type: check-acc-minus-1
210        cases:
211          - values:
212              - '1.0'
213          - values:
214              - '12345678'
215          - values:
216              - '-12345678'
217          - values:
218              - '-1.0'
219          - values:
220              - '4e30'
221          - values:
222              - '-4e30'
223
224      - file-name: inf
225        isa:
226          instructions:
227            - sig: fcmpl v:in:f32
228              acc: inout:f32->i32
229              prefix: f32
230              format: [pref_op_v_8]
231        tags: ['irtoc_ignore']
232        code-template: |
233          #   test - check comparison of values
234              fldai %s
235              # +Inf
236              fmovi v0, %s
237              movi v1, %s
238              fcmpl v0
239              jne v1, set_failure
240              ldai 0
241              return
242          set_failure:
243              ldai 1
244              return
245        check-type: none
246        cases:
247          - values:
248              # -Inf
249              - '0xff800000'
250              - '0x7f800000'
251              - '-1'
252          - values:
253              - '0x7f800000'
254              # -Inf
255              - '0xff800000'
256              - '+1'
257
258      - file-name: incorrect_register
259        isa:
260          instructions:
261            - sig: fcmpl v:in:f32
262              acc: inout:f32->i32
263              prefix: f32
264              format: [pref_op_v_8]
265        runner-options: [compile-failure]
266        description: Check fcmpl with incorrect register numbers.
267        code-template: |
268          #
269              fcmpl %s
270        check-type: exit-positive
271        cases:
272          - values: [v256]
273          - values: [a0]
274          - values: [0]
275          - values: ['1.1']
276          - values: [1.1]
277
278      - file-name: applicable_register
279        isa:
280          instructions:
281            - sig: fcmpl v:in:f32
282              acc: inout:f32->i32
283              prefix: f32
284              format: [pref_op_v_8]
285        runner-options: [compile-only]
286        description: Check fcmpl with correct register numbers.
287        code-template: |
288          #
289              fldai 0.0
290          %s
291        check-type: exit-positive
292        cases:
293          - values:
294              - '#{[*0..255].map do |i| "    fmovi v#{i}, 0\n    fcmpl v#{i}\n" end .join}'
295
296      - file-name: type
297        isa:
298          verification:
299            - v1_type
300            - acc_type
301        tags: ['verifier']
302        runner-options: ['verifier-failure', 'verifier-config']
303        header-template: []
304        code-template: |
305          #
306          .record A {}
307          .record B {}
308          .record panda.String <external>
309          .record panda.Object <external>
310          .function i32 main() {
311              %s
312              *s
313              fcmpl v0
314        check-type: exit-positive
315        description: Check 'fcmpl' with incorrect register type.
316        template-cases:
317          - values:
318              - movi v0, 0
319          - values:
320              - fmovi v0, 0
321            exclude: [val]
322          - values:
323              - movi.64 v0, 0
324          - values:
325              - fmovi.64 v0, 0
326          - values:
327              - |
328                #
329                    lda.type B
330                    sta.obj v0
331          - values:
332              - |
333                #
334                    lda.type B[]
335                    sta.obj v0
336          - values:
337              - |
338                #
339                    lda.type panda.String
340                    sta.obj v0
341          - values:
342              - |
343                #
344                    lda.str "string"
345                    sta.obj v0
346          - values:
347              - |
348                #
349                    movi v0, 10
350                    newarr v0, v0, i32[]
351          - values:
352              - mov.null v0
353        cases:
354          - values:
355              - ldai 0
356          - values:
357              - fldai 0
358            id: val
359          - values:
360              - ldai.64 0
361          - values:
362              - fldai.64 0
363          - values:
364              - |
365                #
366                    lda.type A
367          - values:
368              - |
369                #
370                    lda.type A[]
371          - values:
372              - |
373                #
374                    lda.type panda.String
375          - values:
376              - |
377                #
378                    lda.str "string"
379          - values:
380              - |
381                #
382                    movi v1, 10
383                    newarr v1, v1, f64[]
384                    lda.obj v1
385          - values:
386              - lda.null
387
388      - file-name: uninitialized_regs
389        isa:
390          instructions:
391            - sig: fcmpl v:in:f32
392              acc: inout:f32->i32
393              prefix: f32
394              format: [pref_op_v_8]
395        description: Check 'fcmpl' with uninitialized registers.
396        tags: ['verifier']
397        runner-options: ['verifier-failure', 'verifier-config']
398        header-template: []
399        code-template: |
400          #
401          .function i32 main() {
402              %s
403              *s
404              fcmpl %s
405        check-type: exit-positive
406        template-cases:
407          - values:
408              - ''
409              - v0
410          - values:
411              - fmovi v0, 0
412              - v0
413            exclude: [init]
414          - values:
415              - ''
416              - v7
417          - values:
418              - ''
419              - v15
420          - values:
421              - 'fmovi v15, 0'
422              - v15
423            exclude: [init]
424          - values:
425              - ''
426              - v128
427          - values:
428              - 'fmovi v128, 0'
429              - v128
430            exclude: [init]
431          - values:
432              - ''
433              - v255
434          - values:
435              - 'fmovi v255, 0'
436              - v255
437            exclude: [init]
438        cases:
439          - values:
440              - ''
441          - values:
442              - fldai 0
443            id: init
444