[cfe-commits] r45243 - in /cfe/trunk: CodeGen/CGBuiltin.cpp Sema/SemaExpr.cpp

Chris Lattner sabre at nondot.org
Wed Dec 19 16:44:32 PST 2007


Author: lattner
Date: Wed Dec 19 18:44:32 2007
New Revision: 45243

URL: http://llvm.org/viewvc/llvm-project?rev=45243&view=rev
Log:
Implement codegen for ordered comparison builtins.

Modified:
    cfe/trunk/CodeGen/CGBuiltin.cpp
    cfe/trunk/Sema/SemaExpr.cpp

Modified: cfe/trunk/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGBuiltin.cpp?rev=45243&r1=45242&r2=45243&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/CodeGen/CGBuiltin.cpp Wed Dec 19 18:44:32 2007
@@ -166,6 +166,42 @@
     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);
 }

Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=45243&r1=45242&r2=45243&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Wed Dec 19 18:44:32 2007
@@ -720,8 +720,7 @@
   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()) {





More information about the cfe-commits mailing list