From c8ee7988c4ea9ec784625d2a47a8575feb191421 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Wed, 5 Dec 2007 07:22:48 +0000 Subject: [PATCH] Implement codegen for builtin infinity functions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44604 91177308-0d34-0410-b5e6-96231b3b80d8 --- CodeGen/CGBuiltin.cpp | 16 ++++++++++++++++ include/clang/AST/Builtins.def | 6 +++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CodeGen/CGBuiltin.cpp b/CodeGen/CGBuiltin.cpp index 27c82e8cd0..8f9b7b3d74 100644 --- a/CodeGen/CGBuiltin.cpp +++ b/CodeGen/CGBuiltin.cpp @@ -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); diff --git a/include/clang/AST/Builtins.def b/include/clang/AST/Builtins.def index d95dbd4301..c0e978fcd1 100644 --- a/include/clang/AST/Builtins.def +++ b/include/clang/AST/Builtins.def @@ -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") -- 2.40.0