forked from OSchip/llvm-project
parent
5c3f1541a7
commit
4f8eb127e1
|
@ -85,6 +85,18 @@ RValue CodeGenFunction::EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E) {
|
|||
|
||||
return RValue::get(llvm::ConstantInt::get(Result));
|
||||
}
|
||||
case Builtin::BI__builtin_abs: {
|
||||
llvm::Value *ArgValue = EmitScalarExpr(E->getArg(0));
|
||||
|
||||
llvm::BinaryOperator *NegOp =
|
||||
Builder.CreateNeg(ArgValue, (ArgValue->getName() + "neg").c_str());
|
||||
llvm::Value *CmpResult =
|
||||
Builder.CreateICmpSGE(ArgValue, NegOp->getOperand(0), "abscond");
|
||||
llvm::Value *Result =
|
||||
Builder.CreateSelect(CmpResult, ArgValue, NegOp, "abs");
|
||||
|
||||
return RValue::get(Result);
|
||||
}
|
||||
}
|
||||
|
||||
return RValue::get(0);
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
BUILTIN(__builtin_inf , "d" , "ncF")
|
||||
BUILTIN(__builtin_inff , "f" , "ncF")
|
||||
BUILTIN(__builtin_infl , "Ld" , "ncF")
|
||||
BUILTIN(__builtin_abs , "ii" , "ncF")
|
||||
BUILTIN(__builtin_fabs , "dd" , "ncF")
|
||||
BUILTIN(__builtin_fabsf, "ff" , "ncF")
|
||||
BUILTIN(__builtin_fabsl, "LdLd", "ncF")
|
||||
|
|
Loading…
Reference in New Issue