# Copyright (c) 2021-2024 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. .function i32 main() { # f32toi32 (NaN to 0 check) fldai 0x7FFFFFFF f32toi32 movi v0, 0 jne v0, exit_failure # f64toi64 (NaN to 0 check) fldai.64 0x7FF8000000000000 f64toi64 movi.64 v0, 0 jne v0, exit_failure # f32tou32 (NaN to 0 check) fldai 0x7FFFFFFF f32tou32 movi v0, 0 jne v0, exit_failure # f64tou64 (NaN to 0 check) fldai.64 0x7FF8000000000000 f64tou64 movi.64 v0, 0 jne v0, exit_failure # f32toi64 (NaN to 0 check) fldai 0x7FFFFFFF f32toi64 movi.64 v0, 0 jne v0, exit_failure # f32tou64 (NaN to 0 check) fldai 0x7FFFFFFF movi.64 v0, 0 f32tou64 jne v0, exit_failure # f32toi32 (MAX_INT32 + 1F to MAX_INT32 check) fldai 0x4F000001 f32toi32 movi v0, 2147483647 jne v0, exit_failure # f32toi32 (MIN_INT32 + 1F to MIN_INT32 (0x80000000) check) # (sign bit set to 1 so if we sum float(MIN_INT32) with 1F # we will get result < float(MIN_INT32)) fldai 0xCF000001 f32toi32 movi v0, 0x80000000 jne v0, exit_failure # f32tou32 (MAX_UINT32 + 1F to MAX_UINT32 check) fldai 0x4F800001 f32tou32 movi v0, 4294967295 jne v0, exit_failure # f32tou32 (-1 to 0 check) fldai 0xBF800000 f32tou32 movi v0, 0 jne v0, exit_failure # f32toi64 (MAX_INT64 + 1F to MAX_INT64 check) fldai 0x5F000001 f32toi64 movi.64 v0, 9223372036854775807 jne v0, exit_failure # f32toi64 (MIN_INT64 - 1 to MIN_INT64 (0x8000000000000000) check) # (sign bit set to 1 so if we sum float(MIN_INT64) with 1F # we will get result < float(MIN_INT64)) fldai 0xDF000001 f32toi64 movi.64 v0, 0x8000000000000000 jne v0, exit_failure # f32tou64 (MAX_UINT64 + 1F to MAX_UINT64 check) fldai 0x5F800001 f32tou64 movi.64 v0, 18446744073709551615 jne v0, exit_failure # f32tou64 (-1 to 0 check) fldai 0xBF800000 f32tou64 movi v0, 0 jne v0, exit_failure # f64toi32 (+inf to MAX_INT32 check) fldai.64 0x7FF0000000000000 f64toi32 movi v0, 2147483647 jne v0, exit_failure # f64toi32 (-inf to MIN_INT32 (0x80000000) check) fldai.64 0xFFF0000000000000 f64toi32 movi v0, 0x80000000 jne v0, exit_failure # f64tou32 (+inf to UMAX_INT32 check) fldai.64 0x7FF0000000000000 f64tou32 movi v0, 4294967295 jne v0, exit_failure # f64tou32 (-inf to 0 check) fldai.64 0xFFF0000000000000 f64tou32 movi v0, 0 jne v0, exit_failure # f32toi32 (+inf to MAX_INT32 check) fldai 0x7F800000 f32toi32 movi v0, 2147483647 jne v0, exit_failure # f32toi32 (-inf to MIN_INT32 (0x80000000) check) fldai 0xFF800000 f32toi32 movi v0, 0x80000000 jne v0, exit_failure # f32tou32 (+inf to UMAX_INT32 check) fldai 0x7F800000 f32tou32 movi v0, 4294967295 jne v0, exit_failure # f32tou32 (-inf to 0 check) fldai 0xFF800000 f32tou32 movi v0, 0 jne v0, exit_failure # All tests done ldai 0 return exit_failure: ldai 1 return }