Ignore:
Timestamp:
Apr 25, 2017, 2:33:31 PM (2 years ago)
Author:
nmedfort
Message:

Changes towards separate compilation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/IR_Gen/CBuilder.h

    r5424 r5425  
    66#define CBUILDER_H
    77
    8 #include <string>
     8#include <IR_Gen/FunctionTypeBuilder.h>
    99#include <llvm/IR/IRBuilder.h>
    1010#include <llvm/IR/Constants.h>
     11#include <llvm/ADT/Triple.h>
     12
     13namespace kernels { class KernelBuilder; }
    1114namespace llvm { class Function; }
    1215namespace llvm { class IntegerType; }
     
    1619namespace llvm { class Value; }
    1720
     21class ParabixDriver;
     22
    1823class CBuilder : public llvm::IRBuilder<> {
    19    
     24    friend class ParabixDriver;
    2025public:
    2126
    22     CBuilder(llvm::Module * m, const unsigned GeneralRegisterWidthInBits, const bool SupportsIndirectBr, const unsigned CacheLineAlignmentInBytes = 64);
     27    CBuilder(llvm::Module * const module, const unsigned GeneralRegisterWidthInBits, const bool SupportsIndirectBr, const unsigned CacheLineAlignmentInBytes = 64);
    2328   
    2429    virtual ~CBuilder() {}
     
    2833    }
    2934   
    30     void setModule(llvm::Module * m)  {
     35    void setModule(llvm::Module * m) {
     36        assert (m);
    3137        mMod = m;
    3238    }
     39
    3340
    3441    llvm::Value * CreateMalloc(llvm::Value * size);
     
    138145
    139146    inline llvm::IntegerType * getSizeTy() const {
     147        assert (mSizeType);
    140148        return mSizeType;
    141149    }
     
    180188    llvm::Value * CreateReadCycleCounter();
    181189
     190    template <typename ExternalFunctionType>
     191    llvm::Function * LinkFunction(llvm::StringRef name, ExternalFunctionType * functionPtr) const;
     192
    182193protected:
    183     llvm::Module *                  mMod;
     194
     195    llvm::Function * LinkFunction(llvm::StringRef name, llvm::FunctionType * type, void * functionPtr) const;
     196
     197    void setDriver(ParabixDriver * driver) {
     198        mDriver = driver;
     199    }
     200
     201protected:
     202    llvm::Module *                  mMod;   
    184203    unsigned                        mCacheLineAlignment;
    185204    llvm::IntegerType *             mSizeType;
    186205    llvm::StructType *              mFILEtype;
    187206    const bool                      mSupportsIndirectBr;
     207    ParabixDriver *                 mDriver;
     208    llvm::LLVMContext               mContext;
     209    const std::string               mTriple;
    188210};
    189211
     212template <typename ExternalFunctionType>
     213llvm::Function *CBuilder::LinkFunction(llvm::StringRef name, ExternalFunctionType * functionPtr) const {
     214    llvm::FunctionType * const type = FunctionTypeBuilder<ExternalFunctionType>::get(getContext());
     215    assert ("FunctionTypeBuilder did not resolve a function type." && type);
     216    return LinkFunction(name, type, reinterpret_cast<void *>(functionPtr));
     217}
     218
    190219#endif
Note: See TracChangeset for help on using the changeset viewer.