Ignore:
Timestamp:
Jul 22, 2015, 8:39:29 AM (4 years ago)
Author:
cameron
Message:

Carry Manager restructuring and bug fixes

File:
1 edited

Legend:

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

    r4682 r4687  
    2626}
    2727
    28 unsigned PabloBlockCarryData::enumerate(PabloBlock & blk) {
    29     for (Statement * stmt : blk) {
     28void PabloBlockCarryData::enumerateLocal() {
     29    for (Statement * stmt : *theScope) {
    3030        if (Advance * adv = dyn_cast<Advance>(stmt)) {
    3131            unsigned shift_amount = adv->getAdvanceAmount();
     
    7373    nested.frameOffsetinBits = advance1.frameOffsetinBits + advance1.entries * BLOCK_SIZE;
    7474#endif
    75     unsigned nestedframePosition = nested.frameOffsetinBits;
     75}
     76       
     77void PabloBlockCarryData::dumpCarryData(llvm::raw_ostream & strm) {
     78    unsigned totalDepth = ifDepth + whileDepth;
     79    for (int i = 0; i < totalDepth; i++) strm << "  ";
     80    strm << "scope index = " << theScope->getScopeIndex();
     81    strm << " framePosition: " << framePosition << ", ifDepth: " << ifDepth << ", whileDepth:" << whileDepth << ", maxNestingDepth: " << maxNestingDepth << "\n";
     82    for (int i = 0; i < totalDepth; i++) strm << "  ";
     83    strm << "longAdvance: offset = " << longAdvance.frameOffsetinBits << ", entries = " << longAdvance.entries << "\n";
     84    for (int i = 0; i < totalDepth; i++) strm << "  ";
     85    strm << "shortAdvance: offset = " << shortAdvance.frameOffsetinBits << ", entries = " << shortAdvance.entries << "\n";
     86    for (int i = 0; i < totalDepth; i++) strm << "  ";
     87    strm << "advance1: offset = " << advance1.frameOffsetinBits << ", entries = " << advance1.entries << "\n";
     88    for (int i = 0; i < totalDepth; i++) strm << "  ";
     89    strm << "addWithCarry: offset = " << addWithCarry.frameOffsetinBits << ", entries = " << addWithCarry.entries << "\n";
     90    for (int i = 0; i < totalDepth; i++) strm << "  ";
     91    strm << "nested: offset = " << nested.frameOffsetinBits << ", allocatedBits = " << nested.allocatedBits << "\n";
     92    for (int i = 0; i < totalDepth; i++) strm << "  ";
     93    strm << "summary: offset = " << summary.frameOffsetinBits << ", allocatedBits = " << summary.allocatedBits << "\n";
     94    for (int i = 0; i < totalDepth; i++) strm << "  ";
     95    strm << "scopeCarryDataBits = " << scopeCarryDataBits  << "\n";
     96    strm.flush();
    7697   
    77     for (Statement * stmt : blk) {
    78         if (If * ifStatement = dyn_cast<If>(stmt)) {
    79             PabloBlockCarryData & nestedBlockData = ifStatement->getBody().carryData;
    80             nestedBlockData.ifDepth = ifDepth + 1;
    81             nestedBlockData.whileDepth = whileDepth;
    82             const unsigned ifCarryDataBits = nestedBlockData.enumerate(ifStatement->getBody());
    83 #ifdef PACKING
    84             EnsurePackHasSpace(nestedframePosition, ifCarryDataBits);
    85 #endif
    86             nestedBlockData.framePosition = nestedframePosition;
    87             nestedframePosition += ifCarryDataBits;
    88             if (maxNestingDepth <= nestedBlockData.maxNestingDepth) maxNestingDepth = nestedBlockData.maxNestingDepth + 1;
    89             nested.entries++;
    90         }
    91         else if (While * whileStatement = dyn_cast<While>(stmt)) {
    92             PabloBlockCarryData & nestedBlockData = whileStatement->getBody().carryData;
    93             nestedBlockData.ifDepth = ifDepth;
    94             nestedBlockData.whileDepth = whileDepth + 1;
    95             unsigned whileCarryDataBits = nestedBlockData.enumerate(whileStatement->getBody());
    96             //if (whileStatement->isMultiCarry()) whileCarryDataBits *= whileStatement->getMaxIterations();
    97 #ifdef PACKING
    98             EnsurePackHasSpace(nestedframePosition, whileCarryDataBits);
    99 #endif
    100             nestedBlockData.framePosition = nestedframePosition;
    101             nestedframePosition += whileCarryDataBits;
    102             if (maxNestingDepth <= nestedBlockData.maxNestingDepth) maxNestingDepth = nestedBlockData.maxNestingDepth + 1;
    103             nested.entries++;
    104         }
    105     }
    106    
    107    
    108     scopeCarryDataBits = nestedframePosition;
    109    
    110     if (explicitSummaryRequired()) {
    111         // Need extra space for the summary variable, always the last
    112         // entry within an if block.
    113         scopeCarryDataBits = alignCeiling(scopeCarryDataBits, PACK_SIZE);
    114         summary.frameOffsetinBits = scopeCarryDataBits;
    115         summary.allocatedBits = PACK_SIZE;
    116         scopeCarryDataBits += PACK_SIZE;
    117     }
    118     else {
    119         summary.frameOffsetinBits = 0;
    120         summary.allocatedBits = scopeCarryDataBits;
    121     }
    122     return scopeCarryDataBits;
    12398}
    12499
Note: See TracChangeset for help on using the changeset viewer.