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

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

Carry Manager restructuring and bug fixes

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