Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Apple Silicon Mac support #164

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c7328c8
Fixed clang as assembly
cielavenir Nov 21, 2020
d6ec9e6
fixed clang as build
cielavenir Nov 21, 2020
e904c34
Fixed addressing assembly
cielavenir Nov 24, 2020
afa64d0
It should be fine to enable pmull always on Apple Silicon
cielavenir Nov 24, 2020
6b59dac
Fixed assembly (compared with objdump)
cielavenir Nov 25, 2020
75115c8
Merge branch 'fix_clang_as' into fix_mach
cielavenir Nov 25, 2020
d68f604
Fix typo, thanks @yuhaoth
cielavenir Dec 5, 2020
ecf1e81
Changed the conditional macro to __APPLE__
cielavenir Dec 6, 2020
84d2132
Rewritten dispatcher using sysctlbyname
cielavenir Dec 6, 2020
30b9639
Use __USER_LABEL_PREFIX__
cielavenir May 10, 2021
df8eb0a
Use __TEXT,__const as readonly section
cielavenir May 10, 2021
22211f8
Merge remote-tracking branch 'origin/master' into HEAD
cielavenir May 10, 2021
5eab6c1
Fixed erasure_code build on mach
cielavenir May 10, 2021
599615e
Fix indent
cielavenir May 10, 2021
cd25b1f
Merge commit '642ef36' into fix_mach
cielavenir Mar 6, 2022
2d7dd04
Merge remote-tracking branch 'origin/master' into fix_mach
cielavenir Mar 6, 2022
6875af9
Reworked on dispatcher
cielavenir Mar 6, 2022
e31c00f
fix func decl
cielavenir Mar 6, 2022
3646af7
use ASM_DEF_RODATA macro
cielavenir Mar 6, 2022
5bce07f
add comment
cielavenir Mar 9, 2022
b878e6d
Merge remote-tracking branch 'origin/master' into fix_mach
cielavenir Jul 20, 2022
acd48c0
fix ASM_DEF_RODATA include
cielavenir Jul 22, 2022
855112d
Merge remote-tracking branch 'ciel/fix_mach' into HEAD
cielavenir Jul 22, 2022
225b6bd
Fix q_fold_const load
cielavenir Jul 22, 2022
de6af92
Merge remote-tracking branch 'ciel/master' into fix_mach
cielavenir Oct 27, 2022
825d080
fix fold_constant decl
cielavenir Oct 27, 2022
33a7a42
fixed another fold_constant decl
cielavenir Oct 27, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 32 additions & 6 deletions crc/aarch64/crc16_t10dif_copy_pmull.S
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#########################################################################

#include "../include/aarch64_label.h"

.arch armv8-a+crc+crypto
.text
.align 3
.global crc16_t10dif_copy_pmull
.global cdecl(crc16_t10dif_copy_pmull)
#ifndef __APPLE__
.type crc16_t10dif_copy_pmull, %function
#endif

/* uint16_t crc16_t10dif_pmull(uint16_t seed, uint8_t *buf, uint64_t len) */

Expand Down Expand Up @@ -67,7 +71,7 @@ x_crc16tab .req x5
x_src_saved .req x0
x_dst_saved .req x12

crc16_t10dif_copy_pmull:
cdecl(crc16_t10dif_copy_pmull):
cmp x_len, 63
sub sp, sp, #16
uxth w_seed, w_seed
Expand All @@ -80,11 +84,19 @@ crc16_t10dif_copy_pmull:
cmp x_len, x_tmp
bls .end

#ifndef __APPLE__
sxtw x_counter, w_counter
adrp x_crc16tab, .LANCHOR0
sub x_src, x_src, x_counter
sub x_dst, x_dst, x_counter
add x_crc16tab, x_crc16tab, :lo12:.LANCHOR0
#else
sxtw x_counter, w_counter
adrp x_crc16tab, .LANCHOR0@PAGE
sub x_src, x_src, x_counter
sub x_dst, x_dst, x_counter
add x_crc16tab, x_crc16tab, .LANCHOR0@PAGEOFF
#endif

.align 2
.crc_table_loop:
Expand Down Expand Up @@ -145,8 +157,13 @@ v_tmp3 .req v16
stp q_x0, q_x1, [x_dst]
stp q_x2, q_x3, [x_dst, 32]

