Ignore:
Timestamp:
Jan 31, 2017, 4:08:11 PM (2 years ago)
Author:
nmedfort
Message:

Removed 'function' and 'self' parameters from generateXXXMethod() functions.

File:
1 edited

Legend:

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

    r5287 r5292  
    2020namespace parabix { class StreamSetBuffer; }
    2121
    22 const std::string logicalSegmentNoScalar = "logicalSegNo";
    23 const std::string processedItemCountSuffix = "_processedItemCount";
    24 const std::string producedItemCountSuffix = "_producedItemCount";
    25 const std::string terminationSignal = "terminationSignal";
    26 const std::string bufferPtrSuffix = "_bufferPtr";
    27 const std::string blkMaskSuffix = "_blkMask";
    28 
    2922namespace kernel {
    3023   
     
    4336    void createInstance() override;
    4437
    45     llvm::Value * getBlockNo(llvm::Value * self) const;
    46 
    47     virtual llvm::Value * getProcessedItemCount(llvm::Value * self, const std::string & ssName) const override;
    48 
    49     virtual llvm::Value * getProducedItemCount(llvm::Value * self, const std::string & ssName) const override;
    50    
     38    virtual llvm::Value * getProcessedItemCount(llvm::Value * instance, const std::string & name) const override;
     39
     40    virtual void setProcessedItemCount(llvm::Value * instance, const std::string & name, llvm::Value * value) const;
     41
     42    virtual llvm::Value * getProducedItemCount(llvm::Value * instance, const std::string & name) const override;
     43
     44    virtual void setProducedItemCount(llvm::Value * instance, const std::string & name, llvm::Value * value) const;
     45
    5146    bool hasNoTerminateAttribute() { return mNoTerminateAttribute;}
    5247   
    53     llvm::Value * getTerminationSignal(llvm::Value * self) const override;
    54    
    55     inline llvm::IntegerType * getSizeTy() const {
    56         return getBuilder()->getSizeTy();
    57     }
    58 
    59     inline llvm::Type * getStreamTy(const unsigned FieldWidth = 1) {
    60         return getBuilder()->getStreamTy(FieldWidth);
    61     }
    62    
    63     inline llvm::Type * getStreamSetTy(const unsigned NumElements = 1, const unsigned FieldWidth = 1) {
    64         return getBuilder()->getStreamSetTy(NumElements, FieldWidth);
    65     }
    66    
     48    llvm::Value * getTerminationSignal(llvm::Value * instance) const override final;
     49
     50    void setTerminationSignal(llvm::Value * instance) const override final;
     51
     52    llvm::Value * getScalarFieldPtr(llvm::Value * instance, const std::string & name) const;
     53
     54    llvm::Value * getScalarFieldPtr(llvm::Value *instance, llvm::Value * index) const;
     55
     56    llvm::Value * getStreamSetBufferPtr(llvm::Value * instance, const std::string & name) const;
     57
     58    llvm::Value * getStreamSetBufferPtr(llvm::Value * instance, llvm::Value * index) const;
     59   
     60    // Get the value of a scalar field for a given instance.
     61    llvm::Value * getScalarField(llvm::Value * instance, const std::string & fieldName) const;
     62
     63    llvm::Value * getScalarField(llvm::Value * instance, llvm::Value * index) const;
     64
     65    // Set the value of a scalar field for a given instance.
     66    void setScalarField(llvm::Value *instance, const std::string & fieldName, llvm::Value * value) const;
     67
     68    void setScalarField(llvm::Value * instance, llvm::Value * index, llvm::Value * value) const;
     69
    6770    // Synchronization actions for executing a kernel for a particular logical segment.
    68     // 
     71    //
    6972    // Before the segment is processed, acquireLogicalSegmentNo must be used to load
    7073    // the segment number of the kernel state to ensure that the previous segment is
    7174    // complete (by checking that the acquired segment number is equal to the desired segment
    7275    // number).
    73     // After all segment processing actions for the kernel are complete, and any necessary 
    74     // data has been extracted from the kernel for further pipeline processing, the 
     76    // After all segment processing actions for the kernel are complete, and any necessary
     77    // data has been extracted from the kernel for further pipeline processing, the
    7578    // segment number must be incremented and stored using releaseLogicalSegmentNo.
    76     llvm::LoadInst * acquireLogicalSegmentNo(llvm::Value * self) const;
    77 
    78     void releaseLogicalSegmentNo(llvm::Value * self, llvm::Value * newFieldVal) const;
    79 
     79    llvm::LoadInst * acquireLogicalSegmentNo(llvm::Value * instance) const;
     80
     81    void releaseLogicalSegmentNo(llvm::Value * instance, llvm::Value * newFieldVal) const;
     82
     83    // Get a parameter by name.
     84    llvm::Argument * getParameter(llvm::Function * f, const std::string & name) const;
     85
     86    inline llvm::IntegerType * getSizeTy() const {
     87        return getBuilder()->getSizeTy();
     88    }
     89
     90    inline llvm::Type * getStreamTy(const unsigned FieldWidth = 1) {
     91        return getBuilder()->getStreamTy(FieldWidth);
     92    }
     93   
     94    inline llvm::Type * getStreamSetTy(const unsigned NumElements = 1, const unsigned FieldWidth = 1) {
     95        return getBuilder()->getStreamSetTy(NumElements, FieldWidth);
     96    }
     97   
    8098    virtual ~KernelBuilder() = 0;
    8199   
     
    83101
    84102    const std::vector<const parabix::StreamSetBuffer *> & getStreamSetOutputBuffers() const { return mStreamSetOutputBuffers; }
    85 
    86     void setTerminationSignal(llvm::Value * self) const;
    87103
    88104    llvm::Value * createDoSegmentCall(const std::vector<llvm::Value *> & args) const;
     
    122138    virtual void prepareKernel();
    123139       
    124     virtual void generateInitMethod(llvm::Function * initFunction, llvm::Value * self) const;
    125    
    126     virtual void generateDoSegmentMethod(llvm::Function * function, llvm::Value * self, llvm::Value * doFinal, const std::vector<llvm::Value *> & producerPos) const = 0;
    127    
     140    virtual void generateInitMethod() { }
     141   
     142    virtual void generateDoSegmentMethod(llvm::Value * doFinal, const std::vector<llvm::Value *> & producerPos) = 0;
     143
     144    virtual void generateInternalMethods() { }
     145
    128146    // Add an additional scalar field to the KernelState struct.
    129147    // Must occur before any call to addKernelDeclarations or createKernelModule.
     
    139157    // Get the index of a named scalar field within the kernel state struct.
    140158    llvm::ConstantInt * getScalarIndex(const std::string & name) const;
     159
     160    llvm::Value * getBlockNo() const;
     161
     162    void setBlockNo(llvm::Value * value) const;
    141163   
    142164    // Get the value of a scalar field for a given instance.
    143     llvm::Value * getScalarField(llvm::Value * self, const std::string & fieldName) const;
    144 
    145     llvm::Value * getScalarField(llvm::Value * self, llvm::Value * index) const;
     165    llvm::Value * getScalarField(const std::string & fieldName) const {
     166        return getScalarField(getSelf(), fieldName);
     167    }
     168
     169    llvm::Value * getScalarField(llvm::Value * index) const {
     170        return getScalarField(getSelf(), index);
     171    }
    146172
    147173    // Set the value of a scalar field for a given instance.
    148     void setScalarField(llvm::Value * self, const std::string & fieldName, llvm::Value * value) const;
    149 
    150     void setScalarField(llvm::Value * self, llvm::Value * index, llvm::Value * value) const;
    151 
    152     // Get a parameter by name.
    153     llvm::Argument * getParameter(llvm::Function * f, const std::string & name) const;
    154 
    155     llvm::Value * getStream(llvm::Value * self, const std::string & name, llvm::Value * blockNo, llvm::Value * index) const;
    156 
    157     llvm::Value * getStream(llvm::Value * self, const std::string & name, llvm::Value * blockNo, llvm::Value * index1, llvm::Value * index2) const;
    158 
    159     llvm::Value * getStreamView(llvm::Value * self, const std::string & name, llvm::Value * blockNo, llvm::Value * index) const;
    160 
    161     llvm::Value * getStreamView(llvm::Type * type, llvm::Value * self, const std::string & name, llvm::Value * blockNo, llvm::Value * index) const;
     174    void setScalarField(const std::string & fieldName, llvm::Value * value) const {
     175        return setScalarField(getSelf(), fieldName, value);
     176    }
     177
     178    void setScalarField(llvm::Value * index, llvm::Value * value) const {
     179        return setScalarField(getSelf(), index, value);
     180    }
     181
     182    llvm::Value * getStream(const std::string & name, llvm::Value * blockNo, llvm::Value * index) const;
     183
     184    llvm::Value * getStream(const std::string & name, llvm::Value * blockNo, llvm::Value * index1, llvm::Value * index2) const;
     185
     186    llvm::Value * getStreamView(const std::string & name, llvm::Value * blockNo, llvm::Value * index) const;
     187
     188    llvm::Value * getStreamView(llvm::Type * type, const std::string & name, llvm::Value * blockNo, llvm::Value * index) const;
    162189
    163190    // Stream set helpers.
     191    llvm::Value * getScalarFieldPtr(const std::string & name) const {
     192        return getScalarFieldPtr(getSelf(), name);
     193    }
     194
     195    llvm::Value * getScalarFieldPtr(llvm::Value * index) const {
     196        return getScalarFieldPtr(getSelf(), index);
     197    }
     198
     199    llvm::Value * getStreamSetBufferPtr(const std::string & name) const {
     200        return getStreamSetBufferPtr(getSelf(), name);
     201    }
     202
     203    llvm::Value * getStreamSetBufferPtr(llvm::Value * index) const {
     204        return getStreamSetBufferPtr(getSelf(), index);
     205    }
     206
     207    llvm::Value * getStreamSetPtr(const std::string & name, llvm::Value * blockNo) const;
     208
     209    inline llvm::Value * getProcessedItemCount(const std::string & name) const {
     210        return getProcessedItemCount(getSelf(), name);
     211    }
     212
     213    inline void setProcessedItemCount(const std::string & name, llvm::Value * value) const {
     214        setProcessedItemCount(getSelf(), name, value);
     215    }
     216
     217    inline llvm::Value * getProducedItemCount(const std::string & name) const {
     218        return getProducedItemCount(getSelf(), name);
     219    }
     220
     221    inline void setProducedItemCount(const std::string & name, llvm::Value * value) const {
     222        setProducedItemCount(getSelf(), name, value);
     223    }
     224
     225    llvm::Value * getTerminationSignal() const {
     226        return getTerminationSignal(getSelf());
     227    }
     228
     229    void setTerminationSignal() const {
     230        return setTerminationSignal(getSelf());
     231    }
     232
     233
     234    llvm::Value * getSelf() const {
     235        return mSelf;
     236    }
     237
     238    llvm::BasicBlock * CreateBasicBlock(std::string && name) const;
     239
     240private:
     241
    164242    unsigned getStreamSetIndex(const std::string & name) const;
    165    
    166     llvm::Value * getScalarFieldPtr(llvm::Value * self, const std::string & name) const;
    167 
    168     llvm::Value * getScalarFieldPtr(llvm::Value * self, llvm::Value * index) const;
    169 
    170     llvm::Value * getStreamSetBufferPtr(llvm::Value * self, const std::string & name) const;
    171 
    172     llvm::Value * getStreamSetBufferPtr(llvm::Value * self, llvm::Value * index) const;
    173 
    174     llvm::Value * getStreamSetPtr(llvm::Value * self, const std::string & name, llvm::Value * blockNo) const;
    175    
    176     void setBlockNo(llvm::Value * self, llvm::Value * value) const;
    177 
    178     virtual void setProcessedItemCount(llvm::Value * self, const std::string & name, llvm::Value * value) const;
    179 
    180     virtual void setProducedItemCount(llvm::Value * self, const std::string & name, llvm::Value * value) const;
    181243
    182244    const parabix::StreamSetBuffer * getStreamSetBuffer(const std::string & name) const;
    183245
    184 private:
    185 
    186     void callGenerateInitMethod() const;
    187 
    188     void callGenerateDoSegmentMethod() const;
     246    void callGenerateInitMethod();
     247
     248    void callGenerateDoSegmentMethod();
    189249
    190250protected:
     251
     252    llvm::Value *                                   mSelf;
     253    llvm::Function *                                mCurrentFunction;
    191254
    192255    std::vector<llvm::Type *>                       mKernelFields;
     
    216279
    217280class BlockOrientedKernel : public KernelBuilder {
     281public:
     282
     283    llvm::CallInst * CreateDoBlockMethodCall() const;
     284
     285    llvm::CallInst * CreateDoFinalBlockMethodCall(llvm::Value * remainingItems) const;
     286
    218287protected:
     288
     289    virtual void addAdditionalKernelDeclarations(llvm::Module * module, llvm::PointerType * selfType);
    219290
    220291    // Each kernel builder subtype must provide its own logic for generating
    221292    // doBlock calls.
    222     virtual void generateDoBlockMethod(llvm::Function * function, llvm::Value * self, llvm::Value * blockNo) const = 0;
    223 
    224     virtual void addAdditionalKernelDeclarations(llvm::Module * module, llvm::PointerType * selfType) const;
     293    virtual void generateDoBlockMethod(llvm::Value * blockNo) = 0;
    225294
    226295    // Each kernel builder subtypre must also specify the logic for processing the
     
    231300    // not be overridden.
    232301
    233     virtual void generateFinalBlockMethod(llvm::Function * function, llvm::Value * self, llvm::Value * remainingBytes, llvm::Value * blockNo) const;
    234 
    235     virtual void generateDoSegmentMethod(llvm::Function * function, llvm::Value * self, llvm::Value * doFinal, const std::vector<llvm::Value *> & producerPos) const final;
     302    virtual void generateFinalBlockMethod(llvm::Value * remainingBytes, llvm::Value * blockNo);
     303
     304    virtual void generateDoSegmentMethod(llvm::Value * doFinal, const std::vector<llvm::Value *> & producerPos) final;
     305
     306    void generateInternalMethods() override final;
    236307
    237308    BlockOrientedKernel(IDISA::IDISA_Builder * builder,
     
    250321
    251322private:
    252     void callGenerateDoBlockMethod() const;
    253 
    254     void callGenerateDoFinalBlockMethod() const;
     323
     324    void callGenerateDoBlockMethod();
     325
     326    void callGenerateDoFinalBlockMethod();
     327
    255328};
    256329
Note: See TracChangeset for help on using the changeset viewer.