Ignore:
Timestamp:
May 3, 2017, 1:13:04 PM (2 years ago)
Author:
nmedfort
Message:

partial refactoring check in with change for Linda.

File:
1 edited

Legend:

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

    r5425 r5431  
    6868}
    6969
    70 void KernelInterface::addKernelDeclarations(Module * const client) {
    71     Module * const saveModule = iBuilder->getModule();
    72     iBuilder->setModule(client);
     70void KernelInterface::addKernelDeclarations() {
     71
    7372    if (mKernelStateType == nullptr) {
    7473        throw std::runtime_error("Kernel interface " + getName() + " not yet finalized.");
    7574    }
     75
     76    Module * const module = iBuilder->getModule();
    7677    PointerType * const selfType = mKernelStateType->getPointerTo();
    7778    IntegerType * const sizeTy = iBuilder->getSizeTy();
     
    8081
    8182    // Create the initialization function prototype
    82     std::vector<Type *> initParameters = {selfType};   
     83    std::vector<Type *> initParameters = {selfType};
    8384    for (auto binding : mScalarInputs) {
    8485        initParameters.push_back(binding.type);
     
    8788
    8889    FunctionType * const initType = FunctionType::get(voidTy, initParameters, false);
    89     Function * const initFunc = Function::Create(initType, GlobalValue::ExternalLinkage, getName() + INIT_SUFFIX, client);
     90    Function * const initFunc = Function::Create(initType, GlobalValue::ExternalLinkage, getName() + INIT_SUFFIX, module);
    9091    initFunc->setCallingConv(CallingConv::C);
    9192    initFunc->setDoesNotThrow();
     
    104105
    105106    FunctionType * const doSegmentType = FunctionType::get(voidTy, params, false);
    106     Function * const doSegment = Function::Create(doSegmentType, GlobalValue::ExternalLinkage, getName() + DO_SEGMENT_SUFFIX, client);
     107    Function * const doSegment = Function::Create(doSegmentType, GlobalValue::ExternalLinkage, getName() + DO_SEGMENT_SUFFIX, module);
    107108    doSegment->setCallingConv(CallingConv::C);
    108109    doSegment->setDoesNotThrow();
    109     doSegment->setDoesNotCapture(1); // for self parameter only.   
     110    doSegment->setDoesNotCapture(1); // for self parameter only.
    110111    args = doSegment->arg_begin();
    111112    args->setName("self");
     
    132133    }
    133134    FunctionType * const terminateType = FunctionType::get(resultType, {selfType}, false);
    134     Function * const terminateFunc = Function::Create(terminateType, GlobalValue::ExternalLinkage, getName() + TERMINATE_SUFFIX, client);
     135    Function * const terminateFunc = Function::Create(terminateType, GlobalValue::ExternalLinkage, getName() + TERMINATE_SUFFIX, module);
    135136    terminateFunc->setCallingConv(CallingConv::C);
    136137    terminateFunc->setDoesNotThrow();
     
    140141
    141142    linkExternalMethods();
    142 
    143     iBuilder->setModule(saveModule);
    144143}
    145144
     
    148147}
    149148
    150 Function * KernelInterface::getInitFunction() const {
     149Function * KernelInterface::getInitFunction(Module * const module) const {
    151150    const auto name = getName() + INIT_SUFFIX;
    152     Function * f = iBuilder->getModule()->getFunction(name);
     151    Function * f = module->getFunction(name);
    153152    if (LLVM_UNLIKELY(f == nullptr)) {
    154153        llvm::report_fatal_error("Cannot find " + name);
     
    157156}
    158157
    159 Function * KernelInterface::getDoSegmentFunction() const {
     158Function * KernelInterface::getDoSegmentFunction(llvm::Module * const module) const {
    160159    const auto name = getName() + DO_SEGMENT_SUFFIX;
    161     Function * f = iBuilder->getModule()->getFunction(name);
     160    Function * f = module->getFunction(name);
    162161    if (LLVM_UNLIKELY(f == nullptr)) {
    163162        llvm::report_fatal_error("Cannot find " + name);
     
    166165}
    167166
    168 Function * KernelInterface::getTerminateFunction() const {
     167Function * KernelInterface::getTerminateFunction(Module * const module) const {
    169168    const auto name = getName() + TERMINATE_SUFFIX;
    170     Function * f = iBuilder->getModule()->getFunction(name);
     169    Function * f = module->getFunction(name);
    171170    if (LLVM_UNLIKELY(f == nullptr)) {
    172171        llvm::report_fatal_error("Cannot find " + name);
Note: See TracChangeset for help on using the changeset viewer.