本文整理汇总了C++中IRBuilder::CreatePHI方法的典型用法代码示例。如果您正苦于以下问题:C++ IRBuilder::CreatePHI方法的具体用法?C++ IRBuilder::CreatePHI怎么用?C++ IRBuilder::CreatePHI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRBuilder
的用法示例。
在下文中一共展示了IRBuilder::CreatePHI方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printf
void
code_emitter::emit_phis (statement_t *stmt, BasicBlock *left_bb, BasicBlock *right_bb,
map<rhs_t*, Value*> &rhs_map, int slice_flag)
{
for (; stmt != NULL; stmt = stmt->next)
{
if (!must_emit_stmt(stmt, slice_flag))
continue;
switch (stmt->kind)
{
case STMT_NIL :
g_assert(slice_flag == SLICE_IGNORE);
break;
case STMT_PHI_ASSIGN :
{
Value *left = NULL;
Value *right = NULL;
int compvar_type = stmt->v.assign.lhs->compvar->type;
const Type *type = llvm_type_for_type(module, compvar_type);
#ifdef DEBUG_OUTPUT
compiler_print_assign_statement(stmt);
printf("\n");
#endif
if (left_bb)
{
left = rhs_map[stmt->v.assign.rhs];
g_assert(left != NULL);
#ifdef DEBUG_OUTPUT
printf("left:\n");
left->dump();
#endif
}
if (right_bb)
{
right = rhs_map[stmt->v.assign.rhs2];
g_assert(right != NULL);
#ifdef DEBUG_OUTPUT
printf("right:\n");
right->dump();
#endif
}
PHINode *phi;
if (left_bb)
{
phi = builder->CreatePHI(type);
phi->addIncoming(promote(left, compvar_type), left_bb);
set_value(stmt->v.assign.lhs, phi, false);
phi_map[stmt->v.assign.lhs] = phi;
}
else
{
g_assert(phi_map.find(stmt->v.assign.lhs) != phi_map.end());
phi = phi_map[stmt->v.assign.lhs];
}
#ifdef DEBUG_OUTPUT
printf("phi:\n");
phi->dump();
#endif
if (right_bb)
phi->addIncoming(promote(right, compvar_type), right_bb);
}
break;
default:
g_assert_not_reached();
}
}
commit_set_const_values();
}