| 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 | #include "Flang.h" |
| 10 | #include "Arch/RISCV.h" |
| 11 | #include "Cuda.h" |
| 12 | |
| 13 | #include "clang/Basic/CodeGenOptions.h" |
| 14 | #include "clang/Driver/CommonArgs.h" |
| 15 | #include "clang/Options/OptionUtils.h" |
| 16 | #include "clang/Options/Options.h" |
| 17 | #include "llvm/Frontend/Debug/Options.h" |
| 18 | #include "llvm/Support/Path.h" |
| 19 | #include "llvm/TargetParser/Host.h" |
| 20 | #include "llvm/TargetParser/RISCVISAInfo.h" |
| 21 | #include "llvm/TargetParser/RISCVTargetParser.h" |
| 22 | |
| 23 | #include <cassert> |
| 24 | |
| 25 | using namespace clang::driver; |
| 26 | using namespace clang::driver::tools; |
| 27 | using namespace clang; |
| 28 | using namespace llvm::opt; |
| 29 | |
| 30 | /// Add -x lang to \p CmdArgs for \p Input. |
| 31 | static void addDashXForInput(const ArgList &Args, const InputInfo &Input, |
| 32 | ArgStringList &CmdArgs) { |
| 33 | CmdArgs.push_back(Elt: "-x" ); |
| 34 | // Map the driver type to the frontend type. |
| 35 | CmdArgs.push_back(Elt: types::getTypeName(Id: Input.getType())); |
| 36 | } |
| 37 | |
| 38 | void Flang::addFortranDialectOptions(const ArgList &Args, |
| 39 | ArgStringList &CmdArgs) const { |
| 40 | Args.addAllArgs(Output&: CmdArgs, Ids: {options::OPT_ffixed_form, |
| 41 | options::OPT_ffree_form, |
| 42 | options::OPT_ffixed_line_length_EQ, |
| 43 | options::OPT_fopenacc, |
| 44 | options::OPT_finput_charset_EQ, |
| 45 | options::OPT_fimplicit_none, |
| 46 | options::OPT_fimplicit_none_ext, |
| 47 | options::OPT_fno_implicit_none, |
| 48 | options::OPT_fbackslash, |
| 49 | options::OPT_fno_backslash, |
| 50 | options::OPT_flogical_abbreviations, |
| 51 | options::OPT_fno_logical_abbreviations, |
| 52 | options::OPT_fxor_operator, |
| 53 | options::OPT_fno_xor_operator, |
| 54 | options::OPT_falternative_parameter_statement, |
| 55 | options::OPT_fdefault_integer_4, |
| 56 | options::OPT_fdefault_real_4, |
| 57 | options::OPT_fdefault_real_8, |
| 58 | options::OPT_fdefault_integer_8, |
| 59 | options::OPT_fdefault_double_8, |
| 60 | options::OPT_flarge_sizes, |
| 61 | options::OPT_fno_automatic, |
| 62 | options::OPT_fhermetic_module_files, |
| 63 | options::OPT_frealloc_lhs, |
| 64 | options::OPT_fno_realloc_lhs, |
| 65 | options::OPT_fsave_main_program, |
| 66 | options::OPT_fd_lines_as_code, |
| 67 | options::OPT_fd_lines_as_comments, |
| 68 | options::OPT_fno_save_main_program}); |
| 69 | } |
| 70 | |
| 71 | void Flang::addPreprocessingOptions(const ArgList &Args, |
| 72 | ArgStringList &CmdArgs) const { |
| 73 | Args.addAllArgs(Output&: CmdArgs, |
| 74 | Ids: {options::OPT_P, options::OPT_D, options::OPT_U, |
| 75 | options::OPT_I, options::OPT_cpp, options::OPT_nocpp}); |
| 76 | } |
| 77 | |
| 78 | /// @C shouldLoopVersion |
| 79 | /// |
| 80 | /// Check if Loop Versioning should be enabled. |
| 81 | /// We look for the last of one of the following: |
| 82 | /// -Ofast, -O4, -O<number> and -f[no-]version-loops-for-stride. |
| 83 | /// Loop versioning is disabled if the last option is |
| 84 | /// -fno-version-loops-for-stride. |
| 85 | /// Loop versioning is enabled if the last option is one of: |
| 86 | /// -floop-versioning |
| 87 | /// -Ofast |
| 88 | /// -O4 |
| 89 | /// -O3 |
| 90 | /// For all other cases, loop versioning is is disabled. |
| 91 | /// |
| 92 | /// The gfortran compiler automatically enables the option for -O3 or -Ofast. |
| 93 | /// |
| 94 | /// @return true if loop-versioning should be enabled, otherwise false. |
| 95 | static bool shouldLoopVersion(const ArgList &Args) { |
| 96 | const Arg *LoopVersioningArg = Args.getLastArg( |
| 97 | Ids: options::OPT_Ofast, Ids: options::OPT_O, Ids: options::OPT_O4, |
| 98 | Ids: options::OPT_floop_versioning, Ids: options::OPT_fno_loop_versioning); |
| 99 | if (!LoopVersioningArg) |
| 100 | return false; |
| 101 | |
| 102 | if (LoopVersioningArg->getOption().matches(ID: options::OPT_fno_loop_versioning)) |
| 103 | return false; |
| 104 | |
| 105 | if (LoopVersioningArg->getOption().matches(ID: options::OPT_floop_versioning)) |
| 106 | return true; |
| 107 | |
| 108 | if (LoopVersioningArg->getOption().matches(ID: options::OPT_Ofast) || |
| 109 | LoopVersioningArg->getOption().matches(ID: options::OPT_O4)) |
| 110 | return true; |
| 111 | |
| 112 | if (LoopVersioningArg->getOption().matches(ID: options::OPT_O)) { |
| 113 | StringRef S(LoopVersioningArg->getValue()); |
| 114 | unsigned OptLevel = 0; |
| 115 | // Note -Os or Oz woould "fail" here, so return false. Which is the |
| 116 | // desiered behavior. |
| 117 | if (S.getAsInteger(Radix: 10, Result&: OptLevel)) |
| 118 | return false; |
| 119 | |
| 120 | return OptLevel > 2; |
| 121 | } |
| 122 | |
| 123 | llvm_unreachable("We should not end up here" ); |
| 124 | return false; |
| 125 | } |
| 126 | |
| 127 | void Flang::addDebugOptions(const llvm::opt::ArgList &Args, const JobAction &JA, |
| 128 | const InputInfo &Output, const InputInfo &Input, |
| 129 | llvm::opt::ArgStringList &CmdArgs) const { |
| 130 | const auto &TC = getToolChain(); |
| 131 | const Driver &D = TC.getDriver(); |
| 132 | Args.addAllArgs(Output&: CmdArgs, |
| 133 | Ids: {options::OPT_module_dir, options::OPT_fdebug_module_writer, |
| 134 | options::OPT_fintrinsic_modules_path, options::OPT_pedantic, |
| 135 | options::OPT_std_EQ, options::OPT_W_Joined, |
| 136 | options::OPT_fconvert_EQ, options::OPT_fpass_plugin_EQ, |
| 137 | options::OPT_funderscoring, options::OPT_fno_underscoring, |
| 138 | options::OPT_funsigned, options::OPT_fno_unsigned, |
| 139 | options::OPT_finstrument_functions}); |
| 140 | |
| 141 | llvm::codegenoptions::DebugInfoKind DebugInfoKind; |
| 142 | bool hasDwarfNArg = getDwarfNArg(Args) != nullptr; |
| 143 | if (Args.hasArg(Ids: options::OPT_gN_Group)) { |
| 144 | Arg *gNArg = Args.getLastArg(Ids: options::OPT_gN_Group); |
| 145 | DebugInfoKind = debugLevelToInfoKind(A: *gNArg); |
| 146 | } else if (Args.hasArg(Ids: options::OPT_g_Flag) || hasDwarfNArg) { |
| 147 | DebugInfoKind = llvm::codegenoptions::FullDebugInfo; |
| 148 | } else { |
| 149 | DebugInfoKind = llvm::codegenoptions::NoDebugInfo; |
| 150 | } |
| 151 | addDebugInfoKind(CmdArgs, DebugInfoKind); |
| 152 | if (hasDwarfNArg) { |
| 153 | const unsigned DwarfVersion = getDwarfVersion(TC: getToolChain(), Args); |
| 154 | CmdArgs.push_back( |
| 155 | Elt: Args.MakeArgString(Str: "-dwarf-version=" + Twine(DwarfVersion))); |
| 156 | } |
| 157 | if (Args.hasArg(Ids: options::OPT_gsplit_dwarf) || |
| 158 | Args.hasArg(Ids: options::OPT_gsplit_dwarf_EQ)) { |
| 159 | // FIXME: -gsplit-dwarf on AIX is currently unimplemented. |
| 160 | if (TC.getTriple().isOSAIX()) { |
| 161 | D.Diag(DiagID: diag::err_drv_unsupported_opt_for_target) |
| 162 | << Args.getLastArg(Ids: options::OPT_gsplit_dwarf)->getSpelling() |
| 163 | << TC.getTriple().str(); |
| 164 | return; |
| 165 | } |
| 166 | if (DebugInfoKind == llvm::codegenoptions::NoDebugInfo) |
| 167 | return; |
| 168 | |
| 169 | Arg *SplitDWARFArg; |
| 170 | DwarfFissionKind DwarfFission = getDebugFissionKind(D, Args, Arg&: SplitDWARFArg); |
| 171 | |
| 172 | if (DwarfFission == DwarfFissionKind::None || |
| 173 | !checkDebugInfoOption(A: SplitDWARFArg, Args, D, TC)) |
| 174 | return; |
| 175 | |
| 176 | if (!TC.getTriple().isOSBinFormatELF() && |
| 177 | !TC.getTriple().isOSBinFormatWasm() && |
| 178 | !TC.getTriple().isOSBinFormatCOFF()) { |
| 179 | D.Diag(DiagID: diag::warn_drv_unsupported_debug_info_opt_for_target) |
| 180 | << SplitDWARFArg->getSpelling() << TC.getTriple().str(); |
| 181 | return; |
| 182 | } |
| 183 | |
| 184 | if (!isa<AssembleJobAction>(Val: JA) && !isa<CompileJobAction>(Val: JA) && |
| 185 | isa<BackendJobAction>(Val: JA)) |
| 186 | return; |
| 187 | |
| 188 | const char *SplitDWARFOut = SplitDebugName(JA, Args, Input, Output); |
| 189 | CmdArgs.push_back(Elt: "-split-dwarf-file" ); |
| 190 | CmdArgs.push_back(Elt: SplitDWARFOut); |
| 191 | if (DwarfFission == DwarfFissionKind::Split) { |
| 192 | CmdArgs.push_back(Elt: "-split-dwarf-output" ); |
| 193 | CmdArgs.push_back(Elt: SplitDWARFOut); |
| 194 | } |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | void Flang::addCodegenOptions(const ArgList &Args, |
| 199 | ArgStringList &CmdArgs) const { |
| 200 | Arg *stackArrays = |
| 201 | Args.getLastArg(Ids: options::OPT_Ofast, Ids: options::OPT_fstack_arrays, |
| 202 | Ids: options::OPT_fno_stack_arrays); |
| 203 | if (stackArrays && |
| 204 | !stackArrays->getOption().matches(ID: options::OPT_fno_stack_arrays)) |
| 205 | CmdArgs.push_back(Elt: "-fstack-arrays" ); |
| 206 | |
| 207 | if (Args.hasFlag(Pos: options::OPT_fsafe_trampoline, |
| 208 | Neg: options::OPT_fno_safe_trampoline, Default: false)) { |
| 209 | const llvm::Triple &T = getToolChain().getTriple(); |
| 210 | if (T.getArch() == llvm::Triple::x86_64 || |
| 211 | T.getArch() == llvm::Triple::aarch64 || |
| 212 | T.getArch() == llvm::Triple::aarch64_be) { |
| 213 | CmdArgs.push_back(Elt: "-fsafe-trampoline" ); |
| 214 | } else { |
| 215 | getToolChain().getDriver().Diag( |
| 216 | DiagID: diag::warn_drv_unsupported_option_for_target) |
| 217 | << "-fsafe-trampoline" << T.str(); |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | // -fno-protect-parens is the default for -Ofast. |
| 222 | if (!Args.hasFlag(Pos: options::OPT_fprotect_parens, |
| 223 | Neg: options::OPT_fno_protect_parens, |
| 224 | /*Default=*/!Args.hasArg(Ids: options::OPT_Ofast))) |
| 225 | CmdArgs.push_back(Elt: "-fno-protect-parens" ); |
| 226 | |
| 227 | if (Args.hasFlag(Pos: options::OPT_funsafe_cray_pointers, |
| 228 | Neg: options::OPT_fno_unsafe_cray_pointers, Default: false)) { |
| 229 | // TODO: currently passed as MLIR option |
| 230 | CmdArgs.push_back(Elt: "-mmlir" ); |
| 231 | CmdArgs.push_back(Elt: "-unsafe-cray-pointers" ); |
| 232 | } |
| 233 | |
| 234 | Args.addOptInFlag(Output&: CmdArgs, Pos: options::OPT_fexperimental_loop_fusion, |
| 235 | Neg: options::OPT_fno_experimental_loop_fusion); |
| 236 | |
| 237 | handleInterchangeLoopsArgs(Args, CmdArgs); |
| 238 | handleVectorizeLoopsArgs(Args, CmdArgs); |
| 239 | handleVectorizeSLPArgs(Args, CmdArgs); |
| 240 | |
| 241 | if (shouldLoopVersion(Args)) |
| 242 | CmdArgs.push_back(Elt: "-fversion-loops-for-stride" ); |
| 243 | |
| 244 | for (const auto &arg : |
| 245 | Args.getAllArgValues(Id: options::OPT_frepack_arrays_contiguity_EQ)) |
| 246 | if (arg != "whole" && arg != "innermost" ) { |
| 247 | getToolChain().getDriver().Diag(DiagID: diag::err_drv_unsupported_option_argument) |
| 248 | << "-frepack-arrays-contiguity=" << arg; |
| 249 | } |
| 250 | |
| 251 | Args.addAllArgs( |
| 252 | Output&: CmdArgs, |
| 253 | Ids: {options::OPT_fdo_concurrent_to_openmp_EQ, |
| 254 | options::OPT_flang_experimental_hlfir, |
| 255 | options::OPT_flang_deprecated_no_hlfir, |
| 256 | options::OPT_fno_ppc_native_vec_elem_order, |
| 257 | options::OPT_fppc_native_vec_elem_order, options::OPT_finit_global_zero, |
| 258 | options::OPT_fno_init_global_zero, options::OPT_frepack_arrays, |
| 259 | options::OPT_fno_repack_arrays, |
| 260 | options::OPT_frepack_arrays_contiguity_EQ, |
| 261 | options::OPT_fstack_repack_arrays, options::OPT_fno_stack_repack_arrays, |
| 262 | options::OPT_ftime_report, options::OPT_ftime_report_EQ, |
| 263 | options::OPT_funroll_loops, options::OPT_fno_unroll_loops}); |
| 264 | if (Args.hasArg(Ids: options::OPT_fcoarray)) |
| 265 | CmdArgs.push_back(Elt: "-fcoarray" ); |
| 266 | } |
| 267 | |
| 268 | void Flang::addLTOOptions(const ArgList &Args, ArgStringList &CmdArgs) const { |
| 269 | const ToolChain &TC = getToolChain(); |
| 270 | const Driver &D = TC.getDriver(); |
| 271 | DiagnosticsEngine &Diags = D.getDiags(); |
| 272 | LTOKind LTOMode = D.getLTOMode(); |
| 273 | // LTO mode is parsed by the Clang driver library. |
| 274 | assert(LTOMode != LTOK_Unknown && "Unknown LTO mode." ); |
| 275 | if (LTOMode == LTOK_Full) |
| 276 | CmdArgs.push_back(Elt: "-flto=full" ); |
| 277 | else if (LTOMode == LTOK_Thin) { |
| 278 | Diags.Report( |
| 279 | DiagID: Diags.getCustomDiagID(L: DiagnosticsEngine::Warning, |
| 280 | FormatString: "the option '-flto=thin' is a work in progress" )); |
| 281 | CmdArgs.push_back(Elt: "-flto=thin" ); |
| 282 | } |
| 283 | Args.addAllArgs(Output&: CmdArgs, Ids: {options::OPT_ffat_lto_objects, |
| 284 | options::OPT_fno_fat_lto_objects}); |
| 285 | } |
| 286 | |
| 287 | void Flang::addPicOptions(const ArgList &Args, ArgStringList &CmdArgs) const { |
| 288 | // ParsePICArgs parses -fPIC/-fPIE and their variants and returns a tuple of |
| 289 | // (RelocationModel, PICLevel, IsPIE). |
| 290 | llvm::Reloc::Model RelocationModel; |
| 291 | unsigned PICLevel; |
| 292 | bool IsPIE; |
| 293 | std::tie(args&: RelocationModel, args&: PICLevel, args&: IsPIE) = |
| 294 | ParsePICArgs(ToolChain: getToolChain(), Args); |
| 295 | |
| 296 | if (auto *RMName = RelocationModelName(Model: RelocationModel)) { |
| 297 | CmdArgs.push_back(Elt: "-mrelocation-model" ); |
| 298 | CmdArgs.push_back(Elt: RMName); |
| 299 | } |
| 300 | if (PICLevel > 0) { |
| 301 | CmdArgs.push_back(Elt: "-pic-level" ); |
| 302 | CmdArgs.push_back(Elt: PICLevel == 1 ? "1" : "2" ); |
| 303 | if (IsPIE) |
| 304 | CmdArgs.push_back(Elt: "-pic-is-pie" ); |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | void Flang::AddAArch64TargetArgs(const ArgList &Args, |
| 309 | ArgStringList &CmdArgs) const { |
| 310 | // Handle -msve_vector_bits=<bits> |
| 311 | if (Arg *A = Args.getLastArg(Ids: options::OPT_msve_vector_bits_EQ)) { |
| 312 | StringRef Val = A->getValue(); |
| 313 | const Driver &D = getToolChain().getDriver(); |
| 314 | if (Val == "128" || Val == "256" || Val == "512" || Val == "1024" || |
| 315 | Val == "2048" || Val == "128+" || Val == "256+" || Val == "512+" || |
| 316 | Val == "1024+" || Val == "2048+" ) { |
| 317 | unsigned Bits = 0; |
| 318 | if (!Val.consume_back(Suffix: "+" )) { |
| 319 | [[maybe_unused]] bool Invalid = Val.getAsInteger(Radix: 10, Result&: Bits); |
| 320 | assert(!Invalid && "Failed to parse value" ); |
| 321 | CmdArgs.push_back( |
| 322 | Elt: Args.MakeArgString(Str: "-mvscale-max=" + llvm::Twine(Bits / 128))); |
| 323 | } |
| 324 | |
| 325 | [[maybe_unused]] bool Invalid = Val.getAsInteger(Radix: 10, Result&: Bits); |
| 326 | assert(!Invalid && "Failed to parse value" ); |
| 327 | CmdArgs.push_back( |
| 328 | Elt: Args.MakeArgString(Str: "-mvscale-min=" + llvm::Twine(Bits / 128))); |
| 329 | // Silently drop requests for vector-length agnostic code as it's implied. |
| 330 | } else if (Val != "scalable" ) |
| 331 | // Handle the unsupported values passed to msve-vector-bits. |
| 332 | D.Diag(DiagID: diag::err_drv_unsupported_option_argument) |
| 333 | << A->getSpelling() << Val; |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | void Flang::AddLoongArch64TargetArgs(const ArgList &Args, |
| 338 | ArgStringList &CmdArgs) const { |
| 339 | const Driver &D = getToolChain().getDriver(); |
| 340 | // Currently, flang only support `-mabi=lp64d` in LoongArch64. |
| 341 | if (const Arg *A = Args.getLastArg(Ids: options::OPT_mabi_EQ)) { |
| 342 | StringRef V = A->getValue(); |
| 343 | if (V != "lp64d" ) { |
| 344 | D.Diag(DiagID: diag::err_drv_argument_not_allowed_with) << "-mabi" << V; |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | if (const Arg *A = Args.getLastArg(Ids: options::OPT_mannotate_tablejump, |
| 349 | Ids: options::OPT_mno_annotate_tablejump)) { |
| 350 | if (A->getOption().matches(ID: options::OPT_mannotate_tablejump)) { |
| 351 | CmdArgs.push_back(Elt: "-mllvm" ); |
| 352 | CmdArgs.push_back(Elt: "-loongarch-annotate-tablejump" ); |
| 353 | } |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | void Flang::AddPPCTargetArgs(const ArgList &Args, |
| 358 | ArgStringList &CmdArgs) const { |
| 359 | const Driver &D = getToolChain().getDriver(); |
| 360 | bool VecExtabi = false; |
| 361 | |
| 362 | if (const Arg *A = Args.getLastArg(Ids: options::OPT_mabi_EQ)) { |
| 363 | StringRef V = A->getValue(); |
| 364 | if (V == "vec-extabi" ) |
| 365 | VecExtabi = true; |
| 366 | else if (V == "vec-default" ) |
| 367 | VecExtabi = false; |
| 368 | else |
| 369 | D.Diag(DiagID: diag::err_drv_unsupported_option_argument) |
| 370 | << A->getSpelling() << V; |
| 371 | } |
| 372 | |
| 373 | const llvm::Triple &T = getToolChain().getTriple(); |
| 374 | if (VecExtabi) { |
| 375 | if (!T.isOSAIX()) { |
| 376 | D.Diag(DiagID: diag::err_drv_unsupported_opt_for_target) |
| 377 | << "-mabi=vec-extabi" << T.str(); |
| 378 | } |
| 379 | CmdArgs.push_back(Elt: "-mabi=vec-extabi" ); |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | void Flang::AddRISCVTargetArgs(const ArgList &Args, |
| 384 | ArgStringList &CmdArgs) const { |
| 385 | const Driver &D = getToolChain().getDriver(); |
| 386 | const llvm::Triple &Triple = getToolChain().getTriple(); |
| 387 | |
| 388 | StringRef ABIName = riscv::getRISCVABI(Args, Triple); |
| 389 | if (ABIName == "lp64" || ABIName == "lp64f" || ABIName == "lp64d" ) |
| 390 | CmdArgs.push_back(Elt: Args.MakeArgString(Str: "-mabi=" + ABIName)); |
| 391 | else |
| 392 | D.Diag(DiagID: diag::err_drv_unsupported_option_argument) << "-mabi=" << ABIName; |
| 393 | |
| 394 | // Handle -mrvv-vector-bits=<bits> |
| 395 | if (Arg *A = Args.getLastArg(Ids: options::OPT_mrvv_vector_bits_EQ)) { |
| 396 | StringRef Val = A->getValue(); |
| 397 | |
| 398 | // Get minimum VLen from march. |
| 399 | unsigned MinVLen = 0; |
| 400 | std::string Arch = riscv::getRISCVArch(Args, Triple); |
| 401 | auto ISAInfo = llvm::RISCVISAInfo::parseArchString( |
| 402 | Arch, /*EnableExperimentalExtensions*/ EnableExperimentalExtension: true); |
| 403 | // Ignore parsing error. |
| 404 | if (!errorToBool(Err: ISAInfo.takeError())) |
| 405 | MinVLen = (*ISAInfo)->getMinVLen(); |
| 406 | |
| 407 | // If the value is "zvl", use MinVLen from march. Otherwise, try to parse |
| 408 | // as integer as long as we have a MinVLen. |
| 409 | unsigned Bits = 0; |
| 410 | if (Val == "zvl" && MinVLen >= llvm::RISCV::RVVBitsPerBlock) { |
| 411 | Bits = MinVLen; |
| 412 | } else if (!Val.getAsInteger(Radix: 10, Result&: Bits)) { |
| 413 | // Only accept power of 2 values beteen RVVBitsPerBlock and 65536 that |
| 414 | // at least MinVLen. |
| 415 | if (Bits < MinVLen || Bits < llvm::RISCV::RVVBitsPerBlock || |
| 416 | Bits > 65536 || !llvm::isPowerOf2_32(Value: Bits)) |
| 417 | Bits = 0; |
| 418 | } |
| 419 | |
| 420 | // If we got a valid value try to use it. |
| 421 | if (Bits != 0) { |
| 422 | unsigned VScaleMin = Bits / llvm::RISCV::RVVBitsPerBlock; |
| 423 | CmdArgs.push_back( |
| 424 | Elt: Args.MakeArgString(Str: "-mvscale-max=" + llvm::Twine(VScaleMin))); |
| 425 | CmdArgs.push_back( |
| 426 | Elt: Args.MakeArgString(Str: "-mvscale-min=" + llvm::Twine(VScaleMin))); |
| 427 | } else if (Val != "scalable" ) { |
| 428 | // Handle the unsupported values passed to mrvv-vector-bits. |
| 429 | D.Diag(DiagID: diag::err_drv_unsupported_option_argument) |
| 430 | << A->getSpelling() << Val; |
| 431 | } |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | void Flang::AddX86_64TargetArgs(const ArgList &Args, |
| 436 | ArgStringList &CmdArgs) const { |
| 437 | if (Arg *A = Args.getLastArg(Ids: options::OPT_masm_EQ)) { |
| 438 | StringRef Value = A->getValue(); |
| 439 | if (Value == "intel" || Value == "att" ) { |
| 440 | CmdArgs.push_back(Elt: Args.MakeArgString(Str: "-mllvm" )); |
| 441 | CmdArgs.push_back(Elt: Args.MakeArgString(Str: "-x86-asm-syntax=" + Value)); |
| 442 | } else { |
| 443 | getToolChain().getDriver().Diag(DiagID: diag::err_drv_unsupported_option_argument) |
| 444 | << A->getSpelling() << Value; |
| 445 | } |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | static void addVSDefines(const ToolChain &TC, const ArgList &Args, |
| 450 | ArgStringList &CmdArgs) { |
| 451 | |
| 452 | unsigned ver = 0; |
| 453 | const VersionTuple vt = TC.computeMSVCVersion(D: nullptr, Args); |
| 454 | ver = vt.getMajor() * 10000000 + vt.getMinor().value_or(u: 0) * 100000 + |
| 455 | vt.getSubminor().value_or(u: 0); |
| 456 | CmdArgs.push_back(Elt: Args.MakeArgString(Str: "-D_MSC_VER=" + Twine(ver / 100000))); |
| 457 | CmdArgs.push_back(Elt: Args.MakeArgString(Str: "-D_MSC_FULL_VER=" + Twine(ver))); |
| 458 | CmdArgs.push_back(Elt: Args.MakeArgString(Str: "-D_WIN32" )); |
| 459 | |
| 460 | const llvm::Triple &triple = TC.getTriple(); |
| 461 | if (triple.isAArch64()) { |
| 462 | CmdArgs.push_back(Elt: "-D_M_ARM64=1" ); |
| 463 | } else if (triple.isX86() && triple.isArch32Bit()) { |
| 464 | CmdArgs.push_back(Elt: "-D_M_IX86=600" ); |
| 465 | } else if (triple.isX86() && triple.isArch64Bit()) { |
| 466 | CmdArgs.push_back(Elt: "-D_M_X64=100" ); |
| 467 | } else { |
| 468 | llvm_unreachable( |
| 469 | "Flang on Windows only supports X86_32, X86_64 and AArch64" ); |
| 470 | } |
| 471 | } |
| 472 | |
| 473 | static void processVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args, |
| 474 | ArgStringList &CmdArgs) { |
| 475 | assert(TC.getTriple().isKnownWindowsMSVCEnvironment() && |
| 476 | "can only add VS runtime library on Windows!" ); |
| 477 | |
| 478 | // Flang/Clang (including clang-cl) -compiled programs targeting the MSVC ABI |
| 479 | // should only depend on msv(u)crt. LLVM still emits libgcc/compiler-rt |
| 480 | // functions in some cases like 128-bit integer math (__udivti3, __modti3, |
| 481 | // __fixsfti, __floattidf, ...) that msvc does not support. We are injecting a |
| 482 | // dependency to Compiler-RT's builtin library where these are implemented. |
| 483 | CmdArgs.push_back(Elt: Args.MakeArgString( |
| 484 | Str: "--dependent-lib=" + TC.getCompilerRTBasename(Args, Component: "builtins" ))); |
| 485 | |
| 486 | unsigned RTOptionID = options::OPT__SLASH_MT; |
| 487 | if (auto *rtl = Args.getLastArg(Ids: options::OPT_fms_runtime_lib_EQ)) { |
| 488 | RTOptionID = llvm::StringSwitch<unsigned>(rtl->getValue()) |
| 489 | .Case(S: "static" , Value: options::OPT__SLASH_MT) |
| 490 | .Case(S: "static_dbg" , Value: options::OPT__SLASH_MTd) |
| 491 | .Case(S: "dll" , Value: options::OPT__SLASH_MD) |
| 492 | .Case(S: "dll_dbg" , Value: options::OPT__SLASH_MDd) |
| 493 | .Default(Value: options::OPT__SLASH_MT); |
| 494 | } |
| 495 | switch (RTOptionID) { |
| 496 | case options::OPT__SLASH_MT: |
| 497 | CmdArgs.push_back(Elt: "-D_MT" ); |
| 498 | CmdArgs.push_back(Elt: "--dependent-lib=libcmt" ); |
| 499 | CmdArgs.push_back(Elt: "--dependent-lib=flang_rt.runtime.static.lib" ); |
| 500 | break; |
| 501 | case options::OPT__SLASH_MTd: |
| 502 | CmdArgs.push_back(Elt: "-D_MT" ); |
| 503 | CmdArgs.push_back(Elt: "-D_DEBUG" ); |
| 504 | CmdArgs.push_back(Elt: "--dependent-lib=libcmtd" ); |
| 505 | CmdArgs.push_back(Elt: "--dependent-lib=flang_rt.runtime.static_dbg.lib" ); |
| 506 | break; |
| 507 | case options::OPT__SLASH_MD: |
| 508 | CmdArgs.push_back(Elt: "-D_MT" ); |
| 509 | CmdArgs.push_back(Elt: "-D_DLL" ); |
| 510 | CmdArgs.push_back(Elt: "--dependent-lib=msvcrt" ); |
| 511 | CmdArgs.push_back(Elt: "--dependent-lib=flang_rt.runtime.dynamic.lib" ); |
| 512 | break; |
| 513 | case options::OPT__SLASH_MDd: |
| 514 | CmdArgs.push_back(Elt: "-D_MT" ); |
| 515 | CmdArgs.push_back(Elt: "-D_DEBUG" ); |
| 516 | CmdArgs.push_back(Elt: "-D_DLL" ); |
| 517 | CmdArgs.push_back(Elt: "--dependent-lib=msvcrtd" ); |
| 518 | CmdArgs.push_back(Elt: "--dependent-lib=flang_rt.runtime.dynamic_dbg.lib" ); |
| 519 | break; |
| 520 | } |
| 521 | } |
| 522 | |
| 523 | void Flang::AddAMDGPUTargetArgs(const ArgList &Args, |
| 524 | ArgStringList &CmdArgs) const { |
| 525 | if (Arg *A = Args.getLastArg(Ids: options::OPT_mcode_object_version_EQ)) { |
| 526 | StringRef Val = A->getValue(); |
| 527 | CmdArgs.push_back(Elt: Args.MakeArgString(Str: "-mcode-object-version=" + Val)); |
| 528 | CmdArgs.push_back(Elt: Args.MakeArgString(Str: "-mllvm" )); |
| 529 | CmdArgs.push_back( |
| 530 | Elt: Args.MakeArgString(Str: "--amdhsa-code-object-version=" + Val)); |
| 531 | } |
| 532 | |
| 533 | const ToolChain &TC = getToolChain(); |
| 534 | TC.addClangTargetOptions(DriverArgs: Args, CC1Args&: CmdArgs, DeviceOffloadKind: Action::OffloadKind::OFK_OpenMP); |
| 535 | } |
| 536 | |
| 537 | void Flang::AddNVPTXTargetArgs(const ArgList &Args, |
| 538 | ArgStringList &CmdArgs) const { |
| 539 | // we cannot use addClangTargetOptions, as it appends unsupported args for |
| 540 | // flang: -fcuda-is-device, -fno-threadsafe-statics, |
| 541 | // -fcuda-allow-variadic-functions and -target-sdk-version Instead we manually |
| 542 | // detect the CUDA installation and link libdevice |
| 543 | const ToolChain &TC = getToolChain(); |
| 544 | const Driver &D = TC.getDriver(); |
| 545 | const llvm::Triple &Triple = TC.getEffectiveTriple(); |
| 546 | |
| 547 | if (!Args.hasFlag(Pos: options::OPT_offloadlib, Neg: options::OPT_no_offloadlib, Default: true)) |
| 548 | return; |
| 549 | |
| 550 | // Detect CUDA installation and link libdevice |
| 551 | CudaInstallationDetector CudaInstallation(D, Triple, Args); |
| 552 | if (!CudaInstallation.isValid()) { |
| 553 | D.Diag(DiagID: diag::err_drv_no_cuda_installation); |
| 554 | return; |
| 555 | } |
| 556 | |
| 557 | StringRef GpuArch = Args.getLastArgValue(Id: options::OPT_march_EQ); |
| 558 | if (GpuArch.empty()) { |
| 559 | D.Diag(DiagID: diag::err_drv_offload_missing_gpu_arch) << "NVPTX" << "flang" ; |
| 560 | return; |
| 561 | } |
| 562 | |
| 563 | std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(Gpu: GpuArch); |
| 564 | if (LibDeviceFile.empty()) { |
| 565 | D.Diag(DiagID: diag::err_drv_no_cuda_libdevice) << GpuArch; |
| 566 | return; |
| 567 | } |
| 568 | |
| 569 | CmdArgs.push_back(Elt: "-mlink-builtin-bitcode" ); |
| 570 | CmdArgs.push_back(Elt: Args.MakeArgString(Str: LibDeviceFile)); |
| 571 | } |
| 572 | |
| 573 | void Flang::addTargetOptions(const ArgList &Args, |
| 574 | ArgStringList &CmdArgs) const { |
| 575 | const ToolChain &TC = getToolChain(); |
| 576 | const llvm::Triple &Triple = TC.getEffectiveTriple(); |
| 577 | const Driver &D = TC.getDriver(); |
| 578 | |
| 579 | std::string CPU = getCPUName(D, Args, T: Triple); |
| 580 | if (!CPU.empty()) { |
| 581 | CmdArgs.push_back(Elt: "-target-cpu" ); |
| 582 | CmdArgs.push_back(Elt: Args.MakeArgString(Str: CPU)); |
| 583 | } |
| 584 | |
| 585 | addOutlineAtomicsArgs(D, TC: getToolChain(), Args, CmdArgs, Triple); |
| 586 | |
| 587 | // Add the target features. |
| 588 | switch (TC.getArch()) { |
| 589 | default: |
| 590 | getTargetFeatures(D, Triple, Args, CmdArgs, /*ForAs*/ ForAS: false); |
| 591 | break; |
| 592 | case llvm::Triple::aarch64: |
| 593 | getTargetFeatures(D, Triple, Args, CmdArgs, /*ForAs*/ ForAS: false); |
| 594 | AddAArch64TargetArgs(Args, CmdArgs); |
| 595 | break; |
| 596 | |
| 597 | case llvm::Triple::r600: |
| 598 | case llvm::Triple::amdgcn: |
| 599 | getTargetFeatures(D, Triple, Args, CmdArgs, /*ForAs*/ ForAS: false); |
| 600 | AddAMDGPUTargetArgs(Args, CmdArgs); |
| 601 | break; |
| 602 | case llvm::Triple::nvptx: |
| 603 | case llvm::Triple::nvptx64: |
| 604 | AddNVPTXTargetArgs(Args, CmdArgs); |
| 605 | break; |
| 606 | case llvm::Triple::riscv64: |
| 607 | getTargetFeatures(D, Triple, Args, CmdArgs, /*ForAs*/ ForAS: false); |
| 608 | AddRISCVTargetArgs(Args, CmdArgs); |
| 609 | break; |
| 610 | case llvm::Triple::x86_64: |
| 611 | getTargetFeatures(D, Triple, Args, CmdArgs, /*ForAs*/ ForAS: false); |
| 612 | AddX86_64TargetArgs(Args, CmdArgs); |
| 613 | break; |
| 614 | case llvm::Triple::ppc: |
| 615 | case llvm::Triple::ppc64: |
| 616 | case llvm::Triple::ppc64le: |
| 617 | AddPPCTargetArgs(Args, CmdArgs); |
| 618 | break; |
| 619 | case llvm::Triple::loongarch64: |
| 620 | getTargetFeatures(D, Triple, Args, CmdArgs, /*ForAs*/ ForAS: false); |
| 621 | AddLoongArch64TargetArgs(Args, CmdArgs); |
| 622 | break; |
| 623 | } |
| 624 | |
| 625 | if (Arg *A = Args.getLastArg(Ids: options::OPT_fveclib)) { |
| 626 | StringRef Name = A->getValue(); |
| 627 | if (Name == "SVML" ) { |
| 628 | if (Triple.getArch() != llvm::Triple::x86 && |
| 629 | Triple.getArch() != llvm::Triple::x86_64) |
| 630 | D.Diag(DiagID: diag::err_drv_unsupported_opt_for_target) |
| 631 | << Name << Triple.getArchName(); |
| 632 | } else if (Name == "AMDLIBM" ) { |
| 633 | if (Triple.getArch() != llvm::Triple::x86 && |
| 634 | Triple.getArch() != llvm::Triple::x86_64) |
| 635 | D.Diag(DiagID: diag::err_drv_unsupported_opt_for_target) |
| 636 | << Name << Triple.getArchName(); |
| 637 | } else if (Name == "libmvec" ) { |
| 638 | if (Triple.getArch() != llvm::Triple::x86 && |
| 639 | Triple.getArch() != llvm::Triple::x86_64 && |
| 640 | Triple.getArch() != llvm::Triple::aarch64 && |
| 641 | Triple.getArch() != llvm::Triple::aarch64_be) |
| 642 | D.Diag(DiagID: diag::err_drv_unsupported_opt_for_target) |
| 643 | << Name << Triple.getArchName(); |
| 644 | } else if (Name == "SLEEF" || Name == "ArmPL" ) { |
| 645 | if (Triple.getArch() != llvm::Triple::aarch64 && |
| 646 | Triple.getArch() != llvm::Triple::aarch64_be) |
| 647 | D.Diag(DiagID: diag::err_drv_unsupported_opt_for_target) |
| 648 | << Name << Triple.getArchName(); |
| 649 | } |
| 650 | |
| 651 | if (Triple.isOSDarwin()) { |
| 652 | // flang doesn't currently suport nostdlib, nodefaultlibs. Adding these |
| 653 | // here incase they are added someday |
| 654 | if (!Args.hasArg(Ids: options::OPT_nostdlib, Ids: options::OPT_nodefaultlibs)) { |
| 655 | if (A->getValue() == StringRef{"Accelerate" }) { |
| 656 | CmdArgs.push_back(Elt: "-framework" ); |
| 657 | CmdArgs.push_back(Elt: "Accelerate" ); |
| 658 | } |
| 659 | } |
| 660 | } |
| 661 | A->render(Args, Output&: CmdArgs); |
| 662 | } |
| 663 | |
| 664 | if (Triple.isKnownWindowsMSVCEnvironment()) { |
| 665 | processVSRuntimeLibrary(TC, Args, CmdArgs); |
| 666 | addVSDefines(TC, Args, CmdArgs); |
| 667 | } |
| 668 | |
| 669 | // TODO: Add target specific flags, ABI, mtune option etc. |
| 670 | if (const Arg *A = Args.getLastArg(Ids: options::OPT_mtune_EQ)) { |
| 671 | CmdArgs.push_back(Elt: "-tune-cpu" ); |
| 672 | if (A->getValue() == StringRef{"native" }) |
| 673 | CmdArgs.push_back(Elt: Args.MakeArgString(Str: llvm::sys::getHostCPUName())); |
| 674 | else |
| 675 | CmdArgs.push_back(Elt: A->getValue()); |
| 676 | } |
| 677 | |
| 678 | Args.addAllArgs(Output&: CmdArgs, |
| 679 | Ids: {options::OPT_fverbose_asm, options::OPT_fno_verbose_asm, |
| 680 | options::OPT_fatomic_ignore_denormal_mode, |
| 681 | options::OPT_fno_atomic_ignore_denormal_mode, |
| 682 | options::OPT_fatomic_fine_grained_memory, |
| 683 | options::OPT_fno_atomic_fine_grained_memory, |
| 684 | options::OPT_fatomic_remote_memory, |
| 685 | options::OPT_fno_atomic_remote_memory, |
| 686 | options::OPT_munsafe_fp_atomics}); |
| 687 | } |
| 688 | |
| 689 | void Flang::addOffloadOptions(Compilation &C, const InputInfoList &Inputs, |
| 690 | const JobAction &JA, const ArgList &Args, |
| 691 | ArgStringList &CmdArgs) const { |
| 692 | bool IsOpenMPDevice = JA.isDeviceOffloading(OKind: Action::OFK_OpenMP); |
| 693 | bool IsHostOffloadingAction = JA.isHostOffloading(OKind: Action::OFK_OpenMP) || |
| 694 | JA.isHostOffloading(OKind: C.getActiveOffloadKinds()); |
| 695 | |
| 696 | // Skips the primary input file, which is the input file that the compilation |
| 697 | // proccess will be executed upon (e.g. the host bitcode file) and |
| 698 | // adds other secondary input (e.g. device bitcode files for embedding to the |
| 699 | // -fembed-offload-object argument or the host IR file for proccessing |
| 700 | // during device compilation to the fopenmp-host-ir-file-path argument via |
| 701 | // OpenMPDeviceInput). This is condensed logic from the ConstructJob |
| 702 | // function inside of the Clang driver for pushing on further input arguments |
| 703 | // needed for offloading during various phases of compilation. |
| 704 | for (size_t i = 1; i < Inputs.size(); ++i) { |
| 705 | if (Inputs[i].getType() == types::TY_Nothing) { |
| 706 | // contains nothing, so it's skippable |
| 707 | } else if (IsHostOffloadingAction) { |
| 708 | CmdArgs.push_back( |
| 709 | Elt: Args.MakeArgString(Str: "-fembed-offload-object=" + |
| 710 | getToolChain().getInputFilename(Input: Inputs[i]))); |
| 711 | } else if (IsOpenMPDevice) { |
| 712 | if (Inputs[i].getFilename()) { |
| 713 | CmdArgs.push_back(Elt: "-fopenmp-host-ir-file-path" ); |
| 714 | CmdArgs.push_back(Elt: Args.MakeArgString(Str: Inputs[i].getFilename())); |
| 715 | } else { |
| 716 | llvm_unreachable("missing openmp host-ir file for device offloading" ); |
| 717 | } |
| 718 | } else { |
| 719 | llvm_unreachable( |
| 720 | "unexpectedly given multiple inputs or given unknown input" ); |
| 721 | } |
| 722 | } |
| 723 | |
| 724 | if (IsOpenMPDevice) { |
| 725 | // -fopenmp-is-target-device is passed along to tell the frontend that it is |
| 726 | // generating code for a device, so that only the relevant code is emitted. |
| 727 | CmdArgs.push_back(Elt: "-fopenmp-is-target-device" ); |
| 728 | |
| 729 | // When in OpenMP offloading mode, enable debugging on the device. |
| 730 | Args.AddAllArgs(Output&: CmdArgs, Id0: options::OPT_fopenmp_target_debug_EQ); |
| 731 | if (Args.hasFlag(Pos: options::OPT_fopenmp_target_debug, |
| 732 | Neg: options::OPT_fno_openmp_target_debug, /*Default=*/false)) |
| 733 | CmdArgs.push_back(Elt: "-fopenmp-target-debug" ); |
| 734 | |
| 735 | // When in OpenMP offloading mode, forward assumptions information about |
| 736 | // thread and team counts in the device. |
| 737 | if (Args.hasFlag(Pos: options::OPT_fopenmp_assume_teams_oversubscription, |
| 738 | Neg: options::OPT_fno_openmp_assume_teams_oversubscription, |
| 739 | /*Default=*/false)) |
| 740 | CmdArgs.push_back(Elt: "-fopenmp-assume-teams-oversubscription" ); |
| 741 | if (Args.hasFlag(Pos: options::OPT_fopenmp_assume_threads_oversubscription, |
| 742 | Neg: options::OPT_fno_openmp_assume_threads_oversubscription, |
| 743 | /*Default=*/false)) |
| 744 | CmdArgs.push_back(Elt: "-fopenmp-assume-threads-oversubscription" ); |
| 745 | if (Args.hasArg(Ids: options::OPT_fopenmp_assume_no_thread_state)) |
| 746 | CmdArgs.push_back(Elt: "-fopenmp-assume-no-thread-state" ); |
| 747 | if (Args.hasArg(Ids: options::OPT_fopenmp_assume_no_nested_parallelism)) |
| 748 | CmdArgs.push_back(Elt: "-fopenmp-assume-no-nested-parallelism" ); |
| 749 | if (!Args.hasFlag(Pos: options::OPT_offloadlib, Neg: options::OPT_no_offloadlib, |
| 750 | Default: true)) |
| 751 | CmdArgs.push_back(Elt: "-nogpulib" ); |
| 752 | } |
| 753 | |
| 754 | addOpenMPHostOffloadingArgs(C, JA, Args, CmdArgs); |
| 755 | } |
| 756 | |
| 757 | static void addFloatingPointOptions(const Driver &D, const ArgList &Args, |
| 758 | ArgStringList &CmdArgs) { |
| 759 | StringRef FPContract; |
| 760 | bool HonorINFs = true; |
| 761 | bool HonorNaNs = true; |
| 762 | bool ApproxFunc = false; |
| 763 | bool SignedZeros = true; |
| 764 | bool AssociativeMath = false; |
| 765 | bool ReciprocalMath = false; |
| 766 | |
| 767 | StringRef LastComplexRangeOption; |
| 768 | LangOptions::ComplexRangeKind Range = LangOptions::ComplexRangeKind::CX_None; |
| 769 | |
| 770 | if (const Arg *A = Args.getLastArg(Ids: options::OPT_ffp_contract)) { |
| 771 | const StringRef Val = A->getValue(); |
| 772 | if (Val == "fast" || Val == "off" ) { |
| 773 | FPContract = Val; |
| 774 | } else if (Val == "on" ) { |
| 775 | // Warn instead of error because users might have makefiles written for |
| 776 | // gfortran (which accepts -ffp-contract=on) |
| 777 | D.Diag(DiagID: diag::warn_drv_unsupported_option_for_flang) |
| 778 | << Val << A->getOption().getName() << "off" ; |
| 779 | FPContract = "off" ; |
| 780 | } else |
| 781 | // Clang's "fast-honor-pragmas" option is not supported because it is |
| 782 | // non-standard |
| 783 | D.Diag(DiagID: diag::err_drv_unsupported_option_argument) |
| 784 | << A->getSpelling() << Val; |
| 785 | } |
| 786 | |
| 787 | for (const Arg *A : Args) { |
| 788 | auto optId = A->getOption().getID(); |
| 789 | switch (optId) { |
| 790 | // if this isn't an FP option, skip the claim below |
| 791 | default: |
| 792 | continue; |
| 793 | |
| 794 | case options::OPT_fcomplex_arithmetic_EQ: { |
| 795 | LangOptions::ComplexRangeKind NewRange; |
| 796 | StringRef Val = A->getValue(); |
| 797 | if (Val == "full" ) |
| 798 | NewRange = LangOptions::ComplexRangeKind::CX_Full; |
| 799 | else if (Val == "improved" ) |
| 800 | NewRange = LangOptions::ComplexRangeKind::CX_Improved; |
| 801 | else if (Val == "basic" ) |
| 802 | NewRange = LangOptions::ComplexRangeKind::CX_Basic; |
| 803 | else { |
| 804 | D.Diag(DiagID: diag::err_drv_unsupported_option_argument) |
| 805 | << A->getSpelling() << Val; |
| 806 | break; |
| 807 | } |
| 808 | |
| 809 | setComplexRange(D, NewOpt: Args.MakeArgString(Str: A->getSpelling() + Val), NewRange, |
| 810 | LastOpt&: LastComplexRangeOption, Range); |
| 811 | break; |
| 812 | } |
| 813 | case options::OPT_fhonor_infinities: |
| 814 | HonorINFs = true; |
| 815 | break; |
| 816 | case options::OPT_fno_honor_infinities: |
| 817 | HonorINFs = false; |
| 818 | break; |
| 819 | case options::OPT_fhonor_nans: |
| 820 | HonorNaNs = true; |
| 821 | break; |
| 822 | case options::OPT_fno_honor_nans: |
| 823 | HonorNaNs = false; |
| 824 | break; |
| 825 | case options::OPT_fapprox_func: |
| 826 | ApproxFunc = true; |
| 827 | break; |
| 828 | case options::OPT_fno_approx_func: |
| 829 | ApproxFunc = false; |
| 830 | break; |
| 831 | case options::OPT_fsigned_zeros: |
| 832 | SignedZeros = true; |
| 833 | break; |
| 834 | case options::OPT_fno_signed_zeros: |
| 835 | SignedZeros = false; |
| 836 | break; |
| 837 | case options::OPT_fassociative_math: |
| 838 | AssociativeMath = true; |
| 839 | break; |
| 840 | case options::OPT_fno_associative_math: |
| 841 | AssociativeMath = false; |
| 842 | break; |
| 843 | case options::OPT_freciprocal_math: |
| 844 | ReciprocalMath = true; |
| 845 | break; |
| 846 | case options::OPT_fno_reciprocal_math: |
| 847 | ReciprocalMath = false; |
| 848 | break; |
| 849 | case options::OPT_Ofast: |
| 850 | [[fallthrough]]; |
| 851 | case options::OPT_ffast_math: |
| 852 | HonorINFs = false; |
| 853 | HonorNaNs = false; |
| 854 | AssociativeMath = true; |
| 855 | ReciprocalMath = true; |
| 856 | ApproxFunc = true; |
| 857 | SignedZeros = false; |
| 858 | FPContract = "fast" ; |
| 859 | setComplexRange(D, NewOpt: A->getSpelling(), |
| 860 | NewRange: LangOptions::ComplexRangeKind::CX_Basic, |
| 861 | LastOpt&: LastComplexRangeOption, Range); |
| 862 | break; |
| 863 | case options::OPT_fno_fast_math: |
| 864 | HonorINFs = true; |
| 865 | HonorNaNs = true; |
| 866 | AssociativeMath = false; |
| 867 | ReciprocalMath = false; |
| 868 | ApproxFunc = false; |
| 869 | SignedZeros = true; |
| 870 | // -fno-fast-math should undo -ffast-math so I return FPContract to the |
| 871 | // default. It is important to check it is "fast" (the default) so that |
| 872 | // --ffp-contract=off -fno-fast-math --> -ffp-contract=off |
| 873 | if (FPContract == "fast" ) |
| 874 | FPContract = "" ; |
| 875 | setComplexRange(D, NewOpt: A->getSpelling(), |
| 876 | NewRange: LangOptions::ComplexRangeKind::CX_None, |
| 877 | LastOpt&: LastComplexRangeOption, Range); |
| 878 | break; |
| 879 | } |
| 880 | |
| 881 | // If we handled this option claim it |
| 882 | A->claim(); |
| 883 | } |
| 884 | |
| 885 | StringRef Recip = parseMRecipOption(Diags&: D.getDiags(), Args); |
| 886 | if (!Recip.empty()) |
| 887 | CmdArgs.push_back(Elt: Args.MakeArgString(Str: "-mrecip=" + Recip)); |
| 888 | |
| 889 | if (Range != LangOptions::ComplexRangeKind::CX_None) { |
| 890 | std::string ComplexRangeStr = renderComplexRangeOption(Range); |
| 891 | CmdArgs.push_back(Elt: Args.MakeArgString(Str: ComplexRangeStr)); |
| 892 | CmdArgs.push_back(Elt: Args.MakeArgString(Str: "-fcomplex-arithmetic=" + |
| 893 | complexRangeKindToStr(Range))); |
| 894 | } |
| 895 | |
| 896 | if (llvm::opt::Arg *A = |
| 897 | Args.getLastArg(Ids: clang::options::OPT_ffast_real_mod, |
| 898 | Ids: clang::options::OPT_fno_fast_real_mod)) { |
| 899 | if (A->getOption().matches(ID: clang::options::OPT_ffast_real_mod)) |
| 900 | CmdArgs.push_back(Elt: "-ffast-real-mod" ); |
| 901 | else if (A->getOption().matches(ID: clang::options::OPT_fno_fast_real_mod)) |
| 902 | CmdArgs.push_back(Elt: "-fno-fast-real-mod" ); |
| 903 | } |
| 904 | |
| 905 | if (!HonorINFs && !HonorNaNs && AssociativeMath && ReciprocalMath && |
| 906 | ApproxFunc && !SignedZeros && |
| 907 | (FPContract == "fast" || FPContract.empty())) { |
| 908 | CmdArgs.push_back(Elt: "-ffast-math" ); |
| 909 | return; |
| 910 | } |
| 911 | |
| 912 | if (!FPContract.empty()) |
| 913 | CmdArgs.push_back(Elt: Args.MakeArgString(Str: "-ffp-contract=" + FPContract)); |
| 914 | |
| 915 | if (!HonorINFs) |
| 916 | CmdArgs.push_back(Elt: "-menable-no-infs" ); |
| 917 | |
| 918 | if (!HonorNaNs) |
| 919 | CmdArgs.push_back(Elt: "-menable-no-nans" ); |
| 920 | |
| 921 | if (ApproxFunc) |
| 922 | CmdArgs.push_back(Elt: "-fapprox-func" ); |
| 923 | |
| 924 | if (!SignedZeros) |
| 925 | CmdArgs.push_back(Elt: "-fno-signed-zeros" ); |
| 926 | |
| 927 | if (AssociativeMath && !SignedZeros) |
| 928 | CmdArgs.push_back(Elt: "-mreassociate" ); |
| 929 | |
| 930 | if (ReciprocalMath) |
| 931 | CmdArgs.push_back(Elt: "-freciprocal-math" ); |
| 932 | } |
| 933 | |
| 934 | static void (const ArgList &Args, ArgStringList &CmdArgs, |
| 935 | const InputInfo &Input) { |
| 936 | StringRef Format = "yaml" ; |
| 937 | if (const Arg *A = Args.getLastArg(Ids: options::OPT_fsave_optimization_record_EQ)) |
| 938 | Format = A->getValue(); |
| 939 | |
| 940 | CmdArgs.push_back(Elt: "-opt-record-file" ); |
| 941 | |
| 942 | const Arg *A = Args.getLastArg(Ids: options::OPT_foptimization_record_file_EQ); |
| 943 | if (A) { |
| 944 | CmdArgs.push_back(Elt: A->getValue()); |
| 945 | } else { |
| 946 | SmallString<128> F; |
| 947 | |
| 948 | if (Args.hasArg(Ids: options::OPT_c) || Args.hasArg(Ids: options::OPT_S)) { |
| 949 | if (Arg *FinalOutput = Args.getLastArg(Ids: options::OPT_o)) |
| 950 | F = FinalOutput->getValue(); |
| 951 | } |
| 952 | |
| 953 | if (F.empty()) { |
| 954 | // Use the input filename. |
| 955 | F = llvm::sys::path::stem(path: Input.getBaseInput()); |
| 956 | } |
| 957 | |
| 958 | SmallString<32> Extension; |
| 959 | Extension += "opt." ; |
| 960 | Extension += Format; |
| 961 | |
| 962 | llvm::sys::path::replace_extension(path&: F, extension: Extension); |
| 963 | CmdArgs.push_back(Elt: Args.MakeArgString(Str: F)); |
| 964 | } |
| 965 | |
| 966 | if (const Arg *A = |
| 967 | Args.getLastArg(Ids: options::OPT_foptimization_record_passes_EQ)) { |
| 968 | CmdArgs.push_back(Elt: "-opt-record-passes" ); |
| 969 | CmdArgs.push_back(Elt: A->getValue()); |
| 970 | } |
| 971 | |
| 972 | if (!Format.empty()) { |
| 973 | CmdArgs.push_back(Elt: "-opt-record-format" ); |
| 974 | CmdArgs.push_back(Elt: Format.data()); |
| 975 | } |
| 976 | } |
| 977 | |
| 978 | void Flang::ConstructJob(Compilation &C, const JobAction &JA, |
| 979 | const InputInfo &Output, const InputInfoList &Inputs, |
| 980 | const ArgList &Args, const char *LinkingOutput) const { |
| 981 | const auto &TC = getToolChain(); |
| 982 | const llvm::Triple &Triple = TC.getEffectiveTriple(); |
| 983 | const std::string &TripleStr = Triple.getTriple(); |
| 984 | |
| 985 | const Driver &D = TC.getDriver(); |
| 986 | ArgStringList CmdArgs; |
| 987 | |
| 988 | // Invoke ourselves in -fc1 mode. |
| 989 | CmdArgs.push_back(Elt: "-fc1" ); |
| 990 | |
| 991 | // Add the "effective" target triple. |
| 992 | CmdArgs.push_back(Elt: "-triple" ); |
| 993 | CmdArgs.push_back(Elt: Args.MakeArgString(Str: TripleStr)); |
| 994 | |
| 995 | if (isa<PreprocessJobAction>(Val: JA)) { |
| 996 | CmdArgs.push_back(Elt: "-E" ); |
| 997 | if (Args.getLastArg(Ids: options::OPT_dM)) { |
| 998 | CmdArgs.push_back(Elt: "-dM" ); |
| 999 | } |
| 1000 | } else if (isa<CompileJobAction>(Val: JA) || isa<BackendJobAction>(Val: JA)) { |
| 1001 | if (JA.getType() == types::TY_Nothing) { |
| 1002 | CmdArgs.push_back(Elt: "-fsyntax-only" ); |
| 1003 | } else if (JA.getType() == types::TY_AST) { |
| 1004 | CmdArgs.push_back(Elt: "-emit-ast" ); |
| 1005 | } else if (JA.getType() == types::TY_LLVM_IR || |
| 1006 | JA.getType() == types::TY_LTO_IR) { |
| 1007 | CmdArgs.push_back(Elt: "-emit-llvm" ); |
| 1008 | } else if (JA.getType() == types::TY_LLVM_BC || |
| 1009 | JA.getType() == types::TY_LTO_BC) { |
| 1010 | CmdArgs.push_back(Elt: "-emit-llvm-bc" ); |
| 1011 | } else if (JA.getType() == types::TY_PP_Asm) { |
| 1012 | CmdArgs.push_back(Elt: "-S" ); |
| 1013 | } else { |
| 1014 | assert(false && "Unexpected output type!" ); |
| 1015 | } |
| 1016 | } else if (isa<AssembleJobAction>(Val: JA)) { |
| 1017 | CmdArgs.push_back(Elt: "-emit-obj" ); |
| 1018 | } else if (isa<PrecompileJobAction>(Val: JA)) { |
| 1019 | // The precompile job action is only needed for options such as -mcpu=help. |
| 1020 | // Those will already have been handled by the fc1 driver. |
| 1021 | } else { |
| 1022 | assert(false && "Unexpected action class for Flang tool." ); |
| 1023 | } |
| 1024 | |
| 1025 | // We support some options that are invalid for Fortran and have no effect. |
| 1026 | // These are solely for compatibility with other compilers. Emit a warning if |
| 1027 | // any such options are provided, then proceed normally. |
| 1028 | for (options::ID Opt : {options::OPT_fbuiltin, options::OPT_fno_builtin}) |
| 1029 | if (const Arg *A = Args.getLastArg(Ids: Opt)) |
| 1030 | D.Diag(DiagID: diag::warn_drv_invalid_argument_for_flang) << A->getSpelling(); |
| 1031 | |
| 1032 | // Warn about options that are ignored by flang. These are options that are |
| 1033 | // accepted by gfortran, but have no equivalent in flang. |
| 1034 | for (const Arg *A : |
| 1035 | Args.filtered(Ids: options::OPT_clang_ignored_gcc_optimization_f_Group)) { |
| 1036 | D.Diag(DiagID: diag::warn_ignored_gcc_optimization) << A->getAsString(Args); |
| 1037 | A->claim(); |
| 1038 | } |
| 1039 | |
| 1040 | const InputInfo &Input = Inputs[0]; |
| 1041 | types::ID InputType = Input.getType(); |
| 1042 | |
| 1043 | // Add preprocessing options like -I, -D, etc. if we are using the |
| 1044 | // preprocessor (i.e. skip when dealing with e.g. binary files). |
| 1045 | if (types::getPreprocessedType(Id: InputType) != types::TY_INVALID) |
| 1046 | addPreprocessingOptions(Args, CmdArgs); |
| 1047 | |
| 1048 | addFortranDialectOptions(Args, CmdArgs); |
| 1049 | |
| 1050 | // 'flang -E' always produces output that is suitable for use as fixed form |
| 1051 | // Fortran. However it is only valid free form source if the original is also |
| 1052 | // free form. Ensure this logic does not incorrectly assume fixed-form for |
| 1053 | // cases where it shouldn't, such as `flang -x f95 foo.f90`. |
| 1054 | bool isAtemporaryPreprocessedFile = |
| 1055 | Input.isFilename() && |
| 1056 | llvm::sys::path::extension(path: Input.getFilename()) |
| 1057 | .ends_with(Suffix: types::getTypeTempSuffix(Id: InputType, /*CLStyle=*/false)); |
| 1058 | if (InputType == types::TY_PP_Fortran && isAtemporaryPreprocessedFile && |
| 1059 | !Args.getLastArg(Ids: options::OPT_ffixed_form, Ids: options::OPT_ffree_form)) |
| 1060 | CmdArgs.push_back(Elt: "-ffixed-form" ); |
| 1061 | |
| 1062 | handleColorDiagnosticsArgs(D, Args, CmdArgs); |
| 1063 | |
| 1064 | addLTOOptions(Args, CmdArgs); |
| 1065 | |
| 1066 | // -fPIC and related options. |
| 1067 | addPicOptions(Args, CmdArgs); |
| 1068 | |
| 1069 | // Floating point related options |
| 1070 | addFloatingPointOptions(D, Args, CmdArgs); |
| 1071 | |
| 1072 | // Add target args, features, etc. |
| 1073 | addTargetOptions(Args, CmdArgs); |
| 1074 | |
| 1075 | llvm::Reloc::Model RelocationModel = |
| 1076 | std::get<0>(t: ParsePICArgs(ToolChain: getToolChain(), Args)); |
| 1077 | // Add MCModel information |
| 1078 | addMCModel(D, Args, Triple, RelocationModel, CmdArgs); |
| 1079 | |
| 1080 | // Add Codegen options |
| 1081 | addCodegenOptions(Args, CmdArgs); |
| 1082 | |
| 1083 | // Add R Group options |
| 1084 | Args.AddAllArgs(Output&: CmdArgs, Id0: options::OPT_R_Group); |
| 1085 | |
| 1086 | // Remarks can be enabled with any of the `-f.*optimization-record.*` flags. |
| 1087 | if (willEmitRemarks(Args)) |
| 1088 | renderRemarksOptions(Args, CmdArgs, Input); |
| 1089 | |
| 1090 | // Add debug compile options |
| 1091 | addDebugOptions(Args, JA, Output, Input, CmdArgs); |
| 1092 | |
| 1093 | // Disable all warnings |
| 1094 | // TODO: Handle interactions between -w, -pedantic, -Wall, -WOption |
| 1095 | Args.AddLastArg(Output&: CmdArgs, Ids: options::OPT_w); |
| 1096 | |
| 1097 | // recognise options: fprofile-generate -fprofile-use= |
| 1098 | Args.addAllArgs( |
| 1099 | Output&: CmdArgs, Ids: {options::OPT_fprofile_generate, options::OPT_fprofile_use_EQ}); |
| 1100 | |
| 1101 | // Forward flags for OpenMP. We don't do this if the current action is an |
| 1102 | // device offloading action other than OpenMP. |
| 1103 | if (Args.hasFlag(Pos: options::OPT_fopenmp, PosAlias: options::OPT_fopenmp_EQ, |
| 1104 | Neg: options::OPT_fno_openmp, Default: false) && |
| 1105 | (JA.isDeviceOffloading(OKind: Action::OFK_None) || |
| 1106 | JA.isDeviceOffloading(OKind: Action::OFK_OpenMP))) { |
| 1107 | switch (D.getOpenMPRuntime(Args)) { |
| 1108 | case Driver::OMPRT_OMP: |
| 1109 | case Driver::OMPRT_IOMP5: |
| 1110 | // Clang can generate useful OpenMP code for these two runtime libraries. |
| 1111 | CmdArgs.push_back(Elt: "-fopenmp" ); |
| 1112 | Args.AddAllArgs(Output&: CmdArgs, Id0: options::OPT_fopenmp_version_EQ); |
| 1113 | |
| 1114 | if (Args.hasArg(Ids: options::OPT_fopenmp_force_usm)) |
| 1115 | CmdArgs.push_back(Elt: "-fopenmp-force-usm" ); |
| 1116 | Args.AddLastArg(Output&: CmdArgs, Ids: options::OPT_fopenmp_simd, |
| 1117 | Ids: options::OPT_fno_openmp_simd); |
| 1118 | |
| 1119 | // FIXME: Clang supports a whole bunch more flags here. |
| 1120 | break; |
| 1121 | default: |
| 1122 | // By default, if Clang doesn't know how to generate useful OpenMP code |
| 1123 | // for a specific runtime library, we just don't pass the '-fopenmp' flag |
| 1124 | // down to the actual compilation. |
| 1125 | // FIXME: It would be better to have a mode which *only* omits IR |
| 1126 | // generation based on the OpenMP support so that we get consistent |
| 1127 | // semantic analysis, etc. |
| 1128 | const Arg *A = Args.getLastArg(Ids: options::OPT_fopenmp_EQ); |
| 1129 | D.Diag(DiagID: diag::warn_drv_unsupported_openmp_library) |
| 1130 | << A->getSpelling() << A->getValue(); |
| 1131 | break; |
| 1132 | } |
| 1133 | } else { |
| 1134 | Args.AddLastArg(Output&: CmdArgs, Ids: options::OPT_fopenmp_simd, |
| 1135 | Ids: options::OPT_fno_openmp_simd); |
| 1136 | } |
| 1137 | |
| 1138 | // Pass the path to compiler resource files. |
| 1139 | CmdArgs.push_back(Elt: "-resource-dir" ); |
| 1140 | CmdArgs.push_back(Elt: D.ResourceDir.c_str()); |
| 1141 | |
| 1142 | // Offloading related options |
| 1143 | addOffloadOptions(C, Inputs, JA, Args, CmdArgs); |
| 1144 | |
| 1145 | // Forward -Xflang arguments to -fc1 |
| 1146 | Args.AddAllArgValues(Output&: CmdArgs, Id0: options::OPT_Xflang); |
| 1147 | |
| 1148 | CodeGenOptions::FramePointerKind FPKeepKind = |
| 1149 | getFramePointerKind(Args, Triple); |
| 1150 | |
| 1151 | const char *FPKeepKindStr = nullptr; |
| 1152 | switch (FPKeepKind) { |
| 1153 | case CodeGenOptions::FramePointerKind::None: |
| 1154 | FPKeepKindStr = "-mframe-pointer=none" ; |
| 1155 | break; |
| 1156 | case CodeGenOptions::FramePointerKind::Reserved: |
| 1157 | FPKeepKindStr = "-mframe-pointer=reserved" ; |
| 1158 | break; |
| 1159 | case CodeGenOptions::FramePointerKind::NonLeafNoReserve: |
| 1160 | FPKeepKindStr = "-mframe-pointer=non-leaf-no-reserve" ; |
| 1161 | break; |
| 1162 | case CodeGenOptions::FramePointerKind::NonLeaf: |
| 1163 | FPKeepKindStr = "-mframe-pointer=non-leaf" ; |
| 1164 | break; |
| 1165 | case CodeGenOptions::FramePointerKind::All: |
| 1166 | FPKeepKindStr = "-mframe-pointer=all" ; |
| 1167 | break; |
| 1168 | } |
| 1169 | assert(FPKeepKindStr && "unknown FramePointerKind" ); |
| 1170 | CmdArgs.push_back(Elt: FPKeepKindStr); |
| 1171 | |
| 1172 | // Forward -mllvm options to the LLVM option parser. In practice, this means |
| 1173 | // forwarding to `-fc1` as that's where the LLVM parser is run. |
| 1174 | for (const Arg *A : Args.filtered(Ids: options::OPT_mllvm)) { |
| 1175 | A->claim(); |
| 1176 | A->render(Args, Output&: CmdArgs); |
| 1177 | } |
| 1178 | |
| 1179 | for (const Arg *A : Args.filtered(Ids: options::OPT_mmlir)) { |
| 1180 | A->claim(); |
| 1181 | A->render(Args, Output&: CmdArgs); |
| 1182 | } |
| 1183 | |
| 1184 | // Remove any unsupported gfortran diagnostic options |
| 1185 | for (const Arg *A : Args.filtered(Ids: options::OPT_flang_ignored_w_Group)) { |
| 1186 | A->claim(); |
| 1187 | D.Diag(DiagID: diag::warn_drv_unsupported_diag_option_for_flang) |
| 1188 | << A->getOption().getName(); |
| 1189 | } |
| 1190 | |
| 1191 | // Optimization level for CodeGen. |
| 1192 | if (const Arg *A = Args.getLastArg(Ids: options::OPT_O_Group)) { |
| 1193 | if (A->getOption().matches(ID: options::OPT_O4)) { |
| 1194 | CmdArgs.push_back(Elt: "-O3" ); |
| 1195 | D.Diag(DiagID: diag::warn_O4_is_O3); |
| 1196 | } else if (A->getOption().matches(ID: options::OPT_Ofast)) { |
| 1197 | CmdArgs.push_back(Elt: "-O3" ); |
| 1198 | D.Diag(DiagID: diag::warn_drv_deprecated_arg_ofast_for_flang); |
| 1199 | } else { |
| 1200 | A->render(Args, Output&: CmdArgs); |
| 1201 | } |
| 1202 | } |
| 1203 | |
| 1204 | renderGlobalISelOptions(D, Args, CmdArgs, Triple); |
| 1205 | renderCommonIntegerOverflowOptions(Args, CmdArgs); |
| 1206 | |
| 1207 | assert((Output.isFilename() || Output.isNothing()) && "Invalid output." ); |
| 1208 | if (Output.isFilename()) { |
| 1209 | CmdArgs.push_back(Elt: "-o" ); |
| 1210 | CmdArgs.push_back(Elt: Output.getFilename()); |
| 1211 | } |
| 1212 | |
| 1213 | if (Args.getLastArg(Ids: options::OPT_save_temps_EQ)) |
| 1214 | Args.AddLastArg(Output&: CmdArgs, Ids: options::OPT_save_temps_EQ); |
| 1215 | |
| 1216 | addDashXForInput(Args, Input, CmdArgs); |
| 1217 | |
| 1218 | bool FRecordCmdLine = false; |
| 1219 | bool GRecordCmdLine = false; |
| 1220 | if (shouldRecordCommandLine(TC, Args, FRecordCommandLine&: FRecordCmdLine, GRecordCommandLine&: GRecordCmdLine)) { |
| 1221 | const char *CmdLine = renderEscapedCommandLine(TC, Args); |
| 1222 | if (FRecordCmdLine) { |
| 1223 | CmdArgs.push_back(Elt: "-record-command-line" ); |
| 1224 | CmdArgs.push_back(Elt: CmdLine); |
| 1225 | } |
| 1226 | if (TC.UseDwarfDebugFlags() || GRecordCmdLine) { |
| 1227 | CmdArgs.push_back(Elt: "-dwarf-debug-flags" ); |
| 1228 | CmdArgs.push_back(Elt: CmdLine); |
| 1229 | } |
| 1230 | } |
| 1231 | |
| 1232 | // The input could be Ty_Nothing when "querying" options such as -mcpu=help |
| 1233 | // are used. |
| 1234 | ArrayRef<InputInfo> FrontendInputs = Input; |
| 1235 | if (Input.isNothing()) |
| 1236 | FrontendInputs = {}; |
| 1237 | |
| 1238 | for (const InputInfo &Input : FrontendInputs) { |
| 1239 | if (Input.isFilename()) |
| 1240 | CmdArgs.push_back(Elt: Input.getFilename()); |
| 1241 | else |
| 1242 | Input.getInputArg().renderAsInput(Args, Output&: CmdArgs); |
| 1243 | } |
| 1244 | |
| 1245 | const char *Exec = Args.MakeArgString(Str: D.GetProgramPath(Name: "flang" , TC)); |
| 1246 | C.addCommand(C: std::make_unique<Command>(args: JA, args: *this, |
| 1247 | args: ResponseFileSupport::AtFileUTF8(), |
| 1248 | args&: Exec, args&: CmdArgs, args: Inputs, args: Output)); |
| 1249 | } |
| 1250 | |
| 1251 | Flang::Flang(const ToolChain &TC) : Tool("flang" , "flang frontend" , TC) {} |
| 1252 | |
| 1253 | Flang::~Flang() {} |
| 1254 | |