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

Last change on this file since 6237 was 6184, checked in by nmedfort, 10 months ago

Initial version of PipelineKernel? + revised StreamSet? model.

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