diff options
author | Mats Petersson <mats.petersson@arm.com> | 2023-10-02 12:01:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-02 12:01:12 +0100 |
commit | 11e68c7e7ffb430f17a02c5ca28f6884b5de563a (patch) | |
tree | 26f224a0d030993d1f528906467b5aeb4da4351b /flang/lib/Frontend/CompilerInvocation.cpp | |
parent | 414ff812d6241b728754ce562081419e7fc091eb (diff) | |
download | llvm-11e68c7e7ffb430f17a02c5ca28f6884b5de563a.zip llvm-11e68c7e7ffb430f17a02c5ca28f6884b5de563a.tar.gz llvm-11e68c7e7ffb430f17a02c5ca28f6884b5de563a.tar.bz2 |
[flang]Add vscale argument parsing (#67676)
Support for vector scale range arguments, for AArch64 scalable vector
extension (SVE) support.
Adds -msve-vector-bits to the flang frontend, and for flang fc1 the
options are -mvscale-min and -mvscale-max (optional). These match the
clang and clang cc1 options for the same purposes.
A further patch will actually USE these arguments.
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | flang/lib/Frontend/CompilerInvocation.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index 6c0b90c..37315e0 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -986,6 +986,41 @@ static bool parseFloatingPointArgs(CompilerInvocation &invoc, return true; } +/// Parses vscale range options and populates the CompilerInvocation +/// accordingly. +/// Returns false if new errors are generated. +/// +/// \param [out] invoc Stores the processed arguments +/// \param [in] args The compiler invocation arguments to parse +/// \param [out] diags DiagnosticsEngine to report erros with +static bool parseVScaleArgs(CompilerInvocation &invoc, llvm::opt::ArgList &args, + clang::DiagnosticsEngine &diags) { + LangOptions &opts = invoc.getLangOpts(); + if (const auto arg = + args.getLastArg(clang::driver::options::OPT_mvscale_min_EQ)) { + llvm::StringRef argValue = llvm::StringRef(arg->getValue()); + unsigned VScaleMin; + if (argValue.getAsInteger(/*Radix=*/10, VScaleMin)) { + diags.Report(clang::diag::err_drv_unsupported_option_argument) + << arg->getSpelling() << argValue; + return false; + } + opts.VScaleMin = VScaleMin; + } + if (const auto arg = + args.getLastArg(clang::driver::options::OPT_mvscale_max_EQ)) { + llvm::StringRef argValue = llvm::StringRef(arg->getValue()); + unsigned VScaleMax; + if (argValue.getAsInteger(/*Radix=w*/ 10, VScaleMax)) { + diags.Report(clang::diag::err_drv_unsupported_option_argument) + << arg->getSpelling() << argValue; + return false; + } + opts.VScaleMax = VScaleMax; + } + return true; +} + bool CompilerInvocation::createFromArgs( CompilerInvocation &res, llvm::ArrayRef<const char *> commandLineArgs, clang::DiagnosticsEngine &diags, const char *argv0) { @@ -1079,6 +1114,8 @@ bool CompilerInvocation::createFromArgs( success &= parseFloatingPointArgs(res, args, diags); + success &= parseVScaleArgs(res, args, diags); + // Set the string to be used as the return value of the COMPILER_OPTIONS // intrinsic of iso_fortran_env. This is either passed in from the parent // compiler driver invocation with an environment variable, or failing that |