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

Last change on this file since 4659 was 4659, checked in by nmedfort, 4 years ago

Minor changes to function compilation preceeding any modification of the pablo Call class.

File size: 3.4 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)
35    , mBuilder(b)
36    , mBitBlockType(bitBlockType)
37    , mZeroInitializer(zero)
38    , mOneInitializer(one)
39    , iBuilder(mMod, mBuilder, mBitBlockType) {
40
41    }
42   
43    unsigned initialize(PabloBlock * blk, Value * carryDataPtr); 
44   
45    void generateBlockNoIncrement();
46   
47    Value * getBlockNoPtr();
48   
49    /* Methods for processing individual carry-generating operations. */
50   
51    Value * getCarryOpCarryIn(PabloBlock * blk, int localIndex);
52
53    void setCarryOpCarryOut(PabloBlock * blk, unsigned idx, Value * carry_out);
54
55    Value * advanceCarryInCarryOut(PabloBlock * blk, int localIndex, int shift_amount, Value * strm);
56 
57    /* Methods for getting and setting carry summary values for If statements */
58   
59    bool blockHasCarries(PabloBlock & blk);
60   
61    Value * getCarrySummaryExpr(PabloBlock & blk);
62   
63    void generateCarryOutSummaryCode(PabloBlock & blk);
64   
65    bool summaryNeededInParentBlock(PabloBlock & blk);
66   
67    void addSummaryPhi(PabloBlock & blk, BasicBlock * ifEntryBlock, BasicBlock * ifBodyFinalBlock);
68   
69    /* Methods for load/store of carries for non-while blocks. */
70   
71    void ensureCarriesLoadedLocal(PabloBlock & blk);
72
73    void ensureCarriesStoredLocal(PabloBlock & blk);
74   
75    /* Methods for handling while statements */
76   
77    void ensureCarriesLoadedRecursive(PabloBlock & whileBlk);
78
79    void initializeCarryDataPhisAtWhileEntry(PabloBlock & whileBlk, BasicBlock * whileBodyFinalBlock);
80
81    void extendCarryDataPhisAtWhileBodyFinalBlock(PabloBlock & whileBlk, BasicBlock * whileBodyFinalBlock);
82
83    void ensureCarriesStoredRecursive(PabloBlock & whileBlk);
84
85   
86private:
87    Module * mMod;
88    IRBuilder <> * mBuilder;
89    VectorType * mBitBlockType;
90    ConstantAggregateZero * mZeroInitializer;
91    Constant * mOneInitializer;
92    IDISA::IDISA_Builder iBuilder;
93    PabloBlock * mPabloRoot;
94    Value * mCarryDataPtr;
95    Value * mBlockNoPtr;
96    Value * mBlockNo;
97    unsigned mTotalCarryDataSize;
98
99    std::vector<Value *> mCarryInVector;
100    std::vector<PHINode *> mCarryInPhis; 
101    std::vector<PHINode *> mCarryOutAccumPhis; 
102    std::vector<Value *> mCarryOutVector;
103
104    Value * unitAdvanceCarryInCarryOut(PabloBlock * blk, int localIndex, Value * strm);
105    Value * shortAdvanceCarryInCarryOut(PabloBlock * blk, int localIndex, int shift_amount, Value * strm);
106    Value * longAdvanceCarryInCarryOut(PabloBlock * blk, int localIndex, int shift_amount, Value * strm);
107   
108};
109
110}
111
112#endif // CARRY_MANAGER_H
Note: See TracBrowser for help on using the repository browser.