| 1 |
//===--- Flang.h - Flang Tool and 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 |
#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_FLANG_H |
| 10 |
#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_FLANG_H |
| 11 |
|
| 12 |
#include "clang/Driver/Tool.h" |
| 13 |
#include "clang/Driver/Action.h" |
| 14 |
#include "clang/Driver/Compilation.h" |
| 15 |
#include "clang/Driver/ToolChain.h" |
| 16 |
#include "llvm/Option/ArgList.h" |
| 17 |
#include "llvm/Support/Compiler.h" |
| 18 |
|
| 19 |
namespace clang { |
| 20 |
namespace driver { |
| 21 |
|
| 22 |
namespace tools { |
| 23 |
|
| 24 |
/// Flang compiler tool. |
| 25 |
class LLVM_LIBRARY_VISIBILITY Flang : public Tool { |
| 26 |
private: |
| 27 |
/// Extract fortran dialect options from the driver arguments and add them to |
| 28 |
/// the list of arguments for the generated command/job. |
| 29 |
/// |
| 30 |
/// \param [in] Args The list of input driver arguments |
| 31 |
/// \param [out] CmdArgs The list of output command arguments |
| 32 |
void addFortranDialectOptions(const llvm::opt::ArgList &Args, |
| 33 |
llvm::opt::ArgStringList &CmdArgs) const; |
| 34 |
|
| 35 |
/// Extract preprocessing options from the driver arguments and add them to |
| 36 |
/// the preprocessor command arguments. |
| 37 |
/// |
| 38 |
/// \param [in] Args The list of input driver arguments |
| 39 |
/// \param [out] CmdArgs The list of output command arguments |
| 40 |
void addPreprocessingOptions(const llvm::opt::ArgList &Args, |
| 41 |
llvm::opt::ArgStringList &CmdArgs) const; |
| 42 |
|
| 43 |
/// Extract LTO options from the driver arguments and add them to |
| 44 |
/// the command arguments. |
| 45 |
/// |
| 46 |
/// \param [in] Args The list of input driver arguments |
| 47 |
/// \param [out] CmdArgs The list of output command arguments |
| 48 |
void addLTOOptions(const llvm::opt::ArgList &Args, |
| 49 |
llvm::opt::ArgStringList &CmdArgs) const; |
| 50 |
|
| 51 |
/// Extract PIC options from the driver arguments and add them to |
| 52 |
/// the command arguments. |
| 53 |
/// |
| 54 |
/// \param [in] Args The list of input driver arguments |
| 55 |
/// \param [out] CmdArgs The list of output command arguments |
| 56 |
void addPicOptions(const llvm::opt::ArgList &Args, |
| 57 |
llvm::opt::ArgStringList &CmdArgs) const; |
| 58 |
|
| 59 |
/// Extract target options from the driver arguments and add them to |
| 60 |
/// the command arguments. |
| 61 |
/// |
| 62 |
/// \param [in] Args The list of input driver arguments |
| 63 |
/// \param [out] CmdArgs The list of output command arguments |
| 64 |
void addTargetOptions(const llvm::opt::ArgList &Args, |
| 65 |
llvm::opt::ArgStringList &CmdArgs) const; |
| 66 |
|
| 67 |
/// Add specific options for AArch64 target. |
| 68 |
/// |
| 69 |
/// \param [in] Args The list of input driver arguments |
| 70 |
/// \param [out] CmdArgs The list of output command arguments |
| 71 |
void AddAArch64TargetArgs(const llvm::opt::ArgList &Args, |
| 72 |
llvm::opt::ArgStringList &CmdArgs) const; |
| 73 |
|
| 74 |
/// Add specific options for AMDGPU target. |
| 75 |
/// |
| 76 |
/// \param [in] Args The list of input driver arguments |
| 77 |
/// \param [out] CmdArgs The list of output command arguments |
| 78 |
void AddAMDGPUTargetArgs(const llvm::opt::ArgList &Args, |
| 79 |
llvm::opt::ArgStringList &CmdArgs) const; |
| 80 |
|
| 81 |
/// Add specific options for LoongArch64 target. |
| 82 |
/// |
| 83 |
/// \param [in] Args The list of input driver arguments |
| 84 |
/// \param [out] CmdArgs The list of output command arguments |
| 85 |
void AddLoongArch64TargetArgs(const llvm::opt::ArgList &Args, |
| 86 |
llvm::opt::ArgStringList &CmdArgs) const; |
| 87 |
|
| 88 |
/// Add specific options for RISC-V target. |
| 89 |
/// |
| 90 |
/// \param [in] Args The list of input driver arguments |
| 91 |
/// \param [out] CmdArgs The list of output command arguments |
| 92 |
void AddRISCVTargetArgs(const llvm::opt::ArgList &Args, |
| 93 |
llvm::opt::ArgStringList &CmdArgs) const; |
| 94 |
|
| 95 |
/// Add specific options for X86_64 target. |
| 96 |
/// |
| 97 |
/// \param [in] Args The list of input driver arguments |
| 98 |
/// \param [out] CmdArgs The list of output command arguments |
| 99 |
void AddX86_64TargetArgs(const llvm::opt::ArgList &Args, |
| 100 |
llvm::opt::ArgStringList &CmdArgs) const; |
| 101 |
|
| 102 |
/// Add specific options for PPC target. |
| 103 |
/// |
| 104 |
/// \param [in] Args The list of input driver arguments |
| 105 |
/// \param [out] CmdArgs The list of output command arguments |
| 106 |
void AddPPCTargetArgs(const llvm::opt::ArgList &Args, |
| 107 |
llvm::opt::ArgStringList &CmdArgs) const; |
| 108 |
|
| 109 |
/// Extract offload options from the driver arguments and add them to |
| 110 |
/// the command arguments. |
| 111 |
/// \param [in] C The current compilation for the driver invocation |
| 112 |
/// \param [in] Inputs The input infomration on the current file inputs |
| 113 |
/// \param [in] JA The job action |
| 114 |
/// \param [in] Args The list of input driver arguments |
| 115 |
/// \param [out] CmdArgs The list of output command arguments |
| 116 |
void addOffloadOptions(Compilation &C, const InputInfoList &Inputs, |
| 117 |
const JobAction &JA, const llvm::opt::ArgList &Args, |
| 118 |
llvm::opt::ArgStringList &CmdArgs) const; |
| 119 |
|
| 120 |
/// Extract options for code generation from the driver arguments and add them |
| 121 |
/// to the command arguments. |
| 122 |
/// |
| 123 |
/// \param [in] Args The list of input driver arguments |
| 124 |
/// \param [out] CmdArgs The list of output command arguments |
| 125 |
void addCodegenOptions(const llvm::opt::ArgList &Args, |
| 126 |
llvm::opt::ArgStringList &CmdArgs) const; |
| 127 |
|
| 128 |
/// Extract debug compilation options from the driver arguments and add them |
| 129 |
/// to the command arguments. |
| 130 |
/// |
| 131 |
/// \param [in] Args The list of input driver arguments |
| 132 |
/// \param [in] JA The job action |
| 133 |
/// \param [in] Output The output information on the current file output |
| 134 |
/// \param [in] Input The input information on the current file input |
| 135 |
/// \param [out] CmdArgs The list of output command arguments |
| 136 |
void addDebugOptions(const llvm::opt::ArgList &Args, const JobAction &JA, |
| 137 |
const InputInfo &Output, const InputInfo &Input, |
| 138 |
llvm::opt::ArgStringList &CmdArgs) const; |
| 139 |
|
| 140 |
public: |
| 141 |
Flang(const ToolChain &TC); |
| 142 |
~Flang() override; |
| 143 |
|
| 144 |
bool hasGoodDiagnostics() const override { return true; } |
| 145 |
bool hasIntegratedAssembler() const override { return true; } |
| 146 |
bool hasIntegratedCPP() const override { return true; } |
| 147 |
bool canEmitIR() const override { return true; } |
| 148 |
|
| 149 |
void ConstructJob(Compilation &C, const JobAction &JA, |
| 150 |
const InputInfo &Output, const InputInfoList &Inputs, |
| 151 |
const llvm::opt::ArgList &TCArgs, |
| 152 |
const char *LinkingOutput) const override; |
| 153 |
}; |
| 154 |
|
| 155 |
} // end namespace tools |
| 156 |
|
| 157 |
} // end namespace driver |
| 158 |
} // end namespace clang |
| 159 |
|
| 160 |
#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_FLANG_H |