Ignore:
Timestamp:
May 7, 2017, 4:34:48 PM (2 years ago)
Author:
nmedfort
Message:

Continued refactoring work. PabloKernel? now abstract base type with a 'generatePabloMethod' hook to generate Pablo code.

File:
1 edited

Legend:

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

    r5435 r5436  
    1717#include <kernels/streamset.h>
    1818#include <sstream>
     19#include <kernels/kernel_builder.h>
    1920
    2021using namespace llvm;
     
    5354    mKernelFields.push_back(type);
    5455    return index;
     56}
     57
     58// Get the value of a scalar field for the current instance.
     59llvm::Value * Kernel::getScalarFieldPtr(llvm::Value * index) const {
     60    return iBuilder->CreateGEP(getInstance(), {iBuilder->getInt32(0), index});
     61}
     62
     63llvm::Value * Kernel::getScalarFieldPtr(const std::string & fieldName) const {
     64    return getScalarFieldPtr(iBuilder->getInt32(getScalarIndex(fieldName)));
     65}
     66
     67llvm::Value * Kernel::getScalarField(const std::string & fieldName) const {
     68    return iBuilder->CreateLoad(getScalarFieldPtr(fieldName), fieldName);
     69}
     70
     71// Set the value of a scalar field for the current instance.
     72void Kernel::setScalarField(const std::string & fieldName, llvm::Value * value) const {
     73    iBuilder->CreateStore(value, getScalarFieldPtr(fieldName));
    5574}
    5675
     
    231250    setInstance(&*(args++));
    232251    iBuilder->CreateStore(ConstantAggregateZero::get(mKernelStateType), getInstance());
    233     for (auto binding : mScalarInputs) {
     252    for (const auto & binding : mScalarInputs) {
    234253        setScalarField(binding.name, &*(args++));
    235254    }
    236     for (auto binding : mStreamSetOutputs) {
     255    for (const auto & binding : mStreamSetOutputs) {
    237256        setConsumerLock(binding.name, &*(args++));
    238257    }
     
    550569}
    551570
    552 Argument * Kernel::getParameter(Function * const f, const std::string & name) const {
    553     for (auto & arg : f->getArgumentList()) {
    554         if (arg.getName().equals(name)) {
    555             return &arg;
    556         }
    557     }
    558     report_fatal_error(getName() + " does not have parameter " + name);
    559 }
     571//Argument * Kernel::getParameter(Function * const f, const std::string & name) const {
     572//    for (auto & arg : f->getArgumentList()) {
     573//        if (arg.getName().equals(name)) {
     574//            return &arg;
     575//        }
     576//    }
     577//    report_fatal_error(getName() + " does not have parameter " + name);
     578//}
    560579
    561580CallInst * Kernel::createDoSegmentCall(const std::vector<Value *> & args) const {
     
    650669            Kernel * const consumer = consumers[i];
    651670            assert ("all instances must be created prior to initialization of any instance" && consumer->getInstance());
    652             consumer->setBuilder(iBuilder);
    653671            Value * const segmentNoPtr = consumer->getScalarFieldPtr(LOGICAL_SEGMENT_NO_SCALAR);
    654672            iBuilder->CreateStore(segmentNoPtr, iBuilder->CreateGEP(consumerSegNoArray, { iBuilder->getInt32(0), iBuilder->getInt32(i) }));
     
    890908}
    891909
     910bool BlockOrientedKernel::useIndirectBr() const {
     911    return iBuilder->supportsIndirectBr();
     912}
     913
    892914void BlockOrientedKernel::CreateDoBlockMethodCall() {
    893915    if (useIndirectBr()) {
Note: See TracChangeset for help on using the changeset viewer.