Implement codegen for builtin infinity functions.

llvm-svn: 44604
This commit is contained in:
Anders Carlsson 2007-12-05 07:22:48 +00:00
parent cbdb6f5b5d
commit e8ee04c0bc
2 changed files with 19 additions and 3 deletions

View File

@ -112,6 +112,22 @@ RValue CodeGenFunction::EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E) {
return RValue::get(V);
}
case Builtin::BI__builtin_inff: {
llvm::APFloat f(llvm::APFloat::IEEEsingle,
llvm::APFloat::fcInfinity, false);
llvm::Value *V = llvm::ConstantFP::get(llvm::Type::FloatTy, f);
return RValue::get(V);
}
case Builtin::BI__builtin_inf:
// FIXME: mapping long double onto double.
case Builtin::BI__builtin_infl: {
llvm::APFloat f(llvm::APFloat::IEEEdouble,
llvm::APFloat::fcInfinity, false);
llvm::Value *V = llvm::ConstantFP::get(llvm::Type::DoubleTy, f);
return RValue::get(V);
}
}
return RValue::get(0);

View File

@ -54,9 +54,9 @@
// F -> this is a libc/libm function with a '__builtin_' prefix added.
// Standard libc/libm functions:
BUILTIN(__builtin_inf , "d" , "ncF")
BUILTIN(__builtin_inff , "f" , "ncF")
BUILTIN(__builtin_infl , "Ld" , "ncF")
BUILTIN(__builtin_inf , "d" , "nc")
BUILTIN(__builtin_inff , "f" , "nc")
BUILTIN(__builtin_infl , "Ld" , "nc")
BUILTIN(__builtin_abs , "ii" , "ncF")
BUILTIN(__builtin_fabs , "dd" , "ncF")
BUILTIN(__builtin_fabsf, "ff" , "ncF")