aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorErich Keane <ekeane@nvidia.com>2023-11-17 06:29:02 -0800
committerGitHub <noreply@github.com>2023-11-17 06:29:02 -0800
commitff219ea9ca80f46ff85dbdb94622ffb319a0d237 (patch)
tree17213428b3e4b11cc4b516b42f02cb7f64f2cb60 /clang/lib/Frontend/CompilerInvocation.cpp
parent9c0e64999b23046d0b8987a48ddc41a4c6129f9d (diff)
downloadllvm-ff219ea9ca80f46ff85dbdb94622ffb319a0d237.zip
llvm-ff219ea9ca80f46ff85dbdb94622ffb319a0d237.tar.gz
llvm-ff219ea9ca80f46ff85dbdb94622ffb319a0d237.tar.bz2
[OpenACC] Initial commits to support OpenACC (#70234)
Initial commits to support OpenACC. This patchset: adds a clang-command line argument '-fopenacc', and starts to define _OPENACC, albeit to '1' instead of the standardized value (since we don't properly implement OpenACC yet). The OpenACC spec defines `_OPENACC` to be equal to the latest standard implemented. However, since we're not done implementing any standard, we've defined this by default to be `1`. As it is useful to run our compiler against existing OpenACC workloads, we're providing a temporary override flag to change the `_OPENACC` value to be any entirely digit value, permitting testing against any existing OpenACC project. Exactly like the OpenMP parser, the OpenACC pragma parser needs to consume and reprocess the tokens. This patch sets up the infrastructure to do so by refactoring the OpenMP version of this into a more general version that works for OpenACC as well. Additionally, this adds a few diagnostics and token kinds to get us started.
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index efcf073..3f4ca02 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3549,6 +3549,13 @@ void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts,
if (Opts.OpenMPCUDAMode)
GenerateArg(Consumer, OPT_fopenmp_cuda_mode);
+ if (Opts.OpenACC) {
+ GenerateArg(Consumer, OPT_fopenacc);
+ if (!Opts.OpenACCMacroOverride.empty())
+ GenerateArg(Consumer, OPT_openacc_macro_override,
+ Opts.OpenACCMacroOverride);
+ }
+
// The arguments used to set Optimize, OptimizeSize and NoInlineDefine are
// generated from CodeGenOptions.
@@ -4018,6 +4025,14 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
(T.isNVPTX() || T.isAMDGCN()) &&
Args.hasArg(options::OPT_fopenmp_cuda_mode);
+ // OpenACC Configuration.
+ if (Args.hasArg(options::OPT_fopenacc)) {
+ Opts.OpenACC = true;
+
+ if (Arg *A = Args.getLastArg(options::OPT_openacc_macro_override))
+ Opts.OpenACCMacroOverride = A->getValue();
+ }
+
// FIXME: Eliminate this dependency.
unsigned Opt = getOptimizationLevel(Args, IK, Diags),
OptSize = getOptimizationLevelSize(Args);