Ignore:
Timestamp:
Aug 4, 2017, 12:31:21 PM (22 months ago)
Author:
nmedfort
Message:

Modified stream set buffers to use heap memory.

Location:
icGREP/icgrep-devel/icgrep/IR_Gen
Files:
2 edited

Legend:

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

    r5543 r5597  
    295295}
    296296
     297llvm::Value * CBuilder::CreateCacheAlignedMalloc(llvm::Value * size) {
     298    const auto alignment = getCacheAlignment();
     299    if (LLVM_LIKELY(isa<Constant>(size))) {
     300        Constant * const align = ConstantInt::get(size->getType(), alignment, false);
     301        Constant * offset = ConstantExpr::getURem(cast<Constant>(size), align);
     302        if (!offset->isNullValue()) {
     303            size = ConstantExpr::getAdd(cast<Constant>(size), ConstantExpr::getSub(align, offset));
     304        }
     305    }
     306    return CreateAlignedMalloc(size, alignment);
     307}
     308
    297309Value * CBuilder::CreateAlignedMalloc(Value * size, const unsigned alignment) {
    298310    if (LLVM_UNLIKELY((alignment & (alignment - 1)) != 0)) {
     
    308320        CreateAssertZero(CreateURem(size, align), "CreateAlignedMalloc: size must be an integral multiple of alignment.");
    309321    }
    310 
    311322    Value * ptr = nullptr;
    312323    if (hasAlignedAlloc()) {
     
    363374    }
    364375    CallInst * const ci = CreateCall(f, {CreatePointerCast(ptr, voidPtrTy), CreateZExtOrTrunc(size, sizeTy)});
    365 
    366376    return CreatePointerCast(ci, ptr->getType());
    367377}
  • icGREP/icgrep-devel/icgrep/IR_Gen/CBuilder.h

    r5543 r5597  
    7878    }
    7979
    80     llvm::Value * CreateCacheAlignedMalloc(llvm::Value * size) {
    81         return CreateAlignedMalloc(size, getCacheAlignment());
    82     }
     80    llvm::Value * CreateCacheAlignedMalloc(llvm::Value * size);
    8381
    8482    // stdio.h functions
Note: See TracChangeset for help on using the changeset viewer.