source: icGREP/icgrep-devel/icgrep/re/re_cc.cpp

Last change on this file was 5847, checked in by cameron, 6 months ago

Unify Parabix CC compiler and Direct CC compiler with a common superclass

File size: 2.0 KB
Line 
1/*
2 *  Copyright (c) 2018 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
6
7#include "re_cc.h"
8#include <llvm/Support/Compiler.h>
9#include <sstream>
10
11namespace re {
12
13std::string CC::canonicalName() const {
14    std::stringstream name;
15    name << mAlphabet->getName();
16    name << std::hex;
17    char separator = '_';
18    for (const interval_t i : *this) {
19        name << separator;
20        if (lo_codepoint(i) == hi_codepoint(i)) {
21            name << lo_codepoint(i);
22        }
23        else {
24            name << lo_codepoint(i) << '_' << hi_codepoint(i);
25        }
26        separator = ',';
27    }
28    return name.str();
29}
30   
31CC::CC(const cc::Alphabet * alphabet)
32: RE(ClassTypeId::CC)
33, UnicodeSet()
34, mAlphabet(alphabet) {}
35
36
37CC::CC(const CC & cc)
38: RE(ClassTypeId::CC)
39, UCD::UnicodeSet(cc)
40, mAlphabet(cc.getAlphabet()) {}
41
42
43CC::CC(const codepoint_t codepoint, const cc::Alphabet * alphabet)
44: RE(ClassTypeId::CC)
45, UCD::UnicodeSet(codepoint)
46, mAlphabet(alphabet) {}
47
48
49CC::CC(const codepoint_t lo_codepoint, const codepoint_t hi_codepoint, const cc::Alphabet * alphabet)
50: RE(ClassTypeId::CC)
51, UCD::UnicodeSet(lo_codepoint, hi_codepoint)
52, mAlphabet(alphabet) {}
53
54
55CC::CC(const CC * cc1, const CC * cc2)
56: RE(ClassTypeId::CC)
57, UCD::UnicodeSet(std::move(*cc1 + *cc2))
58, mAlphabet(cc1->getAlphabet()) {
59    assert (cc1->getAlphabet() == cc2->getAlphabet());
60}
61
62
63CC::CC(const UCD::UnicodeSet && set, const cc::Alphabet * alphabet)
64: RE(ClassTypeId::CC)
65, UCD::UnicodeSet(std::move(set))
66, mAlphabet(alphabet) {}
67
68
69CC::CC(std::initializer_list<interval_t>::iterator begin, std::initializer_list<interval_t>::iterator end, const cc::Alphabet * alphabet)
70: RE(ClassTypeId::CC)
71, UCD::UnicodeSet(begin, end)
72, mAlphabet(alphabet) {}
73
74
75CC::CC(const std::vector<interval_t>::iterator begin, const std::vector<interval_t>::iterator end, const cc::Alphabet * alphabet)
76: RE(ClassTypeId::CC)
77, UCD::UnicodeSet(begin, end)
78, mAlphabet(alphabet) {}
79
80}
Note: See TracBrowser for help on using the repository browser.