clang 18.0.0git
Flang.cpp
Go to the documentation of this file.
1//===-- Flang.cpp - Flang+LLVM ToolChain Implementations --------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9
10#include "Flang.h"
11#include "CommonArgs.h"
12
14#include "llvm/Frontend/Debug/Options.h"
15#include "llvm/Support/FileSystem.h"
16#include "llvm/Support/Path.h"
17
18#include <cassert>
19
20using namespace clang::driver;
21using namespace clang::driver::tools;
22using namespace clang;
23using namespace llvm::opt;
24
25/// Add -x lang to \p CmdArgs for \p Input.
26static void addDashXForInput(const ArgList &Args, const InputInfo &Input,
27 ArgStringList &CmdArgs) {
28 CmdArgs.push_back("-x");
29 // Map the driver type to the frontend type.
30 CmdArgs.push_back(types::getTypeName(Input.getType()));
31}
32
33void Flang::addFortranDialectOptions(const ArgList &Args,
34 ArgStringList &CmdArgs) const {
35 Args.AddAllArgs(CmdArgs, {options::OPT_ffixed_form,
36 options::OPT_ffree_form,
37 options::OPT_ffixed_line_length_EQ,
38 options::OPT_fopenmp,
39 options::OPT_fopenmp_version_EQ,
40 options::OPT_fopenacc,
41 options::OPT_finput_charset_EQ,
42 options::OPT_fimplicit_none,
43 options::OPT_fno_implicit_none,
44 options::OPT_fbackslash,
45 options::OPT_fno_backslash,
46 options::OPT_flogical_abbreviations,
47 options::OPT_fno_logical_abbreviations,
48 options::OPT_fxor_operator,
49 options::OPT_fno_xor_operator,
50 options::OPT_falternative_parameter_statement,
51 options::OPT_fdefault_real_8,
52 options::OPT_fdefault_integer_8,
53 options::OPT_fdefault_double_8,
54 options::OPT_flarge_sizes,
55 options::OPT_fno_automatic});
56}
57
58void Flang::addPreprocessingOptions(const ArgList &Args,
59 ArgStringList &CmdArgs) const {
60 Args.AddAllArgs(CmdArgs,
61 {options::OPT_P, options::OPT_D, options::OPT_U,
62 options::OPT_I, options::OPT_cpp, options::OPT_nocpp});
63}
64
65/// @C shouldLoopVersion
66///
67/// Check if Loop Versioning should be enabled.
68/// We look for the last of one of the following:
69/// -Ofast, -O4, -O<number> and -f[no-]version-loops-for-stride.
70/// Loop versioning is disabled if the last option is
71/// -fno-version-loops-for-stride.
72/// Loop versioning is enabled if the last option is one of:
73/// -floop-versioning
74/// -Ofast
75/// -O4
76/// -O3
77/// For all other cases, loop versioning is is disabled.
78///
79/// The gfortran compiler automatically enables the option for -O3 or -Ofast.
80///
81/// @return true if loop-versioning should be enabled, otherwise false.
82static bool shouldLoopVersion(const ArgList &Args) {
83 const Arg *LoopVersioningArg = Args.getLastArg(
84 options::OPT_Ofast, options::OPT_O, options::OPT_O4,
85 options::OPT_floop_versioning, options::OPT_fno_loop_versioning);
86 if (!LoopVersioningArg)
87 return false;
88
89 if (LoopVersioningArg->getOption().matches(options::OPT_fno_loop_versioning))
90 return false;
91
92 if (LoopVersioningArg->getOption().matches(options::OPT_floop_versioning))
93 return true;
94
95 if (LoopVersioningArg->getOption().matches(options::OPT_Ofast) ||
96 LoopVersioningArg->getOption().matches(options::OPT_O4))
97 return true;
98
99 if (LoopVersioningArg->getOption().matches(options::OPT_O)) {
100 StringRef S(LoopVersioningArg->getValue());
101 unsigned OptLevel = 0;
102 // Note -Os or Oz woould "fail" here, so return false. Which is the
103 // desiered behavior.
104 if (S.getAsInteger(10, OptLevel))
105 return false;
106
107 return OptLevel > 2;
108 }
109
110 llvm_unreachable("We should not end up here");
111 return false;
112}
113
114void Flang::addOtherOptions(const ArgList &Args, ArgStringList &CmdArgs) const {
115 Args.AddAllArgs(CmdArgs,
116 {options::OPT_module_dir, options::OPT_fdebug_module_writer,
117 options::OPT_fintrinsic_modules_path, options::OPT_pedantic,
118 options::OPT_std_EQ, options::OPT_W_Joined,
119 options::OPT_fconvert_EQ, options::OPT_fpass_plugin_EQ,
120 options::OPT_funderscoring, options::OPT_fno_underscoring});
121
122 llvm::codegenoptions::DebugInfoKind DebugInfoKind;
123 if (Args.hasArg(options::OPT_gN_Group)) {
124 Arg *gNArg = Args.getLastArg(options::OPT_gN_Group);
125 DebugInfoKind = debugLevelToInfoKind(*gNArg);
126 } else if (Args.hasArg(options::OPT_g_Flag)) {
127 DebugInfoKind = llvm::codegenoptions::DebugLineTablesOnly;
128 } else {
129 DebugInfoKind = llvm::codegenoptions::NoDebugInfo;
130 }
131 addDebugInfoKind(CmdArgs, DebugInfoKind);
132}
133
134void Flang::addCodegenOptions(const ArgList &Args,
135 ArgStringList &CmdArgs) const {
136 Arg *stackArrays =
137 Args.getLastArg(options::OPT_Ofast, options::OPT_fstack_arrays,
138 options::OPT_fno_stack_arrays);
139 if (stackArrays &&
140 !stackArrays->getOption().matches(options::OPT_fno_stack_arrays))
141 CmdArgs.push_back("-fstack-arrays");
142
143 if (shouldLoopVersion(Args))
144 CmdArgs.push_back("-fversion-loops-for-stride");
145
146 Args.AddAllArgs(CmdArgs, {options::OPT_flang_experimental_hlfir,
147 options::OPT_flang_experimental_polymorphism,
148 options::OPT_fno_ppc_native_vec_elem_order,
149 options::OPT_fppc_native_vec_elem_order});
150}
151
152void Flang::addPicOptions(const ArgList &Args, ArgStringList &CmdArgs) const {
153 // ParsePICArgs parses -fPIC/-fPIE and their variants and returns a tuple of
154 // (RelocationModel, PICLevel, IsPIE).
155 llvm::Reloc::Model RelocationModel;
156 unsigned PICLevel;
157 bool IsPIE;
158 std::tie(RelocationModel, PICLevel, IsPIE) =
159 ParsePICArgs(getToolChain(), Args);
160
161 if (auto *RMName = RelocationModelName(RelocationModel)) {
162 CmdArgs.push_back("-mrelocation-model");
163 CmdArgs.push_back(RMName);
164 }
165 if (PICLevel > 0) {
166 CmdArgs.push_back("-pic-level");
167 CmdArgs.push_back(PICLevel == 1 ? "1" : "2");
168 if (IsPIE)
169 CmdArgs.push_back("-pic-is-pie");
170 }
171}
172
173void Flang::addTargetOptions(const ArgList &Args,
174 ArgStringList &CmdArgs) const {
175 const ToolChain &TC = getToolChain();
176 const llvm::Triple &Triple = TC.getEffectiveTriple();
177 const Driver &D = TC.getDriver();
178
179 std::string CPU = getCPUName(D, Args, Triple);
180 if (!CPU.empty()) {
181 CmdArgs.push_back("-target-cpu");
182 CmdArgs.push_back(Args.MakeArgString(CPU));
183 }
184
185 // Add the target features.
186 switch (TC.getArch()) {
187 default:
188 break;
189 case llvm::Triple::r600:
190 case llvm::Triple::amdgcn:
191 case llvm::Triple::aarch64:
192 case llvm::Triple::riscv64:
193 case llvm::Triple::x86_64:
194 getTargetFeatures(D, Triple, Args, CmdArgs, /*ForAs*/ false);
195 break;
196 }
197
198 // TODO: Add target specific flags, ABI, mtune option etc.
199}
200
201void Flang::addOffloadOptions(Compilation &C, const InputInfoList &Inputs,
202 const JobAction &JA, const ArgList &Args,
203 ArgStringList &CmdArgs) const {
204 bool IsOpenMPDevice = JA.isDeviceOffloading(Action::OFK_OpenMP);
205 bool IsHostOffloadingAction = JA.isHostOffloading(Action::OFK_OpenMP) ||
206 JA.isHostOffloading(C.getActiveOffloadKinds());
207
208 // Skips the primary input file, which is the input file that the compilation
209 // proccess will be executed upon (e.g. the host bitcode file) and
210 // adds other secondary input (e.g. device bitcode files for embedding to the
211 // -fembed-offload-object argument or the host IR file for proccessing
212 // during device compilation to the fopenmp-host-ir-file-path argument via
213 // OpenMPDeviceInput). This is condensed logic from the ConstructJob
214 // function inside of the Clang driver for pushing on further input arguments
215 // needed for offloading during various phases of compilation.
216 for (size_t i = 1; i < Inputs.size(); ++i) {
217 if (Inputs[i].getType() == types::TY_Nothing) {
218 // contains nothing, so it's skippable
219 } else if (IsHostOffloadingAction) {
220 CmdArgs.push_back(
221 Args.MakeArgString("-fembed-offload-object=" +
222 getToolChain().getInputFilename(Inputs[i])));
223 } else if (IsOpenMPDevice) {
224 if (Inputs[i].getFilename()) {
225 CmdArgs.push_back("-fopenmp-host-ir-file-path");
226 CmdArgs.push_back(Args.MakeArgString(Inputs[i].getFilename()));
227 } else {
228 llvm_unreachable("missing openmp host-ir file for device offloading");
229 }
230 } else {
231 llvm_unreachable(
232 "unexpectedly given multiple inputs or given unknown input");
233 }
234 }
235
236 if (IsOpenMPDevice) {
237 // -fopenmp-is-target-device is passed along to tell the frontend that it is
238 // generating code for a device, so that only the relevant code is emitted.
239 CmdArgs.push_back("-fopenmp-is-target-device");
240
241 // When in OpenMP offloading mode, enable debugging on the device.
242 Args.AddAllArgs(CmdArgs, options::OPT_fopenmp_target_debug_EQ);
243 if (Args.hasFlag(options::OPT_fopenmp_target_debug,
244 options::OPT_fno_openmp_target_debug, /*Default=*/false))
245 CmdArgs.push_back("-fopenmp-target-debug");
246
247 // When in OpenMP offloading mode, forward assumptions information about
248 // thread and team counts in the device.
249 if (Args.hasFlag(options::OPT_fopenmp_assume_teams_oversubscription,
250 options::OPT_fno_openmp_assume_teams_oversubscription,
251 /*Default=*/false))
252 CmdArgs.push_back("-fopenmp-assume-teams-oversubscription");
253 if (Args.hasFlag(options::OPT_fopenmp_assume_threads_oversubscription,
254 options::OPT_fno_openmp_assume_threads_oversubscription,
255 /*Default=*/false))
256 CmdArgs.push_back("-fopenmp-assume-threads-oversubscription");
257 if (Args.hasArg(options::OPT_fopenmp_assume_no_thread_state))
258 CmdArgs.push_back("-fopenmp-assume-no-thread-state");
259 if (Args.hasArg(options::OPT_fopenmp_assume_no_nested_parallelism))
260 CmdArgs.push_back("-fopenmp-assume-no-nested-parallelism");
261 }
262}
263
264static void addFloatingPointOptions(const Driver &D, const ArgList &Args,
265 ArgStringList &CmdArgs) {
266 StringRef FPContract;
267 bool HonorINFs = true;
268 bool HonorNaNs = true;
269 bool ApproxFunc = false;
270 bool SignedZeros = true;
271 bool AssociativeMath = false;
272 bool ReciprocalMath = false;
273
274 if (const Arg *A = Args.getLastArg(options::OPT_ffp_contract)) {
275 const StringRef Val = A->getValue();
276 if (Val == "fast" || Val == "off") {
277 FPContract = Val;
278 } else if (Val == "on") {
279 // Warn instead of error because users might have makefiles written for
280 // gfortran (which accepts -ffp-contract=on)
281 D.Diag(diag::warn_drv_unsupported_option_for_flang)
282 << Val << A->getOption().getName() << "off";
283 FPContract = "off";
284 } else
285 // Clang's "fast-honor-pragmas" option is not supported because it is
286 // non-standard
287 D.Diag(diag::err_drv_unsupported_option_argument)
288 << A->getSpelling() << Val;
289 }
290
291 for (const Arg *A : Args) {
292 auto optId = A->getOption().getID();
293 switch (optId) {
294 // if this isn't an FP option, skip the claim below
295 default:
296 continue;
297
298 case options::OPT_fhonor_infinities:
299 HonorINFs = true;
300 break;
301 case options::OPT_fno_honor_infinities:
302 HonorINFs = false;
303 break;
304 case options::OPT_fhonor_nans:
305 HonorNaNs = true;
306 break;
307 case options::OPT_fno_honor_nans:
308 HonorNaNs = false;
309 break;
310 case options::OPT_fapprox_func:
311 ApproxFunc = true;
312 break;
313 case options::OPT_fno_approx_func:
314 ApproxFunc = false;
315 break;
316 case options::OPT_fsigned_zeros:
317 SignedZeros = true;
318 break;
319 case options::OPT_fno_signed_zeros:
320 SignedZeros = false;
321 break;
322 case options::OPT_fassociative_math:
323 AssociativeMath = true;
324 break;
325 case options::OPT_fno_associative_math:
326 AssociativeMath = false;
327 break;
328 case options::OPT_freciprocal_math:
329 ReciprocalMath = true;
330 break;
331 case options::OPT_fno_reciprocal_math:
332 ReciprocalMath = false;
333 break;
334 case options::OPT_Ofast:
335 [[fallthrough]];
336 case options::OPT_ffast_math:
337 HonorINFs = false;
338 HonorNaNs = false;
339 AssociativeMath = true;
340 ReciprocalMath = true;
341 ApproxFunc = true;
342 SignedZeros = false;
343 FPContract = "fast";
344 break;
345 case options::OPT_fno_fast_math:
346 HonorINFs = true;
347 HonorNaNs = true;
348 AssociativeMath = false;
349 ReciprocalMath = false;
350 ApproxFunc = false;
351 SignedZeros = true;
352 // -fno-fast-math should undo -ffast-math so I return FPContract to the
353 // default. It is important to check it is "fast" (the default) so that
354 // --ffp-contract=off -fno-fast-math --> -ffp-contract=off
355 if (FPContract == "fast")
356 FPContract = "";
357 break;
358 }
359
360 // If we handled this option claim it
361 A->claim();
362 }
363
364 if (!HonorINFs && !HonorNaNs && AssociativeMath && ReciprocalMath &&
365 ApproxFunc && !SignedZeros &&
366 (FPContract == "fast" || FPContract == "")) {
367 CmdArgs.push_back("-ffast-math");
368 return;
369 }
370
371 if (!FPContract.empty())
372 CmdArgs.push_back(Args.MakeArgString("-ffp-contract=" + FPContract));
373
374 if (!HonorINFs)
375 CmdArgs.push_back("-menable-no-infs");
376
377 if (!HonorNaNs)
378 CmdArgs.push_back("-menable-no-nans");
379
380 if (ApproxFunc)
381 CmdArgs.push_back("-fapprox-func");
382
383 if (!SignedZeros)
384 CmdArgs.push_back("-fno-signed-zeros");
385
386 if (AssociativeMath && !SignedZeros)
387 CmdArgs.push_back("-mreassociate");
388
389 if (ReciprocalMath)
390 CmdArgs.push_back("-freciprocal-math");
391}
392
393static void renderRemarksOptions(const ArgList &Args, ArgStringList &CmdArgs,
394 const InputInfo &Input) {
395 StringRef Format = "yaml";
396 if (const Arg *A = Args.getLastArg(options::OPT_fsave_optimization_record_EQ))
397 Format = A->getValue();
398
399 CmdArgs.push_back("-opt-record-file");
400
401 const Arg *A = Args.getLastArg(options::OPT_foptimization_record_file_EQ);
402 if (A) {
403 CmdArgs.push_back(A->getValue());
404 } else {
406
407 if (Args.hasArg(options::OPT_c) || Args.hasArg(options::OPT_S)) {
408 if (Arg *FinalOutput = Args.getLastArg(options::OPT_o))
409 F = FinalOutput->getValue();
410 }
411
412 if (F.empty()) {
413 // Use the input filename.
414 F = llvm::sys::path::stem(Input.getBaseInput());
415 }
416
417 SmallString<32> Extension;
418 Extension += "opt.";
419 Extension += Format;
420
421 llvm::sys::path::replace_extension(F, Extension);
422 CmdArgs.push_back(Args.MakeArgString(F));
423 }
424
425 if (const Arg *A =
426 Args.getLastArg(options::OPT_foptimization_record_passes_EQ)) {
427 CmdArgs.push_back("-opt-record-passes");
428 CmdArgs.push_back(A->getValue());
429 }
430
431 if (!Format.empty()) {
432 CmdArgs.push_back("-opt-record-format");
433 CmdArgs.push_back(Format.data());
434 }
435}
436
438 const InputInfo &Output, const InputInfoList &Inputs,
439 const ArgList &Args, const char *LinkingOutput) const {
440 const auto &TC = getToolChain();
441 const llvm::Triple &Triple = TC.getEffectiveTriple();
442 const std::string &TripleStr = Triple.getTriple();
443
444 const Driver &D = TC.getDriver();
445 ArgStringList CmdArgs;
446 DiagnosticsEngine &Diags = D.getDiags();
447
448 // Invoke ourselves in -fc1 mode.
449 CmdArgs.push_back("-fc1");
450
451 // Add the "effective" target triple.
452 CmdArgs.push_back("-triple");
453 CmdArgs.push_back(Args.MakeArgString(TripleStr));
454
455 if (isa<PreprocessJobAction>(JA)) {
456 CmdArgs.push_back("-E");
457 } else if (isa<CompileJobAction>(JA) || isa<BackendJobAction>(JA)) {
458 if (JA.getType() == types::TY_Nothing) {
459 CmdArgs.push_back("-fsyntax-only");
460 } else if (JA.getType() == types::TY_AST) {
461 CmdArgs.push_back("-emit-ast");
462 } else if (JA.getType() == types::TY_LLVM_IR ||
463 JA.getType() == types::TY_LTO_IR) {
464 CmdArgs.push_back("-emit-llvm");
465 } else if (JA.getType() == types::TY_LLVM_BC ||
466 JA.getType() == types::TY_LTO_BC) {
467 CmdArgs.push_back("-emit-llvm-bc");
468 } else if (JA.getType() == types::TY_PP_Asm) {
469 CmdArgs.push_back("-S");
470 } else {
471 assert(false && "Unexpected output type!");
472 }
473 } else if (isa<AssembleJobAction>(JA)) {
474 CmdArgs.push_back("-emit-obj");
475 } else {
476 assert(false && "Unexpected action class for Flang tool.");
477 }
478
479 const InputInfo &Input = Inputs[0];
480 types::ID InputType = Input.getType();
481
482 // Add preprocessing options like -I, -D, etc. if we are using the
483 // preprocessor (i.e. skip when dealing with e.g. binary files).
485 addPreprocessingOptions(Args, CmdArgs);
486
487 addFortranDialectOptions(Args, CmdArgs);
488
489 // Color diagnostics are parsed by the driver directly from argv and later
490 // re-parsed to construct this job; claim any possible color diagnostic here
491 // to avoid warn_drv_unused_argument.
492 Args.getLastArg(options::OPT_fcolor_diagnostics,
493 options::OPT_fno_color_diagnostics);
494 if (Diags.getDiagnosticOptions().ShowColors)
495 CmdArgs.push_back("-fcolor-diagnostics");
496
497 // LTO mode is parsed by the Clang driver library.
498 LTOKind LTOMode = D.getLTOMode(/* IsOffload */ false);
499 assert(LTOMode != LTOK_Unknown && "Unknown LTO mode.");
500 if (LTOMode == LTOK_Full)
501 CmdArgs.push_back("-flto=full");
502 else if (LTOMode == LTOK_Thin) {
503 Diags.Report(
505 "the option '-flto=thin' is a work in progress"));
506 CmdArgs.push_back("-flto=thin");
507 }
508
509 // -fPIC and related options.
510 addPicOptions(Args, CmdArgs);
511
512 // Floating point related options
513 addFloatingPointOptions(D, Args, CmdArgs);
514
515 // Add target args, features, etc.
516 addTargetOptions(Args, CmdArgs);
517
518 // Add Codegen options
519 addCodegenOptions(Args, CmdArgs);
520
521 // Add R Group options
522 Args.AddAllArgs(CmdArgs, options::OPT_R_Group);
523
524 // Remarks can be enabled with any of the `-f.*optimization-record.*` flags.
525 if (willEmitRemarks(Args))
526 renderRemarksOptions(Args, CmdArgs, Input);
527
528 // Add other compile options
529 addOtherOptions(Args, CmdArgs);
530
531 // Offloading related options
532 addOffloadOptions(C, Inputs, JA, Args, CmdArgs);
533
534 // Forward -Xflang arguments to -fc1
535 Args.AddAllArgValues(CmdArgs, options::OPT_Xflang);
536
537 // Forward -mllvm options to the LLVM option parser. In practice, this means
538 // forwarding to `-fc1` as that's where the LLVM parser is run.
539 for (const Arg *A : Args.filtered(options::OPT_mllvm)) {
540 A->claim();
541 A->render(Args, CmdArgs);
542 }
543
544 for (const Arg *A : Args.filtered(options::OPT_mmlir)) {
545 A->claim();
546 A->render(Args, CmdArgs);
547 }
548
549 // Remove any unsupported gfortran diagnostic options
550 for (const Arg *A : Args.filtered(options::OPT_flang_ignored_w_Group)) {
551 A->claim();
552 D.Diag(diag::warn_drv_unsupported_diag_option_for_flang)
553 << A->getOption().getName();
554 }
555
556 // Optimization level for CodeGen.
557 if (const Arg *A = Args.getLastArg(options::OPT_O_Group)) {
558 if (A->getOption().matches(options::OPT_O4)) {
559 CmdArgs.push_back("-O3");
560 D.Diag(diag::warn_O4_is_O3);
561 } else if (A->getOption().matches(options::OPT_Ofast)) {
562 CmdArgs.push_back("-O3");
563 } else {
564 A->render(Args, CmdArgs);
565 }
566 }
567
568 assert((Output.isFilename() || Output.isNothing()) && "Invalid output.");
569 if (Output.isFilename()) {
570 CmdArgs.push_back("-o");
571 CmdArgs.push_back(Output.getFilename());
572 }
573
574 assert(Input.isFilename() && "Invalid input.");
575
576 if (Args.getLastArg(options::OPT_save_temps_EQ))
577 Args.AddLastArg(CmdArgs, options::OPT_save_temps_EQ);
578
579 addDashXForInput(Args, Input, CmdArgs);
580
581 CmdArgs.push_back(Input.getFilename());
582
583 // TODO: Replace flang-new with flang once the new driver replaces the
584 // throwaway driver
585 const char *Exec = Args.MakeArgString(D.GetProgramPath("flang-new", TC));
586 C.addCommand(std::make_unique<Command>(JA, *this,
588 Exec, CmdArgs, Inputs, Output));
589}
590
591Flang::Flang(const ToolChain &TC) : Tool("flang-new", "flang frontend", TC) {}
592
static void addDashXForInput(const ArgList &Args, const InputInfo &Input, ArgStringList &CmdArgs)
Add -x lang to CmdArgs for Input.
Definition: Clang.cpp:677
static void renderRemarksOptions(const ArgList &Args, ArgStringList &CmdArgs, const llvm::Triple &Triple, const InputInfo &Input, const InputInfo &Output, const JobAction &JA)
Definition: Clang.cpp:1464
static bool shouldLoopVersion(const ArgList &Args)
@C shouldLoopVersion
Definition: Flang.cpp:82
static void addDashXForInput(const ArgList &Args, const InputInfo &Input, ArgStringList &CmdArgs)
Add -x lang to CmdArgs for Input.
Definition: Flang.cpp:26
static void addFloatingPointOptions(const Driver &D, const ArgList &Args, ArgStringList &CmdArgs)
Definition: Flang.cpp:264
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:192
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Definition: Diagnostic.h:1542
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
Definition: Diagnostic.h:868
DiagnosticOptions & getDiagnosticOptions() const
Retrieve the diagnostic options.
Definition: Diagnostic.h:557
types::ID getType() const
Definition: Action.h:148
bool isHostOffloading(unsigned int OKind) const
Check if this action have any offload kinds.
Definition: Action.h:218
bool isDeviceOffloading(OffloadKind OKind) const
Definition: Action.h:221
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:45
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:77
DiagnosticsEngine & getDiags() const
Definition: Driver.h:390
DiagnosticBuilder Diag(unsigned DiagID) const
Definition: Driver.h:144
LTOKind getLTOMode(bool IsOffload=false) const
Get the specific kind of LTO being performed.
Definition: Driver.h:704
std::string GetProgramPath(StringRef Name, const ToolChain &TC) const
GetProgramPath - Lookup Name in the list of program search paths.
Definition: Driver.cpp:6082
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
const char * getBaseInput() const
Definition: InputInfo.h:78
const char * getFilename() const
Definition: InputInfo.h:83
bool isNothing() const
Definition: InputInfo.h:74
bool isFilename() const
Definition: InputInfo.h:75
types::ID getType() const
Definition: InputInfo.h:77
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:92
llvm::Triple::ArchType getArch() const
Definition: ToolChain.h:261
const Driver & getDriver() const
Definition: ToolChain.h:245
const llvm::Triple & getEffectiveTriple() const
Get the toolchain's effective clang triple.
Definition: ToolChain.h:275
Tool - Information on a specific compilation tool.
Definition: Tool.h:32
const ToolChain & getToolChain() const
Definition: Tool.h:52
Flang(const ToolChain &TC)
Definition: Flang.cpp:591
void ConstructJob(Compilation &C, const JobAction &JA, const InputInfo &Output, const InputInfoList &Inputs, const llvm::opt::ArgList &TCArgs, const char *LinkingOutput) const override
ConstructJob - Construct jobs to perform the action JA, writing to Output and with Inputs,...
Definition: Flang.cpp:437
void getTargetFeatures(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, bool ForAS, bool IsAux=false)
std::string getCPUName(const Driver &D, const llvm::opt::ArgList &Args, const llvm::Triple &T, bool FromAs=false)
void addDebugInfoKind(llvm::opt::ArgStringList &CmdArgs, llvm::codegenoptions::DebugInfoKind DebugInfoKind)
llvm::codegenoptions::DebugInfoKind debugLevelToInfoKind(const llvm::opt::Arg &A)
std::tuple< llvm::Reloc::Model, unsigned, bool > ParsePICArgs(const ToolChain &ToolChain, const llvm::opt::ArgList &Args)
const char * RelocationModelName(llvm::Reloc::Model Model)
ID getPreprocessedType(ID Id)
getPreprocessedType - Get the ID of the type for this input when it has been preprocessed,...
Definition: Types.cpp:56
const char * getTypeName(ID Id)
getTypeName - Return the name of the type for Id.
Definition: Types.cpp:52
LTOKind
Describes the kind of LTO mode selected via -f(no-)?lto(=.*)? options.
Definition: Driver.h:58
@ LTOK_Unknown
Definition: Driver.h:62
bool willEmitRemarks(const llvm::opt::ArgList &Args)
@ C
Languages that the frontend can parse and compile.
static constexpr ResponseFileSupport AtFileUTF8()
Definition: Job.h:85