Changeset 4265


Ignore:
Timestamp:
Oct 24, 2014, 7:08:09 AM (5 years ago)
Author:
cameron
Message:

log2 technique for fixed-length upper bound repetition

File:
1 edited

Legend:

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

    r4264 r4265  
    281281}
    282282
    283 inline Assign * RE_Compiler::processBoundedRep(RE * repeated, int ub, Assign * target, PabloBlock & pb) {
     283inline Assign * RE_Compiler::processBoundedRep(RE * repeated, int ub, Assign * marker, PabloBlock & pb) {
     284#ifdef VARIABLE_ADVANCE
     285    if (isFixedLength(repeated)) {
     286// log2 upper bound for fixed length (=1) class
     287// Mask out any positions that are more than ub positions from a current match.
     288// Use matchstar, then apply filter.
     289        Assign * nonMatch = pb.createAssign("nonmatch", pb.createNot(pb.createVar(marker)));
     290        PabloAST * upperLimitMask = pb.createNot(pb.createVar(consecutive(nonMatch, 1, ub + 1, pb)));
     291        PabloAST * rep_class_var = pb.createVar(cast<Name>(repeated) -> getName());
     292                return pb.createAssign("bounded", pb.createAnd(pb.createMatchStar(pb.createVar(marker), rep_class_var), upperLimitMask));
     293    }
     294#endif
    284295    while (ub-- != 0) {
    285         Assign * alt = process(repeated, target, pb);
    286         target = pb.createAssign("m", pb.createOr(pb.createVar(target), pb.createVar(alt)));
    287     }
    288     return target;
     296        Assign * alt = process(repeated, marker, pb);
     297        marker = pb.createAssign("m", pb.createOr(pb.createVar(marker), pb.createVar(alt)));
     298    }
     299    return marker;
    289300}
    290301
Note: See TracChangeset for help on using the changeset viewer.