================ @@ -3167,3 +3167,30 @@ void tools::handleInterchangeLoopsArgs(const ArgList &Args, options::OPT_fno_loop_interchange, EnableInterchange)) CmdArgs.push_back("-floop-interchange"); } + +void tools::ParseMPreferVectorWidthOption(clang::DiagnosticsEngine &Diags, + const llvm::opt::ArgList &Args, + ArgStringList &CmdArgs, + bool isCompilerDriver) { + // If this was invoked by the Compiler Driver, we pass through the option + // as-is. Otherwise, if this is the Frontend Driver, we want just the value. + StringRef Out = (isCompilerDriver) ? "-mprefer-vector-width=" : ""; + + Arg *A = Args.getLastArg(clang::driver::options::OPT_mprefer_vector_width_EQ); + if (!A) + return; + + StringRef Value = A->getValue(); + unsigned Width; + + // Only "none" and Integer values are accepted by + // -mprefer-vector-width=<value>. + if (Value != "none" && Value.getAsInteger(10, Width)) { + Diags.Report(clang::diag::err_drv_invalid_value) + << A->getOption().getName() << Value; + return; + } + + CmdArgs.push_back(Args.MakeArgString(Out + Value)); ---------------- mcinally wrote:
> The function could take an ArgStringList*, only push Out + Value if it is > provided, and always return Value as a StringRef. That would work. It would disturb the Compiler Driver a bit to avoid warnings. We'd need to explicitly discard the results when unwanted. E.g.: `(void)ParseMPreferVectorWidthOption(...);` I wonder if we could come up with a Frontend Driver mechanism to discard everything up to and including the `=`. Then we'd just need to wrap the parsing/handling call in that mechanism. > Not sure if it would works with all options, I am not familiar with the > drivers. Same. I suggest that we delay this decision until there's a better view of the entire problem. https://github.com/llvm/llvm-project/pull/142800 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits