source: icGREP/icgrep-devel/icgrep/pablo/carry_data.cpp @ 4766

Last change on this file since 4766 was 4750, checked in by cameron, 4 years ago

Clean ups for compilation with gcc 4.8

File size: 4.6 KB
Line 
1/*
2 *  Copyright (c) 2015 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
6
7
8#include <include/simd-lib/bitblock.hpp>
9#include <pablo/pablo_compiler.h>
10#include <pablo/codegenstate.h>
11#include <pablo/carry_data.h>
12#include <iostream>
13
14namespace pablo {
15
16void PabloBlockCarryData::enumerateLocal() {
17    for (Statement * stmt : *theScope) {
18        if (Advance * adv = dyn_cast<Advance>(stmt)) {
19            unsigned shift_amount = adv->getAdvanceAmount();
20            if (shift_amount == 1) {
21                adv->setLocalAdvanceIndex(advance1.entries);
22                advance1.entries++;               
23            }
24            else if (shift_amount < LongAdvanceBase) {
25                // short Advance
26                if (mITEMS_PER_PACK >= LongAdvanceBase) {
27                    // Packing is possible.   We will use the allocated bit position as
28                    // the index.
29                    if (roomInFinalPack(shortAdvance.allocatedBits) < shift_amount) {
30                        // Start a new pack.
31                        shortAdvance.allocatedBits = alignCeiling(shortAdvance.allocatedBits, mPACK_SIZE);
32                    }
33                    adv->setLocalAdvanceIndex(shortAdvance.allocatedBits);
34                }
35                else {
36                    adv->setLocalAdvanceIndex(shortAdvance.entries);
37                }
38                shortAdvance.entries++;
39                shortAdvance.allocatedBits += shift_amount;
40            }
41            else {
42                adv->setLocalAdvanceIndex(longAdvance.allocatedBitBlocks);
43                longAdvance.entries++;
44                longAdvance.allocatedBitBlocks += longAdvanceBufferSize(shift_amount);
45            }
46        }
47        else if (MatchStar * m = dyn_cast<MatchStar>(stmt)) {
48            m->setLocalCarryIndex(addWithCarry.entries);
49            ++addWithCarry.entries;
50        }
51        else if (ScanThru * s = dyn_cast<ScanThru>(stmt)) {
52            s->setLocalCarryIndex(addWithCarry.entries);
53            ++addWithCarry.entries;
54        }
55    }
56    longAdvance.frameOffset = 0;
57    shortAdvance.frameOffset = longAdvance.frameOffset + longAdvance.allocatedBitBlocks * mPOSITIONS_PER_BLOCK;
58    if (mITEMS_PER_PACK == mPACK_SIZE) {
59        addWithCarry.frameOffset = shortAdvance.frameOffset + shortAdvance.allocatedBits;
60        if (roomInFinalPack(addWithCarry.frameOffset) < addWithCarry.entries) {
61            addWithCarry.frameOffset = alignCeiling(addWithCarry.frameOffset, mPACK_SIZE);
62        }
63        advance1.frameOffset = addWithCarry.frameOffset + addWithCarry.entries;
64        if (roomInFinalPack(advance1.frameOffset) < advance1.entries) {
65            advance1.frameOffset = alignCeiling(advance1.frameOffset, mPACK_SIZE);
66        }
67    }
68    else {
69        addWithCarry.frameOffset = shortAdvance.frameOffset + shortAdvance.entries;
70        advance1.frameOffset = addWithCarry.frameOffset + addWithCarry.entries;
71
72    }
73    nested.frameOffset = advance1.frameOffset + advance1.entries;
74}
75       
76void PabloBlockCarryData::dumpCarryData(llvm::raw_ostream & strm) {
77    unsigned totalDepth = ifDepth + whileDepth;
78    for (unsigned i = 0; i < totalDepth; i++) strm << "  ";
79    strm << "scope index = " << theScope->getScopeIndex();
80    strm << " framePosition: " << framePosition << ", ifDepth: " << ifDepth << ", whileDepth:" << whileDepth << ", maxNestingDepth: " << maxNestingDepth << "\n";
81    for (unsigned i = 0; i < totalDepth; i++) strm << "  ";
82    strm << "longAdvance: offset = " << longAdvance.frameOffset << ", entries = " << longAdvance.entries << "\n";
83    for (unsigned i = 0; i < totalDepth; i++) strm << "  ";
84    strm << "shortAdvance: offset = " << shortAdvance.frameOffset << ", entries = " << shortAdvance.entries << "\n";
85    for (unsigned i = 0; i < totalDepth; i++) strm << "  ";
86    strm << "advance1: offset = " << advance1.frameOffset << ", entries = " << advance1.entries << "\n";
87    for (unsigned i = 0; i < totalDepth; i++) strm << "  ";
88    strm << "addWithCarry: offset = " << addWithCarry.frameOffset << ", entries = " << addWithCarry.entries << "\n";
89    for (unsigned i = 0; i < totalDepth; i++) strm << "  ";
90    strm << "nested: offset = " << nested.frameOffset << ", allocatedBits = " << nested.allocatedBits << "\n";
91    for (unsigned i = 0; i < totalDepth; i++) strm << "  ";
92    strm << "summary: offset = " << summary.frameOffset << "\n";
93    for (unsigned i = 0; i < totalDepth; i++) strm << "  ";
94    strm << "scopeCarryDataSize = " << scopeCarryDataSize  << "\n";
95    strm.flush();
96   
97}
98
99}
Note: See TracBrowser for help on using the repository browser.