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: 'cmp.64'
17    isa:
18      title: Integer comparison
19      description: Perform specified signed or unsigned integer comparison between register and accumulator.
20      exceptions:
21        - x_none
22    commands:
23      - file-name: 'op_vs_8_eq'
24        isa:
25          instructions:
26            - sig: cmp.64 v:in:i64
27              acc: inout:i64->i32
28              format: [op_v_8]
29        check-type: check-positive
30        description: Check cmp.64 with equal values.
31        tags: ['tsan']
32        code-template: |
33          # test - compare equal values
34              ldai.64 %s
35              movi.64 v0, %s
36              cmp.64 v0
37        cases:
38          - values:
39              - '0'
40              - '0'
41          - values:
42              - '1'
43              - '1'
44          - values:
45              - '-1'
46              - '-1'
47          - values:
48              - '0x7fffffff'
49              - '0x7fffffff'
50          - values:
51              - '-0x7fffffff'
52              - '-0x7fffffff'
53          - values:
54              - '0x80000000'
55              - '0x80000000'
56          - values:
57              - '-0x80000000'
58              - '-0x80000000'
59          - values:
60              - '0xffffffff'
61              - '0xffffffff'
62          - values:
63              - '-0xffffffff'
64              - '-0xffffffff'
65          - values:
66              - '0x7fffffffffffffff'
67              - '0x7fffffffffffffff'
68          - values:
69              - '-9223372036854775808'
70              - '0x8000000000000000'
71
72      - file-name: 'op_vs_8_lt'
73        isa:
74          instructions:
75            - sig: cmp.64 v:in:i64
76              acc: inout:i64->i32
77              format: [op_v_8]
78        check-type: check-positive
79        description: Check cmp.64 with different values.
80        tags: ['tsan']
81        code-template: |
82          # test - check less than
83              ldai.64 %s
84              movi.64 v0, %s
85              cmp.64 v0
86              addi 1
87        cases:
88          - values:
89              - '0'
90              - '0x0000000000000001'
91          - values:
92              - '-1'
93              - '0'
94          - values:
95              - '9223372036854775707'
96              - '9223372036854775807'
97          - values:
98              - '0x8000000000000000'
99              - '0x7fffffffffffffff'
100          - values:
101              - '0x8000000000000000'
102              - '0x8000000000000001'
103          - values:
104              - '-2'
105              - '0xffffffffffffffff'
106          - values:
107              - '0x7ffffffffffffffe'
108              - '9223372036854775807'
109          - values:
110              - '65535'
111              - '0x00010000'
112
113      - file-name: 'op_vs_8_gt'
114        isa:
115          instructions:
116            - sig: cmp.64 v:in:i64
117              acc: inout:i64->i32
118              format: [op_v_8]
119        check-type: check-positive
120        description: Check cmp.64 with different values.
121        tags: ['tsan']
122        code-template: |
123          #   test - check greater than
124              ldai.64 %s
125              movi.64 v0, %s
126              cmp.64 v0
127              subi 1
128        cases:
129          - values:
130              - '0x0000000000000001'
131              - '0'
132          - values:
133              - '0'
134              - '-1'
135          - values:
136              - '9223372036854775807'
137              - '9223372036854775707'
138          - values:
139              - '0x7fffffffffffffff'
140              - '0x8000000000000000'
141          - values:
142              - '0x8000000000000001'
143              - '0x8000000000000000'
144          - values:
145              - '0xffffffffffffffff'
146              - '-2'
147          - values:
148              - '9223372036854775807'
149              - '0x7ffffffffffffffe'
150          - values:
151              - '0x00010000'
152              - '65535'
153
154      - file-name: 'op_vs_8_reg256'
155        isa:
156          instructions:
157            - sig: cmp.64 v:in:i64
158              acc: inout:i64->i32
159              format: [op_v_8]
160        check-type: exit-positive
161        runner-options: [compile-failure]
162        description: Check cmp.64 with incorrect register numbers.
163        code-template: |
164          #
165              cmp.64 v256
166
167      - file-name: 'op_vs_8_reg255'
168        isa:
169          instructions:
170            - sig: cmp.64 v:in:i64
171              acc: inout:i64->i32
172              format: [op_v_8]
173        check-type: exit-positive
174        runner-options: [compile-only]
175        description: Check cmp.64 with correct register numbers.
176        code-template: |
177          #
178              cmp.64 v255
179
180      - file-name: type
181        isa:
182          verification:
183            - v1_type
184            - acc_type
185        tags: ['verifier']
186        runner-options: ['verifier-failure', 'verifier-config']
187        header-template: []
188        code-template: |
189          #
190          .record A {}
191          .record B {}
192          .record panda.String <external>
193          .record panda.Object <external>
194          .function i32 main() {
195              %s
196              *s
197              cmp.64 v0
198        check-type: exit-positive
199        description: Check 'cmp.64' with incorrect register type.
200        template-cases:
201          - values:
202              - movi v0, 0
203          - values:
204              - fmovi v0, 0
205          - values:
206              - movi.64 v0, 0
207            exclude: [val]
208          - values:
209              - fmovi.64 v0, 0
210          - values:
211              - |
212                #
213                    lda.type B
214                    sta.obj v0
215          - values:
216              - |
217                #
218                    lda.type B[]
219                    sta.obj v0
220          - values:
221              - |
222                #
223                    lda.type panda.String
224                    sta.obj v0
225          - values:
226              - |
227                #
228                    lda.str "string"
229                    sta.obj v0
230          - values:
231              - |
232                #
233                    movi v0, 10
234                    newarr v0, v0, i32[]
235          - values:
236              - mov.null v0
237
238        cases:
239          - values:
240              - ldai 0
241          - values:
242              - fldai 0
243          - values:
244              - ldai.64 0
245            id: val
246          - values:
247              - fldai.64 0
248          - values:
249              - |
250                #
251                    lda.type A
252          - values:
253              - |
254                #
255                    lda.type A[]
256          - values:
257              - |
258                #
259                    lda.type panda.String
260          - values:
261              - |
262                #
263                    lda.str "string"
264          - values:
265              - |
266                #
267                    movi v1, 10
268                    newarr v1, v1, f64[]
269                    lda.obj v1
270
271          - values:
272              - lda.null
273
274      - file-name: uninitialized_regs
275        isa:
276          instructions:
277            - sig: cmp.64 v:in:i64
278              acc: inout:i64->i32
279              format: [op_v_8]
280        description: Check 'cmp.64' with uninitialized registers.
281        tags: ['verifier']
282        runner-options: ['verifier-failure', 'verifier-config']
283        header-template: []
284        code-template: |
285          #
286          .function i32 main() {
287              %s
288              *s
289              cmp.64 %s
290        check-type: exit-positive
291        template-cases:
292          - values:
293              - ''
294              - v0
295          - values:
296              - movi.64 v0, 0
297              - v0
298            exclude: [init]
299          - values:
300              - ''
301              - v7
302          - values:
303              - ''
304              - v15
305          - values:
306              - 'movi.64 v15, 0'
307              - v15
308            exclude: [init]
309          - values:
310              - ''
311              - v128
312          - values:
313              - 'movi.64 v128, 0'
314              - v128
315            exclude: [init]
316          - values:
317              - ''
318              - v255
319          - values:
320              - 'movi.64 v255, 0'
321              - v255
322            exclude: [init]
323        cases:
324          - values:
325              - ''
326          - values:
327              - ldai.64 0
328            id: init
329