1480093f4SDimitry Andric //===--- Flang.h - Flang Tool and ToolChain Implementations ====-*- C++ -*-===// 2480093f4SDimitry Andric // 3480093f4SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4480093f4SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5480093f4SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6480093f4SDimitry Andric // 7480093f4SDimitry Andric //===----------------------------------------------------------------------===// 8480093f4SDimitry Andric 9480093f4SDimitry Andric #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_FLANG_H 10480093f4SDimitry Andric #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_FLANG_H 11480093f4SDimitry Andric 12480093f4SDimitry Andric #include "clang/Driver/Tool.h" 13480093f4SDimitry Andric #include "clang/Driver/Action.h" 14480093f4SDimitry Andric #include "clang/Driver/Compilation.h" 15480093f4SDimitry Andric #include "clang/Driver/ToolChain.h" 16480093f4SDimitry Andric #include "llvm/Option/ArgList.h" 17480093f4SDimitry Andric #include "llvm/Support/Compiler.h" 18480093f4SDimitry Andric 19480093f4SDimitry Andric namespace clang { 20480093f4SDimitry Andric namespace driver { 21480093f4SDimitry Andric 22480093f4SDimitry Andric namespace tools { 23480093f4SDimitry Andric 24480093f4SDimitry Andric /// Flang compiler tool. 25480093f4SDimitry Andric class LLVM_LIBRARY_VISIBILITY Flang : public Tool { 26e8d8bef9SDimitry Andric private: 27fe6060f1SDimitry Andric /// Extract fortran dialect options from the driver arguments and add them to 28fe6060f1SDimitry Andric /// the list of arguments for the generated command/job. 29fe6060f1SDimitry Andric /// 30fe6060f1SDimitry Andric /// \param [in] Args The list of input driver arguments 31fe6060f1SDimitry Andric /// \param [out] CmdArgs The list of output command arguments 32bdd1243dSDimitry Andric void addFortranDialectOptions(const llvm::opt::ArgList &Args, 33fe6060f1SDimitry Andric llvm::opt::ArgStringList &CmdArgs) const; 34fe6060f1SDimitry Andric 35e8d8bef9SDimitry Andric /// Extract preprocessing options from the driver arguments and add them to 36e8d8bef9SDimitry Andric /// the preprocessor command arguments. 37e8d8bef9SDimitry Andric /// 38e8d8bef9SDimitry Andric /// \param [in] Args The list of input driver arguments 39e8d8bef9SDimitry Andric /// \param [out] CmdArgs The list of output command arguments 40bdd1243dSDimitry Andric void addPreprocessingOptions(const llvm::opt::ArgList &Args, 41e8d8bef9SDimitry Andric llvm::opt::ArgStringList &CmdArgs) const; 42bdd1243dSDimitry Andric 43bdd1243dSDimitry Andric /// Extract PIC options from the driver arguments and add them to 44bdd1243dSDimitry Andric /// the command arguments. 45bdd1243dSDimitry Andric /// 46bdd1243dSDimitry Andric /// \param [in] Args The list of input driver arguments 47bdd1243dSDimitry Andric /// \param [out] CmdArgs The list of output command arguments 48bdd1243dSDimitry Andric void addPicOptions(const llvm::opt::ArgList &Args, 49bdd1243dSDimitry Andric llvm::opt::ArgStringList &CmdArgs) const; 50bdd1243dSDimitry Andric 51bdd1243dSDimitry Andric /// Extract target options from the driver arguments and add them to 52bdd1243dSDimitry Andric /// the command arguments. 53bdd1243dSDimitry Andric /// 54bdd1243dSDimitry Andric /// \param [in] Args The list of input driver arguments 55bdd1243dSDimitry Andric /// \param [out] CmdArgs The list of output command arguments 56bdd1243dSDimitry Andric void addTargetOptions(const llvm::opt::ArgList &Args, 57bdd1243dSDimitry Andric llvm::opt::ArgStringList &CmdArgs) const; 58bdd1243dSDimitry Andric 59*06c3fb27SDimitry Andric /// Extract offload options from the driver arguments and add them to 60*06c3fb27SDimitry Andric /// the command arguments. 61*06c3fb27SDimitry Andric /// \param [in] C The current compilation for the driver invocation 62*06c3fb27SDimitry Andric /// \param [in] Inputs The input infomration on the current file inputs 63*06c3fb27SDimitry Andric /// \param [in] JA The job action 64*06c3fb27SDimitry Andric /// \param [in] Args The list of input driver arguments 65*06c3fb27SDimitry Andric /// \param [out] CmdArgs The list of output command arguments 66*06c3fb27SDimitry Andric void addOffloadOptions(Compilation &C, const InputInfoList &Inputs, 67*06c3fb27SDimitry Andric const JobAction &JA, const llvm::opt::ArgList &Args, 68*06c3fb27SDimitry Andric llvm::opt::ArgStringList &CmdArgs) const; 69*06c3fb27SDimitry Andric 70*06c3fb27SDimitry Andric /// Extract options for code generation from the driver arguments and add them 71*06c3fb27SDimitry Andric /// to the command arguments. 72*06c3fb27SDimitry Andric /// 73*06c3fb27SDimitry Andric /// \param [in] Args The list of input driver arguments 74*06c3fb27SDimitry Andric /// \param [out] CmdArgs The list of output command arguments 75*06c3fb27SDimitry Andric void addCodegenOptions(const llvm::opt::ArgList &Args, 76*06c3fb27SDimitry Andric llvm::opt::ArgStringList &CmdArgs) const; 77*06c3fb27SDimitry Andric 78fe6060f1SDimitry Andric /// Extract other compilation options from the driver arguments and add them 79fe6060f1SDimitry Andric /// to the command arguments. 80fe6060f1SDimitry Andric /// 81fe6060f1SDimitry Andric /// \param [in] Args The list of input driver arguments 82fe6060f1SDimitry Andric /// \param [out] CmdArgs The list of output command arguments 83bdd1243dSDimitry Andric void addOtherOptions(const llvm::opt::ArgList &Args, 84fe6060f1SDimitry Andric llvm::opt::ArgStringList &CmdArgs) const; 85e8d8bef9SDimitry Andric 86480093f4SDimitry Andric public: 87480093f4SDimitry Andric Flang(const ToolChain &TC); 88480093f4SDimitry Andric ~Flang() override; 89480093f4SDimitry Andric 90480093f4SDimitry Andric bool hasGoodDiagnostics() const override { return true; } 91480093f4SDimitry Andric bool hasIntegratedAssembler() const override { return true; } 92480093f4SDimitry Andric bool hasIntegratedCPP() const override { return true; } 93480093f4SDimitry Andric bool canEmitIR() const override { return true; } 94480093f4SDimitry Andric 95480093f4SDimitry Andric void ConstructJob(Compilation &C, const JobAction &JA, 96480093f4SDimitry Andric const InputInfo &Output, const InputInfoList &Inputs, 97480093f4SDimitry Andric const llvm::opt::ArgList &TCArgs, 98480093f4SDimitry Andric const char *LinkingOutput) const override; 99480093f4SDimitry Andric }; 100480093f4SDimitry Andric 101480093f4SDimitry Andric } // end namespace tools 102480093f4SDimitry Andric 103480093f4SDimitry Andric } // end namespace driver 104480093f4SDimitry Andric } // end namespace clang 105480093f4SDimitry Andric 106480093f4SDimitry Andric #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_FLANG_H 107