• 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
16tests:
17  - file-name: "sta.obj"
18    isa:
19      title: Store accumulator
20      description: Moves accumulator content into a register.
21      exceptions:
22        - x_none
23    commands:
24      - file-name: "op"
25        isa:
26          instructions:
27            - sig: sta.obj v:out:ref
28              acc: in:ref
29              format: [op_v_8]
30        code-template: |
31          %s
32          # header
33          .function i32 main() {
34          #
35              newobj v0, Object
36              lda.obj v0
37              sta.obj v1
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        check-type: none
46        description: Check sta.obj with different type of arguments (empty object, with fields, statics, string, type).
47        tags: ['tsan']
48        cases:
49          - values:
50              - |
51                .record Object {
52                }
53          - values:
54              - |
55                .record Object {
56                    i32 fld2
57                }
58          - values:
59              - |
60                .record Object {
61                    i64 fld2
62                }
63          - values:
64              - |
65                .record Object {
66                    u64 fld2
67                }
68          - values:
69              - |
70                .record Object {
71                    i32 fld2 <static>
72                }
73          - values:
74              - |
75                .record Object {
76                    i32 fld1
77                    i32 fld2 <static>
78                }
79
80          - values:
81              - |
82                .record Object {
83                    i64 fld1
84                    i64 fld2 <static>
85                }
86          - values:
87              - |
88                .record Object {
89                    f64 fld1
90                    f64 fld2 <static>
91                }
92          - values:
93              - |
94                .record Object {
95                    f32 fld1
96                    f32 fld2 <static>
97                    f64 fld3
98                    f64 fld4 <static>
99                    i32 fld5
100                    i32 fld6 <static>
101                    i64 fld7
102                    i64 fld8 <static>
103                }
104          - case-template: |
105              #
106              .function i32 main() {
107              # Check sta.obj for string
108                  lda.str ""
109                  sta.obj v0
110                  jne.obj v0, 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 sta.obj for type
121                  lda.type Object
122                  sta.obj v0
123                  jne.obj v0, return_ne_num
124                  ldai 0
125                  return
126              return_ne_num:
127                  ldai 1
128                  return
129
130      - file-name: "null"
131        isa:
132          instructions:
133            - sig: sta.obj v:out:ref
134              acc: in:ref
135              format: [op_v_8]
136        description: Check sta.obj with null.
137        check-type: none
138        code-template: |
139          # header
140          .function i32 main() {
141          # Check sta.obj for null
142              lda.null
143              sta.obj v0
144              jne.obj v0, return_ne_num
145              ldai 0
146              return
147          return_ne_num:
148              ldai 1
149              return
150        header-template: []
151
152      - file-name: "op_v8"
153        isa:
154          instructions:
155            - sig: sta.obj v:out:ref
156              acc: in:ref
157              format: [op_v_8]
158        code-template: |
159            .record Object {}
160            # header
161            .function i32 main() {
162            #
163                newobj v0, Object
164                lda.obj v0
165                sta.obj %s
166                jne.obj %s, return_ne_num
167                ldai 0
168                return
169            return_ne_num:
170                ldai 1
171                return
172        header-template: []
173        check-type: none
174        description: Check sta.obj with various register numbers.
175        cases:
176            - values: [v0, v0]
177            - values: [v7, v7]
178            - values: [v8, v8]
179            - values: [v15, v15]
180            - values: [v16, v16]
181            - values: [v127, v127]
182            - values: [v128, v128]
183            - values: [v255, v255]
184            - values: [v256, v256]
185              runner-options: [compile-failure]
186              description: Check sta.obj with incorrect register numbers.
187
188      - file-name: "op_v8_null"
189        isa:
190            instructions:
191              - sig: sta.obj v:out:ref
192                acc: in:ref
193                format: [op_v_8]
194        code-template: |
195            # Check sta.obj with different registers number and null
196                lda.null
197                sta.obj %s
198                jne.obj %s, return_ne_num
199                ldai 0
200                return
201            return_ne_num:
202                ldai 1
203                return
204        description: Check sta.obj with various register numbers.
205        check-type: none
206        cases:
207            - values: [v0, v0]
208            - values: [v7, v7]
209            - values: [v8, v8]
210            - values: [v15, v15]
211            - values: [v16, v16]
212            - values: [v127, v127]
213            - values: [v128, v128]
214            - values: [v255, v255]
215            - values: [v256, v256]
216              runner-options: [compile-failure]
217              description: Check sta.obj with incorrect register numbers.
218
219      - file-name: 'type'
220        isa:
221          instructions:
222              - sig: sta.obj v:out:ref
223                acc: in:ref
224                format: [op_v_8]
225          verification:
226            - acc_type
227        tags: ['verifier']
228        runner-options: ['verifier-failure', 'verifier-debug-config']
229        header-template: []
230        code-template: |
231          #
232          .record A {}
233          .record panda.String <external>
234          .function i32 main() {
235              ##- v1 initialization with different types
236              *s
237              ##- Accumulator initialization with incorrect types
238              %s
239              sta.obj v1
240        check-type: exit-positive
241        description: Check 'sta.obj' with incorrect accumulator type. Register type is not checked.
242        template-cases:
243          - values:
244              - ldai 0
245          - values:
246              - ldai.64 0
247          - values:
248              - fldai.64 0
249
250        cases:
251          - values:
252              - movi v1, 0
253          - values:
254              - movi.64 v1, 0
255          - values:
256              - fmovi.64 v1, 0
257          - values:
258              - |
259                #
260                    lda.type A
261                    sta.obj v1
262          - values:
263              - |
264                #
265                    lda.type A[]
266                    sta.obj v1
267
268          - values:
269              - |
270                #
271                    lda.type panda.String
272                    sta.obj v1
273          - values:
274              - |
275                #
276                    lda.str "string"
277                    sta.obj v1
278          - values:
279              - |
280                #
281                    movi v1, 10
282                    newarr v1, v1, f64[]
283          - values:
284              - mov.null v1
285
286      - file-name: uninitialized_acc
287        isa:
288          verification:
289            - acc_type
290        description: Check 'sta.obj' with uninitialized accumulator. Destination register is not checked.
291        tags: ['verifier']
292        runner-options: ['verifier-failure', 'verifier-debug-config']
293        header-template: []
294        code-template: |
295            #
296            .function i32 main() {
297                %s
298                sta.obj %s
299        check-type: exit-positive
300        cases:
301          - values:
302              - ''
303              - v0
304          - values:
305              - movi v0, 0
306              - v0
307          - values:
308              - ''
309              - v15
310          - values:
311              - 'movi.64 v15, 0'
312              - v15
313          - values:
314              - ''
315              - v128
316          - values:
317              - 'fmovi.64 v128, 0'
318              - v128
319          - values:
320              - ''
321              - v255
322          - values:
323              - 'mov.null v255'
324              - v255
325
326      - file-name: "err"
327        isa:
328          instructions:
329            - sig: sta.obj v:out:ref
330              acc: in:ref
331              format: [op_v_8]
332        code-template: |
333            # Check sta.obj with wrong arguments
334                %s
335        check-type: none
336        runner-options: [compile-failure]
337        description: Check sta.obj with incorrect value.
338        cases:
339            - values:
340                - sta.obj 1
341            - values:
342                - sta.obj 1.1
343            - values:
344                - sta.obj a0
345            - values:
346                - sta.obj ""
347