Changeset 5810


Ignore:
Timestamp:
Dec 27, 2017, 6:01:07 PM (3 weeks ago)
Author:
cameron
Message:

RE optimizations

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

Legend:

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

    r5808 r5810  
    182182        accum[p] = pb.createOr(accum[p], markerVar(m), "alt");
    183183    }
    184     if (isa<Zeroes>(accum[MarkerPosition::FinalPostPositionUnit])) {
     184    if (isa<Zeroes>(accum[MarkerPosition::InitialPostPositionUnit]) && isa<Zeroes>(accum[MarkerPosition::FinalPostPositionUnit])) {
    185185        return makeMarker(MarkerPosition::FinalMatchUnit, accum[MarkerPosition::FinalMatchUnit]);
    186186    }
    187     PabloAST * combine = pb.createAdvance(accum[MarkerPosition::FinalMatchUnit], 1, "combine");
     187    PabloAST * combine = pb.createOr(accum[InitialPostPositionUnit], pb.createAdvance(accum[MarkerPosition::FinalMatchUnit], 1), "alt");
     188    if (isa<Zeroes>(accum[FinalPostPositionUnit])) {
     189        return makeMarker(InitialPostPositionUnit, combine);
     190    }
    188191    combine = pb.createOr(pb.createScanThru(pb.createAnd(mInitial, combine), mNonFinal), accum[MarkerPosition::FinalPostPositionUnit], "alt");
    189192    return makeMarker(MarkerPosition::FinalPostPositionUnit, combine);
     
    411414            // Create a mask of positions reachable within ub from current marker.
    412415            // Use matchstar, then apply filter.
    413             PabloAST * cursor = markerVar(AdvanceMarker(marker, MarkerPosition::FinalPostPositionUnit, pb));
     416            PabloAST * cursor = markerVar(AdvanceMarker(marker, MarkerPosition::InitialPostPositionUnit, pb));
    414417            // If we've advanced the cursor to the post position unit, cursor begins on the first masked bit of the bounded mask.
    415418            // Extend the mask by ub - 1 byte positions to ensure the mask ends on the FinalMatchUnit of the repeated region.
     
    419422            // "multi-byte" character. Combine the masked range with any nonFinals.
    420423            PabloAST * bounded = pb.createMatchStar(cursor, pb.createOr(masked, mNonFinal), "bounded");
    421             return makeMarker(MarkerPosition::FinalPostPositionUnit, bounded);
     424            return makeMarker(MarkerPosition::InitialPostPositionUnit, bounded);
    422425        }
    423426        else if (isUnicodeUnitLength(repeated)) {
     
    529532inline MarkerType RE_Compiler::compileStart(MarkerType marker, pablo::PabloBuilder & pb) {
    530533    PabloAST * sol = pb.createNot(pb.createAdvance(pb.createNot(mLineBreak), 1));
    531     if (!AlgorithmOptionIsSet(DisableUnicodeLineBreak)) {
    532         sol = pb.createScanThru(pb.createAnd(mInitial, sol), mNonFinal);
    533     }
    534     MarkerType m = AdvanceMarker(marker, MarkerPosition::FinalPostPositionUnit, pb);
    535     return makeMarker(MarkerPosition::FinalPostPositionUnit, pb.createAnd(markerVar(m), sol, "sol"));
     534    MarkerType m = AdvanceMarker(marker, MarkerPosition::InitialPostPositionUnit, pb);
     535    return makeMarker(MarkerPosition::InitialPostPositionUnit, pb.createAnd(markerVar(m), sol, "sol"));
    536536}
    537537
     
    546546        if (marker.pos == MarkerPosition::FinalMatchUnit) {
    547547            marker.stream = pb.createAdvance(marker.stream, 1, "ipp");
     548            marker.pos = MarkerPosition::InitialPostPositionUnit;
     549        }
     550        if (newpos == MarkerPosition::FinalPostPositionUnit) {
    548551            PabloAST * nonFinal = mNonFinal;
    549             PabloAST * starts = pb.createAnd(mInitial, marker.stream);
    550             marker.stream = pb.createScanThru(starts, nonFinal, "fpp");
     552            marker.stream = pb.createScanThru(pb.createAnd(mInitial, marker.stream), nonFinal, "fpp");
    551553            marker.pos = MarkerPosition::FinalPostPositionUnit;
    552554        }
  • icGREP/icgrep-devel/icgrep/re/re_compiler.h

    r5786 r5810  
    4343namespace re {
    4444
    45 enum MarkerPosition {FinalMatchUnit, FinalPostPositionUnit};
     45enum MarkerPosition {FinalMatchUnit, InitialPostPositionUnit, FinalPostPositionUnit};
    4646
    4747struct MarkerType {
  • icGREP/icgrep-devel/icgrep/re/re_seq.h

    r5725 r5810  
    6969}
    7070
     71inline bool isEmptySeq(RE * s) {
     72    return llvm::isa<Seq>(s) && llvm::cast<Seq>(s)->empty();
     73}
    7174}
    7275
Note: See TracChangeset for help on using the changeset viewer.