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/IR_Gen/CBuilder.cpp

    r5242 r5243  
    1313#include <llvm/IR/TypeBuilder.h>
    1414
    15    
     15
     16
     17// ssize_t write(int fildes, const void *buf, size_t nbyte);
     18Value * CBuilder::CreateWriteCall(Value * fildes, Value * buf, Value * nbyte) {
     19    Function * write = mMod->getFunction("write");
     20    if (write == nullptr) {
     21        IntegerType * sizeTy = getSizeTy();
     22        IntegerType * int32Ty = getInt32Ty();
     23        PointerType * int8PtrTy = getInt8PtrTy();
     24        write = cast<Function>(mMod->getOrInsertFunction("write",
     25                                                        AttributeSet().addAttribute(mMod->getContext(), 2U, Attribute::NoAlias),
     26                                                        sizeTy, int32Ty, int8PtrTy, sizeTy, nullptr));
     27    }
     28    return CreateCall(write, {fildes, buf, nbyte});
     29}
     30
    1631Function * CBuilder::GetPrintf() {
    1732    Function * printf = mMod->getFunction("printf");
Note: See TracChangeset for help on using the changeset viewer.