1276789Sdim//===-- fixdfsivfp.S - Implement fixdfsivfp -----------------------===//
2276789Sdim//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6276789Sdim//
7276789Sdim//===----------------------------------------------------------------------===//
8276789Sdim
9276789Sdim#include "../assembly.h"
10276789Sdim
11276789Sdim//
12276789Sdim// extern int __fixdfsivfp(double a);
13276789Sdim//
14276789Sdim// Converts double precision float to a 32-bit int rounding towards zero.
15353358Sdim// Uses Darwin calling convention where a double precision parameter is
16276789Sdim// passed in GPR register pair.
17276789Sdim//
18276789Sdim	.syntax unified
19276789Sdim	.p2align 2
20276789SdimDEFINE_COMPILERRT_FUNCTION(__fixdfsivfp)
21314564Sdim#if defined(COMPILER_RT_ARMHF_TARGET)
22314564Sdim	vcvt.s32.f64 s0, d0
23314564Sdim	vmov r0, s0
24314564Sdim#else
25276789Sdim	vmov	d7, r0, r1    // load double register from R0/R1
26276789Sdim	vcvt.s32.f64 s15, d7  // convert double to 32-bit int into s15
27276789Sdim	vmov	r0, s15	      // move s15 to result register
28314564Sdim#endif
29276789Sdim	bx	lr
30276789SdimEND_COMPILERRT_FUNCTION(__fixdfsivfp)
31309124Sdim
32309124SdimNO_EXEC_STACK_DIRECTIVE
33309124Sdim
34