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