From 231aa3070dcd91e10e9972d20f7557c0068c41e3 Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Tue, 8 Apr 2025 10:06:28 -0700 Subject: [OpenACC][CIR] Basic infrastructure for OpenACC lowering (#134717) This is the first of a few patches that will do infrastructure work to enable the OpenACC lowering via the OpenACC dialect. At the moment this just gets the various function calls that will end up generating OpenACC, plus some tests to validate that we're doing the diagnostics in OpenACC specific locations. Additionally, this adds Stmt and Decl files for CIRGen. --- clang/lib/Frontend/CompilerInvocation.cpp | 49 +++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'clang/lib/Frontend/CompilerInvocation.cpp') diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 572c71e..cfc5c06 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -4674,6 +4674,51 @@ static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) { llvm_unreachable("invalid frontend action"); } +static bool isCodeGenAction(frontend::ActionKind Action) { + switch (Action) { + case frontend::EmitAssembly: + case frontend::EmitBC: + case frontend::EmitCIR: + case frontend::EmitHTML: + case frontend::EmitLLVM: + case frontend::EmitLLVMOnly: + case frontend::EmitCodeGenOnly: + case frontend::EmitObj: + case frontend::GenerateModule: + case frontend::GenerateModuleInterface: + case frontend::GenerateReducedModuleInterface: + case frontend::GenerateHeaderUnit: + case frontend::GeneratePCH: + case frontend::GenerateInterfaceStubs: + return true; + case frontend::ASTDeclList: + case frontend::ASTDump: + case frontend::ASTPrint: + case frontend::ASTView: + case frontend::ExtractAPI: + case frontend::FixIt: + case frontend::ParseSyntaxOnly: + case frontend::ModuleFileInfo: + case frontend::VerifyPCH: + case frontend::PluginAction: + case frontend::RewriteObjC: + case frontend::RewriteTest: + case frontend::RunAnalysis: + case frontend::TemplightDump: + case frontend::DumpCompilerOptions: + case frontend::DumpRawTokens: + case frontend::DumpTokens: + case frontend::InitOnly: + case frontend::PrintPreamble: + case frontend::PrintPreprocessedInput: + case frontend::RewriteMacros: + case frontend::RunPreprocessorOnly: + case frontend::PrintDependencyDirectivesSourceMinimizerOutput: + return false; + } + llvm_unreachable("invalid frontend action"); +} + static void GeneratePreprocessorArgs(const PreprocessorOptions &Opts, ArgumentConsumer Consumer, const LangOptions &LangOpts, @@ -5001,6 +5046,10 @@ bool CompilerInvocation::CreateFromArgsImpl( Res.getTargetOpts().HostTriple = Res.getFrontendOpts().AuxTriple; } + if (LangOpts.OpenACC && !Res.getFrontendOpts().UseClangIRPipeline && + isCodeGenAction(Res.getFrontendOpts().ProgramAction)) + Diags.Report(diag::warn_drv_openacc_without_cir); + // Set the triple of the host for OpenMP device compile. if (LangOpts.OpenMPIsTargetDevice) Res.getTargetOpts().HostTriple = Res.getFrontendOpts().AuxTriple; -- cgit v1.1