Changeset 4609


Ignore:
Timestamp:
Jun 18, 2015, 10:13:18 AM (4 years ago)
Author:
cameron
Message:

New compilation technique for star-height eliminates nested whiles.

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

Legend:

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

    r4607 r4609  
    485485        return makeMarker(FinalPostPositionByte, pb.createAnd(pb.createMatchStar(base, pb.createOr(mNonFinal, cc)), mFinal, "unbounded"));
    486486    }
     487    else if (mStarDepth > 0){
     488       
     489        PabloBlock * outerb = pb.getParent();
     490       
     491        Assign * starPending = outerb->createAssign("pending", outerb->createZeroes());
     492        Assign * starAccum = outerb->createAssign("accum", outerb->createZeroes());
     493       
     494        mStarDepth++;
     495        PabloAST * m1 = pb.createOr(base, starPending);
     496        PabloAST * m2 = pb.createOr(base, starAccum);
     497        PabloAST * loopComputation = markerVar(AdvanceMarker(process(repeated, makeMarker(InitialPostPositionByte, m1), pb), InitialPostPositionByte, pb));
     498        Next * nextPending = pb.createNext(starPending, pb.createAnd(loopComputation, pb.createNot(m2)));
     499        Next * nextStarAccum = pb.createNext(starAccum, pb.createOr(loopComputation, m2));
     500        mWhileTest = pb.createOr(mWhileTest, nextPending);
     501        mStarDepth--;
     502       
     503        return makeMarker(InitialPostPositionByte, pb.createAssign("unbounded", pb.createOr(base, nextStarAccum)));
     504    }   
    487505    else {
    488506        Assign * whileTest = pb.createAssign("test", base);
     507        Assign * whilePending = pb.createAssign("pending", base);
    489508        Assign * whileAccum = pb.createAssign("accum", base);
     509        mWhileTest = pb.createZeroes();
    490510
    491511        PabloBlock & wb = PabloBlock::Create(pb);
    492512        mStarDepth++;
    493513
    494         PabloAST * loopComputation = markerVar(AdvanceMarker(process(repeated, makeMarker(InitialPostPositionByte, whileTest), wb), InitialPostPositionByte, wb));
    495         Next * nextWhileTest = wb.createNext(whileTest, wb.createAnd(loopComputation, wb.createNot(whileAccum)));
     514        PabloAST * loopComputation = markerVar(AdvanceMarker(process(repeated, makeMarker(InitialPostPositionByte, whilePending), wb), InitialPostPositionByte, wb));
     515        Next * nextWhilePending = wb.createNext(whilePending, wb.createAnd(loopComputation, wb.createNot(whileAccum)));
    496516        Next * nextWhileAccum = wb.createNext(whileAccum, wb.createOr(loopComputation, whileAccum));
    497 
     517        Next * nextWhileTest = wb.createNext(whileTest, wb.createOr(mWhileTest, nextWhilePending));
    498518        pb.createWhile(nextWhileTest, wb);
    499519        mStarDepth--;
  • icGREP/icgrep-devel/icgrep/re/re_compiler.h

    r4520 r4609  
    9797    pablo::Assign *                                 mNonFinal;
    9898    pablo::PabloAST *                               mFinal;
     99    pablo::PabloAST *                               mWhileTest;
    99100    int                                             mStarDepth;
    100101};
Note: See TracChangeset for help on using the changeset viewer.