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: [] 15tests: 16 - file-name: "sta.obj" 17 isa: 18 title: Store accumulator 19 description: Moves accumulator content into a register. 20 exceptions: 21 - x_none 22 commands: 23 - file-name: "op" 24 description: Check sta.obj with different type of arguments (empty object, with fields, statics, string, type). 25 isa: 26 instructions: 27 - sig: sta.obj v:out:ref 28 acc: in:ref 29 format: [op_v_8] 30 header-template: [] 31 code-template: | 32 %s 33 # header 34 .function i32 main() { 35 # 36 newobj v0, Object 37 lda.obj v0 38 sta.obj v1 39 jne.obj v1, return_ne_num 40 ldai 0 41 return 42 return_ne_num: 43 ldai 1 44 return 45 check-type: none 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 sta.obj for string 107 lda.str "" 108 sta.obj v0 109 jne.obj v0, return_ne_num 110 ldai 0 111 return 112 return_ne_num: 113 ldai 1 114 return 115 - case-template: | 116 # 117 .record Object {} 118 .function i32 main() { 119 # Check sta.obj for type 120 lda.type Object 121 sta.obj v0 122 jne.obj v0, return_ne_num 123 ldai 0 124 return 125 return_ne_num: 126 ldai 1 127 return 128 129 - file-name: "null" 130 description: Check sta.obj with null. 131 isa: 132 instructions: 133 - sig: sta.obj v:out:ref 134 acc: in:ref 135 format: [op_v_8] 136 header-template: [] 137 code-template: | 138 # header 139 .function i32 main() { 140 # Check sta.obj for null 141 lda.null 142 sta.obj v0 143 jne.obj v0, return_ne_num 144 ldai 0 145 return 146 return_ne_num: 147 ldai 1 148 return 149 check-type: none 150 151 - file-name: "op_v8" 152 description: Check sta.obj with various register numbers. 153 isa: 154 instructions: 155 - sig: sta.obj v:out:ref 156 acc: in:ref 157 format: [op_v_8] 158 header-template: [] 159 code-template: | 160 .record Object {} 161 # header 162 .function i32 main() { 163 # 164 newobj v0, Object 165 lda.obj v0 166 sta.obj %s 167 jne.obj %s, return_ne_num 168 ldai 0 169 return 170 return_ne_num: 171 ldai 1 172 return 173 check-type: none 174 cases: 175 - values: [v0, v0] 176 - values: [v7, v7] 177 - values: [v8, v8] 178 - values: [v15, v15] 179 - values: [v16, v16] 180 - values: [v127, v127] 181 - values: [v128, v128] 182 - values: [v255, v255] 183 - values: [v256, v256] 184 runner-options: [compile-failure] 185 description: Check sta.obj with incorrect register numbers. 186 187 - file-name: "op_v8_null" 188 description: Check sta.obj with various register numbers. 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 check-type: none 205 cases: 206 - values: [v0, v0] 207 - values: [v7, v7] 208 - values: [v8, v8] 209 - values: [v15, v15] 210 - values: [v16, v16] 211 - values: [v127, v127] 212 - values: [v128, v128] 213 - values: [v255, v255] 214 - values: [v256, v256] 215 runner-options: [compile-failure] 216 description: Check sta.obj with incorrect register numbers. 217 218 - file-name: 'type' 219 description: Check 'sta.obj' with incorrect accumulator type. Register type is not checked. 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-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 template-cases: 242 - values: 243 - ldai 0 244 - values: 245 - fldai 0 246 - values: 247 - ldai.64 0 248 - values: 249 - fldai.64 0 250 cases: 251 - values: 252 - movi v1, 0 253 - values: 254 - fmovi v1, 0 255 - values: 256 - movi.64 v1, 0 257 - values: 258 - fmovi.64 v1, 0 259 - values: 260 - | 261 # 262 lda.type A 263 sta.obj v1 264 - values: 265 - | 266 # 267 lda.type A[] 268 sta.obj v1 269 270 - values: 271 - | 272 # 273 lda.type panda.String 274 sta.obj v1 275 - values: 276 - | 277 # 278 lda.str "string" 279 sta.obj v1 280 - values: 281 - | 282 # 283 movi v1, 10 284 newarr v1, v1, f64[] 285 - values: 286 - mov.null v1 287 288 - file-name: uninitialized_acc 289 description: Check 'sta.obj' with uninitialized accumulator. Destination register is not checked. 290 isa: 291 verification: 292 - acc_type 293 tags: ['verifier'] 294 runner-options: ['verifier-failure', 'verifier-config'] 295 header-template: [] 296 code-template: | 297 # 298 .function i32 main() { 299 %s 300 sta.obj %s 301 check-type: exit-positive 302 cases: 303 - values: 304 - '' 305 - v0 306 - values: 307 - movi v0, 0 308 - v0 309 - values: 310 - '' 311 - v15 312 - values: 313 - 'movi.64 v15, 0' 314 - v15 315 - values: 316 - '' 317 - v128 318 - values: 319 - 'fmovi.64 v128, 0' 320 - v128 321 - values: 322 - '' 323 - v255 324 - values: 325 - 'mov.null v255' 326 - v255 327 328 - file-name: "err" 329 description: Check sta.obj with incorrect value. 330 isa: 331 instructions: 332 - sig: sta.obj v:out:ref 333 acc: in:ref 334 format: [op_v_8] 335 runner-options: [compile-failure] 336 code-template: | 337 # Check sta.obj with wrong arguments 338 %s 339 check-type: exit-positive 340 cases: 341 - values: 342 - sta.obj 1 343 - values: 344 - sta.obj 1.1 345 - values: 346 - sta.obj a0 347 - values: 348 - sta.obj "" 349