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