ToolChain.h revision e20e508aecf413f84b0dc4928cbf4bb5ce6c5bdc
12ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar//===--- ToolChain.h - Collections of tools for one platform ----*- C++ -*-===//
22ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar//
32ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar//                     The LLVM Compiler Infrastructure
42ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar//
52ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar// This file is distributed under the University of Illinois Open Source
62ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar// License. See LICENSE.TXT for details.
72ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar//
82ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar//===----------------------------------------------------------------------===//
92ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar
102ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar#ifndef CLANG_DRIVER_TOOLCHAIN_H_
112ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar#define CLANG_DRIVER_TOOLCHAIN_H_
122ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar
13641b98b7b52e0067beaf3978f2a8721e5d16c111Daniel Dunbar#include "clang/Driver/Util.h"
144180011fb8cef06adec04d30486b1bf3b99aa8b8Daniel Dunbar#include "clang/Driver/Types.h"
150edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar#include "llvm/ADT/SmallVector.h"
16cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar#include "llvm/ADT/Triple.h"
1703013fa9a0bf1ef4b907f5fec006c8f4000fdd21Michael J. Spencer#include "llvm/Support/Path.h"
182ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar#include <string>
192ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar
202ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbarnamespace clang {
21260611a32535c851237926bfcf78869b13c07d5bJohn McCall  class ObjCRuntime;
22260611a32535c851237926bfcf78869b13c07d5bJohn McCall
232ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbarnamespace driver {
2400577ada44c889fbe311d61c51a8da89e65c7c9aDaniel Dunbar  class ArgList;
252ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar  class Compilation;
26f3cad36e59a41b5767fe662b5ac8911ee174b801Daniel Dunbar  class DerivedArgList;
27ee788e70fcd0adf76103b17c78ac658d4ea30c9bDaniel Dunbar  class Driver;
28f3cad36e59a41b5767fe662b5ac8911ee174b801Daniel Dunbar  class InputArgList;
292ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar  class JobAction;
302ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar  class Tool;
312ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar
322ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar/// ToolChain - Access to tools for a single platform.
332ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbarclass ToolChain {
340edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbarpublic:
35686775deca8b8685eb90801495880e3abdd844c2Chris Lattner  typedef SmallVector<std::string, 4> path_list;
360edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar
37641b98b7b52e0067beaf3978f2a8721e5d16c111Daniel Dunbar  enum CXXStdlibType {
383f16c959e30b7e7ba8e4b8d597c313fbe457206dDaniel Dunbar    CST_Libcxx,
39641b98b7b52e0067beaf3978f2a8721e5d16c111Daniel Dunbar    CST_Libstdcxx
40641b98b7b52e0067beaf3978f2a8721e5d16c111Daniel Dunbar  };
41641b98b7b52e0067beaf3978f2a8721e5d16c111Daniel Dunbar
42c24767c9dd869ba0e78c2d4c86d86ed24b8e401eDaniel Dunbar  enum RuntimeLibType {
43c24767c9dd869ba0e78c2d4c86d86ed24b8e401eDaniel Dunbar    RLT_CompilerRT,
44c24767c9dd869ba0e78c2d4c86d86ed24b8e401eDaniel Dunbar    RLT_Libgcc
45c24767c9dd869ba0e78c2d4c86d86ed24b8e401eDaniel Dunbar  };
46c24767c9dd869ba0e78c2d4c86d86ed24b8e401eDaniel Dunbar
470edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbarprivate:
484d7ff6e8639bdce74e39b90370729ad0179ebccaChandler Carruth  const Driver &D;
49cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar  const llvm::Triple Triple;
502ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar
510edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar  /// The list of toolchain specific path prefixes to search for
520edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar  /// files.
530edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar  path_list FilePaths;
540edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar
550edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar  /// The list of toolchain specific path prefixes to search for
560edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar  /// programs.
570edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar  path_list ProgramPaths;
580edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar
592ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbarprotected:
601d16f0f805c2a3e2198a87154990347b2759f6bdChandler Carruth  ToolChain(const Driver &D, const llvm::Triple &T);
612ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar
6279cbbdc8affe52591f7ee487a789639aa38331ecChandler Carruth  /// \name Utilities for implementing subclasses.
6379cbbdc8affe52591f7ee487a789639aa38331ecChandler Carruth  ///@{
6479cbbdc8affe52591f7ee487a789639aa38331ecChandler Carruth  static void addSystemInclude(const ArgList &DriverArgs,
6579cbbdc8affe52591f7ee487a789639aa38331ecChandler Carruth                               ArgStringList &CC1Args,
6679cbbdc8affe52591f7ee487a789639aa38331ecChandler Carruth                               const Twine &Path);
6779cbbdc8affe52591f7ee487a789639aa38331ecChandler Carruth  static void addExternCSystemInclude(const ArgList &DriverArgs,
6879cbbdc8affe52591f7ee487a789639aa38331ecChandler Carruth                                      ArgStringList &CC1Args,
6979cbbdc8affe52591f7ee487a789639aa38331ecChandler Carruth                                      const Twine &Path);
7079cbbdc8affe52591f7ee487a789639aa38331ecChandler Carruth  static void addSystemIncludes(const ArgList &DriverArgs,
7179cbbdc8affe52591f7ee487a789639aa38331ecChandler Carruth                                ArgStringList &CC1Args,
7279cbbdc8affe52591f7ee487a789639aa38331ecChandler Carruth                                ArrayRef<StringRef> Paths);
7379cbbdc8affe52591f7ee487a789639aa38331ecChandler Carruth  ///@}
7479cbbdc8affe52591f7ee487a789639aa38331ecChandler Carruth
752ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbarpublic:
762ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar  virtual ~ToolChain();
772ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar
782ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar  // Accessors
792ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar
80ee788e70fcd0adf76103b17c78ac658d4ea30c9bDaniel Dunbar  const Driver &getDriver() const;
8112cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar  const llvm::Triple &getTriple() const { return Triple; }
8212cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar
83ba30bbe4e36a30a274da809a11a42f9cdc168e92Rafael Espindola  llvm::Triple::ArchType getArch() const { return Triple.getArch(); }
84686775deca8b8685eb90801495880e3abdd844c2Chris Lattner  StringRef getArchName() const { return Triple.getArchName(); }
85686775deca8b8685eb90801495880e3abdd844c2Chris Lattner  StringRef getPlatform() const { return Triple.getVendorName(); }
86686775deca8b8685eb90801495880e3abdd844c2Chris Lattner  StringRef getOS() const { return Triple.getOSName(); }
872ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar
88cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar  std::string getTripleString() const {
89cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar    return Triple.getTriple();
90cd8e4c44dd068956e9181381be3ee2d49a0fac52Daniel Dunbar  }
91cd8e4c44dd068956e9181381be3ee2d49a0fac52Daniel Dunbar
92bbafc5c7645e41a52af688ef8f71a28b19fe4326Daniel Dunbar  path_list &getFilePaths() { return FilePaths; }
93bbafc5c7645e41a52af688ef8f71a28b19fe4326Daniel Dunbar  const path_list &getFilePaths() const { return FilePaths; }
940edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar
95bbafc5c7645e41a52af688ef8f71a28b19fe4326Daniel Dunbar  path_list &getProgramPaths() { return ProgramPaths; }
96bbafc5c7645e41a52af688ef8f71a28b19fe4326Daniel Dunbar  const path_list &getProgramPaths() const { return ProgramPaths; }
970edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar
982ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar  // Tool access.
992ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar
1000dcb9a3705743ec972af37f48ead81a0939e3958Daniel Dunbar  /// TranslateArgs - Create a new derived argument list for any argument
101279c1dbebf37cd128f3c73c70741a6b8c35ad025Daniel Dunbar  /// translations this ToolChain may wish to perform, or 0 if no tool chain
102279c1dbebf37cd128f3c73c70741a6b8c35ad025Daniel Dunbar  /// specific translations are needed.
1030dcb9a3705743ec972af37f48ead81a0939e3958Daniel Dunbar  ///
1040dcb9a3705743ec972af37f48ead81a0939e3958Daniel Dunbar  /// \param BoundArch - The bound architecture name, or 0.
105279c1dbebf37cd128f3c73c70741a6b8c35ad025Daniel Dunbar  virtual DerivedArgList *TranslateArgs(const DerivedArgList &Args,
106279c1dbebf37cd128f3c73c70741a6b8c35ad025Daniel Dunbar                                        const char *BoundArch) const {
107279c1dbebf37cd128f3c73c70741a6b8c35ad025Daniel Dunbar    return 0;
108279c1dbebf37cd128f3c73c70741a6b8c35ad025Daniel Dunbar  }
1092ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar
1101824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko  /// SelectTool - Choose a tool to use to handle the action \p JA with the
1111824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko  /// given \p Inputs.
112ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar  virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
113ac0659ae4124156915eddf70e78065df224d34c8Daniel Dunbar                           const ActionList &Inputs) const = 0;
1142ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar
1152ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar  // Helper methods
1162ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar
1174a7e88978cf646ad10d654020cb00b3877069210Daniel Dunbar  std::string GetFilePath(const char *Name) const;
118fc44e88cbdf013d285f2e4e3962fb80dcad56770Simon Atanasyan  std::string GetProgramPath(const char *Name) const;
1192ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar
1202ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar  // Platform defaults information
1212ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar
122b993f5d93b994b9b0aac6aebae669621744bbed7Daniel Dunbar  /// HasNativeLTOLinker - Check whether the linker and related tools have
123b993f5d93b994b9b0aac6aebae669621744bbed7Daniel Dunbar  /// native LLVM support.
124b993f5d93b994b9b0aac6aebae669621744bbed7Daniel Dunbar  virtual bool HasNativeLLVMSupport() const;
125b993f5d93b994b9b0aac6aebae669621744bbed7Daniel Dunbar
1264180011fb8cef06adec04d30486b1bf3b99aa8b8Daniel Dunbar  /// LookupTypeForExtension - Return the default language type to use for the
1274180011fb8cef06adec04d30486b1bf3b99aa8b8Daniel Dunbar  /// given extension.
1284180011fb8cef06adec04d30486b1bf3b99aa8b8Daniel Dunbar  virtual types::ID LookupTypeForExtension(const char *Ext) const;
1294180011fb8cef06adec04d30486b1bf3b99aa8b8Daniel Dunbar
1309e5cc6b703b2d0013f13800c2ffbeb3cf85fcfadDaniel Dunbar  /// IsBlocksDefault - Does this tool chain enable -fblocks by default.
1319e5cc6b703b2d0013f13800c2ffbeb3cf85fcfadDaniel Dunbar  virtual bool IsBlocksDefault() const { return false; }
132398c610b16728b4398214367dd0effd9d2e61340Daniel Dunbar
1338767cbc475ed96397b6f08617814eeb9cab121bdDaniel Dunbar  /// IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as
1348767cbc475ed96397b6f08617814eeb9cab121bdDaniel Dunbar  /// by default.
1358767cbc475ed96397b6f08617814eeb9cab121bdDaniel Dunbar  virtual bool IsIntegratedAssemblerDefault() const { return false; }
1368767cbc475ed96397b6f08617814eeb9cab121bdDaniel Dunbar
137398c610b16728b4398214367dd0effd9d2e61340Daniel Dunbar  /// IsStrictAliasingDefault - Does this tool chain use -fstrict-aliasing by
138398c610b16728b4398214367dd0effd9d2e61340Daniel Dunbar  /// default.
139398c610b16728b4398214367dd0effd9d2e61340Daniel Dunbar  virtual bool IsStrictAliasingDefault() const { return true; }
140398c610b16728b4398214367dd0effd9d2e61340Daniel Dunbar
141769aa2d46fa5dc0bee5285c95a80ad8749cb79cfBenjamin Kramer  /// IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
142769aa2d46fa5dc0bee5285c95a80ad8749cb79cfBenjamin Kramer  virtual bool IsMathErrnoDefault() const { return true; }
143769aa2d46fa5dc0bee5285c95a80ad8749cb79cfBenjamin Kramer
144c32647d111e516593b9ba242cad7b8ff4016c155Ted Kremenek  /// IsObjCDefaultSynthPropertiesDefault - Does this tool chain enable
145c32647d111e516593b9ba242cad7b8ff4016c155Ted Kremenek  /// -fobjc-default-synthesize-properties by default.
146c32647d111e516593b9ba242cad7b8ff4016c155Ted Kremenek  virtual bool IsObjCDefaultSynthPropertiesDefault() const { return false; }
147c32647d111e516593b9ba242cad7b8ff4016c155Ted Kremenek
1489e5cc6b703b2d0013f13800c2ffbeb3cf85fcfadDaniel Dunbar  /// IsObjCNonFragileABIDefault - Does this tool chain set
1499e5cc6b703b2d0013f13800c2ffbeb3cf85fcfadDaniel Dunbar  /// -fobjc-nonfragile-abi by default.
1509e5cc6b703b2d0013f13800c2ffbeb3cf85fcfadDaniel Dunbar  virtual bool IsObjCNonFragileABIDefault() const { return false; }
1519e5cc6b703b2d0013f13800c2ffbeb3cf85fcfadDaniel Dunbar
152f643b9b338b797a824447207d7eab5f1187f4f34Daniel Dunbar  /// UseObjCMixedDispatchDefault - When using non-legacy dispatch, should the
153f643b9b338b797a824447207d7eab5f1187f4f34Daniel Dunbar  /// mixed dispatch method be used?
154f643b9b338b797a824447207d7eab5f1187f4f34Daniel Dunbar  virtual bool UseObjCMixedDispatch() const { return false; }
155f643b9b338b797a824447207d7eab5f1187f4f34Daniel Dunbar
1569e5cc6b703b2d0013f13800c2ffbeb3cf85fcfadDaniel Dunbar  /// GetDefaultStackProtectorLevel - Get the default stack protector level for
1579e5cc6b703b2d0013f13800c2ffbeb3cf85fcfadDaniel Dunbar  /// this tool chain (0=off, 1=on, 2=all).
1582fef11164cbe804f7b808c07757c6f900c08d765Nico Weber  virtual unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const {
1592fef11164cbe804f7b808c07757c6f900c08d765Nico Weber    return 0;
1602fef11164cbe804f7b808c07757c6f900c08d765Nico Weber  }
1619e5cc6b703b2d0013f13800c2ffbeb3cf85fcfadDaniel Dunbar
162c24767c9dd869ba0e78c2d4c86d86ed24b8e401eDaniel Dunbar  /// GetDefaultRuntimeLibType - Get the default runtime library variant to use.
163c24767c9dd869ba0e78c2d4c86d86ed24b8e401eDaniel Dunbar  virtual RuntimeLibType GetDefaultRuntimeLibType() const {
164c24767c9dd869ba0e78c2d4c86d86ed24b8e401eDaniel Dunbar    return ToolChain::RLT_Libgcc;
165c24767c9dd869ba0e78c2d4c86d86ed24b8e401eDaniel Dunbar  }
166c24767c9dd869ba0e78c2d4c86d86ed24b8e401eDaniel Dunbar
1672ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar  /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables
1682ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar  /// by default.
16903a86385d6628398e1671db1d1970eb83ef0f8b3Rafael Espindola  virtual bool IsUnwindTablesDefault() const;
1702ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar
1712ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar  /// GetDefaultRelocationModel - Return the LLVM name of the default
1722ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar  /// relocation model for this tool chain.
1732ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar  virtual const char *GetDefaultRelocationModel() const = 0;
1742ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar
1752ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar  /// GetForcedPicModel - Return the LLVM name of the forced PIC model
1762ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar  /// for this tool chain, or 0 if this tool chain does not force a
1772ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar  /// particular PIC mode.
1782ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar  virtual const char *GetForcedPicModel() const = 0;
179f2d8b9f967a1ab53ee9fdbcc3ac0a4ee0a83a26eDaniel Dunbar
180bbe8e3eff56ac1d79f3668d706536e3cebe28c18Daniel Dunbar  /// SupportsProfiling - Does this tool chain support -pg.
181bbe8e3eff56ac1d79f3668d706536e3cebe28c18Daniel Dunbar  virtual bool SupportsProfiling() const { return true; }
182bbe8e3eff56ac1d79f3668d706536e3cebe28c18Daniel Dunbar
18343a9b3263cb0bcb050cc75c15b3e6a8951e6b97aDaniel Dunbar  /// Does this tool chain support Objective-C garbage collection.
18474a63bca21a352319162505dce8310c1d6ed15cdDavid Chisnall  virtual bool SupportsObjCGC() const { return true; }
18543a9b3263cb0bcb050cc75c15b3e6a8951e6b97aDaniel Dunbar
1860a7dd788dbef975f35f273c7ab913f480f7edd60John McCall  /// Complain if this tool chain doesn't support Objective-C ARC.
1870a7dd788dbef975f35f273c7ab913f480f7edd60John McCall  virtual void CheckObjCARC() const {}
1885840dd9a09c458ef894e7d47caab1d90dc4c1112Argyrios Kyrtzidis
189f2d8b9f967a1ab53ee9fdbcc3ac0a4ee0a83a26eDaniel Dunbar  /// UseDwarfDebugFlags - Embed the compile options to clang into the Dwarf
190f2d8b9f967a1ab53ee9fdbcc3ac0a4ee0a83a26eDaniel Dunbar  /// compile unit information.
191f2d8b9f967a1ab53ee9fdbcc3ac0a4ee0a83a26eDaniel Dunbar  virtual bool UseDwarfDebugFlags() const { return false; }
192b2987d159a88ab0ee2e40c884eb4d77b42ab89b6Daniel Dunbar
193b2987d159a88ab0ee2e40c884eb4d77b42ab89b6Daniel Dunbar  /// UseSjLjExceptions - Does this tool chain use SjLj exceptions.
1948aa79947cbf8f0f3ac82cdd36a823ac1bb53cab4Benjamin Kramer  virtual bool UseSjLjExceptions() const { return false; }
19500577ada44c889fbe311d61c51a8da89e65c7c9aDaniel Dunbar
19600577ada44c889fbe311d61c51a8da89e65c7c9aDaniel Dunbar  /// ComputeLLVMTriple - Return the LLVM target triple to use, after taking
19700577ada44c889fbe311d61c51a8da89e65c7c9aDaniel Dunbar  /// command line arguments into account.
19861ab80a8b35e6fe9363e8ef1b3d27209b0e89349Chad Rosier  virtual std::string ComputeLLVMTriple(const ArgList &Args,
19961ab80a8b35e6fe9363e8ef1b3d27209b0e89349Chad Rosier                                 types::ID InputType = types::TY_INVALID) const;
20000577ada44c889fbe311d61c51a8da89e65c7c9aDaniel Dunbar
20100577ada44c889fbe311d61c51a8da89e65c7c9aDaniel Dunbar  /// ComputeEffectiveClangTriple - Return the Clang triple to use for this
20200577ada44c889fbe311d61c51a8da89e65c7c9aDaniel Dunbar  /// target, which may take into account the command line arguments. For
20300577ada44c889fbe311d61c51a8da89e65c7c9aDaniel Dunbar  /// example, on Darwin the -mmacosx-version-min= command line argument (which
20400577ada44c889fbe311d61c51a8da89e65c7c9aDaniel Dunbar  /// sets the deployment target) determines the version in the triple passed to
20500577ada44c889fbe311d61c51a8da89e65c7c9aDaniel Dunbar  /// Clang.
20661ab80a8b35e6fe9363e8ef1b3d27209b0e89349Chad Rosier  virtual std::string ComputeEffectiveClangTriple(const ArgList &Args,
20761ab80a8b35e6fe9363e8ef1b3d27209b0e89349Chad Rosier                                 types::ID InputType = types::TY_INVALID) const;
208641b98b7b52e0067beaf3978f2a8721e5d16c111Daniel Dunbar
209260611a32535c851237926bfcf78869b13c07d5bJohn McCall  /// getDefaultObjCRuntime - Return the default Objective-C runtime
210260611a32535c851237926bfcf78869b13c07d5bJohn McCall  /// for this platform.
2119f084a3166b684573ba49df28fc5792bc37d92e1John McCall  ///
21213db5cfc4e5f03eb70efe0d227b53b8280f16161John McCall  /// FIXME: this really belongs on some sort of DeploymentTarget abstraction
213260611a32535c851237926bfcf78869b13c07d5bJohn McCall  virtual ObjCRuntime getDefaultObjCRuntime(bool isNonFragile) const;
2149f084a3166b684573ba49df28fc5792bc37d92e1John McCall
21513db5cfc4e5f03eb70efe0d227b53b8280f16161John McCall  /// hasBlocksRuntime - Given that the user is compiling with
21613db5cfc4e5f03eb70efe0d227b53b8280f16161John McCall  /// -fblocks, does this tool chain guarantee the existence of a
21713db5cfc4e5f03eb70efe0d227b53b8280f16161John McCall  /// blocks runtime?
21813db5cfc4e5f03eb70efe0d227b53b8280f16161John McCall  ///
21913db5cfc4e5f03eb70efe0d227b53b8280f16161John McCall  /// FIXME: this really belongs on some sort of DeploymentTarget abstraction
22013db5cfc4e5f03eb70efe0d227b53b8280f16161John McCall  virtual bool hasBlocksRuntime() const { return true; }
22113db5cfc4e5f03eb70efe0d227b53b8280f16161John McCall
22288491fc6dfc7ebbd856d57a9acb49fb83077d6c8Chandler Carruth  /// \brief Add the clang cc1 arguments for system include paths.
22388491fc6dfc7ebbd856d57a9acb49fb83077d6c8Chandler Carruth  ///
22488491fc6dfc7ebbd856d57a9acb49fb83077d6c8Chandler Carruth  /// This routine is responsible for adding the necessary cc1 arguments to
22588491fc6dfc7ebbd856d57a9acb49fb83077d6c8Chandler Carruth  /// include headers from standard system header directories.
22688491fc6dfc7ebbd856d57a9acb49fb83077d6c8Chandler Carruth  virtual void AddClangSystemIncludeArgs(const ArgList &DriverArgs,
22788491fc6dfc7ebbd856d57a9acb49fb83077d6c8Chandler Carruth                                         ArgStringList &CC1Args) const;
22888491fc6dfc7ebbd856d57a9acb49fb83077d6c8Chandler Carruth
2298af669f2f1d92436fe6dc43144bb084a620e7516Rafael Espindola  // addClangTargetOptions - Add options that need to be passed to cc1 for
2308af669f2f1d92436fe6dc43144bb084a620e7516Rafael Espindola  // this target.
2318af669f2f1d92436fe6dc43144bb084a620e7516Rafael Espindola  virtual void addClangTargetOptions(ArgStringList &CC1Args) const;
2328af669f2f1d92436fe6dc43144bb084a620e7516Rafael Espindola
233c24767c9dd869ba0e78c2d4c86d86ed24b8e401eDaniel Dunbar  // GetRuntimeLibType - Determine the runtime library type to use with the
234c24767c9dd869ba0e78c2d4c86d86ed24b8e401eDaniel Dunbar  // given compilation arguments.
235c24767c9dd869ba0e78c2d4c86d86ed24b8e401eDaniel Dunbar  virtual RuntimeLibType GetRuntimeLibType(const ArgList &Args) const;
236c24767c9dd869ba0e78c2d4c86d86ed24b8e401eDaniel Dunbar
237641b98b7b52e0067beaf3978f2a8721e5d16c111Daniel Dunbar  // GetCXXStdlibType - Determine the C++ standard library type to use with the
238641b98b7b52e0067beaf3978f2a8721e5d16c111Daniel Dunbar  // given compilation arguments.
239641b98b7b52e0067beaf3978f2a8721e5d16c111Daniel Dunbar  virtual CXXStdlibType GetCXXStdlibType(const ArgList &Args) const;
240641b98b7b52e0067beaf3978f2a8721e5d16c111Daniel Dunbar
241641b98b7b52e0067beaf3978f2a8721e5d16c111Daniel Dunbar  /// AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set
242641b98b7b52e0067beaf3978f2a8721e5d16c111Daniel Dunbar  /// the include paths to use for the given C++ standard library type.
243ab9fcd0ad3202735d5f21f15b2989d65f2747a13Chandler Carruth  virtual void AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
244ab9fcd0ad3202735d5f21f15b2989d65f2747a13Chandler Carruth                                            ArgStringList &CC1Args) const;
245641b98b7b52e0067beaf3978f2a8721e5d16c111Daniel Dunbar
246132e35d2f87895d20e7ea146c8c00404b80221a1Daniel Dunbar  /// AddCXXStdlibLibArgs - Add the system specific linker arguments to use
247641b98b7b52e0067beaf3978f2a8721e5d16c111Daniel Dunbar  /// for the given C++ standard library type.
248132e35d2f87895d20e7ea146c8c00404b80221a1Daniel Dunbar  virtual void AddCXXStdlibLibArgs(const ArgList &Args,
249132e35d2f87895d20e7ea146c8c00404b80221a1Daniel Dunbar                                   ArgStringList &CmdArgs) const;
2507433fedce98a58341d0f30c2e12e8d53f3bba575Shantonu Sen
2517433fedce98a58341d0f30c2e12e8d53f3bba575Shantonu Sen  /// AddCCKextLibArgs - Add the system specific linker arguments to use
2527433fedce98a58341d0f30c2e12e8d53f3bba575Shantonu Sen  /// for kernel extensions (Darwin-specific).
2537433fedce98a58341d0f30c2e12e8d53f3bba575Shantonu Sen  virtual void AddCCKextLibArgs(const ArgList &Args,
2547433fedce98a58341d0f30c2e12e8d53f3bba575Shantonu Sen                                ArgStringList &CmdArgs) const;
255e20e508aecf413f84b0dc4928cbf4bb5ce6c5bdcBenjamin Kramer
256e20e508aecf413f84b0dc4928cbf4bb5ce6c5bdcBenjamin Kramer  /// AddFastMathRuntimeIfAvailable - If a runtime library exists that sets
257e20e508aecf413f84b0dc4928cbf4bb5ce6c5bdcBenjamin Kramer  /// global flags for unsafe floating point math, add it and return true.
258e20e508aecf413f84b0dc4928cbf4bb5ce6c5bdcBenjamin Kramer  ///
259e20e508aecf413f84b0dc4928cbf4bb5ce6c5bdcBenjamin Kramer  /// This checks for presence of the -ffast-math or -funsafe-math flags.
260e20e508aecf413f84b0dc4928cbf4bb5ce6c5bdcBenjamin Kramer  virtual bool AddFastMathRuntimeIfAvailable(const ArgList &Args,
261e20e508aecf413f84b0dc4928cbf4bb5ce6c5bdcBenjamin Kramer                                             ArgStringList &CmdArgs) const;
2622ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar};
2632ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar
2642ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar} // end namespace driver
2652ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar} // end namespace clang
2662ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar
2672ba38ba9a18b8ec88e2509fad622eeec01562769Daniel Dunbar#endif
268