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

Last change on this file since 4713 was 4704, checked in by cameron, 4 years ago

Carry manager fixes, restructuring

File size: 4.0 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
16   
17
18void PabloBlockCarryData::enumerateLocal() {
19    for (Statement * stmt : *theScope) {
20        if (Advance * adv = dyn_cast<Advance>(stmt)) {
21            unsigned shift_amount = adv->getAdvanceAmount();
22            if (shift_amount == 1) {
23                adv->setLocalAdvanceIndex(advance1.entries);
24                advance1.entries++;               
25            }
26            else if (shift_amount < LongAdvanceBase) {
27#ifdef PACKING
28                EnsurePackHasSpace(shortAdvance.allocatedBits, shift_amount);
29                adv->setLocalAdvanceIndex(shortAdvance.allocatedBits);
30#else
31                adv->setLocalAdvanceIndex(shortAdvance.entries);
32#endif
33                shortAdvance.entries++;
34                shortAdvance.allocatedBits += shift_amount;
35            }
36            else {
37                adv->setLocalAdvanceIndex(longAdvance.allocatedBitBlocks);
38                longAdvance.entries++;
39                longAdvance.allocatedBitBlocks += longAdvanceBufferSize(shift_amount);
40            }
41        }
42        else if (MatchStar * m = dyn_cast<MatchStar>(stmt)) {
43            m->setLocalCarryIndex(addWithCarry.entries);
44            ++addWithCarry.entries;
45        }
46        else if (ScanThru * s = dyn_cast<ScanThru>(stmt)) {
47            s->setLocalCarryIndex(addWithCarry.entries);
48            ++addWithCarry.entries;
49        }
50    }
51    longAdvance.frameOffset = 0;
52#ifdef PACKING
53    shortAdvance.frameOffset = longAdvance.frameOffset + longAdvance.allocatedBitBlocks * BLOCK_SIZE;
54    addWithCarry.frameOffset = shortAdvance.frameOffset + shortAdvance.allocatedBits;
55    EnsurePackHasSpace(addWithCarry.frameOffset, addWithCarry.entries);
56    advance1.frameOffset = addWithCarry.frameOffset + addWithCarry.entries;
57    EnsurePackHasSpace(advance1.frameOffset, advance1.entries);
58    nested.frameOffset = advance1.frameOffset + advance1.entries;
59#else
60    shortAdvance.frameOffset = longAdvance.frameOffset + longAdvance.allocatedBitBlocks;
61    addWithCarry.frameOffset = shortAdvance.frameOffset + shortAdvance.entries;
62    advance1.frameOffset = addWithCarry.frameOffset + addWithCarry.entries;
63    nested.frameOffset = advance1.frameOffset + advance1.entries;
64#endif
65}
66       
67void PabloBlockCarryData::dumpCarryData(llvm::raw_ostream & strm) {
68    unsigned totalDepth = ifDepth + whileDepth;
69    for (int i = 0; i < totalDepth; i++) strm << "  ";
70    strm << "scope index = " << theScope->getScopeIndex();
71    strm << " framePosition: " << framePosition << ", ifDepth: " << ifDepth << ", whileDepth:" << whileDepth << ", maxNestingDepth: " << maxNestingDepth << "\n";
72    for (int i = 0; i < totalDepth; i++) strm << "  ";
73    strm << "longAdvance: offset = " << longAdvance.frameOffset << ", entries = " << longAdvance.entries << "\n";
74    for (int i = 0; i < totalDepth; i++) strm << "  ";
75    strm << "shortAdvance: offset = " << shortAdvance.frameOffset << ", entries = " << shortAdvance.entries << "\n";
76    for (int i = 0; i < totalDepth; i++) strm << "  ";
77    strm << "advance1: offset = " << advance1.frameOffset << ", entries = " << advance1.entries << "\n";
78    for (int i = 0; i < totalDepth; i++) strm << "  ";
79    strm << "addWithCarry: offset = " << addWithCarry.frameOffset << ", entries = " << addWithCarry.entries << "\n";
80    for (int i = 0; i < totalDepth; i++) strm << "  ";
81    strm << "nested: offset = " << nested.frameOffset << ", allocatedBits = " << nested.allocatedBits << "\n";
82    for (int i = 0; i < totalDepth; i++) strm << "  ";
83    strm << "summary: offset = " << summary.frameOffset << "\n";
84    for (int i = 0; i < totalDepth; i++) strm << "  ";
85    strm << "scopeCarryDataSize = " << scopeCarryDataSize  << "\n";
86    strm.flush();
87   
88}
89
90}
Note: See TracBrowser for help on using the repository browser.