#ifndef __APPLE__
adrp x_tmp, .shuffle_mask_lanchor
ldr q_permutation, [x_tmp, :lo12:.shuffle_mask_lanchor]
#else
adrp x_tmp, .shuffle_mask_lanchor@PAGE
ldr q_permutation, [x_tmp, .shuffle_mask_lanchor@PAGEOFF]
#endif

tbl v_tmp1.16b, {v_x0.16b}, v7.16b
eor v_x0.16b, v_tmp3.16b, v_tmp1.16b
Expand Down Expand Up @@ -193,7 +210,7 @@ v_tmp1_x3 .req v27
q_fold_const .req q17
v_fold_const .req v17

ldr q_fold_const, =0x371d00000000000087e70000;
ldr q_fold_const, fold_constant

.align 2
.crc_fold_loop:
Expand Down Expand Up @@ -358,23 +375,32 @@ v_br1 .req v5
umov x0, v_x0.d[0]
ubfx x0, x0, 16, 16
b .crc_table_loop_pre

#ifndef __APPLE__
.size crc16_t10dif_copy_pmull, .-crc16_t10dif_copy_pmull
#endif

.section .rodata

ASM_DEF_RODATA
.align 4
fold_constant:
.word 0x87e70000
.word 0x00000000
.word 0x371d0000
.word 0x00000000
.shuffle_mask_lanchor = . + 0
#ifndef __APPLE__
.type shuffle_mask, %object
.size shuffle_mask, 16
#endif
shuffle_mask:
.byte 15, 14, 13, 12, 11, 10, 9, 8
.byte 7, 6, 5, 4, 3, 2, 1, 0

.align 4
.LANCHOR0 = . + 0
#ifndef __APPLE__
.type crc16tab, %object
.size crc16tab, 512
#endif
crc16tab:
.hword 0x0000, 0x8bb7, 0x9cd9, 0x176e, 0xb205, 0x39b2, 0x2edc, 0xa56b
.hword 0xEFBD, 0x640a, 0x7364, 0xf8d3, 0x5db8, 0xd60f, 0xc161, 0x4ad6
Expand Down
36 changes: 31 additions & 5 deletions crc/aarch64/crc16_t10dif_pmull.S
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#########################################################################

#include "../include/aarch64_label.h"

.arch armv8-a+crc+crypto
.text
.align 3
.global crc16_t10dif_pmull
.global cdecl(crc16_t10dif_pmull)
#ifndef __APPLE__
.type crc16_t10dif_pmull, %function
#endif

/* uint16_t crc16_t10dif_pmull(uint16_t seed, uint8_t *buf, uint64_t len) */

Expand Down Expand Up @@ -65,7 +69,7 @@ x_counter .req x3
x_crc16tab .req x4
x_buf_saved .req x0

crc16_t10dif_pmull:
cdecl(crc16_t10dif_pmull):
cmp x_len, 63
sub sp, sp, #16
uxth w_seed, w_seed
Expand All @@ -78,10 +82,17 @@ crc16_t10dif_pmull:
cmp x_len, x_tmp
bls .end

#ifndef __APPLE__
sxtw x_counter, w_counter
adrp x_crc16tab, .LANCHOR0
sub x_buf, x_buf, x_counter
add x_crc16tab, x_crc16tab, :lo12:.LANCHOR0
#else
sxtw x_counter, w_counter
adrp x_crc16tab, .LANCHOR0@PAGE
sub x_buf, x_buf, x_counter
add x_crc16tab, x_crc16tab, .LANCHOR0@PAGEOFF
#endif

.align 2
.crc_table_loop:
Expand Down Expand Up @@ -137,8 +148,13 @@ v_tmp3 .req v16
ldp q_x0, q_x1, [x_buf]
ldp q_x2, q_x3, [x_buf, 32]

#ifndef __APPLE__
adrp x_tmp, .shuffle_mask_lanchor
ldr q7, [x_tmp, :lo12:.shuffle_mask_lanchor]
#else
adrp x_tmp, .shuffle_mask_lanchor@PAGE
ldr q7, [x_tmp, .shuffle_mask_lanchor@PAGEOFF]
#endif

