Changeset 4085 for icGREP


Ignore:
Timestamp:
Aug 27, 2014, 11:27:35 AM (5 years ago)
Author:
cameron
Message:

Some refactoring

Location:
icGREP/icgrep-devel/icgrep
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/llvm_gen.cpp

    r4003 r4085  
    834834    {
    835835        IRBuilder<> b(mBasicBlock);
    836 
     836       
    837837        b.CreateStore(Generate_PabloE(assign->getExpr()), GetMarker(assign->getM()));
    838 
     838       
    839839        retVal = assign->getM();
    840840    }
     
    871871        for (int i=0; i<(mCarryQueueSize-idx); i++)
    872872        {
    873             Value* carryq_idx1 = b_wb1.getInt64(i);
    874             Value* carryq_GEP1 = b_wb1.CreateGEP(ptr_while_carry_q, carryq_idx1);
    875             Value* void_1 = b_wb1.CreateStore(mConst_Aggregate_64x2_0, carryq_GEP1);
     873            Value* void_1 = genCarryOutStore(mConst_Aggregate_64x2_0, ptr_while_carry_q, i);
    876874        }
    877875
     
    885883        for (int c=0; c<(mCarryQueueSize-idx); c++)
    886884        {
    887             Value* carryq_idx = b_wb2.getInt64(c);
    888             Value* carryq_GEP = b_wb2.CreateGEP(mptr_carry_q, carryq_idx);
    889             Value* carryq_value = b_wb2.CreateLoad(carryq_GEP);
    890 
    891             Value* last_carryq_idx = b_wb2.getInt64(idx + c);
    892             Value* last_carryq_GEP = b_wb2.CreateGEP(ptr_last_carry_q, last_carryq_idx);
    893             Value* last_carryq_value = b_wb2.CreateLoad(last_carryq_GEP);
    894 
    895             Value* new_carryq_value = b_wb2.CreateOr(carryq_value, last_carryq_value);
    896             Value* void_1 = b_wb2.CreateStore(new_carryq_value, last_carryq_GEP);
     885            Value* new_carryq_value = b_wb2.CreateOr(genCarryInLoad(mptr_carry_q, c), genCarryInLoad(ptr_last_carry_q, idx + c));
     886            Value* void_1 = genCarryOutStore(new_carryq_value, ptr_last_carry_q, idx + c);
    897887        }
    898888
     
    1003993        IRBuilder<> b(mBasicBlock);
    1004994
    1005         //CarryQ - carry in.
    1006         Value* carryq_GEP = genNewCarryInPtr();
    1007         Value* carryq_value = b.CreateLoad(carryq_GEP);
     995        int this_carry_idx = mCarryQueueIdx;
     996        mCarryQueueIdx++;
     997       
     998        Value* carryq_value = genCarryInLoad(mptr_carry_q, this_carry_idx);
    1008999
    10091000        Value* strm_value = Generate_PabloE(adv->getExpr());
     
    10211012        Value* result_value = b.CreateOr(shl_value, packed_shuffle, "or.result_value");
    10221013
    1023         //CarryQ - carry out.
    1024         Value* cast_marker_value_1 = b.CreateBitCast(strm_value, IntegerType::get(mMod->getContext(), 128));
    1025         Value* srli_2_value = b.CreateLShr(cast_marker_value_1, 127);
    1026         Value* carryout_2_carry = b.CreateBitCast(srli_2_value, m64x2Vect);
    1027         Value* void_1 = b.CreateStore(carryout_2_carry, carryq_GEP);
     1014        Value* carry_out = genShiftRight127(strm_value, "carry_out");
     1015        //CarryQ - carry out:
     1016        Value* void_1 = genCarryOutStore(carry_out, mptr_carry_q, this_carry_idx);
    10281017
    10291018        retVal = result_value;
     
    10321021    {
    10331022        IRBuilder<> b(mBasicBlock);
    1034         //Get the input stream.
    10351023        Value* strm_value = Generate_PabloE(mstar->getExpr1());
    1036         //Get the scanthru bit stream.
    10371024        Value* cc_value = Generate_PabloE(mstar->getExpr2());
    10381025        retVal = genMatchStar(strm_value, cc_value);
     
    10411028    {
    10421029        IRBuilder<> b(mBasicBlock);
    1043         //Get the input stream.
    10441030        Value* strm_value = Generate_PabloE(sthru->getScanFrom());
    1045         //Get the scanthru bit stream.
    10461031        Value* scanthru_value = Generate_PabloE(sthru->getScanThru());
    10471032        retVal = genScanThru(strm_value, scanthru_value);
     
    10671052   
    10681053    //CarryQ - carry in.
    1069     Value* carryq_GEP = genNewCarryInPtr();
    1070     Value* carryq_value = b.CreateLoad(carryq_GEP);
     1054    int this_carry_idx = mCarryQueueIdx;
     1055    mCarryQueueIdx++;
     1056   
     1057    Value* carryq_value = genCarryInLoad(mptr_carry_q, this_carry_idx);
    10711058
    10721059    Value* carrygen = b.CreateAnd(e1, e2, "carrygen");
     
    10811068   
    10821069    //CarryQ - carry out:   
    1083     Value* void_1 = b.CreateStore(carry_out, carryq_GEP);
     1070    Value* void_1 = genCarryOutStore(carry_out, mptr_carry_q, this_carry_idx);
    10841071   
    10851072    return sum;
    10861073}
    10871074
    1088 Value* LLVM_Generator::genNewCarryInPtr() {
     1075Value* LLVM_Generator::genCarryInLoad(Value* ptr_carry_q, int n) {
    10891076    IRBuilder<> b(mBasicBlock);
    1090     Value* carryq_idx = b.getInt64(mCarryQueueIdx);
    1091     Value* carryq_GEP = b.CreateGEP(mptr_carry_q, carryq_idx);
    1092     mCarryQueueIdx++;
    1093     return carryq_GEP;
    1094 }
    1095 
    1096 
    1097 
     1077    Value* carryq_idx = b.getInt64(n);
     1078    Value* carryq_GEP = b.CreateGEP(ptr_carry_q, carryq_idx);
     1079    return b.CreateLoad(carryq_GEP);
     1080}
     1081
     1082Value* LLVM_Generator::genCarryOutStore(Value* carryout, Value* ptr_carry_q, int n ) {
     1083    IRBuilder<> b(mBasicBlock);
     1084    Value* carryq_idx = b.getInt64(n);
     1085    Value* carryq_GEP = b.CreateGEP(ptr_carry_q, carryq_idx);
     1086    return b.CreateStore(carryout, carryq_GEP);
     1087}
     1088
     1089Value* LLVM_Generator::genBitBlockAny(Value* e) {
     1090    IRBuilder<> b(mBasicBlock);
     1091    Value* cast_marker_value_1 = b.CreateBitCast(e, IntegerType::get(mMod->getContext(), 128));
     1092    return b.CreateICmpEQ(cast_marker_value_1, ConstantInt::get(IntegerType::get(mMod->getContext(), 128), 0));
     1093}
    10981094
    10991095Value* LLVM_Generator::genShiftRight127(Value* e, const Twine &namehint) {
  • icGREP/icgrep-devel/icgrep/llvm_gen.h

    r4070 r4085  
    125125    Value* genMatchStar(Value* marker_expr, Value* cc_expr);
    126126    Value* genScanThru(Value* marker_expr, Value* cc_expr);
    127     Value* genNewCarryInPtr();
     127    Value* genCarryInLoad(Value* ptr_carry_q, int carryq_idx);
     128    Value* genCarryOutStore(Value* carryout, Value* ptr_carry_q, int carryq_idx);
    128129    Value* genAddWithCarry(Value* e1, Value* e2);
     130    Value* genBitBlockAny(Value* e);
    129131    Value* genShiftRight127(Value* e, const Twine &namehint = "");
    130132    Value* genShiftLeft64(Value* e, const Twine &namehint = "") ;
Note: See TracChangeset for help on using the changeset viewer.