1717
1818// Not use PMULL instructions, but it is apparently slow.
1919// This is copied from simdjson.
20- pub unsafe fn prefix_xor ( bitmask : u64 ) -> u64 {
21- let mut bitmask = bitmask;
22- bitmask ^= bitmask << 1 ;
23- bitmask ^= bitmask << 2 ;
24- bitmask ^= bitmask << 4 ;
25- bitmask ^= bitmask << 8 ;
26- bitmask ^= bitmask << 16 ;
27- bitmask ^= bitmask << 32 ;
28- bitmask
29- }
20+
3021
3122// We compute whitespace and op separately. If the code later only use one or the
3223// other, given the fact that all functions are aggressively inlined, we can
@@ -43,7 +34,6 @@ pub unsafe fn prefix_xor(bitmask: u64) -> u64 {
4334// just for minification (or just to identify the structural characters),
4435// there is a small untaken optimization opportunity here. We deliberately
4536// do not pick it up.
46- #[ cfg( not( target_feature = "sve2" ) ) ]
4737#[ inline( always) ]
4838pub unsafe fn get_nonspace_bits ( data : & [ u8 ; 64 ] ) -> u64 {
4939 use std:: arch:: aarch64:: * ;
@@ -75,39 +65,3 @@ pub unsafe fn get_nonspace_bits(data: &[u8; 64]) -> u64 {
7565 chunk_nonspace_bits ( vld1q_u8 ( data. as_ptr ( ) . offset ( 48 ) ) ) ,
7666 )
7767}
78-
79- #[ cfg( target_feature = "sve2" ) ]
80- #[ inline( always) ]
81- pub unsafe fn get_nonspace_bits ( data : & [ u8 ; 16 ] ) -> u64 {
82- let mut index: u64 ;
83- // 空白符集合: 0x09 (Tab), 0x0A (LF), 0x0D (CR), 0x20 (Space)
84- let tokens: u32 = 0x090a0d20 ;
85-
86- core:: arch:: asm!(
87- "ptrue p0.b, vl16" ,
88- "ld1b {{z0.b}}, p0/z, [{ptr}]" ,
89- "mov z1.s, {t:w}" , // 广播 4 个空白符到 z1
90-
91- // nmatch 寻找不属于 {09, 0a, 0d, 20} 的字符
92- // 结果存入 p1,p1 中 true 的位置表示“非空白符”
93- "nmatch p1.b, p0/z, z0.b, z1.b" ,
94-
95- // 定位第一个非空白符的位置
96- "brkb p1.b, p0/z, p1.b" , // 截断,只保留第一个 true 之前的位为 true
97- "cntp {idx}, p0, p1.b" , // 统计数量,得到第一个非空白符的 index
98-
99- ptr = in( reg) data. as_ptr( ) ,
100- t = in( reg) tokens,
101- idx = out( reg) index,
102- out( "z0" ) _, out( "z1" ) _,
103- out( "p0" ) _, out( "p1" ) _,
104- ) ;
105-
106- // 如果 index < 16,返回 1 << index,使外部 trailing_zeros() 拿到正确偏移
107- // 如果 index == 16,返回 0,触发外部 skip_space 的“全空白”跳过逻辑
108- if index < 16 {
109- 1u64 << index
110- } else {
111- 0
112- }
113- }
0 commit comments