1222656Sed// This file is dual licensed under the MIT and the University of Illinois Open
2222656Sed// Source Licenses. See LICENSE.TXT for details.
3214152Sed
4214152Sed#include "../assembly.h"
5214152Sed
6214152Sed// float __floatdisf(di_int a);
7214152Sed
8214152Sed// This routine has some extra memory traffic, loading the 64-bit input via two
9214152Sed// 32-bit loads, then immediately storing it back to the stack via a single 64-bit
10214152Sed// store.  This is to avoid a write-small, read-large stall.
11214152Sed// However, if callers of this routine can be safely assumed to store the argument
12214152Sed// via a 64-bt store, this is unnecessary memory traffic, and should be avoided.
13214152Sed// It can be turned off by defining the TRUST_CALLERS_USE_64_BIT_STORES macro.
14214152Sed
15214152Sed#ifdef __i386__
16214152Sed
17214152Sed.text
18214152Sed.align 4
19214152SedDEFINE_COMPILERRT_FUNCTION(__floatdisf)
20214152Sed#ifndef TRUST_CALLERS_USE_64_BIT_STORES
21214152Sed	movd		4(%esp),	%xmm0
22214152Sed	movd		8(%esp),	%xmm1
23214152Sed	punpckldq	%xmm1,		%xmm0
24214152Sed	movq		%xmm0,		4(%esp)
25214152Sed#endif
26214152Sed	fildll		4(%esp)
27214152Sed	fstps		4(%esp)
28214152Sed	flds		4(%esp)
29214152Sed	ret
30214152Sed
31214152Sed#endif // __i386__
32