diff options
-rw-r--r-- | CodeGen/CGBuiltin.cpp | 36 | ||||
-rw-r--r-- | Sema/SemaExpr.cpp | 3 |
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()) { |