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