static_cast<Instruction::Code>(kMirOpCheck);
// Associate the two halves
insn->meta.throw_insn = new_insn;
- AppendMIR(new_block, new_insn);
+ new_block->AppendMIR(new_insn);
return new_block;
}
}
if (width == 1) {
// It is a simple nop - treat normally.
- AppendMIR(cur_block, insn);
+ cur_block->AppendMIR(insn);
} else {
DCHECK(cur_block->fall_through == NullBasicBlockId);
DCHECK(cur_block->taken == NullBasicBlockId);
flags &= ~Instruction::kContinue;
}
} else {
- AppendMIR(cur_block, insn);
+ cur_block->AppendMIR(insn);
}
// Associate the starting dex_pc for this opcode with its containing basic block.
}
/* Insert an MIR instruction to the end of a basic block */
-void MIRGraph::AppendMIR(BasicBlock* bb, MIR* mir) {
- if (bb->first_mir_insn == NULL) {
- DCHECK(bb->last_mir_insn == NULL);
- bb->last_mir_insn = bb->first_mir_insn = mir;
- mir->next = NULL;
+void BasicBlock::AppendMIR(MIR* mir) {
+ if (first_mir_insn == nullptr) {
+ DCHECK(last_mir_insn == nullptr);
+ last_mir_insn = first_mir_insn = mir;
+ mir->next = nullptr;
} else {
- bb->last_mir_insn->next = mir;
- mir->next = NULL;
- bb->last_mir_insn = mir;
+ last_mir_insn->next = mir;
+ mir->next = nullptr;
+ last_mir_insn = mir;
}
}
/* Insert an MIR instruction to the head of a basic block */
-void MIRGraph::PrependMIR(BasicBlock* bb, MIR* mir) {
- if (bb->first_mir_insn == NULL) {
- DCHECK(bb->last_mir_insn == NULL);
- bb->last_mir_insn = bb->first_mir_insn = mir;
- mir->next = NULL;
+void BasicBlock::PrependMIR(MIR* mir) {
+ if (first_mir_insn == nullptr) {
+ DCHECK(last_mir_insn == nullptr);
+ last_mir_insn = first_mir_insn = mir;
+ mir->next = nullptr;
} else {
- mir->next = bb->first_mir_insn;
- bb->first_mir_insn = mir;
+ mir->next = first_mir_insn;
+ first_mir_insn = mir;
}
}
/* Insert a MIR instruction after the specified MIR */
-void MIRGraph::InsertMIRAfter(BasicBlock* bb, MIR* current_mir, MIR* new_mir) {
+void BasicBlock::InsertMIRAfter(MIR* current_mir, MIR* new_mir) {
new_mir->next = current_mir->next;
current_mir->next = new_mir;
- if (bb->last_mir_insn == current_mir) {
+ if (last_mir_insn == current_mir) {
/* Is the last MIR in the block */
- bb->last_mir_insn = new_mir;
+ last_mir_insn = new_mir;
}
}
-MIR* MIRGraph::GetNextUnconditionalMir(BasicBlock* bb, MIR* current) {
+MIR* BasicBlock::GetNextUnconditionalMir(MIRGraph* mir_graph, MIR* current) {
MIR* next_mir = nullptr;
if (current != nullptr) {
if (next_mir == nullptr) {
// Only look for next MIR that follows unconditionally.
- if ((bb->taken == NullBasicBlockId) && (bb->fall_through != NullBasicBlockId)) {
- next_mir = GetBasicBlock(bb->fall_through)->first_mir_insn;
+ if ((taken == NullBasicBlockId) && (fall_through != NullBasicBlockId)) {
+ next_mir = mir_graph->GetBasicBlock(fall_through)->first_mir_insn;
}
}
ArenaBitVector* dom_frontier; // Dominance frontier.
GrowableArray<BasicBlockId>* predecessors;
GrowableArray<SuccessorBlockInfo*>* successor_blocks;
+
+ void AppendMIR(MIR* mir);
+ void PrependMIR(MIR* mir);
+ void InsertMIRAfter(MIR* current_mir, MIR* new_mir);
+
+ /**
+ * @brief Used to obtain the next MIR that follows unconditionally.
+ * @details The implementation does not guarantee that a MIR does not
+ * follow even if this method returns nullptr.
+ * @param mir_graph the MIRGraph.
+ * @param current The MIR for which to find an unconditional follower.
+ * @return Returns the following MIR if one can be found.
+ */
+ MIR* GetNextUnconditionalMir(MIRGraph* mir_graph, MIR* current);
};
/*
bool SetHigh(int index, bool is_high);
bool SetHigh(int index);
- void AppendMIR(BasicBlock* bb, MIR* mir);
- void PrependMIR(BasicBlock* bb, MIR* mir);
- void InsertMIRAfter(BasicBlock* bb, MIR* current_mir, MIR* new_mir);
-
- /**
- * @brief Used to obtain the next MIR that follows unconditionally.
- * @details The implementation does not guarantee that a MIR does not
- * follow even if this method returns nullptr.
- * @param bb The basic block of "current" MIR.
- * @param current The MIR for which to find an unconditional follower.
- * @return Returns the following MIR if one can be found.
- */
- MIR* GetNextUnconditionalMir(BasicBlock* bb, MIR* current);
-
char* GetDalvikDisassembly(const MIR* mir);
void ReplaceSpecialChars(std::string& str);
std::string GetSSAName(int ssa_reg);
mir->dalvikInsn.opcode = def->opcode;
ASSERT_LT(def->bbid, cu_.mir_graph->block_list_.Size());
BasicBlock* bb = cu_.mir_graph->block_list_.Get(def->bbid);
- cu_.mir_graph->AppendMIR(bb, mir);
+ bb->AppendMIR(mir);
if (def->opcode >= Instruction::SGET && def->opcode <= Instruction::SPUT_SHORT) {
ASSERT_LT(def->field_or_method_info, cu_.mir_graph->sfield_lowering_infos_.Size());
mir->meta.sfield_lowering_info = def->field_or_method_info;
insn->dalvikInsn.opcode = Instruction::CONST;
insn->dalvikInsn.vA = move_result->dalvikInsn.vA;
insn->dalvikInsn.vB = method.d.data;
- mir_graph->InsertMIRAfter(bb, move_result, insn);
+ bb->InsertMIRAfter(move_result, insn);
return true;
}
insn->dalvikInsn.opcode = opcode;
insn->dalvikInsn.vA = move_result->dalvikInsn.vA;
insn->dalvikInsn.vB = arg;
- mir_graph->InsertMIRAfter(bb, move_result, insn);
+ bb->InsertMIRAfter(move_result, insn);
return true;
}
DCHECK_EQ(data.field_offset, mir_graph->GetIFieldLoweringInfo(insn).FieldOffset().Uint32Value());
DCHECK_EQ(data.is_volatile, mir_graph->GetIFieldLoweringInfo(insn).IsVolatile() ? 1u : 0u);
- mir_graph->InsertMIRAfter(bb, move_result, insn);
+ bb->InsertMIRAfter(move_result, insn);
return true;
}
DCHECK_EQ(data.field_offset, mir_graph->GetIFieldLoweringInfo(insn).FieldOffset().Uint32Value());
DCHECK_EQ(data.is_volatile, mir_graph->GetIFieldLoweringInfo(insn).IsVolatile() ? 1u : 0u);
- mir_graph->InsertMIRAfter(bb, invoke, insn);
+ bb->InsertMIRAfter(invoke, insn);
return true;
}
RegLocation rl_dest = GetReturn(cu_->shorty[0] == 'F');
GenPrintLabel(mir);
LoadConstant(rl_dest.reg.GetReg(), static_cast<int>(special.d.data));
- return_mir = mir_graph_->GetNextUnconditionalMir(bb, mir);
+ return_mir = bb->GetNextUnconditionalMir(mir_graph_, mir);
break;
}
case kInlineOpReturnArg:
break;
case kInlineOpIGet:
successful = GenSpecialIGet(mir, special);
- return_mir = mir_graph_->GetNextUnconditionalMir(bb, mir);
+ return_mir = bb->GetNextUnconditionalMir(mir_graph_, mir);
break;
case kInlineOpIPut:
successful = GenSpecialIPut(mir, special);
- return_mir = mir_graph_->GetNextUnconditionalMir(bb, mir);
+ return_mir = bb->GetNextUnconditionalMir(mir_graph_, mir);
break;
default:
break;
phi->dalvikInsn.vA = dalvik_reg;
phi->offset = phi_bb->start_offset;
phi->m_unit_index = 0; // Arbitrarily assign all Phi nodes to outermost method.
- PrependMIR(phi_bb, phi);
+ phi_bb->PrependMIR(phi);
}
}
}