Ignore:
Timestamp:
Apr 23, 2017, 12:44:04 PM (2 years ago)
Author:
nmedfort
Message:

Bug fixes for 32-bit systems

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/grep_engine.cpp

    r5418 r5419  
    5858static std::vector<std::string> parsedPropertyValues;
    5959
    60 uint64_t GrepEngine::doGrep(const std::string & fileName, const int fileIdx) const {
    61     const int fd = open(fileName.c_str(), O_RDONLY);
     60uint64_t GrepEngine::doGrep(const std::string & fileName, const uint32_t fileIdx) const {
     61    const int32_t fd = open(fileName.c_str(), O_RDONLY);
    6262    if (LLVM_UNLIKELY(fd == -1)) {
    6363        return 0;
     
    6868}
    6969
    70 uint64_t GrepEngine::doGrep(const uint32_t fileDescriptor, const int fileIdx) const {
     70uint64_t GrepEngine::doGrep(const int32_t fileDescriptor, const uint32_t fileIdx) const {
    7171    assert (mGrepFunction);
    72     typedef uint64_t (*GrepFunctionType)(size_t fileDescriptor, const int fileIdx);
     72    typedef uint64_t (*GrepFunctionType)(int32_t fileDescriptor, const uint32_t fileIdx);
    7373    return reinterpret_cast<GrepFunctionType>(mGrepFunction)(fileDescriptor, fileIdx);
    7474}
    7575
    76 void GrepEngine::doGrep(const char * buffer, const uint64_t length, const int fileIdx) const {
     76void GrepEngine::doGrep(const char * buffer, const uint64_t length, const uint32_t fileIdx) const {
    7777    assert (mGrepFunction);
    78     typedef uint64_t (*GrepFunctionType)(const char * buffer, const uint64_t length, const int fileIdx);
     78    typedef uint64_t (*GrepFunctionType)(const char * buffer, const uint64_t length, const uint32_t fileIdx);
    7979    reinterpret_cast<GrepFunctionType>(mGrepFunction)(buffer, length, fileIdx);
    8080}
     
    223223
    224224    Type * const int64Ty = iBuilder->getInt64Ty();
     225    Type * const int32Ty = iBuilder->getInt32Ty();
    225226
    226227    Function * mainFunc = nullptr;
     
    231232    if (grepSource == GrepSource::Internal) {
    232233
    233         mainFunc = cast<Function>(M->getOrInsertFunction("Main", int64Ty, iBuilder->getInt8PtrTy(), int64Ty, int64Ty, nullptr));
     234        mainFunc = cast<Function>(M->getOrInsertFunction("Main", int64Ty, iBuilder->getInt8PtrTy(), int64Ty, int32Ty, nullptr));
    234235        mainFunc->setCallingConv(CallingConv::C);
    235236        iBuilder->SetInsertPoint(BasicBlock::Create(M->getContext(), "entry", mainFunc, 0));
     
    238239        Value * const buffer = &*(args++);
    239240        buffer->setName("buffer");
    240         Value * const length = &*(args++);
     241
     242        Value * length = &*(args++);
    241243        length->setName("length");
     244        length = iBuilder->CreateZExtOrTrunc(length, iBuilder->getSizeTy());
     245
    242246        fileIdx = &*(args++);
    243247        fileIdx->setName("fileIdx");
     
    250254    } else {
    251255
    252         mainFunc = cast<Function>(M->getOrInsertFunction("Main", int64Ty, iBuilder->getInt32Ty(), int64Ty, nullptr));
     256        mainFunc = cast<Function>(M->getOrInsertFunction("Main", int64Ty, iBuilder->getInt32Ty(), int32Ty, nullptr));
    253257        mainFunc->setCallingConv(CallingConv::C);
    254258        iBuilder->SetInsertPoint(BasicBlock::Create(M->getContext(), "entry", mainFunc, 0));
     
    307311        pxDriver.addKernelCall(matchCountK, {MergedResults}, {});
    308312        pxDriver.generatePipelineIR();
    309         iBuilder->CreateRet(matchCountK.getScalarField("matchedLineCount"));
     313        Value * matchedLineCount = matchCountK.getScalarField("matchedLineCount");
     314        matchedLineCount = iBuilder->CreateZExt(matchedLineCount, int64Ty);
     315        iBuilder->CreateRet(matchedLineCount);
    310316        pxDriver.linkAndFinalize();
    311317    } else {
Note: See TracChangeset for help on using the changeset viewer.