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.
This commit is contained in:
Jean-Luc Duprat
2012-06-28 10:42:29 -07:00
parent dc9998ccaf
commit ec4021bbf4

View File

@@ -12,6 +12,8 @@
//
//===----------------------------------------------------------------------===//
#include "ispc.h"
#include <stdio.h>
#ifndef _MSC_VER
@@ -2144,6 +2146,12 @@ bool CWriter::doInitialization(llvm::Module &M) {
Out << " #include <alloca.h>\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";