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

Last change on this file since 5895 was 5889, checked in by cameron, 18 months ago

BitByteGrepKernel? initial check-in

File size: 3.2 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
10namespace IDISA { class IDISA_Builder; }
11namespace re { class RE; }
12namespace cc { class Alphabet; }
13namespace kernel {
14
15   
16class RequiredStreams_UTF8 : public pablo::PabloKernel {
17public:
18    RequiredStreams_UTF8(const std::unique_ptr<kernel::KernelBuilder> & kb);
19    bool isCachable() const override { return true; }
20    bool hasSignature() const override { return false; }
21protected:
22    void generatePabloMethod() override;
23};
24
25class RequiredStreams_UTF16 : public pablo::PabloKernel {
26public:
27    RequiredStreams_UTF16(const std::unique_ptr<kernel::KernelBuilder> & kb);
28    bool isCachable() const override { return true; }
29    bool hasSignature() const override { return false; }
30protected:
31    void generatePabloMethod() override;
32};
33
34
35struct ICGrepSignature {
36    ICGrepSignature(re::RE * re_ast);
37protected:
38    re::RE * const  mRE;
39    std::string     mSignature;
40};
41
42   
43class ICGrepKernel : public ICGrepSignature, public pablo::PabloKernel {
44public:
45    ICGrepKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, re::RE * const re_ast, std::vector<std::string> externals, std::vector<cc::Alphabet *> alphabets = {});
46    std::string makeSignature(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
47    bool isCachable() const override { return true; }
48protected:
49    void generatePabloMethod() override;
50    std::vector<std::string> mExternals;
51    std::vector<cc::Alphabet *> mAlphabets;
52};
53
54struct ByteBitGrepSignature {
55    ByteBitGrepSignature(re::RE * prefix, re::RE * suffix);
56protected:
57    re::RE * const  mPrefixRE;
58    re::RE * const  mSuffixRE;
59    std::string     mSignature;
60};
61
62   
63class ByteBitGrepKernel : public ByteBitGrepSignature, public pablo::PabloKernel {
64public:
65    ByteBitGrepKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, re::RE * const prefix, re::RE * const suffix, std::vector<std::string> externals = {});
66    std::string makeSignature(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
67    bool isCachable() const override { return true; }
68protected:
69    void generatePabloMethod() override;
70    std::vector<std::string> mExternals;
71};
72
73class MatchedLinesKernel : public pablo::PabloKernel {
74public:
75    MatchedLinesKernel(const std::unique_ptr<kernel::KernelBuilder> & builder);
76    bool isCachable() const override { return true; }
77    bool hasSignature() const override { return false; }
78protected:
79    void generatePabloMethod() override;   
80};
81
82class InvertMatchesKernel : public BlockOrientedKernel {
83public:
84    InvertMatchesKernel(const std::unique_ptr<kernel::KernelBuilder> & builder);
85private:
86    void generateDoBlockMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
87};
88
89class PopcountKernel : public pablo::PabloKernel {
90public:
91    PopcountKernel(const std::unique_ptr<kernel::KernelBuilder> & builder);
92    bool isCachable() const override { return true; }
93    bool hasSignature() const override { return false; }
94protected:
95    void generatePabloMethod() override;   
96};
97   
98}
99#endif
Note: See TracBrowser for help on using the repository browser.