source: icGREP/icgrep-devel/icgrep/kernels/grep_kernel.h @ 6127

Last change on this file since 6127 was 6127, checked in by xwa163, 10 months ago
  1. Improve RE_Compiler for multiplexing
  2. Use faster approach for LineBreakStream? generating in LZParabix_grep
File size: 4.8 KB
Line 
1/*
2 *  Copyright (c) 2017 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 */
5#ifndef GREP_KERNEL_H
6#define GREP_KERNEL_H
7
8#include <pablo/pablo_kernel.h>  // for PabloKernel
9#include <cc/alphabet.h>
10
11namespace IDISA { class IDISA_Builder; }
12namespace re { class RE; }
13namespace cc { class Alphabet; }
14namespace kernel {
15
16   
17class UnicodeNonFinalKernel : public pablo::PabloKernel {
18public:
19    UnicodeNonFinalKernel(const std::unique_ptr<kernel::KernelBuilder> & kb);
20    bool isCachable() const override { return true; }
21    bool hasSignature() const override { return false; }
22protected:
23    void generatePabloMethod() override;
24};
25
26class UnicodeLineBreakKernel : public pablo::PabloKernel {
27public:
28    UnicodeLineBreakKernel(const std::unique_ptr<kernel::KernelBuilder> & kb);
29    bool isCachable() const override { return true; }
30    bool hasSignature() const override { return false; }
31protected:
32    void generatePabloMethod() override;
33};
34
35class RequiredStreams_UTF8 : public pablo::PabloKernel {
36public:
37    RequiredStreams_UTF8(const std::unique_ptr<kernel::KernelBuilder> & kb);
38    bool isCachable() const override { return true; }
39    bool hasSignature() const override { return false; }
40protected:
41    void generatePabloMethod() override;
42};
43
44class RequiredStreams_UTF16 : public pablo::PabloKernel {
45public:
46    RequiredStreams_UTF16(const std::unique_ptr<kernel::KernelBuilder> & kb);
47    bool isCachable() const override { return true; }
48    bool hasSignature() const override { return false; }
49protected:
50    void generatePabloMethod() override;
51};
52
53
54struct ICGrepSignature {
55    ICGrepSignature(re::RE * re_ast);
56protected:
57    re::RE * const  mRE;
58    std::string     mSignature;
59};
60
61   
62class ICGrepKernel : public ICGrepSignature, public pablo::PabloKernel {
63public:
64    ICGrepKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, re::RE * const re_ast, std::vector<std::string> externals, std::vector<cc::Alphabet *> alphabets = {}, cc::BitNumbering basisSetNumbering = cc::BitNumbering::LittleEndian, bool fakeBasisBits = false);
65    std::string makeSignature(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
66    bool isCachable() const override { return true; }
67protected:
68    void generatePabloMethod() override;
69    std::vector<std::string> mExternals;
70    std::vector<cc::Alphabet *> mAlphabets;
71    cc::BitNumbering mBasisSetNumbering;
72    bool mFakeBasisBits;
73};
74
75struct ByteGrepSignature {
76    ByteGrepSignature(re::RE * re);
77protected:
78    re::RE * const  mRE;
79    std::string     mSignature;
80};
81
82
83class ByteGrepKernel : public ByteGrepSignature, public pablo::PabloKernel {
84public:
85    ByteGrepKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, re::RE * const re, std::vector<std::string> externals = {});
86    std::string makeSignature(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
87    bool isCachable() const override { return true; }
88protected:
89    void generatePabloMethod() override;
90    std::vector<std::string> mExternals;
91};
92   
93struct ByteBitGrepSignature {
94    ByteBitGrepSignature(re::RE * prefix, re::RE * suffix);
95protected:
96    re::RE * const  mPrefixRE;
97    re::RE * const  mSuffixRE;
98    std::string     mSignature;
99};
100
101   
102class ByteBitGrepKernel : public ByteBitGrepSignature, public pablo::PabloKernel {
103public:
104    ByteBitGrepKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, re::RE * const prefix, re::RE * const suffix, std::vector<std::string> externals = {});
105    std::string makeSignature(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
106    bool isCachable() const override { return true; }
107protected:
108    void generatePabloMethod() override;
109    std::vector<std::string> mExternals;
110};
111
112class MatchedLinesKernel : public pablo::PabloKernel {
113public:
114    MatchedLinesKernel(const std::unique_ptr<kernel::KernelBuilder> & builder);
115    bool isCachable() const override { return true; }
116    bool hasSignature() const override { return false; }
117protected:
118    void generatePabloMethod() override;   
119};
120
121class InvertMatchesKernel : public BlockOrientedKernel {
122public:
123    InvertMatchesKernel(const std::unique_ptr<kernel::KernelBuilder> & builder);
124private:
125    void generateDoBlockMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
126};
127
128class PopcountKernel : public pablo::PabloKernel {
129public:
130    PopcountKernel(const std::unique_ptr<kernel::KernelBuilder> & builder);
131    bool isCachable() const override { return true; }
132    bool hasSignature() const override { return false; }
133protected:
134    void generatePabloMethod() override;   
135};
136
137class AbortOnNull final : public MultiBlockKernel {
138public:
139    AbortOnNull(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
140private:
141    void generateMultiBlockLogic(const std::unique_ptr<KernelBuilder> & b, llvm::Value * const numOfStrides) final;
142   
143};
144
145}
146#endif
Note: See TracBrowser for help on using the repository browser.