Changeset 4216 for icGREP


Ignore:
Timestamp:
Oct 6, 2014, 8:59:18 AM (5 years ago)
Author:
nmedfort
Message:

Minor revisions.

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/llvm_gen.cpp

    r4215 r4216  
    428428    ReturnInst::Create(mMod->getContext(), mBasicBlock);
    429429
     430    #ifndef NDEBUG
    430431    //Create a verifier.  The verifier will print an error message if our module is malformed in any way.
    431 #ifdef USE_LLVM_3_5
     432    #ifdef USE_LLVM_3_5
    432433    verifyModule(*mMod, &dbgs());
    433 #endif
    434 
    435 #ifdef USE_LLVM_3_4
     434    #endif
     435    #ifdef USE_LLVM_3_4
    436436    verifyModule(*mMod, PrintMessageAction);
    437 #endif
     437    #endif
     438    #endif
    438439
    439440    //Un-comment this line in order to display the IR that has been generated by this module.
     
    479480    return retVal;
    480481}
    481 
    482 #define bitBlockExprType mXi64Vect
    483482
    484483void LLVM_Generator::DefineTypes()
     
    632631}
    633632
    634 void LLVM_Generator::DeclareCallFunctions(ExpressionList stmts) {
    635     for (auto it = stmts.begin(); it != stmts.end(); ++it) {
    636         DeclareCallFunctions_PabloS(*it);
    637     }
    638 }
    639 
    640 void LLVM_Generator::DeclareCallFunctions_PabloS(PabloE *stmt)
     633void LLVM_Generator::DeclareCallFunctions(const ExpressionList & stmts) {
     634    for (PabloE * stmt : stmts) {
     635        if (const Assign * an = dyn_cast<const Assign>(stmt))
     636        {
     637            DeclareCallFunctions(an->getExpr());
     638        }
     639        else if (If * ifstmt = dyn_cast<If>(stmt))
     640        {
     641            DeclareCallFunctions(ifstmt->getExpr());
     642            DeclareCallFunctions(ifstmt->getPSList());
     643        }
     644        else if (While * whl = dyn_cast<While>(stmt))
     645        {
     646            DeclareCallFunctions(whl->getCondition());
     647            DeclareCallFunctions(whl->getPSList());
     648        }
     649    }
     650}
     651
     652void LLVM_Generator::DeclareCallFunctions(const PabloE * expr)
    641653{
    642     if (Assign * an = dyn_cast<Assign>(stmt))
    643     {
    644         DeclareCallFunctions_PabloE(an->getExpr());
    645     }
    646     else if (If * ifstmt = dyn_cast<If>(stmt))
    647     {
    648         DeclareCallFunctions_PabloE(ifstmt->getExpr());
    649         DeclareCallFunctions(ifstmt->getPSList());
    650     }
    651     else if (While * whl = dyn_cast<While>(stmt))
    652     {
    653         DeclareCallFunctions_PabloE(whl->getCondition());
    654         DeclareCallFunctions(whl->getPSList());
    655     }
    656 }
    657 
    658 void LLVM_Generator::DeclareCallFunctions_PabloE(PabloE* expr)
    659 {
    660     if (Call * pablo_call = dyn_cast<Call>(expr))
     654    if (const Call * pablo_call = dyn_cast<const Call>(expr))
    661655    {
    662656        std::string callee = "wrapped_get_category_" + pablo_call->getCallee();
     
    790784        }
    791785    }
    792     else if (And * pablo_and = dyn_cast<And>(expr))
    793     {
    794         DeclareCallFunctions_PabloE(pablo_and->getExpr1());
    795         DeclareCallFunctions_PabloE(pablo_and->getExpr2());
    796     }
    797     else if (Or * pablo_or = dyn_cast<Or>(expr))
    798     {
    799         DeclareCallFunctions_PabloE(pablo_or->getExpr1());
    800         DeclareCallFunctions_PabloE(pablo_or->getExpr2());
    801     }
    802     else if (Sel * pablo_sel = dyn_cast<Sel>(expr))
    803     {
    804         DeclareCallFunctions_PabloE(pablo_sel->getCondition());
    805         DeclareCallFunctions_PabloE(pablo_sel->getTrueExpr());
    806         DeclareCallFunctions_PabloE(pablo_sel->getFalseExpr());
    807     }
    808     else if (Not * pablo_not = dyn_cast<Not>(expr))
    809     {
    810         DeclareCallFunctions_PabloE(pablo_not->getExpr());
    811     }
    812     else if (Advance * adv = dyn_cast<Advance>(expr))
    813     {
    814         DeclareCallFunctions_PabloE(adv->getExpr());
    815     }
    816     else if (MatchStar * mstar = dyn_cast<MatchStar>(expr))
    817     {
    818         DeclareCallFunctions_PabloE(mstar->getExpr1());
    819         DeclareCallFunctions_PabloE(mstar->getExpr2());
    820     }
    821     else if (ScanThru * sthru = dyn_cast<ScanThru>(expr))
    822     {
    823         DeclareCallFunctions_PabloE(sthru->getScanFrom());
    824         DeclareCallFunctions_PabloE(sthru->getScanThru());
     786    else if (const And * pablo_and = dyn_cast<const And>(expr))
     787    {
     788        DeclareCallFunctions(pablo_and->getExpr1());
     789        DeclareCallFunctions(pablo_and->getExpr2());
     790    }
     791    else if (const Or * pablo_or = dyn_cast<const Or>(expr))
     792    {
     793        DeclareCallFunctions(pablo_or->getExpr1());
     794        DeclareCallFunctions(pablo_or->getExpr2());
     795    }
     796    else if (const Sel * pablo_sel = dyn_cast<const Sel>(expr))
     797    {
     798        DeclareCallFunctions(pablo_sel->getCondition());
     799        DeclareCallFunctions(pablo_sel->getTrueExpr());
     800        DeclareCallFunctions(pablo_sel->getFalseExpr());
     801    }
     802    else if (const Not * pablo_not = dyn_cast<const Not>(expr))
     803    {
     804        DeclareCallFunctions(pablo_not->getExpr());
     805    }
     806    else if (const Advance * adv = dyn_cast<const Advance>(expr))
     807    {
     808        DeclareCallFunctions(adv->getExpr());
     809    }
     810    else if (const MatchStar * mstar = dyn_cast<const MatchStar>(expr))
     811    {
     812        DeclareCallFunctions(mstar->getExpr1());
     813        DeclareCallFunctions(mstar->getExpr2());
     814    }
     815    else if (const ScanThru * sthru = dyn_cast<const ScanThru>(expr))
     816    {
     817        DeclareCallFunctions(sthru->getScanFrom());
     818        DeclareCallFunctions(sthru->getScanThru());
    825819    }
    826820}
     
    865859}
    866860
    867 std::string LLVM_Generator::Generate_PabloStatements(ExpressionList stmts) {
     861std::string LLVM_Generator::Generate_PabloStatements(const ExpressionList & stmts) {
    868862    std::string retVal = "";
    869863    for (auto it = stmts.begin(); it != stmts.end(); ++it) {
     
    993987}
    994988
    995 Value* LLVM_Generator::Generate_PabloE(PabloE *expr)
     989Value* LLVM_Generator::Generate_PabloE(PabloE * expr)
    996990{
    997991    Value* retVal = 0;
     
    12101204    IRBuilder<> b(mBasicBlock);
    12111205    Value* i128_val = b.CreateBitCast(e, IntegerType::get(mMod->getContext(), BLOCK_SIZE));
    1212     return b.CreateBitCast(b.CreateLShr(i128_val, BLOCK_SIZE - 1, namehint), bitBlockExprType);
     1206    return b.CreateBitCast(b.CreateLShr(i128_val, BLOCK_SIZE - 1, namehint), mXi64Vect);
    12131207}
    12141208
     
    12161210    IRBuilder<> b(mBasicBlock);
    12171211    Value* i128_val = b.CreateBitCast(e, IntegerType::get(mMod->getContext(), BLOCK_SIZE));
    1218     return b.CreateBitCast(b.CreateShl(i128_val, 64, namehint), bitBlockExprType);
     1212    return b.CreateBitCast(b.CreateShl(i128_val, 64, namehint), mXi64Vect);
    12191213}
    12201214
  • icGREP/icgrep-devel/icgrep/llvm_gen.h

    r4215 r4216  
    9696    void DefineTypes();
    9797    void DeclareFunctions();
    98     void DeclareCallFunctions(ExpressionList stmts);
    99     void DeclareCallFunctions_PabloS(PabloE* stmt);
    100     void DeclareCallFunctions_PabloE(PabloE* expr);
     98
     99    void DeclareCallFunctions(const ExpressionList & stmts);
     100    void DeclareCallFunctions(const PabloE * expr);
     101
    101102    void StoreBitBlockMarkerPtr(std::string name, int index);
    102103    void LoadBitBlocksFromStaticExtern();
    103104    void SetReturnMarker(std::string marker, int output_idx);
    104105    Value* GetMarker(std::string name);
    105     std::string Generate_PabloStatements(ExpressionList stmts);
    106     std::string Generate_PabloS(PabloE* stmt);
    107     Value* Generate_PabloE(PabloE* expr);
     106    std::string Generate_PabloStatements(const ExpressionList & stmts);
     107    std::string Generate_PabloS(PabloE * stmt);
     108    Value* Generate_PabloE(PabloE *expr);
    108109    Value* genMatchStar(Value* marker_expr, Value* cc_expr);
    109110    Value* genScanThru(Value* marker_expr, Value* cc_expr);
  • icGREP/icgrep-devel/icgrep/pablo/ps_while.h

    r4215 r4216  
    99
    1010#include <pablo/pe_pabloe.h>
    11 #include <vector>
    1211
    1312namespace pablo {
Note: See TracChangeset for help on using the changeset viewer.