| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#if 0 |
| 6 |
|
| 7 |
#undef OP_INT_ADD_OVF |
| 8 |
#define OP_INT_ADD_OVF(x,y,r) \ |
| 9 |
asm volatile( \ |
| 10 |
"\n\t" \ |
| 11 |
"addl %2,%0\n\t" \ |
| 12 |
"jno 0f\n\t" \ |
| 13 |
"pusha\n\t" \ |
| 14 |
"call _op_int_overflowed\n\t" \ |
| 15 |
"popa\n\t" \ |
| 16 |
"0:\n\t" \ |
| 17 |
"" \ |
| 18 |
: "=r"(r) /* outputs */ \ |
| 19 |
: "0"(x), "g"(y) /* inputs */ \ |
| 20 |
: "cc", "memory") /* clobber */ |
| 21 |
|
| 22 |
#undef OP_INT_ADD_NONNEG_OVF |
| 23 |
#define OP_INT_ADD_NONNEG_OVF(x,y,r) OP_INT_ADD_OVF(x,y,r) |
| 24 |
|
| 25 |
#undef OP_INT_SUB_OVF |
| 26 |
#define OP_INT_SUB_OVF(x,y,r) \ |
| 27 |
asm volatile( \ |
| 28 |
"\n\t" \ |
| 29 |
"subl %2,%0\n\t" \ |
| 30 |
"jno 0f\n\t" \ |
| 31 |
"pusha\n\t" \ |
| 32 |
"call _op_int_overflowed\n\t" \ |
| 33 |
"popa\n\t" \ |
| 34 |
"0:\n\t" \ |
| 35 |
"" \ |
| 36 |
: "=r"(r) /* outputs */ \ |
| 37 |
: "0"(x), "g"(y) /* inputs */ \ |
| 38 |
: "cc", "memory") /* clobber */ |
| 39 |
|
| 40 |
#undef OP_INT_MUL_OVF |
| 41 |
#define OP_INT_MUL_OVF(x,y,r) \ |
| 42 |
asm volatile( \ |
| 43 |
"\n\t" \ |
| 44 |
"imull %2,%0\n\t" \ |
| 45 |
"jno 0f\n\t" \ |
| 46 |
"pusha\n\t" \ |
| 47 |
"call _op_int_overflowed\n\t" \ |
| 48 |
"popa\n\t" \ |
| 49 |
"0:\n\t" \ |
| 50 |
"" \ |
| 51 |
: "=r"(r) /* outputs */ \ |
| 52 |
: "0"(x), "g"(y) /* inputs */ \ |
| 53 |
: "cc", "memory") /* clobber */ |
| 54 |
|
| 55 |
RPY_EXTERN void op_int_overflowed(void) |
| 56 |
asm ("_op_int_overflowed") |
| 57 |
__attribute__((used)); |
| 58 |
|
| 59 |
#endif |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
#define READ_TIMESTAMP(val) \ |
| 64 |
asm volatile("rdtsc" : "=A" (val)) |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
#define READ_TIMESTAMP_UNIT TIMESTAMP_UNIT_TSC |
| 74 |
|
| 75 |
#ifndef PYPY_CPU_HAS_STANDARD_PRECISION |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
#define _PyPy_SET_53BIT_PRECISION_HEADER \ |
| 83 |
unsigned short old_387controlword, new_387controlword |
| 84 |
#define _PyPy_SET_53BIT_PRECISION_START \ |
| 85 |
do { \ |
| 86 |
old_387controlword = _PyPy_get_387controlword(); \ |
| 87 |
new_387controlword = (old_387controlword & ~0x0f00) | 0x0200; \ |
| 88 |
if (new_387controlword != old_387controlword) \ |
| 89 |
_PyPy_set_387controlword(new_387controlword); \ |
| 90 |
} while (0) |
| 91 |
#define _PyPy_SET_53BIT_PRECISION_END \ |
| 92 |
if (new_387controlword != old_387controlword) \ |
| 93 |
_PyPy_set_387controlword(old_387controlword) |
| 94 |
|
| 95 |
static unsigned short _PyPy_get_387controlword(void) { |
| 96 |
unsigned short cw; |
| 97 |
__asm__ __volatile__ ("fnstcw %0" : "=m" (cw)); |
| 98 |
return cw; |
| 99 |
} |
| 100 |
static void _PyPy_set_387controlword(unsigned short cw) { |
| 101 |
__asm__ __volatile__ ("fldcw %0" : : "m" (cw)); |
| 102 |
} |
| 103 |
#endif |
| 104 |
|
| 105 |
|
| 106 |
#ifdef PYPY_X86_CHECK_SSE2 |
| 107 |
#define PYPY_X86_CHECK_SSE2_DEFINED |
| 108 |
RPY_EXTERN void pypy_x86_check_sse2(void); |
| 109 |
#endif |
| 110 |
|
| 111 |
|
| 112 |
#define RPy_YieldProcessor() asm("pause") |