Use local labels in the inline asm code to avoid a clash when building with link-time code generation.

[PSEH]
Do not push memory operands with ESP as the base register (can happen when compiling with some GCC options), load arguments into registers.

Fix formatting.

svn path=/trunk/; revision=55628
This commit is contained in:
Dmitry Gorbachev 2012-02-16 07:37:27 +00:00
parent 84d86eb242
commit 426717cc3c
3 changed files with 62 additions and 61 deletions

View file

@ -94,13 +94,14 @@ void _SEH2GlobalUnwind(void * target)
{ {
__asm__ __volatile__ __asm__ __volatile__
( (
"push %%ebp\n" "push %%ebp\n\t"
"push $0\n" "push $0\n\t"
"push $0\n" "push $0\n\t"
"push $Return%=\n" "push $Return%=\n\t"
"push %[target]\n" "push %[target]\n\t"
"call %c[RtlUnwind]\n" "call %c[RtlUnwind]\n"
"Return%=: pop %%ebp\n" : "Return%=:\n\t"
"pop %%ebp" :
: :
[target] "g" (target), [RtlUnwind] "g" (&RtlUnwind) : [target] "g" (target), [RtlUnwind] "g" (&RtlUnwind) :
"eax", "ebx", "ecx", "edx", "esi", "edi", "flags", "memory" "eax", "ebx", "ecx", "edx", "esi", "edi", "flags", "memory"
@ -131,13 +132,13 @@ __SEH_EXCEPT_RET _SEH2Except(_SEH2Frame_t * frame, volatile _SEH2TryLevel_t * tr
__asm__ __volatile__ __asm__ __volatile__
( (
"push %[ep]\n" "push %[ep]\n\t"
"push %[frame]\n" "push %[frame]\n\t"
"call *%[filter]\n" "call *%[filter]\n\t"
"pop %%edx\n" "pop %%edx\n\t"
"pop %%edx\n" : "pop %%edx" :
[ret] "=a" (ret) : [ret] "=a" (ret) :
"c" (context), [filter] "r" (filter), [frame] "g" (frame), [ep] "g" (ep) : "c" (context), [filter] "r" (filter), [frame] "r" (frame), [ep] "r" (ep) :
"edx", "flags", "memory" "edx", "flags", "memory"
); );
@ -158,7 +159,7 @@ void _SEH2Finally(_SEH2Frame_t * frame, volatile _SEH2TryLevel_t * trylevel)
body = _SEHFunctionFromTrampoline((_SEHTrampoline_t *)body); body = _SEHFunctionFromTrampoline((_SEHTrampoline_t *)body);
} }
__asm__ __volatile__("call *%1\n" : : "c" (context), "r" (body) : "eax", "edx", "flags", "memory"); __asm__ __volatile__("call *%1" : : "c" (context), "r" (body) : "eax", "edx", "flags", "memory");
} }
} }

View file

@ -413,24 +413,24 @@ DIB_16BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++) for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++)
{ {
__asm__ __volatile__ ( __asm__ __volatile__ (
" cld\n" "cld\n\t"
" mov %1,%%ebx\n" "mov %1,%%ebx\n\t"
" mov %2,%%edi\n" "mov %2,%%edi\n\t"
" test $0x03, %%edi\n" /* Align to fullword boundary */ "test $0x03, %%edi\n\t" /* Align to fullword boundary */
" jz .FL1\n" "jz 1f\n\t"
" stosw\n" "stosw\n\t"
" dec %%ebx\n" "dec %%ebx\n\t"
" jz .FL2\n" "jz 2f\n"
".FL1:\n" "1:\n\t"
" mov %%ebx,%%ecx\n" /* Setup count of fullwords to fill */ "mov %%ebx,%%ecx\n\t" /* Setup count of fullwords to fill */
" shr $1,%%ecx\n" "shr $1,%%ecx\n\t"
" rep stosl\n" /* The actual fill */ "rep stosl\n\t" /* The actual fill */
" test $0x01, %%ebx\n" /* One left to do at the right side? */ "test $0x01, %%ebx\n\t" /* One left to do at the right side? */
" jz .FL2\n" "jz 2f\n\t"
" stosw\n" "stosw\n"
".FL2:\n" "2:"
: :
: "a" (color), "r" (width), "m" (pos) : "a" (color), "r" (width), "m" (pos)
: "%ecx", "%ebx", "%edi"); : "%ecx", "%ebx", "%edi");
pos =(PULONG)((ULONG_PTR)pos + delta); pos =(PULONG)((ULONG_PTR)pos + delta);
} }

