本文整理汇总了C++中IRBuilder::CreateFCmpONE方法的典型用法代码示例。如果您正苦于以下问题:C++ IRBuilder::CreateFCmpONE方法的具体用法?C++ IRBuilder::CreateFCmpONE怎么用?C++ IRBuilder::CreateFCmpONE使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRBuilder
的用法示例。
在下文中一共展示了IRBuilder::CreateFCmpONE方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getValue
Value* NotEqualExpression::getValue() {
assert(leftExpression != NULL);
assert(rightExpression != NULL);
assert(leftExpression->getType() == rightExpression->getType());
IRBuilder<>* builder = codegen::getBuilder();
int c;
if(leftExpression->getType() != COLEXPRESSION) {
c = leftExpression->getType();
} else {
c = convertDTtoET(leftExpression->getDataType());
}
switch(c) {
case LONGVALUEEXPRESSION:
return builder->CreateICmpNE(leftExpression->getValue(), rightExpression->getValue());
case DOUBLEVALUEEXPRESSION:
return builder->CreateFCmpONE(leftExpression->getValue(), rightExpression->getValue());
case STRINGVALUEEXPRESSION:
case DATEVALUEEXPRESSION:
return codegen::stringCmp(leftExpression->getValue(), rightExpression->getValue(), NOTEQUALEXPRESSION);
default:
cout << "Unknown expression type!" << endl;
exit(-1);
}
return NULL;
}
示例2: if
void
code_emitter::emit_stmts (statement_t *stmt, unsigned 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_ASSIGN :
#ifdef DEBUG_OUTPUT
compiler_print_assign_statement(stmt);
printf("\n");
#endif
if (stmt->v.assign.rhs->kind == RHS_OP
&& stmt->v.assign.rhs->v.op.op->index == OP_OUTPUT_TUPLE)
builder->CreateRet(emit_primary(&stmt->v.assign.rhs->v.op.args[0]));
else
set_value(stmt->v.assign.lhs, emit_rhs(stmt->v.assign.rhs));
break;
case STMT_IF_COND :
{
Value *condition_number = emit_rhs(stmt->v.if_cond.condition);
Value *condition;
map<rhs_t*, Value*> rhs_map;
if (condition_number->getType() == Type::Int32Ty)
condition = builder->CreateICmpNE(condition_number, make_int_const(0));
else if (condition_number->getType() == Type::FloatTy)
condition = builder->CreateFCmpONE(condition_number, make_float_const(0.0));
else
g_assert_not_reached();
BasicBlock *then_bb = BasicBlock::Create("then", current_function);
BasicBlock *else_bb = BasicBlock::Create("else");
BasicBlock *merge_bb = BasicBlock::Create("ifcont");
builder->CreateCondBr(condition, then_bb, else_bb);
builder->SetInsertPoint(then_bb);
emit_stmts(stmt->v.if_cond.consequent, slice_flag);
emit_phi_rhss(stmt->v.if_cond.exit, true, &rhs_map, slice_flag);
builder->CreateBr(merge_bb);
then_bb = builder->GetInsertBlock();
current_function->getBasicBlockList().push_back(else_bb);
builder->SetInsertPoint(else_bb);
emit_stmts(stmt->v.if_cond.alternative, slice_flag);
emit_phi_rhss(stmt->v.if_cond.exit, false, &rhs_map, slice_flag);
builder->CreateBr(merge_bb);
else_bb = builder->GetInsertBlock();
current_function->getBasicBlockList().push_back(merge_bb);
builder->SetInsertPoint(merge_bb);
emit_phis(stmt->v.if_cond.exit, then_bb, else_bb, rhs_map, slice_flag);
}
break;
case STMT_WHILE_LOOP:
{
BasicBlock *start_bb = builder->GetInsertBlock();
BasicBlock *entry_bb = BasicBlock::Create("entry", current_function);
BasicBlock *body_bb = BasicBlock::Create("body");
BasicBlock *exit_bb = BasicBlock::Create("exit");
map<rhs_t*, Value*> rhs_map;
emit_phi_rhss(stmt->v.while_loop.entry, true, &rhs_map, slice_flag);
builder->CreateBr(entry_bb);
builder->SetInsertPoint(entry_bb);
emit_phis(stmt->v.while_loop.entry, start_bb, NULL, rhs_map, slice_flag);
Value *invariant_number = emit_rhs(stmt->v.while_loop.invariant);
Value *invariant;
if (invariant_number->getType() == Type::Int32Ty)
invariant = builder->CreateICmpNE(invariant_number, make_int_const(0));
else if (invariant_number->getType() == Type::FloatTy)
invariant = builder->CreateFCmpONE(invariant_number, make_float_const(0.0));
else
g_assert_not_reached();
builder->CreateCondBr(invariant, body_bb, exit_bb);
current_function->getBasicBlockList().push_back(body_bb);
builder->SetInsertPoint(body_bb);
emit_stmts(stmt->v.while_loop.body, slice_flag);
body_bb = builder->GetInsertBlock();
emit_phi_rhss(stmt->v.while_loop.entry, false, &rhs_map, slice_flag);
emit_phis(stmt->v.while_loop.entry, NULL, body_bb, rhs_map, slice_flag);
builder->CreateBr(entry_bb);
//.........这里部分代码省略.........