Ignore:
Timestamp:
Dec 26, 2016, 10:17:09 PM (3 years ago)
Author:
cameron
Message:

CBuilder initial check-in

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_builder.h

    r5238 r5239  
    1414#include <llvm/Support/Host.h>
    1515#include <llvm/ADT/Triple.h>
     16#include <IR_Gen/CBuilder.h>
    1617#include <IR_Gen/types/streamtype.h>
    1718#include <boost/container/flat_map.hpp>
     
    2122namespace IDISA {
    2223
    23 class IDISA_Builder : public IRBuilder<> {
     24class IDISA_Builder : public CBuilder {
    2425
    2526    using StreamTypes = boost::container::flat_map<unsigned, StreamType *>;
     
    2829
    2930    IDISA_Builder(Module * m, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride, unsigned CacheAlignment=64)
    30     : IRBuilder<>(m->getContext())
    31     , mMod(m)
    32     , mCacheLineAlignment(CacheAlignment)
     31    : CBuilder(m, archBitWidth, CacheAlignment)
    3332    , mBitBlockWidth(bitBlockWidth)
    3433    , mStride(stride)
    35     , mSizeType(getIntNTy(archBitWidth))
    3634    , mBitBlockType(VectorType::get(IntegerType::get(getContext(), 64), bitBlockWidth / 64))
    3735    , mZeroInitializer(Constant::getNullValue(mBitBlockType))
     
    5755    }
    5856
    59     Module * getModule() const {
    60         return mMod;
    61     }
    62    
    63     void setModule(Module * m)  {
    64         mMod = m;
    65     }
    66    
    6757    Constant * allZeroes() const {
    6858        return mZeroInitializer;
     
    8272    void CreateBlockAlignedStore(Value * const value, Value * const ptr, std::initializer_list<Value *> indices);
    8373
    84     Value * CreateMalloc(Type * type, Value * size);
    85     Value * CreateAlignedMalloc(Type *type, Value * size, const unsigned alignment);
    86     void CreateFree(Value * ptr);
    87     void CreateAlignedFree(Value * ptr);
    88     Value * CreateRealloc(Value * ptr, Value * size);
    89     Value * CreateAlignedRealloc(Value * ptr, Value * size, const unsigned alignment);
    90     void CreateMemZero(Value * ptr, Value * size, const unsigned alignment = 1);
    91 
    9274    void CallPrintRegister(const std::string & regName, Value * const value);
    93     void CallPrintInt(const std::string & name, Value * const value);
    94 
     75   
    9576    VectorType * fwVectorType(unsigned fw);
    9677
     
    153134    Value * fwCast(unsigned fw, Value * a);
    154135   
    155     inline llvm::IntegerType * getSizeTy() const {
    156         return mSizeType;
    157     }
    158 
    159     inline llvm::ConstantInt * getSize(const size_t value) const {
    160         return ConstantInt::get(getSizeTy(), value);
    161     }
    162 
    163     PointerType * getVoidPtrTy() const;
    164 
    165136    inline VectorType * getBitBlockType() const {
    166137        return mBitBlockType;
    167     }
    168 
    169     inline unsigned getCacheAlignment() const {
    170         return mCacheLineAlignment;
    171138    }
    172139
     
    183150    }
    184151   
    185     virtual llvm::LoadInst* CreateAtomicLoadAcquire(Value * ptr);
    186     virtual llvm::StoreInst *  CreateAtomicStoreRelease(Value * val, Value * ptr);
    187    
    188152protected:
    189     Module *            mMod;
    190     unsigned            mCacheLineAlignment;
    191153    unsigned            mBitBlockWidth;
    192154    unsigned            mStride;
    193     IntegerType *       mSizeType;
    194155    VectorType *        mBitBlockType;
    195156
     
    197158    Constant *          mOneInitializer;
    198159    Constant *          mPrintRegisterFunction;
    199    
    200160    StreamTypes         mStreamTypes;
    201161};
     
    209169}
    210170
    211 inline LoadInst * IDISA_Builder::CreateBlockAlignedLoad(Value * const ptr, std::initializer_list<Value *> indicies) {
    212     return CreateBlockAlignedLoad(CreateGEP(ptr, indicies));
     171inline LoadInst * IDISA_Builder::CreateBlockAlignedLoad(Value * const ptr, std::initializer_list<Value *> indices) {
     172    return CreateBlockAlignedLoad(CreateGEP(ptr, indices));
    213173}
    214174
     
    221181}
    222182
    223 inline void IDISA_Builder::CreateBlockAlignedStore(Value * const value, Value * const ptr, std::initializer_list<Value *> indicies) {
    224     CreateBlockAlignedStore(value, CreateGEP(ptr, indicies));
     183inline void IDISA_Builder::CreateBlockAlignedStore(Value * const value, Value * const ptr, std::initializer_list<Value *> indices) {
     184    CreateBlockAlignedStore(value, CreateGEP(ptr, indices));
    225185}
    226186   
Note: See TracChangeset for help on using the changeset viewer.