mirror of
https://github.com/intel/isa-l.git
synced 2025-03-04 19:13:28 +01:00
igzip: Setup for variable lookback distance
Change-Id: Idd52c9392113dfc54feea3c66916a7f5aa128bef Signed-off-by: Roy Oursler <roy.j.oursler@intel.com>
This commit is contained in:
parent
f421ea8d7a
commit
6317ce2b78
@ -159,6 +159,7 @@ START_FIELDS ;; isal_zstate
|
|||||||
FIELD _total_in_start,4, 4
|
FIELD _total_in_start,4, 4
|
||||||
FIELD _block_next, 4, 4
|
FIELD _block_next, 4, 4
|
||||||
FIELD _block_end, 4, 4
|
FIELD _block_end, 4, 4
|
||||||
|
FIELD _dist_mask, 4, 4
|
||||||
FIELD _bitbuf, _BitBuf2_size, _BitBuf2_align
|
FIELD _bitbuf, _BitBuf2_size, _BitBuf2_align
|
||||||
FIELD _crc, 4, 4
|
FIELD _crc, 4, 4
|
||||||
FIELD _state, 4, 4
|
FIELD _state, 4, 4
|
||||||
@ -203,7 +204,8 @@ FIELD _level_buf_size, 4, 4
|
|||||||
FIELD _level_buf, 8, 8
|
FIELD _level_buf, 8, 8
|
||||||
FIELD _end_of_stream, 2, 2
|
FIELD _end_of_stream, 2, 2
|
||||||
FIELD _flush, 2, 2
|
FIELD _flush, 2, 2
|
||||||
FIELD _gzip_flag, 4, 4
|
FIELD _gzip_flag, 2, 2
|
||||||
|
FIELD _hist_bits, 2, 2
|
||||||
FIELD _internal_state, _isal_zstate_size, _isal_zstate_align
|
FIELD _internal_state, _isal_zstate_size, _isal_zstate_align
|
||||||
|
|
||||||
%assign _isal_zstream_size _FIELD_OFFSET
|
%assign _isal_zstream_size _FIELD_OFFSET
|
||||||
@ -215,6 +217,7 @@ _internal_state_block_end equ _internal_state+_block_end
|
|||||||
_internal_state_b_bytes_valid equ _internal_state+_b_bytes_valid
|
_internal_state_b_bytes_valid equ _internal_state+_b_bytes_valid
|
||||||
_internal_state_b_bytes_processed equ _internal_state+_b_bytes_processed
|
_internal_state_b_bytes_processed equ _internal_state+_b_bytes_processed
|
||||||
_internal_state_crc equ _internal_state+_crc
|
_internal_state_crc equ _internal_state+_crc
|
||||||
|
_internal_state_dist_mask equ _internal_state+_dist_mask
|
||||||
_internal_state_bitbuf equ _internal_state+_bitbuf
|
_internal_state_bitbuf equ _internal_state+_bitbuf
|
||||||
_internal_state_state equ _internal_state+_state
|
_internal_state_state equ _internal_state+_state
|
||||||
_internal_state_count equ _internal_state+_count
|
_internal_state_count equ _internal_state+_count
|
||||||
|
@ -911,6 +911,18 @@ static inline void reset_match_history(struct isal_zstream *stream)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void inline set_dist_mask(struct isal_zstream *stream)
|
||||||
|
{
|
||||||
|
struct isal_zstate *state = &stream->internal_state;
|
||||||
|
uint32_t hist_size = (1 << (stream->hist_bits));
|
||||||
|
|
||||||
|
if (stream->hist_bits != 0 && hist_size < IGZIP_HIST_SIZE)
|
||||||
|
state->dist_mask = hist_size - 1;
|
||||||
|
else
|
||||||
|
state->dist_mask = IGZIP_HIST_SIZE - 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void isal_deflate_init(struct isal_zstream *stream)
|
void isal_deflate_init(struct isal_zstream *stream)
|
||||||
{
|
{
|
||||||
struct isal_zstate *state = &stream->internal_state;
|
struct isal_zstate *state = &stream->internal_state;
|
||||||
@ -924,6 +936,7 @@ void isal_deflate_init(struct isal_zstream *stream)
|
|||||||
stream->end_of_stream = 0;
|
stream->end_of_stream = 0;
|
||||||
stream->flush = NO_FLUSH;
|
stream->flush = NO_FLUSH;
|
||||||
stream->gzip_flag = 0;
|
stream->gzip_flag = 0;
|
||||||
|
stream->hist_bits = 0;
|
||||||
|
|
||||||
state->block_next = 0;
|
state->block_next = 0;
|
||||||
state->block_end = 0;
|
state->block_end = 0;
|
||||||
@ -1097,6 +1110,7 @@ int isal_deflate_stateless(struct isal_zstream *stream)
|
|||||||
state->state = ZSTATE_NEW_HDR;
|
state->state = ZSTATE_NEW_HDR;
|
||||||
state->crc = 0;
|
state->crc = 0;
|
||||||
state->has_level_buf_init = 0;
|
state->has_level_buf_init = 0;
|
||||||
|
set_dist_mask(stream);
|
||||||
|
|
||||||
if (stream->flush == NO_FLUSH)
|
if (stream->flush == NO_FLUSH)
|
||||||
stream->end_of_stream = 1;
|
stream->end_of_stream = 1;
|
||||||
@ -1248,13 +1262,16 @@ int isal_deflate(struct isal_zstream *stream)
|
|||||||
hist_size = get_hist_size(stream, start_in, buf_hist_start);
|
hist_size = get_hist_size(stream, start_in, buf_hist_start);
|
||||||
|
|
||||||
if (state->has_hist == IGZIP_NO_HIST) {
|
if (state->has_hist == IGZIP_NO_HIST) {
|
||||||
|
set_dist_mask(stream);
|
||||||
stream->total_in -= buffered_size;
|
stream->total_in -= buffered_size;
|
||||||
reset_match_history(stream);
|
reset_match_history(stream);
|
||||||
stream->total_in += buffered_size;
|
stream->total_in += buffered_size;
|
||||||
buf_hist_start = state->b_bytes_processed;
|
buf_hist_start = state->b_bytes_processed;
|
||||||
|
|
||||||
} else if (state->has_hist == IGZIP_DICT_HIST)
|
} else if (state->has_hist == IGZIP_DICT_HIST) {
|
||||||
|
set_dist_mask(stream);
|
||||||
isal_deflate_hash(stream, state->buffer, state->b_bytes_processed);
|
isal_deflate_hash(stream, state->buffer, state->b_bytes_processed);
|
||||||
|
}
|
||||||
|
|
||||||
in_size = stream->avail_in + buffered_size;
|
in_size = stream->avail_in + buffered_size;
|
||||||
out_size = stream->total_out;
|
out_size = stream->total_out;
|
||||||
|
@ -36,6 +36,7 @@ void isal_deflate_body_base(struct isal_zstream *stream)
|
|||||||
struct isal_zstate *state = &stream->internal_state;
|
struct isal_zstate *state = &stream->internal_state;
|
||||||
uint16_t *last_seen = state->head;
|
uint16_t *last_seen = state->head;
|
||||||
uint8_t *file_start = stream->next_in - stream->total_in;
|
uint8_t *file_start = stream->next_in - stream->total_in;
|
||||||
|
uint32_t hist_size = state->dist_mask;
|
||||||
|
|
||||||
if (stream->avail_in == 0) {
|
if (stream->avail_in == 0) {
|
||||||
if (stream->end_of_stream || stream->flush != NO_FLUSH)
|
if (stream->end_of_stream || stream->flush != NO_FLUSH)
|
||||||
@ -62,7 +63,7 @@ void isal_deflate_body_base(struct isal_zstream *stream)
|
|||||||
last_seen[hash] = (uint64_t) (next_in - file_start);
|
last_seen[hash] = (uint64_t) (next_in - file_start);
|
||||||
|
|
||||||
/* The -1 are to handle the case when dist = 0 */
|
/* The -1 are to handle the case when dist = 0 */
|
||||||
if (dist - 1 < IGZIP_HIST_SIZE - 1) {
|
if (dist - 1 < hist_size) {
|
||||||
assert(dist != 0);
|
assert(dist != 0);
|
||||||
|
|
||||||
match_length = compare258(next_in - dist, next_in, 258);
|
match_length = compare258(next_in - dist, next_in, 258);
|
||||||
@ -122,6 +123,7 @@ void isal_deflate_finish_base(struct isal_zstream *stream)
|
|||||||
struct isal_zstate *state = &stream->internal_state;
|
struct isal_zstate *state = &stream->internal_state;
|
||||||
uint16_t *last_seen = state->head;
|
uint16_t *last_seen = state->head;
|
||||||
uint8_t *file_start = stream->next_in - stream->total_in;
|
uint8_t *file_start = stream->next_in - stream->total_in;
|
||||||
|
uint32_t hist_size = state->dist_mask;
|
||||||
|
|
||||||
set_buf(&state->bitbuf, stream->next_out, stream->avail_out);
|
set_buf(&state->bitbuf, stream->next_out, stream->avail_out);
|
||||||
|
|
||||||
@ -141,7 +143,7 @@ void isal_deflate_finish_base(struct isal_zstream *stream)
|
|||||||
dist = (next_in - file_start - last_seen[hash]) & 0xFFFF;
|
dist = (next_in - file_start - last_seen[hash]) & 0xFFFF;
|
||||||
last_seen[hash] = (uint64_t) (next_in - file_start);
|
last_seen[hash] = (uint64_t) (next_in - file_start);
|
||||||
|
|
||||||
if (dist - 1 < IGZIP_HIST_SIZE - 1) { /* The -1 are to handle the case when dist = 0 */
|
if (dist - 1 < hist_size) { /* The -1 are to handle the case when dist = 0 */
|
||||||
match_length =
|
match_length =
|
||||||
compare258(next_in - dist, next_in, end_in - next_in);
|
compare258(next_in - dist, next_in, end_in - next_in);
|
||||||
|
|
||||||
|
@ -224,13 +224,14 @@ isal_deflate_body_ %+ ARCH %+ :
|
|||||||
align 16
|
align 16
|
||||||
|
|
||||||
.loop2:
|
.loop2:
|
||||||
|
mov tmp3 %+ d, dword [stream + _internal_state_dist_mask]
|
||||||
|
|
||||||
; if (state->bitbuf.is_full()) {
|
; if (state->bitbuf.is_full()) {
|
||||||
cmp m_out_buf, [stream + _internal_state_bitbuf_m_out_end]
|
cmp m_out_buf, [stream + _internal_state_bitbuf_m_out_end]
|
||||||
ja .output_end
|
ja .output_end
|
||||||
|
|
||||||
xor dist, dist
|
xor dist, dist
|
||||||
xor dist2, dist2
|
xor dist2, dist2
|
||||||
xor tmp3, tmp3
|
|
||||||
|
|
||||||
lea tmp1, [file_start + f_i]
|
lea tmp1, [file_start + f_i]
|
||||||
|
|
||||||
@ -252,13 +253,13 @@ isal_deflate_body_ %+ ARCH %+ :
|
|||||||
mov [stream + _internal_state_head + 2 * hash2], f_i %+ w
|
mov [stream + _internal_state_head + 2 * hash2], f_i %+ w
|
||||||
|
|
||||||
; if ((dist-1) < (D-1)) {
|
; if ((dist-1) < (D-1)) {
|
||||||
and dist %+ d, (D-1)
|
and dist, tmp3
|
||||||
neg dist
|
neg dist
|
||||||
|
|
||||||
shr tmp8, 8
|
shr tmp8, 8
|
||||||
compute_hash tmp2, tmp8
|
compute_hash tmp2, tmp8
|
||||||
|
|
||||||
and dist2 %+ d, (D-1)
|
and dist2, tmp3
|
||||||
neg dist2
|
neg dist2
|
||||||
|
|
||||||
;; Check for long len/dist match (>7) with first literal
|
;; Check for long len/dist match (>7) with first literal
|
||||||
|
@ -141,6 +141,8 @@ skip_SLOP:
|
|||||||
skip_write_first_byte:
|
skip_write_first_byte:
|
||||||
|
|
||||||
loop2:
|
loop2:
|
||||||
|
mov tmp3 %+ d, dword [stream + _internal_state_dist_mask]
|
||||||
|
|
||||||
; if (state->bitbuf.is_full()) {
|
; if (state->bitbuf.is_full()) {
|
||||||
cmp m_out_buf, [stream + _internal_state_bitbuf_m_out_end]
|
cmp m_out_buf, [stream + _internal_state_bitbuf_m_out_end]
|
||||||
ja end_loop_2
|
ja end_loop_2
|
||||||
@ -164,7 +166,7 @@ loop2:
|
|||||||
; if ((dist-1) <= (D-1)) {
|
; if ((dist-1) <= (D-1)) {
|
||||||
mov tmp1 %+ d, dist %+ d
|
mov tmp1 %+ d, dist %+ d
|
||||||
sub tmp1 %+ d, 1
|
sub tmp1 %+ d, 1
|
||||||
cmp tmp1 %+ d, (D-1)
|
cmp tmp1 %+ d, tmp3 %+ d
|
||||||
jae encode_literal
|
jae encode_literal
|
||||||
|
|
||||||
; len = f_end_i - f_i;
|
; len = f_end_i - f_i;
|
||||||
|
@ -101,6 +101,7 @@
|
|||||||
|
|
||||||
%ifidn __OUTPUT_FORMAT__, win64
|
%ifidn __OUTPUT_FORMAT__, win64
|
||||||
%define stack_size 10*16 + 6 * 8 + 8
|
%define stack_size 10*16 + 6 * 8 + 8
|
||||||
|
%define local_storage_offset (stack_size - 8)
|
||||||
%define func(x) proc_frame x
|
%define func(x) proc_frame x
|
||||||
|
|
||||||
%macro FUNC_SAVE 0
|
%macro FUNC_SAVE 0
|
||||||
@ -143,20 +144,27 @@
|
|||||||
add rsp, stack_size
|
add rsp, stack_size
|
||||||
%endm
|
%endm
|
||||||
%else
|
%else
|
||||||
|
%define stack_size 8
|
||||||
|
%define local_storage_offset 0
|
||||||
|
|
||||||
%define func(x) x:
|
%define func(x) x:
|
||||||
%macro FUNC_SAVE 0
|
%macro FUNC_SAVE 0
|
||||||
push rbp
|
push rbp
|
||||||
push r12
|
push r12
|
||||||
push r13
|
push r13
|
||||||
|
sub rsp, stack_size
|
||||||
%endm
|
%endm
|
||||||
|
|
||||||
%macro FUNC_RESTORE 0
|
%macro FUNC_RESTORE 0
|
||||||
|
add rsp, stack_size
|
||||||
pop r13
|
pop r13
|
||||||
pop r12
|
pop r12
|
||||||
pop rbp
|
pop rbp
|
||||||
%endm
|
%endm
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
%define dist_mask_offset local_storage_offset
|
||||||
|
|
||||||
%define VECT_SIZE 8
|
%define VECT_SIZE 8
|
||||||
%define HASH_BYTES 2
|
%define HASH_BYTES 2
|
||||||
|
|
||||||
@ -174,6 +182,8 @@ func(gen_icf_map_lh1_04)
|
|||||||
jge end_main
|
jge end_main
|
||||||
|
|
||||||
;; Prep for main loop
|
;; Prep for main loop
|
||||||
|
mov tmp %+ d, dword [stream + _internal_state_dist_mask]
|
||||||
|
mov [rsp + dist_mask_offset], tmp
|
||||||
mov tmp, stream
|
mov tmp, stream
|
||||||
mov level_buf, [stream + _level_buf]
|
mov level_buf, [stream + _level_buf]
|
||||||
sub f_i_end, LA
|
sub f_i_end, LA
|
||||||
@ -207,7 +217,7 @@ func(gen_icf_map_lh1_04)
|
|||||||
dec tmp
|
dec tmp
|
||||||
sub tmp %+ w, word [hash_table + HASH_BYTES * hash]
|
sub tmp %+ w, word [hash_table + HASH_BYTES * hash]
|
||||||
|
|
||||||
and tmp %+ d, [dist_mask]
|
and tmp %+ d, [rsp + dist_mask_offset]
|
||||||
neg tmp
|
neg tmp
|
||||||
|
|
||||||
;; Check first 8 bytes of match
|
;; Check first 8 bytes of match
|
||||||
@ -307,7 +317,7 @@ loop1:
|
|||||||
lea next_in, [f_i + file_start]
|
lea next_in, [f_i + file_start]
|
||||||
|
|
||||||
;; Calculate look back dists
|
;; Calculate look back dists
|
||||||
vpbroadcastd ydist_mask, [dist_mask]
|
vpbroadcastd ydist_mask, [rsp + dist_mask_offset]
|
||||||
vpaddd ydists, ydists_lookup, yones
|
vpaddd ydists, ydists_lookup, yones
|
||||||
vpsubd ydists, yindex, ydists
|
vpsubd ydists, yindex, ydists
|
||||||
vpand ydists, ydists, ydist_mask
|
vpand ydists, ydists, ydist_mask
|
||||||
@ -503,7 +513,7 @@ loop1_end:
|
|||||||
lea next_in, [f_i + file_start]
|
lea next_in, [f_i + file_start]
|
||||||
|
|
||||||
;; Calculate look back dists
|
;; Calculate look back dists
|
||||||
vpbroadcastd ydist_mask, [dist_mask]
|
vpbroadcastd ydist_mask, [rsp + dist_mask_offset]
|
||||||
vpaddd ydists, ydists_lookup, yones
|
vpaddd ydists, ydists_lookup, yones
|
||||||
vpsubd ydists, yindex, ydists
|
vpsubd ydists, yindex, ydists
|
||||||
vpand ydists, ydists, ydist_mask
|
vpand ydists, ydists, ydist_mask
|
||||||
@ -710,8 +720,6 @@ ones:
|
|||||||
%define PROD2 0x97B1
|
%define PROD2 0x97B1
|
||||||
hash_prod:
|
hash_prod:
|
||||||
dw PROD1, PROD2
|
dw PROD1, PROD2
|
||||||
dist_mask:
|
|
||||||
dd D-1
|
|
||||||
null_dist_syms:
|
null_dist_syms:
|
||||||
dd LIT
|
dd LIT
|
||||||
hash_mask:
|
hash_mask:
|
||||||
|
@ -174,6 +174,7 @@ func(gen_icf_map_lh1_06)
|
|||||||
jge end_main
|
jge end_main
|
||||||
|
|
||||||
;; Prep for main loop
|
;; Prep for main loop
|
||||||
|
vpbroadcastd zdist_mask, dword [stream + _internal_state_dist_mask]
|
||||||
mov tmp, stream
|
mov tmp, stream
|
||||||
mov level_buf, [stream + _level_buf]
|
mov level_buf, [stream + _level_buf]
|
||||||
sub f_i_end, LA
|
sub f_i_end, LA
|
||||||
@ -189,7 +190,6 @@ func(gen_icf_map_lh1_06)
|
|||||||
vbroadcasti32x4 zbswap, [bswap_shuf]
|
vbroadcasti32x4 zbswap, [bswap_shuf]
|
||||||
vpbroadcastd zthirty, [thirty]
|
vpbroadcastd zthirty, [thirty]
|
||||||
vmovdqu64 zrot_left, [drot_left]
|
vmovdqu64 zrot_left, [drot_left]
|
||||||
vpbroadcastd zdist_mask, dword [dist_mask]
|
|
||||||
vpbroadcastd zshortest_matches, [shortest_matches]
|
vpbroadcastd zshortest_matches, [shortest_matches]
|
||||||
vpbroadcastd ztwofiftyfour, [twofiftyfour]
|
vpbroadcastd ztwofiftyfour, [twofiftyfour]
|
||||||
vpbroadcastd znull_dist_syms, [null_dist_syms]
|
vpbroadcastd znull_dist_syms, [null_dist_syms]
|
||||||
@ -569,8 +569,6 @@ thirty:
|
|||||||
dd 0x1e
|
dd 0x1e
|
||||||
twofiftyfour:
|
twofiftyfour:
|
||||||
dd 0xfe
|
dd 0xfe
|
||||||
dist_mask:
|
|
||||||
dd D-1
|
|
||||||
hash_mask:
|
hash_mask:
|
||||||
dd HASH_MAP_HASH_MASK
|
dd HASH_MAP_HASH_MASK
|
||||||
lit_len_mask:
|
lit_len_mask:
|
||||||
|
@ -44,6 +44,7 @@ void isal_deflate_icf_body_hash8k_base(struct isal_zstream *stream)
|
|||||||
struct level_buf *level_buf = (struct level_buf *)stream->level_buf;
|
struct level_buf *level_buf = (struct level_buf *)stream->level_buf;
|
||||||
uint16_t *last_seen = level_buf->hash8k.hash_table;
|
uint16_t *last_seen = level_buf->hash8k.hash_table;
|
||||||
uint8_t *file_start = stream->next_in - stream->total_in;
|
uint8_t *file_start = stream->next_in - stream->total_in;
|
||||||
|
uint32_t hist_size = state->dist_mask;
|
||||||
|
|
||||||
if (stream->avail_in == 0) {
|
if (stream->avail_in == 0) {
|
||||||
if (stream->end_of_stream || stream->flush != NO_FLUSH)
|
if (stream->end_of_stream || stream->flush != NO_FLUSH)
|
||||||
@ -76,7 +77,7 @@ void isal_deflate_icf_body_hash8k_base(struct isal_zstream *stream)
|
|||||||
last_seen[hash] = (uint64_t) (next_in - file_start);
|
last_seen[hash] = (uint64_t) (next_in - file_start);
|
||||||
|
|
||||||
/* The -1 are to handle the case when dist = 0 */
|
/* The -1 are to handle the case when dist = 0 */
|
||||||
if (dist - 1 < IGZIP_HIST_SIZE - 1) {
|
if (dist - 1 < hist_size) {
|
||||||
assert(dist != 0);
|
assert(dist != 0);
|
||||||
|
|
||||||
match_length = compare258(next_in - dist, next_in, 258);
|
match_length = compare258(next_in - dist, next_in, 258);
|
||||||
@ -139,6 +140,7 @@ void isal_deflate_icf_body_hash_hist_base(struct isal_zstream *stream)
|
|||||||
struct level_buf *level_buf = (struct level_buf *)stream->level_buf;
|
struct level_buf *level_buf = (struct level_buf *)stream->level_buf;
|
||||||
uint16_t *last_seen = level_buf->hash_hist.hash_table;
|
uint16_t *last_seen = level_buf->hash_hist.hash_table;
|
||||||
uint8_t *file_start = stream->next_in - stream->total_in;
|
uint8_t *file_start = stream->next_in - stream->total_in;
|
||||||
|
uint32_t hist_size = state->dist_mask;
|
||||||
|
|
||||||
if (stream->avail_in == 0) {
|
if (stream->avail_in == 0) {
|
||||||
if (stream->end_of_stream || stream->flush != NO_FLUSH)
|
if (stream->end_of_stream || stream->flush != NO_FLUSH)
|
||||||
@ -171,7 +173,7 @@ void isal_deflate_icf_body_hash_hist_base(struct isal_zstream *stream)
|
|||||||
last_seen[hash] = (uint64_t) (next_in - file_start);
|
last_seen[hash] = (uint64_t) (next_in - file_start);
|
||||||
|
|
||||||
/* The -1 are to handle the case when dist = 0 */
|
/* The -1 are to handle the case when dist = 0 */
|
||||||
if (dist - 1 < IGZIP_HIST_SIZE - 1) {
|
if (dist - 1 < hist_size) {
|
||||||
assert(dist != 0);
|
assert(dist != 0);
|
||||||
|
|
||||||
match_length = compare258(next_in - dist, next_in, 258);
|
match_length = compare258(next_in - dist, next_in, 258);
|
||||||
@ -234,6 +236,7 @@ void isal_deflate_icf_finish_hash8k_base(struct isal_zstream *stream)
|
|||||||
struct level_buf *level_buf = (struct level_buf *)stream->level_buf;
|
struct level_buf *level_buf = (struct level_buf *)stream->level_buf;
|
||||||
uint16_t *last_seen = level_buf->hash8k.hash_table;
|
uint16_t *last_seen = level_buf->hash8k.hash_table;
|
||||||
uint8_t *file_start = stream->next_in - stream->total_in;
|
uint8_t *file_start = stream->next_in - stream->total_in;
|
||||||
|
uint32_t hist_size = state->dist_mask;
|
||||||
|
|
||||||
start_in = stream->next_in;
|
start_in = stream->next_in;
|
||||||
end_in = start_in + stream->avail_in;
|
end_in = start_in + stream->avail_in;
|
||||||
@ -263,7 +266,7 @@ void isal_deflate_icf_finish_hash8k_base(struct isal_zstream *stream)
|
|||||||
dist = (next_in - file_start - last_seen[hash]) & 0xFFFF;
|
dist = (next_in - file_start - last_seen[hash]) & 0xFFFF;
|
||||||
last_seen[hash] = (uint64_t) (next_in - file_start);
|
last_seen[hash] = (uint64_t) (next_in - file_start);
|
||||||
|
|
||||||
if (dist - 1 < IGZIP_HIST_SIZE - 1) { /* The -1 are to handle the case when dist = 0 */
|
if (dist - 1 < hist_size) { /* The -1 are to handle the case when dist = 0 */
|
||||||
match_length = compare258(next_in - dist, next_in, end_in - next_in);
|
match_length = compare258(next_in - dist, next_in, end_in - next_in);
|
||||||
|
|
||||||
if (match_length >= SHORTEST_MATCH) {
|
if (match_length >= SHORTEST_MATCH) {
|
||||||
@ -343,6 +346,7 @@ void isal_deflate_icf_finish_hash_hist_base(struct isal_zstream *stream)
|
|||||||
struct level_buf *level_buf = (struct level_buf *)stream->level_buf;
|
struct level_buf *level_buf = (struct level_buf *)stream->level_buf;
|
||||||
uint16_t *last_seen = level_buf->hash_hist.hash_table;
|
uint16_t *last_seen = level_buf->hash_hist.hash_table;
|
||||||
uint8_t *file_start = stream->next_in - stream->total_in;
|
uint8_t *file_start = stream->next_in - stream->total_in;
|
||||||
|
uint32_t hist_size = state->dist_mask;
|
||||||
|
|
||||||
start_in = stream->next_in;
|
start_in = stream->next_in;
|
||||||
end_in = start_in + stream->avail_in;
|
end_in = start_in + stream->avail_in;
|
||||||
@ -372,7 +376,7 @@ void isal_deflate_icf_finish_hash_hist_base(struct isal_zstream *stream)
|
|||||||
dist = (next_in - file_start - last_seen[hash]) & 0xFFFF;
|
dist = (next_in - file_start - last_seen[hash]) & 0xFFFF;
|
||||||
last_seen[hash] = (uint64_t) (next_in - file_start);
|
last_seen[hash] = (uint64_t) (next_in - file_start);
|
||||||
|
|
||||||
if (dist - 1 < IGZIP_HIST_SIZE - 1) { /* The -1 are to handle the case when dist = 0 */
|
if (dist - 1 < hist_size) { /* The -1 are to handle the case when dist = 0 */
|
||||||
match_length = compare258(next_in - dist, next_in, end_in - next_in);
|
match_length = compare258(next_in - dist, next_in, end_in - next_in);
|
||||||
|
|
||||||
if (match_length >= SHORTEST_MATCH) {
|
if (match_length >= SHORTEST_MATCH) {
|
||||||
@ -452,6 +456,7 @@ void isal_deflate_icf_finish_hash_map_base(struct isal_zstream *stream)
|
|||||||
struct level_buf *level_buf = (struct level_buf *)stream->level_buf;
|
struct level_buf *level_buf = (struct level_buf *)stream->level_buf;
|
||||||
uint16_t *last_seen = level_buf->hash_map.hash_table;
|
uint16_t *last_seen = level_buf->hash_map.hash_table;
|
||||||
uint8_t *file_start = stream->next_in - stream->total_in;
|
uint8_t *file_start = stream->next_in - stream->total_in;
|
||||||
|
uint32_t hist_size = state->dist_mask;
|
||||||
|
|
||||||
start_in = stream->next_in;
|
start_in = stream->next_in;
|
||||||
end_in = start_in + stream->avail_in;
|
end_in = start_in + stream->avail_in;
|
||||||
@ -480,7 +485,7 @@ void isal_deflate_icf_finish_hash_map_base(struct isal_zstream *stream)
|
|||||||
dist = (next_in - file_start - last_seen[hash]) & 0xFFFF;
|
dist = (next_in - file_start - last_seen[hash]) & 0xFFFF;
|
||||||
last_seen[hash] = (uint64_t) (next_in - file_start);
|
last_seen[hash] = (uint64_t) (next_in - file_start);
|
||||||
|
|
||||||
if (dist - 1 < IGZIP_HIST_SIZE - 1) { /* The -1 are to handle the case when dist = 0 */
|
if (dist - 1 < hist_size) { /* The -1 are to handle the case when dist = 0 */
|
||||||
match_length = compare258(next_in - dist, next_in, end_in - next_in);
|
match_length = compare258(next_in - dist, next_in, end_in - next_in);
|
||||||
|
|
||||||
if (match_length >= SHORTEST_MATCH) {
|
if (match_length >= SHORTEST_MATCH) {
|
||||||
|
@ -77,6 +77,7 @@ uint64_t gen_icf_map_h1_base(struct isal_zstream *stream,
|
|||||||
uint64_t match;
|
uint64_t match;
|
||||||
struct level_buf *level_buf = (struct level_buf *)stream->level_buf;
|
struct level_buf *level_buf = (struct level_buf *)stream->level_buf;
|
||||||
uint16_t *hash_table = level_buf->hash_map.hash_table;
|
uint16_t *hash_table = level_buf->hash_map.hash_table;
|
||||||
|
uint32_t hist_size = stream->internal_state.dist_mask;
|
||||||
|
|
||||||
if (input_size < ISAL_LOOK_AHEAD)
|
if (input_size < ISAL_LOOK_AHEAD)
|
||||||
return 0;
|
return 0;
|
||||||
@ -97,7 +98,7 @@ uint64_t gen_icf_map_h1_base(struct isal_zstream *stream,
|
|||||||
while (next_in < end_in - ISAL_LOOK_AHEAD) {
|
while (next_in < end_in - ISAL_LOOK_AHEAD) {
|
||||||
hash = compute_hash(*(uint32_t *) next_in) & HASH_MAP_HASH_MASK;
|
hash = compute_hash(*(uint32_t *) next_in) & HASH_MAP_HASH_MASK;
|
||||||
dist = (next_in - file_start - hash_table[hash]);
|
dist = (next_in - file_start - hash_table[hash]);
|
||||||
dist = ((dist - 1) & (IGZIP_HIST_SIZE - 1)) + 1;
|
dist = ((dist - 1) & hist_size) + 1;
|
||||||
hash_table[hash] = (uint64_t) (next_in - file_start);
|
hash_table[hash] = (uint64_t) (next_in - file_start);
|
||||||
|
|
||||||
match_bytes = *(uint64_t *) (next_in - dist);
|
match_bytes = *(uint64_t *) (next_in - dist);
|
||||||
|
@ -103,11 +103,12 @@ global %1
|
|||||||
|
|
||||||
m_out_end equ 0 ; local variable (8 bytes)
|
m_out_end equ 0 ; local variable (8 bytes)
|
||||||
m_out_start equ 8
|
m_out_start equ 8
|
||||||
f_end_i_mem_offset equ 16
|
dist_mask_offset equ 16
|
||||||
stream_offset equ 24
|
f_end_i_mem_offset equ 24
|
||||||
gpr_save_mem_offset equ 32 ; gpr save area (8*8 bytes)
|
stream_offset equ 32
|
||||||
|
gpr_save_mem_offset equ 40 ; gpr save area (8*8 bytes)
|
||||||
xmm_save_mem_offset equ gpr_save_mem_offset + 8*8 ; xmm save area (4*16 bytes) (16 byte aligned)
|
xmm_save_mem_offset equ gpr_save_mem_offset + 8*8 ; xmm save area (4*16 bytes) (16 byte aligned)
|
||||||
stack_size equ 5*8 + 8*8 + 4*16
|
stack_size equ 7*8 + 8*8 + 4*16
|
||||||
|
|
||||||
;;; 8 because stack address is odd multiple of 8 after a function call and
|
;;; 8 because stack address is odd multiple of 8 after a function call and
|
||||||
;;; we want it aligned to 16 bytes
|
;;; we want it aligned to 16 bytes
|
||||||
@ -182,6 +183,8 @@ isal_deflate_icf_body_ %+ METHOD %+ _ %+ ARCH %+ :
|
|||||||
mov [rsp + stream_offset], stream
|
mov [rsp + stream_offset], stream
|
||||||
|
|
||||||
mov byte [stream + _internal_state_has_eob], 0
|
mov byte [stream + _internal_state_has_eob], 0
|
||||||
|
mov tmp1 %+ d, dword[stream + _internal_state_dist_mask]
|
||||||
|
mov [rsp + dist_mask_offset], tmp1
|
||||||
|
|
||||||
; state->bitbuf.set_buf(stream->next_out, stream->avail_out);
|
; state->bitbuf.set_buf(stream->next_out, stream->avail_out);
|
||||||
mov level_buf, [stream + _level_buf]
|
mov level_buf, [stream + _level_buf]
|
||||||
@ -230,13 +233,13 @@ isal_deflate_icf_body_ %+ METHOD %+ _ %+ ARCH %+ :
|
|||||||
align 16
|
align 16
|
||||||
|
|
||||||
.loop2:
|
.loop2:
|
||||||
|
mov tmp3 %+ d, [rsp + dist_mask_offset]
|
||||||
; if (state->bitbuf.is_full()) {
|
; if (state->bitbuf.is_full()) {
|
||||||
cmp m_out_buf, [rsp + m_out_end]
|
cmp m_out_buf, [rsp + m_out_end]
|
||||||
ja .output_end
|
ja .output_end
|
||||||
|
|
||||||
xor dist, dist
|
xor dist, dist
|
||||||
xor dist2, dist2
|
xor dist2, dist2
|
||||||
xor tmp3, tmp3
|
|
||||||
|
|
||||||
lea tmp1, [file_start + f_i]
|
lea tmp1, [file_start + f_i]
|
||||||
|
|
||||||
@ -258,14 +261,14 @@ isal_deflate_icf_body_ %+ METHOD %+ _ %+ ARCH %+ :
|
|||||||
mov [hash_table + 2 * hash2], f_i %+ w
|
mov [hash_table + 2 * hash2], f_i %+ w
|
||||||
|
|
||||||
; if ((dist-1) < (D-1)) {
|
; if ((dist-1) < (D-1)) {
|
||||||
and dist %+ d, (D-1)
|
and dist %+ d, tmp3 %+ d
|
||||||
neg dist
|
neg dist
|
||||||
|
|
||||||
shr tmp2, 24
|
shr tmp2, 24
|
||||||
compute_hash hash2, tmp2
|
compute_hash hash2, tmp2
|
||||||
and hash2 %+ d, HASH_MASK
|
and hash2 %+ d, HASH_MASK
|
||||||
|
|
||||||
and dist2 %+ d, (D-1)
|
and dist2 %+ d, tmp3 %+ d
|
||||||
neg dist2
|
neg dist2
|
||||||
|
|
||||||
;; Check for long len/dist match (>7) with first literal
|
;; Check for long len/dist match (>7) with first literal
|
||||||
|
@ -86,6 +86,7 @@
|
|||||||
f_end_i_mem_offset equ 0 ; local variable (8 bytes)
|
f_end_i_mem_offset equ 0 ; local variable (8 bytes)
|
||||||
m_out_end equ 8
|
m_out_end equ 8
|
||||||
m_out_start equ 16
|
m_out_start equ 16
|
||||||
|
dist_mask_offset equ 24
|
||||||
stack_size equ 32
|
stack_size equ 32
|
||||||
|
|
||||||
%xdefine HASH_MASK HASH8K_HASH_MASK
|
%xdefine HASH_MASK HASH8K_HASH_MASK
|
||||||
@ -108,6 +109,7 @@ isal_deflate_icf_finish_ %+ METHOD %+ _01:
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
; state->bitbuf.set_buf(stream->next_out, stream->avail_out);
|
; state->bitbuf.set_buf(stream->next_out, stream->avail_out);
|
||||||
|
mov tmp2, [stream + _internal_state_dist_mask]
|
||||||
mov level_buf, [stream + _level_buf]
|
mov level_buf, [stream + _level_buf]
|
||||||
mov m_out_buf, [level_buf + _icf_buf_next]
|
mov m_out_buf, [level_buf + _icf_buf_next]
|
||||||
mov [rsp + m_out_start], m_out_buf
|
mov [rsp + m_out_start], m_out_buf
|
||||||
@ -115,6 +117,7 @@ isal_deflate_icf_finish_ %+ METHOD %+ _01:
|
|||||||
add tmp1, m_out_buf
|
add tmp1, m_out_buf
|
||||||
sub tmp1, 4
|
sub tmp1, 4
|
||||||
|
|
||||||
|
mov [rsp + dist_mask_offset], tmp2
|
||||||
mov [rsp + m_out_end], tmp1
|
mov [rsp + m_out_end], tmp1
|
||||||
|
|
||||||
mov hufftables, [stream + _hufftables]
|
mov hufftables, [stream + _hufftables]
|
||||||
@ -150,6 +153,7 @@ isal_deflate_icf_finish_ %+ METHOD %+ _01:
|
|||||||
.skip_write_first_byte:
|
.skip_write_first_byte:
|
||||||
|
|
||||||
.loop2:
|
.loop2:
|
||||||
|
mov tmp3 %+ d, [rsp + dist_mask_offset]
|
||||||
; if (state->bitbuf.is_full()) {
|
; if (state->bitbuf.is_full()) {
|
||||||
cmp m_out_buf, [rsp + m_out_end]
|
cmp m_out_buf, [rsp + m_out_end]
|
||||||
ja .end_loop_2
|
ja .end_loop_2
|
||||||
@ -173,7 +177,7 @@ isal_deflate_icf_finish_ %+ METHOD %+ _01:
|
|||||||
; if ((dist-1) <= (D-1)) {
|
; if ((dist-1) <= (D-1)) {
|
||||||
mov tmp1 %+ d, dist %+ d
|
mov tmp1 %+ d, dist %+ d
|
||||||
sub tmp1 %+ d, 1
|
sub tmp1 %+ d, 1
|
||||||
cmp tmp1 %+ d, (D-1)
|
cmp tmp1 %+ d, tmp3 %+ d
|
||||||
jae .encode_literal
|
jae .encode_literal
|
||||||
|
|
||||||
; len = f_end_i - f_i;
|
; len = f_end_i - f_i;
|
||||||
|
@ -314,6 +314,7 @@ struct isal_zstate {
|
|||||||
uint32_t total_in_start; //!< Not used, may be replaced with something else
|
uint32_t total_in_start; //!< Not used, may be replaced with something else
|
||||||
uint32_t block_next; //!< Start of current deflate block in the input
|
uint32_t block_next; //!< Start of current deflate block in the input
|
||||||
uint32_t block_end; //!< End of current deflate block in the input
|
uint32_t block_end; //!< End of current deflate block in the input
|
||||||
|
uint32_t dist_mask; //!< Distance mask used.
|
||||||
struct BitBuf2 bitbuf; //!< Bit Buffer
|
struct BitBuf2 bitbuf; //!< Bit Buffer
|
||||||
uint32_t crc; //!< Current crc
|
uint32_t crc; //!< Current crc
|
||||||
enum isal_zstate_state state; //!< Current state in processing the data stream
|
enum isal_zstate_state state; //!< Current state in processing the data stream
|
||||||
@ -365,8 +366,8 @@ struct isal_zstream {
|
|||||||
uint8_t * level_buf; //!< User allocated buffer required for different compression levels
|
uint8_t * level_buf; //!< User allocated buffer required for different compression levels
|
||||||
uint16_t end_of_stream; //!< non-zero if this is the last input buffer
|
uint16_t end_of_stream; //!< non-zero if this is the last input buffer
|
||||||
uint16_t flush; //!< Flush type can be NO_FLUSH, SYNC_FLUSH or FULL_FLUSH
|
uint16_t flush; //!< Flush type can be NO_FLUSH, SYNC_FLUSH or FULL_FLUSH
|
||||||
uint32_t gzip_flag; //!< Indicate if gzip compression is to be performed
|
uint16_t gzip_flag; //!< Indicate if gzip compression is to be performed
|
||||||
|
uint16_t hist_bits; //!< Log base 2 of maximum lookback distance, 0 is use default
|
||||||
struct isal_zstate internal_state; //!< Internal state for this stream
|
struct isal_zstate internal_state; //!< Internal state for this stream
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user