Ignore:
Timestamp:
Jan 31, 2017, 4:08:11 PM (2 years ago)
Author:
nmedfort
Message:

Removed 'function' and 'self' parameters from generateXXXMethod() functions.

File:
1 edited

Legend:

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

    r5286 r5292  
    1212namespace kernel {
    1313   
    14 void StdInKernel::generateDoSegmentMethod(Function *doSegmentFunction, Value *self, Value *doFinal, const std::vector<Value *> &producerPos) const {
     14void StdInKernel::generateDoSegmentMethod(Value *doFinal, const std::vector<Value *> &producerPos) {
    1515
    1616    Type * i8PtrTy = iBuilder->getInt8PtrTy();
    1717   
    18     iBuilder->SetInsertPoint(BasicBlock::Create(iBuilder->getContext(), "entry", doSegmentFunction, 0));
    19     BasicBlock * setTermination = BasicBlock::Create(iBuilder->getContext(), "setTermination", doSegmentFunction, 0);
    20     BasicBlock * stdInExit = BasicBlock::Create(iBuilder->getContext(), "stdInExit", doSegmentFunction, 0);
     18    BasicBlock * setTermination = CreateBasicBlock("setTermination");
     19    BasicBlock * stdInExit = CreateBasicBlock("stdInExit");
    2120    ConstantInt * blockItems = iBuilder->getSize(iBuilder->getBitBlockWidth());
    2221    ConstantInt * itemBytes = iBuilder->getSize(mCodeUnitWidth/8);
    2322    ConstantInt * segmentBytes = iBuilder->getSize(mSegmentBlocks * iBuilder->getBitBlockWidth() * mCodeUnitWidth/8);
    2423    ConstantInt * stdin_fileno = iBuilder->getInt32(STDIN_FILENO);
    25     Value * produced = getProducedItemCount(self, "codeUnitBuffer");
     24    Value * produced = getProducedItemCount("codeUnitBuffer");
    2625    Value * blockNo = iBuilder->CreateUDiv(produced, blockItems);
    2726    Value * byteOffset = iBuilder->CreateMul(iBuilder->CreateURem(produced, blockItems), itemBytes);
    28     Value * bytePtr = getStreamView(i8PtrTy, self, "codeUnitBuffer", blockNo, byteOffset);
     27    Value * bytePtr = getStreamView(i8PtrTy, "codeUnitBuffer", blockNo, byteOffset);
    2928   
    3029    Value * nRead = iBuilder->CreateReadCall(stdin_fileno, bytePtr, segmentBytes);
    3130    Value * bytesRead = iBuilder->CreateSelect(iBuilder->CreateICmpSLT(nRead, iBuilder->getSize(0)), iBuilder->getSize(0), nRead);
    3231    produced = iBuilder->CreateAdd(produced, iBuilder->CreateUDiv(bytesRead, itemBytes));
    33     setProducedItemCount(self, "codeUnitBuffer", produced);
     32    setProducedItemCount("codeUnitBuffer", produced);
    3433    Value * lessThanFullSegment = iBuilder->CreateICmpULT(bytesRead, segmentBytes);
    3534    iBuilder->CreateCondBr(lessThanFullSegment, setTermination, stdInExit);
    3635    iBuilder->SetInsertPoint(setTermination);
    37     setTerminationSignal(self);
     36    setTerminationSignal();
    3837    iBuilder->CreateBr(stdInExit);
    3938   
     
    5049}
    5150
    52 void FileSource::generateInitMethod(Function * initFunction, Value * self) const {
    53     BasicBlock * setTerminationOnFailure = BasicBlock::Create(iBuilder->getContext(), "setTerminationOnFailure", initFunction, 0);
    54     BasicBlock * fileSourceInitExit = BasicBlock::Create(iBuilder->getContext(), "fileSourceInitExit", initFunction, 0);
    55     Value * handle = iBuilder->CreateFOpenCall(getScalarField(self, "fileName"), iBuilder->CreateGlobalStringPtr("r"));
    56     setScalarField(self, "IOstreamPtr", handle);
     51void FileSource::generateInitMethod() {
     52    BasicBlock * setTerminationOnFailure = CreateBasicBlock("setTerminationOnFailure");
     53    BasicBlock * fileSourceInitExit = CreateBasicBlock("fileSourceInitExit");
     54    Value * handle = iBuilder->CreateFOpenCall(getScalarField("fileName"), iBuilder->CreateGlobalStringPtr("r"));
     55    setScalarField("IOstreamPtr", handle);
    5756    Value * failure = iBuilder->CreateICmpEQ(iBuilder->CreatePtrToInt(handle, iBuilder->getSizeTy()), iBuilder->getSize(0));
    5857    iBuilder->CreateCondBr(failure, setTerminationOnFailure, fileSourceInitExit);
    5958    iBuilder->SetInsertPoint(setTerminationOnFailure);
    60     setTerminationSignal(self);
     59    setTerminationSignal();
    6160    iBuilder->CreateBr(fileSourceInitExit);
    6261    iBuilder->SetInsertPoint(fileSourceInitExit);
    6362}
    6463   
    65 void FileSource::generateDoSegmentMethod(Function * doSegmentFunction, Value *self, Value * doFinal, const std::vector<Value *> & producerPos) const {
     64void FileSource::generateDoSegmentMethod(Value * doFinal, const std::vector<Value *> & producerPos) {
    6665
    6766    PointerType * i8PtrTy = iBuilder->getInt8PtrTy();
    68    
    69     iBuilder->SetInsertPoint(BasicBlock::Create(iBuilder->getContext(), "entry", doSegmentFunction, 0));
    70     BasicBlock * closeFile = BasicBlock::Create(iBuilder->getContext(), "closeFile", doSegmentFunction, 0);
    71     BasicBlock * fileSourceExit = BasicBlock::Create(iBuilder->getContext(), "fileSourceExit", doSegmentFunction, 0);
     67    BasicBlock * closeFile = CreateBasicBlock("closeFile");
     68    BasicBlock * fileSourceExit = CreateBasicBlock("fileSourceExit");
    7269    Constant * blockItems = iBuilder->getSize(iBuilder->getBitBlockWidth());
    7370    Constant * itemBytes = iBuilder->getSize(mCodeUnitWidth/8);
    7471   
    75     Value * produced = getProducedItemCount(self, "codeUnitBuffer");
     72    Value * produced = getProducedItemCount("codeUnitBuffer");
    7673    Value * blockNo = iBuilder->CreateUDiv(produced, blockItems);
    7774    Value * byteOffset = iBuilder->CreateMul(iBuilder->CreateURem(produced, blockItems), itemBytes);
    78     Value * bytePtr = getStreamView(i8PtrTy, self, "codeUnitBuffer", blockNo, byteOffset);
    79     Value * IOstreamPtr = getScalarField(self, "IOstreamPtr");
     75    Value * bytePtr = getStreamView(i8PtrTy, "codeUnitBuffer", blockNo, byteOffset);
     76    Value * IOstreamPtr = getScalarField("IOstreamPtr");
    8077    Value * itemsToDo = iBuilder->getSize(mSegmentBlocks * iBuilder->getBitBlockWidth());
    8178    Value * nRead = iBuilder->CreateFReadCall(bytePtr, itemsToDo, itemBytes, IOstreamPtr);
    8279    produced = iBuilder->CreateAdd(produced, nRead);
    83     setProducedItemCount(self, "codeUnitBuffer", produced);
     80    setProducedItemCount("codeUnitBuffer", produced);
    8481    Value * lessThanFullSegment = iBuilder->CreateICmpULT(nRead, itemsToDo);
    8582    iBuilder->CreateCondBr(lessThanFullSegment, closeFile, fileSourceExit);
     
    8784    iBuilder->SetInsertPoint(closeFile);
    8885    iBuilder->CreateFCloseCall(IOstreamPtr);
    89     setTerminationSignal(self);
     86    setTerminationSignal();
    9087    iBuilder->CreateBr(fileSourceExit);
    9188   
Note: See TracChangeset for help on using the changeset viewer.