Changeset 5281


Ignore:
Timestamp:
Jan 26, 2017, 10:38:38 PM (10 months ago)
Author:
cameron
Message:

Stdin kernel: initial check-in

Location:
icGREP/icgrep-devel/icgrep
Files:
2 added
3 edited

Legend:

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

    r5280 r5281  
    2626    }
    2727    return CreateCall(write, {fildes, buf, nbyte});
     28}
     29
     30Value * CBuilder::CreateReadCall(Value * fildes, Value * buf, Value * nbyte) {
     31    Function * readFn = mMod->getFunction("read");
     32    if (readFn == nullptr) {
     33        IntegerType * sizeTy = getSizeTy();
     34        IntegerType * int32Ty = getInt32Ty();
     35        PointerType * int8PtrTy = getInt8PtrTy();
     36        readFn = cast<Function>(mMod->getOrInsertFunction("read",
     37                                                         AttributeSet().addAttribute(mMod->getContext(), 2U, Attribute::NoAlias),
     38                                                         sizeTy, int32Ty, int8PtrTy, sizeTy, nullptr));
     39    }
     40    return CreateCall(readFn, {fildes, buf, nbyte});
    2841}
    2942
     
    259272}
    260273
     274Value * CBuilder::CreateFReadCall(Value * ptr, Value * size, Value * nitems, Value * stream) {
     275    Function * fReadFunc = mMod->getFunction("fread");
     276    if (fReadFunc == nullptr) {
     277        fReadFunc = cast<Function>(mMod->getOrInsertFunction("fread", getSizeTy(), getVoidPtrTy(), getSizeTy(), getSizeTy(), getFILEptrTy(), nullptr));
     278        fReadFunc->setCallingConv(llvm::CallingConv::C);
     279    }
     280    return CreateCall(fReadFunc, {ptr, size, nitems, stream});
     281}
     282
    261283Value * CBuilder::CreateFWriteCall(Value * ptr, Value * size, Value * nitems, Value * stream) {
    262284    Function * fWriteFunc = mMod->getFunction("fwrite");
  • icGREP/icgrep-devel/icgrep/IR_Gen/CBuilder.h

    r5280 r5281  
    5454    //  Create a call to:  FILE *fopen(const char *filename, const char *mode);
    5555    llvm::Value * CreateFOpenCall(llvm::Value * filename, llvm::Value * mode);
     56    //  Create a call to:  size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream);
     57    llvm::Value * CreateFReadCall(llvm::Value * ptr, llvm::Value * size, llvm::Value * nitems, llvm::Value * stream);
    5658    //  Create a call to:  size_t fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream));
    5759    llvm::Value * CreateFWriteCall(llvm::Value * ptr, llvm::Value * size, llvm::Value * nitems, llvm::Value * stream);
     
    6567    //  Create a call to:  ssize_t write(int fildes, const void *buf, size_t nbyte);
    6668    llvm::Value * CreateWriteCall(llvm::Value * fildes, llvm::Value * buf, llvm::Value * nbyte);
     69    //  Create a call to:  ssize_t read(int fildes, void *buf, size_t nbyte);
     70    llvm::Value * CreateReadCall(llvm::Value * fildes, llvm::Value * buf, llvm::Value * nbyte);
     71
    6772   
    6873    //  Posix thread (pthread.h) functions.
  • icGREP/icgrep-devel/icgrep/cc/alphabet.h

    r5279 r5281  
    3636    virtual unsigned fromUnicode(UCD::codepoint_t ucp);
    3737
    38 private:
     38protected:
    3939    std::string mAlphabetName;
    4040    UCD::UnicodeSet mCharSet;
Note: See TracChangeset for help on using the changeset viewer.