summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2018-10-02 08:55:29 +0200
committerEugen Wissner <belka@caraus.de>2018-10-02 08:55:29 +0200
commit772e87739c848a10a014d3118ff14bd0ca48b2d0 (patch)
treeb567a3c6fb03d45fb7048632bdb66501e42e65d8 /arch
parent2a90a812db53728d29a3a821cb292c032437d806 (diff)
downloadtanya-772e87739c848a10a014d3118ff14bd0ca48b2d0.tar.gz
Replace memory.op.cmp with optimized equal version
Deprecate cmp. Fix #68.
Diffstat (limited to 'arch')
-rw-r--r--arch/build.ninja4
-rw-r--r--arch/x64/linux/memory/equal.S (renamed from arch/x64/linux/memory/cmp.S)30
2 files changed, 13 insertions, 21 deletions
diff --git a/arch/build.ninja b/arch/build.ninja
index 824efa4..cf05696 100644
--- a/arch/build.ninja
+++ b/arch/build.ninja
@@ -6,9 +6,9 @@ rule archive
build abs.o: gas x64/linux/math/abs.S
build log.o: gas x64/linux/math/log.S
-build cmp.o: gas x64/linux/memory/cmp.S
+build equal.o: gas x64/linux/memory/equal.S
build fill.o: gas x64/linux/memory/fill.S
build copy.o: gas x64/linux/memory/copy.S
build syscall.o: gas x64/linux/syscall.S
-build tanya.a: archive syscall.o copy.o fill.o cmp.o log.o abs.o
+build tanya.a: archive syscall.o copy.o fill.o equal.o log.o abs.o
diff --git a/arch/x64/linux/memory/cmp.S b/arch/x64/linux/memory/equal.S
index bd9f02e..37a906a 100644
--- a/arch/x64/linux/memory/cmp.S
+++ b/arch/x64/linux/memory/equal.S
@@ -1,20 +1,19 @@
.text
/*
- * cmpMemory.
+ * equalMemory.
*
* rdi - r1 length
* rsi - r1 data.
* rdx - r2 length.
* rcx - r2 data.
*/
- .globl _D5tanya6memory2op9cmpMemoryFNaNbNixAvxQdZi
- .type _D5tanya6memory2op9cmpMemoryFNaNbNixAvxQdZi, @function
-_D5tanya6memory2op9cmpMemoryFNaNbNixAvxQdZi:
+ .globl _D5tanya6memory2op11equalMemoryFNaNbNixAvxQdZb
+ .type _D5tanya6memory2op11equalMemoryFNaNbNixAvxQdZb, @function
+_D5tanya6memory2op11equalMemoryFNaNbNixAvxQdZb:
// Compare the lengths
cmp %rdx, %rdi
- jl less
- jg greater
+ jne not_equal
mov %rcx, %rdi
@@ -26,8 +25,7 @@ _D5tanya6memory2op9cmpMemoryFNaNbNixAvxQdZi:
naligned:
cmpsb
- jl less
- jg greater
+ jne not_equal
dec %rdx
test $0x07, %edi
@@ -38,8 +36,7 @@ _D5tanya6memory2op9cmpMemoryFNaNbNixAvxQdZi:
shr $0x03, %rcx
repe cmpsq
- jl less
- jg greater
+ jne not_equal
and $0x07, %edx
jz equal
@@ -49,19 +46,14 @@ _D5tanya6memory2op9cmpMemoryFNaNbNixAvxQdZi:
cmp $0x0, %rcx
repe cmpsb
- jl less
- jg greater
+ jne not_equal
equal:
- xor %rax, %rax // Return 0
- jmp end
-
- greater:
- mov $0x01, %rax
+ mov $0x01, %rax // Return 1
jmp end
- less:
- mov $-0x01, %rax
+ not_equal:
+ xor %rax, %rax // Return 0
end:
ret