diff options
author | Tom Eccles <tom.eccles@arm.com> | 2023-11-13 10:04:50 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-13 10:04:50 +0000 |
commit | a207e6307a589d482fd11c1aac17507c6eabc802 (patch) | |
tree | 7e43a5318da175a334bde09077f6ef1f072b7375 /flang/lib/Frontend/CompilerInvocation.cpp | |
parent | 4cc791bc98e075879f8c379f17e0b0369d57a40d (diff) | |
download | llvm-a207e6307a589d482fd11c1aac17507c6eabc802.zip llvm-a207e6307a589d482fd11c1aac17507c6eabc802.tar.gz llvm-a207e6307a589d482fd11c1aac17507c6eabc802.tar.bz2 |
[flang] add fveclib flag (#71734)
-fveclib= allows users to choose a vectorized libm so that loops
containing math functions are vectorized.
This is implemented as much as possible in the same way as in clang. The
driver test in veclib.f90 is copied from the clang test.
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | flang/lib/Frontend/CompilerInvocation.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index 3fef377..334da3a 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -153,6 +153,34 @@ static bool parseDebugArgs(Fortran::frontend::CodeGenOptions &opts, return true; } +static bool parseVectorLibArg(Fortran::frontend::CodeGenOptions &opts, + llvm::opt::ArgList &args, + clang::DiagnosticsEngine &diags) { + llvm::opt::Arg *arg = args.getLastArg(clang::driver::options::OPT_fveclib); + if (!arg) + return true; + + using VectorLibrary = llvm::driver::VectorLibrary; + std::optional<VectorLibrary> val = + llvm::StringSwitch<std::optional<VectorLibrary>>(arg->getValue()) + .Case("Accelerate", VectorLibrary::Accelerate) + .Case("LIBMVEC", VectorLibrary::LIBMVEC) + .Case("MASSV", VectorLibrary::MASSV) + .Case("SVML", VectorLibrary::SVML) + .Case("SLEEF", VectorLibrary::SLEEF) + .Case("Darwin_libsystem_m", VectorLibrary::Darwin_libsystem_m) + .Case("ArmPL", VectorLibrary::ArmPL) + .Case("NoLibrary", VectorLibrary::NoLibrary) + .Default(std::nullopt); + if (!val.has_value()) { + diags.Report(clang::diag::err_drv_invalid_value) + << arg->getAsString(args) << arg->getValue(); + return false; + } + opts.setVecLib(val.value()); + return true; +} + // Generate an OptRemark object containing info on if the -Rgroup // specified is enabled or not. static CodeGenOptions::OptRemark @@ -1116,6 +1144,7 @@ bool CompilerInvocation::createFromArgs( parsePreprocessorArgs(res.getPreprocessorOpts(), args); parseCodeGenArgs(res.getCodeGenOpts(), args, diags); success &= parseDebugArgs(res.getCodeGenOpts(), args, diags); + success &= parseVectorLibArg(res.getCodeGenOpts(), args, diags); success &= parseSemaArgs(res, args, diags); success &= parseDialectArgs(res, args, diags); success &= parseDiagArgs(res, args, diags); |