Ignore:
Timestamp:
Feb 4, 2017, 6:49:46 AM (2 years ago)
Author:
cameron
Message:

Ability to set input/output signatures for Pablo functions in the constructor

Location:
icGREP/icgrep-devel/icgrep/pablo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.cpp

    r5298 r5299  
    1313//#include <llvm/IR/Verifier.h>
    1414//#include <IR_Gen/idisa_builder.h>
     15#include "llvm/Support/Debug.h"
    1516
    1617using namespace pablo;
     
    2930    return false;
    3031}
     32
     33Var * PabloKernel::getInputSet(std::string inputSetName) {
     34    unsigned ssIndex = getStreamSetIndex(inputSetName);
     35    return mInputs[ssIndex];
     36}
     37
     38Var * PabloKernel::getOutputSet(std::string outputSetName) {
     39    unsigned ssIndex = getStreamSetIndex(outputSetName);
     40    return mOutputs[ssIndex - mInputs.size()];
     41}
     42
    3143
    3244Var * PabloKernel::addInput(const std::string & name, Type * const type) {
     
    118130}
    119131
     132PabloKernel::PabloKernel(IDISA::IDISA_Builder * builder, std::string kernelName,
     133                         std::vector<Binding> && stream_inputs,
     134                         std::vector<Binding> && stream_outputs,
     135                         std::vector<Binding> && scalar_outputs)
     136: BlockOrientedKernel(builder, std::move(kernelName),
     137                      std::move(stream_inputs), std::move(stream_outputs),
     138                      {}, std::move(scalar_outputs),
     139                      {Binding{builder->getBitBlockType(), "EOFbit"}, Binding{builder->getBitBlockType(), "EOFmask"}})
     140, PabloAST(PabloAST::ClassTypeId::Kernel, nullptr, mAllocator)
     141, mPabloCompiler(new PabloCompiler(this))
     142, mSymbolTable(new SymbolGenerator(mAllocator))
     143, mEntryBlock(PabloBlock::Create(this)) {
     144    setDoBlockUpdatesProducedItemCountsAttribute(false);
     145    prepareKernelSignature();
     146    for (auto ss : mStreamSetInputs) {
     147        Var * param = new (mAllocator) Var(mSymbolTable->makeString(ss.name, iBuilder), ss.type, mAllocator, Var::ReadOnly);
     148        param->addUser(this);
     149        mInputs.push_back(param);
     150        mVariables.push_back(param);
     151    }
     152    for (auto ss : mStreamSetOutputs) {
     153        Var * result = new (mAllocator) Var(mSymbolTable->makeString(ss.name, iBuilder), ss.type, mAllocator, Var::ReadNone);
     154        result->addUser(this);
     155        mOutputs.push_back(result);
     156        mVariables.push_back(result);
     157    }
     158    for (auto ss : mScalarOutputs) {
     159        Var * result = new (mAllocator) Var(mSymbolTable->makeString(ss.name, iBuilder), ss.type, mAllocator, Var::ReadNone);
     160        result->addUser(this);
     161        mOutputs.push_back(result);
     162        mVariables.push_back(result);
     163    }
     164}
     165
    120166PabloKernel::~PabloKernel() {
    121167    delete mPabloCompiler;
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.h

    r5297 r5299  
    4747    PabloKernel(IDISA::IDISA_Builder * builder, std::string kernelName);
    4848   
     49    PabloKernel(IDISA::IDISA_Builder * builder, std::string kernelName,                     
     50                    std::vector<Binding> && stream_inputs,
     51                    std::vector<Binding> && stream_outputs,
     52                    std::vector<Binding> && scalar_outputs);
     53
    4954    virtual ~PabloKernel();
    5055
     
    6267        return entryBlock;
    6368    }
     69   
     70    Var * getInputSet(std::string inputSetName);
    6471
    6572    Var * getInput(const unsigned index) {
     
    7683        return mInputs.size();
    7784    }
     85   
     86    Var * getOutputSet(std::string inputSetName);
    7887
    7988    Var * getOutput(const unsigned index) {
Note: See TracChangeset for help on using the changeset viewer.