Ignore:
Timestamp:
May 7, 2017, 4:34:48 PM (2 years ago)
Author:
nmedfort
Message:

Continued refactoring work. PabloKernel? now abstract base type with a 'generatePabloMethod' hook to generate Pablo code.

Location:
icGREP/icgrep-devel/icgrep/IR_Gen
Files:
10 edited

Legend:

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

    r5435 r5436  
    746746}
    747747
    748 CBuilder::CBuilder(Module * const module, const unsigned GeneralRegisterWidthInBits)
    749 : IRBuilder<>(module->getContext())
    750 , mMod(module)
     748CBuilder::CBuilder(llvm::LLVMContext & C, const unsigned GeneralRegisterWidthInBits)
     749: IRBuilder<>(C)
     750, mMod(nullptr)
    751751, mCacheLineAlignment(64)
    752752, mSizeType(getIntNTy(GeneralRegisterWidthInBits))
  • icGREP/icgrep-devel/icgrep/IR_Gen/CBuilder.h

    r5435 r5436  
    2525public:
    2626
    27     CBuilder(llvm::Module * const module, const unsigned GeneralRegisterWidthInBits);
     27    CBuilder(llvm::LLVMContext & C, const unsigned GeneralRegisterWidthInBits);
    2828   
    2929    virtual ~CBuilder() {}
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_avx_builder.cpp

    r5374 r5436  
    99namespace IDISA {
    1010   
    11 std::string IDISA_AVX_Builder::getBuilderUniqueName() { return mBitBlockWidth != 256 ? "AVX_" + std::to_string(mBitBlockWidth) : "AVX";}
    12 std::string IDISA_AVX2_Builder::getBuilderUniqueName() { return mBitBlockWidth != 256 ? "AVX2_" + std::to_string(mBitBlockWidth) : "AVX2";}
     11std::string IDISA_AVX_Builder::getBuilderUniqueName() {
     12    return mBitBlockWidth != 256 ? "AVX_" + std::to_string(mBitBlockWidth) : "AVX";
     13}
    1314
    1415Value * IDISA_AVX_Builder::hsimd_signmask(unsigned fw, Value * a) {
     
    4344    // Otherwise use default SSE logic.
    4445    return IDISA_SSE_Builder::hsimd_signmask(fw, a);
     46}
     47
     48std::string IDISA_AVX2_Builder::getBuilderUniqueName() {
     49    return mBitBlockWidth != 256 ? "AVX2_" + std::to_string(mBitBlockWidth) : "AVX2";
    4550}
    4651   
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_avx_builder.h

    r5435 r5436  
    1616public:
    1717   
    18     IDISA_AVX_Builder(llvm::Module * const module, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
    19     : IDISA_Builder(module, archBitWidth, bitBlockWidth, stride)
    20     , IDISA_SSE2_Builder(module, archBitWidth, bitBlockWidth, stride)
     18    IDISA_AVX_Builder(llvm::LLVMContext & C, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
     19    : IDISA_Builder(C, archBitWidth, bitBlockWidth, stride)
     20    , IDISA_SSE2_Builder(C, archBitWidth, bitBlockWidth, stride)
    2121    {
    2222
     
    3434public:
    3535   
    36     IDISA_AVX2_Builder(llvm::Module * const module, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
    37     : IDISA_Builder(module, archBitWidth, bitBlockWidth, stride)
    38     , IDISA_AVX_Builder(module, archBitWidth, bitBlockWidth, stride) {
     36    IDISA_AVX2_Builder(llvm::LLVMContext & C, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
     37    : IDISA_Builder(C, archBitWidth, bitBlockWidth, stride)
     38    , IDISA_AVX_Builder(C, archBitWidth, bitBlockWidth, stride) {
    3939
    4040    }
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_builder.cpp

    r5435 r5436  
    2828    return CreateBitCast(a, ty);
    2929}
    30 
    31 std::string IDISA_Builder::getBitBlockTypeName() const {
    32     const auto type = getBitBlockType();
    33     if (type->isIntegerTy()) {
    34         return "i" + std::to_string(getBitBlockWidth());
    35     }
    36     assert("BitBlockType is neither integer nor vector" && type->isVectorTy());
    37     const auto fw = type->getScalarSizeInBits();
    38     return "v" + std::to_string(getBitBlockWidth() / fw) + "i" + std::to_string(fw);
    39 }
    40 
    4130
    4231void IDISA_Builder::CallPrintRegister(const std::string & name, Value * const value) {
     
    376365}
    377366
    378 void IDISA_Builder::initialize(llvm::Module * const module, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride) {
    379 
    380 }
    381 
    382 IDISA_Builder::IDISA_Builder(llvm::Module * const module, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
    383 : CBuilder(module, archBitWidth)
     367IDISA_Builder::IDISA_Builder(llvm::LLVMContext & C, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
     368: CBuilder(C, archBitWidth)
    384369, mBitBlockWidth(bitBlockWidth)
    385370, mStride(stride)
    386 , mBitBlockType(VectorType::get(IntegerType::get(module->getContext(), 64), bitBlockWidth / 64))
     371, mBitBlockType(VectorType::get(IntegerType::get(C, 64), bitBlockWidth / 64))
    387372, mZeroInitializer(Constant::getNullValue(mBitBlockType))
    388373, mOneInitializer(Constant::getAllOnesValue(mBitBlockType))
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_builder.h

    r5435 r5436  
    2020public:
    2121
    22     IDISA_Builder(llvm::Module * const module, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride);
     22    IDISA_Builder(llvm::LLVMContext & C, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride);
    2323
    2424    virtual ~IDISA_Builder();
     
    2626    virtual std::string getBuilderUniqueName() = 0;  // A name uniquely identifying builder/bitBlockWidth/stride.
    2727   
    28     std::string getBitBlockTypeName() const;  // A short string such as v4i64 or i256.
    29 
    3028    llvm::Value * bitCast(llvm::Value * a) {
    3129        return CreateBitCast(a, mBitBlockType);
     
    129127
    130128    void CallPrintRegister(const std::string & regName, llvm::Value * const value);
    131    
    132 protected:
    133 
    134     void initialize(llvm::Module * const module, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride);
    135129
    136130protected:
    137     unsigned            mBitBlockWidth;
    138     unsigned            mStride;
     131    const unsigned              mBitBlockWidth;
     132    const unsigned              mStride;
     133    llvm::VectorType * const    mBitBlockType;
     134    llvm::Constant * const      mZeroInitializer;
     135    llvm::Constant * const      mOneInitializer;
    139136
    140     llvm::VectorType *  mBitBlockType;
    141     llvm::Constant *    mZeroInitializer;
    142     llvm::Constant *    mOneInitializer;
    143     llvm::Constant *    mPrintRegisterFunction;
     137    llvm::Constant *            mPrintRegisterFunction;
    144138};
    145139
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_i64_builder.h

    r5435 r5436  
    1616public:
    1717 
    18     IDISA_I64_Builder(llvm::Module * const module, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
    19     : IDISA_Builder(module, archBitWidth, bitBlockWidth, stride) {
     18    IDISA_I64_Builder(llvm::LLVMContext & C, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
     19    : IDISA_Builder(C, archBitWidth, bitBlockWidth, stride) {
    2020
    2121    }
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_nvptx_builder.h

    r5435 r5436  
    1616public:
    1717   
    18     IDISA_NVPTX20_Builder(llvm::Module * const module, unsigned registerWidth, unsigned vectorWidth, unsigned groupSize)
    19     : IDISA_Builder(module, registerWidth, registerWidth, (vectorWidth * groupSize))
    20     , IDISA_I64_Builder(module, registerWidth, registerWidth, (vectorWidth * groupSize))
     18    IDISA_NVPTX20_Builder(llvm::LLVMContext & C, unsigned registerWidth, unsigned vectorWidth, unsigned groupSize)
     19    : IDISA_Builder(C, registerWidth, registerWidth, (vectorWidth * groupSize))
     20    , IDISA_I64_Builder(C, registerWidth, registerWidth, (vectorWidth * groupSize))
    2121    , groupThreads(groupSize) {
    2222        CreateGlobals();
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_sse_builder.h

    r5435 r5436  
    1717public:
    1818 
    19     IDISA_SSE_Builder(llvm::Module * const module, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
    20     : IDISA_Builder(module, archBitWidth, bitBlockWidth, stride) {
     19    IDISA_SSE_Builder(llvm::LLVMContext & C, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
     20    : IDISA_Builder(C, archBitWidth, bitBlockWidth, stride) {
    2121
    2222    }
     
    3131public:
    3232 
    33     IDISA_SSE2_Builder(llvm::Module * const module, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
    34     : IDISA_Builder(module, archBitWidth, bitBlockWidth, stride)
    35     , IDISA_SSE_Builder(module, archBitWidth, bitBlockWidth, stride) {
     33    IDISA_SSE2_Builder(llvm::LLVMContext & C, unsigned archBitWidth, unsigned bitBlockWidth, unsigned stride)
     34    : IDISA_Builder(C, archBitWidth, bitBlockWidth, stride)
     35    , IDISA_SSE_Builder(C, archBitWidth, bitBlockWidth, stride) {
    3636
    3737    }
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_target.cpp

    r5435 r5436  
    66#include "idisa_target.h"
    77#include <toolchain/toolchain.h>
     8#include <IR_Gen/idisa_sse_builder.h>
    89#include <IR_Gen/idisa_avx_builder.h>
    9 #include <IR_Gen/idisa_sse_builder.h>
    1010#include <IR_Gen/idisa_i64_builder.h>
    1111#include <IR_Gen/idisa_nvptx_builder.h>
     
    3535    if (codegen::BlockSize >= 256) {
    3636        if (hasAVX2) {
    37             return new KernelBuilderImpl<IDISA_AVX2_Builder>(module, registerWidth, codegen::BlockSize, codegen::BlockSize);
     37            return new KernelBuilderImpl<IDISA_AVX2_Builder>(module->getContext(), registerWidth, codegen::BlockSize, codegen::BlockSize);
    3838        }
    3939    } else if (codegen::BlockSize == 64) {
    40         return new KernelBuilderImpl<IDISA_I64_Builder>(module, registerWidth, codegen::BlockSize, codegen::BlockSize);
     40        return new KernelBuilderImpl<IDISA_I64_Builder>(module->getContext(), registerWidth, codegen::BlockSize, codegen::BlockSize);
    4141    }
    42     return new KernelBuilderImpl<IDISA_SSE2_Builder>(module, registerWidth, codegen::BlockSize, codegen::BlockSize);
     42    return new KernelBuilderImpl<IDISA_SSE2_Builder>(module->getContext(), registerWidth, codegen::BlockSize, codegen::BlockSize);
    4343}
    4444
    4545KernelBuilder * GetIDISA_GPU_Builder(llvm::Module * const module) {
    46     return new KernelBuilderImpl<IDISA_NVPTX20_Builder>(module, 64, 64, 64);
     46    return new KernelBuilderImpl<IDISA_NVPTX20_Builder>(module->getContext(), 64, 64, 64);
    4747}
    4848
Note: See TracChangeset for help on using the changeset viewer.