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: "and" 17 isa: 18 title: Three address binary operation 19 description: Perform specified binary operation on two registers and store result 20 into accumulator 21 exceptions: 22 - x_none 23 commands: 24 - file-name: "op_vs1_4_vs2_4_zero" 25 isa: 26 instructions: 27 - sig: and v1:in:i32, v2:in:i32 28 acc: out:i32 29 prefix: bit 30 format: [pref_op_v1_4_v2_4] 31 code-template: | 32 # 33 movi v0, 0 34 movi v1, %s 35 and v0, v1 36 movi v0, 0 37 jne v0, set_failure 38 ldai 0 39 jmp fall_through 40 set_failure: 41 ldai 1 42 fall_through: 43 description: Check 'and' with zero and various values. 44 tags: ['tsan'] 45 cases: 46 - values: 47 - "0" 48 - values: 49 - "1" 50 - values: 51 - "-1" 52 - values: 53 - "0x7FFFFFFF" 54 - values: 55 - "0x80000000" 56 - values: 57 - "-0x7FFFFFFF" 58 - values: 59 - "-0x80000000" 60 - values: 61 - "0xFFFFFFFF" 62 - values: 63 - "-0xFFFFFFFF" 64 65 - file-name: "op_vs1_4_vs2_4_pone" 66 isa: 67 instructions: 68 - sig: and v1:in:i32, v2:in:i32 69 acc: out:i32 70 prefix: bit 71 format: [pref_op_v1_4_v2_4] 72 code-template: | 73 # 74 movi v0, 1 75 movi v1, %s 76 and v0, v1 77 movi v0, %s 78 jne v0, set_failure 79 ldai 0 80 jmp fall_through 81 set_failure: 82 ldai 1 83 fall_through: 84 description: Check 'and' with +1 and various values. 85 cases: 86 - values: 87 - "0" 88 - "0" 89 - values: 90 - "1" 91 - "1" 92 - values: 93 - "-1" 94 - "1" 95 - values: 96 - "0x7FFFFFFF" 97 - "1" 98 - values: 99 - "0x80000000" 100 - "0" 101 - values: 102 - "-0x7FFFFFFF" 103 - "1" 104 - values: 105 - "-0x80000000" 106 - "0" 107 - values: 108 - "0xFFFFFFFF" 109 - "1" 110 - values: 111 - "-0xFFFFFFFF" 112 - "1" 113 - file-name: "op_vs1_4_vs2_4_none" 114 isa: 115 instructions: 116 - sig: and v1:in:i32, v2:in:i32 117 acc: out:i32 118 prefix: bit 119 format: [pref_op_v1_4_v2_4] 120 code-template: | 121 # 122 movi v0, -1 123 movi v1, %s 124 and v0, v1 125 movi v0, %s 126 jne v0, set_failure 127 ldai 0 128 jmp fall_through 129 set_failure: 130 ldai 1 131 fall_through: 132 description: Check 'and' with -1 and various values. 133 cases: 134 - values: 135 - "0" 136 - "0" 137 - values: 138 - "1" 139 - "1" 140 - values: 141 - "-1" 142 - "-1" 143 - values: 144 - "0x7FFFFFFF" 145 - "0x7FFFFFFF" 146 - values: 147 - "0x80000000" 148 - "0x80000000" 149 - values: 150 - "-0x7FFFFFFF" 151 - "-0x7FFFFFFF" 152 - values: 153 - "-0x80000000" 154 - "-0x80000000" 155 - values: 156 - "0xFFFFFFFF" 157 - "0xFFFFFFFF" 158 - values: 159 - "-0xFFFFFFFF" 160 - "-0xFFFFFFFF" 161 - file-name: "op_vs1_4_vs2_4_pmax" 162 isa: 163 instructions: 164 - sig: and v1:in:i32, v2:in:i32 165 acc: out:i32 166 prefix: bit 167 format: [pref_op_v1_4_v2_4] 168 code-template: | 169 # 170 movi v0, 0x7FFFFFFF 171 movi v1, %s 172 and v0, v1 173 movi v0, %s 174 jne v0, set_failure 175 ldai 0 176 jmp fall_through 177 set_failure: 178 ldai 1 179 fall_through: 180 description: Check 'and' with +max and various values. 181 cases: 182 - values: 183 - "0" 184 - "0" 185 - values: 186 - "1" 187 - "1" 188 - values: 189 - "-1" 190 - "0x7FFFFFFF" 191 - values: 192 - "0x7FFFFFFF" 193 - "0x7FFFFFFF" 194 - values: 195 - "0x80000000" 196 - "0" 197 - values: 198 - "-0x7FFFFFFF" 199 - "1" 200 - values: 201 - "-0x80000000" 202 - "0" 203 - values: 204 - "0xFFFFFFFF" 205 - "0x7FFFFFFF" 206 - values: 207 - "-0xFFFFFFFF" 208 - "1" 209 210 - file-name: "op_vs1_4_vs2_4_nmax" 211 isa: 212 instructions: 213 - sig: and v1:in:i32, v2:in:i32 214 acc: out:i32 215 prefix: bit 216 format: [pref_op_v1_4_v2_4] 217 code-template: | 218 # 219 movi v0, -0x80000000 220 movi v1, %s 221 and v0, v1 222 movi v0, %s 223 jne v0, set_failure 224 ldai 0 225 jmp fall_through 226 set_failure: 227 ldai 1 228 fall_through: 229 description: Check 'and' with -max and various values. 230 cases: 231 - values: 232 - "0" 233 - "0" 234 - values: 235 - "1" 236 - "0" 237 - values: 238 - "-1" 239 - "0x80000000" 240 - values: 241 - "0x7FFFFFFF" 242 - "0" 243 - values: 244 - "0x80000000" 245 - "0x80000000" 246 - values: 247 - "-0x7FFFFFFF" 248 - "0x80000000" 249 - values: 250 - "-0x80000000" 251 - "0x80000000" 252 - values: 253 - "0xFFFFFFFF" 254 - "0x80000000" 255 - values: 256 - "-0xFFFFFFFF" 257 - "0" 258 259 - file-name: "vals" 260 isa: 261 instructions: 262 - sig: and v1:in:i32, v2:in:i32 263 acc: out:i32 264 prefix: bit 265 format: [pref_op_v1_4_v2_4] 266 code-template: | 267 # 268 movi v0, %s 269 movi v1, %s 270 and v0, v1 271 movi v0, %s 272 jne v0, set_failure 273 ldai 0 274 jmp fall_through 275 set_failure: 276 ldai 1 277 fall_through: 278 description: Check 'and' with various values. 279 cases: 280 - values: 281 - "0xA51B315E" 282 - "0x87C8F582" 283 - "0x85083102" 284 - values: 285 - "0x38A75ED8" 286 - "0x7D32F542" 287 - "0x38225440" 288 - values: 289 - "0xBE9510AB" 290 - "0x43500AD6" 291 - "0x2100082" 292 - values: 293 - "0x6B3EBCF0" 294 - "0xDE8EC51C" 295 - "0x4A0E8410" 296 - values: 297 - "0xD0A1860" 298 - "0x5EB6DAA" 299 - "0x50A0820" 300 - values: 301 - "0xD9B646CB" 302 - "0xF6F2454C" 303 - "0xD0B24448" 304 - values: 305 - "0xB3BC65C4" 306 - "0xE8F33B3E" 307 - "0xA0B02104" 308 - values: 309 - "0xD9962D72" 310 - "0xC661F3D4" 311 - "0xC0002150" 312 - values: 313 - "0xC39C6250" 314 - "0x97BB08D2" 315 - "0x83980050" 316 - values: 317 - "0xECFD3116" 318 - "0x59D1C953" 319 - "0x48D10112" 320 321 - file-name: "vals_mod32_1" 322 bugid: ['1324', '2075'] 323 tags: [verifier] 324 runner-options: ['verifier-failure', 'verifier-config'] 325 description: Check 'and' with incorrect type of registers. 326 isa: 327 instructions: 328 - sig: and v1:in:i32, v2:in:i32 329 acc: out:i32 330 prefix: bit 331 format: [pref_op_v1_4_v2_4] 332 code-template: | 333 # 334 movi.64 v0, %s 335 movi.64 v1, %s 336 and v0, v1 337 movi.64 v0, %s 338 cmp.64 v0 339 cases: 340 - values: 341 - "0x17FFFFFFF" 342 - "0x17FFFFFFF" 343 - "0x7FFFFFFF" 344 - values: 345 - "0x77777777FFFFFFFF" 346 - "0x1111111180000000" 347 - "0xFFFFFFFF80000000" 348 - values: 349 - "0x180000000" 350 - "0x180000000" 351 - "0xFFFFFFFF80000000" 352 353 - file-name: "regs" 354 isa: 355 instructions: 356 - sig: and v1:in:i32, v2:in:i32 357 acc: out:i32 358 prefix: bit 359 format: [pref_op_v1_4_v2_4] 360 runner-options: ['compile-only'] 361 code-template: | 362 # 363 and %s, %s 364 check-type: none 365 description: Check 'and' with various register numbers. 366 cases: 367 - values: 368 - v0 369 - v15 370 - values: 371 - v0 372 - v16 373 runner-options: 374 - compile-failure 375 - values: 376 - v15 377 - v0 378 - values: 379 - v16 380 - v0 381 runner-options: 382 - compile-failure 383 384 - file-name: type 385 isa: 386 verification: 387 - v1_type 388 - v2_type 389 tags: ['verifier'] 390 runner-options: ['verifier-failure', 'verifier-config'] 391 header-template: [] 392 code-template: | 393 # 394 .record A {} 395 .record B {} 396 .record panda.String <external> 397 .record panda.Object <external> 398 .function i32 main() { 399 %s 400 *s 401 and v0, v1 402 check-type: exit-positive 403 description: Check 'and' with incorrect register types. 404 template-cases: 405 - values: 406 - movi v0, 0 407 exclude: [val] 408 - values: 409 - movi.64 v0, 0 410 - values: 411 - fmovi v0, 0 412 bugid: ['7315'] 413 - values: 414 - fmovi.64 v0, 0 415 - values: 416 - | 417 # 418 lda.type B 419 sta.obj v0 420 - values: 421 - | 422 # 423 lda.type B[] 424 sta.obj v0 425 - values: 426 - | 427 # 428 lda.type panda.String 429 sta.obj v0 430 - values: 431 - | 432 # 433 lda.type panda.Object 434 sta.obj v0 435 - values: 436 - | 437 # 438 movi v0, 10 439 newarr v0, v0, i32[] 440 - values: 441 - mov.null v0 442 cases: 443 - values: 444 - movi v1, 0 445 id: val 446 - values: 447 - movi.64 v1, 0 448 - values: 449 - fmovi v1, 0 450 bugid: ['7315'] 451 - values: 452 - fmovi.64 v1, 0 453 - values: 454 - | 455 # 456 lda.type A 457 sta.obj v1 458 - values: 459 - | 460 # 461 lda.type A[] 462 sta.obj v1 463 464 - values: 465 - | 466 # 467 lda.type panda.String 468 sta.obj v1 469 - values: 470 - | 471 # 472 lda.type panda.Object 473 sta.obj v1 474 - values: 475 - | 476 # 477 movi v1, 10 478 newarr v1, v1, f64[] 479 - values: 480 - mov.null v1 481 482 - file-name: uninitialized_regs 483 bugid: ['2260'] 484 isa: 485 instructions: 486 - sig: and v1:in:i32, v2:in:i32 487 acc: out:i32 488 prefix: bit 489 format: [pref_op_v1_4_v2_4] 490 description: Check 'and' with uninitialized registers. 491 tags: ['verifier'] 492 runner-options: ['verifier-failure', 'verifier-config'] 493 code-template: | 494 # 495 %s 496 *s 497 and %s, *s 498 check-type: exit-positive 499 template-cases: 500 - values: 501 - '' 502 - v0 503 - values: 504 - movi v0, 0 505 - v0 506 exclude: [init] 507 - values: 508 - '' 509 - v7 510 - values: 511 - '' 512 - v15 513 - values: 514 - 'movi v15, 0' 515 - v15 516 exclude: [init] 517 cases: 518 - values: 519 - '' 520 - v1 521 - values: 522 - movi v1, 0 523 - v1 524 id: init 525 - values: 526 - '' 527 - v8 528 - values: 529 - '' 530 - v14 531