Ignore:
Timestamp:
Jan 5, 2017, 3:54:40 PM (2 years ago)
Author:
nmedfort
Message:

Code clean up to enforce proper calling order of KernelBuilder? methods

File:
1 edited

Legend:

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

    r5240 r5246  
    4040// a continous buffer for the full segment (number of blocks).
    4141
    42 void expand3_4Kernel::generateDoSegmentMethod() {
     42void expand3_4Kernel::generateDoSegmentMethod() const {
    4343    IDISA::IDISA_Builder::InsertPoint savePoint = iBuilder->saveIP();
    4444    Module * m = iBuilder->getModule();
     
    8181        expand_3_4_shuffle[j] = ConstantVector::get(Idxs);
    8282    }
    83     Constant * Const3 = ConstantInt::get(iBuilder->getSizeTy(), 3);
    84     Constant * Const4 = ConstantInt::get(iBuilder->getSizeTy(), 4);
    85     Constant * stride = ConstantInt::get(iBuilder->getSizeTy(), iBuilder->getStride());
    86     Constant * packSize = ConstantInt::get(iBuilder->getSizeTy(), PACK_SIZE);
    87     Constant * loopItemCount = ConstantInt::get(iBuilder->getSizeTy(), 3 * PACK_SIZE); // 3 packs per loop.
     83    Constant * Const3 = iBuilder->getSize(3);
     84    Constant * Const4 = iBuilder->getSize(4);
     85    Constant * stride = iBuilder->getSize(iBuilder->getStride());
     86    Constant * packSize = iBuilder->getSize(PACK_SIZE);
     87    Constant * loopItemCount = iBuilder->getSize(3 * PACK_SIZE); // 3 packs per loop.
    8888    UndefValue * undefPack = UndefValue::get(iBuilder->fwVectorType(parabix::i8));
    8989   
     
    100100    // Except for the final segment, we always process an integral number of triple blocks.
    101101    Value * tripleBlocksToDo = iBuilder->CreateMul(blocksToDo, Const3);
    102     Constant * blockItems = ConstantInt::get(iBuilder->getSizeTy(), iBuilder->getBitBlockWidth());
     102    Constant * blockItems = iBuilder->getSize(iBuilder->getBitBlockWidth());
    103103    Value * tripleItemMax = iBuilder->CreateMul(tripleBlocksToDo, blockItems);
    104104
     
    205205    expand0 = iBuilder->bitCast(iBuilder->CreateShuffleVector(undefPack, pack0, expand_3_4_shuffle[0]));
    206206    iBuilder->CreateAlignedStore(expand0, loopExitOutput_ptr, packAlign);
    207     Value * condition_b = iBuilder->CreateICmpULE(loopExitItemsRemain, ConstantInt::get(iBuilder->getSizeTy(), 3 * PACK_SIZE/4));
     207    Value * condition_b = iBuilder->CreateICmpULE(loopExitItemsRemain, iBuilder->getSize(3 * PACK_SIZE/4));
    208208    iBuilder->CreateCondBr(condition_b, itemsDone, finalStep2);
    209209    // Final Step 2 processing
     
    222222    expand1 = iBuilder->bitCast(iBuilder->CreateShuffleVector(pack0, pack1phi, expand_3_4_shuffle[1]));
    223223    iBuilder->CreateAlignedStore(expand1, outPack1_ptr, packAlign);
    224     Value * condition_d = iBuilder->CreateICmpULE(loopExitItemsRemain, ConstantInt::get(iBuilder->getSizeTy(), 6 * PACK_SIZE/4));
     224    Value * condition_d = iBuilder->CreateICmpULE(loopExitItemsRemain, iBuilder->getSize(6 * PACK_SIZE/4));
    225225    iBuilder->CreateCondBr(condition_d, itemsDone, finalStep3);
    226226    // Final Step 3
    227227    iBuilder->SetInsertPoint(finalStep3);
    228     Value * condition_e = iBuilder->CreateICmpULE(loopExitItemsRemain, ConstantInt::get(iBuilder->getSizeTy(), 2 * PACK_SIZE));
     228    Value * condition_e = iBuilder->CreateICmpULE(loopExitItemsRemain, iBuilder->getSize(2 * PACK_SIZE));
    229229    iBuilder->CreateCondBr(condition_e, step3store, step3load);
    230230    iBuilder->SetInsertPoint(step3load);
     
    239239    expand2 = iBuilder->bitCast(iBuilder->CreateShuffleVector(pack1phi, pack2phi, expand_3_4_shuffle[2]));
    240240    iBuilder->CreateAlignedStore(expand2, outPack2_ptr, packAlign);
    241     Value * condition_f = iBuilder->CreateICmpULE(loopExitItemsRemain, ConstantInt::get(iBuilder->getSizeTy(), 9 * PACK_SIZE/4));
     241    Value * condition_f = iBuilder->CreateICmpULE(loopExitItemsRemain, iBuilder->getSize(9 * PACK_SIZE/4));
    242242    iBuilder->CreateCondBr(condition_f, itemsDone, step3store2);
    243243    iBuilder->SetInsertPoint(step3store2);
     
    284284// The doBlock method is deprecated.   But in case it is used, just call doSegment with
    285285// 1 as the number of blocks to do.
    286 void expand3_4Kernel::generateDoBlockMethod() {
     286void expand3_4Kernel::generateDoBlockMethod() const {
    287287    auto savePoint = iBuilder->saveIP();
    288288    Module * m = iBuilder->getModule();
     
    306306//                                   ba    bits to move 12 positions left
    307307//    xwvuts|  nlkjzy|  barqpm|  hgfedc    Target
    308 void radix64Kernel::generateDoBlockLogic(Value * self, Value * blockNo) {
     308void radix64Kernel::generateDoBlockLogic(Value * self, Value * blockNo) const {
    309309    Value * expandedStream = getStreamSetBlockPtr(self, "expandedStream", blockNo);
    310310    Value * radix64stream = getStreamSetBlockPtr(self, "radix64stream",blockNo);
     
    338338    }
    339339    Value * produced = getProducedItemCount(self);
    340     produced = iBuilder->CreateAdd(produced, ConstantInt::get(iBuilder->getSizeTy(), iBuilder->getStride()));
     340    produced = iBuilder->CreateAdd(produced, iBuilder->getSize(iBuilder->getStride()));
    341341    setProducedItemCount(self, produced);   
    342342}
    343343
    344 void radix64Kernel::generateFinalBlockMethod() {
     344void radix64Kernel::generateFinalBlockMethod() const {
    345345    auto savePoint = iBuilder->saveIP();
    346346    Module * m = iBuilder->getModule();
     
    361361
    362362    const unsigned PACK_SIZE = iBuilder->getStride()/8;
    363     Constant * packSize = ConstantInt::get(iBuilder->getSizeTy(), PACK_SIZE);
     363    Constant * packSize = iBuilder->getSize(PACK_SIZE);
    364364    Value * blockNo = getScalarField(self, blockNoScalar);
    365365    Value * expandedstream_ptr = getStreamSetBlockPtr(self, "expandedStream", blockNo);
     
    457457}
    458458
    459 void radix64Kernel::generateDoBlockMethod() {
     459void radix64Kernel::generateDoBlockMethod() const {
    460460    auto savePoint = iBuilder->saveIP();
    461461
     
    474474
    475475
    476 void base64Kernel::generateDoBlockLogic(Value * self, Value * blockNo) {
     476void base64Kernel::generateDoBlockLogic(Value * self, Value * blockNo) const {
    477477    Value * radix64stream_ptr = getStreamSetBlockPtr(self, "radix64stream", blockNo);
    478478    Value * base64stream_ptr = getStreamSetBlockPtr(self, "base64stream", blockNo);   
     
    497497    }
    498498    Value * produced = getProducedItemCount(self);
    499     produced = iBuilder->CreateAdd(produced, ConstantInt::get(iBuilder->getSizeTy(), iBuilder->getStride()));
     499    produced = iBuilder->CreateAdd(produced, iBuilder->getSize(iBuilder->getStride()));
    500500    setProducedItemCount(self, produced);   
    501501}
     
    505505// of 4 bytes.   When the number of radix 64 values is not a multiple of 4
    506506// number of radix 64 values
    507 void base64Kernel::generateFinalBlockMethod() {
     507void base64Kernel::generateFinalBlockMethod() const {
    508508    auto savePoint = iBuilder->saveIP();
    509509    Module * m = iBuilder->getModule();
     
    520520    Value * self = &*(args++);
    521521    Value * remainingBytes = &*(args++);
    522     Value * remainMod4 = iBuilder->CreateAnd(remainingBytes, ConstantInt::get(iBuilder->getSizeTy(), 3));
    523     Value * padBytes = iBuilder->CreateSub(ConstantInt::get(iBuilder->getSizeTy(), 4), remainMod4);
    524     padBytes = iBuilder->CreateAnd(padBytes, ConstantInt::get(iBuilder->getSizeTy(), 3));
     522    Value * remainMod4 = iBuilder->CreateAnd(remainingBytes, iBuilder->getSize(3));
     523    Value * padBytes = iBuilder->CreateSub(iBuilder->getSize(4), remainMod4);
     524    padBytes = iBuilder->CreateAnd(padBytes, iBuilder->getSize(3));
    525525
    526526    Constant * packSize = iBuilder->getSize(iBuilder->getStride() / 8);
     
    574574}
    575575
    576 void base64Kernel::generateDoBlockMethod() {
     576void base64Kernel::generateDoBlockMethod() const {
    577577    auto savePoint = iBuilder->saveIP();
    578578
Note: See TracChangeset for help on using the changeset viewer.