ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/uae_cpu/m68k.h
(Generate patch)

Comparing BasiliskII/src/uae_cpu/m68k.h (file contents):
Revision 1.5 by gbeauche, 2001-07-13T10:13:58Z vs.
Revision 1.7 by gbeauche, 2006-02-06T22:55:44Z

# Line 11 | Line 11
11  
12   #ifdef OPTIMIZED_FLAGS
13  
14 < #if defined(__i386__) && defined(X86_ASSEMBLY)
14 > #if (defined(__i386__) && defined(X86_ASSEMBLY)) || (defined(__x86_64__) && defined(X86_64_ASSEMBLY))
15  
16   #ifndef SAHF_SETO_PROFITABLE
17  
18 + /* PUSH/POP instructions are naturally 64-bit sized on x86-64, thus
19 +   unsigned long hereunder is either 64-bit or 32-bit wide depending
20 +   on the target.  */
21   struct flag_struct {
22 <    uae_u32 cznv;
23 <    uae_u32 x;
22 >    unsigned long cznv;
23 >    unsigned long x;
24   };
25  
26   #define FLAGVAL_Z       0x40
27   #define FLAGVAL_N       0x80
28  
29 < #define SET_ZFLG(y)     (regflags.cznv = (regflags.cznv & ~0x40) | (((y) & 1) << 6))
30 < #define SET_CFLG(y)     (regflags.cznv = (regflags.cznv & ~1) | ((y) & 1))
31 < #define SET_VFLG(y)     (regflags.cznv = (regflags.cznv & ~0x800) | (((y) & 1) << 11))
32 < #define SET_NFLG(y)     (regflags.cznv = (regflags.cznv & ~0x80) | (((y) & 1) << 7))
29 > #define SET_ZFLG(y)     (regflags.cznv = (((uae_u32)regflags.cznv) & ~0x40) | (((y) & 1) << 6))
30 > #define SET_CFLG(y)     (regflags.cznv = (((uae_u32)regflags.cznv) & ~1) | ((y) & 1))
31 > #define SET_VFLG(y)     (regflags.cznv = (((uae_u32)regflags.cznv) & ~0x800) | (((y) & 1) << 11))
32 > #define SET_NFLG(y)     (regflags.cznv = (((uae_u32)regflags.cznv) & ~0x80) | (((y) & 1) << 7))
33   #define SET_XFLG(y)     (regflags.x = (y))
34  
35   #define GET_ZFLG        ((regflags.cznv >> 6) & 1)
# Line 74 | Line 77 | static __inline__ int cctrue(int cc)
77  
78   #define optflag_testl(v) \
79    __asm__ __volatile__ ("andl %1,%1\n\t" \
80 <                        "pushfl\n\t" \
81 <                        "popl %0\n\t" \
80 >                        "pushf\n\t" \
81 >                        "pop %0\n\t" \
82                          : "=r" (regflags.cznv) : "r" (v) : "cc")
83  
84   #define optflag_testw(v) \
85    __asm__ __volatile__ ("andw %w1,%w1\n\t" \
86 <                        "pushfl\n\t" \
87 <                        "popl %0\n\t" \
86 >                        "pushf\n\t" \
87 >                        "pop %0\n\t" \
88                          : "=r" (regflags.cznv) : "r" (v) : "cc")
89  
90   #define optflag_testb(v) \
91    __asm__ __volatile__ ("andb %b1,%b1\n\t" \
92 <                        "pushfl\n\t" \
93 <                        "popl %0\n\t" \
92 >                        "pushf\n\t" \
93 >                        "pop %0\n\t" \
94                          : "=r" (regflags.cznv) : "q" (v) : "cc")
95  
96   #define optflag_addl(v, s, d) do { \
97    __asm__ __volatile__ ("addl %k2,%k1\n\t" \
98 <                        "pushfl\n\t" \
99 <                        "popl %0\n\t" \
98 >                        "pushf\n\t" \
99 >                        "pop %0\n\t" \
100                          : "=r" (regflags.cznv), "=r" (v) : "rmi" (s), "1" (d) : "cc"); \
101      COPY_CARRY; \
102      } while (0)
103  
104   #define optflag_addw(v, s, d) do { \
105    __asm__ __volatile__ ("addw %w2,%w1\n\t" \
106 <                        "pushfl\n\t" \
107 <                        "popl %0\n\t" \
106 >                        "pushf\n\t" \
107 >                        "pop %0\n\t" \
108                          : "=r" (regflags.cznv), "=r" (v) : "rmi" (s), "1" (d) : "cc"); \
109      COPY_CARRY; \
110      } while (0)
111  
112   #define optflag_addb(v, s, d) do { \
113    __asm__ __volatile__ ("addb %b2,%b1\n\t" \
114 <                        "pushfl\n\t" \
115 <                        "popl %0\n\t" \
114 >                        "pushf\n\t" \
115 >                        "pop %0\n\t" \
116                          : "=r" (regflags.cznv), "=q" (v) : "qmi" (s), "1" (d) : "cc"); \
117      COPY_CARRY; \
118      } while (0)
119  
120   #define optflag_subl(v, s, d) do { \
121    __asm__ __volatile__ ("subl %k2,%k1\n\t" \
122 <                        "pushfl\n\t" \
123 <                        "popl %0\n\t" \
122 >                        "pushf\n\t" \
123 >                        "pop %0\n\t" \
124                          : "=r" (regflags.cznv), "=r" (v) : "rmi" (s), "1" (d) : "cc"); \
125      COPY_CARRY; \
126      } while (0)
127  
128   #define optflag_subw(v, s, d) do { \
129    __asm__ __volatile__ ("subw %w2,%w1\n\t" \
130 <                        "pushfl\n\t" \
131 <                        "popl %0\n\t" \
130 >                        "pushf\n\t" \
131 >                        "pop %0\n\t" \
132                          : "=r" (regflags.cznv), "=r" (v) : "rmi" (s), "1" (d) : "cc"); \
133      COPY_CARRY; \
134      } while (0)
135  
136   #define optflag_subb(v, s, d) do { \
137    __asm__ __volatile__ ("subb %b2,%b1\n\t" \
138 <                        "pushfl\n\t" \
139 <                        "popl %0\n\t" \
138 >                        "pushf\n\t" \
139 >                        "pop %0\n\t" \
140                          : "=r" (regflags.cznv), "=q" (v) : "qmi" (s), "1" (d) : "cc"); \
141      COPY_CARRY; \
142      } while (0)
143  
144   #define optflag_cmpl(s, d) \
145    __asm__ __volatile__ ("cmpl %k1,%k2\n\t" \
146 <                        "pushfl\n\t" \
147 <                        "popl %0\n\t" \
146 >                        "pushf\n\t" \
147 >                        "pop %0\n\t" \
148                          : "=r" (regflags.cznv) : "rmi" (s), "r" (d) : "cc")
149  
150   #define optflag_cmpw(s, d) \
151    __asm__ __volatile__ ("cmpw %w1,%w2\n\t" \
152 <                        "pushfl\n\t" \
153 <                        "popl %0\n\t" \
152 >                        "pushf\n\t" \
153 >                        "pop %0\n\t" \
154                          : "=r" (regflags.cznv) : "rmi" (s), "r" (d) : "cc")
155  
156   #define optflag_cmpb(s, d) \
157    __asm__ __volatile__ ("cmpb %b1,%b2\n\t" \
158 <                        "pushfl\n\t" \
159 <                        "popl %0\n\t" \
158 >                        "pushf\n\t" \
159 >                        "pop %0\n\t" \
160                          : "=r" (regflags.cznv) : "qmi" (s), "q" (d) : "cc")
161  
162   #else
# Line 216 | Line 219 | static __inline__ int cctrue(int cc)
219      return 0;
220   }
221  
222 + /* Manually emit LAHF instruction so that 64-bit assemblers can grok it */
223 + #if defined __x86_64__ && defined __GNUC__
224 + #define ASM_LAHF ".byte 0x9f"
225 + #else
226 + #define ASM_LAHF "lahf"
227 + #endif
228 +
229   /* Is there any way to do this without declaring *all* memory clobbered?
230     I.e. any way to tell gcc that some byte-sized value is in %al? */
231   #define optflag_testl(v) \
232    __asm__ __volatile__ ("andl %0,%0\n\t" \
233 <                        "lahf\n\t" \
233 >                        ASM_LAHF "\n\t" \
234                          "seto %%al\n\t" \
235                          "movb %%al,regflags\n\t" \
236                          "movb %%ah,regflags+1\n\t" \
# Line 228 | Line 238 | static __inline__ int cctrue(int cc)
238  
239   #define optflag_testw(v) \
240    __asm__ __volatile__ ("andw %w0,%w0\n\t" \
241 <                        "lahf\n\t" \
241 >                        ASM_LAHF "\n\t" \
242                          "seto %%al\n\t" \
243                          "movb %%al,regflags\n\t" \
244                          "movb %%ah,regflags+1\n\t" \
# Line 236 | Line 246 | static __inline__ int cctrue(int cc)
246  
247   #define optflag_testb(v) \
248    __asm__ __volatile__ ("andb %b0,%b0\n\t" \
249 <                        "lahf\n\t" \
249 >                        ASM_LAHF "\n\t" \
250                          "seto %%al\n\t" \
251                          "movb %%al,regflags\n\t" \
252                          "movb %%ah,regflags+1\n\t" \
# Line 244 | Line 254 | static __inline__ int cctrue(int cc)
254  
255   #define optflag_addl(v, s, d) do { \
256    __asm__ __volatile__ ("addl %k1,%k0\n\t" \
257 <                        "lahf\n\t" \
257 >                        ASM_LAHF "\n\t" \
258                          "seto %%al\n\t" \
259                          "movb %%al,regflags\n\t" \
260                          "movb %%ah,regflags+1\n\t" \
# Line 254 | Line 264 | static __inline__ int cctrue(int cc)
264  
265   #define optflag_addw(v, s, d) do { \
266    __asm__ __volatile__ ("addw %w1,%w0\n\t" \
267 <                        "lahf\n\t" \
267 >                        ASM_LAHF "\n\t" \
268                          "seto %%al\n\t" \
269                          "movb %%al,regflags\n\t" \
270                          "movb %%ah,regflags+1\n\t" \
# Line 264 | Line 274 | static __inline__ int cctrue(int cc)
274  
275   #define optflag_addb(v, s, d) do { \
276    __asm__ __volatile__ ("addb %b1,%b0\n\t" \
277 <                        "lahf\n\t" \
277 >                        ASM_LAHF "\n\t" \
278                          "seto %%al\n\t" \
279                          "movb %%al,regflags\n\t" \
280                          "movb %%ah,regflags+1\n\t" \
# Line 274 | Line 284 | static __inline__ int cctrue(int cc)
284  
285   #define optflag_subl(v, s, d) do { \
286    __asm__ __volatile__ ("subl %k1,%k0\n\t" \
287 <                        "lahf\n\t" \
287 >                        ASM_LAHF "\n\t" \
288                          "seto %%al\n\t" \
289                          "movb %%al,regflags\n\t" \
290                          "movb %%ah,regflags+1\n\t" \
# Line 284 | Line 294 | static __inline__ int cctrue(int cc)
294  
295   #define optflag_subw(v, s, d) do { \
296    __asm__ __volatile__ ("subw %w1,%w0\n\t" \
297 <                        "lahf\n\t" \
297 >                        ASM_LAHF "\n\t" \
298                          "seto %%al\n\t" \
299                          "movb %%al,regflags\n\t" \
300                          "movb %%ah,regflags+1\n\t" \
# Line 294 | Line 304 | static __inline__ int cctrue(int cc)
304  
305   #define optflag_subb(v, s, d) do { \
306     __asm__ __volatile__ ("subb %b1,%b0\n\t" \
307 <                        "lahf\n\t" \
307 >                        ASM_LAHF "\n\t" \
308                          "seto %%al\n\t" \
309                          "movb %%al,regflags\n\t" \
310                          "movb %%ah,regflags+1\n\t" \
# Line 304 | Line 314 | static __inline__ int cctrue(int cc)
314  
315   #define optflag_cmpl(s, d) \
316    __asm__ __volatile__ ("cmpl %k0,%k1\n\t" \
317 <                        "lahf\n\t" \
317 >                        ASM_LAHF "\n\t" \
318                          "seto %%al\n\t" \
319                          "movb %%al,regflags\n\t" \
320                          "movb %%ah,regflags+1\n\t" \
# Line 312 | Line 322 | static __inline__ int cctrue(int cc)
322  
323   #define optflag_cmpw(s, d) \
324    __asm__ __volatile__ ("cmpw %w0,%w1\n\t" \
325 <                        "lahf\n\t" \
325 >                        ASM_LAHF "\n\t" \
326                          "seto %%al\n\t" \
327                          "movb %%al,regflags\n\t" \
328                          "movb %%ah,regflags+1\n\t" \
# Line 320 | Line 330 | static __inline__ int cctrue(int cc)
330  
331   #define optflag_cmpb(s, d) \
332    __asm__ __volatile__ ("cmpb %b0,%b1\n\t" \
333 <                        "lahf\n\t" \
333 >                        ASM_LAHF "\n\t" \
334                          "seto %%al\n\t" \
335                          "movb %%al,regflags\n\t" \
336                          "movb %%ah,regflags+1\n\t" \

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines