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/stdout_kernel.cpp

    r5238 r5243  
    88
    99namespace kernel {
    10 
    11 static Function * create_write(Module * const mod, IDISA::IDISA_Builder * builder) {
    12     Function * write = mod->getFunction("write");
    13     if (write == nullptr) {
    14         IntegerType * sizeTy = builder->getSizeTy();
    15         IntegerType * int32Ty = builder->getInt32Ty();
    16         PointerType * int8PtrTy = builder->getInt8PtrTy();
    17         write = cast<Function>(mod->getOrInsertFunction("write",
    18                                  AttributeSet().addAttribute(mod->getContext(), 2U, Attribute::NoAlias),
    19                                  sizeTy, int32Ty, int8PtrTy, sizeTy, nullptr));
    20     }
    21     return write;
    22 }
    2310
    2411// The doBlock method is deprecated.   But in case it is used, just call doSegment with
     
    4128    auto savePoint = iBuilder->saveIP();
    4229    Module * m = iBuilder->getModule();
    43     Function * writefn = create_write(m, iBuilder);
    4430    Function * doSegmentFunction = m->getFunction(mKernelName + doSegment_suffix);
    4531    Type * i8PtrTy = iBuilder->getInt8PtrTy();
     
    7359    Value * bytePtr = iBuilder->CreateGEP(iBuilder->CreateBitCast(basePtr, i8PtrTy), byteOffset);
    7460
    75     iBuilder->CreateCall(writefn, std::vector<Value *>({iBuilder->getInt32(1), bytePtr, iBuilder->CreateMul(itemsToDo, itemBytes)}));
    76    
     61    iBuilder->CreateWriteCall(iBuilder->getInt32(1), bytePtr, iBuilder->CreateMul(itemsToDo, itemBytes));
     62
    7763    processed = iBuilder->CreateAdd(processed, itemsToDo);
    7864    setProcessedItemCount(self, processed);
     
    9783    auto savePoint = iBuilder->saveIP();
    9884    Module * m = iBuilder->getModule();
    99     Function * writefn = create_write(m, iBuilder);
    10085    Function * finalBlockFunction = m->getFunction(mKernelName + finalBlock_suffix);
    10186    Type * i8PtrTy = iBuilder->getInt8PtrTy();
     
    11398    Value * byteOffset = iBuilder->CreateMul(iBuilder->CreateURem(processed, blockItems), itemBytes);
    11499    Value * bytePtr = iBuilder->CreateGEP(iBuilder->CreateBitCast(basePtr, i8PtrTy), byteOffset);
    115     iBuilder->CreateCall(writefn, std::vector<Value *>({iBuilder->getInt32(1), bytePtr, iBuilder->CreateMul(itemsAvail, itemBytes)}));
     100    iBuilder->CreateWriteCall(iBuilder->getInt32(1), bytePtr, iBuilder->CreateMul(itemsAvail, itemBytes));
    116101    setProcessedItemCount(self, producerPos);
    117102    mStreamSetInputBuffers[0]->setConsumerPos(streamStructPtr, producerPos);
Note: See TracChangeset for help on using the changeset viewer.