Changeset 4086


Ignore:
Timestamp:
Aug 28, 2014, 8:26:35 AM (5 years ago)
Author:
cameron
Message:

Support for Pablo if-statements; use for utf-8 scope streams

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

Legend:

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

    r4085 r4086  
    839839        retVal = assign->getM();
    840840    }
     841    else if (If* ifstmt = dynamic_cast<If*>(stmt))
     842    {
     843        BasicBlock*  ifEntryBlock = mBasicBlock;
     844        BasicBlock*  ifBodyBlock = BasicBlock::Create(mMod->getContext(), "if.body",mFunc_process_block, 0);
     845        BasicBlock*  ifEndBlock = BasicBlock::Create(mMod->getContext(), "if.end",mFunc_process_block, 0);
     846       
     847        int if_start_idx = mCarryQueueIdx;
     848       
     849        Value* if_test_value = Generate_PabloE(ifstmt->getExpr());
     850
     851        /* Generate the statements into the if body block, and also determine the
     852           final carry index.  */
     853       
     854        IRBuilder<> b_ifbody(ifBodyBlock);
     855        mBasicBlock = ifBodyBlock;
     856        std::string returnMarker = Generate_PabloStatements(ifstmt->getPSList());
     857        int if_end_idx = mCarryQueueIdx;
     858       
     859        if (if_start_idx < if_end_idx + 1) {
     860            // Have at least two internal carries.   Accumulate and store.
     861            int if_accum_idx = mCarryQueueIdx;
     862            mCarryQueueIdx++;
     863           
     864            Value* if_carry_accum_value = genCarryInLoad(mptr_carry_q, if_start_idx);
     865           
     866            for (int c = if_start_idx+1; c < if_end_idx; c++)
     867            {
     868                Value* carryq_value = genCarryInLoad(mptr_carry_q, c);
     869                if_carry_accum_value = b_ifbody.CreateOr(carryq_value, if_carry_accum_value);
     870            }
     871            Value* void_1 = genCarryOutStore(if_carry_accum_value, mptr_carry_q, if_accum_idx);
     872           
     873        }
     874        b_ifbody.CreateBr(ifEndBlock);
     875       
     876        IRBuilder<> b_entry(ifEntryBlock);
     877        mBasicBlock = ifEntryBlock;
     878        if (if_start_idx < if_end_idx) {
     879            // Have at least one internal carry.
     880            int if_accum_idx = mCarryQueueIdx - 1;
     881            Value* last_if_pending_carries = genCarryInLoad(mptr_carry_q, if_accum_idx);
     882            if_test_value = b_entry.CreateOr(if_test_value, last_if_pending_carries);
     883        }
     884        b_entry.CreateCondBr(genBitBlockAny(if_test_value), ifEndBlock, ifBodyBlock);
     885       
     886        mBasicBlock = ifEndBlock;
     887
     888        retVal = returnMarker;
     889    }
    841890    else if (While* whl = dynamic_cast<While*>(stmt))
    842891    {
  • icGREP/icgrep-devel/icgrep/llvm_gen_helper.cpp

    r3955 r4086  
    2929    {
    3030        retVal = CarryCount_PabloE(sm->getExpr());
     31    }
     32    else if (If* ifstmt = dynamic_cast<If*>(stmt)) {
     33        retVal = CarryCount_PabloE(ifstmt->getExpr());
     34        retVal += CarryCount_PabloStatements(ifstmt->getPSList());
     35        // If there is more than one internal carry, we create a stored
     36        // accumulator value that Ors together all the carries, so add 1
     37        // to the carry count.
     38        if (retVal > 1) retVal++;
    3139    }
    3240    else if (While* whl = dynamic_cast<While*>(stmt))
  • icGREP/icgrep-devel/icgrep/pbix_compiler.cpp

    r4000 r4086  
    8686        std::string gs_nonfinal = symgen.gensym("internal.nonfinal");
    8787        m_name_map.insert(make_pair("internal.nonfinal", gs_nonfinal));
     88        cg_state.stmtsl.push_back(new Assign(gs_nonfinal, new All(0)));
    8889        PabloE * u8scope32 = new Advance(u8pfx3);
    8990        PabloE * u8scope42 = new Advance(u8pfx4);
    9091        PabloE * u8scope43 = new Advance(u8scope42);
    91      
    92         cg_state.stmtsl.push_back(new Assign(gs_nonfinal, new Or(new Or(u8pfx, u8scope32), new Or(u8scope42, u8scope43))));
     92        PabloS * assign_non_final = new Assign(gs_nonfinal, new Or(new Or(u8pfx, u8scope32), new Or(u8scope42, u8scope43)));
     93        std::list<PabloS *> * if_body = new std::list<PabloS *> ();
     94        if_body->push_back(assign_non_final);
     95        cg_state.stmtsl.push_back(new If(u8pfx, *if_body));
    9396#if 0
    9497        cg_state.stmtsl.push_back(new Assign(gs_nonfinal, new Or(new Or(new Or(new Or(new Or( new And(new Var(m_name_map.find("UTF8-Prefix3")->second),
  • icGREP/icgrep-devel/icgrep/printer_pablos.cpp

    r3984 r4086  
    6060        retVal = "Assign('" + an->getM() + "', " + ShowPabloE(an->getExpr()) + "),";
    6161    }
    62     if (While* whl = dynamic_cast<While*>(stmt))
     62    else if (If* ifstmt = dynamic_cast<If*>(stmt))
     63    {
     64        retVal = "If(" + ShowPabloE(ifstmt->getExpr()) + ", " + Print_PB_PabloStmts(ifstmt->getPSList(), retVal) + ")";
     65    }
     66    else if (While* whl = dynamic_cast<While*>(stmt))
    6367    {
    6468        retVal = "While(" + ShowPabloE(whl->getExpr()) + ", " + Print_PB_PabloStmts(whl->getPSList(), retVal) + ")";
    6569    }
    66 
     70    else retVal = "UNKNOWN_STATEMENT_TYPE!!!";
    6771    return retVal;
    6872}
     
    121125        retVal = "ScanThru (" + ShowPabloE(sthru->getScanFrom()) + ", " + ShowPabloE(sthru->getScanThru()) + ")";
    122126    }
     127    else retVal = "UNKNOWN_Pablo_EXPRESSION_TYPE!!!";
    123128
    124129    return retVal;
Note: See TracChangeset for help on using the changeset viewer.