Ignore:
Timestamp:
Dec 3, 2017, 12:40:40 PM (23 months ago)
Author:
nmedfort
Message:

Bug fixes and simplified MultiBlockKernel? logic

File:
1 edited

Legend:

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

    r5746 r5755  
    5757    llvm::Value * CreateUDivCeil(llvm::Value * number, llvm::Value * divisor, const llvm::Twine &Name = "");
    5858   
    59     llvm::Value * CreateUDivCeil(llvm::Value * number, const uint64_t divisor, const llvm::Twine &Name = "");
    60 
    6159    // Round up to a multiple of divisor.
    6260    llvm::Value * CreateRoundUp(llvm::Value * number, llvm::Value * divisor, const llvm::Twine &Name = "");
    6361           
    6462    // Get minimum of two unsigned numbers
    65     llvm::Value * CreateUMin(llvm::Value * a, llvm::Value * b) {
     63    llvm::Value * CreateUMin(llvm::Value * const a, llvm::Value * const b) {
     64        if (a == nullptr) return b;
     65        if (b == nullptr) return a;
    6666        assert (a->getType() == b->getType());
    6767        return CreateSelect(CreateICmpULT(a, b), a, b);
     
    6969
    7070    // Get minimum of two signed numbers
    71     llvm::Value * CreateSMin(llvm::Value * a, llvm::Value * b) {
     71    llvm::Value * CreateSMin(llvm::Value * const a, llvm::Value * const b) {
     72        if (a == nullptr) return b;
     73        if (b == nullptr) return a;
    7274        assert (a->getType() == b->getType());
    7375        return CreateSelect(CreateICmpSLT(a, b), a, b);
     
    7577
    7678    // Get maximum of two unsigned numbers
    77     llvm::Value * CreateUMax(llvm::Value * a, llvm::Value * b) {
     79    llvm::Value * CreateUMax(llvm::Value * const a, llvm::Value * const b) {
     80        if (a == nullptr) return b;
     81        if (b == nullptr) return a;
    7882        assert (a->getType() == b->getType());
    7983        return CreateSelect(CreateICmpUGT(a, b), a, b);
     
    8185
    8286    // Get maximum of two signed numbers
    83     llvm::Value * CreateSMax(llvm::Value * a, llvm::Value * b) {
     87    llvm::Value * CreateSMax(llvm::Value * const a, llvm::Value * const b) {
     88        if (a == nullptr) return b;
     89        if (b == nullptr) return a;
    8490        assert (a->getType() == b->getType());
    8591        return CreateSelect(CreateICmpSGT(a, b), a, b);
    8692    }
    8793
    88     llvm::Value * CreateMalloc(llvm::Value * size);
    89 
    90     llvm::Value * CreateAlignedMalloc(llvm::Value * size, const unsigned alignment);
     94    llvm::Value * CreateMalloc(llvm::Value * const size);
     95
     96    llvm::Value * CreateAlignedMalloc(llvm::Value * const size, const unsigned alignment);
     97
     98    llvm::Value * CreateCacheAlignedMalloc(llvm::Value * const size) {
     99        return CreateAlignedMalloc(size, getCacheAlignment());
     100    }
    91101   
    92102    void CreateFree(llvm::Value * const ptr);
    93103
    94     llvm::Value * CreateRealloc(llvm::Value * ptr, llvm::Value * size);
    95 
    96     llvm::CallInst * CreateMemZero(llvm::Value * ptr, llvm::Value * size, const unsigned alignment = 1) {
     104    llvm::Value * CreateRealloc(llvm::Value * const ptr, llvm::Value * const size);
     105
     106    llvm::CallInst * CreateMemZero(llvm::Value * const ptr, llvm::Value * const size, const unsigned alignment = 1) {
    97107        return CreateMemSet(ptr, getInt8(0), size, alignment);
    98108    }
    99109
    100     llvm::AllocaInst * CreateCacheAlignedAlloca(llvm::Type * Ty, llvm::Value * ArraySize = nullptr) {
     110    llvm::AllocaInst * CreateAlignedAlloca(llvm::Type * const Ty, const unsigned alignment, llvm::Value * const ArraySize = nullptr) {
    101111        llvm::AllocaInst * instr = CreateAlloca(Ty, ArraySize);
    102         instr->setAlignment(getCacheAlignment());
     112        instr->setAlignment(alignment);
    103113        return instr;
    104114    }
    105115
    106     llvm::Value * CreateCacheAlignedMalloc(llvm::Value * size);
     116    llvm::AllocaInst * CreateCacheAlignedAlloca(llvm::Type * const Ty, llvm::Value * const ArraySize = nullptr) {
     117        return CreateAlignedAlloca(Ty, getCacheAlignment(), ArraySize);
     118    }
    107119
    108120    // stdio.h functions
     
    169181    llvm::Value * CreateMUnmap(llvm::Value * addr, llvm::Value * size);
    170182
     183    enum Protect {
     184        NONE = 0
     185        , READ = 1
     186        , WRITE = 2
     187        , EXEC = 4
     188    };
     189
     190    llvm::Value * CreateMProtect(llvm::Value * addr, llvm::Value * size, int protect);
     191
    171192    //  Posix thread (pthread.h) functions.
    172193    //
     
    203224    llvm::IntegerType * getIntAddrTy() const;
    204225   
    205     llvm::PointerType * getVoidPtrTy() const;
     226    llvm::PointerType * getVoidPtrTy(const unsigned AddressSpace = 0) const;
    206227   
    207228    llvm::PointerType * getFILEptrTy();
     
    310331                           llvm::MDNode *NoAliasTag = nullptr);
    311332
     333    llvm::CallInst * CreateMemSet(llvm::Value *Ptr, llvm::Value *Val, uint64_t Size, unsigned Align,
     334                           bool isVolatile = false, llvm::MDNode *TBAATag = nullptr,
     335                           llvm::MDNode *ScopeTag = nullptr,
     336                           llvm::MDNode *NoAliasTag = nullptr) {
     337        return CreateMemSet(Ptr, Val, getInt64(Size), Align, isVolatile, TBAATag, ScopeTag, NoAliasTag);
     338    }
     339
     340    llvm::CallInst * CreateMemSet(llvm::Value *Ptr, llvm::Value *Val, llvm::Value *Size, unsigned Align,
     341                           bool isVolatile = false, llvm::MDNode *TBAATag = nullptr,
     342                           llvm::MDNode *ScopeTag = nullptr,
     343                           llvm::MDNode *NoAliasTag = nullptr);
    312344
    313345    void setDriver(Driver * const driver) {
Note: See TracChangeset for help on using the changeset viewer.