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