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

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

Initial check of carry manager - not yet enabled

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