tbl v_tmp1.16b, {v_x0.16b}, v7.16b
eor v_x0.16b, v_tmp3.16b, v_tmp1.16b
Expand Down Expand Up @@ -185,7 +201,7 @@ v_tmp1_x3 .req v27
q_fold_const .req q17
v_fold_const .req v17

ldr q_fold_const, =0x371d00000000000087e70000;
ldr q_fold_const, fold_constant

.align 2
.crc_fold_loop:
Expand Down Expand Up @@ -344,22 +360,32 @@ v_br1 .req v5
ubfx x0, x0, 16, 16
b .crc_table_loop_pre

#ifndef __APPLE__
.size crc16_t10dif_pmull, .-crc16_t10dif_pmull
#endif

.section .rodata

ASM_DEF_RODATA
.align 4
fold_constant:
.word 0x87e70000
.word 0x00000000
.word 0x371d0000
.word 0x00000000
.shuffle_mask_lanchor = . + 0
#ifndef __APPLE__
.type shuffle_mask, %object
.size shuffle_mask, 16
#endif
shuffle_mask:
.byte 15, 14, 13, 12, 11, 10, 9, 8
.byte 7, 6, 5, 4, 3, 2, 1, 0

.align 4
.LANCHOR0 = . + 0
#ifndef __APPLE__
.type crc16tab, %object
.size crc16tab, 512
#endif
crc16tab:
.hword 0x0000, 0x8bb7, 0x9cd9, 0x176e, 0xb205, 0x39b2, 0x2edc, 0xa56b
.hword 0xEFBD, 0x640a, 0x7364, 0xf8d3, 0x5db8, 0xd60f, 0xc161, 0x4ad6
Expand Down
3 changes: 1 addition & 2 deletions crc/aarch64/crc32_aarch64_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************/



#include "../include/aarch64_label.h"

.macro crc32_hw_common poly_type

Expand Down
2 changes: 1 addition & 1 deletion crc/aarch64/crc32_common_mix_neoverse_n1.S
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************/

#include "../include/aarch64_label.h"

.macro declare_var_vector_reg name:req,reg:req
\name\()_q .req q\reg
Expand Down Expand Up @@ -429,4 +430,3 @@ start_final:
.endif
ret
.endm

8 changes: 6 additions & 2 deletions crc/aarch64/crc32_gzip_refl_3crc_fold.S
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,12 @@
);
*/

.global crc32_gzip_refl_3crc_fold
.global cdecl(crc32_gzip_refl_3crc_fold)
#ifndef __APPLE__
.type crc32_gzip_refl_3crc_fold, %function
crc32_gzip_refl_3crc_fold:
#endif
cdecl(crc32_gzip_refl_3crc_fold):
crc32_3crc_fold crc32
#ifndef __APPLE__
.size crc32_gzip_refl_3crc_fold, .-crc32_gzip_refl_3crc_fold
#endif
8 changes: 6 additions & 2 deletions crc/aarch64/crc32_gzip_refl_crc_ext.S
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@
* uint32_t crc32_gzip_refl_crc_ext(const unsigned char *BUF,
* uint64_t LEN,uint32_t wCRC);
*/
.global crc32_gzip_refl_crc_ext
.global cdecl(crc32_gzip_refl_crc_ext)
#ifndef __APPLE__
.type crc32_gzip_refl_crc_ext, %function
crc32_gzip_refl_crc_ext:
#endif
cdecl(crc32_gzip_refl_crc_ext):
crc32_hw_common crc32
#ifndef __APPLE__
.size crc32_gzip_refl_crc_ext, .-crc32_gzip_refl_crc_ext
#endif
1 change: 1 addition & 0 deletions crc/aarch64/crc32_gzip_refl_pmull.S
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#########################################################################

#include "../include/aarch64_label.h"
#include "crc32_gzip_refl_pmull.h"
#include "crc32_refl_common_pmull.h"

Expand Down
4 changes: 3 additions & 1 deletion crc/aarch64/crc32_gzip_refl_pmull.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@
.equ br_high_b2, 0x1

