Daniel Dunbar | 9c073ff | 2009-03-17 22:07:58 +0000 | [diff] [blame] | 1 | //===--- Tools.h - Tool 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 CLANG_LIB_DRIVER_TOOLS_H_ |
| 11 | #define CLANG_LIB_DRIVER_TOOLS_H_ |
| 12 | |
| 13 | #include "clang/Driver/Tool.h" |
Daniel Dunbar | 40f1265 | 2009-03-29 17:08:39 +0000 | [diff] [blame] | 14 | #include "clang/Driver/Types.h" |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 15 | #include "clang/Driver/Util.h" |
Daniel Dunbar | 9c073ff | 2009-03-17 22:07:58 +0000 | [diff] [blame] | 16 | |
| 17 | #include "llvm/Support/Compiler.h" |
| 18 | |
| 19 | namespace clang { |
| 20 | namespace driver { |
Douglas Gregor | df91ef3 | 2009-04-18 00:34:01 +0000 | [diff] [blame] | 21 | class Driver; |
| 22 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 23 | namespace toolchains { |
| 24 | class Darwin_X86; |
| 25 | } |
| 26 | |
Daniel Dunbar | 985b825 | 2009-03-17 22:18:43 +0000 | [diff] [blame] | 27 | namespace tools { |
Daniel Dunbar | 9c073ff | 2009-03-17 22:07:58 +0000 | [diff] [blame] | 28 | |
Daniel Dunbar | 985b825 | 2009-03-17 22:18:43 +0000 | [diff] [blame] | 29 | class VISIBILITY_HIDDEN Clang : public Tool { |
Douglas Gregor | df91ef3 | 2009-04-18 00:34:01 +0000 | [diff] [blame] | 30 | void AddPreprocessingOptions(const Driver &D, |
| 31 | const ArgList &Args, |
Daniel Dunbar | c21c485 | 2009-04-08 23:54:23 +0000 | [diff] [blame] | 32 | ArgStringList &CmdArgs, |
| 33 | const InputInfo &Output, |
| 34 | const InputInfoList &Inputs) const; |
| 35 | |
Daniel Dunbar | 9c073ff | 2009-03-17 22:07:58 +0000 | [diff] [blame] | 36 | public: |
Daniel Dunbar | 31b1e54 | 2009-03-17 22:45:24 +0000 | [diff] [blame] | 37 | Clang(const ToolChain &TC) : Tool("clang", TC) {} |
Daniel Dunbar | 9c073ff | 2009-03-17 22:07:58 +0000 | [diff] [blame] | 38 | |
| 39 | virtual bool acceptsPipedInput() const { return true; } |
| 40 | virtual bool canPipeOutput() const { return true; } |
| 41 | virtual bool hasIntegratedCPP() const { return true; } |
Daniel Dunbar | 47ac7d2 | 2009-03-18 06:00:36 +0000 | [diff] [blame] | 42 | |
| 43 | virtual void ConstructJob(Compilation &C, const JobAction &JA, |
Daniel Dunbar | 871adcf | 2009-03-18 07:06:02 +0000 | [diff] [blame] | 44 | Job &Dest, |
Daniel Dunbar | 62cf601 | 2009-03-18 06:07:59 +0000 | [diff] [blame] | 45 | const InputInfo &Output, |
| 46 | const InputInfoList &Inputs, |
Daniel Dunbar | 47ac7d2 | 2009-03-18 06:00:36 +0000 | [diff] [blame] | 47 | const ArgList &TCArgs, |
| 48 | const char *LinkingOutput) const; |
Daniel Dunbar | 9c073ff | 2009-03-17 22:07:58 +0000 | [diff] [blame] | 49 | }; |
| 50 | |
Daniel Dunbar | 31b1e54 | 2009-03-17 22:45:24 +0000 | [diff] [blame] | 51 | /// gcc - Generic GCC tool implementations. |
| 52 | namespace gcc { |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 53 | class VISIBILITY_HIDDEN Common : public Tool { |
Daniel Dunbar | 9c073ff | 2009-03-17 22:07:58 +0000 | [diff] [blame] | 54 | public: |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 55 | Common(const char *Name, const ToolChain &TC) : Tool(Name, TC) {} |
| 56 | |
| 57 | virtual void ConstructJob(Compilation &C, const JobAction &JA, |
| 58 | Job &Dest, |
| 59 | const InputInfo &Output, |
| 60 | const InputInfoList &Inputs, |
| 61 | const ArgList &TCArgs, |
| 62 | const char *LinkingOutput) const; |
| 63 | |
| 64 | /// RenderExtraToolArgs - Render any arguments necessary to force |
| 65 | /// the particular tool mode. |
| 66 | virtual void RenderExtraToolArgs(ArgStringList &CmdArgs) const = 0; |
| 67 | }; |
| 68 | |
| 69 | |
| 70 | class VISIBILITY_HIDDEN Preprocess : public Common { |
| 71 | public: |
| 72 | Preprocess(const ToolChain &TC) : Common("gcc::Preprocess", TC) {} |
Daniel Dunbar | 9c073ff | 2009-03-17 22:07:58 +0000 | [diff] [blame] | 73 | |
| 74 | virtual bool acceptsPipedInput() const { return true; } |
| 75 | virtual bool canPipeOutput() const { return true; } |
| 76 | virtual bool hasIntegratedCPP() const { return false; } |
Daniel Dunbar | 47ac7d2 | 2009-03-18 06:00:36 +0000 | [diff] [blame] | 77 | |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 78 | virtual void RenderExtraToolArgs(ArgStringList &CmdArgs) const; |
Daniel Dunbar | 9c073ff | 2009-03-17 22:07:58 +0000 | [diff] [blame] | 79 | }; |
| 80 | |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 81 | class VISIBILITY_HIDDEN Precompile : public Common { |
Daniel Dunbar | 9c073ff | 2009-03-17 22:07:58 +0000 | [diff] [blame] | 82 | public: |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 83 | Precompile(const ToolChain &TC) : Common("gcc::Precompile", TC) {} |
Daniel Dunbar | 9c073ff | 2009-03-17 22:07:58 +0000 | [diff] [blame] | 84 | |
| 85 | virtual bool acceptsPipedInput() const { return true; } |
| 86 | virtual bool canPipeOutput() const { return false; } |
| 87 | virtual bool hasIntegratedCPP() const { return true; } |
Daniel Dunbar | 47ac7d2 | 2009-03-18 06:00:36 +0000 | [diff] [blame] | 88 | |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 89 | virtual void RenderExtraToolArgs(ArgStringList &CmdArgs) const; |
Daniel Dunbar | 9c073ff | 2009-03-17 22:07:58 +0000 | [diff] [blame] | 90 | }; |
| 91 | |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 92 | class VISIBILITY_HIDDEN Compile : public Common { |
Daniel Dunbar | 9c073ff | 2009-03-17 22:07:58 +0000 | [diff] [blame] | 93 | public: |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 94 | Compile(const ToolChain &TC) : Common("gcc::Compile", TC) {} |
Daniel Dunbar | 9c073ff | 2009-03-17 22:07:58 +0000 | [diff] [blame] | 95 | |
| 96 | virtual bool acceptsPipedInput() const { return true; } |
| 97 | virtual bool canPipeOutput() const { return true; } |
| 98 | virtual bool hasIntegratedCPP() const { return true; } |
Daniel Dunbar | 47ac7d2 | 2009-03-18 06:00:36 +0000 | [diff] [blame] | 99 | |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 100 | virtual void RenderExtraToolArgs(ArgStringList &CmdArgs) const; |
Daniel Dunbar | 9c073ff | 2009-03-17 22:07:58 +0000 | [diff] [blame] | 101 | }; |
| 102 | |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 103 | class VISIBILITY_HIDDEN Assemble : public Common { |
Daniel Dunbar | 9c073ff | 2009-03-17 22:07:58 +0000 | [diff] [blame] | 104 | public: |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 105 | Assemble(const ToolChain &TC) : Common("gcc::Assemble", TC) {} |
Daniel Dunbar | 9c073ff | 2009-03-17 22:07:58 +0000 | [diff] [blame] | 106 | |
| 107 | virtual bool acceptsPipedInput() const { return true; } |
| 108 | virtual bool canPipeOutput() const { return false; } |
| 109 | virtual bool hasIntegratedCPP() const { return false; } |
Daniel Dunbar | 47ac7d2 | 2009-03-18 06:00:36 +0000 | [diff] [blame] | 110 | |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 111 | virtual void RenderExtraToolArgs(ArgStringList &CmdArgs) const; |
Daniel Dunbar | 9c073ff | 2009-03-17 22:07:58 +0000 | [diff] [blame] | 112 | }; |
| 113 | |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 114 | class VISIBILITY_HIDDEN Link : public Common { |
Daniel Dunbar | 9c073ff | 2009-03-17 22:07:58 +0000 | [diff] [blame] | 115 | public: |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 116 | Link(const ToolChain &TC) : Common("gcc::Link", TC) {} |
Daniel Dunbar | 9c073ff | 2009-03-17 22:07:58 +0000 | [diff] [blame] | 117 | |
| 118 | virtual bool acceptsPipedInput() const { return false; } |
| 119 | virtual bool canPipeOutput() const { return false; } |
| 120 | virtual bool hasIntegratedCPP() const { return false; } |
Daniel Dunbar | 47ac7d2 | 2009-03-18 06:00:36 +0000 | [diff] [blame] | 121 | |
Daniel Dunbar | b488c1d | 2009-03-18 08:07:30 +0000 | [diff] [blame] | 122 | virtual void RenderExtraToolArgs(ArgStringList &CmdArgs) const; |
Daniel Dunbar | 9c073ff | 2009-03-17 22:07:58 +0000 | [diff] [blame] | 123 | }; |
Daniel Dunbar | 31b1e54 | 2009-03-17 22:45:24 +0000 | [diff] [blame] | 124 | } // end namespace gcc |
Daniel Dunbar | 9c073ff | 2009-03-17 22:07:58 +0000 | [diff] [blame] | 125 | |
Daniel Dunbar | ff7488d | 2009-03-20 00:52:38 +0000 | [diff] [blame] | 126 | namespace darwin { |
Daniel Dunbar | 40f1265 | 2009-03-29 17:08:39 +0000 | [diff] [blame] | 127 | class VISIBILITY_HIDDEN CC1 : public Tool { |
Daniel Dunbar | a5a7bd0 | 2009-03-30 00:34:04 +0000 | [diff] [blame] | 128 | public: |
| 129 | static const char *getBaseInputName(const ArgList &Args, |
| 130 | const InputInfoList &Input); |
| 131 | static const char *getBaseInputStem(const ArgList &Args, |
| 132 | const InputInfoList &Input); |
| 133 | static const char *getDependencyFileName(const ArgList &Args, |
| 134 | const InputInfoList &Inputs); |
| 135 | |
Daniel Dunbar | 40f1265 | 2009-03-29 17:08:39 +0000 | [diff] [blame] | 136 | protected: |
| 137 | const char *getCC1Name(types::ID Type) const; |
| 138 | |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 139 | void AddCC1Args(const ArgList &Args, ArgStringList &CmdArgs) const; |
Daniel Dunbar | 40f1265 | 2009-03-29 17:08:39 +0000 | [diff] [blame] | 140 | void AddCC1OptionsArgs(const ArgList &Args, ArgStringList &CmdArgs, |
| 141 | const InputInfoList &Inputs, |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 142 | const ArgStringList &OutputArgs) const; |
Daniel Dunbar | 40f1265 | 2009-03-29 17:08:39 +0000 | [diff] [blame] | 143 | void AddCPPOptionsArgs(const ArgList &Args, ArgStringList &CmdArgs, |
| 144 | const InputInfoList &Inputs, |
Daniel Dunbar | a3ec60e | 2009-03-29 18:40:18 +0000 | [diff] [blame] | 145 | const ArgStringList &OutputArgs) const; |
| 146 | void AddCPPUniqueOptionsArgs(const ArgList &Args, |
| 147 | ArgStringList &CmdArgs, |
| 148 | const InputInfoList &Inputs) const; |
| 149 | void AddCPPArgs(const ArgList &Args, ArgStringList &CmdArgs) const; |
Daniel Dunbar | 40f1265 | 2009-03-29 17:08:39 +0000 | [diff] [blame] | 150 | |
| 151 | public: |
| 152 | CC1(const char *Name, const ToolChain &TC) : Tool(Name, TC) {} |
| 153 | |
| 154 | virtual bool acceptsPipedInput() const { return true; } |
| 155 | virtual bool canPipeOutput() const { return true; } |
| 156 | virtual bool hasIntegratedCPP() const { return true; } |
| 157 | }; |
| 158 | |
| 159 | class VISIBILITY_HIDDEN Preprocess : public CC1 { |
| 160 | public: |
| 161 | Preprocess(const ToolChain &TC) : CC1("darwin::Preprocess", TC) {} |
| 162 | |
| 163 | virtual void ConstructJob(Compilation &C, const JobAction &JA, |
| 164 | Job &Dest, |
| 165 | const InputInfo &Output, |
| 166 | const InputInfoList &Inputs, |
| 167 | const ArgList &TCArgs, |
| 168 | const char *LinkingOutput) const; |
| 169 | }; |
| 170 | |
| 171 | class VISIBILITY_HIDDEN Compile : public CC1 { |
| 172 | public: |
| 173 | Compile(const ToolChain &TC) : CC1("darwin::Compile", TC) {} |
| 174 | |
| 175 | virtual void ConstructJob(Compilation &C, const JobAction &JA, |
| 176 | Job &Dest, |
| 177 | const InputInfo &Output, |
| 178 | const InputInfoList &Inputs, |
| 179 | const ArgList &TCArgs, |
| 180 | const char *LinkingOutput) const; |
| 181 | }; |
| 182 | |
Daniel Dunbar | 8cac5f7 | 2009-03-20 16:06:39 +0000 | [diff] [blame] | 183 | class VISIBILITY_HIDDEN Assemble : public Tool { |
| 184 | public: |
| 185 | Assemble(const ToolChain &TC) : Tool("darwin::Assemble", TC) {} |
| 186 | |
| 187 | virtual bool acceptsPipedInput() const { return true; } |
| 188 | virtual bool canPipeOutput() const { return false; } |
| 189 | virtual bool hasIntegratedCPP() const { return false; } |
| 190 | |
| 191 | virtual void ConstructJob(Compilation &C, const JobAction &JA, |
| 192 | Job &Dest, |
| 193 | const InputInfo &Output, |
| 194 | const InputInfoList &Inputs, |
| 195 | const ArgList &TCArgs, |
| 196 | const char *LinkingOutput) const; |
| 197 | }; |
| 198 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 199 | class VISIBILITY_HIDDEN Link : public Tool { |
| 200 | void AddDarwinArch(const ArgList &Args, ArgStringList &CmdArgs) const; |
| 201 | void AddDarwinSubArch(const ArgList &Args, ArgStringList &CmdArgs) const; |
| 202 | void AddLinkArgs(const ArgList &Args, ArgStringList &CmdArgs) const; |
| 203 | |
| 204 | /// The default macosx-version-min. |
| 205 | const char *MacosxVersionMin; |
| 206 | |
| 207 | const toolchains::Darwin_X86 &getDarwinToolChain() const; |
| 208 | |
| 209 | public: |
| 210 | Link(const ToolChain &TC, |
| 211 | const char *_MacosxVersionMin) |
| 212 | : Tool("darwin::Link", TC), MacosxVersionMin(_MacosxVersionMin) { |
| 213 | } |
| 214 | |
| 215 | virtual bool acceptsPipedInput() const { return false; } |
| 216 | virtual bool canPipeOutput() const { return false; } |
| 217 | virtual bool hasIntegratedCPP() const { return false; } |
| 218 | |
| 219 | virtual void ConstructJob(Compilation &C, const JobAction &JA, |
| 220 | Job &Dest, |
| 221 | const InputInfo &Output, |
| 222 | const InputInfoList &Inputs, |
| 223 | const ArgList &TCArgs, |
| 224 | const char *LinkingOutput) const; |
| 225 | }; |
| 226 | |
Daniel Dunbar | ff7488d | 2009-03-20 00:52:38 +0000 | [diff] [blame] | 227 | class VISIBILITY_HIDDEN Lipo : public Tool { |
| 228 | public: |
Daniel Dunbar | 8cac5f7 | 2009-03-20 16:06:39 +0000 | [diff] [blame] | 229 | Lipo(const ToolChain &TC) : Tool("darwin::Lipo", TC) {} |
Daniel Dunbar | ff7488d | 2009-03-20 00:52:38 +0000 | [diff] [blame] | 230 | |
| 231 | virtual bool acceptsPipedInput() const { return false; } |
| 232 | virtual bool canPipeOutput() const { return false; } |
| 233 | virtual bool hasIntegratedCPP() const { return false; } |
| 234 | |
| 235 | virtual void ConstructJob(Compilation &C, const JobAction &JA, |
| 236 | Job &Dest, |
| 237 | const InputInfo &Output, |
| 238 | const InputInfoList &Inputs, |
| 239 | const ArgList &TCArgs, |
| 240 | const char *LinkingOutput) const; |
| 241 | }; |
| 242 | } |
| 243 | |
Daniel Dunbar | 68a31d4 | 2009-03-31 17:45:15 +0000 | [diff] [blame] | 244 | /// freebsd -- Directly call GNU Binutils assembler and linker |
| 245 | namespace freebsd { |
| 246 | class VISIBILITY_HIDDEN Assemble : public Tool { |
| 247 | public: |
| 248 | Assemble(const ToolChain &TC) : Tool("freebsd::Assemble", TC) {} |
| 249 | |
| 250 | virtual bool acceptsPipedInput() const { return true; } |
| 251 | virtual bool canPipeOutput() const { return true; } |
| 252 | virtual bool hasIntegratedCPP() const { return false; } |
| 253 | |
| 254 | virtual void ConstructJob(Compilation &C, const JobAction &JA, |
| 255 | Job &Dest, |
| 256 | const InputInfo &Output, |
| 257 | const InputInfoList &Inputs, |
| 258 | const ArgList &TCArgs, |
| 259 | const char *LinkingOutput) const; |
| 260 | }; |
Daniel Dunbar | 008f54a | 2009-04-01 19:36:32 +0000 | [diff] [blame] | 261 | class VISIBILITY_HIDDEN Link : public Tool { |
| 262 | public: |
| 263 | Link(const ToolChain &TC) : Tool("freebsd::Link", TC) {} |
| 264 | |
| 265 | virtual bool acceptsPipedInput() const { return true; } |
| 266 | virtual bool canPipeOutput() const { return true; } |
| 267 | virtual bool hasIntegratedCPP() const { return false; } |
| 268 | |
| 269 | virtual void ConstructJob(Compilation &C, const JobAction &JA, |
| 270 | Job &Dest, |
| 271 | const InputInfo &Output, |
| 272 | const InputInfoList &Inputs, |
| 273 | const ArgList &TCArgs, |
| 274 | const char *LinkingOutput) const; |
| 275 | }; |
Daniel Dunbar | 68a31d4 | 2009-03-31 17:45:15 +0000 | [diff] [blame] | 276 | } |
| 277 | |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 278 | /// dragonfly -- Directly call GNU Binutils assembler and linker |
| 279 | namespace dragonfly { |
| 280 | class VISIBILITY_HIDDEN Assemble : public Tool { |
| 281 | public: |
| 282 | Assemble(const ToolChain &TC) : Tool("dragonfly::Assemble", TC) {} |
| 283 | |
| 284 | virtual bool acceptsPipedInput() const { return true; } |
| 285 | virtual bool canPipeOutput() const { return true; } |
| 286 | virtual bool hasIntegratedCPP() const { return false; } |
| 287 | |
| 288 | virtual void ConstructJob(Compilation &C, const JobAction &JA, |
| 289 | Job &Dest, |
| 290 | const InputInfo &Output, |
| 291 | const InputInfoList &Inputs, |
| 292 | const ArgList &TCArgs, |
| 293 | const char *LinkingOutput) const; |
| 294 | }; |
| 295 | class VISIBILITY_HIDDEN Link : public Tool { |
| 296 | public: |
| 297 | Link(const ToolChain &TC) : Tool("dragonfly::Link", TC) {} |
| 298 | |
| 299 | virtual bool acceptsPipedInput() const { return true; } |
| 300 | virtual bool canPipeOutput() const { return true; } |
| 301 | virtual bool hasIntegratedCPP() const { return false; } |
| 302 | |
| 303 | virtual void ConstructJob(Compilation &C, const JobAction &JA, |
| 304 | Job &Dest, |
| 305 | const InputInfo &Output, |
| 306 | const InputInfoList &Inputs, |
| 307 | const ArgList &TCArgs, |
| 308 | const char *LinkingOutput) const; |
| 309 | }; |
| 310 | } |
| 311 | |
Daniel Dunbar | 9c073ff | 2009-03-17 22:07:58 +0000 | [diff] [blame] | 312 | } // end namespace toolchains |
| 313 | } // end namespace driver |
| 314 | } // end namespace clang |
| 315 | |
| 316 | #endif |