Debian Codegraph @

rpython/translator/c/src/asm_gcc_x86.h

raw symbols SCIP
1 /* This optional file only works for GCC on an i386.
2 * It replaces some complex macros with native assembler instructions.
3 */
4
5 #if 0 /* --- disabled: does not give any speed-up --- */
6
7 #undef OP_INT_ADD_OVF
8 #define OP_INT_ADD_OVF(x,y,r) \
9 asm volatile( \
10 "/* ignore_in_trackgcroot */\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 "/* end_ignore_in_trackgcroot */" \
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 "/* ignore_in_trackgcroot */\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 "/* end_ignore_in_trackgcroot */" \
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 "/* ignore_in_trackgcroot */\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 "/* end_ignore_in_trackgcroot */" \
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 /* 0 */
60
61
62 /* Pentium only! */
63 #define READ_TIMESTAMP(val) \
64 asm volatile("rdtsc" : "=A" (val))
65 // Kernel has a barrier around rtdsc
66 // mfence
67 // lfence
68 // rtdsc
69 // mfence
70 // lfence
71 // I don't know how important it is, comment talks about time warps
72
73 #define READ_TIMESTAMP_UNIT TIMESTAMP_UNIT_TSC
74
75 #ifndef PYPY_CPU_HAS_STANDARD_PRECISION
76 /* On x86-32, we have to use the following hacks to set and restore
77 * the CPU's precision to 53 bits around calls to dtoa.c. The macro
78 * PYPY_CPU_HAS_STANDARD_PRECISION is defined if we are compiling
79 * with -mss2 -mfpmath=sse anyway, in which case the precision is
80 * already ok.
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 /* !PYPY_CPU_HAS_STANDARD_PRECISION */
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")