本文整理汇总了C++中IRBuilder::CreateFCmpOGE方法的典型用法代码示例。如果您正苦于以下问题:C++ IRBuilder::CreateFCmpOGE方法的具体用法?C++ IRBuilder::CreateFCmpOGE怎么用?C++ IRBuilder::CreateFCmpOGE使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRBuilder
的用法示例。
在下文中一共展示了IRBuilder::CreateFCmpOGE方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getValue
Value* GreaterThanEqualExpression::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->CreateICmpSGE(leftExpression->getValue(), rightExpression->getValue());
case DOUBLEVALUEEXPRESSION:
return builder->CreateFCmpOGE(leftExpression->getValue(), rightExpression->getValue());
case STRINGVALUEEXPRESSION:
case DATEVALUEEXPRESSION:
return codegen::stringCmp(leftExpression->getValue(), rightExpression->getValue(), GREATERTHANEQUALEXPRESSION);
default:
cout << "Unknown expression type!" << endl;
exit(-1);
}
return NULL;
}
示例2:
/*
* float t1(float p) { return (p>0)?p:-p; }
*/
Function *createAbs(Module *m, LLVMContext &Context) {
Type *floatTy = Type::getFloatTy(Context);
Type *ArgTypes[] = { floatTy };
FunctionType *Ty = FunctionType::get(floatTy, ArgTypes, false);
Function *func = Function::Create(Ty,
GlobalValue::ExternalLinkage, "fabs", m);
BasicBlock *bb = BasicBlock::Create(Context, "EntryBlock", func);
IRBuilder<> *builder = new IRBuilder<>(bb);
Value *arg0 = func->arg_begin();arg0->setName("arg0");
Value *v = builder->CreateFCmpOGE(arg0, ConstantFP::get(floatTy, 0.0));
Value *v0 = builder->CreateFNeg(arg0);
Value *ret = builder->CreateSelect(v, arg0, v0);
builder->CreateRet(ret);
return func;
}