• 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: "cmp"
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 v:in:i32
27              acc: inout:i32
28              format: [op_v_8]
29        check-type: check-positive
30        code-template: |
31            # test - compare equal values
32                ldai %s
33                movi v0, %s
34                cmp v0
35        description: Check cmp with equal values.
36        tags: ['tsan']
37        cases:
38          - values:
39            - "0"
40            - "0x00000000"
41          - values:
42            - "-0"
43            - "-0"
44          - values:
45            - "-0"
46            - "0"
47          - values:
48            - "0x00000000"
49            - "-0"
50          - values:
51            - "1"
52            - "0x00000001"
53          - values:
54            - "-1"
55            - "0xffffffff"
56          - values:
57            - "0x7fffffff"
58            - "2147483647"
59          - values:
60            - "-2147483648"
61            - "0x80000000"
62
63      - file-name: "op_vs_8_lt"
64        isa:
65          instructions:
66            - sig: cmp v:in:i32
67              acc: inout:i32
68              format: [op_v_8]
69        check-type: check-positive
70        code-template: |
71          # test - check less than
72                ldai %s
73                movi v0, %s
74                cmp v0
75                addi 1
76        description: Check cmp with different values.
77        tags: ['tsan']
78        cases:
79          - values:
80            - "0"
81            - "0x00000001"
82          - values:
83            - "-1"
84            - "0"
85          - values:
86            - "2147483646"
87            - "2147483647"
88          - values:
89            - "0x80000000"
90            - "0x7fffffff"
91          - values:
92            - "0x80000000"
93            - "0x80000001"
94          - values:
95            - "-2"
96            - "0xffffffff"
97          - values:
98            - "0x7ffffffe"
99            - "2147483647"
100          - values:
101            - "65535"
102            - "0x00010000"
103
104      - file-name: "op_vs_8_gt"
105        isa:
106          instructions:
107            - sig: cmp v:in:i32
108              acc: inout:i32
109              format: [op_v_8]
110        check-type: check-positive
111        description: Check cmp with different values.
112        tags: ['tsan']
113        code-template: |
114          #   test - check greater than
115                ldai %s
116                movi v0, %s
117                cmp v0
118                subi 1
119        cases:
120          - values:
121            - "0x00000001"
122            - "0"
123          - values:
124            - "0"
125            - "-1"
126          - values:
127            - "2147483647"
128            - "2147483646"
129          - values:
130            - "0x7fffffff"
131            - "0x80000000"
132          - values:
133            - "0x80000001"
134            - "0x80000000"
135          - values:
136            - "0xffffffff"
137            - "-2"
138          - values:
139            - "2147483647"
140            - "0x7ffffffe"
141          - values:
142            - "0x00010000"
143            - "65535"
144
145      - file-name: "op_vs_8_reg256"
146        isa:
147          instructions:
148            - sig: cmp v:in:i32
149              acc: inout:i32
150              format: [op_v_8]
151        check-type: none
152        runner-options: [compile-failure]
153        description: Check cmp with incorrect register numbers.
154        code-template: |
155          #
156              cmp v256
157
158      - file-name: "op_vs_8_reg255"
159        isa:
160          instructions:
161            - sig: cmp v:in:i32
162              acc: inout:i32
163              format: [op_v_8]
164        check-type: none
165        runner-options: [compile-only]
166        description: Check cmp with correct register numbers.
167        code-template: |
168          #
169              cmp v255
170
171      - file-name: type
172        isa:
173          instructions:
174            - sig: cmp v:in:i32
175              acc: inout:i32
176              format: [op_v_8]
177          verification:
178            - v1_type
179            - acc_type
180        tags: ['verifier']
181        runner-options: ['verifier-failure', 'verifier-debug-config']
182        header-template: []
183        code-template: |
184          #
185          .record A {}
186          .record B {}
187          .record panda.String <external>
188          .record panda.Object <external>
189          .function i32 main() {
190              %s
191              *s
192              cmp v0
193        check-type: exit-positive
194        description: Check 'cmp' with incorrect register type.
195        template-cases:
196          - values:
197              - movi v0, 0
198            exclude: [val]
199          - values:
200              - movi.64 v0, 0
201          - values:
202              - fmovi.64 v0, 0
203          - values:
204              - |
205                #
206                    lda.type B
207                    sta.obj v0
208          - values:
209              - |
210                #
211                    lda.type B[]
212                    sta.obj v0
213          - values:
214              - |
215                #
216                    lda.type panda.String
217                    sta.obj v0
218          - values:
219              - |
220                #
221                    lda.str "string"
222                    sta.obj v0
223          - values:
224              - |
225                #
226                    movi v0, 10
227                    newarr v0, v0, i32[]
228                    lda.obj v0
229          - values:
230              - mov.null v0
231
232        cases:
233          - values:
234              - ldai 0
235            id: val
236          - values:
237              - ldai.64 0
238          - values:
239              - fldai.64 0
240          - values:
241              - |
242                #
243                    lda.type A
244          - values:
245              - |
246                #
247                    lda.type A[]
248          - values:
249              - |
250                #
251                    lda.type panda.String
252          - values:
253              - |
254                #
255                    lda.str "string"
256          - values:
257              - |
258                #
259                    movi v1, 10
260                    newarr v1, v1, f64[]
261                    lda.obj v1
262
263          - values:
264              - lda.null
265
266      - file-name: uninitialized_regs
267        isa:
268          instructions:
269            - sig: cmp v:in:i32
270              acc: inout:i32
271              format: [op_v_8]
272        description: Check 'cmp' with uninitialized registers.
273        tags: ['verifier']
274        runner-options: ['verifier-failure', 'verifier-debug-config']
275        header-template: []
276        code-template: |
277            #
278            .function i32 main() {
279                %s
280                *s
281                cmp %s
282        check-type: exit-positive
283        template-cases:
284          - values:
285              - ''
286              - v0
287          - values:
288              - movi v0, 0
289              - v0
290            exclude: [init]
291          - values:
292              - ''
293              - v7
294          - values:
295              - ''
296              - v15
297          - values:
298              - 'movi v15, 0'
299              - v15
300            exclude: [init]
301          - values:
302              - ''
303              - v128
304          - values:
305              - 'movi v128, 0'
306              - v128
307            exclude: [init]
308          - values:
309              - ''
310              - v255
311          - values:
312              - 'movi v255, 0'
313              - v255
314            exclude: [init]
315        cases:
316          - values:
317              - ''
318          - values:
319              - ldai 0
320            id: init
321
322      - file-name: "diff_length_values"
323        isa:
324          instructions:
325            - sig: cmp v:in:i32
326              acc: inout:i32
327              format: [op_v_8]
328        check-type: no-check
329        code-template: |
330            # test - compare equal values
331                movi v0, 1
332                newarr v0, v0, %s      # array ref -> v0
333
334                movi v1, 0      # index
335                ldai %s         # content
336                %s v0, v1       # starr  v0[v1] = acc with truncation
337
338                ldai 0          # index
339                %s v0           # ldarr  acc = v0[acc]
340
341                movi v10, %s
342                cmp v10
343        description: Check cmp with different length values.
344        cases:
345          - values: ["u1[]", "1", "starr.8", "ldarru.8", "1"]
346          - values: ["u1[]", "2", "starr.8", "ldarru.8", "0"]
347            bugid: ['4019']
348            ignore: true
349          - values: ["u1[]", "-1", "starr.8", "ldarru.8", "1"]
350            bugid: ['4019']
351            ignore: true
352          - values: ["u1[]", "1", "starr.8", "ldarr.8", "1"]
353          - values: ["u1[]", "2", "starr.8", "ldarr.8", "0"]
354            bugid: ['4019']
355            ignore: true
356          - values: ["u1[]", "-1", "starr.8", "ldarr.8", "1"]
357            bugid: ['4019']
358            ignore: true
359          - values: ["u8[]", "1", "starr.8", "ldarru.8", "1"]
360          - values: ["u8[]", "255", "starr.8", "ldarru.8", "255"]
361          - values: ["u8[]", "-1", "starr.8", "ldarru.8", "255"]
362          - values: ["i8[]", "1", "starr.8", "ldarr.8", "1"]
363          - values: ["i8[]", "255", "starr.8", "ldarr.8", "-1"]
364          - values: ["i8[]", "-1", "starr.8", "ldarr.8", "-1"]
365          - values: ["u16[]", "1", "starr.16", "ldarru.16", "1"]
366          - values: ["u16[]", "0x0000ffff", "starr.16", "ldarru.16", "0x0000ffff"]
367          - values: ["u16[]", "-1", "starr.16", "ldarru.16", "0x0000ffff"]
368          - values: ["i16[]", "1", "starr.16", "ldarr.16", "1"]
369          - values: ["i16[]", "0x0000ffff", "starr.16", "ldarr.16", "-1"]
370          - values: ["i16[]", "-1", "starr.16", "ldarr.16", "-1"]
371