Ignore:
Timestamp:
Sep 23, 2016, 4:12:41 PM (3 years ago)
Author:
nmedfort
Message:

Initial work for incorporating Types into Pablo AST.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r5156 r5160  
    7171    }
    7272
    73     mMarkerMap.emplace(PabloBlock::createZeroes(), iBuilder->allZeroes());
    74     mMarkerMap.emplace(PabloBlock::createOnes(), iBuilder->allOnes());
     73    PabloBlock * const entryBlock = mPabloFunction->getEntryBlock();
     74    mMarkerMap.emplace(entryBlock->createZeroes(), iBuilder->allZeroes());
     75    mMarkerMap.emplace(entryBlock->createOnes(), iBuilder->allOnes());
    7576    for (unsigned j = 0; j < mPabloFunction->getNumOfParameters(); ++j) {
    7677        Value * inputVal = iBuilder->CreateGEP(inputSet_ptr, {iBuilder->getInt32(0), iBuilder->getInt32(j)});
     
    7980            iBuilder->CallPrintRegister(var->getName()->to_string(), iBuilder->CreateBlockAlignedLoad(inputVal));
    8081        }
    81         mMarkerMap.insert(std::make_pair(var, inputVal));
    82     }
    83    
    84     compileBlock(mPabloFunction->getEntryBlock());
     82        mMarkerMap.emplace(var, inputVal);
     83    }
     84   
     85    compileBlock(entryBlock);
    8586   
    8687    for (unsigned j = 0; j < mPabloFunction->getNumOfResults(); ++j) {
     
    132133        compileStatement(statement);
    133134    }
    134     mPabloBlock = block->getParent();
     135    mPabloBlock = block->getPredecessor ();
    135136}
    136137
     
    186187        phi->addIncoming(iBuilder->allZeroes(), ifEntryBlock);
    187188        phi->addIncoming(f->second, ifExitBlock);
    188         mMarkerMap[assign] = phi;
     189        f->second = phi;
     190        assert (mMarkerMap[assign] == phi);
    189191    }
    190192    // Create the phi Node for the summary variable, if needed.
     
    229231        assert (f != mMarkerMap.end());
    230232        phi->addIncoming(f->second, whileEntryBlock);
    231         mMarkerMap[n->getInitial()] = phi;
     233        f->second = phi;
     234        assert(mMarkerMap[n->getInitial()] == phi);
    232235        nextPhis.push_back(phi);
    233236    }
     
    252255    for (unsigned i = 0; i < nextNodes.size(); i++) {
    253256        const Next * n = nextNodes[i];
    254         auto f = mMarkerMap.find(n->getExpr());
     257        const auto f = mMarkerMap.find(n->getExpr());
    255258        if (LLVM_UNLIKELY(f == mMarkerMap.end())) {
    256259            throw std::runtime_error("Next node expression was not compiled!");
     
    400403        throw std::runtime_error(msg.str());
    401404    }
    402     mMarkerMap[stmt] = expr;
     405    mMarkerMap.emplace(stmt, expr);
    403406    if (DebugOptionIsSet(DumpTrace)) {
    404407        iBuilder->CallPrintRegister(stmt->getName()->to_string(), expr);
     
    415418    auto f = mMarkerMap.find(expr);
    416419    if (LLVM_UNLIKELY(f == mMarkerMap.end())) {
    417         std::string o;
    418         llvm::raw_string_ostream str(o);
    419         str << "\"";
    420         PabloPrinter::print(expr, str);
    421         str << "\" was used before definition!";
    422         throw std::runtime_error(str.str());
     420        std::string tmp;
     421        llvm::raw_string_ostream out(tmp);
     422        out << "\"";
     423        PabloPrinter::print(expr, out);
     424        out << "\" was used before definition!";
     425        throw std::runtime_error(out.str());
    423426    }
    424427    Value * result = f->second;
Note: See TracChangeset for help on using the changeset viewer.