10b57cec5SDimitry Andric//===-- truncdfsf2vfp.S - Implement truncdfsf2vfp -------------------------===// 20b57cec5SDimitry Andric// 30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric// 70b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 90b57cec5SDimitry Andric#include "../assembly.h" 100b57cec5SDimitry Andric 110b57cec5SDimitry Andric// 120b57cec5SDimitry Andric// extern float __truncdfsf2vfp(double a); 130b57cec5SDimitry Andric// 14*349cc55cSDimitry Andric// Converts double precision float to single precision result. 150b57cec5SDimitry Andric// Uses Darwin calling convention where a double precision parameter is 16*349cc55cSDimitry Andric// passed in a R0/R1 pair and a single precision result is returned in R0. 170b57cec5SDimitry Andric// 180b57cec5SDimitry Andric .syntax unified 190b57cec5SDimitry Andric .p2align 2 200b57cec5SDimitry AndricDEFINE_COMPILERRT_FUNCTION(__truncdfsf2vfp) 210b57cec5SDimitry Andric#if defined(COMPILER_RT_ARMHF_TARGET) 220b57cec5SDimitry Andric vcvt.f32.f64 s0, d0 230b57cec5SDimitry Andric#else 240b57cec5SDimitry Andric vmov d7, r0, r1 // load double from r0/r1 pair 250b57cec5SDimitry Andric vcvt.f32.f64 s15, d7 // convert double to single (trucate precision) 260b57cec5SDimitry Andric vmov r0, s15 // return result in r0 270b57cec5SDimitry Andric#endif 280b57cec5SDimitry Andric bx lr 290b57cec5SDimitry AndricEND_COMPILERRT_FUNCTION(__truncdfsf2vfp) 300b57cec5SDimitry Andric 310b57cec5SDimitry AndricNO_EXEC_STACK_DIRECTIVE 320b57cec5SDimitry Andric 33