diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-05-06 06:04:13 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-05-06 06:04:13 +0000 |
| commit | dbff4bf5f43fd6a6dd03ed3dd55a65a87f18b4d2 (patch) | |
| tree | 4231690f32f185be042f6fa66a85fc3b7a5c5f51 /clang/lib/CodeGen/CGBuiltin.cpp | |
| parent | 68784efaf62af6cc4234ea01f378e859dd7bfbab (diff) | |
| download | bcm5719-llvm-dbff4bf5f43fd6a6dd03ed3dd55a65a87f18b4d2.tar.gz bcm5719-llvm-dbff4bf5f43fd6a6dd03ed3dd55a65a87f18b4d2.zip | |
implement codegen support for __builtin_isfinite, part of PR6083
llvm-svn: 103168
Diffstat (limited to 'clang/lib/CodeGen/CGBuiltin.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGBuiltin.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 651539f0196..90fcb698285 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -362,6 +362,19 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType()), "tmp")); } + case Builtin::BI__builtin_isfinite: { + // isfinite(x) --> x == x && fabs(x) != infinity; } + Value *V = EmitScalarExpr(E->getArg(0)); + Value *Eq = Builder.CreateFCmpOEQ(V, V, "iseq"); + + Value *Abs = EmitFAbs(*this, V, E->getArg(0)->getType()); + Value *IsNotInf = + Builder.CreateFCmpUNE(Abs, ConstantFP::getInfinity(V->getType()),"isinf"); + + V = Builder.CreateAnd(Eq, IsNotInf, "and"); + return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType()))); + } + case Builtin::BIalloca: case Builtin::BI__builtin_alloca: { // FIXME: LLVM IR Should allow alloca with an i64 size! |

