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