aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-12-20 00:44:32 +0000
committerChris Lattner <sabre@nondot.org>2007-12-20 00:44:32 +0000
commitfe23e217774aaec350086fab839210d7d9e1e3f4 (patch)
tree9571b4b3f81b7e685c0b6a3fa419d6723cb832a5
parent5411772b87c41ab91856bebca752b551d41be421 (diff)
Implement codegen for ordered comparison builtins.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45243 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--CodeGen/CGBuiltin.cpp36
-rw-r--r--Sema/SemaExpr.cpp3
2 files changed, 37 insertions, 2 deletions
diff --git a/CodeGen/CGBuiltin.cpp b/CodeGen/CGBuiltin.cpp
index cc6d03ff04..ec6c2b968c 100644
--- a/CodeGen/CGBuiltin.cpp
+++ b/CodeGen/CGBuiltin.cpp
@@ -166,6 +166,42 @@ RValue CodeGenFunction::EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E) {
APFloat f(APFloat::IEEEdouble, APFloat::fcInfinity, false);
return RValue::get(ConstantFP::get(llvm::Type::DoubleTy, f));
}
+ case Builtin::BI__builtin_isgreater:
+ case Builtin::BI__builtin_isgreaterequal:
+ case Builtin::BI__builtin_isless:
+ case Builtin::BI__builtin_islessequal:
+ case Builtin::BI__builtin_islessgreater:
+ case Builtin::BI__builtin_isunordered: {
+ // Ordered comparisons: we know the arguments to these are matching scalar
+ // floating point values.
+ Value *LHS = EmitScalarExpr(E->getArg(0));
+ Value *RHS = EmitScalarExpr(E->getArg(1));
+
+ switch (BuiltinID) {
+ default: assert(0 && "Unknown ordered comparison");
+ case Builtin::BI__builtin_isgreater:
+ LHS = Builder.CreateFCmpOGT(LHS, RHS, "cmp");
+ break;
+ case Builtin::BI__builtin_isgreaterequal:
+ LHS = Builder.CreateFCmpOGE(LHS, RHS, "cmp");
+ break;
+ case Builtin::BI__builtin_isless:
+ LHS = Builder.CreateFCmpOLT(LHS, RHS, "cmp");
+ break;
+ case Builtin::BI__builtin_islessequal:
+ LHS = Builder.CreateFCmpOLE(LHS, RHS, "cmp");
+ break;
+ case Builtin::BI__builtin_islessgreater:
+ LHS = Builder.CreateFCmpONE(LHS, RHS, "cmp");
+ break;
+ case Builtin::BI__builtin_isunordered:
+ LHS = Builder.CreateFCmpUNO(LHS, RHS, "cmp");
+ break;
+ }
+ // ZExt bool to int type.
+ return RValue::get(Builder.CreateZExt(LHS, ConvertType(E->getType()),
+ "tmp"));
+ }
}
return RValue::get(0);
}
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index 6d1d6a62e6..846c52905c 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -720,8 +720,7 @@ ActOnInitList(SourceLocation LBraceLoc, ExprTy **initlist, unsigned NumInit,
return e;
}
-bool Sema::CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty)
-{
+bool Sema::CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty) {
assert(VectorTy->isVectorType() && "Not a vector type!");
if (Ty->isVectorType() || Ty->isIntegerType()) {