• 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
14---
15definitions: []
16tests:
17  - file-name: add
18    isa:
19      title: Three address binary operation
20      description: Perform specified binary operation on two registers and store result
21        into accumulator
22      exceptions:
23        - x_none
24    commands:
25      - file-name: op_vs1_4_vs2_4_zero
26        isa:
27          instructions:
28            - sig: add v1:in:i32, v2:in:i32
29              acc: out:i32
30              format: [op_v1_4_v2_4]
31        code-template: |
32          #
33              movi v0, 0
34              movi v1, %s
35              add v0, v1
36              movi v0, %s
37              jne v0, set_failure
38              ldai 0
39              jmp fall_through
40          set_failure:
41              ldai 1
42          fall_through:
43        description: Check add with zero and various values.
44        cases:
45          - values:
46              - '0'
47              - '0'
48          - values:
49              - '1'
50              - '1'
51          - values:
52              - "-1"
53              - "-1"
54          - values:
55              - '0x7FFFFFFF'
56              - '0x7FFFFFFF'
57          - values:
58              - '0x80000000'
59              - '0x80000000'
60          - values:
61              - "-0x7FFFFFFF"
62              - "-0x7FFFFFFF"
63          - values:
64              - "-0x80000000"
65              - "-0x80000000"
66          - values:
67              - '0xFFFFFFFF'
68              - '0xFFFFFFFF'
69          - values:
70              - "-0xFFFFFFFF"
71              - "-0xFFFFFFFF"
72      - file-name: op_vs1_4_vs2_4_pone
73        isa:
74          instructions:
75            - sig: add v1:in:i32, v2:in:i32
76              acc: out:i32
77              format: [op_v1_4_v2_4]
78        code-template: |
79          #
80              movi v0, 1
81              movi v1, %s
82              add v0, v1
83              movi v0, %s
84              jne v0, set_failure
85              ldai 0
86              jmp fall_through
87          set_failure:
88              ldai 1
89          fall_through:
90        description: Check add with +1 and various values.
91        cases:
92          - values:
93              - '0'
94              - '1'
95          - values:
96              - '1'
97              - '2'
98          - values:
99              - "-1"
100              - '0'
101          - values:
102              - '0x7FFFFFFF'
103              - '0x80000000'
104            bugid: ["966"]
105          - values:
106              - '0x80000000'
107              - '0x80000001'
108          - values:
109              - "-0x7FFFFFFF"
110              - "-0x7FFFFFFE"
111          - values:
112              - "-0x80000000"
113              - "-0x7FFFFFFF"
114          - values:
115              - '0xFFFFFFFF'
116              - '0'
117          - values:
118              - "-0xFFFFFFFF"
119              - "-0xFFFFFFFE"
120      - file-name: op_vs1_4_vs2_4_none
121        isa:
122          instructions:
123            - sig: add v1:in:i32, v2:in:i32
124              acc: out:i32
125              format: [op_v1_4_v2_4]
126        code-template: |
127          #
128              movi v0, -1
129              movi v1, %s
130              add v0, v1
131              movi v0, %s
132              jne v0, set_failure
133              ldai 0
134              jmp fall_through
135          set_failure:
136              ldai 1
137          fall_through:
138        description: Check add with -1 and various values.
139        cases:
140          - values:
141              - '0'
142              - "-1"
143          - values:
144              - '1'
145              - '0'
146          - values:
147              - "-1"
148              - "-2"
149          - values:
150              - '0x7FFFFFFF'
151              - '0x7FFFFFFE'
152          - values:
153              - '0x80000000'
154              - '0x7FFFFFFF'
155            bugid: ["966"]
156          - values:
157              - "-0x7FFFFFFF"
158              - "-0x80000000"
159          - values:
160              - "-0x80000000"
161              - "-0x80000001"
162            bugid: ["966"]
163          - values:
164              - '0xFFFFFFFF'
165              - "-2"
166          - values:
167              - "-0xFFFFFFFF"
168              - '0'
169      - file-name: op_vs1_4_vs2_4_pmax
170        isa:
171          instructions:
172            - sig: add v1:in:i32, v2:in:i32
173              acc: out:i32
174              format: [op_v1_4_v2_4]
175        code-template: |
176          #
177              movi v0, 0x7FFFFFFF
178              movi v1, %s
179              add v0, v1
180              movi v0, %s
181              jne v0, set_failure
182              ldai 0
183              jmp fall_through
184          set_failure:
185              ldai 1
186          fall_through:
187        description: Check add with +max and various values.
188        cases:
189          - values:
190              - '0'
191              - '0x7fffffff'
192          - values:
193              - '1'
194              - '0x80000000'
195            bugid: ["966"]
196          - values:
197              - "-1"
198              - '0x7FFFFFFE'
199          - values:
200              - '0x7FFFFFFF'
201              - '0xFFFFFFFE'
202            bugid: ["966"]
203          - values:
204              - '0x80000000'
205              - '0xFFFFFFFF'
206          - values:
207              - "-0x7FFFFFFF"
208              - '0'
209          - values:
210              - "-0x80000000"
211              - '0xFFFFFFFF'
212          - values:
213              - '0xFFFFFFFF'
214              - '0x7FFFFFFE'
215          - values:
216              - "-0xFFFFFFFF"
217              - '0x80000000'
218            bugid: ["966"]
219      - file-name: op_vs1_4_vs2_4_nmax
220        isa:
221          instructions:
222            - sig: add v1:in:i32, v2:in:i32
223              acc: out:i32
224              format: [op_v1_4_v2_4]
225        code-template: |
226          #
227              movi v0, -0x80000000
228              movi v1, %s
229              add v0, v1
230              movi v0, %s
231              jne v0, set_failure
232              ldai 0
233              jmp fall_through
234          set_failure:
235              ldai 1
236          fall_through:
237        description: Check add with -max and various values.
238        cases:
239          - values:
240              - '0'
241              - '0x80000000'
242          - values:
243              - '1'
244              - '0x80000001'
245          - values:
246              - "-1"
247              - '0x7FFFFFFF'
248            bugid: ["966"]
249          - values:
250              - '0x7FFFFFFF'
251              - "-1"
252          - values:
253              - '0x80000000'
254              - '0'
255            bugid: ["966"]
256          - values:
257              - "-0x7FFFFFFF"
258              - '1'
259            bugid: ["966"]
260          - values:
261              - "-0x80000000"
262              - '0'
263            bugid: ["966"]
264          - values:
265              - '0xFFFFFFFF'
266              - '0x7FFFFFFF'
267            bugid: ["966"]
268          - values:
269              - "-0xFFFFFFFF"
270              - "-0x7FFFFFFF"
271      - file-name: vals
272        isa:
273          instructions:
274            - sig: add v1:in:i32, v2:in:i32
275              acc: out:i32
276              format: [op_v1_4_v2_4]
277        code-template: |
278          #
279              movi v0, %s
280              movi v1, %s
281              add v0, v1
282              movi v0, %s
283              jne v0, set_failure
284              ldai 0
285              jmp fall_through
286          set_failure:
287              ldai 1
288          fall_through:
289        description: Check add with various values.
290        tags: ['tsan']
291        cases:
292          - values:
293              - '0x455ed8f5'
294              - '0xfe61fbdd'
295              - '0x43c0d4d2'
296          - values:
297              - '0xc3e6a70'
298              - '0xae9b1e98'
299              - '0xbad98908'
300          - values:
301              - '0xd2670242'
302              - '0xef691c0f'
303              - '0xc1d01e51'
304          - values:
305              - '0xf6d0f4f8'
306              - '0x4ee5e5df'
307              - '0x45b6dad7'
308          - values:
309              - '0xded7f996'
310              - '0xd94428a1'
311              - '0xb81c2237'
312          - values:
313              - '0x262d5e15'
314              - '0x1a85200d'
315              - '0x40b27e22'
316          - values:
317              - '0x4bb930e4'
318              - '0x416b3a07'
319              - '0x8d246aeb'
320            bugid: ["966"]
321          - values:
322              - '0x61a80560'
323              - '0xb076ee9'
324              - '0x6caf7449'
325          - values:
326              - '0x42bd8cd3'
327              - '0x9e28b8b6'
328              - '0xe0e64589'
329          - values:
330              - '0x3c0a62e1'
331              - '0xb18cfa'
332              - '0x3cbbefdb'
333      - file-name: vals_mod32_1
334        bugid: ['1324', '2072']
335        tags: ['verifier']
336        runner-options: ['verifier-failure', 'verifier-config']
337        isa:
338          instructions:
339            - sig: add v1:in:i32, v2:in:i32
340              acc: out:i32
341              format: [op_v1_4_v2_4]
342        code-template: |
343          #
344              movi v0, %s
345              movi v1, %s
346              add v0, v1
347              movi.64 v0, %s
348              cmp.64 v0
349        description: Check add with incorrect register type.
350        cases:
351          - values:
352              - '0x7FFFFFFF'
353              - '0x7FFFFFFF'
354              - '0xFFFFFFFFFFFFFFFE'
355            bugid: ["966"]
356          - values:
357              - '0x7FFFFFFF'
358              - '0x80000000'
359              - '0xFFFFFFFFFFFFFFFF'
360          - values:
361              - '0x80000000'
362              - '0x80000000'
363              - '0'
364            bugid: ["966"]
365      - file-name: vals_mod32_2
366        bugid: ['1324']
367        tags: ['verifier']
368        runner-options: ['verifier-failure', 'verifier-config']
369        isa:
370          instructions:
371            - sig: add v1:in:i32, v2:in:i32
372              acc: out:i32
373              format: [op_v1_4_v2_4]
374        code-template: |
375          #
376              movi.64 v0, %s
377              movi.64 v1, %s
378              add v0, v1
379              movi.64 v0, %s
380              cmp.64 v0
381        description: Check add with incorrect register type.
382        cases:
383          - values:
384              - '0x17FFFFFFF'
385              - '0x17FFFFFFF'
386              - '0xFFFFFFFFFFFFFFFE'
387            bugid: ["966"]
388          - values:
389              - '0x777777777FFFFFFF'
390              - '0x1111111180000000'
391              - '0xFFFFFFFFFFFFFFFF'
392          - values:
393              - '0x180000000'
394              - '0x180000000'
395              - '0'
396            bugid: ["966"]
397      - file-name: regs
398        isa:
399          instructions:
400            - sig: add v1:in:i32, v2:in:i32
401              acc: out:i32
402              format: [op_v1_4_v2_4]
403        runner-options:
404          - compile-only
405        code-template: |
406          #
407              add %s, %s
408        check-type: none
409        description: Check add with various register numbers.
410        cases:
411          - values:
412              - v0
413              - v15
414          - values:
415              - v0
416              - v16
417            runner-options:
418              - compile-failure
419          - values:
420              - v15
421              - v0
422          - values:
423              - v16
424              - v0
425            runner-options:
426              - compile-failure
427
428      - file-name: type
429        isa:
430          verification:
431            - v1_type
432            - v2_type
433        tags: ['verifier']
434        runner-options: ['verifier-failure', 'verifier-config']
435        header-template: []
436        code-template: |
437          #
438          .record A {}
439          .record B {}
440          .record panda.String <external>
441          .record panda.Object <external>
442          .function i32 main() {
443              %s
444              *s
445              add v0, v1
446        check-type: exit-positive
447        description: Check 'add' with incorrect register types.
448        template-cases:
449          - values:
450              - movi v0, 0
451            exclude: [val]
452          - values:
453              - movi.64 v0, 0
454          - values:
455              - fmovi v0, 0
456          - values:
457              - fmovi.64 v0, 0
458          - values:
459              - |
460                #
461                    lda.type B
462                    sta.obj v0
463          - values:
464              - |
465                #
466                    lda.type B[]
467                    sta.obj v0
468          - values:
469              - |
470                #
471                    lda.type panda.String
472                    sta.obj v0
473          - values:
474              - |
475                #
476                    lda.type panda.Object
477                    sta.obj v0
478          - values:
479              - |
480                #
481                    movi v0, 10
482                    newarr v0, v0, i32[]
483          - values:
484              - mov.null v0
485        cases:
486          - values:
487              - movi v1, 0
488            id: val
489          - values:
490              - movi.64 v1, 0
491          - values:
492              - fmovi v1, 0
493          - values:
494              - fmovi.64 v1, 0
495          - values:
496              - |
497                #
498                    lda.type A
499                    sta.obj v1
500          - values:
501              - |
502                #
503                    lda.type A[]
504                    sta.obj v1
505
506          - values:
507              - |
508                #
509                    lda.type panda.String
510                    sta.obj v1
511          - values:
512              - |
513                #
514                    lda.type panda.Object
515                    sta.obj v1
516          - values:
517              - |
518                #
519                    movi v1, 10
520                    newarr v1, v1, f64[]
521          - values:
522              - mov.null v1
523
524      - file-name: uninitialized_regs
525        isa:
526          instructions:
527            - sig: add v1:in:i32, v2:in:i32
528              acc: out:i32
529              format: [op_v1_4_v2_4]
530        description: Check 'add' with uninitialized registers.
531        tags: ['verifier']
532        runner-options: ['verifier-failure', 'verifier-config']
533        code-template: |
534          #
535              %s
536              *s
537              add %s, *s
538        check-type: exit-positive
539        template-cases:
540          - values:
541              - ''
542              - v0
543          - values:
544              - movi v0, 0
545              - v0
546            exclude: [init]
547          - values:
548              - ''
549              - v7
550          - values:
551              - ''
552              - v15
553          - values:
554              - 'movi v15, 0'
555              - v15
556            exclude: [init]
557        cases:
558          - values:
559              - ''
560              - v1
561          - values:
562              - movi v1, 0
563              - v1
564            id: init
565          - values:
566              - ''
567              - v8
568          - values:
569              - ''
570              - v14
571