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: "lda.obj" 18 isa: 19 title: Load accumulator from register 20 description: Moves register content into an accumulator. 21 exceptions: 22 - x_none 23 commands: 24 - file-name: "op_p" 25 isa: 26 instructions: 27 - sig: lda.obj v:in:ref 28 acc: out:ref 29 format: [op_v_8] 30 code-template: | 31 %s 32 # header 33 .function i32 main() { 34 # Check lda.obj for different type of arguments (empty object, with fields, statics, etc). 35 newobj v0, Object 36 lda.obj v0 37 jne.obj v0, return_ne_num 38 ldai 0 39 return 40 return_ne_num: 41 ldai 1 42 return 43 header-template: [] 44 description: Check lda.obj moves register content into accumulator (references to various type of objects) in PandaAssembly context. 45 cases: 46 - values: 47 - | 48 .record Object { 49 } 50 - values: 51 - | 52 .record Object { 53 i32 fld2 54 } 55 - values: 56 - | 57 .record Object { 58 i64 fld2 59 } 60 - values: 61 - | 62 .record Object { 63 u64 fld2 64 } 65 - values: 66 - | 67 .record Object { 68 i32 fld2 <static> 69 } 70 - values: 71 - | 72 .record Object { 73 i32 fld1 74 i32 fld2 <static> 75 } 76 77 - values: 78 - | 79 .record Object { 80 i64 fld1 81 i64 fld2 <static> 82 } 83 - values: 84 - | 85 .record Object { 86 f64 fld1 87 f64 fld2 <static> 88 } 89 - values: 90 - | 91 .record Object { 92 f32 fld1 93 f32 fld2 <static> 94 f64 fld3 95 f64 fld4 <static> 96 i32 fld5 97 i32 fld6 <static> 98 i64 fld7 99 i64 fld8 <static> 100 } 101 - case-template: | 102 # 103 .function i32 main() { 104 # Check lda.obj for string 105 lda.str "" 106 sta.obj v0 107 lda.obj v0 108 jne.obj v0, return_ne_num 109 ldai 0 110 return 111 return_ne_num: 112 ldai 1 113 return 114 - case-template: | 115 # 116 .record Object {} 117 .function i32 main() { 118 # Check lda.obj for type 119 lda.type Object 120 sta.obj v0 121 lda.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 isa: 131 instructions: 132 - sig: lda.obj v:in:ref 133 acc: out:ref 134 format: [op_v_8] 135 description: Check lda.obj moves register content into accumulator (null reference). 136 code-template: | 137 # header 138 .function i32 main() { 139 # Check lda.obj for null 140 lda.null 141 sta.obj v0 142 lda.obj v0 143 jne.obj v0, return_ne_num 144 ldai 0 145 return 146 return_ne_num: 147 ldai 1 148 return 149 header-template: [] 150 151 - file-name: "op_8" 152 description: Check lda.obj with various register numbers. 153 isa: 154 instructions: 155 - sig: lda.obj v:in:ref 156 acc: out:ref 157 format: [op_v_8] 158 tags: ['tsan'] 159 code-template: | 160 .record Object {} 161 # header 162 .function i32 main() { 163 # Check lda.obj with different registers number 164 newobj v0, Object 165 mov.obj %s, v0 166 lda.obj %s 167 jne.obj v0, return_ne_num 168 ldai 0 169 return 170 return_ne_num: 171 ldai 1 172 return 173 header-template: [] 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 lda.obj with incorrect register number. 186 187 - file-name: "op_8_null" 188 isa: 189 instructions: 190 - sig: lda.obj v:in:ref 191 acc: out:ref 192 format: [op_v_8] 193 description: Check lda.obj with various register numbers and null. 194 code-template: | 195 # 196 lda.null 197 sta.obj v0 198 mov.obj %s, v0 199 lda.obj %s 200 jne.obj v0, return_ne_num 201 ldai 0 202 return 203 return_ne_num: 204 ldai 1 205 return 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 lda.obj with incorrect register number and null. 218 219 - file-name: "op_type" 220 tags: ["verifier"] 221 bugid: ['966', '964'] 222 isa: 223 instructions: 224 - sig: lda.obj v:in:ref 225 acc: out:ref 226 format: [op_v_8] 227 verification: 228 - v1_type 229 code-template: | 230 # Check lda.obj with wrong type 231 %s 232 lda.obj v0 233 jne.obj v0, return_ne_num 234 ldai 0 235 return 236 return_ne_num: 237 ldai 1 238 return 239 runner-options: ['verifier-failure', 'verifier-debug-config'] 240 description: Check lda.obj with incorrect register type (i32, i64, f64). 241 cases: 242 - values: 243 - movi v0, 0 244 - values: 245 - movi v0, 123 246 - values: 247 - movi.64 v0, 0 248 - values: 249 - movi.64 v0, 123 250 - values: 251 - fmovi.64 v0, 0 252 - values: 253 - fmovi.64 v0, 123 254 255 - file-name: "err" 256 isa: 257 instructions: 258 - sig: lda.obj v:in:ref 259 acc: out:ref 260 format: [op_v_8] 261 code-template: | 262 # Check lda.obj with wrong arguments 263 %s 264 check-type: none 265 runner-options: [compile-failure] 266 description: Check lda.obj with incorrect values. 267 cases: 268 - values: 269 - lda.obj 1 270 - values: 271 - lda.obj 1.1 272 - values: 273 - lda.obj a0 274 - values: 275 - lda.obj "" 276 277 - file-name: "type_p" 278 isa: 279 instructions: 280 - sig: lda.obj v:in:ref 281 acc: out:ref 282 format: [op_v_8] 283 verification: 284 - v1_type 285 description: Check lda.obj with incorrect source register type in PandaAssembly context. Accumulator type is not checked. 286 runner-options: ['verifier-failure', 'verifier-debug-config'] 287 tags: ["verifier"] 288 header-template: [] 289 code-template: | 290 # 291 .record B {} 292 .record panda.String <external> 293 .record panda.Object <external> 294 .function i32 main() { 295 %s 296 *s 297 lda.obj v1 298 ldai 0 299 check-type: no-check 300 template-cases: 301 - values: 302 - | 303 # 304 lda.type B 305 - values: 306 - | 307 # 308 lda.type B[] 309 - values: 310 - | 311 # 312 lda.type panda.String 313 - values: 314 - | 315 # 316 lda.str "string" 317 - values: 318 - | 319 # 320 lda.type panda.Object 321 - values: 322 - | 323 # 324 movi v0, 10 325 newarr v0, v0, i32[] 326 lda.obj v0 327 - values: 328 - lda.null 329 - values: 330 - ldai 0 331 - values: 332 - ldai.64 0 333 - values: 334 - fldai.64 0 335 cases: 336 337 - values: 338 - movi v1, 0 339 - values: 340 - movi.64 v1, 0 341 - values: 342 - fmovi.64 v1, 0 343 344 - file-name: uninitialized_regs 345 isa: 346 instructions: 347 - sig: lda.obj v:in:ref 348 acc: out:ref 349 format: [op_v_8] 350 description: Check lda.obj with uninitialized registers. 351 tags: ['verifier'] 352 runner-options: ['verifier-failure', 'verifier-debug-config'] 353 header-template: [] 354 code-template: | 355 # 356 .function i32 main() { 357 lda.obj %s 358 ldai 0 359 check-type: no-check 360 cases: 361 - values: 362 - v0 363 - values: 364 - v8 365 - values: 366 - v15 367 - values: 368 - v255 369 370