]> git.proxmox.com Git - ceph.git/blame - ceph/src/isa-l/igzip/detect_repeated_char.asm
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / isa-l / igzip / detect_repeated_char.asm
CommitLineData
7c673cae
FG
1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2; Copyright(c) 2011-2016 Intel Corporation All rights reserved.
3;
4; Redistribution and use in source and binary forms, with or without
5; modification, are permitted provided that the following conditions
6; are met:
7; * Redistributions of source code must retain the above copyright
8; notice, this list of conditions and the following disclaimer.
9; * Redistributions in binary form must reproduce the above copyright
10; notice, this list of conditions and the following disclaimer in
11; the documentation and/or other materials provided with the
12; distribution.
13; * Neither the name of Intel Corporation nor the names of its
14; contributors may be used to endorse or promote products derived
15; from this software without specific prior written permission.
16;
17; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
29
30%include "reg_sizes.asm"
31
32;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
33;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
34;;
35;; detect_repeated_char buf, size
36%ifidn __OUTPUT_FORMAT__, elf64
37 %define buf rdi
38 %define size rsi
39%elifidn __OUTPUT_FORMAT__, win64
40 %define buf rcx
41 %define size rdx
42%endif ; output formats
43
44%define tmp r10
45
46global detect_repeated_char
47detect_repeated_char:
48
49;; replicate the 1st byte to 8 bytes
50 xor tmp, tmp
51 xor rax, rax
52
53 mov al, [buf]
54 mov ah, al
55 mov tmp %+ w, ax
56 shl tmp, 16
57 or eax, tmp %+ d
58 mov tmp %+ d, eax
59 shl tmp, 32
60 or rax, tmp
61
62;; detect the 8K input
63 lea tmp, [buf + size]
64_loop:
65 cmp rax, [buf]
66 jne _fail
67 add buf, 8
68 cmp buf, tmp
69 jb _loop
70 shr rax, 56
71 jmp _end
72
73_fail:
74 mov rax, -1
75
76_end:
77 ret
78
79%undef buf
80%undef size
81%undef tmp