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