diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2007-08-29 01:56:50 +0400 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2007-08-29 01:56:50 +0400 |
commit | d4a278865234a6bd207dc12a0305e30f3b759284 (patch) | |
tree | 24ab1d88d13f69724625bfc1256933739368da33 /newlib/libc/machine/x86_64/memset.S | |
parent | 01cd95204efdc980ec2a0ad6bc58b37e2ac32f76 (diff) |
2007-08-28 Hans Kester <hans.kester@ellips.nl>
* configure.host: Added support for x86_64.
* libc/include/machine/ieeefp.h: Define __IEEE_LITTLE_ENDIAN for x86_64.
* libc/include/machine/setjmp.h: Define _JBTYPE and _JBLEN for x86_64.
* libc/machine/x86_64/aclocal.m4: Generated.
* libc/machine/x86_64/configure.in: New.
* libc/machine/x86_64/configure: Generated.
* libc/machine/x86_64/Makefile.am: New.
* libc/machine/x86_64/Makefile.in: Generated.
* libc/machine/x86_64/setjmp.S: New.
* libc/machine/x86_64/memcpy.S: New.
* libc/machine/x86_64/memset.S: New.
* libc/machine/configure.in: Added support for x86_64.
* libc/machine/configure: Regenerated.
Diffstat (limited to 'newlib/libc/machine/x86_64/memset.S')
-rw-r--r-- | newlib/libc/machine/x86_64/memset.S | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/newlib/libc/machine/x86_64/memset.S b/newlib/libc/machine/x86_64/memset.S new file mode 100644 index 000000000..4ba53e3c8 --- /dev/null +++ b/newlib/libc/machine/x86_64/memset.S @@ -0,0 +1,88 @@ +/* + * ==================================================== + * Copyright (C) 2007 by Ellips BV. All rights reserved. + * + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + #include "x86_64mach.h" + + .global SYM (memset) + SOTYPE_FUNCTION(memset) + +SYM (memset): + movq rdi, r9 /* Save return value */ + movq rsi, rax + movq rdx, rcx + cmpq $16, rdx + jb byte_set + + movq rdi, r8 /* Align on quad word boundary */ + andq $7, r8 + jz quadword_aligned + movq $8, rcx + subq r8, rcx + subq rcx, rdx + rep stosb + movq rdx, rcx + +quadword_aligned: + movabs $0x0101010101010101, r8 + movzbl sil, eax + imul r8, rax + cmpq $256, rdx + jb quadword_set + + shrq $7, rcx /* Store 128 bytes at a time with minimum cache polution */ + + .p2align 4 +loop: + movntiq rax, (rdi) + movntiq rax, 8 (rdi) + movntiq rax, 16 (rdi) + movntiq rax, 24 (rdi) + movntiq rax, 32 (rdi) + movntiq rax, 40 (rdi) + movntiq rax, 48 (rdi) + movntiq rax, 56 (rdi) + movntiq rax, 64 (rdi) + movntiq rax, 72 (rdi) + movntiq rax, 80 (rdi) + movntiq rax, 88 (rdi) + movntiq rax, 96 (rdi) + movntiq rax, 104 (rdi) + movntiq rax, 112 (rdi) + movntiq rax, 120 (rdi) + + leaq 128 (rdi), rdi + + dec rcx + jnz loop + + sfence + movq rdx, rcx + andq $127, rcx + rep stosb + movq r9, rax + ret + + +byte_set: + rep stosb + movq r9, rax + ret + + +quadword_set: + shrq $3, rcx + .p2align 4 + rep stosq + movq rdx, rcx + andq $7, rcx + rep stosb /* Store the remaining bytes */ + movq r9, rax + ret + |