source: icGREP/icgrep-devel/icgrep/kernels/lzparabix/encoder/LZParabixCompressionKernel.h @ 6123

Last change on this file since 6123 was 6123, checked in by xwa163, 13 months ago

Encode BitStream? directly in LZParabix compressed file

File size: 2.3 KB
Line 
1//
2// Created by wxy325 on 2018/6/24.
3//
4
5#ifndef ICGREP_LZPARABIXCOMPRESSIONKERNEL_H
6#define ICGREP_LZPARABIXCOMPRESSIONKERNEL_H
7
8#define HASHLOG (12)
9#define HASHNBCELLS4 (1 << HASHLOG)
10
11#include "kernels/kernel.h"
12#include <string>
13#include <map>
14#include <vector>
15
16
17namespace llvm {
18    class Module;
19    class Function;
20    class BasicBlock;
21    class Value;
22}
23
24namespace IDISA { class IDISA_Builder; }
25
26namespace kernel {
27    struct MatchInfo {
28        llvm::Value* matchOffset;
29        llvm::Value* matchLength;
30        llvm::Value* matchMask;
31        llvm::Value* matchStart;
32    };
33
34
35    class LZParabixCompressionKernel : public SegmentOrientedKernel {
36    public:
37        LZParabixCompressionKernel(const std::unique_ptr<kernel::KernelBuilder> &b);
38    protected:
39        void generateDoSegmentMethod(const std::unique_ptr<KernelBuilder> &b) override;
40        size_t mLzParabixBlockSize;
41
42        void encodeBlock(const std::unique_ptr<KernelBuilder> &b, llvm::Value* inputCursor, llvm::Value* inputEndPos, llvm::Value* outputPos);
43
44    private:
45        void updateCache(const std::unique_ptr<KernelBuilder> &b, llvm::Value* i64BlockGlobalIndex, llvm::Value *initBlockGlobalIndex);
46        inline llvm::Value* hashKey(const std::unique_ptr<KernelBuilder> &b, llvm::Value* v);
47        MatchInfo extractMatchInfo(const std::unique_ptr<KernelBuilder> &b, llvm::Value *cursorPos, llvm::Value *initBlockGlobalIndex, llvm::Value* inputEndPos, llvm::Value* previousCursorPos);
48        std::pair<llvm::Value*, llvm::Value*> getPossibleMatchInfo(const std::unique_ptr<KernelBuilder> &b, llvm::Value* cursorPos);
49
50
51        llvm::Value* appendLiteralSequence(const std::unique_ptr<KernelBuilder> &b, llvm::Value* literalStart, llvm::Value* literalEnd, llvm::Value* tokenOutputPos);
52        llvm::Value* appendMatchSequence(const std::unique_ptr<KernelBuilder> &b, const MatchInfo& matchInfo, llvm::Value* outputPos);
53
54
55        void appendLiteralData(const std::unique_ptr<KernelBuilder> &b, llvm::Value* literalStart, llvm::Value* literalLength);
56        void appendLiteralData(const std::unique_ptr<KernelBuilder> &b, std::vector<llvm::Value*> literalData, llvm::Value* outputLength);
57        void storePendingLiteralData(const std::unique_ptr<KernelBuilder> &b);
58
59    };
60}
61
62#endif //ICGREP_LZPARABIXCOMPRESSIONKERNEL_H
Note: See TracBrowser for help on using the repository browser.