Changeset 4217


Ignore:
Timestamp:
Oct 6, 2014, 10:37:32 AM (5 years ago)
Author:
nmedfort
Message:

Minor revisions.

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/cc/cc_compiler.cpp

    r4215 r4217  
    102102}
    103103
    104 PabloE* CC_Compiler::bit_pattern_expr(int pattern, int selected_bits)
     104PabloE * CC_Compiler::bit_pattern_expr(int pattern, int selected_bits)
    105105{
    106106    if (selected_bits == 0) {
     
    109109
    110110    std::vector<PabloE*> bit_terms;
    111     int bit_no = 0;
     111    unsigned i = 0;
    112112
    113113    while (selected_bits)
    114114    {
    115         char test_bit = 1 << bit_no;
     115        unsigned test_bit = 1 << i;
    116116        if (selected_bits & test_bit)
    117117        {
    118118            if ((pattern & test_bit) == 0)
    119119            {
    120                 bit_terms.push_back(mCG.createNot(getBasisVar(bit_no)));
     120                bit_terms.push_back(mCG.createNot(getBasisVar(i)));
    121121            }
    122122            else
    123123            {
    124                 bit_terms.push_back(getBasisVar(bit_no));
     124                bit_terms.push_back(getBasisVar(i));
    125125            }
    126126        }
     
    130130        }
    131131        selected_bits &= ~test_bit;
    132         bit_no++;
     132        i++;
    133133    }
    134134
  • icGREP/icgrep-devel/icgrep/llvm_gen.cpp

    r4216 r4217  
    326326{
    327327    m_name_map = name_map;
    328     mBasis_Pattern = basis_pattern;
     328    mBasisBitPattern = basis_pattern;
    329329    mBits = bits;
    330330}
     
    404404
    405405    //The basis bits structure
    406     mPtr_basis_bits_addr = new AllocaInst(mStruct_Basis_Bits_Ptr1, "basis_bits.addr", mBasicBlock);
    407     StoreInst* void_14 = new StoreInst(ptr_basis_bits, mPtr_basis_bits_addr, false, mBasicBlock);
    408 
    409     for (int i = 0; i < mBits; i++)
    410     {
    411         StoreBitBlockMarkerPtr(mBasis_Pattern + std::to_string(i), i);
    412     }
    413 
    414     //The output structure.
    415     mPtr_output_addr = new AllocaInst(mStruct_Output_Ptr1, "output.addr", mBasicBlock);
    416     StoreInst* void_16 = new StoreInst(ptr_output, mPtr_output_addr, false, mBasicBlock);
     406    mBasisBitsAddr = new AllocaInst(mBasisBitsInputPtr, "basis_bits.addr", mBasicBlock);
     407    new StoreInst(ptr_basis_bits, mBasisBitsAddr, false, mBasicBlock);
     408    for (unsigned i = 0; i < mBits; ++i) {
     409        IRBuilder<> b(mBasicBlock);
     410        Value* basisBit = b.CreateLoad(mBasisBitsAddr);
     411        Value* indices[] = {b.getInt64(0), b.getInt32(i)};
     412        const std::string name = mBasisBitPattern + std::to_string(i);
     413        Value* basis_bits_struct_GEP = b.CreateGEP(basisBit, indices, name);
     414        mMarkerMap.insert(make_pair(name, basis_bits_struct_GEP));
     415    }
     416    mPtr_output_addr = new AllocaInst(mOutputPtr, "output.addr", mBasicBlock);
     417    new StoreInst(ptr_output, mPtr_output_addr, false, mBasicBlock);
    417418
    418419    //Generate the IR instructions for the function.
    419     Generate_PabloStatements(cg_state.expressions());
    420 
    421     Assign * final = dyn_cast<Assign>(cg_state.expressions().back());
    422     assert (final);
    423 
    424     SetReturnMarker(final->getName(), 0);
    425     SetReturnMarker(m_name_map.find("LineFeed")->second, 1);
     420    SetReturnMarker(Generate_PabloStatements(cg_state.expressions()), 0);
     421    SetReturnMarker(GetMarker(m_name_map.find("LineFeed")->second), 1);
    426422
    427423    //Terminate the block
     
    439435
    440436    //Un-comment this line in order to display the IR that has been generated by this module.
    441 #ifdef DUMP_GENERATED_IR
     437    #ifdef DUMP_GENERATED_IR
    442438    mMod->dump();
    443 #endif
     439    #endif
    444440
    445441    //Use the pass manager to run optimizations on the function.
     
    493489
    494490    mConst_Aggregate_Xi64_0 = ConstantAggregateZero::get(mXi64Vect);
     491
    495492    std::vector<Constant*> const_packed_27_elems;
    496     for (int i = 0; i < BLOCK_SIZE / 64; ++i)
    497       const_packed_27_elems.push_back(mConst_int64_neg1);
     493    for (int i = 0; i < BLOCK_SIZE / 64; ++i) {
     494        const_packed_27_elems.push_back(mConst_int64_neg1);
     495    }
    498496    mConst_Aggregate_Xi64_neg1 = ConstantVector::get(const_packed_27_elems);
    499497
     
    512510    }
    513511
    514     mStruct_Basis_Bits_Ptr1 = PointerType::get(StructTy_struct_Basis_bits, 0);
     512    mBasisBitsInputPtr = PointerType::get(StructTy_struct_Basis_bits, 0);
    515513
    516514    std::vector<Type*>FuncTy_0_args;
    517     FuncTy_0_args.push_back(mStruct_Basis_Bits_Ptr1);
     515    FuncTy_0_args.push_back(mBasisBitsInputPtr);
    518516
    519517    //The carry q array.
     
    531529        StructTy_struct_Output->setBody(StructTy_struct_Output_fields, /*isPacked=*/false);
    532530    }
    533     mStruct_Output_Ptr1 = PointerType::get(StructTy_struct_Output, 0);
     531    mOutputPtr = PointerType::get(StructTy_struct_Output, 0);
    534532
    535533    //The &output parameter.
    536     FuncTy_0_args.push_back(mStruct_Output_Ptr1);
     534    FuncTy_0_args.push_back(mOutputPtr);
    537535
    538536    mFuncTy_0 = FunctionType::get(
     
    632630
    633631void LLVM_Generator::DeclareCallFunctions(const ExpressionList & stmts) {
    634     for (PabloE * stmt : stmts) {
    635         if (const Assign * an = dyn_cast<const Assign>(stmt))
    636         {
     632    for (const PabloE * stmt : stmts) {
     633        if (const Assign * an = dyn_cast<const Assign>(stmt)) {
    637634            DeclareCallFunctions(an->getExpr());
    638635        }
    639         else if (If * ifstmt = dyn_cast<If>(stmt))
    640         {
     636        else if (const If * ifstmt = dyn_cast<const If>(stmt)) {
    641637            DeclareCallFunctions(ifstmt->getExpr());
    642638            DeclareCallFunctions(ifstmt->getPSList());
    643639        }
    644         else if (While * whl = dyn_cast<While>(stmt))
    645         {
     640        else if (const While * whl = dyn_cast<const While>(stmt)) {
    646641            DeclareCallFunctions(whl->getCondition());
    647642            DeclareCallFunctions(whl->getPSList());
     
    657652        if (mMarkerMap.find(callee) == mMarkerMap.end())
    658653        {
    659             Value* func_get_unicode_category = mMod->getOrInsertFunction(callee, mXi64Vect, mStruct_Basis_Bits_Ptr1, NULL);
     654            Value* func_get_unicode_category = mMod->getOrInsertFunction(callee, mXi64Vect, mBasisBitsInputPtr, NULL);
    660655            void* addr;
    661656            if (pablo_call->getCallee() == "Ps")
     
    826821}
    827822
    828 void LLVM_Generator::StoreBitBlockMarkerPtr(std::string name, int index)
    829 {
    830     IRBuilder<> b(mBasicBlock);
    831 
    832     Value* basis_bits_struct = b.CreateLoad(mPtr_basis_bits_addr);
    833     Value* struct_indices[] = {b.getInt64(0), b.getInt32(index)};
    834     Value* basis_bits_struct_GEP = b.CreateGEP(basis_bits_struct, struct_indices, name);
    835     mMarkerMap.insert(make_pair(name, basis_bits_struct_GEP));
    836 }
    837 
    838 Value* LLVM_Generator::GetMarker(std::string name)
     823Value* LLVM_Generator::GetMarker(const std::string & name)
    839824{
    840825    IRBuilder<> b(mBasicBlock);
     
    848833}
    849834
    850 void LLVM_Generator::SetReturnMarker(std::string marker, int output_idx)
     835void LLVM_Generator::SetReturnMarker(Value * marker, const unsigned output_idx)
    851836{
    852837    IRBuilder<> b(mBasicBlock);
    853 
    854     Value* marker_bitblock = b.CreateLoad(GetMarker(marker));
     838    Value* marker_bitblock = b.CreateLoad(marker);
    855839    Value* output_struct = b.CreateLoad(mPtr_output_addr);
    856840    Value* output_indices[] = {b.getInt64(0), b.getInt32(output_idx)};
    857     Value* output_struct_GEP = b.CreateGEP(output_struct, output_indices, "return" + marker);
    858     Value* store_marker = b.CreateStore(marker_bitblock, output_struct_GEP);
    859 }
    860 
    861 std::string LLVM_Generator::Generate_PabloStatements(const ExpressionList & stmts) {
    862     std::string retVal = "";
    863     for (auto it = stmts.begin(); it != stmts.end(); ++it) {
    864         retVal = Generate_PabloS(*it);
     841    Value* output_struct_GEP = b.CreateGEP(output_struct, output_indices);
     842    b.CreateStore(marker_bitblock, output_struct_GEP);
     843}
     844
     845
     846Value * LLVM_Generator::Generate_PabloStatements(const ExpressionList & stmts) {
     847    Value * retVal = nullptr;
     848    for (PabloE * statement : stmts) {
     849        retVal = Generate_PabloS(statement);
    865850    }
    866851    return retVal;
    867852}
    868853
    869 std::string LLVM_Generator::Generate_PabloS(PabloE *stmt)
     854Value * LLVM_Generator::Generate_PabloS(const PabloE *stmt)
    870855{
    871     std::string retVal = "";
    872 
    873     if (Assign * assign = dyn_cast<Assign>(stmt))
     856    Value * retVal = nullptr;
     857
     858    if (const Assign * assign = dyn_cast<const Assign>(stmt))
    874859    {
    875860        IRBuilder<> b(mBasicBlock);
    876861
    877         b.CreateStore(Generate_PabloE(assign->getExpr()), GetMarker(assign->getName()));
    878 
    879         retVal = assign->getName();
    880     }
    881     else if (If * ifstmt = dyn_cast<If>(stmt))
    882     {
    883         BasicBlock*  ifEntryBlock = mBasicBlock;
    884         BasicBlock*  ifBodyBlock = BasicBlock::Create(mMod->getContext(), "if.body",mFunc_process_block, 0);
    885         BasicBlock*  ifEndBlock = BasicBlock::Create(mMod->getContext(), "if.end",mFunc_process_block, 0);
     862        Value * marker = GetMarker(assign->getName());
     863
     864        b.CreateStore(Generate_PabloE(assign->getExpr()), marker);
     865
     866        retVal = marker;
     867    }
     868    else if (const If * ifstmt = dyn_cast<const If>(stmt))
     869    {
     870        BasicBlock * ifEntryBlock = mBasicBlock;
     871        BasicBlock * ifBodyBlock = BasicBlock::Create(mMod->getContext(), "if.body",mFunc_process_block, 0);
     872        BasicBlock * ifEndBlock = BasicBlock::Create(mMod->getContext(), "if.end",mFunc_process_block, 0);
    886873
    887874        int if_start_idx = mCarryQueueIdx;
     
    894881        IRBuilder<> b_ifbody(ifBodyBlock);
    895882        mBasicBlock = ifBodyBlock;
    896         std::string returnMarker = Generate_PabloStatements(ifstmt->getPSList());
     883
     884        Value *  returnMarker = Generate_PabloStatements(ifstmt->getPSList());
     885
    897886        int if_end_idx = mCarryQueueIdx;
    898 
    899887        if (if_start_idx < if_end_idx + 1) {
    900888            // Have at least two internal carries.   Accumulate and store.
     
    928916        retVal = returnMarker;
    929917    }
    930     else if (While* whl = dyn_cast<While>(stmt))
     918    else if (const While* whl = dyn_cast<const While>(stmt))
    931919    {
    932920        int idx = mCarryQueueIdx;
    933921
    934922        //With this call to the while body we will account for all of the carry in values.
    935         std::string returnMarker = Generate_PabloStatements(whl->getPSList());
     923        Value * returnMarker = Generate_PabloStatements(whl->getPSList());
    936924
    937925        BasicBlock*  whileCondBlock = BasicBlock::Create(mMod->getContext(), "while.cond", mFunc_process_block, 0);
     
    956944        IRBuilder<> b_wb1(mBasicBlock);
    957945        //Create and initialize a new carry queue.
    958         Value* ptr_while_carry_q = b_wb1.CreateAlloca(mXi64Vect, b_wb1.getInt64(mCarryQueueSize - idx));
    959         for (int i=0; i < (mCarryQueueSize - idx); i++)
    960         {
     946        Value * ptr_while_carry_q = b_wb1.CreateAlloca(mXi64Vect, b_wb1.getInt64(mCarryQueueSize - idx));
     947        for (int i=0; i < (mCarryQueueSize - idx); i++) {
    961948            genCarryOutStore(mConst_Aggregate_Xi64_0, ptr_while_carry_q, i);
    962949        }
     
    987974}
    988975
    989 Value* LLVM_Generator::Generate_PabloE(PabloE * expr)
     976Value* LLVM_Generator::Generate_PabloE(const PabloE * expr)
    990977{
    991978    Value* retVal = 0;
    992 
    993     if (All* all = dyn_cast<All>(expr))
    994     {
    995         IRBuilder<> b(mBasicBlock);
     979    IRBuilder<> b(mBasicBlock);
     980    if (const All* all = dyn_cast<All>(expr))
     981    {
    996982        Value* ptr_all = b.CreateAlloca(mXi64Vect);
    997983        b.CreateStore((all->getValue() == 0 ? mConst_Aggregate_Xi64_0 : mConst_Aggregate_Xi64_neg1), ptr_all);
    998         Value* all_value = b.CreateLoad(ptr_all);
    999         retVal = all_value;
    1000     }
    1001     else if (Call* call = dyn_cast<Call>(expr))
    1002     {
    1003         IRBuilder<> b(mBasicBlock);
    1004 
     984        retVal = b.CreateLoad(ptr_all);
     985    }
     986    else if (const Call* call = dyn_cast<Call>(expr))
     987    {
    1005988        //Call the callee once and store the result in the marker map.
    1006         if (mMarkerMap.find(call->getCallee()) == mMarkerMap.end())
    1007         {
     989        auto f = mMarkerMap.find(call->getCallee());
     990        if (f == mMarkerMap.end()) {
    1008991            std::map<std::string, Value*>::iterator itFuncGet = mMarkerMap.find("wrapped_get_category_" + call->getCallee());
    1009             Value* basis_bits_struct = b.CreateLoad(mPtr_basis_bits_addr);
     992            Value* basis_bits_struct = b.CreateLoad(mBasisBitsAddr);
    1010993            Value* unicode_category = b.CreateCall(itFuncGet->second, basis_bits_struct);
    1011994            Value* ptr = b.CreateAlloca(mXi64Vect);
    1012             Value* void_1 = b.CreateStore(unicode_category, ptr);
    1013 
    1014             mMarkerMap.insert(make_pair(call->getCallee(), ptr));
     995            b.CreateStore(unicode_category, ptr);
     996            f = mMarkerMap.insert(make_pair(call->getCallee(), ptr)).first;
    1015997        }
    1016         std::map<std::string, Value*>::iterator itGet = mMarkerMap.find(call->getCallee());
    1017         Value * var_value = b.CreateLoad(itGet->second);
    1018 
    1019 
    1020         retVal = var_value;
    1021     }
    1022     else if (Var * var = dyn_cast<Var>(expr))
    1023     {
    1024         IRBuilder<> b(mBasicBlock);
    1025 
    1026         Value* var_value = b.CreateLoad(GetMarker(var->getName()), false, var->getName());
    1027 
    1028         retVal = var_value;
    1029     }
    1030     else if (And * pablo_and = dyn_cast<And>(expr))
    1031     {
    1032         IRBuilder<> b(mBasicBlock);
    1033 
    1034         Value* and_result = b.CreateAnd(Generate_PabloE(pablo_and->getExpr1()), Generate_PabloE(pablo_and->getExpr2()), "and_inst");
    1035 
    1036         retVal = and_result;
    1037     }
    1038     else if (Or * pablo_or = dyn_cast<Or>(expr))
    1039     {
    1040         IRBuilder<> b(mBasicBlock);
    1041 
    1042         Value* or_result = b.CreateOr(Generate_PabloE(pablo_or->getExpr1()), Generate_PabloE(pablo_or->getExpr2()), "or_inst");
    1043 
    1044         retVal = or_result;
    1045     }
    1046     else if (Sel * pablo_sel = dyn_cast<Sel>(expr))
    1047     {
    1048         IRBuilder<>b(mBasicBlock);
     998        retVal = b.CreateLoad(f->second);
     999    }
     1000    else if (const Var * var = dyn_cast<Var>(expr))
     1001    {
     1002        retVal = b.CreateLoad(GetMarker(var->getName()), false, var->getName());
     1003    }
     1004    else if (const And * pablo_and = dyn_cast<And>(expr))
     1005    {
     1006        retVal = b.CreateAnd(Generate_PabloE(pablo_and->getExpr1()), Generate_PabloE(pablo_and->getExpr2()), "and");
     1007    }
     1008    else if (const Or * pablo_or = dyn_cast<Or>(expr))
     1009    {
     1010        retVal = b.CreateOr(Generate_PabloE(pablo_or->getExpr1()), Generate_PabloE(pablo_or->getExpr2()), "or");
     1011    }
     1012    else if (const Sel * pablo_sel = dyn_cast<Sel>(expr))
     1013    {
    10491014        Value* ifMask = Generate_PabloE(pablo_sel->getCondition());
    10501015        Value* and_if_true_result = b.CreateAnd(ifMask, Generate_PabloE(pablo_sel->getTrueExpr()));
    10511016        Value* and_if_false_result = b.CreateAnd(genNot(ifMask), Generate_PabloE(pablo_sel->getFalseExpr()));
    1052         Value* or_result = b.CreateOr(and_if_true_result, and_if_false_result);
    1053 
    1054         retVal = or_result;
    1055     }
    1056     else if (Not * pablo_not = dyn_cast<Not>(expr))
    1057     {
    1058         IRBuilder<> b(mBasicBlock);
    1059 
     1017        retVal = b.CreateOr(and_if_true_result, and_if_false_result);
     1018    }
     1019    else if (const Not * pablo_not = dyn_cast<Not>(expr))
     1020    {
    10601021        Value* expr_value = Generate_PabloE(pablo_not->getExpr());
    1061         Value* xor_rslt = b.CreateXor(expr_value, mConst_Aggregate_Xi64_neg1, "xor_inst");
    1062 
    1063         retVal = xor_rslt;
    1064     }
    1065     else if (CharClass * cc = dyn_cast<CharClass>(expr))
    1066     {
    1067         IRBuilder<> b(mBasicBlock);
    1068 
    1069         Value* character_class = b.CreateLoad(GetMarker(cc->getCharClass()));
    1070 
    1071         retVal = character_class;
    1072     }
    1073     else if (Advance * adv = dyn_cast<Advance>(expr))
    1074     {
    1075         IRBuilder<> b(mBasicBlock);
     1022        retVal = b.CreateXor(expr_value, mConst_Aggregate_Xi64_neg1, "not");
     1023    }
     1024    else if (const CharClass * cc = dyn_cast<CharClass>(expr))
     1025    {
     1026        retVal = b.CreateLoad(GetMarker(cc->getCharClass()));
     1027    }
     1028    else if (const Advance * adv = dyn_cast<Advance>(expr))
     1029    {
    10761030        Value* strm_value = Generate_PabloE(adv->getExpr());
    10771031        retVal = genAdvanceWithCarry(strm_value);
    10781032    }
    1079     else if (MatchStar * mstar = dyn_cast<MatchStar>(expr))
    1080     {
    1081         IRBuilder<> b(mBasicBlock);
    1082         Value* strm_value = Generate_PabloE(mstar->getExpr1());
    1083         Value* cc_value = Generate_PabloE(mstar->getExpr2());
    1084         retVal = genMatchStar(strm_value, cc_value);
    1085     }
    1086     else if (ScanThru * sthru = dyn_cast<ScanThru>(expr))
    1087     {
    1088         IRBuilder<> b(mBasicBlock);
    1089         Value* strm_value = Generate_PabloE(sthru->getScanFrom());
    1090         Value* scanthru_value = Generate_PabloE(sthru->getScanThru());
    1091         retVal = genScanThru(strm_value, scanthru_value);
    1092     }
    1093 
     1033    else if (const MatchStar * mstar = dyn_cast<MatchStar>(expr))
     1034    {
     1035        Value* marker_expr = Generate_PabloE(mstar->getExpr1());
     1036        Value* cc_expr = Generate_PabloE(mstar->getExpr2());
     1037        Value* marker_and_cc = b.CreateAnd(marker_expr, cc_expr);
     1038        retVal = b.CreateOr(b.CreateXor(genAddWithCarry(marker_and_cc, cc_expr), cc_expr), marker_expr, "matchstar");
     1039    }
     1040    else if (const ScanThru * sthru = dyn_cast<ScanThru>(expr))
     1041    {
     1042        Value* marker_expr = Generate_PabloE(sthru->getScanFrom());
     1043        Value* cc_expr = Generate_PabloE(sthru->getScanThru());
     1044        retVal = b.CreateAnd(genAddWithCarry(marker_expr, cc_expr), genNot(cc_expr), "scanthru_rslt");
     1045    }
    10941046    return retVal;
    1095 }
    1096 
    1097 
    1098 Value* LLVM_Generator::genMatchStar(Value* marker_expr, Value* cc_expr) {
    1099     IRBuilder<> b(mBasicBlock);
    1100     Value* marker_and_cc = b.CreateAnd(marker_expr, cc_expr);
    1101     return b.CreateOr(b.CreateXor(genAddWithCarry(marker_and_cc, cc_expr), cc_expr), marker_expr, "matchstar_rslt");
    1102 }
    1103 
    1104 Value* LLVM_Generator::genScanThru(Value* marker_expr, Value* cc_expr) {
    1105     IRBuilder<> b(mBasicBlock);
    1106     return b.CreateAnd(genAddWithCarry(marker_expr, cc_expr), genNot(cc_expr), "scanthru_rslt");
    11071047}
    11081048
  • icGREP/icgrep-devel/icgrep/llvm_gen.h

    r4216 r4217  
    9191    LLVM_Generator(std::map<std::string, std::string> name_map, std::string basis_pattern, int bits);
    9292    ~LLVM_Generator();
    93     LLVM_Gen_RetVal Generate_LLVMIR(const CodeGenState &cg_state);
     93    LLVM_Gen_RetVal Generate_LLVMIR(const CodeGenState & cg_state);
    9494private:
    9595    void MakeLLVMModule();
    9696    void DefineTypes();
    9797    void DeclareFunctions();
    98 
    9998    void DeclareCallFunctions(const ExpressionList & stmts);
    10099    void DeclareCallFunctions(const PabloE * expr);
     100    void LoadBitBlocksFromStaticExtern();
     101    void SetReturnMarker(Value * marker, const unsigned output_idx);
    101102
    102     void StoreBitBlockMarkerPtr(std::string name, int index);
    103     void LoadBitBlocksFromStaticExtern();
    104     void SetReturnMarker(std::string marker, int output_idx);
    105     Value* GetMarker(std::string name);
    106     std::string Generate_PabloStatements(const ExpressionList & stmts);
    107     std::string Generate_PabloS(PabloE * stmt);
    108     Value* Generate_PabloE(PabloE *expr);
    109     Value* genMatchStar(Value* marker_expr, Value* cc_expr);
    110     Value* genScanThru(Value* marker_expr, Value* cc_expr);
     103    Value * GetMarker(const std::string & name);
     104
     105    Value * Generate_PabloStatements(const ExpressionList & stmts);
     106    Value * Generate_PabloS(const PabloE * stmt);
     107
     108    Value* Generate_PabloE(const PabloE * expr);
    111109    Value* genCarryInLoad(Value* ptr_carry_q, int carryq_idx);
    112110    Value* genCarryOutStore(Value* carryout, Value* ptr_carry_q, int carryq_idx);
     
    122120    int         mBits;
    123121    std::map<std::string, std::string> m_name_map;
    124     std::string mBasis_Pattern;
     122    std::string mBasisBitPattern;
    125123
    126124    Module*          mMod;
     
    134132    VectorType* mXi128Vect;
    135133
    136     PointerType* mStruct_Basis_Bits_Ptr1;
    137     PointerType* mStruct_Output_Ptr1;
     134    PointerType* mBasisBitsInputPtr;
     135    PointerType* mOutputPtr;
    138136
    139137    std::map<std::string, Value*> mMarkerMap;
     
    157155    Value*     mFunc_get_unicode_category_Nd;
    158156
    159     AllocaInst*  mPtr_basis_bits_addr;
     157    AllocaInst*  mBasisBitsAddr;
    160158    AllocaInst*  mPtr_carry_q_addr;
    161159    AllocaInst*  mPtr_output_addr;
  • icGREP/icgrep-devel/icgrep/pablo/codegenstate.h

    r4215 r4217  
    4949    CodeGenState(CodeGenState & cg)
    5050    : mSymbolGenerator(cg.mSymbolGenerator)
    51     , mAll(cg.mAll)    // inherit the original "All" variables for simplicity
     51    , mAll(cg.mAll) // inherit the original "All" variables for simplicity
    5252    , mUnary(&(cg.mUnary), this)
    5353    , mBinary(&(cg.mBinary), this)
     
    9191    PabloE * createSel(PabloE * condition, PabloE * trueExpr, PabloE * falseExpr);
    9292
    93     inline If * createIf(PabloE * condition, ExpressionList statements) {
    94         return new If(condition, std::move(statements));
     93    inline If * createIf(PabloE * condition, CodeGenState && body) {
     94        return new If(condition, std::move(body.mExpressions));
    9595    }
    9696
    97     inline While * createWhile(PabloE * cond, ExpressionList statements) {
    98         return new While(cond, std::move(statements));
     97    inline While * createWhile(PabloE * cond, CodeGenState && body) {
     98        return new While(cond, std::move(body.mExpressions));
    9999    }
    100100
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r4215 r4217  
    7272        PabloE * u8scope42 = cg.createAdvance(u8pfx4);
    7373        PabloE * u8scope43 = cg.createAdvance(u8scope42);
     74        #ifdef USE_IF_FOR_NONFINAL
     75        CodeGenState it(cg);
     76        it.createAssign(gs_nonfinal, it.createOr(it.createOr(u8pfx, u8scope32), it.createOr(u8scope42, u8scope43)));
     77        cg.createIf(u8pfx, std::move(it));
     78        #else
    7479        PabloE * assign_non_final = cg.createAssign(gs_nonfinal, cg.createOr(cg.createOr(u8pfx, u8scope32), cg.createOr(u8scope42, u8scope43)));
    75         #ifdef USE_IF_FOR_NONFINAL
    76         If::List body;
    77         body.push_back(assign_non_final);
    78         mCG.push_back(cg.createIf(u8pfx, body));
    79         #else
    8080        cg.push_back(assign_non_final);
    8181        #endif
     
    224224
    225225        wt.push_back(target);
    226         cg.push_back(cg.createWhile(cg.createVar(while_test), wt.expressions()));
     226        cg.push_back(cg.createWhile(cg.createVar(while_test), std::move(wt)));
    227227    }   
    228228    return target;
Note: See TracChangeset for help on using the changeset viewer.