MSVC: Try to fix inline assembly for MSVC
This is untested and will probably crash :)
This commit is contained in:
@@ -1236,10 +1236,17 @@ void codegen_init()
|
|||||||
block_pos = (block_pos + 15) & ~15;
|
block_pos = (block_pos + 15) & ~15;
|
||||||
mem_check_write_l = (uint32_t)gen_MEM_CHECK_WRITE_L();
|
mem_check_write_l = (uint32_t)gen_MEM_CHECK_WRITE_L();
|
||||||
|
|
||||||
|
#ifndef _MSC_VER
|
||||||
asm(
|
asm(
|
||||||
"fstcw %0\n"
|
"fstcw %0\n"
|
||||||
: "=m" (cpu_state.old_npxc)
|
: "=m" (cpu_state.old_npxc)
|
||||||
);
|
);
|
||||||
|
#else
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
fstcw cpu_state.old_npxc
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void codegen_reset()
|
void codegen_reset()
|
||||||
|
|||||||
@@ -38,6 +38,9 @@
|
|||||||
*/
|
*/
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <fenv.h>
|
#include <fenv.h>
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <intrin.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define fplog 0
|
#define fplog 0
|
||||||
|
|
||||||
@@ -270,7 +273,7 @@ static __inline uint16_t x87_compare(double a, double b)
|
|||||||
if (((a == INFINITY) || (a == -INFINITY)) && ((b == INFINITY) || (b == -INFINITY)))
|
if (((a == INFINITY) || (a == -INFINITY)) && ((b == INFINITY) || (b == -INFINITY)))
|
||||||
{
|
{
|
||||||
/* pclog("Comparing infinity\n"); */
|
/* pclog("Comparing infinity\n"); */
|
||||||
|
#ifndef _MSC_VER
|
||||||
__asm volatile ("" : : : "memory");
|
__asm volatile ("" : : : "memory");
|
||||||
|
|
||||||
__asm(
|
__asm(
|
||||||
@@ -282,11 +285,23 @@ static __inline uint16_t x87_compare(double a, double b)
|
|||||||
: "=m" (out)
|
: "=m" (out)
|
||||||
: "m" (a), "m" (a)
|
: "m" (a), "m" (a)
|
||||||
);
|
);
|
||||||
|
#else
|
||||||
|
_ReadWriteBarrier();
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
fld a
|
||||||
|
fld a
|
||||||
|
fclex
|
||||||
|
fcompp
|
||||||
|
fnstsw out
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return out & (C0|C2|C3);
|
return out & (C0|C2|C3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef _MSC_VER
|
||||||
/* Memory barrier, to force GCC to write to the input parameters
|
/* Memory barrier, to force GCC to write to the input parameters
|
||||||
* before the compare rather than after */
|
* before the compare rather than after */
|
||||||
__asm volatile ("" : : : "memory");
|
__asm volatile ("" : : : "memory");
|
||||||
@@ -300,6 +315,17 @@ static __inline uint16_t x87_compare(double a, double b)
|
|||||||
: "=m" (out)
|
: "=m" (out)
|
||||||
: "m" (a), "m" (b)
|
: "m" (a), "m" (b)
|
||||||
);
|
);
|
||||||
|
#else
|
||||||
|
_ReadWriteBarrier();
|
||||||
|
_asm
|
||||||
|
{
|
||||||
|
fld b
|
||||||
|
fld a
|
||||||
|
fclex
|
||||||
|
fcompp
|
||||||
|
fnstsw out
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return out & (C0|C2|C3);
|
return out & (C0|C2|C3);
|
||||||
#else
|
#else
|
||||||
@@ -337,6 +363,7 @@ static __inline uint16_t x87_ucompare(double a, double b)
|
|||||||
#if defined i386 || defined __i386 || defined __i386__ || defined _X86_ || defined _WIN32
|
#if defined i386 || defined __i386 || defined __i386__ || defined _X86_ || defined _WIN32
|
||||||
uint32_t out;
|
uint32_t out;
|
||||||
|
|
||||||
|
#ifndef _MSC_VER
|
||||||
/* Memory barrier, to force GCC to write to the input parameters
|
/* Memory barrier, to force GCC to write to the input parameters
|
||||||
* before the compare rather than after */
|
* before the compare rather than after */
|
||||||
__asm volatile ("" : : : "memory");
|
__asm volatile ("" : : : "memory");
|
||||||
@@ -350,6 +377,17 @@ static __inline uint16_t x87_ucompare(double a, double b)
|
|||||||
: "=m" (out)
|
: "=m" (out)
|
||||||
: "m" (a), "m" (b)
|
: "m" (a), "m" (b)
|
||||||
);
|
);
|
||||||
|
#else
|
||||||
|
_ReadWriteBarrier();
|
||||||
|
_asm
|
||||||
|
{
|
||||||
|
fld b
|
||||||
|
fld a
|
||||||
|
fclex
|
||||||
|
fcompp
|
||||||
|
fnstsw out
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return out & (C0|C2|C3);
|
return out & (C0|C2|C3);
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user