Ignore:
Timestamp:
Jun 12, 2016, 9:37:33 AM (3 years ago)
Author:
cameron
Message:

Set parameter names and attributes for kernel methods

File:
1 edited

Legend:

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

    r5047 r5049  
    2020                                 std::vector<ScalarBinding> scalar_outputs,
    2121                                 std::vector<ScalarBinding> internal_scalars) {
    22     llvm::errs() << "0\n";
    2322    iBuilder = builder;
    2423    mKernelName = kernelName;
     
    2827    mScalarOutputs = scalar_outputs;
    2928    mInternalScalars = internal_scalars;
    30     llvm::errs() << "1\n";
    3129    std::vector<Type *> kernelFields;
    3230    for (auto binding : scalar_parameters) {
     
    4644    }
    4745    mKernelStateType = StructType::create(getGlobalContext(), kernelFields, kernelName);
    48     llvm::errs() << "2\n";
    49 
    5046}
    5147
     
    5349   
    5450    Type * selfType = PointerType::getUnqual(mKernelStateType);
    55     llvm::errs() << "3\n";
    56    
    5751    // Create the accumulator get function prototypes
    5852    for (auto binding : mScalarOutputs) {
    5953        FunctionType * accumFnType = FunctionType::get(binding.scalarType, {selfType}, false);
    60         Function::Create(accumFnType, GlobalValue::ExternalLinkage, mKernelName + "_get_" + binding.scalarName, client);
     54        Function * accumFn = Function::Create(accumFnType, GlobalValue::ExternalLinkage, mKernelName + "_get_" + binding.scalarName, client);
     55        accumFn->setCallingConv(CallingConv::C);
     56        accumFn->setDoesNotThrow();
     57        Value * self = &*(accumFn->arg_begin());
     58        self->setName("self");       
    6159    }
    62     llvm::errs() << "4\n";
    63 
    6460    // Create the initialization function prototype
    6561
     
    6965    }
    7066    FunctionType * initFunctionType = FunctionType::get(iBuilder->getVoidTy(), initParameters, false);
    71     Function::Create(initFunctionType, GlobalValue::ExternalLinkage, mKernelName + "_Init", client);
    72    
    73    
    74 
    75     llvm::errs() << "5\n";
     67    Function * initFn = Function::Create(initFunctionType, GlobalValue::ExternalLinkage, mKernelName + "_Init", client);
     68    initFn->setCallingConv(CallingConv::C);
     69    initFn->setDoesNotThrow();
     70    Function::arg_iterator initArgs = initFn->arg_begin();
     71    Value * initArg = &*(initArgs++);
     72    initArg->setName("self");
     73    for (auto binding : mScalarInputs) {
     74        initArg = &*(initArgs++);
     75        initArg->setName(binding.scalarName);
     76    }
    7677
    7778    // Create the doBlock and finalBlock function prototypes
     
    9091    }
    9192    FunctionType * doBlockFunctionType = FunctionType::get(iBuilder->getVoidTy(), doBlockParameters, false);
    92     Function::Create(doBlockFunctionType, GlobalValue::ExternalLinkage, mKernelName + "_DoBlock", client);
     93    Function * doBlockFn = Function::Create(doBlockFunctionType, GlobalValue::ExternalLinkage, mKernelName + "_DoBlock", client);
     94    doBlockFn->setCallingConv(CallingConv::C);
     95    doBlockFn->setDoesNotThrow();
     96    for (int i = 1; i <= doBlockParameters.size(); i++) {
     97        doBlockFn->setDoesNotCapture(i);
     98    }
     99   
    93100    FunctionType * finalBlockFunctionType = FunctionType::get(iBuilder->getVoidTy(), finalBlockParameters, false);
    94     Function::Create(finalBlockFunctionType, GlobalValue::ExternalLinkage, mKernelName + "_FinalBlock", client);
     101    Function * finalBlockFn = Function::Create(finalBlockFunctionType, GlobalValue::ExternalLinkage, mKernelName + "_FinalBlock", client);
     102    finalBlockFn->setCallingConv(CallingConv::C);
     103    finalBlockFn->setDoesNotThrow();
     104    finalBlockFn->setDoesNotCapture(1);
     105    // Parameter #2 is not a pointer; nocapture is irrelevant
     106    for (int i = 3; i <= finalBlockParameters.size(); i++) {
     107        finalBlockFn->setDoesNotCapture(i);
     108    }
     109   
     110    Function::arg_iterator doBlockArgs = doBlockFn->arg_begin();
     111    Function::arg_iterator finalBlockArgs = finalBlockFn->arg_begin();
     112    Value * doBlockArg = &*(doBlockArgs++);
     113    doBlockArg->setName("self");
     114    Value * finalBlockArg = &*(finalBlockArgs++);
     115    finalBlockArg->setName("self");
     116    finalBlockArg = &*(finalBlockArgs++);
     117    finalBlockArg->setName("remainingBytes");
     118
     119    for (auto inputSet : mStreamSetInputs) {
     120        doBlockArg = &*(doBlockArgs++);
     121        finalBlockArg = &*(finalBlockArgs++);
     122        doBlockArg->setName(inputSet.ssName);
     123        finalBlockArg->setName(inputSet.ssName);
     124    }
     125    for (auto outputSet : mStreamSetOutputs) {
     126        doBlockArg = &*(doBlockArgs++);
     127        finalBlockArg = &*(finalBlockArgs++);
     128        doBlockArg->setName(outputSet.ssName);
     129        finalBlockArg->setName(outputSet.ssName);
     130    }
    95131}
    96132
     
    122158    Function::arg_iterator args = initFunction->arg_begin();
    123159    Value * self = &*(args++);
    124     self->setName("self");
    125     for (auto binding : mScalarInputs) {
    126         Value * parm = &*(args++);
    127         parm->setName(binding.scalarName);
    128     }
    129 
    130160    iBuilder->CreateStore(Constant::getNullValue(mKernelStateType), self);
    131     args = initFunction->arg_begin();
    132     args++;   // skip self argument.
    133161    for (auto binding : mScalarInputs) {
    134162        Value * parm = &*(args++);
Note: See TracChangeset for help on using the changeset viewer.