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/interface.cpp

    r5287 r5292  
    2222using namespace llvm;
    2323
    24 void KernelInterface::addKernelDeclarations(Module * client) const {
     24void KernelInterface::addKernelDeclarations(Module * client) {
    2525    Module * saveModule = iBuilder->getModule();
    2626    auto savePoint = iBuilder->saveIP();
     
    3131    PointerType * selfType = PointerType::getUnqual(mKernelStateType);
    3232
    33     // Create the accumulator get function prototypes
    34     for (auto binding : mScalarOutputs) {
    35         FunctionType * accumFnType = FunctionType::get(binding.type, {selfType}, false);
    36         std::string fnName = mKernelName + ACCUMULATOR_INFIX + binding.name;
    37         Function * accumFn = Function::Create(accumFnType, GlobalValue::ExternalLinkage, fnName, client);
    38         accumFn->setCallingConv(CallingConv::C);
    39         accumFn->setDoesNotThrow();
    40         Value * self = &*(accumFn->arg_begin());
    41         self->setName("self");       
    42     }
    43 
    4433    // Create the initialization function prototype
    4534    std::vector<Type *> initParameters = {selfType};
     
    4736        initParameters.push_back(binding.type);
    4837    }
    49     FunctionType * initFunctionType = FunctionType::get(iBuilder->getVoidTy(), initParameters, false);
    50     std::string initFnName = mKernelName + INIT_SUFFIX;
    51     Function * initFn = Function::Create(initFunctionType, GlobalValue::ExternalLinkage, initFnName, client);
    52     initFn->setCallingConv(CallingConv::C);
    53     initFn->setDoesNotThrow();
    54     Function::arg_iterator initArgs = initFn->arg_begin();
    55     Value * initArg = &*(initArgs++);
    56     initArg->setName("self");
     38    FunctionType * initType = FunctionType::get(iBuilder->getVoidTy(), initParameters, false);
     39    Function * init = Function::Create(initType, GlobalValue::ExternalLinkage, mKernelName + INIT_SUFFIX, client);
     40    init->setCallingConv(CallingConv::C);
     41    init->setDoesNotThrow();
     42    auto args = init->arg_begin();
     43    args++->setName("self");
    5744    for (auto binding : mScalarInputs) {
    58         initArg = &*(initArgs++);
    59         initArg->setName(binding.name);
     45        args++->setName(binding.name);
    6046    }
     47    assert (args == init->arg_end());
    6148
    6249    // Create the doSegment function prototype.
    6350    std::vector<Type *> doSegmentParameters = {selfType, iBuilder->getInt1Ty()};
    64     for (auto ss : mStreamSetInputs) {
     51    for (unsigned i = 0; i < mStreamSetInputs.size(); ++i) {
    6552        doSegmentParameters.push_back(iBuilder->getSizeTy());
    6653    }
    67     FunctionType * doSegmentFunctionType = FunctionType::get(iBuilder->getVoidTy(), doSegmentParameters, false);
    68     std::string doSegmentName = mKernelName + DO_SEGMENT_SUFFIX;
    69     Function * doSegmentFn = Function::Create(doSegmentFunctionType, GlobalValue::ExternalLinkage, doSegmentName, client);
    70     doSegmentFn->setCallingConv(CallingConv::C);
    71     doSegmentFn->setDoesNotThrow();
    72     Function::arg_iterator args = doSegmentFn->arg_begin();
    73     Value * arg = &*(args++);
    74     arg->setName("self");
    75     arg = &*(args++);
    76     arg->setName("doFinal");
     54    FunctionType * doSegmentType = FunctionType::get(iBuilder->getVoidTy(), doSegmentParameters, false);
     55    Function * doSegment = Function::Create(doSegmentType, GlobalValue::ExternalLinkage, mKernelName + DO_SEGMENT_SUFFIX, client);
     56    doSegment->setCallingConv(CallingConv::C);
     57    doSegment->setDoesNotThrow();
     58    doSegment->setDoesNotCapture(1); // for self parameter only.
     59    args = doSegment->arg_begin();
     60    args++->setName("self");
     61    args++->setName("doFinal");
    7762    for (auto ss : mStreamSetInputs) {
    78         arg = &*(args++);
    79         arg->setName(ss.name + "_availableItems");
     63        args++->setName(ss.name + "_availableItems");
    8064    }
    81     doSegmentFn->setDoesNotCapture(1); // for self parameter only.
     65    assert (args == doSegment->arg_end());
    8266
    8367    // Add any additional kernel declarations
    8468    addAdditionalKernelDeclarations(client, selfType);
    8569
     70    // Create the accumulator get function prototypes
     71    for (const auto & binding : mScalarOutputs) {
     72        FunctionType * accumFnType = FunctionType::get(binding.type, {selfType}, false);
     73        Function * accumFn = Function::Create(accumFnType, GlobalValue::ExternalLinkage, mKernelName + ACCUMULATOR_INFIX + binding.name, client);
     74        accumFn->setCallingConv(CallingConv::C);
     75        accumFn->setDoesNotThrow();
     76        auto self = accumFn->arg_begin();
     77        self->setName("self");
     78    }
     79
    8680    iBuilder->setModule(saveModule);
    8781    iBuilder->restoreIP(savePoint);
    88 }
    89 
    90 void KernelInterface::addAdditionalKernelDeclarations(llvm::Module * module, llvm::PointerType * selfType) const {
    91 
    9282}
    9383
Note: See TracChangeset for help on using the changeset viewer.