mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-21 00:07:36 +08:00
Cygwin: crt: Add "volatile" to all inline assembly snippets under math
On 32 bit x86, clang seems to miss loading input parameters based on asm constraints for inline assembly that uses the x87 floating registers, unless the snippet has got the volatile keyword. Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
0e6690a92c
commit
023ddc4128
@ -10,7 +10,8 @@ long double acosl (long double x)
|
||||
long double res = 0.0L;
|
||||
|
||||
/* acosl = atanl (sqrtl(1 - x^2) / x) */
|
||||
asm ( "fld %%st\n\t"
|
||||
asm volatile (
|
||||
"fld %%st\n\t"
|
||||
"fmul %%st(0)\n\t" /* x^2 */
|
||||
"fld1\n\t"
|
||||
"fsubp\n\t" /* 1 - x^2 */
|
||||
|
@ -16,7 +16,8 @@ long double asinl (long double x)
|
||||
{
|
||||
long double res = 0.0L;
|
||||
|
||||
asm ( "fld %%st\n\t"
|
||||
asm volatile (
|
||||
"fld %%st\n\t"
|
||||
"fmul %%st(0)\n\t" /* x^2 */
|
||||
"fld1\n\t"
|
||||
"fsubp\n\t" /* 1 - x^2 */
|
||||
|
@ -9,6 +9,6 @@ long double
|
||||
atan2l (long double y, long double x)
|
||||
{
|
||||
long double res = 0.0L;
|
||||
asm ("fpatan" : "=t" (res) : "u" (y), "0" (x) : "st(1)");
|
||||
asm volatile ("fpatan" : "=t" (res) : "u" (y), "0" (x) : "st(1)");
|
||||
return res;
|
||||
}
|
||||
|
@ -10,7 +10,8 @@ atanl (long double x)
|
||||
{
|
||||
long double res = 0.0L;
|
||||
|
||||
asm ("fld1\n\t"
|
||||
asm volatile (
|
||||
"fld1\n\t"
|
||||
"fpatan"
|
||||
: "=t" (res) : "0" (x));
|
||||
return res;
|
||||
|
@ -52,7 +52,8 @@ static long double
|
||||
__expl_internal (long double x)
|
||||
{
|
||||
long double res = 0.0L;
|
||||
asm ("fldl2e\n\t" /* 1 log2(e) */
|
||||
asm volatile (
|
||||
"fldl2e\n\t" /* 1 log2(e) */
|
||||
"fmul %%st(1),%%st\n\t" /* 1 x log2(e) */
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
@ -10,7 +10,7 @@ fabsl (long double x)
|
||||
{
|
||||
#if defined(__x86_64__) || defined(_AMD64_) || defined(__i386__) || defined(_X86_)
|
||||
long double res = 0.0L;
|
||||
asm ("fabs;" : "=t" (res) : "0" (x));
|
||||
asm volatile ("fabs;" : "=t" (res) : "0" (x));
|
||||
return res;
|
||||
#elif defined(__arm__) || defined(_ARM_)
|
||||
return __builtin_fabsl (x);
|
||||
|
@ -10,7 +10,8 @@ fmodl (long double x, long double y)
|
||||
{
|
||||
long double res = 0.0L;
|
||||
|
||||
asm ("1:\tfprem\n\t"
|
||||
asm volatile (
|
||||
"1:\tfprem\n\t"
|
||||
"fstsw %%ax\n\t"
|
||||
"sahf\n\t"
|
||||
"jp 1b\n\t"
|
||||
|
@ -16,7 +16,8 @@ logbl (long double x)
|
||||
{
|
||||
long double res = 0.0L;
|
||||
|
||||
asm ("fxtract\n\t"
|
||||
asm volatile (
|
||||
"fxtract\n\t"
|
||||
"fstp %%st" : "=t" (res) : "0" (x));
|
||||
return res;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ modfl (long double value, long double* iptr)
|
||||
long double int_part = 0.0L;
|
||||
/* truncate */
|
||||
#if defined(_AMD64_) || defined(__x86_64__)
|
||||
asm ("subq $8, %%rsp\n"
|
||||
asm volatile ("subq $8, %%rsp\n"
|
||||
"fnstcw 4(%%rsp)\n"
|
||||
"movzwl 4(%%rsp), %%eax\n"
|
||||
"orb $12, %%ah\n"
|
||||
@ -23,7 +23,7 @@ modfl (long double value, long double* iptr)
|
||||
"fldcw 4(%%rsp)\n"
|
||||
"addq $8, %%rsp\n" : "=t" (int_part) : "0" (value) : "eax"); /* round */
|
||||
#elif defined(_X86_) || defined(__i386__)
|
||||
asm ("push %%eax\n\tsubl $8, %%esp\n"
|
||||
asm volatile ("push %%eax\n\tsubl $8, %%esp\n"
|
||||
"fnstcw 4(%%esp)\n"
|
||||
"movzwl 4(%%esp), %%eax\n"
|
||||
"orb $12, %%ah\n"
|
||||
|
@ -82,7 +82,7 @@ internal_modf (__FLT_TYPE value, __FLT_TYPE *iptr)
|
||||
/* truncate */
|
||||
/* truncate */
|
||||
#ifdef __x86_64__
|
||||
asm ("pushq %%rax\n\tsubq $8, %%rsp\n"
|
||||
asm volatile ("pushq %%rax\n\tsubq $8, %%rsp\n"
|
||||
"fnstcw 4(%%rsp)\n"
|
||||
"movzwl 4(%%rsp), %%eax\n"
|
||||
"orb $12, %%ah\n"
|
||||
@ -92,7 +92,7 @@ internal_modf (__FLT_TYPE value, __FLT_TYPE *iptr)
|
||||
"fldcw 4(%%rsp)\n"
|
||||
"addq $8, %%rsp\npopq %%rax" : "=t" (int_part) : "0" (value)); /* round */
|
||||
#else
|
||||
asm ("push %%eax\n\tsubl $8, %%esp\n"
|
||||
asm volatile ("push %%eax\n\tsubl $8, %%esp\n"
|
||||
"fnstcw 4(%%esp)\n"
|
||||
"movzwl 4(%%esp), %%eax\n"
|
||||
"orb $12, %%ah\n"
|
||||
@ -204,7 +204,7 @@ __FLT_ABI(pow) (__FLT_TYPE x, __FLT_TYPE y)
|
||||
}
|
||||
if (y == __FLT_CST(0.5))
|
||||
{
|
||||
asm ("fsqrt" : "=t" (rslt) : "0" (x));
|
||||
asm volatile ("fsqrt" : "=t" (rslt) : "0" (x));
|
||||
return rslt;
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@
|
||||
* asm ("fsqrts %[dst], %[src];\n" : [dst] "=w" (res) : [src] "w" (x));
|
||||
*/
|
||||
__FLT_TYPE __fsqrt_internal( __FLT_TYPE x );
|
||||
asm(".def __fsqrt_internal; .scl 2; .type 32; .endef\n"
|
||||
asm volatile(".def __fsqrt_internal; .scl 2; .type 32; .endef\n"
|
||||
"\t.text\n"
|
||||
"\t.align 4\n"
|
||||
"\t.globl __fsqrt_internal\n"
|
||||
@ -85,7 +85,7 @@ __FLT_ABI (sqrt) (__FLT_TYPE x)
|
||||
#if defined(__arm__) || defined(_ARM_)
|
||||
__fsqrt_internal(x);
|
||||
#elif defined(_X86_) || defined(__i386__) || defined(_AMD64_) || defined(__x86_64__)
|
||||
asm ("fsqrt" : "=t" (res) : "0" (x));
|
||||
asm volatile ("fsqrt" : "=t" (res) : "0" (x));
|
||||
#else
|
||||
#error Not supported on your platform yet
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user