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