aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--flang/lib/Frontend/CompilerInvocation.cpp37
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