@@ -3398,169 +3398,6 @@ void tools::handleInterchangeLoopsArgs(const ArgList &Args,
33983398 CmdArgs.push_back (" -floop-interchange" );
33993399}
34003400
3401- // Parse -mprefer-vector-width=. Return the Value string if well-formed.
3402- // Otherwise, return an empty string and issue a diagnosic message if needed.
3403- StringRef tools::parseMPreferVectorWidthOption (clang::DiagnosticsEngine &Diags,
3404- const llvm::opt::ArgList &Args) {
3405- Arg *A = Args.getLastArg (options::OPT_mprefer_vector_width_EQ);
3406- if (!A)
3407- return " " ;
3408-
3409- StringRef Value = A->getValue ();
3410- unsigned Width LLVM_ATTRIBUTE_UNINITIALIZED;
3411-
3412- // Only "none" and Integer values are accepted by
3413- // -mprefer-vector-width=<value>.
3414- if (Value != " none" && Value.getAsInteger (10 , Width)) {
3415- Diags.Report (clang::diag::err_drv_invalid_value)
3416- << A->getOption ().getName () << Value;
3417- return " " ;
3418- }
3419-
3420- return Value;
3421- }
3422-
3423- // This is a helper function for validating the optional refinement step
3424- // parameter in reciprocal argument strings. Return false if there is an error
3425- // parsing the refinement step. Otherwise, return true and set the Position
3426- // of the refinement step in the input string.
3427- static bool getRefinementStep (StringRef In, clang::DiagnosticsEngine &Diags,
3428- const Arg &A, size_t &Position) {
3429- const char RefinementStepToken = ' :' ;
3430- Position = In.find (RefinementStepToken);
3431- if (Position != StringRef::npos) {
3432- StringRef Option = A.getOption ().getName ();
3433- StringRef RefStep = In.substr (Position + 1 );
3434- // Allow exactly one numeric character for the additional refinement
3435- // step parameter. This is reasonable for all currently-supported
3436- // operations and architectures because we would expect that a larger value
3437- // of refinement steps would cause the estimate "optimization" to
3438- // under-perform the native operation. Also, if the estimate does not
3439- // converge quickly, it probably will not ever converge, so further
3440- // refinement steps will not produce a better answer.
3441- if (RefStep.size () != 1 ) {
3442- Diags.Report (diag::err_drv_invalid_value) << Option << RefStep;
3443- return false ;
3444- }
3445- char RefStepChar = RefStep[0 ];
3446- if (RefStepChar < ' 0' || RefStepChar > ' 9' ) {
3447- Diags.Report (diag::err_drv_invalid_value) << Option << RefStep;
3448- return false ;
3449- }
3450- }
3451- return true ;
3452- }
3453-
3454- // Parse -mrecip. Return the Value string if well-formed.
3455- // Otherwise, return an empty string and issue a diagnosic message if needed.
3456- StringRef tools::parseMRecipOption (clang::DiagnosticsEngine &Diags,
3457- const ArgList &Args) {
3458- StringRef DisabledPrefixIn = " !" ;
3459- StringRef DisabledPrefixOut = " !" ;
3460- StringRef EnabledPrefixOut = " " ;
3461- StringRef Out = " " ;
3462-
3463- Arg *A = Args.getLastArg (options::OPT_mrecip, options::OPT_mrecip_EQ);
3464- if (!A)
3465- return " " ;
3466-
3467- unsigned NumOptions = A->getNumValues ();
3468- if (NumOptions == 0 ) {
3469- // No option is the same as "all".
3470- return " all" ;
3471- }
3472-
3473- // Pass through "all", "none", or "default" with an optional refinement step.
3474- if (NumOptions == 1 ) {
3475- StringRef Val = A->getValue (0 );
3476- size_t RefStepLoc;
3477- if (!getRefinementStep (Val, Diags, *A, RefStepLoc))
3478- return " " ;
3479- StringRef ValBase = Val.slice (0 , RefStepLoc);
3480- if (ValBase == " all" || ValBase == " none" || ValBase == " default" ) {
3481- return Val;
3482- }
3483- }
3484-
3485- // Each reciprocal type may be enabled or disabled individually.
3486- // Check each input value for validity, concatenate them all back together,
3487- // and pass through.
3488-
3489- llvm::StringMap<bool > OptionStrings;
3490- OptionStrings.insert (std::make_pair (" divd" , false ));
3491- OptionStrings.insert (std::make_pair (" divf" , false ));
3492- OptionStrings.insert (std::make_pair (" divh" , false ));
3493- OptionStrings.insert (std::make_pair (" vec-divd" , false ));
3494- OptionStrings.insert (std::make_pair (" vec-divf" , false ));
3495- OptionStrings.insert (std::make_pair (" vec-divh" , false ));
3496- OptionStrings.insert (std::make_pair (" sqrtd" , false ));
3497- OptionStrings.insert (std::make_pair (" sqrtf" , false ));
3498- OptionStrings.insert (std::make_pair (" sqrth" , false ));
3499- OptionStrings.insert (std::make_pair (" vec-sqrtd" , false ));
3500- OptionStrings.insert (std::make_pair (" vec-sqrtf" , false ));
3501- OptionStrings.insert (std::make_pair (" vec-sqrth" , false ));
3502-
3503- for (unsigned i = 0 ; i != NumOptions; ++i) {
3504- StringRef Val = A->getValue (i);
3505-
3506- bool IsDisabled = Val.starts_with (DisabledPrefixIn);
3507- // Ignore the disablement token for string matching.
3508- if (IsDisabled)
3509- Val = Val.substr (1 );
3510-
3511- size_t RefStep;
3512- if (!getRefinementStep (Val, Diags, *A, RefStep))
3513- return " " ;
3514-
3515- StringRef ValBase = Val.slice (0 , RefStep);
3516- llvm::StringMap<bool >::iterator OptionIter = OptionStrings.find (ValBase);
3517- if (OptionIter == OptionStrings.end ()) {
3518- // Try again specifying float suffix.
3519- OptionIter = OptionStrings.find (ValBase.str () + ' f' );
3520- if (OptionIter == OptionStrings.end ()) {
3521- // The input name did not match any known option string.
3522- Diags.Report (diag::err_drv_unknown_argument) << Val;
3523- return " " ;
3524- }
3525- // The option was specified without a half or float or double suffix.
3526- // Make sure that the double or half entry was not already specified.
3527- // The float entry will be checked below.
3528- if (OptionStrings[ValBase.str () + ' d' ] ||
3529- OptionStrings[ValBase.str () + ' h' ]) {
3530- Diags.Report (diag::err_drv_invalid_value)
3531- << A->getOption ().getName () << Val;
3532- return " " ;
3533- }
3534- }
3535-
3536- if (OptionIter->second == true ) {
3537- // Duplicate option specified.
3538- Diags.Report (diag::err_drv_invalid_value)
3539- << A->getOption ().getName () << Val;
3540- return " " ;
3541- }
3542-
3543- // Mark the matched option as found. Do not allow duplicate specifiers.
3544- OptionIter->second = true ;
3545-
3546- // If the precision was not specified, also mark the double and half entry
3547- // as found.
3548- if (ValBase.back () != ' f' && ValBase.back () != ' d' &&
3549- ValBase.back () != ' h' ) {
3550- OptionStrings[ValBase.str () + ' d' ] = true ;
3551- OptionStrings[ValBase.str () + ' h' ] = true ;
3552- }
3553-
3554- // Build the output string.
3555- StringRef Prefix = IsDisabled ? DisabledPrefixOut : EnabledPrefixOut;
3556- Out = Args.MakeArgString (Out + Prefix + Val);
3557- if (i != NumOptions - 1 )
3558- Out = Args.MakeArgString (Out + " ," );
3559- }
3560-
3561- return Out;
3562- }
3563-
35643401std::string tools::complexRangeKindToStr (LangOptions::ComplexRangeKind Range) {
35653402 switch (Range) {
35663403 case LangOptions::ComplexRangeKind::CX_Full:
0 commit comments