From 66d4c2ddd9699f2dddc8fe7d5c51d9ecf5869447 Mon Sep 17 00:00:00 2001 From: Jean-Luc Duprat Date: Thu, 28 Jun 2012 11:17:11 -0700 Subject: [PATCH] When the --emit-c++ option is used, the state of the --opt=fast-math option is passed into the generated C++ code. If --opt=fast-math is used then the generated code contains: #define ISPC_FAST_MATH 1 Otherwise it contains: #undef ISPC_FAST_MATH This allows the generic headers to support the user's request. --- cbackend.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cbackend.cpp b/cbackend.cpp index 499e1868..98061a95 100644 --- a/cbackend.cpp +++ b/cbackend.cpp @@ -12,6 +12,8 @@ // //===----------------------------------------------------------------------===// +#include "ispc.h" + #include #ifndef _MSC_VER @@ -2144,6 +2146,12 @@ bool CWriter::doInitialization(llvm::Module &M) { Out << " #include \n"; Out << "#endif\n\n"; + if (g->opt.fastMath) { + Out << "#define ISPC_FAST_MATH 1\n" + } else { + Out << "#undef ISPC_FAST_MATH\n" + } + Out << "#include \"" << includeName << "\"\n"; Out << "\n/* Basic Library Function Declarations */\n";