From 91bd698eafe5014cd2852d3bb6f5119b73128c6e Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Wed, 11 Mar 2015 21:13:56 +0000 Subject: Refactor float to integer conversion to share the same code. 80bit Intel/PPC long double is excluded due to lacking support for the abstraction. Consistently provide saturation logic. Extend to long double on 128bit IEEE extended platforms. Initial patch with test cases from GuanHong Liu. Reviewed by Steve Canon. Differential Revision: http://reviews.llvm.org/D2804 llvm-svn: 231965 --- compiler-rt/lib/builtins/fixtfti.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 compiler-rt/lib/builtins/fixtfti.c (limited to 'compiler-rt/lib/builtins/fixtfti.c') diff --git a/compiler-rt/lib/builtins/fixtfti.c b/compiler-rt/lib/builtins/fixtfti.c new file mode 100644 index 00000000000..41a56384801 --- /dev/null +++ b/compiler-rt/lib/builtins/fixtfti.c @@ -0,0 +1,23 @@ +/* ===-- fixtfti.c - Implement __fixtfti -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + */ + +#define QUAD_PRECISION +#include "fp_lib.h" + +#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +typedef ti_int fixint_t; +typedef tu_int fixuint_t; +#include "fp_fixuint_impl.inc" + +COMPILER_RT_ABI ti_int +__fixtfti(fp_t a) { + return __fixint(a); +} +#endif -- cgit v1.2.3