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