Ignore:
Timestamp:
Feb 29, 2016, 3:09:51 PM (3 years ago)
Author:
lindanl
Message:

Use kernel state methods.

File:
1 edited

Legend:

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

    r4939 r4945  
    3434       
    3535       
    36 void generateScanWordRoutine(Module * m, IDISA::IDISA_Builder * iBuilder, int scanwordBitWidth, Type * kernelStuctType, bool isNameExpression) {
     36void generateScanWordRoutine(Module * m, IDISA::IDISA_Builder * iBuilder, KernelBuilder * kBuilder, int scanwordBitWidth, bool isNameExpression) {
    3737    LLVMContext & ctxt = m->getContext();
    3838    Type * T = iBuilder->getIntNTy(scanwordBitWidth);   
    3939    Type * S = PointerType::get(iBuilder->getIntNTy(8), 0);
    4040    Type * returnType = StructType::get(ctxt, std::vector<Type *>({T, T}));
     41    Type * kernelStuctType = PointerType::get(kBuilder->getKernelStructType(), 0);
    4142    FunctionType * functionType = FunctionType::get(returnType, std::vector<Type *>({kernelStuctType, T, T, T, T, T}), false);
    4243    Function * sFunction;
     
    141142    Value * matchRecordEnd = iBuilder->CreateAdd(scanwordPos, generateCountForwardZeroes(iBuilder, matches_phi));
    142143
    143     Value* filebuf_gep = iBuilder->CreateGEP(this_input_parm, {iBuilder->getInt64(0), iBuilder->getInt32(0), iBuilder->getInt32(7)});
    144     Value* filebufptr = iBuilder->CreateLoad(filebuf_gep, "filebuf");
    145 
    146     Value* filesize_gep = iBuilder->CreateGEP(this_input_parm, {iBuilder->getInt64(0), iBuilder->getInt32(0), iBuilder->getInt32(8)});
    147     Value* filesize = iBuilder->CreateLoad(filesize_gep, "filensize");
    148 
    149     Value* filename_gep = iBuilder->CreateGEP(this_input_parm, {iBuilder->getInt64(0), iBuilder->getInt32(0), iBuilder->getInt32(9)});
    150     Value* filenameptr = iBuilder->CreateLoad(filename_gep, "filename");
     144    Value* filebufptr = kBuilder->getKernelInternalState(this_input_parm, 7);
     145    Value* filesize = kBuilder->getKernelInternalState(this_input_parm, 8);
     146    Value* filenameptr = kBuilder->getKernelInternalState(this_input_parm, 9);
    151147
    152148    if(isNameExpression)
     
    215211    kBuilder->PrepareDoBlockFunction();
    216212
    217     Type * kernelStuctType = PointerType::get(kBuilder->getKernelStructType(), 0);
    218     generateScanWordRoutine(m, iBuilder, scanwordBitWidth, kernelStuctType, isNameExpression);
     213    generateScanWordRoutine(m, iBuilder, kBuilder, scanwordBitWidth, isNameExpression);
    219214
    220215    struct Inputs inputs = kBuilder->openDoBlock();
     
    222217    Value * kernelStuctParam = kBuilder->getKernelStructParam();
    223218   
    224     Value * scanwordPos = kBuilder->getKernelInternalState(blockPosIdx);
    225     Value * recordStart = kBuilder->getKernelInternalState(lineStartIdx);
    226     Value * recordNum = kBuilder->getKernelInternalState(lineNumIdx);
     219    Value * scanwordPos = kBuilder->getKernelInternalState(kernelStuctParam, blockPosIdx);
     220    Value * recordStart = kBuilder->getKernelInternalState(kernelStuctParam, lineStartIdx);
     221    Value * recordNum = kBuilder->getKernelInternalState(kernelStuctParam, lineNumIdx);
    227222    Value * wordResult = nullptr;
    228223
     
    242237    }
    243238
    244     kBuilder->changeKernelInternalState(blockPosIdx, scanwordPos);
    245     kBuilder->changeKernelInternalState(lineStartIdx, recordStart);
    246     kBuilder->changeKernelInternalState(lineNumIdx, recordNum);
     239    kBuilder->changeKernelInternalState(kernelStuctParam, blockPosIdx, scanwordPos);
     240    kBuilder->changeKernelInternalState(kernelStuctParam, lineStartIdx, recordStart);
     241    kBuilder->changeKernelInternalState(kernelStuctParam, lineNumIdx, recordNum);
    247242
    248243    kBuilder->closeDoBlock(outputs);
Note: See TracChangeset for help on using the changeset viewer.