source: icGREP/icgrep-devel/icgrep/re/re_multiplex.cpp @ 6173

Last change on this file since 6173 was 6173, checked in by nmedfort, 7 months ago

Added RE_Inspector.

Migrated RE passes to RE_Transformer.

Incorporated Memoizer functionality into RE_Transformer/Inspector.

Removed Memoizer.

Bug fix for unicode_set.

File size: 1.7 KB
Line 
1#include "re_multiplex.h"
2#include <re/re_name.h>
3#include <re/re_alt.h>
4#include <re/re_cc.h>
5#include <re/re_seq.h>
6#include <re/re_rep.h>
7#include <re/re_diff.h>
8#include <re/re_intersect.h>
9#include <re/re_assertion.h>
10#include <re/re_group.h>
11#include <re/re_analysis.h>
12#include <re/printer_re.h>
13#include <re/re_toolchain.h>
14#include <UCD/ucd_compiler.hpp>
15#include <UCD/resolve_properties.h>
16#include <boost/container/flat_set.hpp>
17#include <cc/alphabet.h>
18#include <cc/multiplex_CCs.h>
19#include <sstream>
20#include <iostream>
21#include <functional>
22#include <llvm/Support/raw_ostream.h>
23
24using namespace boost::container;
25using namespace llvm;
26
27namespace re {
28 
29
30class CC_multiplexer : public RE_Transformer {
31public:
32    CC_multiplexer(cc::MultiplexedAlphabet * mpx) :
33        RE_Transformer("Multiplex_" + mpx->getName()), mMultiplexedAlphabet(mpx) {}
34    RE * transformCC(CC *) override;
35    RE * transformName(Name *) override;
36private:
37    cc::MultiplexedAlphabet * mMultiplexedAlphabet;
38};
39
40RE * CC_multiplexer::transformCC(CC * cc) {
41    if (cc->getAlphabet() == mMultiplexedAlphabet->getSourceAlphabet()) {
42        return mMultiplexedAlphabet->transformCC(cc);
43    }
44    return cc;
45}
46
47RE * CC_multiplexer::transformName(Name * name) {
48    if (LLVM_LIKELY(name->getDefinition() != nullptr)) {
49        RE * xfrm = transform(name->getDefinition());
50        if (name->getType() == Name::Type::ZeroWidth)
51            return makeZeroWidth(name->getName(), xfrm);
52        else if (name->getType() == Name::Type::Capture)
53            return makeCapture(name->getName(), xfrm);
54        else
55            return makeName(name->getName(), xfrm);
56    }
57    return name;
58}
59
60RE * transformCCs(cc::MultiplexedAlphabet * mpx, RE * re) {
61    return CC_multiplexer(mpx).transformRE(re);
62} 
63
64}
Note: See TracBrowser for help on using the repository browser.