Changeset 4539 for icGREP


Ignore:
Timestamp:
Mar 25, 2015, 5:41:32 PM (4 years ago)
Author:
cameron
Message:

Slight refactoring to have access to PabloBlock? during Examine/compile

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

Legend:

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

    r4538 r4539  
    103103    mCarryQueueSize = 0;
    104104    mAdvanceQueueSize = 0;
    105     Examine(pb.statements());
     105    Examine(pb);
    106106    mCarryQueueVector.resize(mCarryQueueSize);
    107107    mAdvanceQueueVector.resize(mAdvanceQueueSize);
     
    147147
    148148    //Generate the IR instructions for the function.
    149     compileStatements(pb.statements());
     149    compileBlock(pb);
    150150
    151151    if (LLVM_UNLIKELY(mCarryQueueIdx != mCarryQueueSize)) {
     
    375375// well as mMaxNestingDepth of while loops.
    376376//
    377 void PabloCompiler::Examine(StatementList & stmts) {
    378     for (Statement * stmt : stmts) {
    379 
     377void PabloCompiler::Examine(PabloBlock & blk) {
     378    // Count local carries and advances at this level.
     379    unsigned localCarries = 0;
     380    unsigned localAdvances = 0;
     381    for (Statement * stmt : blk) {
    380382        if (Advance * adv = dyn_cast<Advance>(stmt)) {
    381             mAdvanceQueueSize += (((adv->getAdvanceAmount() - 1) / BLOCK_SIZE) + 1);
     383            localAdvances += (adv->getAdvanceAmount() + BLOCK_SIZE - 1) / BLOCK_SIZE;
    382384        }
    383385        else if (isa<MatchStar>(stmt) || isa<ScanThru>(stmt)) {
    384             ++mCarryQueueSize;
    385         }
     386            ++localCarries;
     387        }
     388    }
     389    mCarryQueueSize += localCarries;
     390    mAdvanceQueueSize += localAdvances;
     391    for (Statement * stmt : blk) {
    386392        if (Call * call = dyn_cast<Call>(stmt)) {
    387393            mCalleeMap.insert(std::make_pair(call->getCallee(), nullptr));
     
    394400            int ifAdvanceCount = mAdvanceQueueSize - preIfAdvanceCount;
    395401            if ((ifCarryCount + ifAdvanceCount) > 1) {
    396               ++mAdvanceQueueSize;
    397               ++ifAdvanceCount;
     402                ++mAdvanceQueueSize;
     403                ++ifAdvanceCount;
    398404            }
    399405            ifStatement->setInclusiveCarryCount(ifCarryCount);
     
    433439}
    434440
    435 void PabloCompiler::compileStatements(const StatementList & stmts) {
    436     for (const Statement * statement : stmts) {
     441void PabloCompiler::compileBlock(const PabloBlock & blk) {
     442    for (const Statement * statement : blk) {
    437443        compileStatement(statement);
    438444    }
     
    499505        // Entry processing is complete, now handle the body of the if.
    500506        mBasicBlock = ifBodyBlock;
    501         compileStatements(ifStatement->getBody());
     507        compileBlock(ifStatement->getBody());
    502508
    503509        // If we compiled an If or a While statement, we won't be in the same basic block as before.
     
    598604        ++mNestingDepth;
    599605
    600         compileStatements(whileStatement->getBody());
     606        compileBlock(whileStatement->getBody());
    601607
    602608        // Reset the carry queue index. Note: this ought to be changed in the future. Currently this assumes
     
    610616        BasicBlock* whileEndBlock = BasicBlock::Create(mMod->getContext(), "while.end", mFunction, 0);
    611617
    612         // Note: compileStatements may update the mBasicBlock pointer if the body contains nested loops. It
     618        // Note: compileBlock may update the mBasicBlock pointer if the body contains nested loops. It
    613619        // may not be same one that we entered the function with.
    614620        IRBuilder<> bEntry(mBasicBlock);
     
    649655        // BODY BLOCK
    650656        mBasicBlock = whileBodyBlock;
    651         compileStatements(whileStatement->getBody());
     657        compileBlock(whileStatement->getBody());
    652658        // update phi nodes for any carry propogating instruction
    653659        IRBuilder<> bWhileBody(mBasicBlock);
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.h

    r4538 r4539  
    100100    void DefineTypes();
    101101    void DeclareFunctions();
    102     void Examine(StatementList & stmts);
     102    void Examine(PabloBlock & blk);
    103103    void DeclareCallFunctions();
    104104    void SetOutputValue(Value * marker, const unsigned index);
    105105
    106     void compileStatements(const StatementList & stmts);
     106    void compileBlock(const PabloBlock & blk);
    107107    void compileStatement(const Statement * stmt);
    108108    void compileIf(const If * ifStmt);
Note: See TracChangeset for help on using the changeset viewer.