Ignore:
Timestamp:
Jan 14, 2017, 3:49:56 PM (2 years ago)
Author:
nmedfort
Message:

Changes working towards simplifying accessing stream elements + some modifications to simplify include / forward declarations within the CodeGen? library.

File:
1 edited

Legend:

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

    r5245 r5260  
    66#define CBUILDER_H
    77
    8 #include <llvm/IR/Module.h>
    9 #include <llvm/IR/Constant.h>
    10 #include <llvm/IR/Type.h>
    11 #include <llvm/IR/Value.h>
     8#include <string>
    129#include <llvm/IR/IRBuilder.h>
    13 #include <llvm/Support/Host.h>
    14 #include <llvm/ADT/Triple.h>
    15 #include <IR_Gen/types/streamtype.h>
    16 #include <boost/container/flat_map.hpp>
     10#include <llvm/IR/Constants.h>
     11namespace llvm { class Function; }
     12namespace llvm { class IntegerType; }
     13namespace llvm { class Module; }
     14namespace llvm { class PointerType; }
     15namespace llvm { class Type; }
     16namespace llvm { class Value; }
    1717
    18 using namespace llvm;
    19 
    20 
    21 class CBuilder : public IRBuilder<> {
     18class CBuilder : public llvm::IRBuilder<> {
    2219   
    2320public:
    2421   
    25     CBuilder(Module * m, unsigned archBitWidth, unsigned CacheAlignment=64)
    26     : IRBuilder<>(m->getContext())
    27     , mMod(m)
    28     , mCacheLineAlignment(CacheAlignment)
    29     , mSizeType(getIntNTy(archBitWidth)) {
    30     }
     22    CBuilder(llvm::Module * m, unsigned archBitWidth, unsigned CacheAlignment=64);
    3123   
    3224    virtual ~CBuilder() {}
    3325
    34     Module * getModule() const {
     26    llvm::Module * getModule() const {
    3527        return mMod;
    3628    }
    3729   
    38     void setModule(Module * m)  {
     30    void setModule(llvm::Module * m)  {
    3931        mMod = m;
    4032    }
    4133   
    42     Function * GetPrintf();
    43     Value * CreateMalloc(Type * type, Value * size);
    44     Value * CreateAlignedMalloc(Type * type, Value * size, const unsigned alignment);
    45     void CreateFree(Value * const ptr);
    46     void CreateAlignedFree(Value * const ptr, const bool ptrMayBeNull = false);
    47     Value * CreateRealloc(Value * ptr, Value * size);
    48     void CreateMemZero(Value * ptr, Value * size, const unsigned alignment = 1);
     34    llvm::Function * GetPrintf();
     35    llvm::Value * CreateMalloc(llvm::Type * type, llvm::Value * size);
     36    llvm::Value * CreateAlignedMalloc(llvm::Type * type, llvm::Value * size, const unsigned alignment);
     37    void CreateFree(llvm::Value * const ptr);
     38    void CreateAlignedFree(llvm::Value * const ptr, const bool ptrMayBeNull = false);
     39    llvm::Value * CreateRealloc(llvm::Value * ptr, llvm::Value * size);
     40    void CreateMemZero(llvm::Value * ptr, llvm::Value * size, const unsigned alignment = 1);
    4941
    5042    inline llvm::AllocaInst * CreateCacheAlignedAlloca(llvm::Type * Ty, llvm::Value * ArraySize = nullptr) {
     
    5749    //
    5850    // ssize_t write(int fildes, const void *buf, size_t nbyte);
    59     Value * CreateWriteCall(Value * fildes, Value * buf, Value * nbyte);
     51    llvm::Value * CreateWriteCall(llvm::Value * fildes, llvm::Value * buf, llvm::Value * nbyte);
    6052   
    6153    // Create calls to Posix thread (pthread.h) functions.
     
    6355    //  int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
    6456    //                    void *(*start_routine)(void*), void *arg);
    65     Value * CreatePThreadCreateCall(Value * thread, Value * attr, Function * start_routine, Value * arg);
     57    llvm::Value * CreatePThreadCreateCall(llvm::Value * thread, llvm::Value * attr, llvm::Function * start_routine, llvm::Value * arg);
    6658    //  void pthread_exit(void *value_ptr);
    67     Value * CreatePThreadExitCall(Value * value_ptr);
     59    llvm::Value * CreatePThreadExitCall(llvm::Value * value_ptr);
    6860    //  int pthread_join(pthread_t thread, void **value_ptr);
    69     Value * CreatePThreadJoinCall(Value * thread, Value * value_ptr);
     61    llvm::Value * CreatePThreadJoinCall(llvm::Value * thread, llvm::Value * value_ptr);
    7062   
    71     void CallPrintInt(const std::string & name, Value * const value);
     63    void CallPrintInt(const std::string & name, llvm::Value * const value);
    7264   
    7365    inline llvm::IntegerType * getSizeTy() const {
     
    7668   
    7769    inline llvm::ConstantInt * getSize(const size_t value) const {
    78         return ConstantInt::get(getSizeTy(), value);
     70        return llvm::ConstantInt::get(getSizeTy(), value);
    7971    }
    8072   
    81     PointerType * getVoidPtrTy() const;
     73    llvm::PointerType * getVoidPtrTy() const;
    8274   
    8375    inline unsigned getCacheAlignment() const {
     
    8577    }
    8678   
    87     virtual llvm::LoadInst* CreateAtomicLoadAcquire(Value * ptr);
    88     virtual llvm::StoreInst *  CreateAtomicStoreRelease(Value * val, Value * ptr);
     79    virtual llvm::LoadInst* CreateAtomicLoadAcquire(llvm::Value * ptr);
     80
     81    virtual llvm::StoreInst *  CreateAtomicStoreRelease(llvm::Value * val, llvm::Value * ptr);
    8982   
    9083protected:
    91     Module *            mMod;
     84    llvm::Module *      mMod;
    9285    unsigned            mCacheLineAlignment;
    93     IntegerType *      mSizeType;
     86    llvm::IntegerType * mSizeType;
    9487};
    9588
Note: See TracChangeset for help on using the changeset viewer.