summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Steckelmacher <steckdenis@yahoo.fr>2011-07-05 17:53:39 +0200
committerDenis Steckelmacher <steckdenis@yahoo.fr>2011-07-05 17:53:39 +0200
commite4fd3e001e8d2d9603154c9a17d361e6e1731450 (patch)
tree36dbc5c0b756951cf2dc47f1257af343b141b26d
parentf460b57db905f86979215ad682738d89e7657b11 (diff)
Implement OpenCL C compiler's options.
-rw-r--r--src/core/compiler.cpp62
1 files changed, 61 insertions, 1 deletions
diff --git a/src/core/compiler.cpp b/src/core/compiler.cpp
index 6d52f64..bafeb99 100644
--- a/src/core/compiler.cpp
+++ b/src/core/compiler.cpp
@@ -22,6 +22,7 @@ Compiler::Compiler(const std::string &options)
clang::CodeGenOptions &codegen_opts = p_compiler.getCodeGenOpts();
codegen_opts.DebugInfo = false;
codegen_opts.AsmVerbose = true;
+ codegen_opts.OptimizationLevel = 2;
// Set diagnostic options
clang::DiagnosticOptions &diag_opts = p_compiler.getDiagnosticOpts();
@@ -69,10 +70,67 @@ Compiler::Compiler(const std::string &options)
// Parse the user options
std::istringstream options_stream(options);
std::string token;
+ bool Werror = false, inI = false, inD = false;
while (options_stream >> token)
{
-
+ if (inI)
+ {
+ // token is an include path
+ header_opts.AddPath(token, clang::frontend::Angled, true, false, false);
+ inI = false;
+ continue;
+ }
+ else if (inD)
+ {
+ // token is name or name=value
+ prep_opts.addMacroDef(token);
+ }
+
+ if (token == "-I")
+ {
+ inI = true;
+ }
+ else if (token == "-D")
+ {
+ inD = true;
+ }
+ else if (token == "-cl-single-precision-constant")
+ {
+ lang_opts.SinglePrecisionConstants = true;
+ }
+ else if (token == "-cl-opt-disable")
+ {
+ codegen_opts.OptimizationLevel = 0;
+ }
+ else if (token == "-cl-mad-enable")
+ {
+ codegen_opts.LessPreciseFPMAD = true;
+ }
+ else if (token == "-cl-unsafe-math-optimizations")
+ {
+ codegen_opts.UnsafeFPMath = true;
+ }
+ else if (token == "-cl-finite-math-only")
+ {
+ codegen_opts.NoInfsFPMath = true;
+ codegen_opts.NoNaNsFPMath = true;
+ }
+ else if (token == "-cl-fast-relaxed-math")
+ {
+ codegen_opts.UnsafeFPMath = true;
+ codegen_opts.NoInfsFPMath = true;
+ codegen_opts.NoNaNsFPMath = true;
+ lang_opts.FastRelaxedMath = true;
+ }
+ else if (token == "-w")
+ {
+ diag_opts.IgnoreWarnings = true;
+ }
+ else if (token == "-Werror")
+ {
+ Werror = true;
+ }
}
// Create the diagnostics engine
@@ -82,6 +140,8 @@ Compiler::Compiler(const std::string &options)
if (!p_compiler.hasDiagnostics())
return;
+ p_compiler.getDiagnostics().setWarningsAsErrors(Werror);
+
p_valid = true;
}