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