Ignore:
Timestamp:
Oct 20, 2014, 10:49:33 AM (5 years ago)
Author:
nmedfort
Message:

Transitory check-in; initial integration of pablo Next nodes and enforcement of SSA form for all Assign nodes.

File:
1 edited

Legend:

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

    r4250 r4252  
    183183    ReturnInst::Create(mMod->getContext(), mBasicBlock);
    184184
     185    //Un-comment this line in order to display the IR that has been generated by this module.
     186    #ifdef DUMP_GENERATED_IR
     187    mMod->dump();
     188    #endif
     189
    185190    //Create a verifier.  The verifier will print an error message if our module is malformed in any way.
    186191    #ifdef USE_LLVM_3_5
     
    189194    #ifdef USE_LLVM_3_4
    190195    verifyModule(*mMod, PrintMessageAction);
    191     #endif
    192 
    193     //Un-comment this line in order to display the IR that has been generated by this module.
    194     #ifdef DUMP_GENERATED_IR
    195     mMod->dump();
    196196    #endif
    197197
     
    508508    if (const Assign * assign = dyn_cast<const Assign>(stmt))
    509509    {
     510        Value * expr = compileExpression(assign->getExpr());
     511        Value * marker = nullptr;
    510512        IRBuilder<> b(mBasicBlock);
    511         Value * marker = GetMarker(assign->getName());
    512         Value * expr = compileExpression(assign->getExpr());
     513        auto f = mMarkerMap.find(assign->getName());
     514        if (f == mMarkerMap.end()) {
     515            marker = b.CreateAlloca(mXi64Vect, 0, assign->getName());
     516            mMarkerMap.insert(std::make_pair(assign->getName(), marker));
     517        }
     518        else {
     519            marker = f->second;
     520        }
     521        b.CreateStore(expr, marker);
     522        retVal = marker;
     523    }
     524    if (const Next * next = dyn_cast<const Next>(stmt))
     525    {
     526        IRBuilder<> b(mBasicBlock);
     527        auto f = mMarkerMap.find(next->getName());
     528        assert (f != mMarkerMap.end());
     529        Value * marker = f->second;
     530        Value * expr = compileExpression(next->getExpr());
    513531        b.CreateStore(expr, marker);
    514532        retVal = marker;
     
    624642    Value * retVal = nullptr;
    625643    IRBuilder<> b(mBasicBlock);
    626     if (isa<Ones>(expr))
    627     {
     644    if (isa<Ones>(expr)) {
    628645        retVal = mOneInitializer;
    629646    }
    630     else if (isa<Zeroes>(expr))
    631     {
     647    else if (isa<Zeroes>(expr)) {
    632648        retVal = mZeroInitializer;
    633649    }
    634     else if (const Call* call = dyn_cast<Call>(expr))
    635     {
     650    else if (const Call* call = dyn_cast<Call>(expr)) {
    636651        //Call the callee once and store the result in the marker map.
    637652        auto mi = mMarkerMap.find(call->getCallee());
     
    650665    else if (const Var * var = dyn_cast<Var>(expr))
    651666    {
    652         retVal = b.CreateLoad(GetMarker(var->getName()), false, var->getName());
     667        auto f = mMarkerMap.find(var->getName());
     668        assert (f != mMarkerMap.end());
     669        retVal = b.CreateLoad(f->second, false, var->getName());
    653670    }
    654671    else if (const And * pablo_and = dyn_cast<And>(expr))
Note: See TracChangeset for help on using the changeset viewer.