Changeset 4439


Ignore:
Timestamp:
Jan 23, 2015, 2:48:46 PM (4 years ago)
Author:
nmedfort
Message:

Removed superfluous Assigns from RE compiler. Left the one in the CC for simplicity.

Location:
icGREP/icgrep-devel/icgrep/re
Files:
2 edited

Legend:

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

    r4438 r4439  
    4646    if (m.pos == FinalMatchByte) {
    4747        // Must advance at least to InitialPostPositionByte
    48         a = pb.createAssign("adv", pb.createAdvance(a, 1));
     48        a = pb.createAdvance(a, 1, "adv");
    4949    }
    5050    // Now at InitialPostPositionByte; is a further advance needed?
    5151    if (newpos == FinalPostPositionByte) {
    5252        // Must advance through nonfinal bytes
    53         a = pb.createAssign("scanToFinal", pb.createScanThru(pb.createAnd(mInitial, a), mNonFinal));
     53        a = pb.createScanThru(pb.createAnd(mInitial, a), mNonFinal, "scanToFinal");
    5454    }
    5555    return {newpos, a};
     
    7474void RE_Compiler::initializeRequiredStreams(cc::CC_Compiler & ccc) {
    7575
    76     const std::string initial = "initial";
    7776    const std::string nonfinal = "nonfinal";
    7877
     
    8584#else
    8685    PabloBlock & crb = PabloBlock::Create(mPB);
    87     Assign * cr1 = crb.createAssign("cr1", crb.createAdvance(CR, 1));
     86    PabloAST * cr1 = crb.createAdvance(CR, 1, "cr1");
    8887    Assign * acrlf = crb.createAssign("crlf", crb.createAnd(cr1, LF));
    8988    mPB.createIf(CR, std::move(std::vector<Assign *>{acrlf}), crb);
     
    9291
    9392#ifndef USE_IF_FOR_NONFINAL
    94     PabloAST * u8single = ccc.compileCC(makeCC(0x00, 0x7F));
    9593    PabloAST * u8pfx2 = ccc.compileCC(makeCC(0xC2, 0xDF));
    9694    PabloAST * u8pfx3 = ccc.compileCC(makeCC(0xE0, 0xEF));
    9795    PabloAST * u8pfx4 = ccc.compileCC(makeCC(0xF0, 0xF4));
    9896    PabloAST * u8pfx = mCG.createOr(mCG.createOr(u8pfx2, u8pfx3), u8pfx4);
    99     mInitial = mCG.createAssign(initial, mCG.createOr(u8pfx, u8single));
     97    PabloAST * u8single = ccc.compileCC(makeCC(0x00, 0x7F));
     98    mInitial = mCG.createOr(u8pfx, u8single, "initial");
    10099
    101100    PabloAST * u8scope32 = mCG.createAdvance(u8pfx3, 1);
     
    118117    Assign * valid_pfx = it.createAssign("valid_pfx", it.createOr(it.createOr(u8pfx2, u8pfx3), u8pfx4));
    119118    PabloAST * u8scope32 = it.createAdvance(u8pfx3, 1);
    120     PabloAST * u8scope42 = it.createAssign("u8scope42", it.createAdvance(u8pfx4, 1));
     119    PabloAST * u8scope42 = it.createAdvance(u8pfx4, 1, "u8scope42");
    121120    PabloAST * u8scope43 = it.createAdvance(u8scope42, 1);
    122121    mNonFinal = it.createAssign(nonfinal, it.createOr(it.createOr(u8pfx, u8scope32), it.createOr(u8scope42, u8scope43)));
     
    129128
    130129    PabloAST * u8single = ccc.compileCC(makeCC(0x00, 0x7F));
    131     mInitial = mPB.createAssign(initial, mPB.createOr(u8single, valid_pfx));
     130    mInitial = mPB.createOr(u8single, valid_pfx, "initial");
    132131    mUnicodeLineBreak = mPB.createAnd(LB_chars, mPB.createNot(mCRLF));  // count the CR, but not CRLF
    133132    #endif
     
    143142
    144143MarkerType RE_Compiler::compile(RE * re, PabloBlock & pb) {
    145     return process(re, makeMarker(InitialPostPositionByte, pb.createAssign("start", pb.createOnes())), pb);
     144    return process(re, makeMarker(InitialPostPositionByte, pb.createOnes()), pb);
    146145}
    147146
     
    200199        PabloAST * nextPos = nextUnicodePosition(marker, pb);
    201200        PabloAST * dot = pb.createNot(UNICODE_LINE_BREAK ? pb.createOr(mUnicodeLineBreak, mCRLF) : mLineFeed);
    202         return makeMarker(FinalMatchByte, pb.createAssign("dot", pb.createAnd(nextPos, dot)));
     201        return makeMarker(FinalMatchByte, pb.createAnd(nextPos, dot, "dot"));
    203202    }
    204203    else if (Diff * diff = dyn_cast<Diff>(re)) {
     
    213212            PabloAST * line_end = mPB.createOr(mUnicodeLineBreak, mCRLF);
    214213            PabloAST * sol = pb.createNot(pb.createOr(pb.createAdvance(pb.createNot(line_end), 1), mCRLF));
    215             return makeMarker(InitialPostPositionByte, pb.createAssign("sol", pb.createAnd(markerVar(m), sol)));
     214            return makeMarker(InitialPostPositionByte, pb.createAnd(markerVar(m), sol, "sol"));
    216215        }
    217216        else {
    218217            PabloAST * sol = pb.createNot(pb.createAdvance(pb.createNot(mLineFeed), 1));
    219             return makeMarker(InitialPostPositionByte, pb.createAssign("sol", pb.createAnd(markerVar(m), sol)));
     218            return makeMarker(InitialPostPositionByte, pb.createAnd(markerVar(m), sol, "sol"));
    220219        }
    221220    }
     
    223222        if (UNICODE_LINE_BREAK) {
    224223            PabloAST * nextPos = nextUnicodePosition(marker, pb);
    225             return makeMarker(FinalPostPositionByte, pb.createAssign("end", pb.createAnd(nextPos, mUnicodeLineBreak)));
     224            return makeMarker(FinalPostPositionByte, pb.createAnd(nextPos, mUnicodeLineBreak, "end"));
    226225        }
    227226        PabloAST * nextPos = markerVar(AdvanceMarker(marker, InitialPostPositionByte, pb));  // For LF match
    228         return makeMarker(InitialPostPositionByte, pb.createAssign("eol", pb.createAnd(nextPos, mLineFeed)));
     227        return makeMarker(InitialPostPositionByte, pb.createAnd(nextPos, mLineFeed, "eol"));
    229228    }
    230229    return marker;
     
    240239        nextPos = AdvanceMarker(marker, FinalPostPositionByte, pb);
    241240    }
    242     return makeMarker(FinalMatchByte, pb.createAssign("m", pb.createAnd(markerVar(nextPos), character_class_strm(name, pb))));
     241    return makeMarker(FinalMatchByte, pb.createAnd(markerVar(nextPos), character_class_strm(name, pb), "m"));
    243242}
    244243
     
    259258        MarkerType rslt = process(re, base, pb);
    260259        MarkerPosition p = markerPos(rslt);
    261         accum[p] = pb.createOr(accum[p], markerVar(rslt));
     260        accum[p] = pb.createOr(accum[p], markerVar(rslt), "alt");
    262261    }
    263262    if (isa<Zeroes>(accum[InitialPostPositionByte]) && isa<Zeroes>(accum[FinalPostPositionByte])) {
    264         return makeMarker(FinalMatchByte, pb.createAssign("alt", accum[FinalMatchByte]));
    265     }
    266     PabloAST * combine = pb.createOr(accum[InitialPostPositionByte], pb.createAdvance(accum[FinalMatchByte], 1));
     263        return makeMarker(FinalMatchByte, accum[FinalMatchByte]);
     264    }
     265    PabloAST * combine = pb.createOr(accum[InitialPostPositionByte], pb.createAdvance(accum[FinalMatchByte], 1), "alt");
    267266    if (isa<Zeroes>(accum[FinalPostPositionByte])) {
    268         return makeMarker(InitialPostPositionByte, pb.createAssign("alt", combine));
    269     }
    270     combine = pb.createOr(pb.createScanThru(pb.createAnd(mInitial, combine), mNonFinal), accum[FinalPostPositionByte]);
    271     return makeMarker(FinalPostPositionByte, pb.createAssign("alt", combine));
     267        return makeMarker(InitialPostPositionByte, combine);
     268    }
     269    combine = pb.createOr(pb.createScanThru(pb.createAnd(mInitial, combine), mNonFinal), accum[FinalPostPositionByte], "alt");
     270    return makeMarker(FinalPostPositionByte, combine);
    272271}
    273272
     
    280279        PabloAST * lb = markerVar(lookback);
    281280        if (a->getSense() == Assertion::Sense::Negative) {
    282             lb = pb.createAssign("not", pb.createNot(lb));
    283         }
    284         return makeMarker(markerPos(m), pb.createAssign("lookback", pb.createAnd(markerVar(marker), lb)));
     281            lb = pb.createNot(lb);
     282        }
     283        return makeMarker(markerPos(m), pb.createAnd(markerVar(marker), lb, "lookback"));
    285284    }
    286285    else if (isUnicodeUnitLength(asserted)) {
     
    289288        PabloAST * la = markerVar(lookahead);
    290289        if (a->getSense() == Assertion::Sense::Negative) {
    291             la = pb.createAssign("not", pb.createNot(la));
     290            la = pb.createNot(la);
    292291        }
    293292        MarkerType fbyte = AdvanceMarker(marker, FinalPostPositionByte, pb);
    294         return makeMarker(FinalPostPositionByte, pb.createAssign("lookahead", pb.createAnd(markerVar(fbyte), la)));
     293        return makeMarker(FinalPostPositionByte, pb.createAnd(markerVar(fbyte), la, "lookahead"));
    295294    }
    296295    else {
     
    306305        MarkerType t2 = process(rh, marker, pb);
    307306        AlignMarkers(t1, t2, pb);
    308         return makeMarker(markerPos(t1), pb.createAssign("diff", pb.createAnd(markerVar(t1), pb.createNot(markerVar(t2)))));
     307        return makeMarker(markerPos(t1), pb.createAnd(markerVar(t1), pb.createNot(markerVar(t2)), "diff"));
    309308    }
    310309    throw std::runtime_error("Unsupported Diff operands: " + Printer_RE::PrintRE(diff));
     
    318317        MarkerType t2 = process(rh, marker, pb);
    319318        AlignMarkers(t1, t2, pb);
    320         return makeMarker(markerPos(t1), pb.createAssign("intersect", pb.createAnd(markerVar(t1), markerVar(t2))));
     319        return makeMarker(markerPos(t1), pb.createAnd(markerVar(t1), markerVar(t2), "intersect"));
    321320    }
    322321    throw std::runtime_error("Unsupported Intersect operands: " + Printer_RE::PrintRE(x));
     
    354353            PabloAST * v2 =  pb.createAdvance(v, i);
    355354            i *= 2;
    356             consecutive_i = pb.createAssign("at" + std::to_string(i) + "inarow" , pb.createAnd(v,v2));
     355            consecutive_i = pb.createAnd(v, v2, "at" + std::to_string(i) + "inarow");
    357356        }       
    358357        if (i < total_lgth) {
    359358            PabloAST * v = consecutive_i;
    360             consecutive_i = pb.createAssign("at" + std::to_string(total_lgth) + "inarow" , pb.createAnd(v, pb.createAdvance(v, total_lgth - i)));
     359            consecutive_i = pb.createAnd(v, pb.createAdvance(v, total_lgth - i), "at" + std::to_string(total_lgth) + "inarow");
    361360        }
    362361        return consecutive_i;
     
    369368            return repeated;
    370369        }
    371         PabloAST * reachable_i = pb.createAssign("within1", pb.createOr(repeated, pb.createAdvance(repeated, 1)));
     370        PabloAST * reachable_i = pb.createOr(repeated, pb.createAdvance(repeated, 1), "within1");
    372371        while (i * 2 < total_lgth) {
    373372            PabloAST * v = reachable_i;
    374373            PabloAST * v2 =  pb.createAdvance(v, i);
    375374            i *= 2;
    376             reachable_i = pb.createAssign("within" + std::to_string(i), pb.createOr(v, v2));
     375            reachable_i = pb.createOr(v, v2, "within" + std::to_string(i));
    377376        }       
    378377        if (i < total_lgth) {
    379378            PabloAST * v = reachable_i;
    380             reachable_i = pb.createAssign("within" + std::to_string(total_lgth), pb.createOr(v, pb.createAdvance(v, total_lgth - i)));
     379            reachable_i = pb.createOr(v, pb.createAdvance(v, total_lgth - i), "within" + std::to_string(total_lgth));
    381380        }
    382381        return reachable_i;
     
    388387        PabloAST * cc_lb = consecutive1(cc, 1, lb, pb);
    389388        PabloAST * marker_fwd = pb.createAdvance(markerVar(marker), markerPos(marker) == FinalMatchByte ? lb : lb-1);
    390         return makeMarker(FinalMatchByte, pb.createAssign("lowerbound", pb.createAnd(marker_fwd, cc_lb)));
     389        return makeMarker(FinalMatchByte, pb.createAnd(marker_fwd, cc_lb, "lowerbound"));
    391390    }
    392391    // Fall through to general case.
     
    406405        PabloAST * cursor = markerVar(AdvanceMarker(marker, InitialPostPositionByte, pb));
    407406        PabloAST * rep_class_var = markerVar(compile(repeated, pb));
    408         return makeMarker(InitialPostPositionByte, pb.createAssign("bounded", pb.createAnd(pb.createMatchStar(cursor, rep_class_var), upperLimitMask)));
     407        return makeMarker(InitialPostPositionByte, pb.createAnd(pb.createMatchStar(cursor, rep_class_var), upperLimitMask, "bounded"));
    409408    }
    410409    // Fall through to general case.
     
    413412        MarkerType m = marker;
    414413        AlignMarkers(a, m, pb);
    415         marker = makeMarker(markerPos(a), pb.createAssign("m", pb.createOr(markerVar(a), markerVar(m))));
     414        marker = makeMarker(markerPos(a), pb.createOr(markerVar(a), markerVar(m), "m"));
    416415    }
    417416    return marker;
     
    424423    if (isByteLength(repeated)) {
    425424        PabloAST * cc = markerVar(compile(repeated, pb)); 
    426         return makeMarker(InitialPostPositionByte, pb.createAssign("unbounded", pb.createMatchStar(base, cc)));
     425        return makeMarker(InitialPostPositionByte, pb.createMatchStar(base, cc, "unbounded"));
    427426    }
    428427    else if (isUnicodeUnitLength(repeated)) {
    429428        PabloAST * cc = markerVar(compile(repeated, pb));
    430         return makeMarker(InitialPostPositionByte, pb.createAssign("unbounded", pb.createAnd(pb.createMatchStar(base, pb.createOr(mNonFinal, cc)), mInitial)));
     429        return makeMarker(InitialPostPositionByte, pb.createAnd(pb.createMatchStar(base, pb.createOr(mNonFinal, cc)), mInitial, "unbounded"));
    431430    }
    432431    else {
  • icGREP/icgrep-devel/icgrep/re/re_compiler.h

    r4438 r4439  
    5151inline pablo::PabloAST * markerVar(MarkerType m) {return m.stream;}
    5252   
    53 inline MarkerType makeMarker(MarkerPosition newpos, pablo::Assign * strm) {return {newpos, strm};}
     53inline MarkerType makeMarker(MarkerPosition newpos, pablo::PabloAST * strm) {return {newpos, strm};}
    5454
    5555
     
    9292    pablo::PabloAST *                               mCRLF;
    9393    pablo::PabloAST *                               mUnicodeLineBreak;
    94     pablo::Assign *                                 mInitial;
     94    pablo::PabloAST *                               mInitial;
    9595    pablo::Assign *                                 mNonFinal;
    9696};
Note: See TracChangeset for help on using the changeset viewer.