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: [] 15tests: 16 - file-name: "ucmp" 17 isa: 18 title: Integer comparison 19 description: Perform specified signed or unsigned integer comparison between register and accumulator. 20 exceptions: 21 - x_none 22 commands: 23 - file-name: "op_vs_8_eq" 24 isa: 25 instructions: 26 - sig: ucmp v:in:u32 27 acc: inout:u32->i32 28 prefix: unsigned 29 format: [pref_op_v_8] 30 check-type: check-positive 31 code-template: | 32 # test - compare equal values 33 ldai %s 34 movi v0, %s 35 ucmp v0 36 description: Check ucmp with equal values. 37 cases: 38 - values: 39 - "0" 40 - "0x00000000" 41 - values: 42 - "1" 43 - "0x00000001" 44 - values: 45 - "0x7fffffff" 46 - "2147483647" 47 - values: 48 - "0x80000000" 49 - "2147483648" 50 - values: 51 - "0xCAFEBABE" 52 - "3405691582" 53 54 - file-name: "op_vs_8_lt" 55 isa: 56 instructions: 57 - sig: ucmp v:in:u32 58 acc: inout:u32->i32 59 prefix: unsigned 60 format: [pref_op_v_8] 61 check-type: check-positive 62 code-template: | 63 # test - check less than 64 ldai %s 65 movi v0, %s 66 ucmp v0 67 addi 1 68 description: Check ucmp with different values. 69 cases: 70 - values: 71 - "0" 72 - "0x00000001" 73 - values: 74 - "1" 75 - "0x80000000" 76 - values: 77 - "0x7fffffff" 78 - "2147483648" 79 - values: 80 - "0x80000000" 81 - "3147483648" 82 - values: 83 - "0xCAFEBABE" 84 - "3405691583" 85 86 - file-name: "op_vs_8_gt" 87 isa: 88 instructions: 89 - sig: ucmp v:in:u32 90 acc: inout:u32->i32 91 prefix: unsigned 92 format: [pref_op_v_8] 93 check-type: check-positive 94 code-template: | 95 # test - check greater than 96 ldai %s 97 movi v0, %s 98 ucmp v0 99 subi 1 100 description: Check ucmp with different values. 101 tags: ['tsan'] 102 cases: 103 - values: 104 - "0x00000001" 105 - "0" 106 - values: 107 - "0x80000000" 108 - "1" 109 - values: 110 - "2147483648" 111 - "0x7fffffff" 112 - values: 113 - "3147483648" 114 - "0x80000000" 115 - values: 116 - "3405691583" 117 - "0xCAFEBABE" 118 119 - file-name: "op_vs_8_reg256" 120 isa: 121 instructions: 122 - sig: ucmp v:in:u32 123 acc: inout:u32->i32 124 prefix: unsigned 125 format: [pref_op_v_8] 126 check-type: none 127 runner-options: [compile-failure] 128 code-template: | 129 # 130 ucmp v256 131 description: Check ucmp with incorrect register numbers. 132 133 - file-name: "op_vs_8_reg255" 134 isa: 135 instructions: 136 - sig: ucmp v:in:u32 137 acc: inout:u32->i32 138 prefix: unsigned 139 format: [pref_op_v_8] 140 check-type: none 141 runner-options: [compile-only] 142 code-template: | 143 # 144 ucmp v255 145 description: Check ucmp with correct register numbers. 146 147 - file-name: type 148 isa: 149 instructions: 150 - sig: ucmp v:in:u32 151 acc: inout:u32->i32 152 prefix: unsigned 153 format: [pref_op_v_8] 154 verification: 155 - v1_type 156 - acc_type 157 tags: ['verifier'] 158 runner-options: ['verifier-failure', 'verifier-debug-config'] 159 header-template: [] 160 code-template: | 161 # 162 .record A {} 163 .record B {} 164 .record panda.String <external> 165 .record panda.Object <external> 166 .function i32 main() { 167 %s 168 *s 169 ucmp v0 170 check-type: exit-positive 171 description: Check 'ucmp' with incorrect register type. 172 template-cases: 173 - values: 174 - movi v0, 0 175 exclude: [val] 176 - values: 177 - movi.64 v0, 0 178 - values: 179 - fmovi.64 v0, 0 180 - values: 181 - | 182 # 183 lda.type B 184 sta.obj v0 185 - values: 186 - | 187 # 188 lda.type B[] 189 sta.obj v0 190 - values: 191 - | 192 # 193 lda.type panda.String 194 sta.obj v0 195 - values: 196 - | 197 # 198 lda.str "string" 199 sta.obj v0 200 - values: 201 - | 202 # 203 movi v0, 10 204 newarr v0, v0, i32[] 205 - values: 206 - mov.null v0 207 208 cases: 209 - values: 210 - ldai 0 211 id: val 212 - values: 213 - ldai.64 0 214 - values: 215 - fldai.64 0 216 - values: 217 - | 218 # 219 lda.type A 220 - values: 221 - | 222 # 223 lda.type A[] 224 - values: 225 - | 226 # 227 lda.type panda.String 228 - values: 229 - | 230 # 231 lda.str "string" 232 - values: 233 - | 234 # 235 movi v1, 10 236 newarr v1, v1, f64[] 237 lda.obj v1 238 239 - values: 240 - lda.null 241 242 - file-name: uninitialized_regs 243 isa: 244 instructions: 245 - sig: ucmp v:in:u32 246 acc: inout:u32->i32 247 prefix: unsigned 248 format: [pref_op_v_8] 249 description: Check 'ucmp' with uninitialized registers. 250 tags: ['verifier'] 251 runner-options: ['verifier-failure', 'verifier-debug-config'] 252 header-template: [] 253 code-template: | 254 # 255 .function i32 main() { 256 %s 257 *s 258 ucmp %s 259 check-type: exit-positive 260 template-cases: 261 - values: 262 - '' 263 - v0 264 - values: 265 - movi v0, 0 266 - v0 267 exclude: [init] 268 - values: 269 - '' 270 - v7 271 - values: 272 - '' 273 - v15 274 - values: 275 - 'movi v15, 0' 276 - v15 277 exclude: [init] 278 - values: 279 - '' 280 - v128 281 - values: 282 - 'movi v128, 0' 283 - v128 284 exclude: [init] 285 - values: 286 - '' 287 - v255 288 - values: 289 - 'movi v255, 0' 290 - v255 291 exclude: [init] 292 cases: 293 - values: 294 - '' 295 - values: 296 - ldai 0 297 id: init 298