Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/amd64/support.S
Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | 1: | ||||
jne 1b | jne 1b | ||||
sfence | sfence | ||||
POP_FRAME_POINTER | POP_FRAME_POINTER | ||||
ret | ret | ||||
END(sse2_pagezero) | END(sse2_pagezero) | ||||
ENTRY(bcmp) | ENTRY(bcmp) | ||||
PUSH_FRAME_POINTER | PUSH_FRAME_POINTER | ||||
/* | |||||
* If the length is less than 8, skip right to the 1-byte | |||||
* comparisons. | |||||
*/ | |||||
cmpq $8,%rdx | |||||
jb 5f | |||||
/* | |||||
* If the length is greater than 64, we'll use repe cmpsq | |||||
* rather than our own loop. | |||||
*/ | |||||
cmpq $64,%rdx | |||||
ja 4f | |||||
/* | |||||
* Do 8-byte comparisons in a loop. | |||||
* | |||||
* In this section, we use these register assignments: | |||||
* %r9: Count of 8-byte comparisons. | |||||
* %ecx: Current 8-byte comparison index. | |||||
* %rdx: Number of remaining 1-byte comparisons. | |||||
*/ | |||||
movq %rdx,%r9 | |||||
shrq $3,%r9 | |||||
andq $7,%rdx | |||||
xor %ecx,%ecx | |||||
10: | |||||
movq (%rdi,%rcx,8),%r8 | |||||
cmpq (%rsi,%rcx,8),%r8 | |||||
jne 3f | |||||
addq $0x1,%rcx | |||||
cmpq %rcx,%r9 | |||||
jne 10b | |||||
/* | |||||
* If any bytes remain, we need to increment %rdi and %rsi in | |||||
* preparation for the 1-byte comparisons. | |||||
*/ | |||||
test %rdx,%rdx | test %rdx,%rdx | ||||
je 1f | je 1f | ||||
cmpq $64,%rdx | shlq $3,%rcx | ||||
jg 4f | addq %rcx,%rsi | ||||
addq %rcx,%rdi | |||||
jmp 6f | |||||
5: | |||||
/* Check for 0 length. */ | |||||
test %rdx,%rdx | |||||
je 1f | |||||
6: | |||||
/* Mop up remaining bytes with 1-byte comparisons. */ | |||||
xor %ecx,%ecx | xor %ecx,%ecx | ||||
2: | 2: | ||||
movzbl (%rdi,%rcx,1),%eax | movzbl (%rdi,%rcx,1),%eax | ||||
movzbl (%rsi,%rcx,1),%r8d | movzbl (%rsi,%rcx,1),%r8d | ||||
cmp %r8b,%al | cmp %r8b,%al | ||||
jne 3f | jne 3f | ||||
add $0x1,%rcx | add $0x1,%rcx | ||||
cmp %rcx,%rdx | cmp %rcx,%rdx | ||||
jne 2b | jne 2b | ||||
1: | 1: | ||||
/* The memory matches. */ | |||||
xor %eax,%eax | xor %eax,%eax | ||||
POP_FRAME_POINTER | POP_FRAME_POINTER | ||||
retq | retq | ||||
3: | 3: | ||||
/* The memory is different. */ | |||||
mov $1,%eax | mov $1,%eax | ||||
POP_FRAME_POINTER | POP_FRAME_POINTER | ||||
retq | retq | ||||
4: | 4: | ||||
/* | |||||
* Use repe cmpsq to compare long 8-byte strings. Then, mop | |||||
* up remaining bytes with a small loop of 1-byte comparisons. | |||||
*/ | |||||
movq %rdx,%rcx | movq %rdx,%rcx | ||||
shrq $3,%rcx | shrq $3,%rcx | ||||
repe | repe | ||||
cmpsq | cmpsq | ||||
jne 5f | jne 3b | ||||
andq $7,%rdx | |||||
movq %rdx,%rcx | jmp 5b | ||||
andq $7,%rcx | |||||
repe | |||||
cmpsb | |||||
5: | |||||
setne %al | |||||
movsbl %al,%eax | |||||
POP_FRAME_POINTER | |||||
ret | |||||
END(bcmp) | END(bcmp) | ||||
/* | /* | ||||
* bcopy(src, dst, cnt) | * bcopy(src, dst, cnt) | ||||
* rdi, rsi, rdx | * rdi, rsi, rdx | ||||
* ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800 | * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800 | ||||
*/ | */ | ||||
ENTRY(bcopy) | ENTRY(bcopy) | ||||
▲ Show 20 Lines • Show All 854 Lines • Show Last 20 Lines |