[git commit master] i386/bits/syscalls.h: generate better code using more restrictive asm constraints
Denys Vlasenko
vda.linux at googlemail.com
Tue Apr 6 03:29:26 UTC 2010
commit: http://git.uclibc.org/uClibc/commit/?id=d82f29cd593e371acb3a6f11656543cf2e6e2421
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master
Example: time() doesn't push/pop two registers now, and is smaller:
<__GI_time>:
-57 push %edi
-8b 7c 24 08 mov 0x8(%esp),%edi
-53 push %ebx
-89 fb mov %edi,%ebx
+8b 4c 24 04 mov 0x4(%esp),%ecx
+87 cb xchg %ecx,%ebx
b8 0d 00 00 00 mov $0xd,%eax
cd 80 int $0x80
-5b pop %ebx
-5f pop %edi
+87 cb xchg %ecx,%ebx
c3 ret
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
libc/sysdeps/linux/i386/bits/syscalls.h | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/libc/sysdeps/linux/i386/bits/syscalls.h b/libc/sysdeps/linux/i386/bits/syscalls.h
index 46c2d99..a6e26d7 100644
--- a/libc/sysdeps/linux/i386/bits/syscalls.h
+++ b/libc/sysdeps/linux/i386/bits/syscalls.h
@@ -141,14 +141,21 @@ __asm__ (
#define RESTOREARGS_6 "pop %%ebp\n\t" RESTOREARGS_1
#define ASMFMT_0()
+/* "acdSD" constraint would work too, but "SD" would use esi/edi and cause
+ * them to be pushed/popped by compiler, "a" would use eax and cause ebx
+ * to be saved/restored on stack, not in register. Narrowing choice down
+ * to "ecx or edx" results in smaller and faster code: */
#define ASMFMT_1(arg1) \
- , "acdSD" (arg1)
+ , "cd" (arg1)
+/* Can use "adSD" constraint here: */
#define ASMFMT_2(arg1, arg2) \
- , "adSD" (arg1), "c" (arg2)
+ , "d" (arg1), "c" (arg2)
+/* Can use "aSD" constraint here: */
#define ASMFMT_3(arg1, arg2, arg3) \
- , "aSD" (arg1), "c" (arg2), "d" (arg3)
+ , "a" (arg1), "c" (arg2), "d" (arg3)
+/* Can use "aD" constraint here: */
#define ASMFMT_4(arg1, arg2, arg3, arg4) \
- , "aD" (arg1), "c" (arg2), "d" (arg3), "S" (arg4)
+ , "a" (arg1), "c" (arg2), "d" (arg3), "S" (arg4)
#define ASMFMT_5(arg1, arg2, arg3, arg4, arg5) \
, "a" (arg1), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5)
#define ASMFMT_6(arg1, arg2, arg3, arg4, arg5, arg6) \
--
1.6.3.3
More information about the uClibc-cvs
mailing list