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

Last change on this file since 6135 was 6133, checked in by xwa163, 8 months ago
  1. Add sourceCC in multiplexed CC
  2. Remove workaround FakeBasisBits? from ICGrep
  3. Implement Swizzled version of LZParabix
  4. Init checkin for SwizzleByGather? Kernel
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);
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};
73
74struct ByteGrepSignature {
75    ByteGrepSignature(re::RE * re);
76protected:
77    re::RE * const  mRE;
78    std::string     mSignature;
79};
80
81
82class ByteGrepKernel : public ByteGrepSignature, public pablo::PabloKernel {
83public:
84    ByteGrepKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, re::RE * const re, std::vector<std::string> externals = {});
85    std::string makeSignature(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
86    bool isCachable() const override { return true; }
87protected:
88    void generatePabloMethod() override;
89    std::vector<std::string> mExternals;
90};
91   
92struct ByteBitGrepSignature {
93    ByteBitGrepSignature(re::RE * prefix, re::RE * suffix);
94protected:
95    re::RE * const  mPrefixRE;
96    re::RE * const  mSuffixRE;
97    std::string     mSignature;
98};
99
100   
101class ByteBitGrepKernel : public ByteBitGrepSignature, public pablo::PabloKernel {
102public:
103    ByteBitGrepKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, re::RE * const prefix, re::RE * const suffix, std::vector<std::string> externals = {});
104    std::string makeSignature(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
105    bool isCachable() const override { return true; }
106protected:
107    void generatePabloMethod() override;
108    std::vector<std::string> mExternals;
109};
110
111class MatchedLinesKernel : public pablo::PabloKernel {
112public:
113    MatchedLinesKernel(const std::unique_ptr<kernel::KernelBuilder> & builder);
114    bool isCachable() const override { return true; }
115    bool hasSignature() const override { return false; }
116protected:
117    void generatePabloMethod() override;   
118};
119
120class InvertMatchesKernel : public BlockOrientedKernel {
121public:
122    InvertMatchesKernel(const std::unique_ptr<kernel::KernelBuilder> & builder);
123private:
124    void generateDoBlockMethod(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
125};
126
127class PopcountKernel : public pablo::PabloKernel {
128public:
129    PopcountKernel(const std::unique_ptr<kernel::KernelBuilder> & builder);
130    bool isCachable() const override { return true; }
131    bool hasSignature() const override { return false; }
132protected:
133    void generatePabloMethod() override;   
134};
135
136class AbortOnNull final : public MultiBlockKernel {
137public:
138    AbortOnNull(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
139private:
140    void generateMultiBlockLogic(const std::unique_ptr<KernelBuilder> & b, llvm::Value * const numOfStrides) final;
141   
142};
143
144}
145#endif
Note: See TracBrowser for help on using the repository browser.