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: "f64toi64" 17 isa: 18 title: Conversions between integer and floating point types 19 description: > 20 Perform specified primitive type conversion of accumulator. 21 exceptions: 22 - x_none 23 commands: 24 - file-name: "op_none_vals" 25 isa: 26 instructions: 27 - sig: f64toi64 28 acc: inout:f64->i64 29 prefix: cast 30 format: [pref_op_none] 31 code-template: | 32 # 33 fldai.64 %s 34 f64toi64 35 movi.64 v0, %s 36 cmp.64 v0 37 description: Check f64toi64 with various values. 38 tags: ['tsan'] 39 cases: 40 - values: 41 - "0.0" 42 - "0" 43 - values: 44 - "1.0" 45 - "1" 46 - values: 47 - "2.147483647e9" 48 - "0x7fffffff" 49 - values: 50 - "9.223372036854776e18" 51 - "0x7fffffffffffffff" 52 - values: 53 - "-0.0" 54 - "0" 55 - values: 56 - "-1.0" 57 - "-1" 58 - values: 59 - "-2.147483647e9" 60 - "-2147483647" 61 - values: 62 - "-9.223372036854776e18" 63 # 0x8000000000000000 64 - "-9223372036854775808" 65 - file-name: "op_none_round" 66 isa: 67 instructions: 68 - sig: f64toi64 69 acc: inout:f64->i64 70 prefix: cast 71 format: [pref_op_none] 72 description: It is rounding toward zero. 73 code-template: | 74 # 75 fldai.64 %s 76 f64toi64 77 movi.64 v0, %s 78 cmp.64 v0 79 description: Check f64toi64 rounding with various values. 80 cases: 81 - values: 82 - "0.1" 83 - "0" 84 - values: 85 - "0.9" 86 - "0" 87 - values: 88 - "0.9999999999" 89 - "0" 90 - values: 91 - "1.1" 92 - "1" 93 - values: 94 - "2.14748364699999e9" 95 - "0x7ffffffe" 96 - values: 97 - "2.14748364799999e9" 98 - "0x7fffffff" 99 - values: 100 - "-0.1" 101 - "0" 102 - values: 103 - "-0.9" 104 - "0" 105 - values: 106 - "-0.9999999999" 107 - "0" 108 - values: 109 - "-1.1" 110 - "-1" 111 - values: 112 - "-2.14748364699999e9" 113 - "-2147483646" 114 - values: 115 - "-2.14748364799999e9" 116 - "-2147483647" 117 118 - file-name: "op_none_min" 119 isa: 120 instructions: 121 - sig: f64toi64 122 acc: inout:f64->i64 123 prefix: cast 124 format: [pref_op_none] 125 description: If converted integer is less than minimal value for destination type, the result is minimal value for that type. 126 code-template: | 127 # 128 fldai.64 %s 129 f64toi64 130 movi.64 v0, %s 131 cmp.64 v0 132 description: Check f64toi64 conversion to minimal value. 133 cases: 134 - values: 135 - "-9.2233720368554776e18" 136 - "0x8000000000000000" 137 - values: 138 - "-9.22337203686e18" 139 - "0x8000000000000000" 140 - values: 141 - "-6e100" 142 - "0x8000000000000000" 143 144 - file-name: "op_none_max" 145 isa: 146 instructions: 147 - sig: f64toi64 148 acc: inout:f64->i64 149 prefix: cast 150 format: [pref_op_none] 151 description: If converted integer is greater than maximum value for destination type, the result is maximum value for that type. 152 code-template: | 153 # 154 fldai.64 %s 155 f64toi64 156 movi.64 v0, %s 157 cmp.64 v0 158 description: Check f64toi64 conversion to maximal value. 159 cases: 160 - values: 161 - "9.223372036854776e18" 162 - "0x7fffffffffffffff" 163 - values: 164 - "9.223372036855e18" 165 - "0x7fffffffffffffff" 166 - values: 167 - "6e100" 168 - "0x7fffffffffffffff" 169 170 - file-name: "op_none_pinf" 171 isa: 172 instructions: 173 - sig: f64toi64 174 acc: inout:f64->i64 175 prefix: cast 176 format: [pref_op_none] 177 description: If source is positive infinity, the result is maximum value for destination type. 178 description: Check f64toi64 conversion +inf to maximal value. 179 code-template: | 180 # 181 fldai.64 0x7ff0000000000000 # +Inf 182 f64toi64 183 movi.64 v0, 0x7fffffffffffffff 184 cmp.64 v0 185 186 - file-name: "op_none_ninf" 187 isa: 188 instructions: 189 - sig: f64toi64 190 acc: inout:f64->i64 191 prefix: cast 192 format: [pref_op_none] 193 description: If source is negative infinity, the result is minimal value for destination type. 194 description: Check f64toi64 conversion -inf to minimal value. 195 code-template: | 196 # 197 fldai.64 0xfff0000000000000 # -Inf 198 f64toi64 199 movi.64 v0, 0x8000000000000000 200 cmp.64 v0 201 202 - file-name: "op_none_nan" 203 isa: 204 instructions: 205 - sig: f64toi64 206 acc: inout:f64->i64 207 prefix: cast 208 format: [pref_op_none] 209 description: If source is NaN, the result is equal to 0. 210 code-template: | 211 # 212 fldai.64 %s 213 f64toi64 214 movi.64 v0, 0 215 cmp.64 v0 216 description: Check f64toi64 conversion of NaN to 0. 217 cases: 218 - values: 219 # NaN 220 - "0x7ff8000000000000" 221 - values: 222 # Other NaN representation 223 - "0xFFFFFFFFFFFFFFFF" 224 225 - file-name: "type" 226 isa: 227 instructions: 228 - sig: f64toi64 229 acc: inout:f64->i64 230 prefix: cast 231 format: [pref_op_none] 232 verification: 233 - acc_type 234 description: | 235 Check `f64toi64` with incorrect accumulator type. 236 Load different values (objects, strings, types, 32-bit values, 64-bit integer values) and invokes `f64toi64`. 237 Return 0 to indicate that negative test failed, because this line is unreachable and code will not be executed after verification error. 238 runner-options: ['verifier-failure', 'verifier-config'] 239 bugid: ["964", "1653"] 240 tags: ["verifier"] 241 header-template: [] 242 code-template: | 243 # 244 .record B {} 245 .record panda.String <external> 246 .record panda.Object <external> 247 .function i32 main() { 248 %s 249 f64toi64 250 check-type: exit-positive 251 cases: 252 - values: 253 - ldai 0 254 - values: 255 - ldai.64 0 256 - values: 257 - fldai 0 258 bugid: ['6094'] 259 - values: 260 - lda.type B 261 - values: 262 - lda.type B[] 263 - values: 264 - lda.type panda.String 265 - values: 266 - lda.str "string" 267 - values: 268 - lda.type panda.Object 269 - values: 270 - | 271 # 272 movi v0, 10 273 newarr v0, v0, i32[] 274 lda.obj v0 275 - values: 276 - lda.null 277 278 - file-name: uninitialized_regs 279 isa: 280 instructions: 281 - sig: f64toi64 282 acc: inout:f64->i64 283 prefix: cast 284 format: [pref_op_none] 285 description: Check 'f64toi64' with uninitialized accumulator. 286 tags: ['verifier'] 287 runner-options: ['verifier-failure', 'verifier-config'] 288 code-template: | 289 # 290 f64toi64 291 check-type: exit-positive 292