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: fcmpg 17 isa: 18 title: Floating-point comparison 19 description: Perform specified floating point comparison between register and accumulator. 20 exceptions: 21 - x_none 22 commands: 23 - file-name: zero 24 isa: 25 instructions: 26 - sig: fcmpg v:in:f32 27 acc: inout:f32->i32 28 prefix: f32 29 format: [pref_op_v_8] 30 description: Check fcmpg compares zero with other zero values. 31 tags: ['irtoc_ignore'] 32 code-template: | 33 # 34 fldai %s 35 fmovi v0, %s 36 fcmpg v0 37 check-type: check-positive 38 cases: 39 - values: 40 - '0.0' 41 - '0.0' 42 - values: 43 - '-0.0' 44 - '-0.0' 45 - values: 46 - '-0.0' 47 - '0.0' 48 - values: 49 - '0.0' 50 - '-0.0' 51 52 - file-name: nan 53 isa: 54 instructions: 55 - sig: fcmpg v:in:f32 56 acc: inout:f32->i32 57 prefix: f32 58 format: [pref_op_v_8] 59 description: Check fcmpg compares NaN values. 60 tags: ['irtoc_ignore'] 61 code-template: | 62 # test - check binary representation and comparison of FP literals - NaN 63 fldai 0x7fc00000 64 fmovi v0, %s 65 fcmpg v0 66 check-type: check-acc-1 67 cases: 68 - values: 69 - '0x7fc00000' 70 - values: 71 - '0x7fc00001' 72 - values: 73 - '0x7fc00010' 74 - values: 75 - '0x7fffffff' 76 - values: 77 - '0xffffffff' 78 - values: 79 - '0x7ff81234' 80 - values: 81 # +Inf 82 - '0x7f800000' 83 description: Check fcmpg compares NaN with +Inf 84 - values: 85 # -Inf 86 - '0xff800000' 87 description: Check fcmpg compares NaN with -Inf 88 89 - file-name: nan_numbers_1 90 isa: 91 instructions: 92 - sig: fcmpg v:in:f32 93 acc: inout:f32->i32 94 prefix: f32 95 format: [pref_op_v_8] 96 description: Check fcmpg compares NaN with various values. 97 tags: ['irtoc_ignore'] 98 code-template: | 99 # test - check comparison of NaN with values 100 fldai 0x7fc00000 # One of valid NaN values 101 fmovi v0, %s 102 fcmpg v0 103 check-type: check-acc-1 104 cases: 105 - values: 106 - '4e300' 107 - values: 108 - '0.0' 109 - values: 110 - '-1.0e20' 111 112 - file-name: numbers_2 113 isa: 114 instructions: 115 - sig: fcmpg v:in:f32 116 acc: inout:f32->i32 117 prefix: f32 118 format: [pref_op_v_8] 119 code-template: | 120 # test - check comparison of values 121 fldai %s 122 fmovi v0, %s 123 movi v1, %s 124 fcmpg v0 125 jne v1, set_failure 126 ldai 0 127 return 128 set_failure: 129 ldai 1 130 return 131 check-type: none 132 description: Check fcmpg compares various values. 133 tags: ['tsan', 'irtoc_ignore'] 134 cases: 135 - values: 136 - '1.0' 137 - '0.0' 138 - '1' 139 - values: 140 - '12345679' 141 - '12345678' 142 - '1' 143 - values: 144 - '12345678' 145 - '-12345678' 146 - '1' 147 - values: 148 - '-1.0' 149 - '0.0' 150 - '-1' 151 - values: 152 - '-12345678' 153 - '0.0' 154 - '-1' 155 - values: 156 - '-12345678' 157 - '12345678' 158 - '-1' 159 - values: 160 - '-12345678' 161 - '12345678' 162 - '-1' 163 164 - file-name: pinf 165 isa: 166 instructions: 167 - sig: fcmpg v:in:f32 168 acc: inout:f32->i32 169 prefix: f32 170 format: [pref_op_v_8] 171 description: Check fcmpg compares positive Inf with various values. 172 tags: ['irtoc_ignore'] 173 code-template: | 174 # test - check comparison of values 175 # +Inf 176 fldai 0x7f800000 177 fmovi v0, %s 178 fcmpg v0 179 check-type: check-acc-1 180 cases: 181 - values: 182 - '1.0' 183 - values: 184 - '12345678' 185 - values: 186 - '-12345678' 187 - values: 188 - '-1.0' 189 - values: 190 - '4e30' 191 - values: 192 - '-4e30' 193 194 - file-name: ninf 195 isa: 196 instructions: 197 - sig: fcmpg v:in:f32 198 acc: inout:f32->i32 199 prefix: f32 200 format: [pref_op_v_8] 201 description: Check fcmpg compares negative Inf with various values. 202 tags: ['irtoc_ignore'] 203 code-template: | 204 # test - check comparison of values 205 # -Inf 206 fldai 0xff800000 207 fmovi v0, %s 208 fcmpg v0 209 check-type: check-acc-minus-1 210 cases: 211 - values: 212 - '1.0' 213 - values: 214 - '12345678' 215 - values: 216 - '-12345678' 217 - values: 218 - '-1.0' 219 - values: 220 - '4e30' 221 - values: 222 - '-4e30' 223 224 - file-name: inf 225 isa: 226 instructions: 227 - sig: fcmpg v:in:f32 228 acc: inout:f32->i32 229 prefix: f32 230 format: [pref_op_v_8] 231 tags: ['irtoc_ignore'] 232 code-template: | 233 # test - check comparison of values 234 fldai %s 235 # +Inf 236 fmovi v0, %s 237 movi v1, %s 238 fcmpg v0 239 jne v1, set_failure 240 ldai 0 241 return 242 set_failure: 243 ldai 1 244 return 245 check-type: none 246 cases: 247 - values: 248 # -Inf 249 - '0xff800000' 250 - '0x7f800000' 251 - '-1' 252 - values: 253 - '0x7f800000' 254 # -Inf 255 - '0xff800000' 256 - '+1' 257 258 - file-name: incorrect_register 259 isa: 260 instructions: 261 - sig: fcmpg v:in:f32 262 acc: inout:f32->i32 263 prefix: f32 264 format: [pref_op_v_8] 265 runner-options: [compile-failure] 266 description: Check fcmpg with incorrect register numbers. 267 code-template: | 268 # 269 fcmpg %s 270 check-type: exit-positive 271 cases: 272 - values: [v256] 273 - values: [a0] 274 - values: [0] 275 - values: ['1.1'] 276 - values: [1.1] 277 278 - file-name: applicable_register 279 isa: 280 instructions: 281 - sig: fcmpg v:in:f32 282 acc: inout:f32->i32 283 prefix: f32 284 format: [pref_op_v_8] 285 runner-options: [compile-only] 286 description: Check fcmpg with correct register numbers. 287 code-template: | 288 # 289 fldai 0.0 290 %s 291 check-type: exit-positive 292 cases: 293 - values: 294 - '#{[*0..255].map do |i| " fmovi v#{i}, 0\n fcmpg v#{i}\n" end .join}' 295 296 - file-name: type 297 isa: 298 instructions: 299 - sig: fcmpg v:in:f32 300 acc: inout:f32->i32 301 prefix: f32 302 format: [pref_op_v_8] 303 verification: 304 - v1_type 305 - acc_type 306 tags: ['verifier'] 307 runner-options: ['verifier-failure', 'verifier-config'] 308 header-template: [] 309 code-template: | 310 # 311 .record A {} 312 .record B {} 313 .record panda.String <external> 314 .record panda.Object <external> 315 .function i32 main() { 316 %s 317 *s 318 fcmpg v0 319 check-type: exit-positive 320 description: Check 'fcmpg' with incorrect register type. 321 template-cases: 322 - values: 323 - movi v0, 0 324 - values: 325 - fmovi v0, 0 326 exclude: [val] 327 - values: 328 - movi.64 v0, 0 329 - values: 330 - fmovi.64 v0, 0 331 - values: 332 - | 333 # 334 lda.type B 335 sta.obj v0 336 - values: 337 - | 338 # 339 lda.type B[] 340 sta.obj v0 341 - values: 342 - | 343 # 344 lda.type panda.String 345 sta.obj v0 346 - values: 347 - | 348 # 349 lda.str "string" 350 sta.obj v0 351 - values: 352 - | 353 # 354 movi v0, 10 355 newarr v0, v0, i32[] 356 - values: 357 - mov.null v0 358 359 cases: 360 - values: 361 - ldai 0 362 - values: 363 - ldai.64 0 364 - values: 365 - fldai 0 366 id: val 367 - values: 368 - fldai.64 0 369 - values: 370 - | 371 # 372 lda.type A 373 - values: 374 - | 375 # 376 lda.type A[] 377 - values: 378 - | 379 # 380 lda.type panda.String 381 - values: 382 - | 383 # 384 lda.str "string" 385 - values: 386 - | 387 # 388 movi v1, 10 389 newarr v1, v1, f64[] 390 lda.obj v1 391 - values: 392 - lda.null 393 394 - file-name: uninitialized_regs 395 isa: 396 instructions: 397 - sig: fcmpg v:in:f32 398 acc: inout:f32->i32 399 prefix: f32 400 format: [pref_op_v_8] 401 description: Check 'fcmpg' with uninitialized registers. 402 tags: ['verifier'] 403 runner-options: ['verifier-failure', 'verifier-config'] 404 header-template: [] 405 code-template: | 406 # 407 .function i32 main() { 408 %s 409 *s 410 fcmpg %s 411 check-type: exit-positive 412 template-cases: 413 - values: 414 - '' 415 - v0 416 - values: 417 - fmovi v0, 0 418 - v0 419 exclude: [init] 420 - values: 421 - '' 422 - v7 423 - values: 424 - '' 425 - v15 426 - values: 427 - 'fmovi v15, 0' 428 - v15 429 exclude: [init] 430 - values: 431 - '' 432 - v128 433 - values: 434 - 'fmovi v128, 0' 435 - v128 436 exclude: [init] 437 - values: 438 - '' 439 - v255 440 - values: 441 - 'fmovi v255, 0' 442 - v255 443 exclude: [init] 444 cases: 445 - values: 446 - '' 447 - values: 448 - fldai 0 449 id: init 450