• 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: "shr2"
17    isa:
18      title: Two address binary operation on accumulator
19      description: >
20        Perform specified binary operation on accumulator and register and store result into accumulator
21      exceptions:
22        - x_none
23    commands:
24      - file-name: "op_vs_8_zero"
25        isa:
26          instructions:
27            - sig: shr2 v:in:i32
28              acc: inout:i32
29              prefix: bit
30              format: [pref_op_v_8]
31        code-template: |
32          #
33              ldai 0
34              movi v0, %s
35              mov v1, v0
36              shr2 v0
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 shr2 with zero and various values.
45        cases:
46          - values:
47              - "0"
48          - values:
49              - "1"
50          - values:
51              - "-1"
52            bugid: ['1387']
53          - values:
54              - "0x7FFFFFFF"
55            bugid: ['1387']
56          - values:
57              - "0x80000000"
58            bugid: ['1387']
59          - values:
60              - "-0x7FFFFFFF"
61            bugid: ['1387']
62          - values:
63              - "-0x80000000"
64            bugid: ['1387']
65          - values:
66              - "0xFFFFFFFF"
67            bugid: ['1387']
68          - values:
69              - "-0xFFFFFFFF"
70
71      - file-name: "op_vs_8_pone"
72        isa:
73          instructions:
74            - sig: shr2 v:in:i32
75              acc: inout:i32
76              prefix: bit
77              format: [pref_op_v_8]
78        code-template: |
79          #
80              ldai 1
81              movi v0, %s
82              shr2 v0
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 shr2 with +1 and various values.
91        cases:
92          - values:
93              - "0"
94              - "1"
95          - values:
96              - "1"
97              - "0"
98          - values:
99              - "-1"
100              - "0"
101            bugid: ['1387']
102          - values:
103              - "0x7FFFFFFF"
104              - "0"
105            bugid: ['1387']
106          - values:
107              - "0x80000000"
108              - "1"
109            bugid: ['1387']
110          - values:
111              - "-0x7FFFFFFF"
112              - "0"
113            bugid: ['1387']
114          - values:
115              - "-0x80000000"
116              - "1"
117            bugid: ['1387']
118          - values:
119              - "0xFFFFFFFF"
120              - "0"
121            bugid: ['1387']
122          - values:
123              - "-0xFFFFFFFF"
124              - "0"
125      - file-name: "op_vs_8_none"
126        isa:
127          instructions:
128            - sig: shr2 v:in:i32
129              acc: inout:i32
130              prefix: bit
131              format: [pref_op_v_8]
132        code-template: |
133          #
134              ldai -1
135              movi v0, %s
136              shr2 v0
137              movi v0, %s
138              jne v0, set_failure
139              ldai 0
140              jmp fall_through
141          set_failure:
142              ldai 1
143          fall_through:
144        description: Check shr2 with -1 and various values.
145        cases:
146          - values:
147              - "0"
148              - "0xFFFFFFFF"
149          - values:
150              - "1"
151              - "0x7FFFFFFF"
152          - values:
153              - "-1"
154              - "1"
155            bugid: ['1387']
156          - values:
157              - "0x7FFFFFFF"
158              - "1"
159            bugid: ['1387']
160          - values:
161              - "0x80000000"
162              - "0xFFFFFFFF"
163            bugid: ['1387']
164          - values:
165              - "-0x7FFFFFFF"
166              - "0x7FFFFFFF"
167            bugid: ['1387']
168          - values:
169              - "-0x80000000"
170              - "0xFFFFFFFF"
171            bugid: ['1387']
172          - values:
173              - "0xFFFFFFFF"
174              - "1"
175            bugid: ['1387']
176          - values:
177              - "-0xFFFFFFFF"
178              - "0x7FFFFFFF"
179
180      - file-name: "op_vs_8_pmax"
181        isa:
182          instructions:
183            - sig: shr2 v:in:i32
184              acc: inout:i32
185              prefix: bit
186              format: [pref_op_v_8]
187        code-template: |
188          #
189              ldai 0x7FFFFFFF
190              movi v0, %s
191              shr2 v0
192              movi v0, %s
193              jne v0, set_failure
194              ldai 0
195              jmp fall_through
196          set_failure:
197              ldai 1
198          fall_through:
199        description: Check shr2 with +max and various values.
200        cases:
201          - values:
202              - "0"
203              - "0x7FFFFFFF"
204          - values:
205              - "1"
206              - "0x3FFFFFFF"
207          - values:
208              - "-1"
209              - "0"
210            bugid: ['1387']
211          - values:
212              - "0x7FFFFFFF"
213              - "0"
214            bugid: ['1387']
215          - values:
216              - "0x80000000"
217              - "0x7FFFFFFF"
218            bugid: ['1387']
219          - values:
220              - "-0x7FFFFFFF"
221              - "0x3FFFFFFF"
222            bugid: ['1387']
223          - values:
224              - "-0x80000000"
225              - "0x7FFFFFFF"
226            bugid: ['1387']
227          - values:
228              - "0xFFFFFFFF"
229              - "0"
230            bugid: ['1387']
231          - values:
232              - "-0xFFFFFFFF"
233              - "0x3FFFFFFF"
234
235      - file-name: "op_vs_8_nmax"
236        isa:
237          instructions:
238            - sig: shr2 v:in:i32
239              acc: inout:i32
240              prefix: bit
241              format: [pref_op_v_8]
242        code-template: |
243          #
244              ldai -0x80000000
245              movi v0, %s
246              shr2 v0
247              movi v0, %s
248              jne v0, set_failure
249              ldai 0
250              jmp fall_through
251          set_failure:
252              ldai 1
253          fall_through:
254        description: Check shr2 with -max and various values.
255        cases:
256          - values:
257              - "0"
258              - "0x80000000"
259          - values:
260              - "1"
261              - "0x40000000"
262          - values:
263              - "-1"
264              - "1"
265            bugid: ['1387']
266          - values:
267              - "0x7FFFFFFF"
268              - "1"
269            bugid: ['1387']
270          - values:
271              - "0x80000000"
272              - "0x80000000"
273            bugid: ['1387']
274          - values:
275              - "-0x7FFFFFFF"
276              - "0x40000000"
277            bugid: ['1387']
278          - values:
279              - "-0x80000000"
280              - "0x80000000"
281            bugid: ['1387']
282          - values:
283              - "0xFFFFFFFF"
284              - "1"
285            bugid: ['1387']
286          - values:
287              - "-0xFFFFFFFF"
288              - "0x40000000"
289
290      - file-name: "vals"
291        bugid: ['1387']
292        tags: ["tsan"]
293        isa:
294          instructions:
295            - sig: shr2 v:in:i32
296              acc: inout:i32
297              prefix: bit
298              format: [pref_op_v_8]
299        code-template: |
300          #
301              ldai %s
302              movi v0, %s
303              shr2 v0
304              movi v0, %s
305              jne v0, set_failure
306              ldai 0
307              jmp fall_through
308          set_failure:
309              ldai 1
310          fall_through:
311        description: Check shr2 with various values.
312        cases:
313          - values:
314              - "0x5A8D97D0"
315              - "0xDA783975"
316              - "0x2D4"
317          - values:
318              - "0x4A37BE"
319              - "0x257556A"
320              - "0x128D"
321          - values:
322              - "0xD631242"
323              - "0x47A1179D"
324              - "0x0"
325          - values:
326              - "0x153C1D64"
327              - "0xB3FD21B1"
328              - "0xA9E"
329          - values:
330              - "0x5499AF7B"
331              - "0x3939DE4C"
332              - "0x5499A"
333          - values:
334              - "0xB7C3B77F"
335              - "0xCCA63ED3"
336              - "0x16F8"
337          - values:
338              - "0x90F9BD15"
339              - "0xA8A9ADC"
340              - "0x9"
341          - values:
342              - "0x226BA4EA"
343              - "0x21A3F177"
344              - "0x44"
345          - values:
346              - "0x4A295B4C"
347              - "0x62F1D4C9"
348              - "0x2514AD"
349          - values:
350              - "0xCA310014"
351              - "0xC9A571C8"
352              - "0xCA3100"
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: shr2 v:in:i32
361              acc: inout:i32
362              prefix: bit
363              format: [pref_op_v_8]
364        code-template: |
365          #
366              ldai.64 %s
367              movi.64 v0, %s
368              shr2 v0
369              movi.64 v0, %s
370              cmp.64 v0
371        description: Check shr2 with incorrect accumulator and register types.
372        cases:
373          - values:
374              - "0x17FFFFFFF"
375              - "0x1"
376              - "0x000000003FFFFFFF"
377          - values:
378              - "0x77777777FFFFFFFF"
379              - "0x1111111180000000"
380              - "0xFFFFFFFFFFFFFFFF"
381          - values:
382              - "0x180000000"
383              - "0x180000000"
384              - "0xFFFFFFFF80000000"
385
386      - file-name: "regs"
387        isa:
388          instructions:
389            - sig: shr2 v:in:i32
390              acc: inout:i32
391              prefix: bit
392              format: [pref_op_v_8]
393        runner-options: ['compile-only']
394        code-template: |
395          #
396              shr2 %s
397        check-type: none
398        description: Check shr2 with various register numbers.
399        cases:
400          - values:
401              - "v255"
402          - values:
403              - "v256"
404            runner-options: ['compile-failure']
405
406      - file-name: "type"
407        bugid: ["964", "966"]
408        tags: ["verifier"]
409        isa:
410          verification:
411            - acc_type
412            - v1_type
413        runner-options: ['verifier-failure', 'verifier-config']
414        header-template: []
415        code-template: |
416          .record T {}
417          .function i32 main() {
418              %s
419              *s
420              shr2 v0
421        check-type: exit-positive
422        description: Check 'shr2' with incorrect accumulator and/or register types.
423        cases:
424          - values:
425            - ldai 0
426            id: acc_ok
427          - values:
428            - ldai.64 0
429          - values:
430            - fldai 0
431            bugid: ['7315']
432          - values:
433            - fldai.64 0
434          - values:
435            - lda.null
436          - values:
437            - |
438              #
439                  movi v1, 0
440                  newarr v1, v1, i32[]
441                  lda.obj v1
442          - values:
443            - lda.str "0"
444          - values:
445            - lda.type T
446          - values:
447            - |
448              #
449                  newobj v1, T
450                  lda.obj v1
451        template-cases:
452          - values:
453            - movi v0, 0
454            exclude: [acc_ok]
455          - values:
456            - movi.64 v0, 0
457          - values:
458            - fmovi v0, 0
459            bugid: ['7315']
460          - values:
461            - fmovi.64 v0, 0
462          - values:
463            - mov.null v0
464          - values:
465            - |
466              #
467                  movi v0, 0
468                  newarr v0, v0, i32[]
469          - values:
470            - |
471              #
472                  lda.str "0"
473                  sta.obj v0
474          - values:
475            - |
476              #
477                  lda.type T
478                  sta.obj v0
479          - values:
480            - newobj v0, T
481
482
483      - file-name: uninitialized_regs
484        isa:
485          instructions:
486            - sig: shr2 v:in:i32
487              acc: inout:i32
488              prefix: bit
489              format: [pref_op_v_8]
490        description: Check 'shr2' with uninitialized registers.
491        tags: ['verifier']
492        runner-options: ['verifier-failure', 'verifier-config']
493        code-template: |
494          #
495              %s
496              *s
497              shr2 *s
498        check-type: exit-positive
499        template-cases:
500          - values:
501              - ''
502          - values:
503              - ldai 0
504            exclude: [init]
505        cases:
506          - values:
507              - ''
508              - v0
509          - values:
510              - movi v1, 0
511              - v1
512            id: init
513          - values:
514              - ''
515              - v8
516          - values:
517              - ''
518              - v15
519          - values:
520              - movi v15, 0
521              - v15
522            id: init
523