Ignore:
Timestamp:
Mar 28, 2016, 3:44:17 PM (3 years ago)
Author:
nmedfort
Message:

Continued work on symbol table.

File:
1 edited

Legend:

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

    r4991 r4992  
    4444    KernelBuilder(std::string name, llvm::Module * m, IDISA::IDISA_Builder * b, const unsigned bufferSize = 1);
    4545
     46    template<typename T>
     47    struct disable_implicit_conversion {
     48        inline disable_implicit_conversion(T const value) : _value(value) {}
     49        inline disable_implicit_conversion(std::nullptr_t) = delete;
     50        inline disable_implicit_conversion(unsigned) = delete;
     51        operator T() { return _value; }
     52        T operator -> () { return _value; }
     53    private:
     54        T const  _value;
     55    };
     56
    4657    unsigned addInternalState(llvm::Type * const type);
    4758    unsigned addInternalState(llvm::Type * const type, std::string && name);
     
    6273    }
    6374
     75    inline llvm::Value * getInputStream(disable_implicit_conversion<llvm::Value *> index, const unsigned streamOffset = 0) {
     76        return getInputStream(mKernelState, index, streamOffset);
     77    }
     78
    6479    inline llvm::Value * getInputScalar(const unsigned index) {
    6580        return getInputScalar(mKernelState, index);
    6681    }
    6782
     83    inline llvm::Value * getInputScalar(disable_implicit_conversion<llvm::Value *> const index) {
     84        return getInputScalar(mKernelState, index);
     85    }
     86
    6887    llvm::Value * getInternalState(const std::string & name) {
    6988        return getInternalState(mKernelState, name);
     
    7897    }
    7998
     99    llvm::Value * getInternalState(disable_implicit_conversion<llvm::Value *> const index) {
     100        return getInternalState(mKernelState, index);
     101    }
     102
    80103    void setInternalState(const unsigned index, llvm::Value * value) {
    81104        setInternalState(mKernelState, index, value);
    82105    }
    83106
     107    void setInternalState(disable_implicit_conversion<llvm::Value *> const index, llvm::Value * value) {
     108        setInternalState(mKernelState, index, value);
     109    }
     110
    84111    llvm::Value * getOutputStream(const unsigned index, const unsigned streamOffset = 0) {
    85112        return getOutputStream(mKernelState, index, streamOffset);
    86113    }
    87114
     115    llvm::Value * getOutputStream(disable_implicit_conversion<llvm::Value *> const index, const unsigned streamOffset = 0) {
     116        return getOutputStream(mKernelState, index, streamOffset);
     117    }
     118
    88119    inline unsigned getNumOfOutputStreams() const {
    89120        return mOutputStream.size();
     
    94125    }
    95126
     127    llvm::Value * getOutputScalar(disable_implicit_conversion<llvm::Value *> const index) {
     128        return getOutputScalar(mKernelState, index);
     129    }
     130
    96131    inline unsigned getNumOfOutputScalars() const {
    97132        return mOutputScalar.size();
     
    130165    llvm::Value * getInputStream(llvm::Value * const instance, const unsigned index, const unsigned streamOffset);
    131166
     167    llvm::Value * getInputStream(llvm::Value * const instance, disable_implicit_conversion<llvm::Value *> index, const unsigned streamOffset);
     168
    132169    llvm::Value * getInputScalar(llvm::Value * const instance, const unsigned index);
    133170
     171    llvm::Value * getInputScalar(llvm::Value * const instance, disable_implicit_conversion<llvm::Value *> index);
     172
    134173    llvm::Value * getInternalState(llvm::Value * const instance, const std::string & name);
    135174
     
    138177    llvm::Value * getInternalState(llvm::Value * const instance, const unsigned index);
    139178
     179    llvm::Value * getInternalState(llvm::Value * const instance, disable_implicit_conversion<llvm::Value *> index);
     180
    140181    void setInternalState(llvm::Value * const instance, const unsigned index, llvm::Value * const value);
    141182
     183    void setInternalState(llvm::Value * const instance, disable_implicit_conversion<llvm::Value *> index, llvm::Value * const value);
     184
    142185    llvm::Value * getOutputStream(llvm::Value * const instance, const unsigned index, const unsigned streamOffset);
    143186
     187    llvm::Value * getOutputStream(llvm::Value * const instance, disable_implicit_conversion<llvm::Value *> index, const unsigned streamOffset);
     188
    144189    llvm::Value * getOutputScalar(llvm::Value * const instance, const unsigned index);
    145190
    146     llvm::Value * getOffset(llvm::Value * const instance, const unsigned value);
     191    llvm::Value * getOutputScalar(llvm::Value * const instance, disable_implicit_conversion<llvm::Value *> index);
     192
     193    llvm::Value * getStreamOffset(llvm::Value * const instance, const unsigned index);
    147194
    148195    llvm::Value * getBlockNo(llvm::Value * const instance);
Note: See TracChangeset for help on using the changeset viewer.