Ignore:
Timestamp:
Dec 29, 2016, 11:23:44 PM (3 years ago)
Author:
cameron
Message:

Support for write function in CBuilder, use IRBuilder CreateMemMove? for llvm.memmove.p0i8.p0i8.i64

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/streamset.cpp

    r5240 r5243  
    128128
    129129void LinearCopybackBuffer::setConsumerPos(Value * bufferStructPtr, Value * new_consumer_pos) {
    130     Type * const i1 = iBuilder->getInt1Ty();
    131130    Type * const i8 = iBuilder->getInt8Ty();
    132     Type * const i32 = iBuilder->getInt32Ty();
    133131    Type * const i8_ptr = i8->getPointerTo(mAddrSpace);
    134132    IntegerType * const sizeTy = iBuilder->getSizeTy();
     
    136134    Module * const M = iBuilder->getModule();
    137135
    138     Function * const memmoveFunc = cast<Function>(M->getOrInsertFunction("llvm.memmove.p0i8.p0i8.i" + std::to_string(sizeTy->getBitWidth()),
    139                                                                   iBuilder->getVoidTy(), i8_ptr, i8_ptr, sizeTy, i32, i1, nullptr));
    140136    Function * const current = iBuilder->GetInsertBlock()->getParent();
    141137    BasicBlock * const copyBackBody = BasicBlock::Create(M->getContext(), "copy_back", current, 0);
     
    175171    Value * const consumerBlock = iBuilder->CreateUDiv(consumerPos, blockWidth);
    176172    Value * copyFrom = iBuilder->CreateGEP(bufferPtr, iBuilder->CreateSub(new_consumer_block, consumerBlock));
    177     Value * alignment = ConstantInt::get(iBuilder->getInt32Ty(), iBuilder->getBitBlockWidth() / 8);
    178    
    179     iBuilder->CreateCall(memmoveFunc, {iBuilder->CreateBitCast(bufferPtr, i8_ptr), iBuilder->CreateBitCast(copyFrom, i8_ptr), copyLength, alignment, ConstantInt::getNullValue(i1)});
     173    unsigned alignment = iBuilder->getBitBlockWidth() / 8;
     174    iBuilder->CreateMemMove(iBuilder->CreateBitCast(bufferPtr, i8_ptr), iBuilder->CreateBitCast(copyFrom, i8_ptr), copyLength, alignment);
    180175    iBuilder->CreateBr(setConsumerPosExit);
    181176    // Copy back done, store the new consumer position.
Note: See TracChangeset for help on using the changeset viewer.