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

File:
1 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    {
Note: See TracChangeset for help on using the changeset viewer.