• 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
14definitions: []
15tests:
16  - file-name: "modu2"
17    isa:
18      title: Two address integer division and modulo on accumulator
19      description: >
20        Perform integer division or modulo on accumulator and register and store result into accumulator
21      exceptions:
22        - x_arith
23    commands:
24      - file-name: "op_vs_8_zero"
25        isa:
26          instructions:
27            - sig: modu2 v:in:u32
28              acc: inout:u32
29              prefix: unsigned
30              format: [pref_op_v_8]
31        tags: ['irtoc_ignore']
32        code-template: |
33          #
34              ldai 0
35              movi v0, %s
36              modu2 v0
37              movi v0, 0
38              ucmp v0
39        description: Check modu2 with zero and various values.
40        cases:
41          - values:
42              - "0"
43            runner-options: ['run-failure']
44            description: Division by zero causes to exception.
45          - values:
46              - "1"
47          - values:
48              - "-1"
49          - values:
50              - "0x7FFFFFFF"
51          - values:
52              - "0x80000000"
53          - values:
54              - "-0x7FFFFFFF"
55          - values:
56              - "-0x80000000"
57          - values:
58              - "0xFFFFFFFF"
59          - values:
60              - "-0xFFFFFFFF"
61
62      - file-name: "op_vs_8_pone"
63        isa:
64          instructions:
65            - sig: modu2 v:in:u32
66              acc: inout:u32
67              prefix: unsigned
68              format: [pref_op_v_8]
69        tags: ['irtoc_ignore']
70        code-template: |
71          #
72              ldai 1
73              movi v0, %s
74              modu2 v0
75              movi v0, %s
76              ucmp v0
77        description: Check modu2 with +1 and various values.
78        cases:
79          - values:
80              - "0"
81              - "0x0"
82            runner-options: ['run-failure']
83            description: Division by zero causes to exception.
84          - values:
85              - "1"
86              - "0"
87          - values:
88              - "-1"
89              - "1"
90          - values:
91              - "0x7FFFFFFF"
92              - "1"
93          - values:
94              - "0x80000000"
95              - "1"
96          - values:
97              - "-0x7FFFFFFF"
98              - "1"
99          - values:
100              - "-0x80000000"
101              - "1"
102          - values:
103              - "0xFFFFFFFF"
104              - "1"
105          - values:
106              - "-0xFFFFFFFF"
107              - "0"
108
109      - file-name: "op_vs_8_none"
110        isa:
111          instructions:
112            - sig: modu2 v:in:u32
113              acc: inout:u32
114              prefix: unsigned
115              format: [pref_op_v_8]
116        tags: ['irtoc_ignore']
117        code-template: |
118          #
119              ldai -1
120              movi v0, %s
121              modu2 v0
122              movi v0, %s
123              ucmp v0
124        description: Check modu2 with -1 and various values.
125        cases:
126          - values:
127              - "0"
128              - "0"
129            runner-options: ['run-failure']
130            description: Division by zero causes to exception.
131          - values:
132              - "1"
133              - "0"
134          - values:
135              - "-1"
136              - "0"
137          - values:
138              - "0x7FFFFFFF"
139              - "1"
140          - values:
141              - "0x80000000"
142              - "0x7FFFFFFF"
143          - values:
144              - "-0x7FFFFFFF"
145              - "0x7FFFFFFE"
146          - values:
147              - "-0x80000000"
148              - "0x7FFFFFFF"
149          - values:
150              - "0xFFFFFFFF"
151              - "0"
152          - values:
153              - "-0xFFFFFFFF"
154              - "0"
155
156      - file-name: "op_vs_8_pmax"
157        isa:
158          instructions:
159            - sig: modu2 v:in:u32
160              acc: inout:u32
161              prefix: unsigned
162              format: [pref_op_v_8]
163        tags: ['irtoc_ignore']
164        code-template: |
165          #
166              ldai 0x7FFFFFFF
167              movi v0, %s
168              modu2 v0
169              movi v0, %s
170              ucmp v0
171        description: Check modu2 with +max and various values.
172        cases:
173          - values:
174              - "0"
175              - "0"
176            runner-options: ['run-failure']
177            description: Division by zero causes to exception.
178          - values:
179              - "1"
180              - "0"
181          - values:
182              - "-1"
183              - "0x7FFFFFFF"
184          - values:
185              - "0x7FFFFFFF"
186              - "0"
187          - values:
188              - "0x80000000"
189              - "0x7FFFFFFF"
190          - values:
191              - "-0x7FFFFFFF"
192              - "0x7FFFFFFF"
193          - values:
194              - "-0x80000000"
195              - "0x7FFFFFFF"
196          - values:
197              - "0xFFFFFFFF"
198              - "0x7FFFFFFF"
199          - values:
200              - "-0xFFFFFFFF"
201              - "0"
202
203      - file-name: "op_vs_8_nmax"
204        isa:
205          instructions:
206            - sig: modu2 v:in:u32
207              acc: inout:u32
208              prefix: unsigned
209              format: [pref_op_v_8]
210        tags: ['irtoc_ignore']
211        code-template: |
212          #
213              ldai -0x80000000
214              movi v0, %s
215              modu2 v0
216              movi v0, %s
217              ucmp v0
218        description: Check modu2 with -max and various values.
219        cases:
220          - values:
221              - "0"
222              - "0"
223            runner-options: ['run-failure']
224            description: Division by zero causes to exception.
225          - values:
226              - "1"
227              - "0"
228          - values:
229              - "-1"
230              - "0x80000000"
231          - values:
232              - "0x7FFFFFFF"
233              - "1"
234          - values:
235              - "0x80000000"
236              - "0"
237          - values:
238              - "-0x7FFFFFFF"
239              - "0x80000000"
240          - values:
241              - "-0x80000000"
242              - "0"
243          - values:
244              - "0xFFFFFFFF"
245              - "0x80000000"
246          - values:
247              - "-0xFFFFFFFF"
248              - "0"
249
250      - file-name: "vals"
251        isa:
252          instructions:
253            - sig: modu2 v:in:u32
254              acc: inout:u32
255              prefix: unsigned
256              format: [pref_op_v_8]
257        code-template: |
258          #
259              ldai %s
260              movi v0, %s
261              modu2 v0
262              movi v0, %s
263              ucmp v0
264        description: Check modu2 with various values.
265        tags: ['tsan']
266        cases:
267          - values:
268              - "0x8A2D7087"
269              - "0x9738"
270              - "0x10E7"
271          - values:
272              - "0xF890E968"
273              - "0x2EB89"
274              - "0x1E6D1"
275          - values:
276              - "0x2C8979B4"
277              - "0x9D618"
278              - "0x1330C"
279          - values:
280              - "0x544FAA9D"
281              - "0xD3F57"
282              - "0x39E02"
283          - values:
284              - "0x732823F4"
285              - "0x507F"
286              - "0x4AF"
287          - values:
288              - "0xD3367BD4"
289              - "0x3A2D9"
290              - "0x1532E"
291          - values:
292              - "0x761956A8"
293              - "0x68812"
294              - "0x57140"
295          - values:
296              - "0xF7C3980D"
297              - "0xDDC89"
298              - "0xB63B6"
299          - values:
300              - "0xDF705C05"
301              - "0x4DDE8"
302              - "0x9BDD"
303          - values:
304              - "0xDD536643"
305              - "0xFF005"
306              - "0x150D4"
307
308      - file-name: "op_v_8_exception"
309        isa:
310          instructions:
311            - sig: modu2 v:in:u32
312              acc: inout:u32
313              prefix: unsigned
314              format: [pref_op_v_8]
315        tags: ['irtoc_ignore']
316        header-template: [ArithmeticException, main]
317        code-template: |
318            #
319                ldai %s
320                movi v0, 0
321            begin:
322                modu2 v0
323            end:
324                ldai 1 # Should not reach this line
325                return
326
327            catch_AE:
328                ldai 0 # Expected panda.ArithmeticException
329                return
330
331            catch_all:
332                ldai 1 # Unexpected exception, test failed
333                return
334
335            .catch panda.ArithmeticException, begin, end, catch_AE
336            .catchall begin, end, catch_all
337        check-type: none
338        description: Check `modu2` throws ArithmeticException when divides by zero.
339        cases:
340          - values: ["0"]
341          - values: ["1"]
342          - values: ["0x7FFF"]
343          - values: ["0xFFFF"]
344          - values: ["0x7FFFFFFF"]
345          - values: ["0x80000000"]
346          - values: ["0xFFFFFFFF"]
347          - values: ["-1"]
348          - values: ["-0x7FFF"]
349          - values: ["-0xFFFF"]
350          - values: ["-0x7FFFFFFF"]
351          - values: ["-0x80000000"]
352          - values: ["-0xFFFFFFFF"]
353
354      - file-name: "vals_mod32_1"
355        bugid: ['1324']
356        tags: ['verifier']
357        runner-options: ['verifier-failure', 'verifier-config']
358        isa:
359          instructions:
360            - sig: modu2 v:in:u32
361              acc: inout:u32
362              prefix: unsigned
363              format: [pref_op_v_8]
364        code-template: |
365          #
366              ldai %s
367              movi v0, %s
368              modu2 v0
369              movi.64 v0, %s
370              ucmp.64 v0
371        description: Check modu2 with incorrect accumulator and register type.
372        cases:
373          - values:
374              - "0xFFFFFFFF"
375              - "2"
376              - "1"
377          - values:
378              - "0xFFFFFFFF"
379              - "0x7FFFFFFE"
380              - "0x3"
381          - values:
382              - "0x80000001"
383              - "2"
384              - "1"
385
386      - file-name: "vals_mod32_2"
387        bugid: ['1324']
388        tags: ['verifier']
389        runner-options: ['verifier-failure', 'verifier-config']
390        isa:
391          instructions:
392            - sig: modu2 v:in:u32
393              acc: inout:u32
394              prefix: unsigned
395              format: [pref_op_v_8]
396        code-template: |
397          #
398              ldai.64 %s
399              movi.64 v0, %s
400              modu2 v0
401              movi.64 v0, %s
402              ucmp.64 v0
403        description: Check modu2 with incorrect accumulator and register type.
404        cases:
405          - values:
406              - "0x180000001"
407              - "0xF00000002"
408              - "1"
409          - values:
410              - "0x777777777FFFFFFF"
411              - "0x11111111FFFFFFFE"
412              - "0x7FFFFFFF"
413          - values:
414              - "0xFEDCBA8780000001"
415              - "0x1234567800000002"
416              - "1"
417
418      - file-name: "regs"
419        isa:
420          instructions:
421            - sig: modu2 v:in:u32
422              acc: inout:u32
423              prefix: unsigned
424              format: [pref_op_v_8]
425        runner-options: ['compile-only']
426        code-template: |
427          #
428              modu2 %s
429        check-type: none
430        description: Check modu2 with various register numbers.
431        cases:
432          - values:
433              - "v255"
434          - values:
435              - "v256"
436            runner-options: ['compile-failure']
437
438      - file-name: "type"
439        tags: ["verifier"]
440        isa:
441          verification:
442            - acc_type
443            - v1_type
444        runner-options: ['verifier-failure', 'verifier-config']
445        header-template: []
446        code-template: |
447          .record T {}
448          .function i32 main() {
449              %s
450              *s
451              modu2 v0
452        check-type: exit-positive
453        description: Check 'modu2' with incorrect accumulator and/or register types.
454        cases:
455          - values:
456            - ldai 0
457            id: acc_ok
458          - values:
459            - ldai.64 0
460          - values:
461            - fldai 0
462          - values:
463            - fldai.64 0
464          - values:
465            - lda.null
466          - values:
467            - |
468              #
469                  movi v1, 0
470                  newarr v1, v1, i32[]
471                  lda.obj v1
472          - values:
473            - lda.str "0"
474          - values:
475            - lda.type T
476          - values:
477            - |
478              #
479                  newobj v1, T
480                  lda.obj v1
481        template-cases:
482          - values:
483            - movi v0, 1
484            exclude: [acc_ok]
485          - values:
486            - movi.64 v0, 1
487          - values:
488            - fmovi v0, 1
489          - values:
490            - fmovi.64 v0, 1
491          - values:
492            - mov.null v0
493          - values:
494            - |
495              #
496                  movi v0, 0
497                  newarr v0, v0, i32[]
498          - values:
499            - |
500              #
501                  lda.str "0"
502                  sta.obj v0
503          - values:
504            - |
505              #
506                  lda.type T
507                  sta.obj v0
508          - values:
509            - newobj v0, T
510
511
512      - file-name: uninitialized_regs
513        isa:
514          instructions:
515            - sig: modu2 v:in:u32
516              acc: inout:u32
517              prefix: unsigned
518              format: [pref_op_v_8]
519        description: Check 'modu2' with uninitialized registers.
520        tags: ['verifier']
521        runner-options: ['verifier-failure', 'verifier-config']
522        code-template: |
523          #
524              %s
525              *s
526              modu2 *s
527        check-type: exit-positive
528        template-cases:
529          - values:
530              - ''
531          - values:
532              - ldai 0
533            exclude: [init]
534        cases:
535          - values:
536              - ''
537              - v0
538          - values:
539              - movi v1, 0
540              - v1
541            id: init
542          - values:
543              - ''
544              - v8
545          - values:
546              - ''
547              - v15
548          - values:
549              - movi v15, 0
550              - v15
551            id: init
552