// SelectionBlock
///////////////////////////////////////////////////////////////////////////
- SelectionBlock::SelectionBlock(const ir::BasicBlock *bb) : bb(bb), endifLabel( (ir::LabelIndex) 0){}
+ SelectionBlock::SelectionBlock(const ir::BasicBlock *bb) : bb(bb), isLargeBlock(false), endifLabel( (ir::LabelIndex) 0){}
void SelectionBlock::append(ir::Register reg) { tmp.push_back(reg); }
this->curr.predicate = GEN_PREDICATE_NORMAL;
this->IF(GenRegister::immd(0), jip, jip);
this->pop();
+ this->block->isLargeBlock = true;
}
if (needEndif) {
vector<GenRegInterval> intervals;
/*! All the boolean register intervals on the corresponding BB*/
typedef map<ir::Register, GenRegInterval> RegIntervalMap;
+ set<SelectionBlock *> flag0ReservedBlocks;
map<SelectionBlock *, RegIntervalMap *> boolIntervalsMap;
/*! Intervals sorting based on starting point positions */
vector<GenRegInterval*> starting;
map<ir::Register, uint32_t> allocatedFlags;
map<const GenRegInterval*, uint32_t> allocatedFlagIntervals;
- const uint32_t flagNum = 3;
+ const uint32_t flagNum = flag0ReservedBlocks.contains(&block) ? 2 : 3;
uint32_t freeFlags[] = {2, 3, 0};
uint32_t freeNum = flagNum;
if (boolIntervalsMap.find(&block) == boolIntervalsMap.end())
// Update the intervals of each used register. Note that we do not
// register allocate R0, so we skip all sub-registers in r0
RegIntervalMap *boolsMap = new RegIntervalMap;
+ if (block.isLargeBlock)
+ flag0ReservedBlocks.insert(&block);
for (auto &insn : block.insnList) {
const uint32_t srcNum = insn.srcNum, dstNum = insn.dstNum;
insn.ID = insnID;
// is out-of the if/endif region, so we have to borrow the f0
// to get correct bits for all channels.
boolsMap->find(reg)->second.minID = 0;
+ if (flag0ReservedBlocks.contains(&block))
+ flag0ReservedBlocks.erase(&block);
}
+ } else {
+ // Make sure that instruction selection stage didn't use physiacl flags incorrectly.
+ GBE_ASSERT ((insn.opcode == SEL_OP_LABEL ||
+ insn.opcode == SEL_OP_IF ||
+ insn.opcode == SEL_OP_JMPI ||
+ insn.state.predicate == GEN_PREDICATE_NONE ||
+ (block.hasBarrier && insn.opcode == SEL_OP_MOV) ||
+ (insn.state.flag == 0 && insn.state.subFlag == 1)));
}
lastID = insnID;
insnID++;