1 ///////////////////////////////////////////////////////////////////////////////
4 /// \brief Filter for IA64 (Itanium) binaries
6 // Authors: Igor Pavlov
9 // This file has been put into the public domain.
10 // You can do whatever you want with this file.
12 ///////////////////////////////////////////////////////////////////////////////
14 #include "simple_private.h"
18 ia64_code(void *simple
lzma_attribute((__unused__
)),
19 uint32_t now_pos
, bool is_encoder
,
20 uint8_t *buffer
, size_t size
)
22 static const uint32_t BRANCH_TABLE
[32] = {
23 0, 0, 0, 0, 0, 0, 0, 0,
24 0, 0, 0, 0, 0, 0, 0, 0,
25 4, 4, 6, 6, 0, 0, 7, 7,
26 4, 4, 0, 0, 4, 4, 0, 0
30 for (i
= 0; i
+ 16 <= size
; i
+= 16) {
31 const uint32_t instr_template
= buffer
[i
] & 0x1F;
32 const uint32_t mask
= BRANCH_TABLE
[instr_template
];
35 for (size_t slot
= 0; slot
< 3; ++slot
, bit_pos
+= 41) {
36 if (((mask
>> slot
) & 1) == 0)
39 const size_t byte_pos
= (bit_pos
>> 3);
40 const uint32_t bit_res
= bit_pos
& 0x7;
41 uint64_t instruction
= 0;
43 for (size_t j
= 0; j
< 6; ++j
)
44 instruction
+= (uint64_t)(
45 buffer
[i
+ j
+ byte_pos
])
48 uint64_t inst_norm
= instruction
>> bit_res
;
50 if (((inst_norm
>> 37) & 0xF) == 0x5
51 && ((inst_norm
>> 9) & 0x7) == 0
52 /* && (inst_norm & 0x3F)== 0 */
54 uint32_t src
= (uint32_t)(
55 (inst_norm
>> 13) & 0xFFFFF);
56 src
|= ((inst_norm
>> 36) & 1) << 20;
62 dest
= now_pos
+ (uint32_t)(i
) + src
;
64 dest
= src
- (now_pos
+ (uint32_t)(i
));
68 inst_norm
&= ~((uint64_t)(0x8FFFFF) << 13);
69 inst_norm
|= (uint64_t)(dest
& 0xFFFFF) << 13;
70 inst_norm
|= (uint64_t)(dest
& 0x100000)
73 instruction
&= (1 << bit_res
) - 1;
74 instruction
|= (inst_norm
<< bit_res
);
76 for (size_t j
= 0; j
< 6; j
++)
77 buffer
[i
+ j
+ byte_pos
] = (uint8_t)(
89 ia64_coder_init(lzma_next_coder
*next
, const lzma_allocator
*allocator
,
90 const lzma_filter_info
*filters
, bool is_encoder
)
92 return lzma_simple_coder_init(next
, allocator
, filters
,
93 &ia64_code
, 0, 16, 16, is_encoder
);
98 lzma_simple_ia64_encoder_init(lzma_next_coder
*next
,
99 const lzma_allocator
*allocator
,
100 const lzma_filter_info
*filters
)
102 return ia64_coder_init(next
, allocator
, filters
, true);
107 lzma_simple_ia64_decoder_init(lzma_next_coder
*next
,
108 const lzma_allocator
*allocator
,
109 const lzma_filter_info
*filters
)
111 return ia64_coder_init(next
, allocator
, filters
, false);