# Copyright (c) 2021-2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. definitions: [] tests: - file-name: "f32toi32" isa: title: Conversions between integer and floating point types description: > Perform specified primitive type conversion of accumulator. exceptions: - x_none commands: - file-name: "op_none_vals" isa: instructions: - sig: f32toi32 acc: inout:f32->i32 prefix: cast format: [pref_op_none] code-template: | # fldai %s f32toi32 movi v0, %s jne v0, set_failure ldai 0 jmp fall_through set_failure: ldai 1 fall_through: description: Check f32toi32 with various values. cases: - values: - "0.0" - "0" - values: - "1.0" - "1" - values: - "2.14748365e9" - "0x7fffffff" - values: - "-0.0" - "0" - values: - "-1.0" - "-1" - values: - "-2.14748365e9" - "0x80000000" - file-name: "op_none_round" isa: instructions: - sig: f32toi32 acc: inout:f32->i32 prefix: cast format: [pref_op_none] description: It is rounding toward zero. code-template: | # fldai %s f32toi32 movi v0, %s jne v0, set_failure ldai 0 jmp fall_through set_failure: ldai 1 fall_through: description: Check f32toi32 rounding with various values. tags: ['tsan'] cases: - values: - "0.1" - "0" - values: - "0.9" - "0" - values: - "0.9999999" - "0" - values: - "1.1" - "1" - values: - "2.147483647e9" - "0x7fffffff" - values: - "-0.1" - "0" - values: - "-0.9" - "0" - values: - "-0.9999999" - "0" - values: - "-1.1" - "-1" - values: - "-2.147483647e9" - "0x80000000" - file-name: "op_none_min" isa: instructions: - sig: f32toi32 acc: inout:f32->i32 prefix: cast format: [pref_op_none] description: If converted integer is less than minimal value for destination type, the result is minimal value for that type. code-template: | # fldai %s f32toi32 movi v0, %s jne v0, set_failure ldai 0 jmp fall_through set_failure: ldai 1 fall_through: description: Check f32toi32 conversion to minimal value. cases: - values: - "-2.147483647e9" - "-2147483648" - values: - "-6e44" - "-2147483648" - file-name: "op_none_max" isa: instructions: - sig: f32toi32 acc: inout:f32->i32 prefix: cast format: [pref_op_none] description: If converted integer is greater than maximum value for destination type, the result is maximum value for that type. code-template: | # fldai %s f32toi32 movi v0, %s jne v0, set_failure ldai 0 jmp fall_through set_failure: ldai 1 fall_through: description: Check f32toi32 conversion to maximal value. cases: - values: - "2.147483647e9" - "2147483647" - values: - "2.147483648e9" - "2147483647" - values: - "6e37" - "2147483647" - file-name: "op_none_pinf" isa: instructions: - sig: f32toi32 acc: inout:f32->i32 prefix: cast format: [pref_op_none] description: If source is positive infinity, the result is maximum value for destination type. description: Check f32toi32 conversion +inf to maximal value. code-template: | # fldai 0x7f800000 # +Inf f32toi32 movi v0, 0x7fffffff jne v0, set_failure ldai 0 jmp fall_through set_failure: ldai 1 fall_through: - file-name: "op_none_ninf" isa: instructions: - sig: f32toi32 acc: inout:f32->i32 prefix: cast format: [pref_op_none] description: If source is negative infinity, the result is minimal value for destination type. description: Check f32toi32 conversion -inf to minimal value. code-template: | # fldai 0xff800000 # -Inf f32toi32 movi v0, 0x80000000 jne v0, set_failure ldai 0 jmp fall_through set_failure: ldai 1 fall_through: - file-name: "op_none_nan" isa: instructions: - sig: f32toi32 acc: inout:f32->i32 prefix: cast format: [pref_op_none] description: If source is NaN, the result is equal to 0. description: Check f32toi32 conversion of NaN to 0. code-template: | # fldai %s f32toi32 movi v0, 0 jne v0, set_failure ldai 0 jmp fall_through set_failure: ldai 1 fall_through: cases: - values: # NaN - "0x7ff80000" - values: # Other NaN representation - "0xFFFFFFFF" - file-name: "type" isa: instructions: - sig: f32toi32 acc: inout:f32->i32 prefix: cast format: [pref_op_none] verification: - acc_type description: | Check f32toi32 with incorrect accumulator type. Load different values (objects, strings, types, 32-bit values) and invokes `f32toi32`. Return 0 to indicate that negative test failed, because this line is unreachable and code will not be executed after verification error. runner-options: ['verifier-failure', 'verifier-config'] bugid: ["964", "1653"] tags: ["verifier"] header-template: [] code-template: | # .record B {} .record panda.String .record panda.Object .function i32 main() { %s f32toi32 check-type: exit-positive cases: - values: - ldai 0 - values: - ldai.64 0 - values: - fldai.64 0 - values: - lda.type B - values: - lda.type B[] - values: - lda.type panda.String - values: - lda.str "string" - values: - lda.type panda.Object - values: - | # movi v0, 10 newarr v0, v0, i32[] lda.obj v0 - values: - lda.null - file-name: uninitialized_regs isa: instructions: - sig: f32toi32 acc: inout:f32->i32 prefix: cast format: [pref_op_none] description: Check 'f32toi32' with uninitialized accumulator. tags: ['verifier'] runner-options: ['verifier-failure', 'verifier-config'] code-template: | # f32toi32 check-type: exit-positive