source: icGREP/icgrep-devel/icgrep/UCD/ucd_compiler.hpp @ 4775

Last change on this file since 4775 was 4736, checked in by nmedfort, 4 years ago

Initial stages of a simple boolean equation reassociation pass.

File size: 2.3 KB
Line 
1#ifndef UCDCOMPILER_HPP
2#define UCDCOMPILER_HPP
3
4#include <vector>
5#include <re/re_cc.h>
6
7namespace cc {
8    class CC_Compiler;
9}
10
11namespace pablo {
12    class PabloBuilder;
13    class PabloAST;
14}
15
16namespace UCD {
17
18class UnicodeSet;
19
20class UCDCompiler {
21
22    using CC = re::CC;
23    using PabloBuilder = pablo::PabloBuilder;
24    using PabloAST = pablo::PabloAST;
25    using codepoint_t = re::codepoint_t;
26    using RangeList = std::vector<re::interval_t>;
27
28public:
29    UCDCompiler(cc::CC_Compiler & ccCompiler);
30
31    PabloAST * generateWithDefaultIfHierarchy(const UnicodeSet & set, PabloBuilder & entry);
32
33    PabloAST * generateWithoutIfHierarchy(const UnicodeSet & set, PabloBuilder & entry);
34
35    PabloAST * generateWithIfHierarchy(const RangeList & ifRanges, const UnicodeSet & set, PabloBuilder & entry);
36
37protected:
38
39    PabloAST * generateWithIfHierarchy(const RangeList & ifRanges, const UnicodeSet & set, const codepoint_t lo, const codepoint_t hi, PabloBuilder & builder);
40
41    PabloAST * generateSubRanges(const UnicodeSet & set, const codepoint_t lo, const codepoint_t hi, PabloBuilder & builder, PabloAST * target);
42
43    PabloAST * sequenceGenerator(const RangeList && ranges, const unsigned byte_no, PabloBuilder & builder, PabloAST * target, PabloAST * prefix);
44
45    PabloAST * sequenceGenerator(const codepoint_t lo, const codepoint_t hi, const unsigned byte_no, PabloBuilder & builder, PabloAST * target, PabloAST * prefix);
46
47    PabloAST * ifTestCompiler(const codepoint_t lo, const codepoint_t hi, PabloBuilder & builder);
48
49    PabloAST * ifTestCompiler(const codepoint_t lo, const codepoint_t hi, const unsigned byte_no, PabloBuilder & builder, PabloAST * target);
50
51    PabloAST * makePrefix(const codepoint_t cp, const unsigned byte_no, PabloBuilder & builder, PabloAST * prefix);
52
53    static RangeList byteDefinitions(const RangeList & list, const unsigned byte_no);
54
55    template <typename RangeListOrUnicodeSet>
56    static RangeList rangeIntersect(const RangeListOrUnicodeSet & list, const codepoint_t lo, const codepoint_t hi);
57
58    static RangeList rangeGaps(const RangeList & list, const codepoint_t lo, const codepoint_t hi);
59
60    static RangeList outerRanges(const RangeList & list);
61
62    static RangeList innerRanges(const RangeList & list);
63
64private:
65    cc::CC_Compiler &       mCharacterClassCompiler;
66    PabloAST *              mSuffixVar;
67};
68
69}
70
71#endif // UCDCOMPILER_HPP
Note: See TracBrowser for help on using the repository browser.