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

Last change on this file since 5989 was 5989, checked in by cameron, 12 months ago

AbortOnNull? functionality - initial check-in

File size: 4.7 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 UnicodeNonFinalKernel : public pablo::PabloKernel {
17public:
18    UnicodeNonFinalKernel(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 UnicodeLineBreakKernel : public pablo::PabloKernel {
26public:
27    UnicodeLineBreakKernel(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
34class RequiredStreams_UTF8 : public pablo::PabloKernel {
35public:
36    RequiredStreams_UTF8(const std::unique_ptr<kernel::KernelBuilder> & kb);
37    bool isCachable() const override { return true; }
38    bool hasSignature() const override { return false; }
39protected:
40    void generatePabloMethod() override;
41};
42
43class RequiredStreams_UTF16 : public pablo::PabloKernel {
44public:
45    RequiredStreams_UTF16(const std::unique_ptr<kernel::KernelBuilder> & kb);
46    bool isCachable() const override { return true; }
47    bool hasSignature() const override { return false; }
48protected:
49    void generatePabloMethod() override;
50};
51
52
53struct ICGrepSignature {
54    ICGrepSignature(re::RE * re_ast);
55protected:
56    re::RE * const  mRE;
57    std::string     mSignature;
58};
59
60   
61class ICGrepKernel : public ICGrepSignature, public pablo::PabloKernel {
62public:
63    ICGrepKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, re::RE * const re_ast, std::vector<std::string> externals, std::vector<cc::Alphabet *> alphabets = {});
64    std::string makeSignature(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
65    bool isCachable() const override { return true; }
66protected:
67    void generatePabloMethod() override;
68    std::vector<std::string> mExternals;
69    std::vector<cc::Alphabet *> mAlphabets;
70};
71
72struct ByteGrepSignature {
73    ByteGrepSignature(re::RE * re);
74protected:
75    re::RE * const  mRE;
76    std::string     mSignature;
77};
78
79
80class ByteGrepKernel : public ByteGrepSignature, public pablo::PabloKernel {
81public:
82    ByteGrepKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, re::RE * const re, std::vector<std::string> externals = {});
83    std::string makeSignature(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
84    bool isCachable() const override { return true; }
85protected:
86    void generatePabloMethod() override;
87    std::vector<std::string> mExternals;
88};
89   
90struct ByteBitGrepSignature {
91    ByteBitGrepSignature(re::RE * prefix, re::RE * suffix);
92protected:
93    re::RE * const  mPrefixRE;
94    re::RE * const  mSuffixRE;
95    std::string     mSignature;
96};
97
98   
99class ByteBitGrepKernel : public ByteBitGrepSignature, public pablo::PabloKernel {
100public:
101    ByteBitGrepKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, re::RE * const prefix, re::RE * const suffix, std::vector<std::string> externals = {});
102    std::string makeSignature(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
103    bool isCachable() const override { return true; }
104protected:
105    void generatePabloMethod() override;
106    std::vector<std::string> mExternals;
107};
108
109class MatchedLinesKernel : public pablo::PabloKernel {
110public:
111    MatchedLinesKernel(const std::unique_ptr<kernel::KernelBuilder> & builder);
112    bool isCachable() const override { return true; }
113    bool hasSignature() const override { return false; }
114protected:
115    void generatePabloMethod() override;   
116};
117
118class InvertMatchesKernel : public BlockOrientedKernel {
119public:
120    InvertMatchesKernel(const std::unique_ptr<kernel::KernelBuilder> & builder);
121private:
122    void generateDoBlockMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
123};
124
125class PopcountKernel : public pablo::PabloKernel {
126public:
127    PopcountKernel(const std::unique_ptr<kernel::KernelBuilder> & builder);
128    bool isCachable() const override { return true; }
129    bool hasSignature() const override { return false; }
130protected:
131    void generatePabloMethod() override;   
132};
133
134class AbortOnNull final : public MultiBlockKernel {
135public:
136    AbortOnNull(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
137private:
138    void generateMultiBlockLogic(const std::unique_ptr<KernelBuilder> & b, llvm::Value * const numOfStrides) final;
139   
140};
141
142}
143#endif
Note: See TracBrowser for help on using the repository browser.