View file

@ -344,37 +344,37 @@ DIB_24BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
* So, taking endianness into account again, we need to fill with these * So, taking endianness into account again, we need to fill with these
* ULONGs: CABC BCAB ABCA */ * ULONGs: CABC BCAB ABCA */
/* This is about 30% faster than the generic C code below */ /* This is about 30% faster than the generic C code below */
__asm__ __volatile__ ( __asm__ __volatile__ (
" movl %1, %%ecx\n" "movl %1, %%ecx\n\t"
" andl $0xffffff, %%ecx\n" /* 0ABC */ "andl $0xffffff, %%ecx\n\t" /* 0ABC */
" movl %%ecx, %%ebx\n" /* Construct BCAB in ebx */ "movl %%ecx, %%ebx\n\t" /* Construct BCAB in ebx */
" shrl $8, %%ebx\n" "shrl $8, %%ebx\n\t"
" movl %%ecx, %%eax\n" "movl %%ecx, %%eax\n\t"
" shll $16, %%eax\n" "shll $16, %%eax\n\t"
" orl %%eax, %%ebx\n" "orl %%eax, %%ebx\n\t"
" movl %%ecx, %%edx\n" /* Construct ABCA in edx */ "movl %%ecx, %%edx\n\t" /* Construct ABCA in edx */
" shll $8, %%edx\n" "shll $8, %%edx\n\t"
" movl %%ecx, %%eax\n" "movl %%ecx, %%eax\n\t"
" shrl $16, %%eax\n" "shrl $16, %%eax\n\t"
" orl %%eax, %%edx\n" "orl %%eax, %%edx\n\t"
" movl %%ecx, %%eax\n" /* Construct CABC in eax */ "movl %%ecx, %%eax\n\t" /* Construct CABC in eax */
" shll $24, %%eax\n" "shll $24, %%eax\n\t"
" orl %%ecx, %%eax\n" "orl %%ecx, %%eax\n\t"
" movl %2, %%ecx\n" /* Load count */ "movl %2, %%ecx\n\t" /* Load count */
" shr $2, %%ecx\n" "shr $2, %%ecx\n\t"
" movl %3, %%edi\n" /* Load dest */ "movl %3, %%edi\n" /* Load dest */
".FL1:\n" "1:\n\t"
" movl %%eax, (%%edi)\n" /* Store 4 pixels, 12 bytes */ "movl %%eax, (%%edi)\n\t" /* Store 4 pixels, 12 bytes */
" movl %%ebx, 4(%%edi)\n" "movl %%ebx, 4(%%edi)\n\t"
" movl %%edx, 8(%%edi)\n" "movl %%edx, 8(%%edi)\n\t"
" addl $12, %%edi\n" "addl $12, %%edi\n\t"
" dec %%ecx\n" "dec %%ecx\n\t"
" jnz .FL1\n" "jnz 1b\n\t"
" movl %%edi, %0\n" "movl %%edi, %0"
: "=m"(addr) : "=m"(addr)
: "m"(color), "m"(Count), "m"(addr) : "m"(color), "m"(Count), "m"(addr)
: "%eax", "%ebx", "%ecx", "%edx", "%edi"); : "%eax", "%ebx", "%ecx", "%edx", "%edi");
Count = Count & 0x03; Count = Count & 0x03;
while (0 != Count--) while (0 != Count--)
{ {