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

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

Start of work to make the pablo compiler reenterant. Fixed bug that prevented it from using Less optimization level.

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 * generateWithIfHierarchy(const RangeList & ifRanges, const UnicodeSet & set, PabloBuilder & entry);
34
35protected:
36
37    PabloAST * generateWithIfHierarchy(const RangeList & ifRanges, const UnicodeSet & set, const codepoint_t lo, const codepoint_t hi, PabloBuilder & builder);
38
39    PabloAST * generateSubRanges(const UnicodeSet & set, const codepoint_t lo, const codepoint_t hi, PabloBuilder & builder, PabloAST * target);
40
41    PabloAST * sequenceGenerator(const RangeList && ranges, const unsigned byte_no, PabloBuilder & builder, PabloAST * target, PabloAST * prefix);
42
43    PabloAST * sequenceGenerator(const codepoint_t lo, const codepoint_t hi, const unsigned byte_no, PabloBuilder & builder, PabloAST * target, PabloAST * prefix);
44
45    PabloAST * ifTestCompiler(const codepoint_t lo, const codepoint_t hi, PabloBuilder & builder);
46
47    PabloAST * ifTestCompiler(const codepoint_t lo, const codepoint_t hi, const unsigned byte_no, PabloBuilder & builder, PabloAST * target);
48
49    PabloAST * makePrefix(const codepoint_t cp, const unsigned byte_no, PabloBuilder & builder, PabloAST * prefix);
50
51    static RangeList byteDefinitions(const RangeList & list, const unsigned byte_no);
52
53    template <typename RangeListOrUnicodeSet>
54    static RangeList rangeIntersect(const RangeListOrUnicodeSet & list, const codepoint_t lo, const codepoint_t hi);
55
56    static RangeList rangeGaps(const RangeList & list, const codepoint_t lo, const codepoint_t hi);
57
58    static RangeList outerRanges(const RangeList & list);
59
60    static RangeList innerRanges(const RangeList & list);
61
62private:
63    cc::CC_Compiler &       mCharacterClassCompiler;
64    PabloAST *              mSuffixVar;
65};
66
67}
68
69#endif // UCDCOMPILER_HPP
Note: See TracBrowser for help on using the repository browser.