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

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

Clean-ups

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