Skip to content

Commit

Permalink
Revert "[clang][cli] Port OpenMP-related LangOpts to marshalling system"
Browse files Browse the repository at this point in the history
This reverts commit 9ad94c1

It turns out that to correctly generate command line flags for LangOptions::OpenMP and LangOptions::OpenMPSimd, we need the flexibility of C++.
  • Loading branch information
jansvoboda11 committed Feb 1, 2021
1 parent 11e74e5 commit eefa8a9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
23 changes: 7 additions & 16 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -2145,24 +2145,18 @@ def fopenmp_EQ : Joined<["-"], "fopenmp=">, Group<f_Group>;
def fopenmp_use_tls : Flag<["-"], "fopenmp-use-tls">, Group<f_Group>,
Flags<[NoArgumentUnused, HelpHidden]>;
def fnoopenmp_use_tls : Flag<["-"], "fnoopenmp-use-tls">, Group<f_Group>,
Flags<[CC1Option, NoArgumentUnused, HelpHidden]>,
MarshallingInfoNegativeFlag<LangOpts<"OpenMPUseTLS">, !strconcat("(bool)", fopenmp.KeyPath)>,
ShouldParseIf<fopenmp.KeyPath>;
Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
def fopenmp_targets_EQ : CommaJoined<["-"], "fopenmp-targets=">, Flags<[NoXarchOption, CC1Option]>,
HelpText<"Specify comma-separated list of triples OpenMP offloading targets to be supported">;
def fopenmp_relocatable_target : Flag<["-"], "fopenmp-relocatable-target">,
Group<f_Group>, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
def fnoopenmp_relocatable_target : Flag<["-"], "fnoopenmp-relocatable-target">,
Group<f_Group>, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
defm openmp_simd : BoolFOption<"openmp-simd",
LangOpts<"OpenMPSimd">, DefaultFalse,
PosFlag<SetTrue, [], "Emit OpenMP code only for SIMD-based constructs.">,
NegFlag<SetFalse>, BothFlags<[CC1Option, NoArgumentUnused]>>,
ShouldParseIf<!strconcat("!", fopenmp.KeyPath)>;
def fopenmp_simd : Flag<["-"], "fopenmp-simd">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused]>,
HelpText<"Emit OpenMP code only for SIMD-based constructs.">;
def fopenmp_enable_irbuilder : Flag<["-"], "fopenmp-enable-irbuilder">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>,
HelpText<"Use the experimental OpenMP-IR-Builder codegen path.">,
MarshallingInfoFlag<LangOpts<"OpenMPIRBuilder">>,
ShouldParseIf<fopenmp.KeyPath>;
HelpText<"Use the experimental OpenMP-IR-Builder codegen path.">;
def fno_openmp_simd : Flag<["-"], "fno-openmp-simd">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused]>;
def fopenmp_cuda_mode : Flag<["-"], "fopenmp-cuda-mode">, Group<f_Group>,
Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
def fno_openmp_cuda_mode : Flag<["-"], "fno-openmp-cuda-mode">, Group<f_Group>,
Expand Down Expand Up @@ -5373,12 +5367,9 @@ def fno_cuda_host_device_constexpr : Flag<["-"], "fno-cuda-host-device-constexpr
//===----------------------------------------------------------------------===//

def fopenmp_is_device : Flag<["-"], "fopenmp-is-device">,
HelpText<"Generate code only for an OpenMP target device.">,
MarshallingInfoFlag<LangOpts<"OpenMPIsDevice">>,
ShouldParseIf<fopenmp.KeyPath>;
HelpText<"Generate code only for an OpenMP target device.">;
def fopenmp_host_ir_file_path : Separate<["-"], "fopenmp-host-ir-file-path">,
HelpText<"Path to the IR file produced by the frontend for the host.">,
MarshallingInfoString<LangOpts<"OMPHostIRFile">>;
HelpText<"Path to the IR file produced by the frontend for the host.">;

//===----------------------------------------------------------------------===//
// SYCL Options
Expand Down
22 changes: 16 additions & 6 deletions clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,12 +494,6 @@ static void FixupInvocation(CompilerInvocation &Invocation,
<< A->getSpelling() << T.getTriple();
}

// Report if OpenMP host file does not exist.
if (!LangOpts.OMPHostIRFile.empty() &&
!llvm::sys::fs::exists(LangOpts.OMPHostIRFile))
Diags.Report(diag::err_drv_omp_host_ir_file_not_found)
<< LangOpts.OMPHostIRFile;

if (!CodeGenOpts.ProfileRemappingFile.empty() && CodeGenOpts.LegacyPassManager)
Diags.Report(diag::err_drv_argument_only_allowed_with)
<< Args.getLastArg(OPT_fprofile_remapping_file_EQ)->getAsString(Args)
Expand Down Expand Up @@ -2437,6 +2431,13 @@ void CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
bool IsSimdSpecified =
Args.hasFlag(options::OPT_fopenmp_simd, options::OPT_fno_openmp_simd,
/*Default=*/false);
Opts.OpenMPSimd = !Opts.OpenMP && IsSimdSpecified;
Opts.OpenMPUseTLS =
Opts.OpenMP && !Args.hasArg(options::OPT_fnoopenmp_use_tls);
Opts.OpenMPIsDevice =
Opts.OpenMP && Args.hasArg(options::OPT_fopenmp_is_device);
Opts.OpenMPIRBuilder =
Opts.OpenMP && Args.hasArg(options::OPT_fopenmp_enable_irbuilder);
bool IsTargetSpecified =
Opts.OpenMPIsDevice || Args.hasArg(options::OPT_fopenmp_targets_EQ);

Expand Down Expand Up @@ -2510,6 +2511,15 @@ void CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
}
}

// Get OpenMP host file path if any and report if a non existent file is
// found
if (Arg *A = Args.getLastArg(options::OPT_fopenmp_host_ir_file_path)) {
Opts.OMPHostIRFile = A->getValue();
if (!llvm::sys::fs::exists(Opts.OMPHostIRFile))
Diags.Report(diag::err_drv_omp_host_ir_file_not_found)
<< Opts.OMPHostIRFile;
}

// Set CUDA mode for OpenMP target NVPTX/AMDGCN if specified in options
Opts.OpenMPCUDAMode = Opts.OpenMPIsDevice && (T.isNVPTX() || T.isAMDGCN()) &&
Args.hasArg(options::OPT_fopenmp_cuda_mode);
Expand Down

0 comments on commit eefa8a9

Please sign in to comment.