Ignore:
Timestamp:
Feb 9, 2017, 4:06:24 PM (2 years ago)
Author:
cameron
Message:

Boundary assertions; comment out a bug with RemoveNullableAfterAssertion?

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

Legend:

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

    r5283 r5308  
    1111#include <llvm/IR/Function.h>
    1212#include <llvm/IR/TypeBuilder.h>
     13#include <fcntl.h>  // for
    1314
    1415using namespace llvm;
     16
     17llvm::Value * CBuilder::CreateOpenCall(Value * filename, Value * oflag, Value * mode) {
     18    Function * openFn = mMod->getFunction("open");
     19    if (openFn == nullptr) {
     20        IntegerType * int32Ty = getInt32Ty();
     21        PointerType * int8PtrTy = getInt8PtrTy();
     22        openFn = cast<Function>(mMod->getOrInsertFunction("open",
     23                                                         int32Ty, int8PtrTy, int32Ty, int32Ty, nullptr));
     24    }
     25    return CreateCall(openFn, {filename, oflag, mode});
     26}
     27
     28
    1529
    1630// ssize_t write(int fildes, const void *buf, size_t nbyte);
     
    4054    return CreateCall(readFn, {fildes, buf, nbyte});
    4155}
     56
     57llvm::Value * CBuilder::CreateCloseCall(Value * fildes) {
     58    Function * closeFn = mMod->getFunction("close");
     59    if (closeFn == nullptr) {
     60        IntegerType * int32Ty = getInt32Ty();
     61        closeFn = cast<Function>(mMod->getOrInsertFunction("close",
     62                                                           int32Ty, int32Ty, nullptr));
     63    }
     64    return CreateCall(closeFn, {fildes});
     65}
     66
     67
    4268
    4369Function * CBuilder::GetPrintf() {
  • icGREP/icgrep-devel/icgrep/IR_Gen/CBuilder.h

    r5283 r5308  
    5252    // stdio.h functions
    5353    //
    54     //  Create a call to:  FILE *fopen(const char *filename, const char *mode);
     54    //  Create a call to:  FILE * fopen(const char *filename, const char *mode);
    5555    llvm::Value * CreateFOpenCall(llvm::Value * filename, llvm::Value * mode);
    5656    //  Create a call to:  size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream);
     
    6565    //  Create calls to unistd.h functions.
    6666    //
     67    //  Create a call to:  int open(const char *filename, int oflag, ...);
     68    llvm::Value * CreateOpenCall(llvm::Value * filename, llvm::Value * oflag, llvm::Value * mode);
    6769    //  Create a call to:  ssize_t write(int fildes, const void *buf, size_t nbyte);
    6870    llvm::Value * CreateWriteCall(llvm::Value * fildes, llvm::Value * buf, llvm::Value * nbyte);
    6971    //  Create a call to:  ssize_t read(int fildes, void *buf, size_t nbyte);
    7072    llvm::Value * CreateReadCall(llvm::Value * fildes, llvm::Value * buf, llvm::Value * nbyte);
     73    //  Create a call to:  int close(int filedes);
     74    llvm::Value * CreateCloseCall(llvm::Value * fildes);
    7175
    72    
    7376    //  Posix thread (pthread.h) functions.
    7477    //
Note: See TracChangeset for help on using the changeset viewer.