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