Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Unified Diff: fusl/src/string/x86_64/memset.s

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fusl/src/string/x86_64/memmove.s ('k') | fusl/src/temp/__randname.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fusl/src/string/x86_64/memset.s
diff --git a/fusl/src/string/x86_64/memset.s b/fusl/src/string/x86_64/memset.s
new file mode 100644
index 0000000000000000000000000000000000000000..2d3f5e52b8afe8d612c0fd0b04f4e8a01f078489
--- /dev/null
+++ b/fusl/src/string/x86_64/memset.s
@@ -0,0 +1,72 @@
+.global memset
+.type memset,@function
+memset:
+ movzbq %sil,%rax
+ mov $0x101010101010101,%r8
+ imul %r8,%rax
+
+ cmp $126,%rdx
+ ja 2f
+
+ test %edx,%edx
+ jz 1f
+
+ mov %sil,(%rdi)
+ mov %sil,-1(%rdi,%rdx)
+ cmp $2,%edx
+ jbe 1f
+
+ mov %ax,1(%rdi)
+ mov %ax,(-1-2)(%rdi,%rdx)
+ cmp $6,%edx
+ jbe 1f
+
+ mov %eax,(1+2)(%rdi)
+ mov %eax,(-1-2-4)(%rdi,%rdx)
+ cmp $14,%edx
+ jbe 1f
+
+ mov %rax,(1+2+4)(%rdi)
+ mov %rax,(-1-2-4-8)(%rdi,%rdx)
+ cmp $30,%edx
+ jbe 1f
+
+ mov %rax,(1+2+4+8)(%rdi)
+ mov %rax,(1+2+4+8+8)(%rdi)
+ mov %rax,(-1-2-4-8-16)(%rdi,%rdx)
+ mov %rax,(-1-2-4-8-8)(%rdi,%rdx)
+ cmp $62,%edx
+ jbe 1f
+
+ mov %rax,(1+2+4+8+16)(%rdi)
+ mov %rax,(1+2+4+8+16+8)(%rdi)
+ mov %rax,(1+2+4+8+16+16)(%rdi)
+ mov %rax,(1+2+4+8+16+24)(%rdi)
+ mov %rax,(-1-2-4-8-16-32)(%rdi,%rdx)
+ mov %rax,(-1-2-4-8-16-24)(%rdi,%rdx)
+ mov %rax,(-1-2-4-8-16-16)(%rdi,%rdx)
+ mov %rax,(-1-2-4-8-16-8)(%rdi,%rdx)
+
+1: mov %rdi,%rax
+ ret
+
+2: test $15,%edi
+ mov %rdi,%r8
+ mov %rax,-8(%rdi,%rdx)
+ mov %rdx,%rcx
+ jnz 2f
+
+1: shr $3,%rcx
+ rep
+ stosq
+ mov %r8,%rax
+ ret
+
+2: xor %edx,%edx
+ sub %edi,%edx
+ and $15,%edx
+ mov %rax,(%rdi)
+ mov %rax,8(%rdi)
+ sub %rdx,%rcx
+ add %rdx,%rdi
+ jmp 1b
« no previous file with comments | « fusl/src/string/x86_64/memmove.s ('k') | fusl/src/temp/__randname.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698