source: icGREP/icgrep-devel/icgrep/re/re_simplifier.cpp @ 5350

Last change on this file since 5350 was 5267, checked in by nmedfort, 3 years ago

Code clean-up. Removed Pablo Call, SetIthBit? and Prototype.

File size: 1.5 KB
Line 
1#include "re_simplifier.h"
2#include <re/re_name.h>
3#include <re/re_any.h>
4#include <re/re_start.h>
5#include <re/re_end.h>
6#include <re/re_alt.h>
7#include <re/re_cc.h>
8#include <re/re_seq.h>
9#include <re/re_rep.h>
10#include <re/re_diff.h>
11#include <re/re_intersect.h>
12#include <re/re_assertion.h>
13#include <re/re_analysis.h>
14#include <algorithm>
15#include <memory>
16#include <queue>
17
18using namespace llvm;
19
20namespace re {
21
22RE * RE_Simplifier::simplify(RE * re) {
23    if (Alt * alt = dyn_cast<Alt>(re)) {
24        std::vector<RE *> list;
25        list.reserve(alt->size());
26        for (RE * re : *alt) {
27            list.push_back(simplify(re));
28        }
29        re = makeAlt(list.begin(), list.end());
30    } else if (Seq * seq = dyn_cast<Seq>(re)) {
31        std::vector<RE *> list;
32        list.reserve(seq->size());
33        for (RE * re : *seq) {
34            list.push_back(simplify(re));
35        }
36        re = makeSeq(list.begin(), list.end());
37    } else if (Assertion * a = dyn_cast<Assertion>(re)) {
38        re = makeAssertion(simplify(a->getAsserted()), a->getKind(), a->getSense());
39    } else if (Rep * rep = dyn_cast<Rep>(re)) {
40        RE * expr = simplify(rep->getRE());
41        re = makeRep(expr, rep->getLB(), rep->getUB());
42    } else if (Diff * diff = dyn_cast<Diff>(re)) {
43        re = makeDiff(simplify(diff->getLH()), diff->getRH());
44    } else if (Intersect * e = dyn_cast<Intersect>(re)) {
45        re = makeIntersect(simplify(e->getLH()), e->getRH());
46    } 
47    return re;
48}
49
50}
Note: See TracBrowser for help on using the repository browser.