Ignore:
Timestamp:
Dec 21, 2016, 3:53:58 PM (2 years ago)
Author:
nmedfort
Message:

Bug fixes for Carry Manager and issues reported by Fahad

File:
1 edited

Legend:

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

    r5217 r5233  
    200200RE * RE_Compiler::resolveUnicodeProperties(RE * re) {
    201201    Name * ZeroWidth = nullptr;
    202     UCD::UCDCompiler::NameMap nameMap;
    203     nameMap = resolveNames(re, ZeroWidth);
    204    
     202    mCompiledName = &mBaseMap;
     203
     204    auto nameMap = resolveNames(re, ZeroWidth);
    205205    if (LLVM_LIKELY(nameMap.size() > 0)) {
    206206        UCD::UCDCompiler ucdCompiler(mCCCompiler);
     
    212212        for (auto t : nameMap) {
    213213            if (t.second) {
    214                 mCompiledName.insert(std::make_pair(t.first, makeMarker(MarkerPosition::FinalMatchUnit, mPB.createAnd(t.second, mAny))));
     214                mCompiledName->add(t.first, makeMarker(MarkerPosition::FinalMatchUnit, mPB.createAnd(t.second, mAny)));
    215215            }
    216216        }
     
    219219    // Now precompile any grapheme segmentation rules
    220220    if (ZeroWidth) {
    221         auto gcb = compileName(ZeroWidth, mPB);
    222         mCompiledName.insert(std::make_pair(ZeroWidth, gcb));
     221        mCompiledName->add(ZeroWidth, compileName(ZeroWidth, mPB));
    223222    }
    224223    return re;
     
    312311
    313312inline MarkerType RE_Compiler::compileName(Name * name, PabloBuilder & pb) {
    314     auto f = mCompiledName.find(name);
    315     if (LLVM_LIKELY(f != mCompiledName.end())) {
    316         return f->second;
     313    MarkerType m;
     314    if (LLVM_LIKELY(mCompiledName->get(name, m))) {
     315        return m;
    317316    } else if (LLVM_LIKELY(name->getDefinition() != nullptr)) {
    318         MarkerType m = compile(name->getDefinition(), pb);
    319         mCompiledName.insert(std::make_pair(name, m));
     317        m = compile(name->getDefinition(), pb);
     318        mCompiledName->add(name, m);
    320319        return m;
    321320    }
     
    345344    } else {
    346345        Var * m = pb.createVar("m", pb.createZeroes());
     346        NameMap nestedMap(mCompiledName);
     347        mCompiledName = &nestedMap;
    347348        PabloBuilder nested = PabloBuilder::Create(pb);
    348349        MarkerType m1 = compileSeqTail(current, end, 0, marker, nested);
    349350        nested.createAssign(m, markerVar(m1));
    350351        pb.createIf(markerVar(marker), nested);
     352        mCompiledName = nestedMap.getParent();
    351353        return makeMarker(m1.pos, m);
    352354    }
     
    354356
    355357MarkerType RE_Compiler::compileAlt(Alt * alt, MarkerType marker, PabloBuilder & pb) {
    356     std::vector<PabloAST *>  accum = {pb.createZeroes(), pb.createZeroes(), pb.createZeroes()};
     358    std::vector<PabloAST *>  accum(3, pb.createZeroes());
    357359    MarkerType const base = marker;
    358360    // The following may be useful to force a common Advance rather than separate
    359361    // Advances in each alternative.
    360362    for (RE * re : *alt) {
    361         MarkerType rslt = process(re, base, pb);
    362         MarkerPosition p = markerPos(rslt);
    363         accum[p] = pb.createOr(accum[p], markerVar(rslt), "alt");
     363        MarkerType m = process(re, base, pb);
     364        MarkerPosition p = markerPos(m);
     365        accum[p] = pb.createOr(accum[p], markerVar(m), "alt");
    364366    }
    365367    if (isa<Zeroes>(accum[MarkerPosition::FinalPostPositionUnit])) {
     
    643645, mWhileTest(nullptr)
    644646, mStarDepth(0)
    645 , mPB(ccCompiler.getBuilder()) {
     647, mPB(ccCompiler.getBuilder())
     648, mCompiledName(&mBaseMap) {
    646649
    647650}
Note: See TracChangeset for help on using the changeset viewer.