Changeset 4535 for icGREP


Ignore:
Timestamp:
Mar 4, 2015, 10:12:36 AM (4 years ago)
Author:
cameron
Message:

Factor out separate compileIf, compileWhile routines

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

Legend:

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

    r4534 r4535  
    450450}
    451451
    452 void PabloCompiler::compileStatement(const Statement * stmt)
    453 {
    454     IRBuilder<> b(mBasicBlock);
    455     if (const Assign * assign = dyn_cast<const Assign>(stmt)) {
    456         Value * expr = compileExpression(assign->getExpr());
    457         mMarkerMap[assign] = expr;
    458         if (LLVM_UNLIKELY(assign->isOutputAssignment())) {
    459             SetOutputValue(expr, assign->getOutputIndex());
    460         }
    461     }
    462     else if (const Next * next = dyn_cast<const Next>(stmt)) {
    463         Value * expr = compileExpression(next->getExpr());
    464         mMarkerMap[next->getInitial()] = expr;
    465     }
    466     else if (const If * ifStatement = dyn_cast<const If>(stmt))
    467     {
     452void PabloCompiler::compileIf(const If * ifStatement) {
    468453        //
    469454        //  The If-ElseZero stmt:
     
    483468        //  body.
    484469        //
    485 
    486470        BasicBlock * ifEntryBlock = mBasicBlock;  // The block we are in.
    487471        BasicBlock * ifBodyBlock = BasicBlock::Create(mMod->getContext(), "if.body", mFunction, 0);
     
    597581        // Set the basic block to the new end block
    598582        mBasicBlock = ifEndBlock;
    599     }
    600     else if (const While * whileStatement = dyn_cast<const While>(stmt))
    601     {
     583}
     584
     585void PabloCompiler::compileWhile(const While * whileStatement) {
    602586        const auto baseCarryQueueIdx = mCarryQueueIdx;
    603587        const auto baseAdvanceQueueIdx = mAdvanceQueueIdx;
     
    712696            }
    713697        }
     698 
     699}
     700
     701void PabloCompiler::compileStatement(const Statement * stmt)
     702{
     703    IRBuilder<> b(mBasicBlock);
     704    if (const Assign * assign = dyn_cast<const Assign>(stmt)) {
     705        Value * expr = compileExpression(assign->getExpr());
     706        mMarkerMap[assign] = expr;
     707        if (LLVM_UNLIKELY(assign->isOutputAssignment())) {
     708            SetOutputValue(expr, assign->getOutputIndex());
     709        }
     710    }
     711    else if (const Next * next = dyn_cast<const Next>(stmt)) {
     712        Value * expr = compileExpression(next->getExpr());
     713        mMarkerMap[next->getInitial()] = expr;
     714    }
     715    else if (const If * ifStatement = dyn_cast<const If>(stmt))
     716    {
     717        compileIf(ifStatement);
     718    }
     719    else if (const While * whileStatement = dyn_cast<const While>(stmt))
     720    {
     721        compileWhile(whileStatement);
    714722    }
    715723    else if (const Call* call = dyn_cast<Call>(stmt)) {
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.h

    r4516 r4535  
    5050class Statement;
    5151class StatementList;
     52class If;
     53class While;
    5254
    5355struct CompiledPabloFunction {
     
    102104    void compileStatements(const StatementList & stmts);
    103105    void compileStatement(const Statement * stmt);
     106    void compileIf(const If * ifStmt);
     107    void compileWhile(const While * whileStmt);
    104108    Value* compileExpression(const PabloAST * expr);
    105109    Value* genCarryInLoad(const unsigned index);
Note: See TracChangeset for help on using the changeset viewer.