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/s2p_kernel.cpp

    r5436 r5440  
    1414const int PACK_LANES = 1;
    1515
    16 void s2p_step(IDISA::IDISA_Builder * const iBuilder, Value * s0, Value * s1, Value * hi_mask, unsigned shift, Value * &p0, Value * &p1) {
     16void s2p_step(const std::unique_ptr<KernelBuilder> & iBuilder, Value * s0, Value * s1, Value * hi_mask, unsigned shift, Value * &p0, Value * &p1) {
    1717    Value * t0 = nullptr;
    1818    Value * t1 = nullptr;
     
    3030}
    3131
    32 void s2p(IDISA::IDISA_Builder * const iBuilder, Value * input[], Value * output[]) {
     32void s2p(const std::unique_ptr<KernelBuilder> & iBuilder, Value * input[], Value * output[]) {
    3333    Value * bit00224466[4];
    3434    Value * bit11335577[4];
     
    5757/* Alternative transposition model, but small field width packs are problematic. */
    5858#if 0
    59 void s2p_ideal(IDISA::IDISA_Builder * const iBuilder, Value * input[], Value * output[]) {
     59void s2p_ideal(const std::unique_ptr<KernelBuilder> & iBuilder, Value * input[], Value * output[]) {
    6060    Value * hi_nybble[4];
    6161    Value * lo_nybble[4];
     
    8888   
    8989#if 0
    90 void generateS2P_16Kernel(Module *, IDISA::IDISA_Builder * const iBuilder, KernelBuilder * kBuilder) {
     90void generateS2P_16Kernel(const std::unique_ptr<KernelBuilder> & iBuilder, Kernel * kBuilder) {
    9191    kBuilder->addInputStream(16, "unit_pack");
    9292    for(unsigned i = 0; i < 16; i++) {
    9393            kBuilder->addOutputStream(1);
    9494    }
    95     kBuilder->prepareFunction();
    96 
    9795    Value * ptr = kBuilder->getInputStream(0);
    9896
     
    112110        iBuilder->CreateBlockAlignedStore(output[j], kBuilder->getOutputStream(j));
    113111    }
    114     kBuilder->finalize();
    115112}   
    116113#endif
    117114   
    118 void S2PKernel::generateDoBlockMethod() {
     115void S2PKernel::generateDoBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder) {
    119116    Value * bytepack[8];
    120117    for (unsigned i = 0; i < 8; i++) {
    121118        if (mAligned) {
    122             bytepack[i] = loadInputStreamPack("byteStream", iBuilder->getInt32(0), iBuilder->getInt32(i));
     119            bytepack[i] = iBuilder->loadInputStreamPack("byteStream", iBuilder->getInt32(0), iBuilder->getInt32(i));
    123120        } else {
    124             Value * ptr = getInputStreamPackPtr("byteStream", iBuilder->getInt32(0), iBuilder->getInt32(i));
     121            Value * ptr = iBuilder->getInputStreamPackPtr("byteStream", iBuilder->getInt32(0), iBuilder->getInt32(i));
    125122            // CreateLoad defaults to aligned here, so we need to force the alignment to 1 byte.
    126123            bytepack[i] = iBuilder->CreateAlignedLoad(ptr, 1);
     
    130127    s2p(iBuilder, bytepack, basisbits);
    131128    for (unsigned i = 0; i < 8; ++i) {
    132         storeOutputStreamBlock("basisBits", iBuilder->getInt32(i), basisbits[i]);
     129        iBuilder->storeOutputStreamBlock("basisBits", iBuilder->getInt32(i), basisbits[i]);
    133130    }
    134131}
    135132
    136 void S2PKernel::generateFinalBlockMethod(Value * remainingBytes) {
     133void S2PKernel::generateFinalBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder, Value * remainingBytes) {
    137134    /* Prepare the s2p final block function:
    138135     assumption: if remaining bytes is greater than 0, it is safe to read a full block of bytes.
     
    140137     */
    141138   
    142     BasicBlock * finalPartialBlock = CreateBasicBlock("partial");
    143     BasicBlock * finalEmptyBlock = CreateBasicBlock("empty");
    144     BasicBlock * exitBlock = CreateBasicBlock("exit");
     139    BasicBlock * finalPartialBlock = iBuilder->CreateBasicBlock("partial");
     140    BasicBlock * finalEmptyBlock = iBuilder->CreateBasicBlock("empty");
     141    BasicBlock * exitBlock = iBuilder->CreateBasicBlock("exit");
    145142   
    146143    Value * emptyBlockCond = iBuilder->CreateICmpEQ(remainingBytes, iBuilder->getSize(0));
    147144    iBuilder->CreateCondBr(emptyBlockCond, finalEmptyBlock, finalPartialBlock);
    148145    iBuilder->SetInsertPoint(finalPartialBlock);
    149     CreateDoBlockMethodCall();
     146    CreateDoBlockMethodCall(iBuilder);
    150147   
    151148    iBuilder->CreateBr(exitBlock);
     
    154151
    155152    for (unsigned i = 0; i < 8; ++i) {
    156         storeOutputStreamBlock("basisBits", iBuilder->getInt32(i), Constant::getNullValue(iBuilder->getBitBlockType()));
     153        iBuilder->storeOutputStreamBlock("basisBits", iBuilder->getInt32(i), Constant::getNullValue(iBuilder->getBitBlockType()));
    157154    }
    158155
Note: See TracChangeset for help on using the changeset viewer.