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

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

Carry Manager system integrated into Pablo compiler

File size: 3.2 KB
RevLine 
[4644]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);
[4647]47     
[4644]48    void setCarryOpCarryOut(PabloBlock * blk, unsigned idx, Value * carry_out);
49
50    void setUnitAdvanceCarryOut(PabloBlock * blk, unsigned idx, Value * carry_out);
51
52    void setShortAdvanceCarryOut(PabloBlock * blk, unsigned idx, int shift_amount, Value * carry_out); 
53   
[4647]54    Value * longAdvanceCarryInCarryOut(PabloBlock * blk, int localIndex, int shift_amount, Value * carry_out);
[4644]55 
56    /* Methods for getting and setting carry summary values for If statements */
57   
58    bool blockHasCarries(PabloBlock & blk);
59   
60    Value * getCarrySummaryExpr(PabloBlock & blk);
61   
62    void generateCarryOutSummaryCode(PabloBlock & blk);
63   
64    bool summaryNeededInParentBlock(PabloBlock & blk);
65   
66    void addSummaryPhi(PabloBlock & blk, BasicBlock * ifEntryBlock, BasicBlock * ifBodyFinalBlock);
67   
68    /* Methods for load/store of carries for non-while blocks. */
69   
70    void ensureCarriesLoadedLocal(PabloBlock & blk);
71
72    void ensureCarriesStoredLocal(PabloBlock & blk);
73   
74    /* Methods for handling while statements */
75   
76    void ensureCarriesLoadedRecursive(PabloBlock & whileBlk);
77
78    void initializeCarryDataPhisAtWhileEntry(PabloBlock & whileBlk, BasicBlock * whileBodyFinalBlock);
79
80    void extendCarryDataPhisAtWhileBodyFinalBlock(PabloBlock & whileBlk, BasicBlock * whileBodyFinalBlock);
81
82    void ensureCarriesStoredRecursive(PabloBlock & whileBlk);
83
84   
85private:
86  IRBuilder <> * mBuilder;
87  VectorType * mBitBlockType;
88  ConstantAggregateZero * mZeroInitializer;
89  Constant * mOneInitializer;
90  PabloBlock * mPabloRoot;
91  Value * mCarryDataPtr;
92  Value * mBlockNoPtr;
93  Value * mBlockNo;
94  unsigned mTotalCarryDataSize;
95 
96  std::vector<Value *> mCarryInVector;
97  std::vector<PHINode *> mCarryInPhis; 
98  std::vector<PHINode *> mCarryOutAccumPhis; 
99  std::vector<Value *> mCarryOutVector;
100};
101
102}
103
104#endif // CARRY_MANAGER_H
Note: See TracBrowser for help on using the repository browser.