Changeset 4003 for icGREP


Ignore:
Timestamp:
Aug 15, 2014, 1:22:17 PM (5 years ago)
Author:
cameron
Message:

Fix carry increment bug; tag Seq byte ranges

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

Legend:

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

    r4002 r4003  
    10041004
    10051005        //CarryQ - carry in.
    1006         Value* carryq_idx = b.getInt64(mCarryQueueIdx);
    1007         Value* carryq_GEP = b.CreateGEP(mptr_carry_q, carryq_idx);
     1006        Value* carryq_GEP = genNewCarryInPtr();
    10081007        Value* carryq_value = b.CreateLoad(carryq_GEP);
    10091008
     
    10281027        Value* void_1 = b.CreateStore(carryout_2_carry, carryq_GEP);
    10291028
    1030         //Increment the idx for the next advance or scan through.
    1031         mCarryQueueIdx++;
    1032 
    10331029        retVal = result_value;
    10341030    }
     
    10361032    {
    10371033        IRBuilder<> b(mBasicBlock);
    1038 #if 0
    1039         //CarryQ - carry in.
    1040         Value* carryq_idx = b.getInt64(mCarryQueueIdx);
    1041         Value* carryq_GEP = b.CreateGEP(mptr_carry_q, carryq_idx);
    1042         Value* carryq_value = b.CreateLoad(carryq_GEP);
    1043         //Get the input stream.
    1044         Value* strm_value = Generate_PabloE(mstar->getExpr1());
    1045         //Get the character that is to be matched.
    1046         Value* cc_value = Generate_PabloE(mstar->getExpr2());
    1047 
    1048         Value* and_value_1 = b.CreateAnd(cc_value, strm_value, "match_star_and_value_1");
    1049         Value* add_value_1 = b.CreateAdd(and_value_1, cc_value, "match_star_add_value_1");
    1050         Value* add_value_2 = b.CreateAdd(add_value_1, carryq_value, "match_star_add_value_2");
    1051         Value* xor_value_1 = b.CreateXor(add_value_2, mConst_Aggregate_64x2_neg1, "match_star_xor_value_1");
    1052         Value* and_value_2 = b.CreateAnd(cc_value, xor_value_1, "match_star_and_value_2");
    1053         Value* or_value_1 = b.CreateOr(and_value_1, and_value_2, "match_star_or_value_1");
    1054 
    1055         Value* srli_instr_1 = b.CreateLShr(or_value_1, 63);
    1056 
    1057         Value* cast_marker_value_1 = b.CreateBitCast(srli_instr_1, IntegerType::get(mMod->getContext(), 128));
    1058         Value* sll_1_value = b.CreateShl(cast_marker_value_1, 64);
    1059         Value* cast_marker_value_2 = b.CreateBitCast(sll_1_value, m64x2Vect);
    1060 
    1061 
    1062         Value* add_value_3 = b.CreateAdd(cast_marker_value_2, add_value_2, "match_star_add_value_3");
    1063         Value* xor_value_2 = b.CreateXor(add_value_3, mConst_Aggregate_64x2_neg1, "match_star_xor_value_2");
    1064         Value* and_value_3 = b.CreateAnd(cc_value, xor_value_2, "match_star_and_value_3");
    1065         Value* or_value_2  = b.CreateOr(and_value_1, and_value_3, "match_star_or_value_2 ");
    1066         Value* xor_value_3 = b.CreateXor(add_value_3, cc_value, "match_star_xor_value_3");
    1067         Value* result_value = b.CreateOr(xor_value_3, strm_value, "match_star_result_value");
    1068 
    1069         //CarryQ - carry out:
    1070         Value* cast_marker_value_3 = b.CreateBitCast(or_value_2, IntegerType::get(mMod->getContext(), 128));
    1071         Value* srli_2_value = b.CreateLShr(cast_marker_value_3, 127);
    1072         Value* carryout_2_carry = b.CreateBitCast(srli_2_value, m64x2Vect);
    1073 
    1074         Value* void_1 = b.CreateStore(carryout_2_carry, carryq_GEP);
    1075 
    1076         mCarryQueueIdx++;
    1077 
    1078         retVal = result_value;
    1079 #endif
    10801034        //Get the input stream.
    10811035        Value* strm_value = Generate_PabloE(mstar->getExpr1());
     
    10871041    {
    10881042        IRBuilder<> b(mBasicBlock);
    1089 #if 0
    1090         //CarryQ - carry in.
    1091         Value* carryq_idx = b.getInt64(mCarryQueueIdx);
    1092         Value* carryq_GEP = b.CreateGEP(mptr_carry_q, carryq_idx);
    1093         Value* carryq_value = b.CreateLoad(carryq_GEP);
    1094         //Get the input stream.
    1095         Value* strm_value = Generate_PabloE(sthru->getScanFrom());
    1096         //Get the scanthru bit stream.
    1097         Value* scanthru_value = Generate_PabloE(sthru->getScanThru());
    1098 
    1099         Value* and_value_1 = b.CreateAnd(scanthru_value, strm_value, "scanthru_and_value_1");
    1100         Value* add_value_1 = b.CreateAdd(and_value_1, carryq_value, "scanthru_add_value_1");
    1101         Value* add_value_2 = b.CreateAdd(add_value_1, scanthru_value, "scanthru_add_value_2");
    1102 
    1103         Value* srli_instr_1 = b.CreateLShr(and_value_1, 63);
    1104 
    1105         Value* cast_marker_value_1 = b.CreateBitCast(srli_instr_1, IntegerType::get(mMod->getContext(), 128));
    1106         Value* sll_1_value = b.CreateShl(cast_marker_value_1, 64);
    1107         Value* cast_marker_value_2 = b.CreateBitCast(sll_1_value, m64x2Vect);
    1108 
    1109         Value* add_value_3 = b.CreateAdd(cast_marker_value_2, add_value_2, "scanthru_add_value_3");
    1110         Value* xor_value_1  = b.CreateXor(scanthru_value, mConst_Aggregate_64x2_neg1, "scanthru_xor_value_1");
    1111         Value* result_value = b.CreateAnd(add_value_3, xor_value_1, "scanthru_result_value");
    1112 
    1113         //CarryQ - carry out:
    1114         Value* cast_marker_value_3 = b.CreateBitCast(add_value_3, IntegerType::get(mMod->getContext(), 128));
    1115         Value* srli_2_value = b.CreateLShr(cast_marker_value_3, 127);
    1116         Value* carryout_2_carry = b.CreateBitCast(srli_2_value, m64x2Vect);
    1117 
    1118         Value* void_1 = b.CreateStore(carryout_2_carry, carryq_GEP);
    1119 
    1120         mCarryQueueIdx++;
    1121 
    1122         retVal = result_value;
    1123 #endif
    11241043        //Get the input stream.
    11251044        Value* strm_value = Generate_PabloE(sthru->getScanFrom());
     
    11481067   
    11491068    //CarryQ - carry in.
    1150     Value* carryq_idx = b.getInt64(mCarryQueueIdx);
    1151     Value* carryq_GEP = b.CreateGEP(mptr_carry_q, carryq_idx);
     1069    Value* carryq_GEP = genNewCarryInPtr();
    11521070    Value* carryq_value = b.CreateLoad(carryq_GEP);
    11531071
     
    11651083    Value* void_1 = b.CreateStore(carry_out, carryq_GEP);
    11661084   
     1085    return sum;
     1086}
     1087
     1088Value* LLVM_Generator::genNewCarryInPtr() {
     1089    IRBuilder<> b(mBasicBlock);
     1090    Value* carryq_idx = b.getInt64(mCarryQueueIdx);
     1091    Value* carryq_GEP = b.CreateGEP(mptr_carry_q, carryq_idx);
    11671092    mCarryQueueIdx++;
    1168     return sum;
    1169 }
     1093    return carryq_GEP;
     1094}
     1095
    11701096
    11711097
  • icGREP/icgrep-devel/icgrep/llvm_gen.h

    r3999 r4003  
    125125    Value* genMatchStar(Value* marker_expr, Value* cc_expr);
    126126    Value* genScanThru(Value* marker_expr, Value* cc_expr);
     127    Value* genNewCarryInPtr();
    127128    Value* genAddWithCarry(Value* e1, Value* e2);
    128129    Value* genShiftRight127(Value* e, const Twine &namehint = "");
  • icGREP/icgrep-devel/icgrep/utf8_encoder.cpp

    r3998 r4003  
    160160        {
    161161            Seq* seq = new Seq();
     162            seq->setType((u8Prefix(hbyte) ? Seq::Byte : Seq::Normal));
    162163            seq->AddREListItem(makeByteRange(lbyte, hbyte));
    163164            seq->AddREListItem(rangeToUTF8_helper(lo, hi, n + 1, hlen));
     
    169170bool UTF8_Encoder::u8Prefix(int cp)
    170171{
    171     bool retVal = false;
    172 
    173     if ((cp >= 0xC2) && (cp <= 0xDF))
    174     {
    175         retVal = true;
    176     }
    177     else if ((cp >= 0xE0) && (cp <= 0xEF))
    178     {
    179         retVal = true;
    180     }
    181     else if ((cp >= 0xF0) && (cp <= 0xF4))
    182     {
    183         retVal = true;
     172    return ((cp >= 0xC2) && (cp <= 0xF4));
     173}
     174
     175CC* UTF8_Encoder::makeByteRange(int lo, int hi)
     176{
     177    return new CC(lo, hi);
     178}
     179
     180CC* UTF8_Encoder::makeByteClass(int byteval)
     181{
     182    return new CC(byteval, byteval);
     183}
     184
     185int UTF8_Encoder::u8byte(int codepoint, int n)
     186{
     187    int retVal = 0;
     188
     189    int len = u8len(codepoint);
     190
     191    if (n == 1)
     192    {
     193        if (len == 1)
     194        {
     195            retVal = codepoint;
     196        }
     197        else if (len == 2)
     198        {
     199            retVal = 0xC0 | (codepoint >> 6);
     200        }
     201        else if (len == 3)
     202        {
     203            retVal = 0xE0 | (codepoint >> 12);
     204        }
     205        else
     206        {
     207            retVal = 0xF0 | (codepoint >> 18);
     208        }
     209    }
     210    else
     211    {
     212        retVal = 0x80 | ((codepoint >> (6 * (len - n))) & 0x3F);
    184213    }
    185214
     
    187216}
    188217
    189 CC* UTF8_Encoder::makeByteRange(int lo, int hi)
    190 {
    191     return new CC(lo, hi);
    192 }
    193 
    194 CC* UTF8_Encoder::makeByteClass(int byteval)
    195 {
    196     return new CC(byteval, byteval);
    197 }
    198 
    199 int UTF8_Encoder::u8byte(int codepoint, int n)
    200 {
    201     int retVal = 0;
    202 
    203     int len = u8len(codepoint);
    204 
    205     if (n == 1)
    206     {
    207         if (len == 1)
    208         {
    209             retVal = codepoint;
    210         }
    211         else if (len == 2)
    212         {
    213             retVal = 0xC0 | (codepoint >> 6);
    214         }
    215         else if (len == 3)
    216         {
    217             retVal = 0xE0 | (codepoint >> 12);
    218         }
    219         else
    220         {
    221             retVal = 0xF0 | (codepoint >> 18);
    222         }
    223     }
    224     else
    225     {
    226         retVal = 0x80 | ((codepoint >> (6 * (len - n))) & 0x3F);
    227     }
    228 
    229     return retVal;
    230 }
    231 
    232218int UTF8_Encoder::u8len(int cp)
    233219{
Note: See TracChangeset for help on using the changeset viewer.