source: icGREP/icgrep-devel/icgrep/pablo/carry_manager.h @ 4656

Last change on this file since 4656 was 4654, checked in by cameron, 4 years ago

Move logic for advance operations entirely within carry manager.

File size: 3.3 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#ifndef CARRY_MANAGER_H
8#define CARRY_MANAGER_H
9#include <llvm/IR/IRBuilder.h>
10#include <llvm/IR/Module.h>
11#include <IDISA/idisa_builder.h>
12
13/*
14 * Carry Data Manager.
15 *
16 * Each PabloBlock (Main, If, While) has a contiguous data area for carry information.
17 * The data area may be at a fixed or variable base offset from the base of the
18 * main function carry data area.
19 * The data area for each block consists of contiguous space for the local carries and
20 * advances of the block plus the areas of any ifs/whiles nested within the block.
21
22*/
23
24using namespace llvm;
25
26namespace pablo {
27
28class PabloBlock;
29
30class CarryManager {
31public:
32 
33    CarryManager(Module * m, IRBuilder <> * b, VectorType * bitBlockType, ConstantAggregateZero * zero, Constant * one) :
34        mMod(m), mBuilder(b), mBitBlockType(bitBlockType), mZeroInitializer(zero), mOneInitializer(one) {}
35   
36    unsigned initialize(PabloBlock * blk, Value * carryDataPtr); 
37   
38    void generateBlockNoIncrement();
39   
40    Value * getBlockNoPtr();
41   
42    /* Methods for processing individual carry-generating operations. */
43   
44    Value * getCarryOpCarryIn(PabloBlock * blk, int localIndex);
45
46    void setCarryOpCarryOut(PabloBlock * blk, unsigned idx, Value * carry_out);
47
48    Value * advanceCarryInCarryOut(PabloBlock * blk, int localIndex, int shift_amount, Value * strm);
49 
50    /* Methods for getting and setting carry summary values for If statements */
51   
52    bool blockHasCarries(PabloBlock & blk);
53   
54    Value * getCarrySummaryExpr(PabloBlock & blk);
55   
56    void generateCarryOutSummaryCode(PabloBlock & blk);
57   
58    bool summaryNeededInParentBlock(PabloBlock & blk);
59   
60    void addSummaryPhi(PabloBlock & blk, BasicBlock * ifEntryBlock, BasicBlock * ifBodyFinalBlock);
61   
62    /* Methods for load/store of carries for non-while blocks. */
63   
64    void ensureCarriesLoadedLocal(PabloBlock & blk);
65
66    void ensureCarriesStoredLocal(PabloBlock & blk);
67   
68    /* Methods for handling while statements */
69   
70    void ensureCarriesLoadedRecursive(PabloBlock & whileBlk);
71
72    void initializeCarryDataPhisAtWhileEntry(PabloBlock & whileBlk, BasicBlock * whileBodyFinalBlock);
73
74    void extendCarryDataPhisAtWhileBodyFinalBlock(PabloBlock & whileBlk, BasicBlock * whileBodyFinalBlock);
75
76    void ensureCarriesStoredRecursive(PabloBlock & whileBlk);
77
78   
79private:
80    Module * mMod;
81    IRBuilder <> * mBuilder;
82    VectorType * mBitBlockType;
83    ConstantAggregateZero * mZeroInitializer;
84    Constant * mOneInitializer;
85    IDISA::IDISA_Builder * iBuilder;
86    PabloBlock * mPabloRoot;
87    Value * mCarryDataPtr;
88    Value * mBlockNoPtr;
89    Value * mBlockNo;
90    unsigned mTotalCarryDataSize;
91
92    std::vector<Value *> mCarryInVector;
93    std::vector<PHINode *> mCarryInPhis; 
94    std::vector<PHINode *> mCarryOutAccumPhis; 
95    std::vector<Value *> mCarryOutVector;
96
97    Value * unitAdvanceCarryInCarryOut(PabloBlock * blk, int localIndex, Value * strm);
98    Value * shortAdvanceCarryInCarryOut(PabloBlock * blk, int localIndex, int shift_amount, Value * strm);
99    Value * longAdvanceCarryInCarryOut(PabloBlock * blk, int localIndex, int shift_amount, Value * strm);
100   
101};
102
103}
104
105#endif // CARRY_MANAGER_H
Note: See TracBrowser for help on using the repository browser.