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 595f757f3fSDimitry Andric /// Add specific options for AArch64 target. 605f757f3fSDimitry Andric /// 615f757f3fSDimitry Andric /// \param [in] Args The list of input driver arguments 625f757f3fSDimitry Andric /// \param [out] CmdArgs The list of output command arguments 635f757f3fSDimitry Andric void AddAArch64TargetArgs(const llvm::opt::ArgList &Args, 645f757f3fSDimitry Andric llvm::opt::ArgStringList &CmdArgs) const; 655f757f3fSDimitry Andric 665f757f3fSDimitry Andric /// Add specific options for AMDGPU target. 675f757f3fSDimitry Andric /// 685f757f3fSDimitry Andric /// \param [in] Args The list of input driver arguments 695f757f3fSDimitry Andric /// \param [out] CmdArgs The list of output command arguments 705f757f3fSDimitry Andric void AddAMDGPUTargetArgs(const llvm::opt::ArgList &Args, 715f757f3fSDimitry Andric llvm::opt::ArgStringList &CmdArgs) const; 725f757f3fSDimitry Andric 73297eecfbSDimitry Andric /// Add specific options for RISC-V target. 74297eecfbSDimitry Andric /// 75297eecfbSDimitry Andric /// \param [in] Args The list of input driver arguments 76297eecfbSDimitry Andric /// \param [out] CmdArgs The list of output command arguments 77297eecfbSDimitry Andric void AddRISCVTargetArgs(const llvm::opt::ArgList &Args, 78297eecfbSDimitry Andric llvm::opt::ArgStringList &CmdArgs) const; 79297eecfbSDimitry Andric 80*0fca6ea1SDimitry Andric /// Add specific options for X86_64 target. 81*0fca6ea1SDimitry Andric /// 82*0fca6ea1SDimitry Andric /// \param [in] Args The list of input driver arguments 83*0fca6ea1SDimitry Andric /// \param [out] CmdArgs The list of output command arguments 84*0fca6ea1SDimitry Andric void AddX86_64TargetArgs(const llvm::opt::ArgList &Args, 85*0fca6ea1SDimitry Andric llvm::opt::ArgStringList &CmdArgs) const; 86*0fca6ea1SDimitry Andric 8706c3fb27SDimitry Andric /// Extract offload options from the driver arguments and add them to 8806c3fb27SDimitry Andric /// the command arguments. 8906c3fb27SDimitry Andric /// \param [in] C The current compilation for the driver invocation 9006c3fb27SDimitry Andric /// \param [in] Inputs The input infomration on the current file inputs 9106c3fb27SDimitry Andric /// \param [in] JA The job action 9206c3fb27SDimitry Andric /// \param [in] Args The list of input driver arguments 9306c3fb27SDimitry Andric /// \param [out] CmdArgs The list of output command arguments 9406c3fb27SDimitry Andric void addOffloadOptions(Compilation &C, const InputInfoList &Inputs, 9506c3fb27SDimitry Andric const JobAction &JA, const llvm::opt::ArgList &Args, 9606c3fb27SDimitry Andric llvm::opt::ArgStringList &CmdArgs) const; 9706c3fb27SDimitry Andric 9806c3fb27SDimitry Andric /// Extract options for code generation from the driver arguments and add them 9906c3fb27SDimitry Andric /// to the command arguments. 10006c3fb27SDimitry Andric /// 10106c3fb27SDimitry Andric /// \param [in] Args The list of input driver arguments 10206c3fb27SDimitry Andric /// \param [out] CmdArgs The list of output command arguments 10306c3fb27SDimitry Andric void addCodegenOptions(const llvm::opt::ArgList &Args, 10406c3fb27SDimitry Andric llvm::opt::ArgStringList &CmdArgs) const; 10506c3fb27SDimitry Andric 106fe6060f1SDimitry Andric /// Extract other compilation options from the driver arguments and add them 107fe6060f1SDimitry Andric /// to the command arguments. 108fe6060f1SDimitry Andric /// 109fe6060f1SDimitry Andric /// \param [in] Args The list of input driver arguments 110fe6060f1SDimitry Andric /// \param [out] CmdArgs The list of output command arguments 111bdd1243dSDimitry Andric void addOtherOptions(const llvm::opt::ArgList &Args, 112fe6060f1SDimitry Andric llvm::opt::ArgStringList &CmdArgs) const; 113e8d8bef9SDimitry Andric 114480093f4SDimitry Andric public: 115480093f4SDimitry Andric Flang(const ToolChain &TC); 116480093f4SDimitry Andric ~Flang() override; 117480093f4SDimitry Andric 118480093f4SDimitry Andric bool hasGoodDiagnostics() const override { return true; } 119480093f4SDimitry Andric bool hasIntegratedAssembler() const override { return true; } 120480093f4SDimitry Andric bool hasIntegratedCPP() const override { return true; } 121480093f4SDimitry Andric bool canEmitIR() const override { return true; } 122480093f4SDimitry Andric 123480093f4SDimitry Andric void ConstructJob(Compilation &C, const JobAction &JA, 124480093f4SDimitry Andric const InputInfo &Output, const InputInfoList &Inputs, 125480093f4SDimitry Andric const llvm::opt::ArgList &TCArgs, 126480093f4SDimitry Andric const char *LinkingOutput) const override; 127480093f4SDimitry Andric }; 128480093f4SDimitry Andric 129480093f4SDimitry Andric } // end namespace tools 130480093f4SDimitry Andric 131480093f4SDimitry Andric } // end namespace driver 132480093f4SDimitry Andric } // end namespace clang 133480093f4SDimitry Andric 134480093f4SDimitry Andric #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_FLANG_H 135