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