source: icGREP/icgrep-devel/icgrep/re/re_range.cpp @ 5786

Last change on this file since 5786 was 5764, checked in by cameron, 22 months ago

Range RE new files

File size: 725 bytes
Line 
1/*
2 *  Copyright (c) 2017 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_range.h"
8#include "re_cc.h"
9#include <llvm/Support/Casting.h>
10
11using namespace llvm;
12
13namespace re {
14
15RE * makeRange(RE * lo, RE * hi) {
16    if (isa<CC>(lo) && isa<CC>(hi)) {
17        assert(dyn_cast<CC>(lo)->count() == 1);
18        assert(dyn_cast<CC>(hi)->count() == 1);
19        return makeCC(dyn_cast<CC>(lo)->front().first, dyn_cast<CC>(hi)->front().first);
20    }
21    else if (lo == hi) { // TODO: general check for equality, not just instance equality
22        return lo;
23    }
24    return new Range(lo, hi);
25}
26   
27}
Note: See TracBrowser for help on using the repository browser.