Ignore:
Timestamp:
May 10, 2017, 4:26:11 PM (2 years ago)
Author:
nmedfort
Message:

Large refactoring step. Removed IR generation code from Kernel (formally KernelBuilder?) and moved it into the new KernelBuilder? class.

File:
1 edited

Legend:

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

    r5438 r5440  
    9292    virtual bool isCachable() const = 0;
    9393
    94     virtual std::string makeSignature() = 0;
     94    virtual std::string makeSignature(const std::unique_ptr<kernel::KernelBuilder> & idb) = 0;
    9595
    9696    const std::vector<Binding> & getStreamInputs() const {
     
    127127
    128128    // Add ExternalLinkage method declarations for the kernel to a given client module.
    129     void addKernelDeclarations();
    130 
    131     virtual void linkExternalMethods() = 0;
    132 
    133     virtual llvm::Value * createInstance() = 0;
    134 
    135     virtual void initializeInstance() = 0;
    136 
    137     virtual void finalizeInstance() = 0;
     129    void addKernelDeclarations(const std::unique_ptr<kernel::KernelBuilder> & idb);
     130
     131    virtual void linkExternalMethods(const std::unique_ptr<kernel::KernelBuilder> & idb) = 0;
     132
     133    virtual llvm::Value * createInstance(const std::unique_ptr<kernel::KernelBuilder> & idb) = 0;
     134
     135    virtual void initializeInstance(const std::unique_ptr<kernel::KernelBuilder> & idb) = 0;
     136
     137    virtual void finalizeInstance(const std::unique_ptr<kernel::KernelBuilder> & idb) = 0;
    138138
    139139    void setInitialArguments(std::vector<llvm::Value *> && args) {
     
    145145    }
    146146
     147    void setInstance(llvm::Value * const instance) {
     148        assert ("kernel instance cannot be null!" && instance);
     149        assert ("kernel instance must point to a valid kernel state type!" && (instance->getType()->getPointerElementType() == mKernelStateType));
     150        mKernelInstance = instance;
     151    }
     152
    147153    unsigned getLookAhead() const {
    148154        return mLookAheadPositions;
     
    153159    }
    154160
    155     kernel::KernelBuilder * getBuilder() const {
    156         return iBuilder;
    157     }
    158 
    159     void setBuilder(const std::unique_ptr<kernel::KernelBuilder> & builder) {
    160         iBuilder = builder.get();
    161     }
    162 
    163161protected:
    164 
    165     virtual llvm::Value * getProducedItemCount(const std::string & name, llvm::Value * doFinal = nullptr) const = 0;
    166 
    167     virtual void setProducedItemCount(const std::string & name, llvm::Value * value) const = 0;
    168 
    169     virtual llvm::Value * getProcessedItemCount(const std::string & name) const = 0;
    170 
    171     virtual void setProcessedItemCount(const std::string & name, llvm::Value * value) const = 0;
    172 
    173     virtual llvm::Value * getConsumedItemCount(const std::string & name) const = 0;
    174 
    175     virtual void setConsumedItemCount(const std::string & name, llvm::Value * value) const = 0;
    176 
    177     virtual llvm::Value * getTerminationSignal() const = 0;
    178 
    179     virtual void setTerminationSignal() const = 0;
    180162
    181163    llvm::Function * getInitFunction(llvm::Module * const module) const;
     
    191173                    std::vector<Binding> && scalar_outputs,
    192174                    std::vector<Binding> && internal_scalars)
    193     : iBuilder(nullptr)
     175    : mKernelInstance(nullptr)
    194176    , mModule(nullptr)
    195     , mKernelInstance(nullptr)
    196177    , mKernelStateType(nullptr)
    197178    , mLookAheadPositions(0)
     
    201182    , mScalarInputs(scalar_inputs)
    202183    , mScalarOutputs(scalar_outputs)
    203     , mInternalScalars(internal_scalars)
    204     {
     184    , mInternalScalars(internal_scalars) {
    205185
    206186    }
    207187   
    208     void setInstance(llvm::Value * const instance) {
    209         assert ("kernel instance cannot be null!" && instance);
    210         assert ("kernel instance must point to a valid kernel state type!" && (instance->getType()->getPointerElementType() == mKernelStateType));
    211         mKernelInstance = instance;
    212     }
    213 
    214188protected:
    215    
    216     kernel::KernelBuilder *                 iBuilder;
     189
     190    llvm::Value *                           mKernelInstance;
    217191    llvm::Module *                          mModule;
    218 
    219     llvm::Value *                           mKernelInstance;
    220192    llvm::StructType *                      mKernelStateType;
    221193    unsigned                                mLookAheadPositions;
Note: See TracChangeset for help on using the changeset viewer.