.text
.section .rodata
ASM_DEF_RODATA
.align 4
.set .lanchor_crc_tab,. + 0
#ifndef __APPLE__
.type crc32_table_gzip_refl, %object
.size crc32_table_gzip_refl, 1024
#endif
crc32_table_gzip_refl:
.word 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3
.word 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91
Expand Down
1 change: 1 addition & 0 deletions crc/aarch64/crc32_ieee_norm_pmull.S
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#########################################################################

#include "../include/aarch64_label.h"
#include "crc32_ieee_norm_pmull.h"
#include "crc32_norm_common_pmull.h"

Expand Down
4 changes: 3 additions & 1 deletion crc/aarch64/crc32_ieee_norm_pmull.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@
.equ br_high_b2, 0x1

.text
.section .rodata
ASM_DEF_RODATA
.align 4
.set .lanchor_crc_tab,. + 0
#ifndef __APPLE__
.type crc32_table_ieee_norm, %object
.size crc32_table_ieee_norm, 1024
#endif
crc32_table_ieee_norm:
.word 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005
.word 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd
Expand Down
8 changes: 6 additions & 2 deletions crc/aarch64/crc32_iscsi_3crc_fold.S
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,12 @@

*/

.global crc32_iscsi_3crc_fold
.global cdecl(crc32_iscsi_3crc_fold)
#ifndef __APPLE__
.type crc32_iscsi_3crc_fold, %function
crc32_iscsi_3crc_fold:
#endif
cdecl(crc32_iscsi_3crc_fold):
crc32_3crc_fold crc32c
#ifndef __APPLE__
.size crc32_iscsi_3crc_fold, .-crc32_iscsi_3crc_fold
#endif
8 changes: 6 additions & 2 deletions crc/aarch64/crc32_iscsi_crc_ext.S
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@
* uint32_t crc32_iscsi_crc_ext(const unsigned char *BUF,
* uint64_t LEN,uint32_t wCRC);
*/
.global crc32_iscsi_crc_ext
.global cdecl(crc32_iscsi_crc_ext)
#ifndef __APPLE__
.type crc32_iscsi_crc_ext, %function
crc32_iscsi_crc_ext:
#endif
cdecl(crc32_iscsi_crc_ext):
crc32_hw_common crc32c
#ifndef __APPLE__
.size crc32_iscsi_crc_ext, .-crc32_iscsi_crc_ext
#endif
9 changes: 6 additions & 3 deletions crc/aarch64/crc32_iscsi_refl_pmull.S
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#########################################################################

#include "../include/aarch64_label.h"
#include "crc32_iscsi_refl_pmull.h"
#include "crc32_refl_common_pmull.h"

Expand All @@ -35,9 +36,11 @@ crc32_refl_func crc32_iscsi_refl_pmull_internal
.arch armv8-a+crc+crypto
.text
.align 3
.global crc32_iscsi_refl_pmull
.global cdecl(crc32_iscsi_refl_pmull)
#ifndef __APPLE__
.type crc32_iscsi_refl_pmull, %function
crc32_iscsi_refl_pmull:
#endif
cdecl(crc32_iscsi_refl_pmull):
stp x29, x30, [sp, -32]!
mov x29, sp

Expand All @@ -47,7 +50,7 @@ crc32_iscsi_refl_pmull:
mov w0, w7
mvn w0, w0

bl crc32_iscsi_refl_pmull_internal
bl cdecl(crc32_iscsi_refl_pmull_internal)
mvn w0, w0
ldp x29, x30, [sp], 32
ret
5 changes: 4 additions & 1 deletion crc/aarch64/crc32_iscsi_refl_pmull.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@
.equ br_high_b2, 0x0

.text
.section .rodata

ASM_DEF_RODATA
.align 4
.set .lanchor_crc_tab,. + 0
#ifndef __APPLE__
.type crc32_table_iscsi_refl, %object
.size crc32_table_iscsi_refl, 1024
#endif
crc32_table_iscsi_refl:
.word 0x00000000, 0xF26B8303, 0xE13B70F7, 0x1350F3F4, 0xC79A971F, 0x35F1141C, 0x26A1E7E8, 0xD4CA64EB
.word 0x8AD958CF, 0x78B2DBCC, 0x6BE22838, 0x9989AB3B, 0x4D43CFD0, 0xBF284CD3, 0xAC78BF27, 0x5E133C24
Expand Down
Loading