@@ -125,145 +125,6 @@ forAllAssociatedToolChains(Compilation &C, const JobAction &JA,
125125 //
126126}
127127
128- // / This is a helper function for validating the optional refinement step
129- // / parameter in reciprocal argument strings. Return false if there is an error
130- // / parsing the refinement step. Otherwise, return true and set the Position
131- // / of the refinement step in the input string.
132- static bool getRefinementStep (StringRef In, const Driver &D,
133- const Arg &A, size_t &Position) {
134- const char RefinementStepToken = ' :' ;
135- Position = In.find (RefinementStepToken);
136- if (Position != StringRef::npos) {
137- StringRef Option = A.getOption ().getName ();
138- StringRef RefStep = In.substr (Position + 1 );
139- // Allow exactly one numeric character for the additional refinement
140- // step parameter. This is reasonable for all currently-supported
141- // operations and architectures because we would expect that a larger value
142- // of refinement steps would cause the estimate "optimization" to
143- // under-perform the native operation. Also, if the estimate does not
144- // converge quickly, it probably will not ever converge, so further
145- // refinement steps will not produce a better answer.
146- if (RefStep.size () != 1 ) {
147- D.Diag (diag::err_drv_invalid_value) << Option << RefStep;
148- return false ;
149- }
150- char RefStepChar = RefStep[0 ];
151- if (RefStepChar < ' 0' || RefStepChar > ' 9' ) {
152- D.Diag (diag::err_drv_invalid_value) << Option << RefStep;
153- return false ;
154- }
155- }
156- return true ;
157- }
158-
159- // / The -mrecip flag requires processing of many optional parameters.
160- static void ParseMRecip (const Driver &D, const ArgList &Args,
161- ArgStringList &OutStrings) {
162- StringRef DisabledPrefixIn = " !" ;
163- StringRef DisabledPrefixOut = " !" ;
164- StringRef EnabledPrefixOut = " " ;
165- StringRef Out = " -mrecip=" ;
166-
167- Arg *A = Args.getLastArg (options::OPT_mrecip, options::OPT_mrecip_EQ);
168- if (!A)
169- return ;
170-
171- unsigned NumOptions = A->getNumValues ();
172- if (NumOptions == 0 ) {
173- // No option is the same as "all".
174- OutStrings.push_back (Args.MakeArgString (Out + " all" ));
175- return ;
176- }
177-
178- // Pass through "all", "none", or "default" with an optional refinement step.
179- if (NumOptions == 1 ) {
180- StringRef Val = A->getValue (0 );
181- size_t RefStepLoc;
182- if (!getRefinementStep (Val, D, *A, RefStepLoc))
183- return ;
184- StringRef ValBase = Val.slice (0 , RefStepLoc);
185- if (ValBase == " all" || ValBase == " none" || ValBase == " default" ) {
186- OutStrings.push_back (Args.MakeArgString (Out + Val));
187- return ;
188- }
189- }
190-
191- // Each reciprocal type may be enabled or disabled individually.
192- // Check each input value for validity, concatenate them all back together,
193- // and pass through.
194-
195- llvm::StringMap<bool > OptionStrings;
196- OptionStrings.insert (std::make_pair (" divd" , false ));
197- OptionStrings.insert (std::make_pair (" divf" , false ));
198- OptionStrings.insert (std::make_pair (" divh" , false ));
199- OptionStrings.insert (std::make_pair (" vec-divd" , false ));
200- OptionStrings.insert (std::make_pair (" vec-divf" , false ));
201- OptionStrings.insert (std::make_pair (" vec-divh" , false ));
202- OptionStrings.insert (std::make_pair (" sqrtd" , false ));
203- OptionStrings.insert (std::make_pair (" sqrtf" , false ));
204- OptionStrings.insert (std::make_pair (" sqrth" , false ));
205- OptionStrings.insert (std::make_pair (" vec-sqrtd" , false ));
206- OptionStrings.insert (std::make_pair (" vec-sqrtf" , false ));
207- OptionStrings.insert (std::make_pair (" vec-sqrth" , false ));
208-
209- for (unsigned i = 0 ; i != NumOptions; ++i) {
210- StringRef Val = A->getValue (i);
211-
212- bool IsDisabled = Val.starts_with (DisabledPrefixIn);
213- // Ignore the disablement token for string matching.
214- if (IsDisabled)
215- Val = Val.substr (1 );
216-
217- size_t RefStep;
218- if (!getRefinementStep (Val, D, *A, RefStep))
219- return ;
220-
221- StringRef ValBase = Val.slice (0 , RefStep);
222- llvm::StringMap<bool >::iterator OptionIter = OptionStrings.find (ValBase);
223- if (OptionIter == OptionStrings.end ()) {
224- // Try again specifying float suffix.
225- OptionIter = OptionStrings.find (ValBase.str () + ' f' );
226- if (OptionIter == OptionStrings.end ()) {
227- // The input name did not match any known option string.
228- D.Diag (diag::err_drv_unknown_argument) << Val;
229- return ;
230- }
231- // The option was specified without a half or float or double suffix.
232- // Make sure that the double or half entry was not already specified.
233- // The float entry will be checked below.
234- if (OptionStrings[ValBase.str () + ' d' ] ||
235- OptionStrings[ValBase.str () + ' h' ]) {
236- D.Diag (diag::err_drv_invalid_value) << A->getOption ().getName () << Val;
237- return ;
238- }
239- }
240-
241- if (OptionIter->second == true ) {
242- // Duplicate option specified.
243- D.Diag (diag::err_drv_invalid_value) << A->getOption ().getName () << Val;
244- return ;
245- }
246-
247- // Mark the matched option as found. Do not allow duplicate specifiers.
248- OptionIter->second = true ;
249-
250- // If the precision was not specified, also mark the double and half entry
251- // as found.
252- if (ValBase.back () != ' f' && ValBase.back () != ' d' && ValBase.back () != ' h' ) {
253- OptionStrings[ValBase.str () + ' d' ] = true ;
254- OptionStrings[ValBase.str () + ' h' ] = true ;
255- }
256-
257- // Build the output string.
258- StringRef Prefix = IsDisabled ? DisabledPrefixOut : EnabledPrefixOut;
259- Out = Args.MakeArgString (Out + Prefix + Val);
260- if (i != NumOptions - 1 )
261- Out = Args.MakeArgString (Out + " ," );
262- }
263-
264- OutStrings.push_back (Args.MakeArgString (Out));
265- }
266-
267128static bool
268129shouldUseExceptionTablesForObjCExceptions (const ObjCRuntime &runtime,
269130 const llvm::Triple &Triple) {
@@ -3490,7 +3351,9 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
34903351 CmdArgs.push_back (Args.MakeArgString (" -fbfloat16-excess-precision=" +
34913352 BFloat16ExcessPrecision));
34923353
3493- ParseMRecip (D, Args, CmdArgs);
3354+ StringRef Recip = parseMRecipOption (D.getDiags (), Args);
3355+ if (!Recip.empty ())
3356+ CmdArgs.push_back (Args.MakeArgString (" -mrecip=" + Recip));
34943357
34953358 // -ffast-math enables the __FAST_MATH__ preprocessor macro, but check for the
34963359 // individual features enabled by -ffast-math instead of the option itself as
@@ -7588,7 +7451,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
75887451 handleVectorizeLoopsArgs (Args, CmdArgs);
75897452 handleVectorizeSLPArgs (Args, CmdArgs);
75907453
7591- StringRef VecWidth = ParseMPreferVectorWidthOption (D.getDiags (), Args);
7454+ StringRef VecWidth = parseMPreferVectorWidthOption (D.getDiags (), Args);
75927455 if (!VecWidth.empty ())
75937456 CmdArgs.push_back (Args.MakeArgString (" -mprefer-vector-width=" + VecWidth));
75947457
0 commit comments