• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021 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:
15  - name: java
16    template: |
17      .language Java
18  - name: aoobe_p
19    template: |
20      .record panda.ArrayIndexOutOfBoundsException<external>
21  - name: aoobe_j
22    template: |
23      .record java.lang.ArrayIndexOutOfBoundsException<external>
24  - name: npe_p
25    template: |
26      .record panda.NullPointerException <external>
27  - name: npe_j
28    template: |
29      .record java.lang.NullPointerException <external>
30
31tests:
32  - file-name: "starr.16"
33    isa:
34      title: Store to array
35      description: >
36        Store accumulator content into array slot pointed by index.
37        If size of element to store is less than 32, accumulator content will be truncated
38        to storage size before storing.
39      instructions:
40        - sig: starr.16 v1:in:i16[], v2:in:i32
41          acc: in:i16
42          format: [op_v1_4_v2_4]
43    commands:
44
45
46      - file-name: "reg_valid"
47        isa:
48          instructions:
49            - sig: starr.16 v1:in:i16[], v2:in:i32
50              acc: in:i16
51              format: [op_v1_4_v2_4]
52        check-type: empty
53        runner-options: [compile-only]
54        description: Check 'starr.16' instruction with valid register numbers.
55        header-template: []
56        code-template: |
57          #
58          .function i32 main() {
59              starr.16 %s, %s
60              ldai 0
61              return
62          }
63        cases:
64          - values: [v0, v15]
65          - values: [v15, v0]
66          - values: [v15, v15]
67          - case-template: |
68              #
69              .function i32 f1(i16[] a0, i32 a1) {
70                  starr.16 a0, a1   # valid registers
71                  ldai 0
72                  return
73              }
74
75              .function i32 main() {
76                  call.short f1, v1, v2
77                  return
78              }
79
80
81      - file-name: "reg_v_invalid"
82        isa:
83          instructions:
84            - sig: starr.16 v1:in:i16[], v2:in:i32
85              acc: in:i16
86              format: [op_v1_4_v2_4]
87        runner-options: [compile-failure]
88        description: Check 'starr.16' instruction with invalid register numbers.
89        code-template: |
90          #
91              starr.16 %s, *s
92        check-type: exit-positive
93        template-cases:
94          - values: [v0]
95            exclude: [v0, v15]
96          - values: [v15]
97            exclude: [v0, v15]
98          - values: [v255]
99          - values: [v256]
100          - values: [v65536]
101          - values: [a0]
102          - values: ['V1']
103          - values: [null]
104          - values: [0]
105        cases:
106          - values: [v0]
107            id: v0
108          - values: [v15]
109            id: v15
110          - values: [v255]
111          - values: [v256]
112          - values: [v65536]
113          - values: [a0]
114          - values: ['V1']
115          - values: [null]
116          - values: [0]
117
118
119      - file-name: "reg_a_invalid"
120        isa:
121          instructions:
122            - sig: starr.16 v1:in:i16[], v2:in:i32
123              acc: in:i16
124              format: [op_v1_4_v2_4]
125        runner-options: [compile-failure]
126        description: Check 'starr.16' instruction with invalid register numbers.
127        header-template: []
128        code-template: |
129              #
130              .function void f1(i16[] a0, i32 a1) {
131                  starr.16 %s
132                  return.void
133              }
134
135              .function i32 main() {
136                  call.short f1, v1, v2
137        check-type: exit-positive
138        cases:
139          - values:
140            - 'a0, a2'
141          - values:
142            - 'a2, a1'
143
144
145      - file-name: null_pointer_p
146        isa:
147          exceptions:
148            - x_null
149        description: Check 'starr.16' behavior when array is null reference.
150        header-template: [npe_p]
151        code-template: |
152          .function i16[] get_null() {
153              lda.null
154              return.obj
155          }
156          .function i32 main() {
157              call.short get_null
158              sta.obj v0
159              movi v1, %s
160              ldai 0
161          begin:
162              starr.16 v0, v1
163          end:
164              ldai 1 # Should not reach this line
165              return
166
167          catch_NPE:
168              ldai 0 # Expected panda.NullPointerException
169              return
170
171          catch_all:
172              ldai 2 # Unexpected exception, test failed
173              return
174
175          .catch panda.NullPointerException, begin, end, catch_NPE
176          .catchall begin, end, catch_all
177        check-type: none
178        cases:
179          - values: [0]
180            tags: ['tsan']
181          - values: [1]
182          - values: [10]
183          - values: [128]
184          - values: [255]
185          - values: [65535]
186            tags: ['tsan']
187          - values: [0x7FFFFFFF]
188          - values: [0xFFFFFFFF]
189          - values: [0x80000000]
190
191
192      - file-name: array_out_of_bounds_exception_p
193        isa:
194          exceptions:
195            - x_bounds
196        description: Check 'starr.16' behavior when index is out of array bounds.
197        header-template: [aoobe_p, main]
198        code-template: |
199          #
200              movi v0, %s
201              newarr v0, v0, i16[]
202              movi v1, %s
203              ldai 0
204          begin:
205              starr.16 v0, v1
206          end:
207              ldai 1 # Should not reach this line
208              return
209
210          catch_AOOBE:
211              ldai 0 # Expected panda.ArrayIndexOutOfBoundsException
212              return
213
214          catch_all:
215              ldai 2 # Unexpected exception, test failed
216              return
217
218          .catch panda.ArrayIndexOutOfBoundsException, begin, end, catch_AOOBE
219          .catchall begin, end, catch_all
220        check-type: none
221        cases:
222          - values: [0, 0]
223            tags: ['tsan']
224          - values: [0, 1]
225          - values: [10, -10]
226          - values: [10, 128]
227          - values: [255, 255]
228          - values: [254, 255]
229          - values: [65535, 65535]
230            tags: ['tsan']
231          - values: [65535, 65536]
232          - values: [10, 0xFFFFFFFF]
233          - values: [256, 0xFFFFFFFE]
234          - values: [65536, 0xFFFFFFFD]
235            tags: ['tsan']
236          - values: [0x100000, 0xFFFFFFFC]
237          - values: [10, 0x80000000]
238          - values: [256, 0x80000001]
239          - values: [65536, 0x80000002]
240            tags: ['tsan']
241          - values: [0x100000, 0x80000003]
242
243
244      - file-name: uninitialized_regs
245        isa:
246          verification:
247            - v1_array_type
248            - v2_i32
249            - acc_type
250        description: Check 'starr.16' with uninitialized registers
251        tags: ['verifier']
252        runner-options: ['verifier-failure', 'verifier-debug-config']
253        header-template: []
254        code-template: |
255            #
256            .function i32 main() {
257                %s
258                starr.16 v1, v2
259        check-type: exit-positive
260        cases:
261          - values:
262              - |
263                # acc is not initialized
264                    movi v0, 10
265                    newarr v1, v0, i16[]
266                    movi v2, 0
267          - values:
268              - |
269                # v1 is not initialized
270                    movi v2, 0
271                    ldai 0
272          - values:
273              - |
274                # v2 is not initialized
275                    movi v0, 10
276                    newarr v1, v0, i16[]
277                    ldai 0
278          - values:
279              - |
280                # all regs are not initialized
281
282
283      - file-name: "acceptable_primitive_types_p"
284        isa:
285          verification:
286            - v1_array_type
287        description: Check acceptable array of primitive types for starr.16 instruction in Panda Assembly context.
288        runner-options: ['verifier-only', 'verifier-debug-config']
289        tags: ['verifier']
290        header-template: [main]
291        code-template: |
292          #
293              movi v0, 1
294              newarr v1, v0, %s
295              movi v2, 0
296              ldai 0
297              starr.16 v1, v2
298        check-type: exit-positive
299        cases:
300          - values: ['i16[]']
301          - values: ['u16[]']
302
303
304      - file-name: "rejectable_primitive_types_p"
305        isa:
306          verification:
307            - v1_array_type
308        description: Check rejectable array of primitive types for starr.16 instruction in Panda Assembly context.
309        runner-options: ['verifier-failure', 'verifier-debug-config']
310        tags: ['verifier']
311        header-template: [main]
312        code-template: |
313          #
314              movi v0, 1
315              newarr v1, v0, %s
316              movi v2, 0
317              ldai 0
318              starr.16 v1, v2
319        check-type: exit-positive
320        cases:
321          - values: ['u1[]']
322          - values: ['i8[]']
323          - values: ['u8[]']
324          - values: ['i32[]']
325          - values: ['u32[]']
326          - values: ['i64[]']
327          - values: ['u64[]']
328          - values: ['f32[]']
329          - values: ['f64[]']
330
331
332      - file-name: "arr_type_p"
333        isa:
334          verification:
335            - v1_array_type
336        description: Check 'starr.16' with incorrect array type in Panda Assembly context. See also "rejectable_primitive_types" tests.
337        runner-options: ['verifier-failure', 'verifier-debug-config']
338        tags: ['verifier']
339        header-template: []
340        code-template: |
341          #
342          .record A {}
343          .function void A.ctor(A a0) <ctor> {
344              return.void
345          }
346          .record panda.String <external>
347          .record panda.Object <external>
348          .function i32 main() {
349              %s
350              movi v1, 0
351              ldai 0
352              starr.16 v0, v1
353        check-type: exit-positive
354        cases:
355          - values:
356              - movi v0, 0
357          - values:
358              - movi.64 v0, 0
359          - values:
360              - fmovi.64 v0, 0
361          - values:
362              - |
363                #
364                    initobj A.ctor
365                    sta.obj v0
366          - values:
367              - |
368                #
369                    movi v0, 1
370                    newarr v0, v0, A[]
371          - values:
372              - |
373                #
374                    lda.type A
375                    sta.obj v0
376          - values:
377              - |
378                #
379                    lda.type A[]
380                    sta.obj v0
381          - values:
382              - |
383                #
384                    lda.type panda.String
385                    sta.obj v0
386          - values:
387              - |
388                #
389                    lda.type panda.String[]
390                    sta.obj v0
391          - values:
392              - |
393                #
394                    lda.type panda.Object
395                    sta.obj v0
396          - values:
397              - |
398                #
399                    lda.type panda.Object[]
400                    sta.obj v0
401          - values:
402              - |
403                #
404                    lda.str "string"
405                    sta.obj v0
406          - values:
407              - |
408                #
409                    movi v0, 1
410                    newarr v0, v0, panda.Object[]
411          - values:
412              - |
413                #
414                    movi v0, 1
415                    newarr v0, v0, panda.String[]
416
417
418      - file-name: "index_type_p"
419        isa:
420          verification:
421            - v2_i32
422        description: Check 'starr.16' with incorrect array index type in Panda Assembly context.
423        runner-options: ['verifier-failure', 'verifier-debug-config']
424        tags: ['verifier']
425        header-template: []
426        code-template: |
427          #
428          .record A {}
429          .function void A.ctor(A a0) <ctor> {
430              return.void
431          }
432          .record panda.String <external>
433          .record panda.Object <external>
434          .function i32 main() {
435              movi v0, 1
436              newarr v1, v0, *s
437              %s
438              ldai 0
439              starr.16 v1, v2
440        check-type: exit-positive
441        cases:
442          - values: ['u16[]']
443          - values: ['i16[]']
444        template-cases:
445          - values:
446              - mov.null v2
447          - values:
448              - movi.64 v2, 0
449          - values:
450              - fmovi.64 v2, 0
451          - values:
452              - |
453                #
454                    initobj A.ctor
455                    sta.obj v1
456          - values:
457              - |
458                #
459                    movi v0, 1
460                    newarr v2, v0, A[]
461          - values:
462              - |
463                #
464                    lda.type A
465                    sta.obj v2
466          - values:
467              - |
468                #
469                    lda.type A[]
470                    sta.obj v2
471          - values:
472              - |
473                #
474                    lda.type panda.String
475                    sta.obj v2
476          - values:
477              - |
478                #
479                    lda.type panda.String[]
480                    sta.obj v2
481          - values:
482              - |
483                #
484                    lda.type panda.Object
485                    sta.obj v2
486          - values:
487              - |
488                #
489                    lda.type panda.Object[]
490                    sta.obj v2
491          - values:
492              - |
493                #
494                    lda.str "string"
495                    sta.obj v2
496          - values:
497              - |
498                #
499                    movi v0, 1
500                    newarr v2, v0, panda.Object[]
501          - values:
502              - |
503                #
504                    movi v0, 1
505                    newarr v2, v0, panda.String[]
506
507
508      - file-name: "acc_type_p"
509        isa:
510          verification:
511            - acc_type
512        description: Check 'starr.16' with incorrect accumulator type in Panda Assembly context.
513        runner-options: ['verifier-failure', 'verifier-debug-config']
514        tags: ['verifier']
515        header-template: []
516        code-template: |
517          #
518          .record A {}
519          .function void A.ctor(A a0) <ctor> {
520              return.void
521          }
522          .record panda.String <external>
523          .record panda.Object <external>
524          .function i32 main() {
525              movi v0, 1
526              newarr v1, v0, *s
527              movi v2, 0
528              %s
529              starr.16 v1, v2
530        check-type: exit-positive
531        cases:
532          - values: ['u16[]']
533          - values: ['i16[]']
534        template-cases:
535          - values:
536              - lda.null
537          - values:
538              - ldai.64 0
539          - values:
540              - fldai.64 0
541          - values:
542              - |
543                #
544                    initobj A.ctor
545          - values:
546              - |
547                #
548                    lda.type A
549          - values:
550              - |
551                #
552                    lda.type panda.String
553          - values:
554              - |
555                #
556                    lda.type panda.String[]
557          - values:
558              - |
559                #
560                    lda.type panda.Object
561          - values:
562              - |
563                #
564                    lda.type panda.Object[]
565          - values:
566              - |
567                #
568                    lda.str "string"
569          - values:
570              - |
571                #
572                    movi v0, 1
573                    newarr v0, v0, panda.Object[]
574                    lda.obj v0
575          - values:
576              - |
577                #
578                    movi v0, 1
579                    newarr v0, v0, panda.String[]
580                    lda.obj v0
581
582
583      - file-name: "mult_regs_types_p"
584        isa:
585          verification:
586            - v1_array_type
587            - v2_i32
588            - acc_type
589        description: Check 'starr.16' with multiple incorrect register types in Panda Assembly context.
590        runner-options: ['verifier-failure', 'verifier-debug-config']
591        tags: ['verifier']
592        header-template: []
593        code-template: |
594          #
595          .record A {}
596          .function void A.ctor(A a0) <ctor> {
597              return.void
598          }
599          .record panda.String <external>
600          .record panda.Object <external>
601          .function void panda.Object.ctor(panda.Object a0) <external,ctor>
602          .function i32 main() {
603              %s
604              starr.16 v1, v2
605        check-type: exit-positive
606        cases:
607          - values:
608              - |
609                # all registers invalid
610                    initobj panda.Object.ctor
611                    sta.obj v1
612                    movi.64 v2, 0
613                    lda.str "test string"
614          - values:
615              - |
616                # v1 and v2 invalid
617                    lda.str "test string"
618                    sta.obj v1
619                    fmovi.64 v2, 1
620                    ldai 0
621          - values:
622              - |
623                # v1 and acc invalid
624                    lda.type panda.Object
625                    sta.obj v1
626                    movi v2, 0
627                    lda.str "test string"
628          - values:
629              - |
630                # v2 and acc invalid
631                    movi v0, 1
632                    newarr v1, v0, i16[]
633                    sta.obj v2
634                    initobj A.ctor
635
636
637      - file-name: "store_arr_p"
638        isa:
639          instructions:
640            - sig: starr.16 v1:in:i16[], v2:in:i32
641              acc: in:i16
642              format: [op_v1_4_v2_4]
643        description: Check starr.16 stores items to array of different size and type in Panda Assembly context.
644        code-template: |
645          #
646              movi v0, *s
647              newarr v1, v0, %s
648              movi v2, *s
649              ldai 1234567  # should be truncated
650              starr.16 v1, v2
651        check-type: exit-positive
652        template-cases:
653          - values: ['u16[]']
654          - values: ['i16[]']
655        cases:
656          - values: ['1', '0']
657          - values: ['255', '254']
658            tags: ['tsan']
659          - values: ['65536', '65535']
660
661
662      - file-name: "store_all_elements"
663        isa:
664          description: >
665            Store accumulator content into array slot pointed by index.
666        description: Check starr.16 stores correct items into array of primitives.
667        header-template: []
668        code-template: |
669            .function i32 main() {
670                movi v7, *s         # v7 is array size
671                newarr v1, v7, %s          # v1 - testable array
672
673                movi v2, 0          # array index
674            fill_array:
675                lda v2
676                starr.16 v1, v2      # v1[v2] = acc
677                inci v2, 1           # v2 = v2 + 1
678                lda v2
679                jne v7, fill_array
680                inci v2, -1
681            check_array:
682                lda v2
683                %s
684                sta v3              # value to compare with
685                lda v2
686                %s
687                jeqz ok
688                ldai 2
689                return
690            ok:
691                inci v2, -1
692                lda v2
693                jgez check_array
694        check-type: exit-positive
695        template-cases:
696          - values:
697            - i16[]
698            - |
699              #
700                  shli 16
701                  ashri 16
702            - |
703              #
704                  ldarr.16 v1
705                  jne v3, exit_failure
706                  ldai 0
707                  return
708              exit_failure: ldai 1
709                  return
710            tags: ['tsan']
711          - values:
712            - u16[]
713            - |
714              #
715                  shli 16
716                  shri 16
717            - |
718              #
719                  ldarru.16 v1
720                  ucmp v3
721        cases:
722          - values: [10000]
723