Ignore:
Timestamp:
Nov 7, 2016, 12:08:13 PM (3 years ago)
Author:
nmedfort
Message:

More 32-bit fixes.

Location:
icGREP/icgrep-devel/icgrep/kernels
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/scanmatchgen.cpp

    r5202 r5204  
    4040
    4141       
    42 void scanMatchKernel::generateDoBlockMethod() {
     42void ScanMatchKernel::generateDoBlockMethod() {
    4343    auto savePoint = iBuilder->saveIP();
    4444    Module * m = iBuilder->getModule();
    4545    Function * scanWordFunction = generateScanWordRoutine(m);
    46     const unsigned fieldCount = iBuilder->getBitBlockWidth() / mScanwordBitWidth;
    47     Type * T = iBuilder->getIntNTy(mScanwordBitWidth);
     46    IntegerType * T = iBuilder->getSizeTy();
     47    const unsigned fieldCount = iBuilder->getBitBlockWidth() / T->getBitWidth();
     48
    4849    Type * scanwordVectorType =  VectorType::get(T, fieldCount);
    4950
     
    6667        Value * recordBreaksWord = iBuilder->CreateExtractElement(breakWordVector, ConstantInt::get(T, i));
    6768        Value * wordResult = iBuilder->CreateCall(scanWordFunction, {kernelStuctParam, matchWord, recordBreaksWord, scanwordPos, recordStart, recordNum});
    68         scanwordPos = iBuilder->CreateAdd(scanwordPos, ConstantInt::get(T, mScanwordBitWidth));
     69        scanwordPos = iBuilder->CreateAdd(scanwordPos, ConstantInt::get(T, T->getBitWidth()));
    6970        recordStart = iBuilder->CreateExtractValue(wordResult, std::vector<unsigned>({0}));
    7071        recordNum = iBuilder->CreateExtractValue(wordResult, std::vector<unsigned>({1}));
     
    7778
    7879   
    79 Function * scanMatchKernel::generateScanWordRoutine(Module * m) {
     80Function * ScanMatchKernel::generateScanWordRoutine(Module * m) {
    8081    Function * function = m->getFunction("scan_matches_in_scanword");
    8182    if (LLVM_UNLIKELY(function != nullptr)) {
     
    8485   
    8586    LLVMContext & ctxt = m->getContext();
    86     Type * T = iBuilder->getIntNTy(mScanwordBitWidth);
     87
     88    IntegerType * T = iBuilder->getSizeTy();
    8789    Type * S = PointerType::get(iBuilder->getIntNTy(8), 0);
    8890    Type * returnType = StructType::get(ctxt, std::vector<Type *>({T, T}));
     
    174176    Value * matchRecordNum = iBuilder->CreateAdd(generatePopcount(iBuilder, prior_breaks), recordNum_phi);
    175177    Value * reverseDistance = generateCountReverseZeroes(iBuilder, prior_breaks);
    176     Value * width = ConstantInt::get(T, mScanwordBitWidth);
     178    Value * width = ConstantInt::get(T, T->getBitWidth());
    177179    Value * matchRecordStart = iBuilder->CreateAdd(scanwordPos, iBuilder->CreateSub(width, reverseDistance));
    178180    iBuilder->CreateBr(loop_final_block);
  • icGREP/icgrep-devel/icgrep/kernels/scanmatchgen.h

    r5202 r5204  
    1717namespace kernel {
    1818   
    19 class scanMatchKernel : public KernelBuilder {
     19class ScanMatchKernel : public KernelBuilder {
    2020public:
    21     scanMatchKernel(IDISA::IDISA_Builder * iBuilder, bool isNameExpression) :
     21    ScanMatchKernel(IDISA::IDISA_Builder * iBuilder, bool isNameExpression) :
    2222    KernelBuilder(iBuilder, "scanMatch",
    2323                  {Binding{parabix::StreamSetType(iBuilder,2, 1), "matchResults"}},
     
    2727                    {Binding{iBuilder->getSizeTy(), "BlockNo"}, Binding{iBuilder->getSizeTy(), "LineStart"}, Binding{iBuilder->getSizeTy(), "LineNum"}}),
    2828
    29     mScanwordBitWidth(Triple(llvm::sys::getProcessTriple()).isArch32Bit() ? 32 : 64),
    3029    mIsNameExpression(isNameExpression) {}
    3130       
     
    3433    llvm::Function * generateScanWordRoutine(llvm::Module * m);
    3534       
    36     unsigned mScanwordBitWidth;
    3735    bool mIsNameExpression;
    3836};
  • icGREP/icgrep-devel/icgrep/kernels/stdout_kernel.cpp

    r5202 r5204  
    66#include <kernels/kernel.h>
    77#include <IDISA/idisa_builder.h>
    8 #include <llvm/IR/TypeBuilder.h>
    98
    109namespace kernel {
    1110
    12 static Function * create_write(Module * const mod) {
     11static Function * create_write(Module * const mod, IDISA::IDISA_Builder * builder) {
    1312    Function * write = mod->getFunction("write");
    1413    if (write == nullptr) {
    15         FunctionType *write_type =
    16         TypeBuilder<long(int, char *, long), false>::get(mod->getContext());
    17         write = cast<Function>(mod->getOrInsertFunction("write", write_type,
    18                                                          AttributeSet().addAttribute(mod->getContext(), 2U, Attribute::NoAlias)));
     14        IntegerType * sizeTy = builder->getSizeTy();
     15        IntegerType * int32Ty = builder->getInt32Ty();
     16        PointerType * int8PtrTy = builder->getInt8PtrTy();
     17        write = cast<Function>(mod->getOrInsertFunction("write",
     18                                 AttributeSet().addAttribute(mod->getContext(), 2U, Attribute::NoAlias),
     19                                 sizeTy, int32Ty, int8PtrTy, sizeTy, nullptr));
    1920    }
    2021    return write;
     
    4041    auto savePoint = iBuilder->saveIP();
    4142    Module * m = iBuilder->getModule();
    42     Function * writefn = create_write(m);
     43    Function * writefn = create_write(m, iBuilder);
    4344    Function * doSegmentFunction = m->getFunction(mKernelName + doSegment_suffix);
    4445    Type * i8PtrTy = iBuilder->getInt8PtrTy();
     
    106107    auto savePoint = iBuilder->saveIP();
    107108    Module * m = iBuilder->getModule();
    108     Function * writefn = create_write(m);
     109    Function * writefn = create_write(m, iBuilder);
    109110    Function * finalBlockFunction = m->getFunction(mKernelName + finalBlock_suffix);
    110111    Type * i8PtrTy = iBuilder->getInt8PtrTy();
  • icGREP/icgrep-devel/icgrep/kernels/streamset.cpp

    r5202 r5204  
    145145    Type * const i32 = iBuilder->getInt32Ty();
    146146    Type * const i8_ptr = PointerType::get(i8, mAddrSpace);
     147
     148
    147149    Module * M = iBuilder->getModule();
    148     Function * memmoveFunc = cast<Function>(M->getOrInsertFunction("llvm.memmove.p0i8.p0i8.i" + std::to_string(sizeof(size_t) * 8),
    149                                                                   iBuilder->getVoidTy(), i8_ptr, i8_ptr, iBuilder->getSizeTy(), i32, i1, nullptr));
     150
     151    IntegerType * sizeTy = iBuilder->getSizeTy();
     152
     153    Function * memmoveFunc = cast<Function>(M->getOrInsertFunction("llvm.memmove.p0i8.p0i8.i" + std::to_string(sizeTy->getBitWidth()),
     154                                                                  iBuilder->getVoidTy(), i8_ptr, i8_ptr, sizeTy, i32, i1, nullptr));
    150155    Function * current = iBuilder->GetInsertBlock()->getParent();
    151156    BasicBlock * copyBackBody = BasicBlock::Create(M->getContext(), "copy_back", current, 0);
    152157    BasicBlock * setConsumerPosExit = BasicBlock::Create(M->getContext(), "setConsumerPos_done", current, 0);
    153     Constant * blockWidth = ConstantInt::get(iBuilder->getSizeTy(), iBuilder->getStride());
    154     Constant * one = ConstantInt::get(iBuilder->getSizeTy(), 1);
     158    Constant * blockWidth = ConstantInt::get(sizeTy, iBuilder->getStride());
     159    Constant * one = ConstantInt::get(sizeTy, 1);
    155160    Value * consumerPos_ptr = iBuilder->CreateGEP(bufferStructPtr, {iBuilder->getInt32(0), iBuilder->getInt32(iConsumer_pos)});
    156161    Value * consumerPos = iBuilder->CreateLoad(consumerPos_ptr);
     
    176181    DataLayout dl(iBuilder->getModule());
    177182
    178     Constant * blockBytes = ConstantInt::get(iBuilder->getSizeTy(), dl.getTypeAllocSize(mStreamSetType) * iBuilder->getStride());
     183    Constant * blockBytes = ConstantInt::get(sizeTy, dl.getTypeAllocSize(mStreamSetType) * iBuilder->getStride());
    179184    Value * copyLength = iBuilder->CreateMul(copyBlocks, blockBytes);
    180185    //iBuilder->CallPrintInt("memmove copyLength", copyLength);
     
    182187    Value * handle = iBuilder->CreateGEP(bufferStructPtr, {iBuilder->getInt32(0), iBuilder->getInt32(iBuffer_ptr)});
    183188    Value * bufferPtr = iBuilder->CreateLoad(handle);
    184     //iBuilder->CallPrintInt("memmove bufferPtr", iBuilder->CreatePtrToInt(bufferPtr, iBuilder->getSizeTy()));
     189    //iBuilder->CallPrintInt("memmove bufferPtr", iBuilder->CreatePtrToInt(bufferPtr, sizeTy));
    185190
    186191    Value * copyFrom = iBuilder->CreateGEP(bufferPtr, {iBuilder->CreateSub(new_consumer_block, consumerBlock)});
    187     //iBuilder->CallPrintInt("memmove copyFrom", iBuilder->CreatePtrToInt(copyFrom, iBuilder->getSizeTy()));
     192    //iBuilder->CallPrintInt("memmove copyFrom", iBuilder->CreatePtrToInt(copyFrom, sizeTy));
    188193    Value * alignment = ConstantInt::get(iBuilder->getInt32Ty(), iBuilder->getBitBlockWidth()/8);
    189194   
Note: See TracChangeset for help on using the changeset viewer.