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