David L. Jones | f561aba | 2017-03-08 01:02:16 +0000 | [diff] [blame] | 1 | //===--- Clang.h - Clang Tool and ToolChain Implementations ====-*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_Clang_H |
| 11 | #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_Clang_H |
| 12 | |
| 13 | #include "MSVC.h" |
| 14 | #include "clang/Basic/DebugInfoOptions.h" |
| 15 | #include "clang/Driver/Driver.h" |
| 16 | #include "clang/Driver/Tool.h" |
| 17 | #include "clang/Driver/Types.h" |
| 18 | #include "llvm/ADT/Triple.h" |
| 19 | #include "llvm/Option/Option.h" |
| 20 | #include "llvm/Support/raw_ostream.h" |
| 21 | |
| 22 | namespace clang { |
| 23 | class ObjCRuntime; |
| 24 | namespace driver { |
| 25 | |
| 26 | namespace tools { |
| 27 | |
| 28 | /// \brief Clang compiler tool. |
| 29 | class LLVM_LIBRARY_VISIBILITY Clang : public Tool { |
| 30 | public: |
| 31 | static const char *getBaseInputName(const llvm::opt::ArgList &Args, |
| 32 | const InputInfo &Input); |
| 33 | static const char *getBaseInputStem(const llvm::opt::ArgList &Args, |
| 34 | const InputInfoList &Inputs); |
| 35 | static const char *getDependencyFileName(const llvm::opt::ArgList &Args, |
| 36 | const InputInfoList &Inputs); |
| 37 | |
| 38 | private: |
| 39 | void AddPreprocessingOptions(Compilation &C, const JobAction &JA, |
| 40 | const Driver &D, const llvm::opt::ArgList &Args, |
| 41 | llvm::opt::ArgStringList &CmdArgs, |
| 42 | const InputInfo &Output, |
| 43 | const InputInfoList &Inputs) const; |
| 44 | |
Saleem Abdulrasool | 6c3ed7b | 2017-09-03 04:47:00 +0000 | [diff] [blame^] | 45 | void RenderTargetOptions(const llvm::Triple &EffectiveTriple, |
| 46 | const llvm::opt::ArgList &Args, bool KernelOrKext, |
| 47 | llvm::opt::ArgStringList &CmdArgs) const; |
| 48 | |
David L. Jones | f561aba | 2017-03-08 01:02:16 +0000 | [diff] [blame] | 49 | void AddAArch64TargetArgs(const llvm::opt::ArgList &Args, |
| 50 | llvm::opt::ArgStringList &CmdArgs) const; |
| 51 | void AddARMTargetArgs(const llvm::Triple &Triple, |
| 52 | const llvm::opt::ArgList &Args, |
| 53 | llvm::opt::ArgStringList &CmdArgs, |
| 54 | bool KernelOrKext) const; |
| 55 | void AddARM64TargetArgs(const llvm::opt::ArgList &Args, |
| 56 | llvm::opt::ArgStringList &CmdArgs) const; |
| 57 | void AddMIPSTargetArgs(const llvm::opt::ArgList &Args, |
| 58 | llvm::opt::ArgStringList &CmdArgs) const; |
| 59 | void AddPPCTargetArgs(const llvm::opt::ArgList &Args, |
| 60 | llvm::opt::ArgStringList &CmdArgs) const; |
| 61 | void AddR600TargetArgs(const llvm::opt::ArgList &Args, |
| 62 | llvm::opt::ArgStringList &CmdArgs) const; |
| 63 | void AddSparcTargetArgs(const llvm::opt::ArgList &Args, |
| 64 | llvm::opt::ArgStringList &CmdArgs) const; |
| 65 | void AddSystemZTargetArgs(const llvm::opt::ArgList &Args, |
| 66 | llvm::opt::ArgStringList &CmdArgs) const; |
| 67 | void AddX86TargetArgs(const llvm::opt::ArgList &Args, |
| 68 | llvm::opt::ArgStringList &CmdArgs) const; |
| 69 | void AddHexagonTargetArgs(const llvm::opt::ArgList &Args, |
| 70 | llvm::opt::ArgStringList &CmdArgs) const; |
| 71 | void AddLanaiTargetArgs(const llvm::opt::ArgList &Args, |
| 72 | llvm::opt::ArgStringList &CmdArgs) const; |
| 73 | void AddWebAssemblyTargetArgs(const llvm::opt::ArgList &Args, |
| 74 | llvm::opt::ArgStringList &CmdArgs) const; |
| 75 | |
| 76 | enum RewriteKind { RK_None, RK_Fragile, RK_NonFragile }; |
| 77 | |
| 78 | ObjCRuntime AddObjCRuntimeArgs(const llvm::opt::ArgList &args, |
| 79 | llvm::opt::ArgStringList &cmdArgs, |
| 80 | RewriteKind rewrite) const; |
| 81 | |
| 82 | void AddClangCLArgs(const llvm::opt::ArgList &Args, types::ID InputType, |
| 83 | llvm::opt::ArgStringList &CmdArgs, |
| 84 | codegenoptions::DebugInfoKind *DebugInfoKind, |
| 85 | bool *EmitCodeView) const; |
| 86 | |
| 87 | visualstudio::Compiler *getCLFallback() const; |
| 88 | |
| 89 | mutable std::unique_ptr<visualstudio::Compiler> CLFallback; |
| 90 | |
| 91 | mutable std::unique_ptr<llvm::raw_fd_ostream> CompilationDatabase = nullptr; |
| 92 | void DumpCompilationDatabase(Compilation &C, StringRef Filename, |
| 93 | StringRef Target, |
| 94 | const InputInfo &Output, const InputInfo &Input, |
| 95 | const llvm::opt::ArgList &Args) const; |
| 96 | |
| 97 | public: |
| 98 | Clang(const ToolChain &TC); |
| 99 | ~Clang() override; |
| 100 | |
| 101 | bool hasGoodDiagnostics() const override { return true; } |
| 102 | bool hasIntegratedAssembler() const override { return true; } |
| 103 | bool hasIntegratedCPP() const override { return true; } |
| 104 | bool canEmitIR() const override { return true; } |
| 105 | |
| 106 | void ConstructJob(Compilation &C, const JobAction &JA, |
| 107 | const InputInfo &Output, const InputInfoList &Inputs, |
| 108 | const llvm::opt::ArgList &TCArgs, |
| 109 | const char *LinkingOutput) const override; |
| 110 | }; |
| 111 | |
| 112 | /// \brief Clang integrated assembler tool. |
| 113 | class LLVM_LIBRARY_VISIBILITY ClangAs : public Tool { |
| 114 | public: |
| 115 | ClangAs(const ToolChain &TC) |
| 116 | : Tool("clang::as", "clang integrated assembler", TC, RF_Full) {} |
| 117 | void AddMIPSTargetArgs(const llvm::opt::ArgList &Args, |
| 118 | llvm::opt::ArgStringList &CmdArgs) const; |
| 119 | void AddX86TargetArgs(const llvm::opt::ArgList &Args, |
| 120 | llvm::opt::ArgStringList &CmdArgs) const; |
| 121 | bool hasGoodDiagnostics() const override { return true; } |
| 122 | bool hasIntegratedAssembler() const override { return false; } |
| 123 | bool hasIntegratedCPP() const override { return false; } |
| 124 | |
| 125 | void ConstructJob(Compilation &C, const JobAction &JA, |
| 126 | const InputInfo &Output, const InputInfoList &Inputs, |
| 127 | const llvm::opt::ArgList &TCArgs, |
| 128 | const char *LinkingOutput) const override; |
| 129 | }; |
| 130 | |
| 131 | /// Offload bundler tool. |
| 132 | class LLVM_LIBRARY_VISIBILITY OffloadBundler final : public Tool { |
| 133 | public: |
| 134 | OffloadBundler(const ToolChain &TC) |
| 135 | : Tool("offload bundler", "clang-offload-bundler", TC) {} |
| 136 | |
| 137 | bool hasIntegratedCPP() const override { return false; } |
| 138 | void ConstructJob(Compilation &C, const JobAction &JA, |
| 139 | const InputInfo &Output, const InputInfoList &Inputs, |
| 140 | const llvm::opt::ArgList &TCArgs, |
| 141 | const char *LinkingOutput) const override; |
| 142 | void ConstructJobMultipleOutputs(Compilation &C, const JobAction &JA, |
| 143 | const InputInfoList &Outputs, |
| 144 | const InputInfoList &Inputs, |
| 145 | const llvm::opt::ArgList &TCArgs, |
| 146 | const char *LinkingOutput) const override; |
| 147 | }; |
| 148 | } // end namespace tools |
| 149 | |
| 150 | } // end namespace driver |
| 151 | } // end namespace clang |
| 152 | |
| 153 | #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_CLANG_H |