1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use super::{
    shared::{mask_32, vector_128},
    *,
};
use crate::{
    bin_u32,
    classification::mask::m32,
    classification::{QuoteClassifiedBlock, ResumeClassifierBlockState, ResumeClassifierState},
    debug,
    input::{error::InputError, InputBlock, InputBlockIterator},
    FallibleIterator,
};

super::shared::structural_classifier!(Ssse3Classifier32, BlockSsse3Classifier32, mask_32, 32, u32);

struct BlockSsse3Classifier32 {
    internal_classifier: vector_128::BlockClassifier128,
}

impl BlockSsse3Classifier32 {
    #[inline]
    fn new() -> Self {
        Self {
            // SAFETY: target feature invariant
            internal_classifier: unsafe { vector_128::BlockClassifier128::new() },
        }
    }

    #[target_feature(enable = "ssse3")]
    #[inline]
    unsafe fn classify<'i, B: InputBlock<'i, 32>>(
        &mut self,
        quote_classified_block: QuoteClassifiedBlock<B, u32, 32>,
    ) -> mask_32::StructuralsBlock<B> {
        let (block1, block2) = quote_classified_block.block.halves();
        let classification1 = self.internal_classifier.classify_block(block1);
        let classification2 = self.internal_classifier.classify_block(block2);

        let structural = m32::combine_16(classification1.structural, classification2.structural);
        let nonquoted_structural = structural & !quote_classified_block.within_quotes_mask;

        bin_u32!("structural", structural);
        bin_u32!("nonquoted_structural", nonquoted_structural);

        mask_32::StructuralsBlock::new(quote_classified_block, nonquoted_structural)
    }
}