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

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

Prepare for non-bitblock carry summaries; use IDISA bitblock_any

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(IRBuilder <> * b, VectorType * bitBlockType, ConstantAggregateZero * zero, Constant * one, IDISA::IDISA_Builder * idb)
34    : mBuilder(b)
35    , mBitBlockType(bitBlockType)
36    , mZeroInitializer(zero)
37    , mOneInitializer(one)
38    , iBuilder(idb) {
39
40    }
41   
42    unsigned initialize(PabloBlock * blk, Value * carryDataPtr); 
43   
44    void generateBlockNoIncrement();
45   
46    Value * getBlockNoPtr();
47   
48    /* Methods for processing individual carry-generating operations. */
49   
50    Value * getCarryOpCarryIn(PabloBlock * blk, int localIndex);
51
52    void setCarryOpCarryOut(PabloBlock * blk, unsigned idx, Value * carry_out);
53
54    Value * advanceCarryInCarryOut(PabloBlock * blk, int localIndex, int shift_amount, Value * strm);
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    IDISA::IDISA_Builder * iBuilder;
91    PabloBlock * mPabloRoot;
92    Value * mCarryDataPtr;
93    Value * mBlockNoPtr;
94    Value * mBlockNo;
95    unsigned mTotalCarryDataSize;
96
97    std::vector<Value *> mCarryInVector;
98    std::vector<PHINode *> mCarryInPhis; 
99    std::vector<PHINode *> mCarryOutAccumPhis; 
100    std::vector<Value *> mCarryOutVector;
101
102    Value * unitAdvanceCarryInCarryOut(PabloBlock * blk, int localIndex, Value * strm);
103    Value * shortAdvanceCarryInCarryOut(PabloBlock * blk, int localIndex, int shift_amount, Value * strm);
104    Value * longAdvanceCarryInCarryOut(PabloBlock * blk, int localIndex, int shift_amount, Value * strm);
105   
106};
107
108}
109
110#endif // CARRY_MANAGER_H
Note: See TracBrowser for help on using the repository browser.