Ignore:
Timestamp:
May 10, 2017, 4:26:11 PM (2 years ago)
Author:
nmedfort
Message:

Large refactoring step. Removed IR generation code from Kernel (formally KernelBuilder?) and moved it into the new KernelBuilder? class.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/alignedprint.cpp

    r5436 r5440  
    1111namespace kernel {
    1212
    13 inline void ap_p2s_step(IDISA::IDISA_Builder * const iBuilder, Value * p0, Value * p1, Value * hi_mask, unsigned shift, Value * &s1, Value * &s0) {
     13inline void ap_p2s_step(const std::unique_ptr<KernelBuilder> & iBuilder, Value * p0, Value * p1, Value * hi_mask, unsigned shift, Value * &s1, Value * &s0) {
    1414    Value * t0 = iBuilder->simd_if(1, hi_mask, p0, iBuilder->simd_srli(16, p1, shift));
    1515    Value * t1 = iBuilder->simd_if(1, hi_mask, iBuilder->simd_slli(16, p0, shift), p1);
     
    1818}
    1919
    20 inline void p2s(IDISA::IDISA_Builder * const iBuilder, Value * p[], Value * s[]) {
     20inline void p2s(const std::unique_ptr<KernelBuilder> & iBuilder, Value * p[], Value * s[]) {
    2121    Value * bit00004444[2];
    2222    Value * bit22226666[2];
     
    3838}
    3939
    40 void PrintableBits::generateDoBlockMethod() {
     40void PrintableBits::generateDoBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder) {
    4141    // Load current block
    42     Value * bitStrmVal = loadInputStreamBlock("bitStream", iBuilder->getInt32(0));
     42    Value * bitStrmVal = iBuilder->loadInputStreamBlock("bitStream", iBuilder->getInt32(0));
    4343
    4444    Value * bits[8];
     
    8181   
    8282    for (unsigned j = 0; j < 8; ++j) {
    83         storeOutputStreamPack("byteStream", iBuilder->getInt32(0), iBuilder->getInt32(j), iBuilder->bitCast(printableBytes[j]));
    84     }
    85 }
    86 
    87 void SelectStream::generateDoBlockMethod() {
     83        iBuilder->storeOutputStreamPack("byteStream", iBuilder->getInt32(0), iBuilder->getInt32(j), iBuilder->bitCast(printableBytes[j]));
     84    }
     85}
     86
     87void SelectStream::generateDoBlockMethod(const std::unique_ptr<KernelBuilder> &iBuilder) {
    8888    if (mStreamIndex >= mSizeInputStreamSet)
    8989        llvm::report_fatal_error("Stream index out of bounds.\n");
    9090   
    91     Value * bitStrmVal = loadInputStreamBlock("bitStreams", iBuilder->getInt32(mStreamIndex));
    92 
    93     storeOutputStreamBlock("bitStream", iBuilder->getInt32(0), bitStrmVal);
    94 }
    95 
    96 void PrintStreamSet::generateDoBlockMethod() {
     91    Value * bitStrmVal = iBuilder->loadInputStreamBlock("bitStreams", iBuilder->getInt32(mStreamIndex));
     92
     93    iBuilder->storeOutputStreamBlock("bitStream", iBuilder->getInt32(0), bitStrmVal);
     94}
     95
     96void PrintStreamSet::generateDoBlockMethod(const std::unique_ptr<KernelBuilder> &iBuilder) {
    9797
    9898    /*
     
    122122        BasicBlock * entry = iBuilder->GetInsertBlock();
    123123
    124         Value * count = getInputStreamSetCount(name);
     124        Value * count = iBuilder->getInputStreamSetCount(name);
    125125        ConstantInt * const streamLength = iBuilder->getSize(iBuilder->getBitBlockWidth() + mNameWidth + 1);
    126126        Value * output = iBuilder->CreateAlloca(iBuilder->getInt8Ty(), streamLength);
     
    135135
    136136            // Load current block
    137             Value * const input = loadInputStreamBlock(name, iBuilder->getInt32(0));
     137            Value * const input = iBuilder->loadInputStreamBlock(name, iBuilder->getInt32(0));
    138138
    139139            Value * bits[8];
     
    164164            iBuilder->CreateStore(iBuilder->getInt8('['), iBuilder->CreateGEP(output, length));
    165165
    166             BasicBlock * cond = CreateBasicBlock("cond");
    167 
    168             BasicBlock * getIntLength = CreateBasicBlock("getIntLength");
    169 
    170             BasicBlock * writeInt = CreateBasicBlock("writeInt");
    171             BasicBlock * writeVector = CreateBasicBlock("writeVector");
    172 
    173             BasicBlock * exit = CreateBasicBlock("exit");
     166            BasicBlock * cond = iBuilder->CreateBasicBlock("cond");
     167
     168            BasicBlock * getIntLength = iBuilder->CreateBasicBlock("getIntLength");
     169
     170            BasicBlock * writeInt = iBuilder->CreateBasicBlock("writeInt");
     171            BasicBlock * writeVector = iBuilder->CreateBasicBlock("writeVector");
     172
     173            BasicBlock * exit = iBuilder->CreateBasicBlock("exit");
    174174
    175175            ConstantInt * TEN = iBuilder->getSize(10);
     
    217217
    218218            // Load current block
    219             Value * const input = loadInputStreamBlock(name, i);
     219            Value * const input = iBuilder->loadInputStreamBlock(name, i);
    220220
    221221            Value * bits[8];
Note: See TracChangeset for help on using the changeset viewer.