1# Copyright (c) 2021-2022 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
16tests:
17  - file-name: "mov.obj"
18    isa:
19      title: Move register-to-register
20      description: Move values between registers.
21      exceptions:
22        - x_none
23    commands:
24      - file-name: "op_p"
25        isa:
26          instructions:
27            - sig: mov.obj v1:out:ref, v2:in:ref
28              acc: none
29              format: [op_v1_4_v2_4, op_v1_8_v2_8, op_v1_16_v2_16]
30        code-template: |
31          %s
32          # header
33          .function i32 main() {
34          #
35              newobj v0, Object
36              lda.obj v0
37              mov.obj v1, v0
38              jne.obj v1, return_ne_num
39              ldai 0
40              return
41          return_ne_num:
42              ldai 1
43              return
44        header-template: []
45        description: Check mov.obj with different type of arguments (empty object, with fields, with static fields, string, type) in PandaAssemby context.
46        tags: ['tsan']
47        cases:
48          - values:
49              - |
50                .record Object {
51                }
52          - values:
53              - |
54                .record Object {
55                    i32 fld2
56                }
57          - values:
58              - |
59                .record Object {
60                    i64 fld2
61                }
62          - values:
63              - |
64                .record Object {
65                    u64 fld2
66                }
67          - values:
68              - |
69                .record Object {
70                    i32 fld2 <static>
71                }
72          - values:
73              - |
74                .record Object {
75                    i32 fld1
76                    i32 fld2 <static>
77                }
78
79          - values:
80              - |
81                .record Object {
82                    i64 fld1
83                    i64 fld2 <static>
84                }
85          - values:
86              - |
87                .record Object {
88                    f64 fld1
89                    f64 fld2 <static>
90                }
91          - values:
92              - |
93                .record Object {
94                    f32 fld1
95                    f32 fld2 <static>
96                    f64 fld3
97                    f64 fld4 <static>
98                    i32 fld5
99                    i32 fld6 <static>
100                    i64 fld7
101                    i64 fld8 <static>
102                }
103          - case-template: |
104              #
105              .function i32 main() {
106              # Check mov.obj for string
107                  lda.str ""
108                  sta.obj v0
109                  mov.obj v1, v0
110                  jne.obj v1, return_ne_num
111                  ldai 0
112                  return
113              return_ne_num:
114                  ldai 1
115                  return
116          - case-template: |
117              #
118              .record Object {}
119              .function i32 main() {
120              # Check mov.obj for type
121                  lda.type Object
122                  sta.obj v0
123                  mov.obj v1, v0
124                  jne.obj v1, return_ne_num
125                  ldai 0
126                  return
127              return_ne_num:
128                  ldai 1
129                  return
130
131      - file-name: "op_j"
132        runner-options: [use-pa]
133        isa:
134          instructions:
135            - sig: mov.obj v1:out:ref, v2:in:ref
136              acc: none
137              format: [op_v1_4_v2_4, op_v1_8_v2_8, op_v1_16_v2_16]
138        code-template: |
139          .language PandaAssembly
140          %s
141          # header
142          .function i32 main() {
143          #
144              %s
145              %s
146              mov.obj v1, v0
147              jne.obj v1, return_ne_num
148              ldai 0
149              return
150          return_ne_num:
151              ldai 1
152              return
153        header-template: []
154        description: Check mov.obj with different type of arguments (empty object, with fields, with static fields, string, type) in PandaAssembly context.
155        tags: ['tsan']
156        cases:
157          - values:
158              - |
159                .record Obj {
160                }
161              - newobj v0, Obj
162              - lda.obj v0
163          - values:
164              - |
165                .record Obj {
166                    i32 fld2
167                }
168              - newobj v0, Obj
169              - lda.obj v0
170          - values:
171              - ""
172              - lda.str "test string"
173              - sta.obj v0
174          - values:
175              - .record panda.Object <external>
176              - lda.type panda.Object
177              - sta.obj v0
178          - values:
179              - .record panda.NullPointerException <external>
180              - newobj v0, panda.NullPointerException
181              - lda.obj v0
182
183      - file-name: "null"
184        isa:
185          instructions:
186            - sig: mov.obj v1:out:ref, v2:in:ref
187              acc: none
188              format: [op_v1_4_v2_4, op_v1_8_v2_8, op_v1_16_v2_16]
189        code-template: |
190          %s
191          # header
192          .function i32 main() {
193          # Check mov.obj for null
194              mov.null v0
195              mov.obj v1, v0
196              newobj v2, Object
197              lda.obj v2
198              jne.obj v1, ok
199              ldai 1
200              return
201          ok:
202              ldai 0
203              return
204        header-template: []
205        check-type: none
206        description: Check mov.obj with null value.
207        cases:
208          - values:
209              - |
210                .record Object {
211                }
212          - case-template: |
213              # header
214              .function i32 main() {
215              #
216                  mov.null v0
217                  mov.obj v1, v0
218                  lda.null
219                  jeq.obj v1, ok
220                  ldai 1
221                  return
222              ok:
223                  ldai 0
224                  return
225            case-check-type: none
226
227      - file-name: "op_4_8_16"
228        isa:
229            instructions:
230              - sig: mov.obj v1:out:ref, v2:in:ref
231                acc: none
232                format: [op_v1_4_v2_4, op_v1_8_v2_8, op_v1_16_v2_16]
233        code-template: |
234            .record Object {}
235            # header
236            .function i32 main() {
237            # Check mov.obj with different registers number
238                newobj v0, Object
239                lda.obj v0
240                mov.obj %s, v0
241                mov.obj v1, %s
242                jne.obj v1, return_ne_num
243                ldai 0
244                return
245            return_ne_num:
246                ldai 1
247                return
248        header-template: []
249        description: Check mov.obj instruction with different register numbers (4, 8, 16 bit).
250        cases:
251            - values: [v0, v0]
252            - values: [v7, v7]
253            - values: [v8, v8]
254            - values: [v15, v15]
255            - values: [v16, v16]
256            - values: [v127, v127]
257            - values: [v128, v128]
258            - values: [v255, v255]
259            - values: [v256, v256]
260            - values: [v16384, v16384]
261            - values: [v32767, v32767]
262            - values: [v32768, v32768]
263            - values: [v65524, v65524]
264            - values: [v65535, v65535]
265            - values: [v65536, v65536]
266              runner-options: [compile-failure]
267
268      - file-name: "op_4_8_16_null"
269        isa:
270            instructions:
271              - sig: mov.obj v1:out:ref, v2:in:ref
272                acc: none
273                format: [op_v1_4_v2_4, op_v1_8_v2_8, op_v1_16_v2_16]
274        code-template: |
275            # Check mov.obj with different registers number and null
276                mov.null v0
277                mov.obj %s, v0
278                mov.obj v1, %s
279                lda.null
280                jne.obj v1, return_ne_num
281                ldai 0
282                return
283            return_ne_num:
284                ldai 1
285                return
286        description: Check mov.obj instruction with different register numbers (4, 8, 16 bit) and null value.
287        cases:
288            - values: [v0, v0]
289            - values: [v7, v7]
290            - values: [v8, v8]
291            - values: [v15, v15]
292            - values: [v16, v16]
293            - values: [v127, v127]
294            - values: [v128, v128]
295            - values: [v255, v255]
296            - values: [v256, v256]
297            - values: [v16384, v16384]
298            - values: [v32767, v32767]
299            - values: [v32768, v32768]
300            - values: [v65524, v65524]
301            - values: [v65535, v65535]
302            - values: [v65536, v65536]
303              runner-options: [compile-failure]
304
305      - file-name: "op_type"
306        tags: ['verifier']
307        bugid: ['966', '964']
308        description: Check mov.obj instruction with incorrect type of source argument.
309        isa:
310            instructions:
311              - sig: mov.obj v1:out:ref, v2:in:ref
312                acc: none
313                format: [op_v1_4_v2_4, op_v1_8_v2_8, op_v1_16_v2_16]
314            verification:
315              - v2_type
316        code-template: |
317            # Check mov.obj with wrong type
318                %s
319                mov.obj v1, v0
320        check-type: none
321        runner-options: ['verifier-failure', 'verifier-config']
322        cases:
323            - values:
324                - movi v0, 123
325            - values:
326                - movi.64 v0, 123
327            - values:
328                - fmovi v0, 123
329            - values:
330                - fmovi.64 v0, 123
331            - values:
332                - movi v0, 0
333            - values:
334                - movi.64 v0, 0
335            - values:
336                - fmovi v0, 0
337            - values:
338                - fmovi.64 v0, 0
339
340      - file-name: "err"
341        isa:
342            instructions:
343              - sig: mov.obj v1:out:ref, v2:in:ref
344                acc: none
345                format: [op_v1_4_v2_4, op_v1_8_v2_8, op_v1_16_v2_16]
346            verification:
347              - v2_type
348        code-template: |
349            #
350                %s
351        check-type: none
352        runner-options: [compile-failure]
353        description: Check mov.obj instruction with wrong arguments.
354        cases:
355            - values:
356                - mov.obj 1, 1
357            - values:
358                - mov.obj "", v0
359            - values:
360                - mov.obj v0, ""
361            - values:
362                - mov.obj v0, 1
363            - values:
364                - mov.obj 1, v0
365            - values:
366                - mov.obj 0, v0
367            - values:
368                - mov.obj v0, 0
369            - values:
370                - mov.obj v0, 1.1
371            - values:
372                - mov.obj 1.1, v0
373            - values:
374                - mov.obj a0, a0
375            - values:
376                - mov.obj a0, v0
377            - values:
378                - mov.obj v0, a0
379            - values:
380                - mov.obj "", ""
381            - values:
382                - mov.obj a0, ""
383            - values:
384                - mov.obj "", a0
385
386      - file-name: "type_p"
387        tags: ['verifier']
388        isa:
389          instructions:
390            - sig: mov.obj v1:out:ref, v2:in:ref
391              acc: none
392              format: [op_v1_4_v2_4, op_v1_8_v2_8, op_v1_16_v2_16]
393          verification:
394            - v2_type
395        runner-options: ['verifier-failure', 'verifier-config']
396        header-template: []
397        code-template: |
398            #
399            .record A {}
400            .record B {}
401            .record panda.String <external>
402            .record panda.Object <external>
403            .function i32 main() {
404                %s
405                *s
406                mov.obj v0, v1
407                ldai 0
408        check-type: no-check
409        description: Check mov.obj with incorrect source register type in PandaAssembly context. Destination type is not checked.
410        template-cases:
411          - values:
412              - |
413                #
414                    lda.type B
415                    sta.obj v0
416          - values:
417              - |
418                #
419                    lda.type B[]
420                    sta.obj v0
421          - values:
422              - |
423                #
424                    lda.type panda.String
425                    sta.obj v0
426          - values:
427              - |
428                #
429                    lda.type panda.Object
430                    sta.obj v0
431          - values:
432              - |
433                #
434                    movi v0, 10
435                    newarr v0, v0, i32[]
436          - values:
437              - mov.null v0
438          - values:
439              - movi v0, 0
440          - values:
441              - movi.64 v0, 0
442          - values:
443              - fmovi.64 v0, 0
444        cases:
445          - values:
446              - movi v1, 0
447          - values:
448              - movi.64 v1, 0
449          - values:
450              - fmovi v1, 0
451          - values:
452              - fmovi.64 v1, 0
453
454      - file-name: "type_j"
455        tags: [verifier, pa-verifier]
456        isa:
457          instructions:
458            - sig: mov.obj v1:out:ref, v2:in:ref
459              acc: none
460              format: [op_v1_4_v2_4, op_v1_8_v2_8, op_v1_16_v2_16]
461          verification:
462            - v2_type
463        runner-options: [verifier-failure, use-pa, verifier-config]
464        header-template: []
465        bugid: ["5271"]
466        code-template: |
467            .language PandaAssembly
468            #
469            .record A {}
470            .record B <panda.extends=A> {}
471            .record panda.String <external>
472            .record panda.Object <external>
473            .function i32 main() {
474                %s
475                *s
476                mov.obj v0, v1
477                ldai 0
478        check-type: no-check
479        description: Check mov.obj with incorrect source register type in PandaAssembly context. Destination type is not checked.
480        template-cases:
481          - values:
482              - |
483                #
484                    lda.type B
485                    sta.obj v0
486          - values:
487              - |
488                #
489                    lda.type B[]
490                    sta.obj v0
491          - values:
492              - |
493                #
494                    lda.type panda.String
495                    sta.obj v0
496          - values:
497              - |
498                #
499                    lda.type panda.Object
500                    sta.obj v0
501          - values:
502              - |
503                #
504                    movi v0, 10
505                    newarr v0, v0, i32[]
506          - values:
507              - mov.null v0
508          - values:
509              - movi v0, 0
510          - values:
511              - movi.64 v0, 0
512          - values:
513              - fmovi.64 v0, 0
514        cases:
515          - values:
516              - movi v1, 0
517          - values:
518              - movi.64 v1, 0
519          - values:
520              - fmovi v1, 0
521          - values:
522              - fmovi.64 v1, 0
523
524      - file-name: uninitialized_regs
525        isa:
526          instructions:
527            - sig: mov.obj v1:out:ref, v2:in:ref
528              acc: none
529              format: [op_v1_4_v2_4, op_v1_8_v2_8, op_v1_16_v2_16]
530        description: Check mov.obj with uninitialized registers.
531        tags: ['verifier']
532        runner-options: ['verifier-failure', 'verifier-config']
533        header-template: []
534        code-template: |
535          #
536          .function i32 main() {
537              %s
538              *s
539              mov.obj %s, *s
540              ldai 0
541        check-type: no-check
542        template-cases:
543          - values: ['', 'v0']
544          - values: ['', 'v256']
545          - values: ['', 'v65535']
546          - values:
547              - movi v2, 0
548              - v2
549          - values:
550              - |
551                #
552                    mov.null v1
553                    mov.obj v65534, v1
554              - v65534
555          - values:
556              - |
557                #
558                    mov.null v1
559                    mov.obj v257, v1
560              - v257
561        cases:
562          - values:
563              - ''
564              - v0
565          - values:
566              - ''
567              - v8
568          - values:
569              - ''
570              - v15
571          - values:
572              - ''
573              - v256
574          - values:
575              - ''
576              - v65535
577