Ignore:
Timestamp:
Apr 28, 2017, 2:50:59 PM (2 years ago)
Author:
nmedfort
Message:

Refactored source kernels. icgrep from stdin should now be able to handle any file size.

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

Legend:

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

    r5427 r5429  
    3030// ssize_t write(int fildes, const void *buf, size_t nbyte);
    3131Value * CBuilder::CreateWriteCall(Value * fileDescriptor, Value * buf, Value * nbyte) {
     32    PointerType * voidPtrTy = getVoidPtrTy();
    3233    Function * write = mMod->getFunction("write");
    3334    if (write == nullptr) {
    3435        IntegerType * sizeTy = getSizeTy();
    3536        IntegerType * int32Ty = getInt32Ty();
    36         PointerType * int8PtrTy = getInt8PtrTy();
    3737        write = cast<Function>(mMod->getOrInsertFunction("write",
    3838                                                        AttributeSet().addAttribute(getContext(), 2U, Attribute::NoAlias),
    39                                                         sizeTy, int32Ty, int8PtrTy, sizeTy, nullptr));
    40     }
     39                                                        sizeTy, int32Ty, voidPtrTy, sizeTy, nullptr));
     40    }
     41    buf = CreatePointerCast(buf, voidPtrTy);
    4142    return CreateCall(write, {fileDescriptor, buf, nbyte});
    4243}
    4344
    4445Value * CBuilder::CreateReadCall(Value * fileDescriptor, Value * buf, Value * nbyte) {
     46    PointerType * voidPtrTy = getVoidPtrTy();
    4547    Function * readFn = mMod->getFunction("read");
    4648    if (readFn == nullptr) {
    4749        IntegerType * sizeTy = getSizeTy();
    4850        IntegerType * int32Ty = getInt32Ty();
    49         PointerType * int8PtrTy = getInt8PtrTy();
    5051        readFn = cast<Function>(mMod->getOrInsertFunction("read",
    5152                                                         AttributeSet().addAttribute(getContext(), 2U, Attribute::NoAlias),
    52                                                          sizeTy, int32Ty, int8PtrTy, sizeTy, nullptr));
    53     }
     53                                                         sizeTy, int32Ty, voidPtrTy, sizeTy, nullptr));
     54    }
     55    buf = CreatePointerCast(buf, voidPtrTy);
    5456    return CreateCall(readFn, {fileDescriptor, buf, nbyte});
    5557}
  • icGREP/icgrep-devel/icgrep/IR_Gen/CBuilder.h

    r5427 r5429  
    3737        mMod = m;
    3838    }
    39 
    4039
    4140    llvm::Value * CreateMalloc(llvm::Value * size);
     
    154153   
    155154    llvm::PointerType * getVoidPtrTy() const;
     155
    156156    llvm::PointerType * getFILEptrTy();
    157157   
Note: See TracChangeset for help on using the changeset viewer.