Ignore:
Timestamp:
Oct 16, 2018, 2:29:44 PM (6 months ago)
Author:
nmedfort
Message:

Added RE_Inspector.

Migrated RE passes to RE_Transformer.

Incorporated Memoizer functionality into RE_Transformer/Inspector.

Removed Memoizer.

Bug fix for unicode_set.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/re/re_range.cpp

    r5814 r6173  
    99#include <re/re_name.h>
    1010#include <llvm/Support/Casting.h>
     11#include <llvm/Support/raw_ostream.h>
    1112#include <llvm/Support/ErrorHandling.h>
    1213
     
    1718RE * makeRange(RE * lo, RE * hi) {
    1819    if (isa<CC>(lo) && isa<CC>(hi)) {
    19         if (!((dyn_cast<CC>(lo)->count() == 1) && (dyn_cast<CC>(hi)->count() == 1)))
    20             llvm::report_fatal_error("invalid range operand");
    21         auto lo_val = dyn_cast<CC>(lo)->front().first;
    22         auto hi_val = dyn_cast<CC>(hi)->front().first;
    23         return makeCC(lo_val, hi_val, dyn_cast<CC>(hi)->getAlphabet());
     20        CC * const cc_lo = cast<CC>(lo);
     21        CC * const cc_hi = cast<CC>(hi);
     22        if (LLVM_LIKELY((cc_lo->count() == 1) && (cc_hi->count() == 1))) {
     23            const auto lo_val = cc_lo->at(0);
     24            const auto hi_val = cc_hi->at(0);
     25            if (LLVM_LIKELY(lo_val <= hi_val)) {
     26                return makeCC(lo_val, hi_val, dyn_cast<CC>(hi)->getAlphabet());
     27            }
     28        }
     29        std::string tmp;
     30        raw_string_ostream out(tmp);
     31        cc_lo->print(out);
     32        out << " to ";
     33        cc_hi->print(out);
     34        out << " are invalid range operands";
     35        report_fatal_error(out.str());
    2436    }
    2537    else if (isa<Name>(lo) && (cast<Name>(lo)->getDefinition() != nullptr)) {
Note: See TracChangeset for help on using the changeset viewer.